コード例 #1
0
 public function validateRequest(array $requiredParams)
 {
     $objUtilResponse = new Response();
     $objUtilRequest = new Request();
     if ($objUtilRequest->isPost()) {
         $accessKeyId = $objUtilRequest->getPost('access_key', false);
         $signature = trim($objUtilRequest->getPost('signature', false));
         $timestamp = $objUtilRequest->getPost('timestamp', false);
         // Required to generate variable signature
         $parameters = array('timestamp' => $timestamp);
         $allParamsPresent = true;
         foreach ($requiredParams as $paramName) {
             $paramValue = $objUtilRequest->getPost($paramName, false);
             if ($paramName) {
                 $parameters[$paramName] = $paramValue;
             } else {
                 $allParamsPresent = false;
                 break;
             }
         }
         if ($accessKeyId && $signature && $timestamp) {
             // Okay we have all required parameters
             // Let's identify user
             $requestParams = $objUtilRequest->getRequest();
             $objServerHelper = new ServerInfo();
             $url = $objServerHelper->serverUrl(true);
             $userSyncRestMdl = new \api\Server($parameters, $accessKeyId, null, $url);
             $isValidTimestamp = $userSyncRestMdl->isValidTimestamp($timestamp);
             if (!$isValidTimestamp) {
                 $objUtilResponse->renderJson(array('status' => 403, 'message' => 'Invalid Timestamp'), 403);
             }
             $userProductMdl = new \models\ApiProducts();
             $apiProductDetails = $userProductMdl->isValidAccessKey($accessKeyId);
             if ($apiProductDetails) {
                 // Valid access key
                 $userSyncRestMdl->setSecretKey($apiProductDetails->secret_key);
                 $isValidSignature = $userSyncRestMdl->isValidSignature($signature);
                 if ($isValidSignature === true) {
                     return $apiProductDetails;
                 } else {
                     $objUtilResponse->renderJson(array('status' => 403, 'message' => 'Invalid Signature'), 403);
                 }
             } else {
                 $objUtilResponse->renderJson(array('status' => 403, 'message' => 'Invalid access key.'), 403);
             }
         } else {
             $objUtilResponse->renderJson(array('status' => 403, 'message' => 'Required parameters are missing.'), 403);
         }
     } else {
         $objUtilResponse->renderJson(array('status' => 403, 'message' => 'Only post requests are accepted'), 403);
     }
 }
コード例 #2
0
ファイル: ServerInfoV26x.php プロジェクト: biswars/retwis
 /**
  * {@inheritdoc}
  */
 public function parseResponse($data)
 {
     $info = array();
     $current = null;
     $infoLines = preg_split('/\\r?\\n/', $data);
     if (isset($infoLines[0]) && $infoLines[0][0] !== '#') {
         return parent::parseResponse($data);
     }
     foreach ($infoLines as $row) {
         if ($row === '') {
             continue;
         }
         if (preg_match('/^# (\\w+)$/', $row, $matches)) {
             $info[$matches[1]] = array();
             $current =& $info[$matches[1]];
             continue;
         }
         list($k, $v) = explode(':', $row);
         if (!preg_match('/^db\\d+$/', $k)) {
             if ($k === 'allocation_stats') {
                 $current[$k] = $this->parseAllocationStats($v);
                 continue;
             }
             $current[$k] = $v;
         } else {
             $current[$k] = $this->parseDatabaseStats($v);
         }
     }
     return $info;
 }
コード例 #3
0
ファイル: ServerInfoV26x.php プロジェクト: flachesis/predis
 /**
  * {@inheritdoc}
  */
 public function parseResponse($data)
 {
     if ($data === '') {
         return array();
     }
     $info = array();
     $current = null;
     $infoLines = preg_split('/\\r?\\n/', $data);
     if (isset($infoLines[0]) && $infoLines[0][0] !== '#') {
         return parent::parseResponse($data);
     }
     foreach ($infoLines as $row) {
         if ($row === '') {
             continue;
         }
         if (preg_match('/^# (\\w+)$/', $row, $matches)) {
             $info[$matches[1]] = array();
             $current =& $info[$matches[1]];
             continue;
         }
         list($k, $v) = $this->parseRow($row);
         $current[$k] = $v;
     }
     return $info;
 }
