コード例 #1
0
ファイル: lang.php プロジェクト: husnahadi/info257-website
    echo '<canvas id="myChart" width="400" height="400"></canvas>';
} else {
    echo "Could not find any information for language: " . $lang_name;
}
?>

                <script>
                  // Get the context of the canvas element we want to select
                  var ctx = document.getElementById("myChart").getContext("2d");
                  var data = {
                    labels: ["Before 2010", "2010", "2011", "2012", "2013", "2014"],
                    datasets: [
                     {
                      label: "Language",
                      fillColor: "rgba(220,220,220,0.5)",
                      strokeColor: "rgba(220,220,220,0.8)",
                      highlightFill: "rgba(220,220,220,0.75)",
                      highlightStroke: "rgba(220,220,220,1)",
                      data: [<?php 
echo getBytes($lang, 'bytes_pre_2010') . ',' . getBytes($lang, 'bytes_2010') . ',' . getBytes($lang, 'bytes_2011') . ',' . getBytes($lang, 'bytes_2012') . ',' . getBytes($lang, 'bytes_2013') . ',' . getBytes($lang, 'bytes_2014');
?>
]
                     }
                    ]
                  };
                  var myNewChart = new Chart(ctx).Bar(data);
                </script>
	</div>
</body>
</html>
コード例 #2
0
ファイル: ai-bolit.php プロジェクト: AlexeyManikin/aibolit
    $l_Result .= '<div class="note_warn">' . AI_STR_052 . ' (' . count($g_HeuristicDetected) . ')</div><div class="warn">';
    for ($i = 0; $i < count($g_HeuristicDetected); $i++) {
        $l_Result .= '<li>' . makeSafeFn($g_Structure['n'][$g_HeuristicDetected[$i]], true) . ' (' . get_descr_heur($g_HeuristicType[$i]) . ')</li>';
    }
    $l_Result .= '</ul></div><div class=\\"spacer\\"></div>' . PHP_EOL;
}
stdOut("Building list of hidden files " . count($g_HiddenFiles));
if (count($g_HiddenFiles) > 0) {
    $l_Result .= '<div class="note_warn">' . AI_STR_023 . ' (' . count($g_HiddenFiles) . ')</div><div class="warn">';
    $l_Result .= nl2br(makeSafeFn(implode("\n", $g_HiddenFiles), true));
    $l_Result .= "</div><div class=\"spacer\"></div>" . PHP_EOL;
    $l_PlainResult .= '[HIDDEN]' . "\n" . implode("\n", replacePathArray($g_HiddenFiles)) . "\n\n";
}
stdOut("Building list of bigfiles " . count($g_BigFiles));
$max_size_to_scan = getBytes(MAX_SIZE_TO_SCAN);
$max_size_to_scan = $max_size_to_scan > 0 ? $max_size_to_scan : getBytes('1m');
if (count($g_BigFiles) > 0) {
    $l_Result .= "<div class=\"note_warn\">" . sprintf(AI_STR_038, bytes2Human($max_size_to_scan)) . '</div><div class="warn">';
    $l_Result .= printList($g_BigFiles);
    $l_Result .= "</div>";
    $l_PlainResult .= '[BIG FILES / SKIPPED]' . "\n" . printPlainList($g_BigFiles) . "\n\n";
}
stdOut("Building list of php inj " . count($g_PHPCodeInside));
if (count($g_PHPCodeInside) > 0 && ($defaults['report_mask'] & REPORT_MASK_PHPSIGN) == REPORT_MASK_PHPSIGN) {
    $l_Result .= '<div class="note_warn">' . AI_STR_028 . '</div><div class="warn">';
    $l_Result .= printList($g_PHPCodeInside, $g_PHPCodeInsideFragment, true);
    $l_Result .= "</div>" . PHP_EOL;
}
stdOut("Building list of empty links " . count($g_EmptyLink));
if (count($g_EmptyLink) > 0) {
    $l_Result .= '<div class="note_warn">' . AI_STR_031 . '</div><div class="warn">';
コード例 #3
0
 public function FanweService()
 {
     if (phpversion() < '5.3.0') {
         set_magic_quotes_runtime(0);
     }
     if (!defined('FANWE_ROOT')) {
         define('FANWE_ROOT', str_replace('\\', '/', substr(dirname(__FILE__), 0, -12)));
     }
     if (!file_exists(FANWE_ROOT . './public/install.lock')) {
         header('Location: install/index.php');
         exit;
     }
     define('MAGIC_QUOTES_GPC', function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc());
     define('ICONV_ENABLE', function_exists('iconv'));
     define('MB_ENABLE', function_exists('mb_convert_encoding'));
     define('EXT_OBGZIP', function_exists('ob_gzhandler'));
     define('TIMESTAMP', time());
     if (!(include FANWE_ROOT . './core/function/global.func.php')) {
         exit('not found global.func.php');
     }
     @(require FANWE_ROOT . './public/constant.global.php');
     require fimport("function/time");
     define('IS_ROBOT', checkRobot());
     if (function_exists('ini_get')) {
         $memory_limit = @ini_get('memory_limit');
         if ($memory_limit && getBytes($memory_limit) < 33554432 && function_exists('ini_set')) {
             ini_set('memory_limit', '128M');
         }
     }
     if (!$this->is_admin) {
         foreach ($GLOBALS as $key => $value) {
             if (!isset($this->allow_global[$key])) {
                 $GLOBALS[$key] = NULL;
                 unset($GLOBALS[$key]);
             }
         }
     }
     global $_FANWE;
     $_FANWE = array();
     $_FANWE['uid'] = 0;
     $_FANWE['user_name'] = '';
     $_FANWE['gid'] = 0;
     $_FANWE['sid'] = '';
     $_FANWE['form_hash'] = '';
     $_FANWE['client_ip'] = getFClientIp();
     $_FANWE['referer'] = '';
     $_FANWE['php_self'] = htmlspecialchars(getPhpSelf());
     if ($_FANWE['php_self'] === false) {
         systemError('request_tainting');
     }
     $_FANWE['module_name'] = MODULE_NAME;
     $_FANWE['module_filename'] = basename($_FANWE['php_self']);
     $_FANWE['site_url'] = '';
     $_FANWE['site_root'] = '';
     $_FANWE['site_port'] = '';
     $_FANWE['config'] = array();
     $_FANWE['setting'] = array();
     $_FANWE['user'] = array();
     $_FANWE['group'] = array();
     $_FANWE['cookie'] = array();
     $_FANWE['cache'] = array();
     $_FANWE['session'] = array();
     $_FANWE['lang'] = array();
     $_FANWE['tpl_user_formats'] = array();
     $site_path = substr($_FANWE['php_self'], 0, strrpos($_FANWE['php_self'], '/'));
     $_FANWE['site_url'] = htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $site_path . '/');
     $_FANWE['domain'] = htmlspecialchars($_SERVER['HTTP_HOST'] . $site_path . '/');
     $url = parse_url($_FANWE['site_url']);
     $_FANWE['site_root'] = isset($url['path']) ? $url['path'] : '';
     $_FANWE['site_port'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT'];
     if (defined('SUB_DIR')) {
         $_FANWE['site_url'] = str_replace(SUB_DIR, '', $_FANWE['site_url']);
         $_FANWE['site_root'] = str_replace(SUB_DIR, '', $_FANWE['site_root']);
     }
     define('PUBLIC_ROOT', FANWE_ROOT . './public/');
     define('PUBLIC_PATH', $_FANWE['site_root'] . 'public/');
     define('SITE_URL', $_FANWE['site_root']);
     require fimport("class/cache");
     $this->cache = Cache::getInstance();
     $this->var =& $_FANWE;
     $this->buildConfig();
     $this->buildInput();
     $this->buildOutput();
 }
コード例 #4
0
function image_manipulate($config = array())
{
    global $phpwcms;
    // Merge config values with default
    $config = array_merge(array("max_width" => $phpwcms["img_list_width"], "max_height" => $phpwcms["img_list_height"], "error" => '', "image_name" => '', "thumb_name" => '', "target_ext" => 'jpg', "image_dir" => PHPWCMS_ROOT . '/' . PHPWCMS_FILES, "thumb_dir" => PHPWCMS_THUMB, 'jpg_quality' => 85, 'sharpen_level' => 0, 'density' => 72, 'add_command' => '', 'crop_image' => false, 'crop_pos' => '', 'master_dim' => 'auto'), $config);
    // Test width and height and set correct dimensions
    if (!intval($config["max_width"]) && !intval($config["max_height"])) {
        // Should not happen, but better have a fallback
        $config["max_width"] = $phpwcms["img_list_width"];
        $config["max_height"] = $phpwcms["img_list_height"];
        $config['master_dim'] = 'auto';
    } elseif (!intval($config["max_width"])) {
        // No width given, recalculate final image size based on height
        $config["max_width"] = $phpwcms["img_prev_width"];
        $config['crop_image'] = false;
        $config['master_dim'] = 'height';
    } elseif (!intval($config["max_height"])) {
        // No height given, recalculate final image size based on width
        $config["max_height"] = $phpwcms["img_prev_height"];
        $config['crop_image'] = false;
        $config['master_dim'] = 'width';
    }
    // Check if source image is accessible
    // otherwise use placeholder image "filestorage/image_placeholder.png"
    if (!is_file($config["image_dir"] . $config["image_name"])) {
        $config["image_name"] = 'image_placeholder.png';
        $config["thumb_name"] = 'temp_' . $config["thumb_name"];
    }
    // Doubled config setting but especially for Image manipulation class
    $image_config = array('image_library' => $phpwcms['image_library'], 'library_path' => $phpwcms['library_path'], 'source_image' => $config["image_dir"] . $config["image_name"], 'new_image' => $config["thumb_dir"] . $config["thumb_name"] . '.' . $config["target_ext"], 'maintain_ratio' => true, 'width' => $config['max_width'], 'height' => $config['max_height'], 'master_dim' => $config['master_dim'], 'sharpen' => $config['sharpen_level'], 'quality' => $config['jpg_quality'], 'create_thumb' => false, 'target_ext' => $config["target_ext"], 'colorspace' => $phpwcms['colorspace']);
    $IMG = new Phpwcms_Image_lib($image_config);
    // try to handle limited PHP memory
    if (empty($GLOBALS['phpwcms']['gd_memcheck_off']) && ($phpwcms['image_library'] == 'gd2' || $phpwcms['image_library'] == 'gd')) {
        $php_memory = getBytes(@ini_get('memory_limit'));
        $img_memory = getRealImageSize($IMG->image_current_vals);
        // do memory checks only when PHP's memory limit
        // and "real" image size is known
        if ($php_memory && $img_memory) {
            // test if we have enough PHP memory for this image and test to set it up
            if ($php_memory / 3 < $img_memory) {
                @ini_set('memory_limit', $img_memory * 3);
            }
            $php_memory = getBytes(@ini_get('memory_limit'));
            // still not enough, use fallback memory warning image
            if ($php_memory / 3 < $img_memory) {
                $config["image_name"] = 'image_memoryinfo.png';
                $config["thumb_name"] = 'mem_' . $config["thumb_name"];
                $image_config['source_image'] = $config["image_dir"] . $config["image_name"];
                $image_config['new_image'] = $config["thumb_dir"] . $config["thumb_name"] . '.' . $config["target_ext"];
                $IMG->initialize($image_config);
            }
        }
    }
    // do not resize if image is smaller than target sizes
    if (!$config['crop_image'] && substr($phpwcms['image_library'], 0, 2) == 'gd' && !empty($IMG->orig_width) && !empty($IMG->orig_height) && $image_config['width'] > $IMG->orig_width && $image_config['height'] > $IMG->orig_height) {
        $config['max_width'] = $IMG->orig_width;
        $config['max_height'] = $IMG->orig_height;
        $image_config['width'] = $IMG->orig_width;
        $image_config['height'] = $IMG->orig_height;
        $IMG->width = $IMG->orig_width;
        $IMG->height = $IMG->orig_height;
    }
    if ($config['crop_image']) {
        $image_config = set_cropped_imagesize($image_config, $IMG->orig_width, $IMG->orig_height, $config['crop_pos']);
        if ($image_config['do_cropping']) {
            // first resize width recalculated height/width
            $IMG->width = $image_config['resize_width'];
            $IMG->height = $image_config['resize_height'];
            $IMG->quality = 100;
            $IMG->resize();
            $image_config['sharpen'] = 0;
            $image_config['maintain_ratio'] = FALSE;
            $image_config['create_thumb'] = FALSE;
            $image_config['source_image'] = $image_config['new_image'];
            $IMG->initialize($image_config);
            $IMG->crop();
        } else {
            $IMG->resize();
        }
    } else {
        $IMG->resize();
    }
    $config["thumb_name"] = $IMG->dest_image;
    $config['error'] = $IMG->display_errors('<li>', '</li>', '<ul class="error">', '</ul>');
    return $config;
}
コード例 #5
0
 function highlightText($text, $phrase, $searchType)
 {
     $text = strip_tags(str_replace('<br />', ' ', $text));
     $text1 = strtolower_rus($text);
     $phrase = str_replace('$', '&#036;', $phrase);
     $GLOBALS['bytes'] = array();
     /* Array containing list of begin and end bytes, between them "bold" selection will be inserted. List if formed basing on search phrase(s) when analyzing text by getBytes() */
     if ($phrase != '' and $searchType != 2) {
         $words = explode(' ', $phrase);
         foreach ($words as $w) {
             $w = trim(strtolower_rus($w));
             if ($w != '' and strlen($w) > 2) {
                 getBytes($text1, $w);
             }
             //$text1=str_replace($w, '<strong>'.$w.'</strong>', $text1);
         }
     } elseif ($phrase != '' and $searchType == 2) {
         getBytes($text1, trim(strtolower_rus($phrase)));
     }
     $text = boldText($text, $GLOBALS['bytes']);
     return cutText($text, $GLOBALS['bytes']);
 }
コード例 #6
0
<?php

if ($argc <= 1) {
    die('please input the string!' . PHP_EOL);
}
$word = $argv['1'];
/**
 * 1.转化为ASCII
 * 2.将ASCII码作为字符串连接
 * 3.每10位拆分字符串
 * 4.将拆分的10位十进制数字转换为36进制,默认是7位,余位补"."
 */
$result = getBytes($word);
$result = join($result);
for ($i = 0; $i <= strlen($result) / 10; $i++) {
    $tmp[] = substr($result, $i * 10, 10);
    $num = base_convert(substr($result, $i * 10, 10), 10, 36);
    $num = str_pad($num, 7, '.');
    $str[] = $num;
}
$str = join($str);
echo $str;
echo PHP_EOL;
function getBytes($string)
{
    $bytes = array();
    for ($i = 0; $i < strlen($string); $i++) {
        $bytes[] = ord($string[$i]);
    }
    return $bytes;
}