예제 #1
0
function display(&$feed1_title, &$feed1_pubdate, &$feed1_desc, &$totalfeedNews, $feed_rss, $feedFrom, $source)
{
    $colors = new Colors();
    $feed1_title = $colors->getColoredString($feed1_title, "yellow");
    $feed1_desc = $colors->getColoredString($feed1_desc, "blue", "light_gray");
    $source = strtoupper($source);
    $source = $colors->getColoredString($source, "white", "red");
    print $feed1_title;
    print $feed1_pubdate->format('d-m-Y H:i A') . "\n";
    print $feed1_desc;
    print "Source :" . $source . "\n";
}
예제 #2
0
파일: test.php 프로젝트: NSSX/gnlhi
function test_fd()
{
    $colors = new Colors();
    $exec = "./test_gnl 0 0 0";
    $s1 = "-1";
    $s2 = exec($exec);
    if (!strcmp($s1, $s2)) {
        echo $colors->getColoredString("OK\n", "green");
    } else {
        echo $colors->getColoredString("FAIL\n", "red");
        echo "Output should be: <", $s1, ">\nBut is: <", $s2, ">\n";
    }
}
예제 #3
0
function color($str, $fg, $bg)
{
    global $system;
    require_once $_dir['system_lib'] . 'colors.class.php';
    $colors = new Colors();
    return $colors->getColoredString($str, $fg, $bg);
}
예제 #4
0
 private function __probe($filename, $prettify)
 {
     // Start time
     $init = microtime(true);
     // Default options
     $options = '-loglevel quiet -show_format -show_streams -print_format json';
     if ($prettify) {
         $options .= ' -pretty';
     }
     // Avoid escapeshellarg() issues with UTF-8 filenames
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     //$command = sprintf('ffprobe %s %s ', $options, escapeshellarg($filename));
     $command = sprintf('./ffprobe %s "%s" ', $options, $filename);
     // Run the ffprobe, save the JSON output then decode
     $json = json_decode(shell_exec($command), true);
     //if (!isset($json->format))
     if (!isset($json['format'])) {
         //throw new Exception('Unsupported file type: '.$filename."\r\nCommand:\r\n".$command."\r\n");
         $output = 'ffprobe: Unsupported file type: ' . $filename . "\r\nCommand:\r\n" . $command . "\r\n";
         $colors = new Colors();
         $colors->getColoredString($output, 'black', 'red');
         //The command finished with an error.
         $error = R::dispense('error');
         //$video->ownError = array($error);
         $error->raw_output = $output;
         $error->repaired = false;
         $id = R::store($error);
     }
     // Save parse time (milliseconds)
     $this->parse_time = round((microtime(true) - $init) * 1000);
     return $json;
 }