コード例 #4
0
ファイル: ServerInfo.php プロジェクト: Bishop/loadOdie
 protected static function getInfo()
 {
     if (is_null(self::$apache_modules)) {
         self::$apache_modules = function_exists('apache_get_modules') ? apache_get_modules() : array();
     }
     if (is_null(self::$php_modules)) {
         self::$php_modules = get_loaded_extensions();
     }
 }
コード例 #5
0
ファイル: Tools.php プロジェクト: hackingman/TubeX
 private function __construct()
 {
     $si = ServerInfo::GetCached();
     $this->mencoder = $si->binaries[ServerInfo::BIN_MENCODER];
     $this->mplayer = $si->binaries[ServerInfo::BIN_MPLAYER];
     $this->ffmpeg = $si->binaries[ServerInfo::BIN_FFMPEG];
     $this->mp4box = $si->binaries[ServerInfo::BIN_MP4BOX];
     $this->yamdi = $si->binaries[ServerInfo::BIN_YAMDI];
     $this->convert = $si->binaries[ServerInfo::BIN_CONVERT];
     $this->nice = $si->binaries[ServerInfo::BIN_NICE];
 }
コード例 #6
0
ファイル: Zip.php プロジェクト: hackingman/TubeX
 public static function ExtractEntries($archive, $type)
 {
     $si = ServerInfo::GetCached();
     if (!$si->php_extensions[ServerInfo::EXT_ZIP]) {
         throw new BaseException('Sorry, the ZIP extension for PHP is not available on this server');
     }
     $entries = array();
     $zip = zip_open($archive);
     if (!is_resource($zip)) {
         throw new BaseException('Invalid zip file; zip error #' . $zip . ' generated');
     }
     while (($entry = zip_read($zip)) !== false) {
         if (!is_resource($entry)) {
             throw new BaseException('Invalid zip entry; zip error #' . $zip . ' generated');
         }
         $name = zip_entry_name($entry);
         if (File::Type($name) == $type) {
             $entries[basename($name)] = self::ExtractEntry($zip, $entry);
         }
     }
     zip_close($zip);
     return $entries;
 }
コード例 #7
0
ファイル: QueueProcessor.php プロジェクト: hackingman/TubeX
 public static function IsRunning()
 {
     // Check for empty pid
     $pid = Cache_MySQL::Get(self::$CACHE_PID);
     if (empty($pid)) {
         return false;
     }
     // Try to use ps to determine if the process is running
     $si = ServerInfo::GetCached();
     if (!empty($si->binaries[ServerInfo::BIN_PS])) {
         return preg_match('~' . $pid . '~', shell_exec($si->binaries[ServerInfo::BIN_PS] . " {$pid}")) > 0;
     }
     // Try to determine based on last ping
     $stats = self::LoadStats();
     if ($stats[self::STAT_RUNNING]) {
         if ($stats[self::STAT_LAST_PING] < time() - self::MAX_PING_INTERVAL) {
             self::MarkStopped();
             return false;
         }
         return true;
     }
     // Last resort, assume not running
     return false;
 }
コード例 #8
0
 public function testIsGet()
 {
     $sv = self::$test_data1;
     $sv[ServerInfo::KEY_REQUEST_METHOD] = ServerInfo::REQUEST_TYPE_GET;
     $info = new ServerInfo($sv);
     $expected = true;
     $actual = $info->isGet();
     $this->assertEquals($expected, $actual, __CLASS__ . "::" . __METHOD__ . ": line " . __LINE__);
     $sv[ServerInfo::KEY_REQUEST_METHOD] = ServerInfo::REQUEST_TYPE_POST;
     $info = new ServerInfo($sv);
     $expected = false;
     $actual = $info->isGet();
     $this->assertEquals($expected, $actual, __CLASS__ . "::" . __METHOD__ . ": line " . __LINE__);
 }
