예제 #1
0
function getStatusCode($url, $followRedirects = false)
{
    global $http_codes;
    $url = str_replace("+", "%2b", $url);
    $url = str_replace(" ", "%20", $url);
    $proxy = get_config("linkschecker", "proxyserver");
    $proxyport = get_config("linkschecker", "proxyport");
    $proxyusername = get_config("linkschecker", "proxyusername");
    $proxypassword = get_config("linkschecker", "proxypassword");
    $max_load = 0.4;
    while (get_server_load() > $max_load) {
        usleep(500000);
    }
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, true);
    if ($proxy != "") {
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
        //curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
        curl_setopt($ch, CURLOPT_PROXYPORT, $proxyport);
        if ($proxyusername != "") {
            curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyusername . ':' . $proxypassword);
        }
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 Gecko/20100101 Firefox/4.0.1");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $result = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $error = curl_error($ch);
    curl_close($ch);
    if ($error) {
        return "<span class='code599'>" . preg_replace('/[^\\/\\-a-z\\s]/i', '', $error) . "</span>";
    } else {
        return "<span class='code" . $http_code . "'>" . $http_code . " " . $http_codes[$http_code] . "</span>";
    }
}
예제 #2
0
function check_load_status($return = false)
{
    global $_CORE_CONFIG, $_CLASS;
    static $load_status = null;
    if (!is_null($load_status)) {
        return $load_status;
    }
    $load_status = 0;
    if ($load = get_server_load()) {
        if ($_CORE_CONFIG['server']['limit_load'] && $load > doubleval($_CORE_CONFIG['server']['limit_load']) && VIPERAL != 'Admin') {
            if (VIPERAL == 'Admin' || isset($_CLASS['core_user']) && $_CLASS['core_user']->is_admin) {
                return $load_status;
            }
            if ($return) {
                return $load_status = true;
            }
            trigger_error('503:SITE_UNAVAILABLE');
        }
    }
    return $load_status;
}
$i = 0;
while ($cpu = $cpus->Next()) {
$cpuload += $cpu->LoadPercentage;
$i++;
}

$cpuload = round($cpuload / $i, 2);
return "$cpuload%";
}
else {
return false;
}
}
}

$load_ave = get_server_load(true);


$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);

$stmt="SELECT count(*) from vicidial_users where user='******' and pass='******' and user_level > 6 and view_reports='1';";
if ($DB) {echo "|$stmt|\n";}
if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");}
$rslt=mysql_query($stmt, $link);
$row=mysql_fetch_row($rslt);
$auth=$row[0];

  if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth))
	{
    Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\"");
