Example #1
0
File: user.php Project: skoning/ums
    public static function listUsers()
    {
        /** @var PDO $db */
        $db = self::$db;
        $all = User::getListUsers();
        ?>
		<table>
		<tr>
			<th>#</th>
			<th>Username</th>
			<th>Firstname</th>
			<th>Lastname</th>
			<th colspan="2">Edit</th>
		</tr>
		<?php 
        foreach ($all as $user) {
            vprintf('
				<tr>
					<td>%1$d</td>
				 	<td>%2$d</td>
					<td>%3$s</td>
					<td>%4$s</td>
					<td><a href="?delete=%1$d">X</a></td>
					<td><a href="?edit=%1$d">Edit</a></td>
				</tr>', array($user->id, $user->username, $user->firstname, $user->lastname));
        }
        echo '</table>';
    }
Example #2
0
function println()
{
    global $indent;
    $args = func_get_args();
    $str = array_shift($args);
    vprintf(str_repeat('  ', $indent) . $str . "\n", $args);
}
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $selector = $input->getArgument('selector');
     if (!$selector) {
         $containers = $this->application->getController()->getContainers();
     } else {
         $containers = $this->application->getController()->selectContainers($selector);
     }
     $l = Formatter::calculateNamelength($containers) + 1;
     $FORMAT = "%{$l}s %s\n";
     printf($FORMAT, 'Name', 'Tags');
     array_walk($containers, function (&$container, $key) use($FORMAT) {
         $tags = $container->getTags();
         if (empty($tags)) {
             vprintf($FORMAT, array($container->getName(), '<none>'));
         }
         foreach ($tags as $key => $tag) {
             if ($key === 0) {
                 vprintf($FORMAT, array($container->getName(), $tag));
             } else {
                 vprintf($FORMAT, array('', $tag));
             }
         }
     });
 }
Example #4
0
 /**
  * @param string $format format string for the given arguments. Passed as is
  *                     to <code>vprintf</code>.
  * @param array  $args   array of arguments to pass to vsprinf.
  * @param int    $debug_level debug level at which to print this statement
  * @return boolean true
  */
 static function debug($format, $args, $debug_level = self::DEBUG1)
 {
     if (self::is_debug($debug_level)) {
         vprintf($format . "\n", $args);
     }
     return true;
 }
Example #5
0
function writefln($fmt)
{
    $args = func_get_args();
    array_shift($args);
    vprintf($fmt, $args);
    echo PHP_EOL;
}
Example #6
0
 /**
  * Print a formatted message
  *
  * @param string $message sprintf-formatted message
  *
  * @return void
  */
 public static function printMessage($message)
 {
     $args = func_get_args();
     /* remove first argument, which is $message */
     array_splice($args, 0, 1);
     vprintf($message, $args);
 }
Example #7
0
 function __($key)
 {
     global $_LANG_POT;
     if (!isset($_LANG_POT[$key])) {
         $_LANG_POT[$key] = $key;
     }
     vprintf($_LANG_POT[$key], array_slice(func_get_args(), 1));
 }
Example #8
0
 /**
  * Log Handling
  */
 public function log($type, $args)
 {
     $args[0] .= ' in ' . get_class($this);
     if (is_a($this->log, 'NyaaLog')) {
         return call_user_func_array(array($this->log, $type), $args);
     }
     vprintf("[{$type}] %s<br />\n", vsprintf($args[0], array_slice($args, 1)));
 }
Example #9
0
File: quiz.php Project: n2i/xvnkb
 function show()
 {
     $choices = array();
     foreach ($this->choices as $c) {
         $choices[] = str_replace("\n", '|||', str_replace("'", '~~~', $c));
     }
     vprintf("SFQuiz = {id: '%s', question: '%s', choices: '%s', answer: %d}", array($this->id, str_replace("\n", '|||', str_replace("'", '~~~', $this->question)), implode(",", $choices), $this->answer));
 }