コード例 #9
0
ファイル: ServerInfo.php プロジェクト: hackingman/TubeX
 public static function GetCached()
 {
     if (is_object(self::$instance)) {
         return self::$instance;
     }
     $cached = Cache_MySQL::Get(self::CACHE_NAME);
     if (empty($cached)) {
         return self::Get(true);
     }
     $si = unserialize($cached);
     if (time() - $si->generated >= self::CACHE_LIFETIME) {
         return self::Get(true);
     }
     self::$instance = $si;
     return self::$instance;
 }
コード例 #10
0
    <?php 
$si = ServerInfo::GetCached();
$defaults = array('date_added' => Database_MySQL::Now(), 'status' => STATUS_ACTIVE, 'allow_comments' => 'Yes - Add Immediately', 'allow_ratings' => 1, 'allow_embedding' => 1, 'is_private' => 0);
$_REQUEST = array_merge($defaults, $_REQUEST);
$DB = GetDB();
$categories = $DB->FetchAll('SELECT `category_id`,`name` FROM `tbx_category` ORDER BY `name`');
$clips = $DB->FetchAll('SELECT * FROM `tbx_video_clip` WHERE `video_id`=?', array(Request::Get('video_id')));
?>
    <div id="dialog-header" class="ui-widget-header ui-corner-all">
      <div id="dialog-close"></div>
      <?php 
echo isset($editing) ? 'Update a Video' : 'Add a Video';
?>
    </div>

    <form method="post" action="ajax.php" enctype="multipart/form-data">
      <div id="dialog-panel">
        <div style="padding: 8px;">

        <?php 