예제 #4
0
        $db->delete_query("sessions", "ip='" . $db->escape_string($session->ipaddress) . "' OR uid='{$mybb->user['uid']}'");
    } else {
        $db->delete_query("sessions", "ip='" . $db->escape_string($session->ipaddress) . "'");
    }
    error($lang->error_banned);
}
$closed_bypass = array("member.php" => array("login", "do_login", "logout"), "captcha.php");
// If the board is closed, the user is not an administrator and they're not trying to login, show the board closed message
if ($mybb->settings['boardclosed'] == 1 && $mybb->usergroup['cancp'] != 1 && !in_array($current_page, $closed_bypass) && (!is_array($closed_bypass[$current_page]) || !in_array($mybb->input['action'], $closed_bypass[$current_page]))) {
    // Show error
    $lang->error_boardclosed .= "<blockquote>{$mybb->settings['boardclosed_reason']}</blockquote>";
    error($lang->error_boardclosed);
    exit;
}
// Load Limiting
if ($mybb->usergroup['cancp'] != 1 && $mybb->settings['load'] > 0 && ($load = get_server_load()) && $load != $lang->unknown && $load > $mybb->settings['load']) {
    // User is not an administrator and the load limit is higher than the limit, show an error
    error($lang->error_loadlimit);
}
// If there is a valid referrer in the URL, cookie it
if (!$mybb->user['uid'] && $mybb->settings['usereferrals'] == 1 && (isset($mybb->input['referrer']) || isset($mybb->input['referrername']))) {
    if (isset($mybb->input['referrername'])) {
        $condition = "username='******'referrername']) . "'";
    } else {
        $condition = "uid='" . intval($mybb->input['referrer']) . "'";
    }
    $query = $db->simple_select("users", "uid", $condition, array('limit' => 1));
    $referrer = $db->fetch_array($query);
    if ($referrer['uid']) {
        my_setcookie("mybb[referrer]", $referrer['uid']);
    }
예제 #5
0
파일: data.php 프로젝트: WattyRev/games
 public function update()
 {
     return json_encode(array('load' => get_server_load(), 'time' => time()));
 }
예제 #6
0
            $cpu_num = 0;
            $load_total = 0;
            foreach ($server as $cpu) {
                $cpu_num++;
                $load_total += $cpu->loadpercentage;
            }
            $load = round($load_total / $cpu_num, 2);
            file_put_contents("./load.cache", $load);
        }
    } else {
        $sys_load = sys_getloadavg();
        $load = round($sys_load[0], 2);
    }
    return (int) $load;
}
$avg_load = get_server_load();
$load = str_pad(strstr($avg_load, ".") === false ? $avg_load . "." : $avg_load, 4, "0", STR_PAD_RIGHT);
echo "<load>{$load}</load>\n";
$uptime_array = array("days" => "N/A", "hours" => "N/A", "mins" => "N/A", "secs" => "N/A");
function format_uptime($uptime)
{
    $days = floor($uptime / 60 / 60 / 24);
    $hours = str_pad(floor($uptime / 60 / 60) % 24, 2, "0", STR_PAD_LEFT);
    $mins = str_pad(floor($uptime / 60) % 60, 2, "0", STR_PAD_LEFT);
    $secs = str_pad(floor($uptime % 60), 2, "0", STR_PAD_LEFT);
    return array("days" => $days, "hours" => $hours, "mins" => $mins, "secs" => $secs);
}
if (stristr(PHP_OS, 'win') != false) {
    $fileModTime = filemtime("./uptime.cache");
    $uptime = 0;
    $cache = @file_get_contents("./uptime.cache");
예제 #7
0
/**
 * Prints a debug information page
 */
function debug_page()
{
    global $db, $debug, $templates, $templatelist, $mybb, $maintimer, $globaltime, $ptimer, $parsetime, $lang;
    $totaltime = $maintimer->totaltime;
    $phptime = $maintimer->format($maintimer->totaltime - $db->query_time);
    $query_time = $maintimer->format($db->query_time);
    $percentphp = number_format($phptime / $maintimer->totaltime * 100, 2);
    $percentsql = number_format($query_time / $maintimer->totaltime * 100, 2);
    $phpversion = PHP_VERSION;
    $serverload = get_server_load();
    if ($mybb->settings['gzipoutput'] != 0) {
        $gzipen = "Enabled";
    } else {
        $gzipen = "Disabled";
    }
    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
    echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">";
    echo "<head>";
    echo "<title>MyBB Debug Information</title>";
    echo "</head>";
    echo "<body>";
    echo "<h1>MyBB Debug Information</h1>\n";
    echo "<h2>Page Generation</h2>\n";
    echo "<table bgcolor=\"#666666\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
    echo "<tr>\n";
    echo "<td bgcolor=\"#CCCCCC\" colspan=\"4\"><b><span style=\"size:2;\">Page Generation Statistics</span></b></td>\n";
    echo "</tr>\n";
    echo "<tr>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Page Generation Time:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$totaltime} seconds</font></td>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. DB Queries:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$db->query_count}</font></td>\n";
    echo "</tr>\n";
    echo "<tr>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Processing Time:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$phptime} seconds ({$percentphp}%)</font></td>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">DB Processing Time:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$query_time} seconds ({$percentsql}%)</font></td>\n";
    echo "</tr>\n";
    echo "<tr>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Extensions Used:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$mybb->config['database']['type']}, xml</font></td>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Global.php Processing Time:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$globaltime} seconds</font></td>\n";
    echo "</tr>\n";
    echo "<tr>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">PHP Version:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$phpversion}</font></td>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Server Load:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$serverload}</font></td>\n";
    echo "</tr>\n";
    echo "<tr>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">GZip Encoding Status:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$gzipen}</font></td>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">No. Templates Used:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">" . count($templates->cache) . " (" . intval(count(explode(",", $templatelist))) . " Cached / " . intval(count($templates->uncached_templates)) . " Manually Loaded)</font></td>\n";
    echo "</tr>\n";
    $memory_usage = get_memory_usage();
    if (!$memory_usage) {
        $memory_usage = $lang->unknown;
    } else {
        $memory_usage = get_friendly_size($memory_usage) . " ({$memory_usage} bytes)";
    }
    $memory_limit = @ini_get("memory_limit");
    echo "<tr>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Usage:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_usage}</font></td>\n";
    echo "<td bgcolor=\"#EFEFEF\" width=\"25%\"><b><font face=\"Tahoma\" size=\"2\">Memory Limit:</font></b></td>\n";
    echo "<td bgcolor=\"#FEFEFE\" width=\"25%\"><font face=\"Tahoma\" size=\"2\">{$memory_limit}</font></td>\n";
    echo "</tr>\n";
    echo "</table>\n";
    echo "<h2>Database Connections (" . count($db->connections) . " Total) </h2>\n";
    echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
    echo "<tr>\n";
    echo "<td style=\"background: #fff;\">" . implode("<br />", $db->connections) . "</td>\n";
    echo "</tr>\n";
    echo "</table>\n";
    echo "<br />\n";
    echo "<h2>Database Queries (" . $db->query_count . " Total) </h2>\n";
    echo $db->explain;
    echo "<h2>Template Statistics</h2>\n";
    if (count($templates->cache) > 0) {
        echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
        echo "<tr>\n";
        echo "<td style=\"background-color: #ccc;\"><strong>Templates Used (Loaded for this Page) - " . count($templates->cache) . " Total</strong></td>\n";
        echo "</tr>\n";
        echo "<tr>\n";
        echo "<td style=\"background: #fff;\">" . implode(", ", array_keys($templates->cache)) . "</td>\n";
        echo "</tr>\n";
        echo "</table>\n";
        echo "<br />\n";
    }
    if (count($templates->uncached_templates) > 0) {
        echo "<table style=\"background-color: #666;\" width=\"95%\" cellpadding=\"4\" cellspacing=\"1\" align=\"center\">\n";
        echo "<tr>\n";
        echo "<td style=\"background-color: #ccc;\"><strong>Templates Requiring Additional Calls (Not Cached at Startup) - " . count($templates->uncached_templates) . " Total</strong></td>\n";
        echo "</tr>\n";
        echo "<tr>\n";
        echo "<td style=\"background: #fff;\">" . implode(", ", $templates->uncached_templates) . "</td>\n";
        echo "</tr>\n";
        echo "</table>\n";
        echo "<br />\n";
    }
    echo "</body>";
    echo "</html>";
    exit;
}
예제 #8
0
        return 'unknown';
    }
    if (function_exists("sys_getloadavg")) {
        $load = sys_getloadavg();
        return $load[0];
    }
    if (@file_exists('/proc/loadavg')) {
        $load = @file_get_contents('/proc/loadavg');
        $serverload = explode(' ', $load);
        $serverload[0] = round($serverload[0], 4);
        if (!$serverload) {
            $load = @exec('uptime');
            $load = split('load averages?: ', $load);
            $serverload = explode(',', $load[1]);
        }
    } else {
        $load = @exec('uptime');
        $load = split('load averages?: ', $load);
        $serverload = explode(',', $load[1]);
    }
    $returnload = trim($serverload[0]);
    if (!$returnload) {
        $returnload = 'unknown';
    }
    return $returnload;
}
$load = get_server_load();
if (is_float($load) and $load > 80) {
    header('HTTP/1.1 503 Too busy, try again later');
    die('Server too busy. Please try again later.');
}
 /**
 This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
 */
 public function action()
 {
     global $mybb;
     require_once MYBB_ROOT . "inc/functions.php";
     return (object) get_server_load();
 }