Example #10
0
function dprintf()
{
    if (($_SERVER["REMOTE_ADDR"] == "94.169.97.53" || $_SERVER["REMOTE_ADDR"] == "80.45.72.211") && SHOW_DEBUGGING) {
        $argv = func_get_args();
        $format = array_shift($argv);
        printf('<p class="debug">[%4.3f] ', curScriptTime());
        vprintf($format, $argv);
        printf('</p>');
    }
}
 /**
  * Global translate function # 3
  * This function performs print OR vprintf on a translated String
  *
  * @param string $key
  * @param array|null $args
  */
 function __p(string $key, array $args = null)
 {
     $translated = Translator::getInstance()->translate($key);
     if (is_string($translated)) {
         if (is_array($args)) {
             vprintf($translated, $args);
         } else {
             print $translated;
         }
     }
 }
Example #12
0
/**
 * output markup to be displayed in the admin panel
 */
function teaberry_admin_header_image()
{
    ?>

    <div id="headimg">

    <?php 
    $image = get_header_image();
    if (!empty($image)) {
        $header = array('image' => esc_url($image), 'class' => 'header-image', 'width' => get_custom_header()->width, 'height' => get_custom_header()->height);
        vprintf('<img src="%s" class="%s" width="%s" height="%s" alt="" />', $header);
    }
    ?>

    </div>

<?php 
}
  /**
   * Outputs some debug information about the current response.
   *
   * @param string $realOutput Whether to display the actual content of the response when an error occurred
   *                           or the exception message and the stack trace to ease debugging
   */
  public function debug($realOutput = false)
  {
    print $this->tester->error('Response debug');

    if (!$realOutput && null !== sfException::getLastException())
    {
      // print the exception and the stack trace instead of the "normal" output
      $this->tester->comment('WARNING');
      $this->tester->comment('An error occurred when processing this request.');
      $this->tester->comment('The real response content has been replaced with the exception message to ease debugging.');
    }

    printf("HTTP/1.X %s\n", $this->response->getStatusCode());

    foreach ($this->response->getHttpHeaders() as $name => $value)
    {
      printf("%s: %s\n", $name, $value);
    }

    foreach ($this->response->getCookies() as $cookie)
    {
      vprintf("Set-Cookie: %s=%s; %spath=%s%s%s%s\n", array(
        $cookie['name'],
        $cookie['value'],
        null === $cookie['expire'] ? '' : sprintf('expires=%s; ', date('D d-M-Y H:i:s T', $cookie['expire'])),
        $cookie['path'],
        $cookie['domain'] ? sprintf('; domain=%s', $cookie['domain']) : '',
        $cookie['secure'] ? '; secure' : '',
        $cookie['httpOnly'] ? '; HttpOnly' : '',
      ));
    }

    echo "\n";
    if (!$realOutput && null !== $exception = sfException::getLastException())
    {
      echo $exception;
    }
    else
    {
      echo $this->response->getContent();
    }
    echo "\n";
  }