if (empty($categories)) {
    ?>
         <div class="message-error">
           You will need to create at least one category before you can begin adding videos
         </div>
        <?php 
} else {
    ?>

        <?php 
    if (!isset($editing)) {
コード例 #11
0
ファイル: Thumbnail.php プロジェクト: hackingman/TubeX
 public static function Resize($image, $size, $quality, $directory, $coords = null)
 {
     $si = ServerInfo::GetCached();
     $directory = Dir::StripTrailingSlash($directory);
     $letterbox = Config::Get('flag_letterbox');
     $resized = $directory . '/' . basename($image);
     list($dst_width, $dst_height) = explode('x', $size);
     // See if image is already the correct size
     $imgsize = @getimagesize($image);
     if ($imgsize === false) {
         return null;
     } else {
         if (empty($coords) && $imgsize[0] <= $dst_width && $imgsize[1] <= $dst_height) {
             copy($image, $resized);
             return $resized;
         }
     }
     $src_width = $imgsize[0];
     $src_height = $imgsize[1];
     $src_aspect = $src_width / $src_height;
     $dst_aspect = $dst_width / $dst_height;
     // Get crop information if $coords was supplied
     // Generally only occurs when image is extracted from a HTML image map
     $crop = $crop_x = $crop_y = $crop_width = $crop_height = null;
     if (!empty($coords)) {
         $crop = explode(',', str_replace(' ', '', $coords));
         // Currently only supporting rect
         if (count($crop) == 4) {
             $crop_x = $crop[0];
             $crop_y = $crop[1];
             $crop_width = $crop[2] - $crop_x;
             $crop_height = $crop[3] - $crop_y;
             $src_aspect = $crop_width / $crop_height;
         }
     }
     // Resize with ImageMagick (preferred)
     if (!$si->shell_exec_disabled && $si->binaries[ServerInfo::BIN_CONVERT]) {
         if ($letterbox) {
             shell_exec($si->binaries[ServerInfo::BIN_CONVERT] . ' ' . escapeshellarg($image) . ' ' . (!empty($crop) ? '-crop ' . escapeshellarg($crop_width . 'x' . $crop_height . '!+' . $crop_x . '+' . $crop_y) . ' ' : '') . '-resize ' . $size . ' ' . '-modulate 110,102,100 ' . '-unsharp 1.5x1.2+1.0+0.10 ' . '-enhance ' . '-size ' . $size . ' ' . 'xc:black ' . '+swap ' . '-gravity center ' . '-quality ' . $quality . ' ' . '-format jpeg ' . '-composite ' . escapeshellarg($resized));
         } else {
             $recrop = null;
             if ($src_aspect > $dst_aspect) {
                 $recrop = '-gravity center -crop ' . escapeshellarg(round($src_height * $dst_aspect) . 'x' . $src_height . '+0+0') . ' ';
             } else {
                 if ($src_aspect < $dst_aspect) {
                     $recrop = '-gravity center -crop ' . escapeshellarg($src_width . 'x' . round($src_width / $dst_aspect) . '+0+0') . ' ';
                 }
             }
             shell_exec($si->binaries[ServerInfo::BIN_CONVERT] . ' ' . escapeshellarg($image) . ' ' . (!empty($crop) ? '-crop ' . escapeshellarg($crop_width . 'x' . $crop_height . '!+' . $crop_x . '+' . $crop_y) . ' ' : '') . (!empty($recrop) ? $recrop : '') . '-resize ' . $size . ' ' . '-modulate 110,102,100 ' . '-unsharp 1.5x1.2+1.0+0.10 ' . '-enhance ' . '-quality ' . $quality . ' ' . '-format jpeg ' . escapeshellarg($resized));
         }
         return $resized;
     } else {
         if ($si->php_extensions[ServerInfo::EXT_GD]) {
             if ($crop) {
                 $temp_src = imagecreatefromjpeg($image);
                 $src = imagecreatetruecolor($crop_width, $crop_height);
                 imagecopy($src, $temp_src, 0, 0, $crop_x, $crop_y, $crop_width, $crop_height);
                 imagedestroy($temp_src);
             } else {
                 $src = imagecreatefromjpeg($image);
             }
             $new_width = $dst_width;
             $new_height = $dst_height;
             $dst_x = 0;
             $dst_y = 0;
             if ($src_aspect > $dst_aspect) {
                 $new_height = round($dst_width * $src_height / $src_width);
                 $dst_y = ($dst_height - $new_height) / 2;
             } else {
                 if ($src_aspect < $dst_aspect) {
                     $new_width = round($dst_height * $src_width / $src_height);
                     $dst_x = ($dst_width - $new_width) / 2;
                 }
             }
             $dst = imagecreatetruecolor($dst_width, $dst_height);
             $black = imagecolorallocate($dst, 0, 0, 0);
             imagefill($dst, 0, 0, 0);
             imagecopyresampled($dst, $src, $dst_x, $dst_y, 0, 0, $new_width, $new_height, $src_width, $src_height);
             imagejpeg($dst, $resized, $quality);
             imagedestroy($src);
             imagedestroy($dst);
             return $resized;
         }
     }
     return $image;
 }
コード例 #12
0
ファイル: check.php プロジェクト: sunxfancy/Questionnaire
                    $str = $this->isfun('sqlite_close');
                    if (strpos($str, '√') !== false) {
                        $str .= '&nbsp; 版本:' . sqlite_libversion();
                    }
                }
                return $str;
                break;
            default:
                return '';
                break;
        }
    }
}
$title = 'PHP服务器信息探针';
$j_version = '1.0.0';
$S = new ServerInfo();
$phpSelf = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$disFuns = get_cfg_var("disable_functions");
$disFuns = strpos('phpinfo', needle) ? '<font color="red">×</font>' : "<a href='{$phpSelf}?act=phpinfo' target='_blank'>PHPINFO</a>";
$strcookies = isset($_COOKIE) ? '<font color="green">√</font>' : '<font color="red">×</font>';
$strsmtp = get_cfg_var("SMTP") ? '<font color="green">√</font>' : '<font color="red">×</font>';
$smtpadd = get_cfg_var("SMTP") ? get_cfg_var("SMTP") : '<font color="red">×</font>';
//ajax调用实时刷新
if ($_GET['act'] == "rt") {
    $arr = array('useSpace' => $S->hd['u'], 'freeSpace' => $S->hd['f'], 'hdPercent' => $S->hd['PCT'], 'barhdPercent' => $S->hd['PCT'] . '%', 'TotalMemory' => $S->sysInfo['memTotal'], 'UsedMemory' => $S->sysInfo['memUsed'], 'FreeMemory' => $S->sysInfo['memFree'], 'CachedMemory' => $S->sysInfo['memCached'], 'Buffers' => $S->sysInfo['memBuffers'], 'TotalSwap' => $S->sysInfo['swapTotal'], 'swapUsed' => $S->sysInfo['swapUsed'], 'swapFree' => $S->sysInfo['swapFree'], 'loadAvg' => $S->sysInfo['loadAvg'], 'uptime' => $S->sysInfo['uptime'], 'freetime' => "{$freetime}", 'bjtime' => "{$bjtime}", 'stime' => $S->S['sTime'], 'cpuuse' => $S->CPU_Use, 'memRealPercent' => $S->sysInfo['memRealPercent'], 'memRealUsed' => $S->sysInfo['memRealUsed'], 'memRealFree' => $S->sysInfo['memRealFree'], 'memPercent' => $S->sysInfo['memPercent'] . '%', 'memCachedPercent' => $S->sysInfo['memCachedPercent'], 'barmemCachedPercent' => $S->sysInfo['memCachedPercent'] . '%', 'swapPercent' => $S->sysInfo['swapPercent'], 'barmemRealPercent' => $S->sysInfo['memRealPercent'] . '%', 'barswapPercent' => $S->sysInfo['swapPercent'] . '%', 'NetOut2' => $S->NetWork['NetOut'][2], 'NetOut3' => $S->NetWork['NetOut'][3], 'NetOut4' => $S->NetWork['NetOut'][4], 'NetOut5' => $S->NetWork['NetOut'][5], 'NetOut6' => $S->NetWork['NetOut'][6], 'NetOut7' => $S->NetWork['NetOut'][7], 'NetOut8' => $S->NetWork['NetOut'][8], 'NetOut9' => $S->NetWork['NetOut'][9], 'NetOut10' => $S->NetWork['NetOut'][10], 'NetInput2' => $S->NetWork['NetInput'][2], 'NetInput3' => $S->NetWork['NetInput'][3], 'NetInput4' => $S->NetWork['NetInput'][4], 'NetInput5' => $S->NetWork['NetInput'][5], 'NetInput6' => $S->NetWork['NetInput'][6], 'NetInput7' => $S->NetWork['NetInput'][7], 'NetInput8' => $S->NetWork['NetInput'][8], 'NetInput9' => $S->NetWork['NetInput'][9], 'NetInput10' => $S->NetWork['NetInput'][10], 'NetOutSpeed2' => $S->NetWork['OutSpeed'][2], 'NetOutSpeed3' => $S->NetWork['OutSpeed'][3], 'NetOutSpeed4' => $S->NetWork['OutSpeed'][4], 'NetOutSpeed5' => $S->NetWork['OutSpeed'][5], 'NetInputSpeed2' => $S->NetWork['InputSpeed'][2], 'NetInputSpeed3' => $S->NetWork['InputSpeed'][3], 'NetInputSpeed4' => $S->NetWork['InputSpeed'][4], 'NetInputSpeed5' => $S->NetWork['InputSpeed'][5]);
    $jarr = json_encode($arr);
    $_GET['callback'] = htmlspecialchars($_GET['callback']);
    echo $_GET['callback'], '(', $jarr, ')';
    exit;
}
function memory_usage()
コード例 #13
0
ファイル: ajax.php プロジェクト: hackingman/TubeX
function tbxDatabaseRestore()
{
    Privileges::Check(Privileges::DATABASE);
    $filename = BASE_DIR . '/data/' . File::Sanitize(Request::Get('filename'));
    if (!is_file($filename)) {
        return JSON::Failure('The file you have selected no longer exists on the server.');
    }
    $si = ServerInfo::GetCached();
    if (!$si->shell_exec_disabled && $si->binaries[ServerInfo::BIN_PHP]) {
        Shell::ExecScript('cron.php --restore --file=' . escapeshellarg($filename));
        JSON::Success('Database restore has been started.  Allow a few minutes to complete, then continue with the next step of the restore process.');
    } else {
        $DB = GetDB();
        $DB->RestoreTables($filename);
        JSON::Success('Database restore has been completed');
    }
}
コード例 #14
0
ファイル: otapi.php プロジェクト: rozgo/Open-Transactions
 function __get($var)
 {
     $func = 'Server_' . $var . '_get';
     if (function_exists($func)) {
         $r = call_user_func($func, $this->_cPtr);
         if (!is_resource($r)) {
             return $r;
         }
         $c = substr(get_resource_type($r), strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3);
         return new $c($r);
     }
     if ($var === 'thisown') {
         return swig_otapi_get_newobject($this->_cPtr);
     }
     return ServerInfo::__get($var);
 }