예제 #5
0
function _recurse_output($OUTPUT, $depth = 0, $color = false)
{
    if ($color) {
        require_once "helper_functions/colors.php";
        $colors = new Colors();
    }
    $i = 0;
    $keys = array_keys($OUTPUT);
    while ($i < count($OUTPUT)) {
        if (is_array($OUTPUT[$keys[$i]])) {
            $j = 0;
            while ($j < $depth) {
                echo "  ";
                $j++;
            }
            if ($color) {
                echo $colors->getColoredString($keys[$i], "red") . ":\r\n";
            } else {
                echo (string) $keys[$i] . ":\r\n";
            }
            _recurse_output($OUTPUT[$keys[$i]], $depth + 1, $color);
        } else {
            $j = 0;
            while ($j < $depth) {
                echo "  ";
                $j++;
            }
            if ($color) {
                $out = $colors->getColoredString((string) $keys[$i], "light_red");
                $out .= ": ";
                $out .= $colors->getColoredString((string) $OUTPUT[$keys[$i]], "blue");
                $out .= "\r\n";
                echo $out;
            } else {
                echo (string) $keys[$i] . ": " . (string) $OUTPUT[$keys[$i]] . "\r\n";
            }
        }
        $i++;
    }
}
$file = file_get_contents($filename);
$lines = explode("\n", $file);
$outputFilename = '/Users/Anthony/Desktop/Library Exports/Secondary All Wrong.csv';
$outputFile = fopen($outputFilename, "w+");
foreach ($lines as $lineNumber => $line) {
    $fields = explode(',', $line);
    foreach ($fields as &$field) {
        $field = trim($field, '"');
    }
    if (stripos($fields[9], 'Student') === false) {
        continue;
    }
    if (substr($fields[0], 0, 2) !== 'P ') {
        $str = "\nInvalid barcode format: Line " . $lineNumber . " '" . $fields[0] . "'";
        fwrite($outputFile, "\n" . $line);
        echo $colors->getColoredString($str, 'red');
        continue;
    }
    $idnumber = substr($fields[0], 2);
    $q = $db->prepare('SELECT * FROM ssismdl_user WHERE idnumber = ?');
    $q->execute(array($idnumber));
    if ($user = $q->fetch(PDO::FETCH_OBJ)) {
        $str = "\nBarcode {$fields[0]} matches DragonNet user " . $user->username;
        echo $colors->getColoredString($str, 'green');
    } else {
        $str = "\nUser not found on DragonNet: Line " . $lineNumber . " " . $fields[0];
        fwrite($outputFile, "\n" . $line);
        echo $colors->getColoredString($str, 'purple');
    }
    /*if ($fields[0][0] == 'P' && (stripos($fields[9], 'Student') === false) && $fields[9] != 'Parent') {
    		echo "\n" . $line;
예제 #7
0
파일: ofen.php 프로젝트: nemiah/fheME
function cb_temp($temperature)
{
    $temperature /= 10.0;
    static $temps = array();
    static $times = array();
    static $bingsBad = 0;
    static $bingsGood = 0;
    $temps[] = $temperature;
    $times[] = time();
    if (count($temps) > 600) {
        array_shift($temps);
        array_shift($times);
    }
    $maxK = null;
    $maxV = 0;
    foreach ($temps as $k => $v) {
        if ($v > $maxV) {
            $maxK = $k;
            $maxV = $v;
        }
    }
    $temperature = floor($temperature);
    system('clear');
    $trend = "▬";
    if (count($temps) > 3) {
        $v = leastSquareFit(array_slice($temps, -30));
        if ($v > 0) {
            $trend = "▲";
        }
        if ($v <= 0) {
            $trend = "▼";
        }
    }
    $t = " " . date("H:i:s") . ": " . str_pad($temperature, 5, " ", STR_PAD_LEFT) . " °C {$trend} ";
    $C = new Colors();
    if ($temperature < 80) {
        echo $C->getColoredString($t, "white", "red");
        if ($bingsBad < 3) {
            exec('play /usr/share/sounds/KDE-Sys-Log-Out.ogg > /dev/null 2>&1');
        }
        $bingsGood = 0;
        $bingsBad++;
    } else {
        echo $C->getColoredString($t, "green", "black");
        if ($bingsGood < 1) {
            exec('play /usr/share/sounds/KDE-Sys-App-Positive.ogg > /dev/null 2>&1');
        }
        $bingsBad = 0;
        $bingsGood++;
    }
    echo "\n Max: " . date("H:i:s", $times[$maxK]) . ": " . $maxV . " °C";
}
 public function logSeparator()
 {
     $colors = new Colors();
     $message = $colors->getColoredString("\n\n------------------------------------------------------------", "white", "black") . ' ';
     $this->log($message);
 }
예제 #9
0
파일: col.php 프로젝트: Beertie/web_scraper
    // Returns colored string
    public function getColoredString($string, $foreground_color = null, $background_color = null)
    {
        $colored_string = "";
        // Check if given foreground color found
        if (isset($this->foreground_colors[$foreground_color])) {
            $colored_string .= "[" . $this->foreground_colors[$foreground_color] . "m";
        }
        // Check if given background color found
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "[" . $this->background_colors[$background_color] . "m";
        }
        // Add string and end coloring
        $colored_string .= $string . "";
        return $colored_string;
    }
    // Returns all foreground color names
    public function getForegroundColors()
    {
        return array_keys($this->foreground_colors);
    }
    // Returns all background color names
    public function getBackgroundColors()
    {
        return array_keys($this->background_colors);
    }
}
// example usage:
$colors = new Colors();
echo $colors->getColoredString("some string", "white", "black");
// will echo some white text against black background
예제 #10
0
파일: scan.php 프로젝트: nexylan/phpav
        $input = fgets($handle);
        if (trim($input) == 'y') {
            exec("patch {$file} < fix.patch");
            unlink('fix.patch');
            unlink("{$file}.fixed");
        } else {
            echo 'No patch applied';
        }
    }
    unlink('fix.patch');
}
// Main(void)
if (empty($argv[1])) {
    die("Usage: php find.php directory_to_scan > infected.txt\n");
} else {
    echo $colors->getColoredString('Scanning ' . $argv[1] . " for potential obfuscated malware...\n\n", 'green');
    $data = array();
    $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($argv[1]), RecursiveIteratorIterator::SELF_FIRST);
    // Grab array of the entire structures of $argv[1] (a directory)
    $c = 0;
    // Counter for files processed
    $f = 0;
    // Counter for files with potential malware
    // Preload data
    $shells = file(dirname(__FILE__) . '/data/webshells.txt');
    foreach ($files as $file) {
        //if (($c % 10000) == 0 && $c > 0) { // Display status for every 10,000 files
        //echo $colors->getColoredString("Processed " . $c . " files, found " . $f . "\n","purple");
        //}
        if (is_dir($file) === true) {
            // Not in use, was used to check directory traversal was working properly
        if (isset($this->background_colors[$background_color])) {
            $colored_string .= "[" . $this->background_colors[$background_color] . "m";
        }
        // Add string and end coloring
        $colored_string .= $string . "";
        return $colored_string;
    }
    // Returns all foreground color names
    public function getForegroundColors()
    {
        return array_keys($this->foreground_colors);
    }
    // Returns all background color names
    public function getBackgroundColors()
    {
        return array_keys($this->background_colors);
    }
}
?>

<?php 
//Colors class basic usage examples
// Create new Colors class
$colors = new Colors();
// Test some basic printing with Colors class
echo $colors->getColoredString("Testing Colors class, this is purple string on yellow background.", "purple", "yellow") . "\n";
echo $colors->getColoredString("Testing Colors class, this is blue string on light gray background.", "blue", "light_gray") . "\n";
echo $colors->getColoredString("Testing Colors class, this is red string on black background.", "red", "black") . "\n";
echo $colors->getColoredString("Testing Colors class, this is cyan string on green background.", "cyan", "green") . "\n";
echo $colors->getColoredString("Testing Colors class, this is cyan string on default background.", "cyan") . "\n";
echo $colors->getColoredString("Testing Colors class, this is default string on cyan background.", null, "cyan") . "\n";
예제 #12
0
 public function printColorArray($color_ary)
 {
     $s = '';
     $clr = new Colors();
     foreach ($color_ary as $i => $ct) {
         foreach ($ct as $color => $text) {
             if (!empty($text)) {
                 if ($color == 'gray') {
                     $color = null;
                 }
                 $s .= $clr->getColoredString($text, $color, 'black');
             }
         }
     }
     return $s;
 }
예제 #13
0
 $filename = explode('.', $filename);
 $filename = $filename[0] . '.mp4';
 $filepath = $GLOBALS['transcode_to'] . $filepath[3] . '/' . $filepath[4] . '/' . $filepath[5] . '/' . $filepath[6] . '/';
 if (!file_exists($filepath)) {
     mkdir($filepath, 0777, true);
 }
 $filename = $filepath . str_replace(' ', '_', $filename);
 $output = $filename;
 $options = false;
 if (strstr($video->definition, 'HD')) {
     $options = $GLOBALS['transcode_options_hd'];
 } else {
     $options = $GLOBALS['transcode_options_sd'];
 }
 if ($options) {
     echo $colors->getColoredString("transcoding {$video->id} {$video->definition}\r\n\t{$video->filename}\r\n\tto\t\r\n\t{$output}\r\n", 'red');
     $command = sprintf('./ffmpeg -i "%s" %s "%s" ', $video->filename, $options, $output);
     echo $colors->getColoredString("\tRunning\r\n\t" . $command . "\r\n", 'blue');
     //Real time output
     //from http://stackoverflow.com/questions/8370628/php-shell-exec-with-realtime-updating
     if ($fp = popen($command, "r")) {
         $output = '';
         while (!feof($fp)) {
             $temp = fread($fp, 1024);
             $output .= $temp;
             echo $temp;
             flush();
             // you have to flush buffer
         }
         if (!pclose($fp)) {
             //The command finished with an error.
예제 #14
0
/**
 *  Outputs a $message to STDOUT and log file, color-coded depending on $case.
 *  @param $message - the message to log
 *  @param $case - the type of severity and reson to log, the message will be color-coded accordingly, the cases are:
 *          userConnected, userDisconnected, addedItem, updatedItem, removedItem, clearedList, synced, error, warn
 */
function logMsg($message, $level = "default")
{
    $colors = new Colors();
    $fg = null;
    $bg = null;
    switch ($level) {
        case 'userConnected':
            $fg = null;
            $bg = "cyan";
            break;
        case 'userDisconnected':
            $fg = "cyan";
            $bg = "black";
            break;
        case 'addedItem':
            $fg = "black";
            $bg = "green";
            break;
        case 'updatedItem':
            $fg = "light_gray";
            $bg = "green";
            break;
        case 'clearedList':
            $fg = "light_gray";
            $bg = "black";
            break;
        case 'removedItem':
            $fg = "yellow";
            $bg = "black";
            break;
        case 'error':
            $fg = "white";
            $bg = "red";
            break;
        case 'warn':
            $fg = "brown";
            $bg = "magenta";
            break;
        case 'sync':
            $fg = "light_green";
            $bg = "blue";
            break;
        default:
            break;
    }
    echo $colors->getColoredString($message, $fg, $bg) . "\n<br>";
    echo GetCallingMethodName();
    date_default_timezone_set('Europe/Stockholm');
    file_put_contents("/var/www/shoppinglist/logs/logFile", date("{Y-m-d H:i:s}") . " " . $message . "\n", FILE_APPEND);
}
예제 #15
0
    static $spinnerChars = array();
    if (!$spinnerChars) {
        $spinnerChars = explode(' ', '| / - \\ | / - \\');
    }
    static $spinnerPhase = 0;
    static $terminalLineLength = 80;
    // Clear line
    echo "\r" . str_repeat(' ', $terminalLineLength);
    // Show spinner phase and status
    $time = $timer->get();
    if ($time >= 1) {
        $timeSpent = timeIntervalStr($timer->get());
    } else {
        $timeSpent = '-';
    }
    $timeSpentText = $GColors->getColoredString("[{$timeSpent}]", $GTimeTextColor);
    $statusText = $GColors->getColoredString($GStatusText, $GStatusTextColor);
    $memUsage = formatBytes(memory_get_usage(true));
    $memUsageText = $GColors->getColoredString("[{$memUsage}]", 'yellow');
    echo "\r{$spinnerChars[$spinnerPhase]} {$timeSpentText} {$memUsageText} {$statusText}";
    // Change phase
    $spinnerPhase = $spinnerPhase < count($spinnerChars) - 1 ? $spinnerPhase + 1 : 0;
});
$GScriptTimer = new Timer(1);
register_shutdown_function(function () use($GScriptTimer, $GColors) {
    $time = $GScriptTimer->get();
    if ($time >= 1) {
        $timeSpent = timeIntervalStr($time);
    } else {
        $timeSpent = 'less then a second';
    }
예제 #16
0
/**
 *  Outputs a $message to STDOUT and log file, color-coded depending on $case.
 *  @param $message - the message to log
 *  @param $case - the type of severity and reson to log, the message will be color-coded accordingly, the cases are:
 *          userConnected, userDisconnected, addedItem, updatedItem, removedItem, clearedList, synced, error, warn
 */
function logMsg($message, $level = "default")
{
    $colors = new Colors();
    $fg = null;
    $bg = null;
    switch ($level) {
        case 'userConnected':
            $fg = null;
            $bg = "cyan";
            break;
        case 'userDisconnected':
            $fg = "cyan";
            $bg = "black";
            break;
        case 'addedItem':
            $fg = "black";
            $bg = "green";
            break;
        case 'updatedItem':
            $fg = "light_gray";
            $bg = "green";
            break;
        case 'clearedList':
            $fg = "light_gray";
            $bg = "black";
            break;
        case 'removedItem':
            $fg = "yellow";
            $bg = "black";
            break;
        case 'error':
            $fg = "white";
            $bg = "red";
            break;
        case 'warn':
            $fg = "brown";
            $bg = "magenta";
            break;
        case 'sync':
            $fg = "light_green";
            $bg = "blue";
            break;
        default:
            break;
    }
    echo $colors->getColoredString($message, $fg, $bg) . "\n";
}
예제 #17
0
<?php

include_once 'settings.php';
include_once 'cli_colors.php';
$colors = new Colors();
$errors = R::find('error');
$count = 0;
foreach ($errors as $error) {
    echo $colors->getColoredString(" id: " . $error - id, 'black', 'red') . "\r\n";
    echo $error->raw_output . "\r\n";
    $count++;
}
echo "\r\n" . $count . " errors found\r\n";