예제 #10
0
         if (mb_strripos($POSTS['filename'], ":") !== false) {
             $POSTS['filename'] = mb_substr($POSTS['filename'], mb_strripos($POSTS['filename'], ":") - 1, mb_strlen($POSTS['filename']));
         }
         $POSTS['filename'] = mb_convert_encoding($POSTS['filename'], 'BIG5', 'UTF-8');
     }
     if (touch($POSTS['filename'])) {
         echo "1";
     } else {
         echo "0";
     }
     exit;
     break;
 case 'getSystemStatus':
     check_login(true);
     //取得系統資料
     $system_loading = get_server_load();
     ?>
     系統負載:<?php 
     echo $system_loading;
     ?>
     <br>
     記憶體使用:<span id='mem_span_usage'>計算中...</span> / <span id='mem_span'>計算中...</span>
     <script language="javascript">
       $(document).ready(function(){
         myAjax_async("?mode=getMemoryTotal","","#mem_span",function(){});
         myAjax_async("?mode=getMemoryUsage","","#mem_span_usage",function(){});
       });
     </script>
     <br>
     硬碟狀態:<br>
     <div style="margin-left:15px;">
예제 #11
0
{
    $os = strtolower(PHP_OS);
    if (strpos($os, "win") === false) {
        if (file_exists("/proc/loadavg")) {
            $load = file_get_contents("/proc/loadavg");
            $load = explode(' ', $load);
            return $load;
        } elseif (function_exists("shell_exec")) {
            $load = explode(' ', `uptime`);
            return $load;
        } else {
            return "";
        }
    }
}
list($one, $two, $three) = get_server_load();
//bar width
$width = 300;
//bar height
$height = 20;
$real_load = $one / 2;
$img_handle = imagecreate($width, $height);
$box_color = imagecolorallocate($img_handle, 255, 255, 255);
$bar_color = imagecolorallocate($img_handle, 0, 195, 255);
$text_color = imagecolorallocate($img_handle, 0, 0, 0);
$real_load = $real_load > 1 ? 1 : $real_load;
imagerectangle($img_handle, 0, 0, $width, $height, $box_color);
imagefilledrectangle($img_handle, 0, 0, (int) $width * $real_load, $height, $bar_color);
imagestring($img_handle, 5, $width / 2 - 15, $height / 2 - 7, $real_load * 100 . '%', $text_color);
header("Content-type: image/png");
imagepng($img_handle);
예제 #12
0
파일: load.php 프로젝트: CharlieHD/U-232-V2
 *   Project Leaders: Mindless,putyn,kidvision.
 **/