コード例 #15
0
 private function load()
 {
     $now = time();
     $max_age = 130;
     // 2+ mins.
     $this->servers = array();
     while (!feof($this->file)) {
         $line = trim(fgets($this->file, 4096));
         if ($line == "--") {
             // Expired announcements are ignored.
             if ($now - $record['time'] < $max_age && count($record) >= 3) {
                 $info = ServerInfo::constructFrom($record);
                 $this->servers[$info->ident()] = $info;
             }
             $record = array();
         } else {
             $parts = explode(" ", $line);
             $record[$parts[0]] = isset($parts[1]) ? urldecode($parts[1]) : "";
         }
     }
 }
コード例 #16
0
ファイル: ServerWrap.php プロジェクト: Nubtehy/openProjects
 public function ServerWrap($url)
 {
     parent::__construct($url);
 }
コード例 #17
0
ファイル: Info.php プロジェクト: hackingman/TubeX
 public static function CanExtract()
 {
     $si = ServerInfo::GetCached();
     return !$si->shell_exec_disabled && $si->binaries[ServerInfo::BIN_MENCODER];
 }
コード例 #18
0
 function __get($var)
 {
     $func = 'Server_' . $var . '_get';
     if (function_exists($func)) {
         return call_user_func($func, $this->_cPtr);
     }
     if ($var === 'thisown') {
         return swig_otapi_get_newobject($this->_cPtr);
     }
     return ServerInfo::__get($var);
 }
コード例 #19
0
ファイル: pear.php プロジェクト: Nubtehy/openProjects
<?php

require_once 'class/ServerInfo.php';
$info = new ServerInfo('www.inedo.com');
var_dump($info->isGzip());
var_dump($info->header);
var_dump($info->validateW3C());
var_dump($info->getValidateW3Cerrors());
var_dump($info->getValidateW3Cwarnings());
コード例 #20
0
ファイル: Shell.php プロジェクト: hackingman/TubeX
 public static function ExecScript($cmd, $background = true)
 {
     $si = ServerInfo::GetCached();
     $cmd = ($si->php_binary_is_cli ? $si->binaries[ServerInfo::BIN_PHP_CLI] . ' ' . $cmd : $si->binaries[ServerInfo::BIN_PHP_CGI] . ' -q ' . $cmd) . ($background ? ' >/dev/null 2>&1 &' : '');
     return shell_exec($cmd);
 }
コード例 #21
0
ファイル: FrameGrabber.php プロジェクト: hackingman/TubeX
 public static function CanGrab()
 {
     $si = ServerInfo::GetCached();
     return !$si->shell_exec_disabled && $si->binaries[ServerInfo::BIN_MPLAYER];
 }