/**
  * Return the locale of the client browser
  * @param string $language The language of the browser
  * @return string The locale of the client
  */
 public static function getLocaleFromLanguage($language)
 {
     $locale = StringTool::substr($language, 0, 2);
     if (in_array($locale, TranslationTool::$languageList)) {
         return $locale;
     } else {
         return TranslationTool::DEFAULT_LOCALE;
     }
 }
 /**
  * Convert a color string from hexadecimal to RGB format
  *
  * @param string $color an hexadecimal color (#FFFFFF, #FFF, AAAAAA are available formats)
  * @return array|boolean an array with r,g,b result, or false if color format was not correct
  */
 public static function hexaToRGB($color)
 {
     if ($color[0] == '#') {
         $color = StringTool::substr($color, 1);
     }
     if (StringTool::strlen($color) == 6) {
         list($r, $g, $b) = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
     } elseif (StringTool::strlen($color) == 3) {
         list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
     } else {
         return false;
     }
     $r = hexdec($r);
     $g = hexdec($g);
     $b = hexdec($b);
     return array($r, $g, $b);
 }
示例#3
0
// Starts session before header is sent
session_start();
require_once '../../../init/initLog.inc.php';
$currentDay = DateTool::getTimeString(DateTool::FORMAT_MYSQL_DATE);
define('TAIL_LOG_FILE', LOG_DIR . '/' . $currentDay . '-web.log');
$grep = RequestTool::getParameter('grep', RequestTool::PARAM_TYPE_FREE, false);
$logFile = file_exists(TAIL_LOG_FILE) ? file(TAIL_LOG_FILE) : array();
$starterLine = SessionTool::getInstance()->getParameter('startLine', false, 0);
$lineCount = count($logFile);
for ($index = $starterLine; $index < $lineCount; ++$index) {
    // Filter lines per grep
    if ($grep && !StringTool::strpos($logFile[$index], $grep)) {
        continue;
    }
    $truncate = true;
    switch (StringTool::substr($logFile[$index], 0, 7)) {
        case "":
            $color = '#5F5';
            // Green
            break;
        case "":
            $color = '#FF5';
            // Yellow
            break;
        case "":
            $color = '#F55';
            // Red
            break;
        case "":
            $color = '#55F';
            // Blue
 /**
  * Generates a random string (for unique filenames)
  * @param int $length The string length
  * @return string The created string
  */
 public static function generateRandomString($length = 10)
 {
     return StringTool::substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
 }