if (!defined('IN_INSTALLER09_ADMIN')) {
    $HTMLOUT = '';
    $HTMLOUT .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\r\n\t\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n\t\t<html xmlns='http://www.w3.org/1999/xhtml'>\r\n\t\t<head>\r\n\t\t<title>Error!</title>\r\n\t\t</head>\r\n\t\t<body>\r\n\t<div style='font-size:33px;color:white;background-color:red;text-align:center;'>Incorrect access<br />You cannot access this file directly.</div>\r\n\t</body></html>";
    echo $HTMLOUT;
    exit;
}
require_once INCL_DIR . 'user_functions.php';
require_once CLASS_DIR . 'class_check.php';
class_check(UC_SYSOP);
$lang = array_merge($lang, load_language('ad_index'));
$HTMLOUT = '';
//==Windows Server Load
$HTMLOUT .= "\r\n    <div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>\r\n    <div style='background:transparent;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_serverload']}</span></div>\r\n    <br />\r\n    <table width='100%' border='1' cellspacing='0' cellpadding='1'>\r\n\t\t<tr><td align='center'>\r\n\t\t<table class='main' border='0' width='402'>\r\n    <tr><td style='padding: 0px; background-image: url({$INSTALLER09['pic_base_url']}loadbarbg.gif); background-repeat: repeat-x'>";
$perc = get_server_load();
$percent = min(100, $perc);
if ($percent <= 70) {
    $pic = "loadbargreen.gif";
} elseif ($percent <= 90) {
    $pic = "loadbaryellow.gif";
} else {
    $pic = "loadbarred.gif";
}
$width = $percent * 4;
$HTMLOUT .= "<img height='15' width='{$width}' src=\"{$INSTALLER09['pic_base_url']}{$pic}\" alt='{$percent}&#37;' /><br />Currently {$percent}&#37; CPU usage.<br /></td></tr></table></td></tr></table></div><br />";
//==End
/*
//==Server Load linux
$HTMLOUT .="
<div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>
예제 #13
0
 public function __destruct()
 {
     global $start_timer, $load_timer, $db;
     $load_time = $start_timer - $load_timer;
     $end_timer = microtime(true);
     $total_time = $end_timer - $start_timer;
     $php_time = number_format($total_time - $db->query_time, 7);
     $query_time = number_format($db->query_time, 7);
     if ($total_time > 0) {
         $percentphp = number_format($php_time / $total_time * 100, 2);
         $percentsql = number_format($query_time / $total_time * 100, 2);
     } else {
         // if we've got a super fast script...  all we can do is assume something
         $percentphp = 0;
         $percentsql = 0;
     }
     $phpversion = PHP_VERSION;
     $serverload = get_server_load();
     $current_memory_usage = get_memory_usage();
     if ($current_memory_usage) {
         $memory_usage = " / Memory Usage: " . get_friendly_size($current_memory_usage);
     } else {
         $memory_usage = '';
     }
     $this->trace0("Generated in {$total_time} seconds ({$percentphp}% PHP / {$percentsql}% MySQL) / Initialize Load Time: {$load_time} / SQL Queries: {$db->query_count}{$memory_usage} PHP version: {$phpversion} / Server Load: {$serverload}");
 }