Example #14
0
 function init()
 {
     global $FANNIE_URL;
     $this->add_script($FANNIE_URL . 'src/javascript/jquery.js');
     $this->add_script($FANNIE_URL . 'src/javascript/jquery-ui.js');
     $this->add_css_file($FANNIE_URL . "src/javascript/jquery-ui.css");
     ob_start();
     vprintf('
         <a href="%s">Home</a>
         &nbsp;&nbsp;&nbsp;&nbsp;
         <a href="%s&mode=view">View</a>
         &nbsp;&nbsp;&nbsp;&nbsp;
         <a href="%s&mode=receive">Add</a>
         &nbsp;&nbsp;&nbsp;&nbsp;
         <a href="%s&mode=sale">Use</a>
         &nbsp;&nbsp;&nbsp;&nbsp;
         <a href="%s&mode=adjust">Adjust</a>
         &nbsp;&nbsp;&nbsp;&nbsp;
         <a href="%s&mode=import">Import</a>
         &nbsp;&nbsp;&nbsp;&nbsp;
         ', array_fill(0, 6, 'Brewventory.php'));
     return ob_get_clean();
 }
Example #15
0
function printUnknown($file)
{
    fseek($file, 0x6a616);
    $output = [];
    $totals = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    for ($i = 0; $i < 32; $i++) {
        for ($j = 1; $j < 100; $j++) {
            $output[$i][$j] = ord(fgetc($file));
        }
    }
    echo 'LV | 00  01  02  03  04  05  06  07  08  09  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31 ' . PHP_EOL;
    echo '------------------------------------------------------------------------------------------------------------------------------------' . PHP_EOL;
    for ($i = 1; $i < 100; $i++) {
        printf('%02d | ', $i);
        foreach ($output as $k => $levelarray) {
            $totals[$k] += $levelarray[$i];
            $totals[$k] = min($totals[$k], 999);
            printf('%02d  ', $levelarray[$i]);
        }
        echo PHP_EOL;
    }
    echo '------------------------------------------------------------------------------------------------------------------------------------' . PHP_EOL;
    vprintf('TOT| %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d', $totals);
}
 /**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args     Widget arguments.
  * @param array $instance Saved values from database.
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', $instance['title']);
     if ($instance['width'] == 0) {
         $width = null;
     } else {
         $width = 'width="' . $instance['width'] . '"';
     }
     if ($instance['height'] == 0) {
         $height = null;
     } else {
         $height = 'height="' . $instance['height'] . '"';
     }
     echo $args['before_widget'];
     if (!empty($title)) {
         echo str_replace('<h3>', '<h3 class="pinterest">', $args['before_title']) . $title . $args['after_title'];
     }
     // Download RSS
     $things = $this->download_rss($instance['username'], $instance['number'], $instance['cache-time']);
     if (is_null($things)) {
         printf('Unable to load Pinterest pins for %s', $instance['username']);
     } else {
         echo '<ul class="latest-works pinterest">';
         foreach ($things as $thing) {
             array_push($thing, $width);
             array_push($thing, $height);
             vprintf('<li><a href="%s" rel="external nofollow"><img src="%s" alt="%s" %s %s /></a></li>', $thing);
             // may we can use style="height:auto; width:auto; max-width:%dpx; max-height:%dpx;" ?
         }
         echo '</ul>';
         if ($instance['follow-text'] != '') {
             printf('<a class="view-all" href="http://pinterest.com/%s/" rel="">%s</a>', $instance['username'], $instance['follow-text']);
         }
     }
     echo $args['after_widget'];
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($selector = $input->getArgument('selector')) {
         $containers = $this->application->getController()->selectContainers($selector);
     } else {
         $containers = $this->application->getController()->getContainers();
     }
     $namelength = Formatter::calculateNamelength($containers) + 1;
     $FORMAT = "%2s %{$namelength}s %6s %8s %12s %12s %12s %18s %10s %10s\n";
     printf($FORMAT, ' ', 'Name', 'Tasks', 'Rss', 'User time', 'System time', 'Uptime', 'IP', 'Upload', 'Download');
     foreach ($containers as $container) {
         $r = array('state' => '', 'name' => '', 'tasks' => 'n/a', 'rss' => 'n/a', 'usertime' => 'n/a', 'systemtime' => 'n/a', 'uptime' => 'n/a', 'ip' => 'n/a', 'upload' => 'n/a', 'download' => 'n/a');
         $r['name'] = $container->getName();
         $state = $container->getState();
         if ($state == 'RUNNING') {
             $r['state'] = \Console_Color::convert(' %g>>%n');
         } else {
             if ($state == 'STOPPED') {
                 $r['state'] = \Console_Color::convert(' %b--%n');
             }
         }
         if ($state == 'RUNNING') {
             $r['tasks'] = count($container->getTasks());
             $r['rss'] = Formatter::formatBytes($container->getRss());
             $r['uptime'] = Formatter::formatTime($container->getUptime());
             $times = $container->getCpuTimes();
             $r['systemtime'] = Formatter::formatTime($times['system']);
             $r['usertime'] = Formatter::formatTime($times['user']);
             $r['ip'] = $container->getIp();
             $traffic = $container->getTraffic();
             $r['upload'] = Formatter::formatBytes($traffic['upload']);
             $r['download'] = Formatter::formatBytes($traffic['download']);
         }
         vprintf($FORMAT, $r);
     }
 }
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($selector = $input->getArgument('selector')) {
         $containers = $this->application->getController()->selectContainers($selector);
     } else {
         $containers = $this->application->getController()->getContainers();
     }
     $namelength = Formatter::calculateNamelength($containers) + 1;
     $FORMAT = "%2s %{$namelength}s\n";
     printf($FORMAT, ' ', 'Name');
     foreach ($containers as $container) {
         $r = array('state' => '', 'name' => '');
         $r['name'] = $container->getName();
         $state = $container->getState();
         if ($state == 'RUNNING') {
             $r['state'] = \Console_Color::convert(' %g>>%n');
         } else {
             if ($state == 'STOPPED') {
                 $r['state'] = \Console_Color::convert(' %b--%n');
             }
         }
         vprintf($FORMAT, $r);
     }
 }
Example #19
0
File: login.php Project: reZo/Tiger
 *
 * @author    Gareth Stones <*****@*****.**>
 * @copyright 5th December 2007
 */
$continue = true;
if (methodCheck(FILE) == true) {
    $clean = array();
    foreach ($_POST as $key => $value) {
        if (in_array($key, $allow[FILE]) == false || ($clean[$key] = new SecureData($value)) == false || $clean[$key]->isValid == false) {
            unset($clean);
            require_once DIR_COMPONENT . FILE . '/error.php';
            break 2;
        }
    }
    $query = null;
    $query = vprintf('CALL login_user ("%s", "%s")', $clean);
    unset($clean);
    $result = null;
    try {
        $result = $mysql->query($query);
        unset($query);
        if ($result->num_rows == 1 && ($row = $result->fetch_assoc()) == true && $row['success'] == 1) {
            $continue = false;
            require_once DIR_COMPONENT . FILE . '/success.php';
        }
    } catch (MySQLException $e) {
        require_once DIR_COMPONENT . FILE . '/error.php';
    }
}
if ($continue == true) {
    $content->display(FILE);
Example #20
0
function printLn($string)
{
    $vars = func_get_args();
    array_shift($vars);
    vprintf('>>> ' . $string . PHP_EOL, $vars);
}
 function debug($fmt)
 {
     $fmt = date('H:i:s') . ' ' . $fmt . PHP_EOL;
     $args = array_slice(func_get_args(), 1);
     if (!empty($args)) {
         vprintf($fmt, $args);
     } else {
         echo $fmt;
     }
 }
}
?>
</h2>

<div>
	<div class="user-card">
		<div class="user-avatar"><img src="<?php 
echo $user->get_avatar();
?>
" /> </div>

		<dl class="user-info">
			<dd><?php 
$locale_keys = array_keys($locales);
if (1 < count($locales)) {
    vprintf(__('%s is a polyglot who knows %s but also knows %s.'), array_merge(array($user->display_name), $locale_keys));
} else {
    if (!empty($locale_keys)) {
        printf(__('%s is a polyglot who contributes to %s'), $user->display_name, $locale_keys[0]);
    }
}
?>
</dd>
			<dt><?php 
_e('Member Since');
?>
</dt>
			<dd><?php 
echo date('M j, Y', strtotime($user->user_registered));
?>
</dd>
Example #23
0
 /**
  * Print the run info 
  * 
  * @param  int    $startTime 
  * @access public
  * @return void
  */
 public function printRunInfo($startTime)
 {
     vprintf($this->lang->runInfo, $this->common->getRunInfo($startTime));
 }
Example #24
0
    $message = trim($message);
    if ($message) {
        $ansi_codes = implode('|', array_keys($ansi));
        if (preg_match_all('/#\\{((?:(?:' . $ansi_codes . '),?)+):(.+?)\\}/s', $message, $matches, PREG_SET_ORDER)) {
            foreach ($matches as $match) {
                $chunk = '';
                $codes = explode(',', $match[1]);
                foreach ($codes as $code) {
                    $chunk .= "[{$ansi[$code]}m";
                }
                $chunk .= $match[2] . "[{$ansi[off]}m";
                $message = str_replace($match[0], $chunk, $message);
            }
        }
        $args = array_slice(func_get_args(), 1);
        vprintf($message . "\n", $args);
    }
};
$log_if = function ($condition, $message) use($log) {
    if ($condition) {
        call_user_func_array($log, array_slice(func_get_args(), 1));
    }
};
// Prepare line highlighter
$highlight = function ($content, $variable) {
    $lines = explode("\n", $content);
    $result = array();
    foreach ($lines as $index => $line) {
        if (strpos($line, $variable) === false) {
            continue;
        }
Example #25
0
function printf_and_exit()
{
    $args = func_get_args();
    vprintf($args[0], array_slice($args, 1));
    exit;
}
Example #26
0
 /**
  * Prints a result set.
  *
  * @param array   $count
  * @param boolean $printTests
  */
 public function printResult(array $count, $printTests)
 {
     $args = array();
     $format = '';
     if ($count['directories'] > 0) {
         $format .= "Directories:                                 %10d\n" . "Files:                                       %10d\n\n";
         $args[] = $count['directories'];
         $args[] = $count['files'];
     }
     $format .= "Lines of Code (LOC):                         %10d\n" . "  Cyclomatic Complexity / Lines of Code:     %10.2f\n";
     $args[] = $count['loc'];
     $args[] = $count['ccnByLoc'];
     if (isset($count['eloc'])) {
         $format .= "Executable Lines of Code (ELOC):             %10d\n";
         $args[] = $count['eloc'];
     }
     $format .= "Comment Lines of Code (CLOC):                %10d\n" . "Non-Comment Lines of Code (NCLOC):           %10d\n\n" . "Namespaces:                                  %10d\n" . "Interfaces:                                  %10d\n" . "Traits:                                      %10d\n" . "Classes:                                     %10d\n" . "  Abstract:                                  %10d (%.2f%%)\n" . "  Concrete:                                  %10d (%.2f%%)\n" . "  Average Class Length (NCLOC):              %10d\n" . "Methods:                                     %10d\n" . "  Scope:\n" . "    Non-Static:                              %10d (%.2f%%)\n" . "    Static:                                  %10d (%.2f%%)\n" . "  Visibility:\n" . "    Public:                                  %10d (%.2f%%)\n" . "    Non-Public:                              %10d (%.2f%%)\n" . "  Average Method Length (NCLOC):             %10d\n" . "  Cyclomatic Complexity / Number of Methods: %10.2f\n\n" . "Anonymous Functions:                         %10d\n" . "Functions:                                   %10d\n\n" . "Constants:                                   %10d\n" . "  Global constants:                          %10d\n" . "  Class constants:                           %10d\n";
     $args[] = $count['cloc'];
     $args[] = $count['ncloc'];
     $args[] = $count['namespaces'];
     $args[] = $count['interfaces'];
     $args[] = $count['traits'];
     $args[] = $count['classes'];
     $args[] = $count['abstractClasses'];
     $args[] = $count['classes'] > 0 ? $count['abstractClasses'] / $count['classes'] * 100 : 0;
     $args[] = $count['concreteClasses'];
     $args[] = $count['classes'] > 0 ? $count['concreteClasses'] / $count['classes'] * 100 : 0;
     $args[] = $count['nclocByNoc'];
     $args[] = $count['methods'];
     $args[] = $count['nonStaticMethods'];
     $args[] = $count['methods'] > 0 ? $count['nonStaticMethods'] / $count['methods'] * 100 : 0;
     $args[] = $count['staticMethods'];
     $args[] = $count['methods'] > 0 ? $count['staticMethods'] / $count['methods'] * 100 : 0;
     $args[] = $count['publicMethods'];
     $args[] = $count['methods'] > 0 ? $count['publicMethods'] / $count['methods'] * 100 : 0;
     $args[] = $count['nonPublicMethods'];
     $args[] = $count['methods'] > 0 ? $count['nonPublicMethods'] / $count['methods'] * 100 : 0;
     $args[] = $count['nclocByNom'];
     $args[] = $count['ccnByNom'];
     $args[] = $count['anonymousFunctions'];
     $args[] = $count['functions'];
     $args[] = $count['constants'];
     $args[] = $count['globalConstants'];
     $args[] = $count['classConstants'];
     if ($printTests) {
         $format .= "\nTests:\n  Classes:                                   %10d\n" . "  Methods:                                   %10d\n";
         $args[] = $count['testClasses'];
         $args[] = $count['testMethods'];
     }
     vprintf($format, $args);
 }
Example #27
0
 /**
  * @param string $format
  * @param array  ...$variables
  * @return BodyFetcher
  */
 private function println(string $format, ...$variables) : self
 {
     $format .= PHP_EOL;
     vprintf($format, $variables);
     return $this;
 }
Example #28
0
<?php

/* Prototype  : string vprintf(string format, array args)
 * Description: Output a formatted string 
 * Source code: ext/standard/formatted_print.c
*/
/*
 * Test vprintf() when different unsigned formats and unsigned values
 * are passed to the '$format' and '$args' arguments of the function
*/
echo "*** Testing vprintf() : unsigned formats and unsigned values ***\n";
// defining array of unsigned formats
$formats = array('%u %+u %-u', '%lu %Lu %4u %-4u', '%10.4u %-10.4u %.4u', '%\'#2u %\'2u %\'$2u %\'_2u', '%3$u %4$u %1$u %2$u');
// Arrays of unsigned values for the format defined in $format.
// Each sub array contains unsigned values which correspond to each format string in $format
$args_array = array(array(1234567, 01234567, 0), array(12345678900, 12345678900, 1234, 12345), array("1234000", 101234567000.0, 120.0), array(1, 0, 00, "10_"), array(3, 4, 1, 2));
// looping to test vprintf() with different unsigned formats from the above $format array
// and with signed and other types of  values from the above $args_array array
$counter = 1;
foreach ($formats as $format) {
    echo "\n-- Iteration {$counter} --\n";
    $result = vprintf($format, $args_array[$counter - 1]);
    echo "\n";
    var_dump($result);
    $counter++;
}
?>
===DONE===
Example #29
0
function println()
{
    $args = func_get_args();
    $fmt = array_shift($args);
    vprintf($fmt . "\n", $args);
}
Example #30
0
 /**
  * Conditionally output a warning.
  *
  * This method works just like printf() except that it prepends the
  * output with the string 'Warning: ', terminates the output with a
  * newline, and that it only outputs something if the PEL_DEBUG
  * defined to some true value.
  *
  * @param string $format
  *            the format string.
  *
  * @param mixed $args,...
  *            any number of arguments can be given. The
  *            arguments will be available for the format string as usual with
  *            sprintf().
  */
 public static function warning()
 {
     if (self::$debug) {
         $args = func_get_args();
         $str = array_shift($args);
         vprintf('Warning: ' . $str . "\n", $args);
     }
 }