コード例 #1
0
/**
* Automatically update the agent binaries from the public agents (if configured)
* 
*/
function AgentUpdate()
{
    $updateServer = GetSetting('agentUpdate');
    echo "\nChecking for agent update...\n";
    if ($updateServer && strlen($updateServer)) {
        if (!is_dir('./work/update')) {
            mkdir('./work/update', 0777, true);
        }
        $url = $updateServer . 'work/getupdates.php';
        $updates = json_decode(http_fetch($url), true);
        if ($updates && is_array($updates) && count($updates)) {
            foreach ($updates as $update) {
                $needsUpdate = true;
                $ini = "./work/update/{$update['name']}.ini";
                $zip = "./work/update/{$update['name']}.zip";
                if (is_file($ini) && is_file($zip)) {
                    $current = parse_ini_file($ini);
                    if ($current['ver'] == $update['ver']) {
                        $needsUpdate = false;
                    }
                }
                if ($needsUpdate && isset($update['md5'])) {
                    $tmp = "./work/update/{$update['name']}.tmp";
                    if (is_file($tmp)) {
                        unlink($tmp);
                    }
                    $url = $updateServer . str_replace(" ", "%20", "work/update/{$update['name']}.zip?v={$update['ver']}");
                    echo "Fetching {$url}\n";
                    if (http_fetch_file($url, $tmp)) {
                        $md5 = md5_file($tmp);
                        if ($md5 == $update['md5']) {
                            if (is_file("{$ini}.bak")) {
                                unlink("{$ini}.bak");
                            }
                            if (is_file($ini)) {
                                rename($ini, "{$ini}.bak");
                            }
                            if (is_file("{$zip}.bak")) {
                                unlink("{$zip}.bak");
                            }
                            if (is_file($zip)) {
                                rename($zip, "{$zip}.bak");
                            }
                            rename($tmp, $zip);
                            $z = new ZipArchive();
                            if ($z->open($zip) === TRUE) {
                                $z->extractTo('./work/update', "{$update['name']}.ini");
                                $z->close();
                            }
                        }
                    }
                }
            }
        }
    }
}
コード例 #2
0
ファイル: statsd.inc.php プロジェクト: NeilBryant/webpagetest
function graphite_key($location, $browser, $label, $cached, $metric)
{
    if (GetSetting('statsdCleanPattern')) {
        $label = preg_replace('/' . GetSetting('statsdPattern') . '/', '', $label);
    }
    $fvrv = $cached ? 'repeat' : 'first';
    $locationParts = explode('_', $location);
    $location = $locationParts[0];
    return "{$location}.{$browser}.{$label}.{$fvrv}.";
}
コード例 #3
0
/**
* Convert an AVI video capture into the video frames the WPT is expecting
* 
* @param mixed $testPath
* @param mixed $run
* @param mixed $cached
*/
function ProcessAVIVideo(&$test, $testPath, $run, $cached)
{
    global $max_load;
    $cachedText = '';
    if ($cached) {
        $cachedText = '_Cached';
    }
    $videoFile = "{$testPath}/{$run}{$cachedText}_video.mp4";
    $crop = '';
    if (!is_file($videoFile)) {
        $videoFile = "{$testPath}/{$run}{$cachedText}_video.avi";
    }
    if (!GetSetting('disable_video_processing') && is_file($videoFile)) {
        $videoDir = "{$testPath}/video_{$run}" . strtolower($cachedText);
        if (!is_file("{$videoDir}/video.json")) {
            if (isset($max_load) && $max_load > 0) {
                WaitForSystemLoad($max_load, 3600);
            }
            if (is_dir($videoDir)) {
                delTree($videoDir, false);
            }
            if (!is_dir($videoDir)) {
                mkdir($videoDir, 0777, true);
            }
            $videoFile = realpath($videoFile);
            $videoDir = realpath($videoDir);
            if (strlen($videoFile) && strlen($videoDir)) {
                if (PythonVisualMetrics($videoFile, $videoDir, $testPath, $run, $cached)) {
                    unlink($videoFile);
                } else {
                    $crop = FindVideoCrop($videoFile, $videoDir);
                    if (Video2PNG($videoFile, $videoDir, $crop)) {
                        $startOffset = DevToolsGetVideoOffset($testPath, $run, $cached, $endTime);
                        FindAVIViewport($videoDir, $startOffset, $viewport);
                        EliminateDuplicateAVIFiles($videoDir, $viewport);
                        $lastImage = ProcessVideoFrames($videoDir, $viewport);
                        $screenShot = "{$testPath}/{$run}{$cachedText}_screen.jpg";
                        if (isset($lastImage) && is_file($lastImage)) {
                            unlink($videoFile);
                            if (!is_file($screenShot)) {
                                copy($lastImage, $screenShot);
                            }
                        }
                    }
                }
            }
            $videoInfo = array();
            if (isset($viewport)) {
                $videoInfo['viewport'] = $viewport;
            }
            file_put_contents("{$videoDir}/video.json", json_encode($videoInfo));
        }
    }
}
コード例 #4
0
 private function _createLegend()
 {
     $out = '';
     if (!GetSetting('mime_waterfalls')) {
         $out .= '<table border="1" bordercolor="silver" cellpadding="2px" cellspacing="0" ' . 'style="width:auto; font-size:11px; margin-left:auto; margin-right:auto;">';
         $out .= "\n<tr>\n";
         $out .= $this->_legendBarTableCell("#1f7c83", "DNS Lookup", 15);
         $out .= $this->_legendBarTableCell("#e58226", "Initial Connection", 15);
         if ($this->requests->hasSecureRequests()) {
             $out .= $this->_legendBarTableCell("#c141cd", "SSL Negotiation", 15);
         }
         $out .= $this->_legendBarTableCell("#1fe11f", "Time to First Byte", 15);
         $out .= $this->_legendBarTableCell("#1977dd", "Content Download", 15);
         $out .= $this->_legendHighlightTableCell("#ffff60", "3xx response");
         $out .= $this->_legendHighlightTableCell("#ff6060", "4xx+ response");
         $out .= "</tr>\n</table>\n";
     }
     $out .= '<table border="1" bordercolor="silver" cellpadding="2px" cellspacing="0" ' . 'style="width:auto; font-size:11px; margin-left:auto; margin-right:auto; margin-top:11px;">';
     $out .= "\n<tr>\n";
     $out .= $this->_legendBarTableCell("#28BC00", "Start Render", 2);
     if ($this->stepResult->getMetric("aft")) {
         $out .= $this->_legendBarTableCell("#FF0000", "Above the Fold", 2);
     }
     if ((double) $this->stepResult->getMetric("domTime")) {
         $out .= $this->_legendBarTableCell("#F28300", "DOM Element", 2);
     }
     if ((double) $this->stepResult->getMetric("firstPaint")) {
         $out .= $this->_legendBarTableCell("#8FBC83", "msFirstPaint", 2);
     }
     if ((double) $this->stepResult->getMetric("domInteractive")) {
         $out .= $this->_legendBarTableCell("#FFC61A", "DOM Interactive", 2);
     }
     if ((double) $this->stepResult->getMetric("domContentLoadedEventStart")) {
         $out .= $this->_legendBarTableCell("#D888DF", "DOM Content Loaded", 15);
     }
     if ((double) $this->stepResult->getMetric("loadEventStart")) {
         $out .= $this->_legendBarTableCell("#C0C0FF", "On Load", 15);
     }
     $out .= $this->_legendBarTableCell("#0000FF", "Document Complete", 2);
     if (GetSetting('waterfall_show_user_timing') && ($this->stepResult->getMetric('userTime') || $this->hasCsi)) {
         $out .= '<td><table><tr><td><div class="arrow-down"></div></td><td>User Timings</td></tr></table></td>';
     }
     $out .= "</tr>\n</table>\n<br>";
     return $out;
 }
コード例 #5
0
ファイル: runtest.php プロジェクト: it114/webpagetest
/**
* See if we are requiring key validation and if so, enforce the restrictions
*
* @param mixed $test
* @param mixed $error
*/
function ValidateKey(&$test, &$error, $key = null)
{
    global $admin;
    // load the secret key (if there is one)
    $secret = '';
    $keys = parse_ini_file('./settings/keys.ini', true);
    if ($keys && isset($keys['server']) && isset($keys['server']['secret'])) {
        $secret = trim($keys['server']['secret']);
    }
    if (strlen($secret)) {
        // ok, we require key validation, see if they have an hmac (user with form)
        // or API key
        if (!isset($key) && isset($test['vh']) && strlen($test['vh'])) {
            // validate the hash
            $hashStr = $secret;
            $hashStr .= $_SERVER['HTTP_USER_AGENT'];
            $hashStr .= $test['owner'];
            $hashStr .= $test['vd'];
            $hmac = sha1($hashStr);
            // check the elapsed time since the hmac was issued
            $now = time();
            $origTime = strtotime($test['vd']);
            $elapsed = abs($now - $origTime);
            if ($hmac != $test['vh'] || $elapsed > 86400) {
                $error = 'Your test request could not be validated (this can happen if you leave the browser window open for over a day before submitting a test).  Please try submitting it again.';
            }
        } elseif (isset($key) || isset($test['key']) && strlen($test['key'])) {
            if (isset($test['key']) && strlen($test['key']) && !isset($key)) {
                $key = $test['key'];
            }
            // see if it was an auto-provisioned key
            if (preg_match('/^(?P<prefix>[0-9A-Za-z]+)\\.(?P<key>[0-9A-Za-z]+)$/', $key, $matches)) {
                $prefix = $matches['prefix'];
                $db = new SQLite3(__DIR__ . "/dat/{$prefix}_api_keys.db");
                $k = $db->escapeString($matches['key']);
                $info = $db->querySingle("SELECT key_limit FROM keys WHERE key='{$k}'", true);
                $db->close();
                if (isset($info) && is_array($info) && isset($info['key_limit'])) {
                    $keys[$key] = array('limit' => $info['key_limit']);
                }
            }
            // validate their API key and enforce any rate limits
            if (array_key_exists($key, $keys)) {
                if (array_key_exists('default location', $keys[$key]) && strlen($keys[$key]['default location']) && !strlen($test['location'])) {
                    $test['location'] = $keys[$key]['default location'];
                }
                if (isset($keys[$key]['priority'])) {
                    $test['priority'] = $keys[$key]['priority'];
                }
                if (isset($keys[$key]['limit'])) {
                    $limit = (int) $keys[$key]['limit'];
                    // update the number of tests they have submitted today
                    if (!is_dir('./dat')) {
                        mkdir('./dat', 0777, true);
                    }
                    $lock = Lock("API Keys");
                    if (isset($lock)) {
                        $keyfile = './dat/keys_' . gmdate('Ymd') . '.dat';
                        $usage = null;
                        if (is_file($keyfile)) {
                            $usage = json_decode(file_get_contents($keyfile), true);
                        }
                        if (!isset($usage)) {
                            $usage = array();
                        }
                        if (isset($usage[$key])) {
                            $used = (int) $usage[$key];
                        } else {
                            $used = 0;
                        }
                        $runcount = max(1, $test['runs']);
                        if (!$test['fvonly']) {
                            $runcount *= 2;
                        }
                        if ($limit > 0) {
                            if ($used + $runcount <= $limit) {
                                $used += $runcount;
                                $usage[$key] = $used;
                            } else {
                                $error = 'The test request will exceed the daily test limit for the given API key';
                            }
                        } else {
                            $used += $runcount;
                            $usage[$key] = $used;
                        }
                        if (!strlen($error)) {
                            file_put_contents($keyfile, json_encode($usage));
                        }
                        Unlock($lock);
                    }
                }
                // check to see if we need to limit queue lengths from this API key
                if ($keys[$key]['queue_limit']) {
                    $test['queue_limit'] = $keys[$key]['queue_limit'];
                }
            } else {
                $error = 'Invalid API Key';
            }
            if (!strlen($error) && $key != $keys['server']['key']) {
                global $usingAPI;
                $usingAPI = true;
            }
        } elseif (!isset($admin) || !$admin) {
            $error = 'An error occurred processing your request (missing API key).';
            if (GetSetting('allow_getkeys')) {
                $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
                $url = "{$protocol}://{$_SERVER['HTTP_HOST']}/getkey.php";
                $error .= "  If you do not have an API key assigned you can request one at {$url}";
            }
        }
    }
}
コード例 #6
0
				<p><input type="text" name="title<?php 
    echo $recROW['language_id'];
    ?>
" value="<?php 
    echo $title;
    ?>
"></p>				
				<div class="editor_holder">		
					<?php 
    $sBasePath = $absoluteURL . 'includes/php.module/fckeditor/';
    $body_text = 'body' . $recROW['language_id'];
    $oFCKeditor = new FCKeditor("{$body_text}");
    $oFCKeditor->BasePath = $sBasePath;
    $oFCKeditor->Value = $body;
    $oFCKeditor->ToolbarSet = GetSetting('toolbar_set', $feature_id);
    $oFCKeditor->Height = GetSetting('height', $feature_id);
    //$oFCKeditor->Config['EditorAreaCSS']	= $docRoot.'includes/style/editableregion.css';
    $oFCKeditor->Create();
    ?>
				</div>
	
			</div>
			
			<script type="text/javascript">	animatedcollapse.addDiv('content_<?php 
    echo $recROW['language_id'];
    ?>
', 'fade=0,speed=1000')</script>
	
	<?php 
}
?>
コード例 #7
0
ファイル: fppjson.php プロジェクト: rudybrian/fpp
function SetSetting()
{
    global $args, $SUDO;
    $setting = $args['key'];
    $value = $args['value'];
    check($setting, "setting", __FUNCTION__);
    check($value, "value", __FUNCTION__);
    WriteSettingToFile($setting, $value);
    if ($setting == "LogLevel") {
        SendCommand("LogLevel,{$value},");
    } else {
        if ($setting == "LogMask") {
            $newValue = "";
            if ($value != "") {
                $newValue = preg_replace("/,/", ";", $value);
            }
            SendCommand("LogMask,{$newValue},");
        } else {
            if ($setting == "HostName") {
                $value = preg_replace("/[^a-zA-Z0-9]/", "", $value);
                exec($SUDO . " sed -i 's/^.*\$/{$value}/' /etc/hostname ; " . $SUDO . " sed -i '/^127.0.1.1[^0-9]/d' /etc/hosts ; " . $SUDO . " sed -i '\$a127.0.1.1 {$value}' /etc/hosts ; " . $SUDO . " hostname {$value} ; " . $SUDO . " /etc/init.d/avahi-daemon restart ;" . $SUDO . " systemctl restart avahi-daemon.service", $output, $return_val);
                sleep(1);
                // Give Avahi time to restart before we return
            } else {
                if ($setting == "EnableRouting") {
                    if ($value != "1") {
                        $value = "0";
                    }
                    exec($SUDO . " sed -i '/net.ipv4.ip_forward/d' /etc/sysctl.conf; " . $SUDO . " sed -i '\$anet.ipv4.ip_forward = {$value}' /etc/sysctl.conf ; " . $SUDO . " sysctl --system", $output, $return_val);
                } else {
                    if ($setting == "storageDevice") {
                        exec('mount | grep boot | cut -f1 -d" " | sed -e "s/\\/dev\\///" -e "s/p[0-9]$//"', $output, $return_val);
                        $bootDevice = $output[0];
                        unset($output);
                        if (preg_match("/{$bootDevice}/", $value)) {
                            exec($SUDO . " sed -i 's/.*home\\/fpp\\/media/#\\/dev\\/sda1    \\/home\\/fpp\\/media/' /etc/fstab", $output, $return_val);
                        } else {
                            exec($SUDO . " sed -i 's/.*home\\/fpp\\/media/\\/dev\\/{$value}    \\/home\\/fpp\\/media/' /etc/fstab", $output, $return_val);
                        }
                    } else {
                        if ($setting == "AudioOutput") {
                            SetAudioOutput($value);
                        } else {
                            if ($setting == "ForceHDMI") {
                                if ($value) {
                                    exec($SUDO . " sed -i '/hdmi_force_hotplug/d' /boot/config.txt; " . $SUDO . " sed -i '\$ahdmi_force_hotplug=1' /boot/config.txt", $output, $return_val);
                                } else {
                                    exec($SUDO . " sed -i '/hdmi_force_hotplug/d' /boot/config.txt; " . $SUDO . " sed -i '\$a#hdmi_force_hotplug=1' /boot/config.txt", $output, $return_val);
                                }
                            } else {
                                SendCommand("SetSetting,{$setting},{$value},");
                            }
                        }
                    }
                }
            }
        }
    }
    GetSetting();
}
コード例 #8
0
ファイル: index.php プロジェクト: NeilBryant/webpagetest
                                         <small>Chrome 34+ on Android</small>
                                     </label>
                                 </li>
                                 <?php 
 if ($admin && GetSetting('wprDesktop')) {
     ?>
                                 <li>
                                     <input type="checkbox" name="wprDesktop" id="wprDesktop" class="checkbox" style="float: left;width: auto;">
                                     <label for="wprDesktop" class="auto_width">
                                         Use Web Page Replay recorded Desktop Page<br>
                                         <small>Limited list of available <a href="/wprDesktop.txt">URLs</a></small>
                                     </label>
                                 </li>
                                 <?php 
 }
 if ($admin && GetSetting('wprMobile')) {
     ?>
                                 <li>
                                     <input type="checkbox" name="wprMobile" id="wprMobile" class="checkbox" style="float: left;width: auto;">
                                     <label for="wprMobile" class="auto_width">
                                         Use Web Page Replay recorded Mobile Page<br>
                                         <small>Limited list of available <a href="/wprMobile.txt">URLs</a></small>
                                     </label>
                                 </li>
                                 <?php 
 }
 ?>
                                 <li>
                                     <label for="hostResolverRules" style="width: auto;">
                                     <a href="https://github.com/atom/electron/blob/master/docs/api/chrome-command-line-switches.md#--host-rulesrules">Host Rules</a><br>
                                     <small>i.e. MAP * 1.2.3.4</small>
コード例 #9
0
 ArchiveTest($id, false);
 // post the test to tsview if requested
 $tsviewdb = GetSetting('tsviewdb');
 if (array_key_exists('tsview_id', $testInfo) && strlen($testInfo['tsview_id']) && strlen($tsviewdb) && is_file('./lib/tsview.inc.php')) {
     require_once './lib/tsview.inc.php';
     TSViewPostResult($testInfo, $id, $testPath, $settings['tsviewdb'], $testInfo['tsview_id']);
 }
 // post the test to statsd if requested
 if (GetSetting('statsdHost') && is_file('./lib/statsd.inc.php')) {
     require_once './lib/statsd.inc.php';
     StatsdPostResult($testInfo, $testPath);
 }
 // Send an email notification if necessary
 $notifyFrom = GetSetting('notifyFrom');
 if ($notifyFrom && strlen($notifyFrom) && is_file("{$testPath}/testinfo.ini")) {
     $host = GetSetting('host');
     $test = parse_ini_file("{$testPath}/testinfo.ini", true);
     if (array_key_exists('notify', $test['test']) && strlen($test['test']['notify'])) {
         notify($test['test']['notify'], $notifyFrom, $id, $testPath, $host);
     }
 }
 // send a callback/pingback request
 if (isset($testInfo) && isset($testInfo['callback']) && strlen($testInfo['callback'])) {
     $send_callback = true;
     $testId = $id;
     if (array_key_exists('batch_id', $testInfo) && strlen($testInfo['batch_id'])) {
         require_once 'testStatus.inc';
         $testId = $testInfo['batch_id'];
         $status = GetTestStatus($testId);
         $send_callback = false;
         if (array_key_exists('statusCode', $status) && $status['statusCode'] == 200) {
コード例 #10
0
/**
* Calculate histograms for each color channel for the given image
*/
function GetImageHistogram($image_file, $options, $histograms)
{
    $histogram = null;
    $ext = strripos($image_file, '.jpg');
    if ($ext !== false) {
        $histogram_file = substr($image_file, 0, $ext) . '.hist';
    } else {
        $ext = strripos($image_file, '.png');
        if ($ext !== false) {
            $histogram_file = substr($image_file, 0, $ext) . '.hist';
        }
    }
    if (isset($histograms)) {
        // figure out the timestamp for the video frame in ms
        $ms = null;
        if (preg_match('/ms_(?P<ms>[0-9]+)\\.(png|jpg)/i', $image_file, $matches)) {
            $ms = intval($matches['ms']);
        } elseif (preg_match('/frame_(?P<ms>[0-9]+)\\.(png|jpg)/i', $image_file, $matches)) {
            $ms = intval($matches['ms']) * 100;
        }
        foreach ($histograms as &$hist) {
            if (isset($hist['histogram']) && isset($hist['time']) && $hist['time'] == $ms) {
                $histogram = $hist['histogram'];
                break;
            }
        }
    }
    // See if we have the old-style histograms (separate files)
    if (!isset($histogram) && !isset($options) && isset($histogram_file) && is_file($histogram_file)) {
        $histogram = json_decode(file_get_contents($histogram_file), true);
        if (!is_array($histogram) || !array_key_exists('r', $histogram) || !array_key_exists('g', $histogram) || !array_key_exists('b', $histogram) || count($histogram['r']) != 256 || count($histogram['g']) != 256 || count($histogram['b']) != 256) {
            unset($histogram);
        }
    }
    // generate a histogram from the image itself
    if (!isset($histogram) && !GetSetting('disable_image_processing')) {
        $im = imagecreatefromjpeg($image_file);
        if ($im !== false) {
            $width = imagesx($im);
            $height = imagesy($im);
            if ($width > 0 && $height > 0) {
                // default a resample to 1/4 in each direction which will significantly speed up processing with minimal impact to accuracy.
                // This is only for calculations done on the server.  Histograms from the client look at every pixel
                $resample = 8;
                if (isset($options) && array_key_exists('resample', $options)) {
                    $resample = $options['resample'];
                }
                if ($resample > 2) {
                    $oldWidth = $width;
                    $oldHeight = $height;
                    $width = intval($width * 2 / $resample);
                    $height = intval($height * 2 / $resample);
                    $tmp = imagecreatetruecolor($width, $height);
                    fastimagecopyresampled($tmp, $im, 0, 0, 0, 0, $width, $height, $oldWidth, $oldHeight, 3);
                    imagedestroy($im);
                    $im = $tmp;
                    unset($tmp);
                }
                $histogram = array();
                $histogram['r'] = array();
                $histogram['g'] = array();
                $histogram['b'] = array();
                $buckets = 256;
                if (isset($options) && array_key_exists('buckets', $options) && $options['buckets'] >= 1 && $options['buckets'] <= 256) {
                    $buckets = $options['buckets'];
                }
                for ($i = 0; $i < $buckets; $i++) {
                    $histogram['r'][$i] = 0;
                    $histogram['g'][$i] = 0;
                    $histogram['b'][$i] = 0;
                }
                for ($y = 0; $y < $height; $y++) {
                    for ($x = 0; $x < $width; $x++) {
                        $rgb = ImageColorAt($im, $x, $y);
                        $r = $rgb >> 16 & 0xff;
                        $g = $rgb >> 8 & 0xff;
                        $b = $rgb & 0xff;
                        // ignore white pixels
                        if ($r != 255 || $g != 255 || $b != 255) {
                            if (isset($options) && array_key_exists('colorSpace', $options) && $options['colorSpace'] != 'RGB') {
                                if ($options['colorSpace'] == 'HSV') {
                                    RGB_TO_HSV($r, $g, $b);
                                } elseif ($options['colorSpace'] == 'YUV') {
                                    RGB_TO_YUV($r, $g, $b);
                                }
                            }
                            $bucket = (int) (($r + 1.0) / 256.0 * $buckets) - 1;
                            $histogram['r'][$bucket]++;
                            $bucket = (int) (($g + 1.0) / 256.0 * $buckets) - 1;
                            $histogram['g'][$bucket]++;
                            $bucket = (int) (($b + 1.0) / 256.0 * $buckets) - 1;
                            $histogram['b'][$bucket]++;
                        }
                    }
                }
            }
            imagedestroy($im);
            unset($im);
        }
        if (!isset($options) && isset($histogram_file) && !is_file($histogram_file) && isset($histogram)) {
            file_put_contents($histogram_file, json_encode($histogram));
        }
    }
    return $histogram;
}
コード例 #11
0
ファイル: getwork.php プロジェクト: nowol79/webpagetest-1
        $is_done = GetReboot();
    }
    if (!$is_done && array_key_exists('ver', $_GET)) {
        $is_done = GetUpdate();
    }
    if (!$is_done && @$_GET['video']) {
        $is_done = GetVideoJob();
    }
    foreach ($locations as $loc) {
        $location = trim($loc);
        if (!$is_done && strlen($location)) {
            $is_done = GetJob();
        }
    }
} elseif (isset($_GET['freedisk']) && (double) $_GET['freedisk'] <= 0.1) {
    if (isset($_GET['reboot']) && GetSetting("lowDiskReboot")) {
        header('Content-type: text/plain');
        header("Cache-Control: no-cache, must-revalidate");
        header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
        echo "Reboot";
        $is_done = true;
    }
}
// kick off any cron work we need to do asynchronously
CheckCron();
// Send back a blank result if we didn't have anything.
if (!$is_done) {
    header('Content-type: text/plain');
    header("Cache-Control: no-cache, must-revalidate");
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
}
コード例 #12
0
ファイル: getkey.php プロジェクト: NeilBryant/webpagetest
/**
* The request has been validated, generate the API key
* 
* @param mixed $request
*/
function CreateApiKey($request)
{
    global $prefix;
    $info = false;
    if ($db = OpenKeysDatabase()) {
        $email = '"' . $request['email'] . '"';
        $name = 'NULL';
        if (isset($request['name']) && strlen($request['name'])) {
            $name = '"' . $db->escapeString($request['name']) . '"';
        }
        $company = 'NULL';
        if (isset($request['company']) && strlen($request['company'])) {
            $company = '"' . $db->escapeString($request['company']) . '"';
        }
        $website = 'NULL';
        if (isset($request['website']) && strlen($request['website'])) {
            $website = '"' . $db->escapeString($request['website']) . '"';
        }
        $contact = 0;
        if (isset($request['contact']) && $request['contact']) {
            $contact = 1;
        }
        $ip = '"' . $db->escapeString($_SERVER["REMOTE_ADDR"]) . '"';
        $key = md5(uniqid(rand(), true));
        $now = time();
        $limit = GetSetting('api_key_limit');
        if (!$limit) {
            $limit = 200;
        }
        $query = "INSERT INTO keys (key, created, key_limit, email, ip, name, company, website, contact) VALUES (\"{$key}\", {$now}, {$limit}, {$email}, {$ip}, {$name}, {$company}, {$website}, {$contact})";
        if ($db->query($query)) {
            $info = $request;
            $info['key'] = $key;
            $info['key_limit'] = $limit;
            logMsg("{$ip},{$email},{$name},{$company},{$website},{$contact}", __DIR__ . '/log/keys.log', true);
        }
        $db->close();
    }
    return $info;
}
コード例 #13
0
ファイル: 5min.php プロジェクト: NeilBryant/webpagetest
set_time_limit(1200);
error_reporting(E_ALL);
$lock = Lock("cron-5", false, 1200);
if (!isset($lock)) {
    exit(0);
}
if (GetSetting('ec2')) {
    CleanGetWork();
}
require_once './ec2/ec2.inc.php';
if (GetSetting('ec2_key')) {
    EC2_TerminateIdleInstances();
    EC2_StartNeededInstances();
    EC2_DeleteOrphanedVolumes();
}
if (GetSetting('sbl_api_key')) {
    SBL_Update();
}
/**
* Clean up extraneous getwork.php.xxx files that may be left behind
* from using wget in a cron job.  The server AMI was supposed to run wget
* silently but there have been reports of the files getting created
* 
*/
function CleanGetWork()
{
    $files = glob('/var/www/getwork.php.*');
    foreach ($files as $file) {
        if (is_file($file)) {
            unlink($file);
        }
コード例 #14
0
?>
 </div>
	</div>
	<div class="top_navigation">
		<ul class="top_navigation_link_container">
			<li><a href="<?php 
echo $absoluteURL . "admin.space/";
?>
" target="_top">Home</a></li>
			<li style="background-image:none"><a href="<?php 
echo $absoluteURL . "admin.space/login/logout.php";
?>
" target="_top">Log out</a></li>
		</ul>
		<div class="back_end_name"><?php 
echo GetSetting('BackendName');
?>
</div>
	</div>
	<div class="top_sub_navigation">You are logged in as <strong><?php 
echo ucfirst(getAdmin($_SESSION['admin_login']));
?>
</strong>. Not you, please 
		<strong><a href="<?php 
echo $absoluteURL . "admin.space/login/logout.php";
?>
" target="_top">Sign out</a></strong></div>
</div>
</body>

</html>
コード例 #15
0
function usortpage()
{
    $admin_id = $_SESSION['admin_login'];
    if ($_GET['id'] && isset($_GET['pid']) && isset($_GET['usort']) && isset($_GET['fid'])) {
        // make GET vars easier to handle
        $dir = $_GET['dir'];
        // cast as int and couple with switch for sql injection prevention for $id
        $id = (int) $_GET['id'];
        $usort = (int) $_GET['usort'];
        $pid = (int) $_GET['pid'];
        $fid = (int) $_GET['fid'];
        $value = GetSetting('Dir', $fid);
        switch ($value) {
            // if we're going up, swap is 1 less than id
            case 'down':
                // make sure that there's a row above to swap
                //Check if there is a higher sort order
                $sql = "SELECT nav_tab_id,usort FROM navigation_tab WHERE usort > '{$usort}'  AND parent_id = '{$pid}' ORDER BY usort ASC LIMIT 1";
                $set = mysql_query($sql) or die(mysql_error());
                if ($row = mysql_fetch_assoc($set)) {
                    $swap_id = $row['nav_tab_id'];
                    $swap_usort = $row['usort'];
                    $sql = "UPDATE navigation_tab SET admin_id = 'Sort - {$admin_id}', usort = CASE nav_tab_id WHEN {$id} THEN {$swap_usort} WHEN {$swap_id} THEN {$usort} END WHERE nav_tab_id IN ({$id}, {$swap_id})";
                    /*
                                CASE Id
                                WHEN '$id' THEN UPDATE 
                                as t1, info as t2 SET t1.usort = '$swap_usort' WHERE usort WHEN $usort THEN $swap WHEN $swap THEN $usort END WHERE usort IN ($usort, $swap)";
                    */
                } else {
                    $usort++;
                    $sql = "UPDATE navigation_tab SET admin_id = '{$admin_id}', usort = '{$usort}' WHERE nav_tab_id = '{$id}'";
                }
                break;
                // if we're going down, swap is 1 more than id
            // if we're going down, swap is 1 more than id
            case 'up':
                //Check if there is a lower sort order
                $sql = "SELECT nav_tab_id,usort FROM navigation_tab WHERE usort < '{$usort}' AND  parent_id = '{$pid}' ORDER BY usort DESC LIMIT 1";
                $set = mysql_query($sql) or die(mysql_error());
                if ($row = mysql_fetch_assoc($set)) {
                    $swap_id = $row['nav_tab_id'];
                    $swap_usort = $row['usort'];
                    $sql = "UPDATE navigation_tab SET admin_id = 'Sort - {$admin_id}', usort = CASE nav_tab_id WHEN {$id} THEN {$swap_usort} WHEN {$swap_id} THEN {$usort} END WHERE nav_tab_id IN ({$id}, {$swap_id}) ";
                } else {
                    $usort--;
                    $sql = "UPDATE navigation_tab SET admin_id = '{$admin_id}', usort = '{$usort}' WHERE nav_tab_id = '{$id}'";
                }
                break;
                // default value (sql injection prevention for $dir)
            // default value (sql injection prevention for $dir)
            default:
                $swap = $id;
        }
        // end switch $dir
        //die($sql);
        // swap the rows. Basic idea is to make $id=$swap and $swap=$id
        $result = mysql_query($sql) or die(mysql_error());
        $return;
    } else {
        return;
    }
}
コード例 #16
0
ファイル: login.php プロジェクト: xlucagiordanox/webpagetest
<?php

chdir('..');
require_once 'common.inc';
$user = null;
set_include_path(get_include_path() . PATH_SEPARATOR . './lib/oauth');
require_once 'Google/Client.php';
$client_id = GetSetting('google_oauth_client_id');
$client_secret = GetSetting('google_oauth_client_secret');
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['PHP_SELF'];
$redirect_uri = "{$protocol}://{$host}{$uri}";
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setScopes('email');
if (!isset($_GET['code'])) {
    setcookie("page_before_google_oauth", $_SERVER['HTTP_REFERER']);
    $authUrl = $client->createAuthUrl();
    header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL));
    exit;
} else {
    $client->authenticate($_GET['code']);
    $token_data = $client->verifyIdToken()->getAttributes();
    if (isset($token_data['payload']['sub'])) {
        setcookie("google_id", md5($token_data['payload']['sub']), time() + 60 * 60 * 24 * 7 * 2, "/");
    }
    if (isset($token_data['payload']['email'])) {
        setcookie("google_email", $token_data['payload']['email'], time() + 60 * 60 * 24 * 7 * 2, "/");
コード例 #17
0
 $target_medium = GetSetting('target_medium', $feature_id);
 $target_small = GetSetting('target_small', $feature_id);
 $extra_large_width = GetSetting('extra_large_width', $feature_id);
 $extra_large_height = GetSetting('extra_large_height', $feature_id);
 $large_width = GetSetting('large_width', $feature_id);
 $large_height = GetSetting('large_height', $feature_id);
 $medium_width = GetSetting('medium_width', $feature_id);
 $medium_height = GetSetting('medium_height', $feature_id);
 $small_width = GetSetting('small_width', $feature_id);
 $small_height = GetSetting('small_height', $feature_id);
 $multimedia_type = GetSetting('multimedia_type', $feature_id);
 $picture_type = GetSetting('picture_type', $feature_id);
 $resample_extra_large = GetSetting('resample_extra_large', $feature_id);
 $resample_large = GetSetting('resample_large', $feature_id);
 $resample_medium = GetSetting('resample_medium', $feature_id);
 $resample_small = GetSetting('resample_small', $feature_id);
 /*************************************************************************************************************************
 	DO THE PROCESSING
 **************************************************************************************************************************/
 $filename = basename($_FILES['Filedata']['name']);
 $file_basename = substr($filename, 0, strripos($filename, '.'));
 // strip extention
 $file_ext = substr($filename, strripos($filename, '.'));
 $size = $_FILES['Filedata']['size'] / 1024;
 $sort_number = getUsortNumber('multimedia', 'ASC', 'feature_id', $feature_id);
 /*************************************************************************************************************************
 	CHECK THE MAX NUMBER OF PICS ALLOWED AND DELETE THE LAST ONE IF MAX NUMBER REACHED
 **************************************************************************************************************************/
 if (getSetting('max_upload', $feature_id) > 0) {
     $mySQL = "SELECT * FROM multimedia WHERE nav_tab_id = '{$nav_tab_id}' AND feature_id = '{$feature_id}' AND status >0";
     $recSET = mysql_query($mySQL) or die(mysql_error());
コード例 #18
0
ファイル: getwork.php プロジェクト: lucasRolff/webpagetest
/**
* Get an actual task to complete
* 
*/
function GetJob()
{
    $is_done = false;
    global $location;
    global $key;
    global $pc;
    global $ec2;
    global $tester;
    global $recover;
    global $is_json;
    global $dnsServers;
    global $screenwidth;
    global $screenheight;
    global $winver;
    global $isWinServer;
    global $isWin64;
    $workDir = "./work/jobs/{$location}";
    $locInfo = GetLocationInfo($location);
    $locKey = '';
    if (isset($locInfo) && is_array($locInfo) && isset($locInfo['key'])) {
        $locKey = $locInfo['key'];
    }
    $incremental = true;
    if (GetSetting('no_incremental') || isset($locInfo['incremental']) && !$locInfo['incremental']) {
        $incremental = false;
    }
    if (strpos($location, '..') == false && strpos($location, '\\') == false && strpos($location, '/') == false && (!strlen($locKey) || !strcmp($key, $locKey))) {
        $now = time();
        // If it is an EC2 auto-scaling location, make sure the agent isn't marked as offline
        $offline = false;
        if (isset($locInfo['ami'])) {
            $testers = GetTesters($location, true);
            // make sure the tester isn't marked as offline (usually when shutting down EC2 instances)
            $testerCount = isset($testers['testers']) ? count($testers['testers']) : 0;
            $testerIndex = null;
            if ($testerCount) {
                if (strlen($ec2)) {
                    foreach ($testers['testers'] as $index => $testerInfo) {
                        if (isset($testerInfo['ec2']) && $testerInfo['ec2'] == $ec2 && isset($testerInfo['offline']) && $testerInfo['offline']) {
                            $offline = true;
                        }
                        break;
                    }
                }
                foreach ($testers['testers'] as $index => $testerInfo) {
                    if ($testerInfo['id'] == $tester) {
                        $testerIndex = $index;
                        break;
                    }
                }
            }
        }
        if (!$offline) {
            $testInfo = GetTestJob($location, $fileName, $workDir, $priority, $testInfo, $pc, $testerIndex, $testerCount);
            if (isset($testInfo)) {
                $original_test_info = $testInfo;
                $is_done = true;
                $delete = true;
                if ($is_json) {
                    header("Content-type: application/json");
                } else {
                    header('Content-type: text/plain');
                }
                header("Cache-Control: no-cache, must-revalidate");
                header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
                // send the test info to the test agent
                $newline = strpos($testInfo, "\n", 2);
                if ($newline) {
                    $newline++;
                    $after = substr($testInfo, $newline);
                    $testInfo = substr($testInfo, 0, $newline);
                    $software = GetSetting('software');
                    if ($software) {
                        $testInfo .= "software={$software}\r\n";
                    }
                    if (GetSetting('enable_agent_processing')) {
                        $testInfo .= "processResults=1\r\n";
                    }
                    if (!$incremental) {
                        $testInfo .= "incremental=0\r\n";
                    }
                    $testInfo .= $after;
                }
                // extract the test ID from the job file
                if (preg_match('/Test ID=([^\\r\\n]+)\\r/i', $testInfo, $matches)) {
                    $testId = trim($matches[1]);
                }
                if (isset($testId)) {
                    // figure out the path to the results
                    $testPath = './' . GetTestPath($testId);
                    // flag the test with the start time
                    $ini = file_get_contents("{$testPath}/testinfo.ini");
                    if (stripos($ini, 'startTime=') === false) {
                        $time = time();
                        $start = "[test]\r\nstartTime=" . gmdate("m/d/y G:i:s", $time);
                        $out = str_replace('[test]', $start, $ini);
                        file_put_contents("{$testPath}/testinfo.ini", $out);
                    }
                    $lock = LockTest($testId);
                    if ($lock) {
                        $testInfoJson = GetTestInfo($testId);
                        if ($testInfoJson) {
                            if (!array_key_exists('tester', $testInfoJson) || !strlen($testInfoJson['tester'])) {
                                $testInfoJson['tester'] = $tester;
                            }
                            if (isset($dnsServers) && strlen($dnsServers)) {
                                $testInfoJson['testerDNS'] = $dnsServers;
                            }
                            if (!array_key_exists('started', $testInfoJson) || !$testInfoJson['started']) {
                                $testInfoJson['started'] = $time;
                                logTestMsg($testId, "Starting test (initiated by tester {$tester})");
                            }
                            if (!array_key_exists('test_runs', $testInfoJson)) {
                                $testInfoJson['test_runs'] = array();
                            }
                            for ($run = 1; $run <= $testInfoJson['runs']; $run++) {
                                if (!array_key_exists($run, $testInfoJson['test_runs'])) {
                                    $testInfoJson['test_runs'][$run] = array('done' => false);
                                }
                            }
                            $dotPos = stripos($testId, ".");
                            $testInfoJson['id'] = $dotPos === false ? $testId : substr($testId, $dotPos + 1);
                            ProcessTestShard($testInfoJson, $testInfo, $delete, $priority);
                            SaveTestInfo($testId, $testInfoJson);
                        }
                        UnlockTest($lock);
                    }
                }
                if ($delete) {
                    if (isset($fileName) && is_file("{$workDir}/{$fileName}")) {
                        unlink("{$workDir}/{$fileName}");
                    }
                } else {
                    AddTestJobHead($location, $original_test_info, $workDir, $fileName, $priority, true);
                }
                if ($is_json) {
                    $testJson = array();
                    $script = '';
                    $isScript = false;
                    $lines = explode("\r\n", $testInfo);
                    foreach ($lines as $line) {
                        if (strlen(trim($line))) {
                            if ($isScript) {
                                if (strlen($script)) {
                                    $script .= "\r\n";
                                }
                                $script .= $line;
                            } elseif (!strcasecmp($line, '[Script]')) {
                                $isScript = true;
                            } else {
                                $pos = strpos($line, '=');
                                if ($pos !== false) {
                                    $key = trim(substr($line, 0, $pos));
                                    $value = trim(substr($line, $pos + 1));
                                    if (strlen($key) && strlen($value)) {
                                        if ($key == 'customMetric') {
                                            $pos = strpos($value, ':');
                                            if ($pos !== false) {
                                                $metric = trim(substr($value, 0, $pos));
                                                $code = base64_decode(substr($value, $pos + 1));
                                                if ($code !== false && strlen($metric) && strlen($code)) {
                                                    if (!isset($testJson['customMetrics'])) {
                                                        $testJson['customMetrics'] = array();
                                                    }
                                                    $testJson['customMetrics'][$metric] = $code;
                                                }
                                            }
                                        } elseif (is_numeric($value)) {
                                            $testJson[$key] = (int) $value;
                                        } else {
                                            $testJson[$key] = $value;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (strlen($script)) {
                        $testJson['script'] = $script;
                    }
                    // See if we need to include apk information
                    if (isset($_REQUEST['apk']) && is_file(__DIR__ . '/update/apk.dat')) {
                        $apk_info = json_decode(file_get_contents(__DIR__ . '/update/apk.dat'), true);
                        if (isset($apk_info) && is_array($apk_info) && isset($apk_info['packages']) && is_array($apk_info['packages'])) {
                            $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
                            $update_path = dirname($_SERVER['PHP_SELF']) . '/update/';
                            $base_uri = "{$protocol}://{$_SERVER['HTTP_HOST']}{$update_path}";
                            foreach ($apk_info['packages'] as $package => $info) {
                                $apk_info['packages'][$package]['apk_url'] = "{$base_uri}{$apk_info['packages'][$package]['file_name']}?md5={$apk_info['packages'][$package]['md5']}";
                            }
                            $testJson['apk_info'] = $apk_info;
                        }
                    }
                    echo json_encode($testJson);
                } else {
                    echo $testInfo;
                }
                $ok = true;
            }
            // keep track of the last time this location reported in
            $testerInfo = array();
            $testerInfo['ip'] = $_SERVER['REMOTE_ADDR'];
            $testerInfo['pc'] = $pc;
            $testerInfo['ec2'] = $ec2;
            $testerInfo['ver'] = array_key_exists('version', $_GET) ? $_GET['version'] : $_GET['ver'];
            $testerInfo['freedisk'] = @$_GET['freedisk'];
            $testerInfo['ie'] = @$_GET['ie'];
            $testerInfo['dns'] = $dnsServers;
            $testerInfo['video'] = @$_GET['video'];
            $testerInfo['GPU'] = @$_GET['GPU'];
            $testerInfo['screenwidth'] = $screenwidth;
            $testerInfo['screenheight'] = $screenheight;
            $testerInfo['winver'] = $winver;
            $testerInfo['isWinServer'] = $isWinServer;
            $testerInfo['isWin64'] = $isWin64;
            $testerInfo['test'] = '';
            if (isset($testId)) {
                $testerInfo['test'] = $testId;
            }
            UpdateTester($location, $tester, $testerInfo);
        }
    }
    return $is_done;
}
コード例 #19
0
/**
 * If we have a timeline, figure out what each thread was doing at each point in time.
 * Basically CPU utilization from the timeline.
 *
 * @param TestPaths $localPaths Paths related to this run/step
 * @return array|null An array of threads with each thread being an array of slices (one for
 * each time period).  Each slice is an array of events and the fraction of that
 * slice that they consumed (with a total maximum of 1 for any slice).
 */
function DevToolsGetCPUSlicesForStep($localPaths)
{
    $slices = null;
    $slices_file = $localPaths->devtoolsCPUTimelineFile() . ".gz";
    $trace_file = $localPaths->devtoolsTraceFile() . ".gz";
    $script_timing = $localPaths->devtoolsScriptTimingFile() . ".gz";
    if (!GetSetting('disable_timeline_processing') && !is_file($slices_file) && is_file($trace_file) && is_file(__DIR__ . '/lib/trace/trace-parser.py')) {
        $script = realpath(__DIR__ . '/lib/trace/trace-parser.py');
        touch($slices_file);
        if (is_file($slices_file)) {
            $slices_file = realpath($slices_file);
            unlink($slices_file);
        }
        $user_timing = $localPaths->chromeUserTimingFile() . ".gz";
        touch($user_timing);
        if (is_file($user_timing)) {
            $user_timing = realpath($user_timing);
            unlink($user_timing);
        }
        $trace_file = realpath($trace_file);
        $command = "python \"{$script}\" -t \"{$trace_file}\" -u \"{$user_timing}\" -c \"{$slices_file}\" -j \"{$script_timing}\" 2>&1";
        exec($command, $output, $result);
        if (!is_file($slices_file)) {
            touch($slices_file);
        }
    }
    if (gz_is_file($slices_file)) {
        $slices = json_decode(gz_file_get_contents($slices_file), true);
    }
    if (isset($slices) && !is_array($slices)) {
        $slices = null;
    }
    return $slices;
}
コード例 #20
0
<?php

if (extension_loaded('newrelic')) {
    newrelic_add_custom_tracer('ApcCheckIp');
    newrelic_add_custom_tracer('CheckIp');
}
include 'common_lib.inc';
error_reporting(E_ERROR | E_PARSE);
$has_apc = function_exists('apc_fetch') && function_exists('apc_store');
$ok = false;
if (isset($_REQUEST['installer']) && isset($_SERVER['REMOTE_ADDR'])) {
    $installer = $_REQUEST['installer'];
    $installer_postfix = GetSetting('installerPostfix');
    if ($installer_postfix) {
        $installer .= $installer_postfix;
        $ok = true;
    } elseif (preg_match('/^(software|browsers\\/[-_a-zA-Z0-9]+)\\.dat$/', $installer)) {
        $ok = $has_apc ? ApcCheckIp($installer) : CheckIp($installer);
    }
}
if ($ok) {
    $file = __DIR__ . '/installers/' . $installer;
    $data = $has_apc ? apc_fetch("installer-{$installer}") : null;
    if (!$data && is_file($file)) {
        $data = file_get_contents($file);
        if ($has_apc) {
            apc_store("installer-{$installer}", str_pad($data, 1000), 600);
        }
    }
    if (isset($data) && strlen($data)) {
        header("Content-type: text/plain");
コード例 #21
0
?>
" target="body">Website Navigation</a></li>
	<li><a href="<?php 
echo $absoluteURL . "admin.space/report/csv/";
?>
" target="body">Survey report</a></li>
	<li><a href="<?php 
echo $absoluteURL . "admin.space/installation/configuration.simple/";
?>
" target="body">Simple Configuration</a></li>
	<li><a href="<?php 
echo $absoluteURL . "admin.space/admin/";
?>
" target="body">Admin Logins</a></li>
<?php 
if (GetSetting('mod_rewrite_htaccess') == 'on') {
    ?>
	<li><a href="<?php 
    echo $absoluteURL . "admin.space/installation/generate.htaccess/";
    ?>
" target="body">Generate .Htaccess</a></li>
<?php 
}
if ($debug_mode == 1) {
    ?>
	<li><a href="<?php 
    echo $absoluteURL . "admin.space/installation/setup/";
    ?>
" target="body">Setup</a></li>
	<li><a href="<?php 
    echo $absoluteURL . "admin.space/installation/configuration.feature/";
コード例 #22
0
ファイル: render.php プロジェクト: renajohn/webpagetest
<?php

chdir('..');
$settings = null;
require_once 'common_lib.inc';
require_once 'video/visualProgress.inc.php';
ignore_user_abort(true);
set_time_limit(3600);
error_reporting(E_ERROR | E_PARSE);
$max_load = GetSetting('render_max_load');
if ($max_load !== false && $max_load > 0) {
    WaitForSystemLoad($max_load, 3600);
}
// Globals used throughout the video render
$width = 900;
$height = 650;
$padding = 4;
$textPadding = 0;
$minThumbnailSize = 60;
$biggestThumbnail = 0;
$backgroundColor = null;
$textColor = null;
$bgEvenText = null;
$bgOddText = null;
$image_bytes = null;
$timeFont = __DIR__ . '/font/sourcesanspro-semibold.ttf';
$labelFont = __DIR__ . '/font/sourcesanspro-semibold.ttf';
$labelHeight = 30;
$timeHeight = 40;
$timePadding = 3;
$rowPadding = 10;
コード例 #23
0
 $feature_id = $_GET['feature_id'];
 /*************************************************************************************************************************
 	GET ALL THE FEATURE'S RELATED VARIABLES
 **************************************************************************************************************************/
 $target_original = GetSetting('target_original', $feature_id);
 $target_large = GetSetting('target_large', $feature_id);
 $target_medium = GetSetting('target_medium', $feature_id);
 $target_small = GetSetting('target_small', $feature_id);
 $large_width = GetSetting('large_width', $feature_id);
 $large_height = GetSetting('large_height', $feature_id);
 $medium_width = GetSetting('medium_width', $feature_id);
 $medium_height = GetSetting('medium_height', $feature_id);
 $small_width = GetSetting('small_width', $feature_id);
 $small_height = GetSetting('small_height', $feature_id);
 $multimedia_type = GetSetting('multimedia_type', $feature_id);
 $picture_type = GetSetting('picture_type', $feature_id);
 /*************************************************************************************************************************
 	DO THE PROCESSING
 **************************************************************************************************************************/
 $filename = basename($_FILES['Filedata']['name']);
 $file_basename = substr($filename, 0, strripos($filename, '.'));
 // strip extention
 $file_ext = substr($filename, strripos($filename, '.'));
 $size = $_FILES['Filedata']['size'] / 1024;
 $sort_number = getUsortNumber('multimedia', 'ASC', 'feature_id', $feature_id);
 /*************************************************************************************************************************
 	CHECK THE MAX NUMBER OF PICS ALLOWED AND DELETE THE LAST ONE IF MAX NUMBER REACHED
 **************************************************************************************************************************/
 if (getSetting('max_upload', $feature_id) > 0) {
     $mySQL = "SELECT * FROM multimedia WHERE vignette_id = '{$vignette_id}' AND feature_id = '{$feature_id}' AND status >0";
     $recSET = mysql_query($mySQL) or die(mysql_error());
コード例 #24
0
ファイル: timeline.php プロジェクト: lucasRolff/webpagetest
  #devtools {overflow:hidden;height:100%;width:100%}
</style>
</head>
<body>
<script>
function DevToolsLoaded() {
  var devTools = document.getElementById("devtools").contentWindow;
<?php 
if (!$newTimeline) {
    echo "devTools.InspectorFrontendAPI._runOnceLoaded(function(){(devTools.WebInspector.inspectorView.showPanel(\"timeline\")).loadFromURL(\"{$timelineUrlParam}\");});\n";
}
?>
}
</script>
<?php 
if ($newTimeline) {
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'];
    $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $cdn = GetSetting('cdn');
    $url = $cdn ? $cdn : "{$protocol}://{$host}";
    $url .= $uri;
    // short-term hack because the timeline code doesn't URLdecode query params and we can't pass any URL with a &
    $url .= "/inspector-20160510/inspector.html?experiments=true&loadTimelineFromURL={$timelineUrlParam}";
    header("Location: {$url}");
} else {
    echo '<iframe id="devtools" frameborder="0" height="100%" width="100%" src="/chrome/inspector-20140603/devtools.html" onload="DevToolsLoaded();"></iframe>';
}
?>
</body>
</html>
コード例 #25
0
<?php

include '../../../../includes/configuration/master.configuration.php';
checkAdminSpaceLogin();
$nav_tab_id = $_GET['nav_tab_id'];
$feature_id = $_GET['fid'];
usortpageMultemedia();
/*************************************************************************************************************************
	CHOSE THE LIST PAGE
**************************************************************************************************************************/
$list_page = GetSetting('list_type', $feature_id);
if (empty($list_page)) {
    $list_page = 'index.php';
}
header("Location:../list/{$list_page}?nav_tab_id={$nav_tab_id}&feature_id={$feature_id}");
コード例 #26
0
?>
',
		'wmode' : 'transparent',
		'auto'	: true,
		'height' : 25,
		'width' : 114,
		'multi': <?php 
echo deSanitizeData(GetSetting('multi_upload', $feature_id));
?>
,
		'fileDesc': '<?php 
echo GetSetting('file_extensions_description', $feature_id);
?>
',
		'fileExt': '<?php 
echo GetSetting('file_extensions', $feature_id);
?>
',
		'scriptData': {'nav_tab_id': <?php 
echo SanitizeData($nav_tab_id);
?>
,'feature_id': <?php 
echo SanitizeData($feature_id);
?>
,'vignette_id': <?php 
echo SanitizeData($vignette_id);
?>
}, 

		onError: function (event, queueID ,fileObj, errorObj) {
			var msg;
コード例 #27
0
ファイル: login.php プロジェクト: lucasRolff/webpagetest
 $lock = Lock('Auth', true, 10);
 if ($lock) {
     $users = json_decode(gz_file_get_contents('./dat/users.dat'), true);
     $user['id'] = md5($token_data['payload']['sub']);
     $user['oauth2id'] = $token_data['payload']['sub'];
     $user['email'] = $token_data['payload']['email'];
     if (!isset($users) || !is_array($users)) {
         $users = array();
     }
     if (isset($users[$user['email']]['id'])) {
         $user['id'] = $users[$user['email']]['id'];
     }
     $users[$user['email']] = $user;
     gz_file_put_contents('./dat/users.dat', json_encode($users));
     // se if the user that logged in was an administrator
     $admin_users = GetSetting('admin_users');
     if ($admin_users) {
         $admins = explode(',', $admin_users);
         foreach ($admins as $admin) {
             if (stripos(strtolower($user['email']), strtolower(trim($admin))) !== false) {
                 $session = sha1(json_encode($token_data) . time());
                 setcookie("asid", $session, time() + 60 * 60 * 24 * 7 * 2, "/");
                 $sessions = json_decode(gz_file_get_contents('./dat/admin_sessions.dat'), true);
                 if (!isset($sessions) || !is_array($sessions)) {
                     $sessions = array();
                 }
                 $sessions[$session] = $user;
                 gz_file_put_contents('./dat/admin_sessions.dat', json_encode($sessions));
                 break;
             }
         }
コード例 #28
0
        $total = $info['seg_size'] * $info['num_seg'];
        $avail = $info['avail_mem'];
        if ($total > 0) {
            $pct = $avail / $total;
            if ($avail < 5000000 || $pct < 0.1) {
                apc_clear_cache("user");
                apc_clear_cache();
            }
        }
    }
}
if (GetSetting('ec2')) {
    CleanGetWork();
}
require_once './ec2/ec2.inc.php';
if (GetSetting('ec2_key')) {
    EC2_TerminateIdleInstances();
    EC2_StartNeededInstances();
}
/**
* Clean up extraneous getwork.php.xxx files that may be left behind
* from using wget in a cron job.  The server AMI was supposed to run wget
* silently but there have been reports of the files getting created
* 
*/
function CleanGetWork()
{
    $files = glob('/var/www/getwork.php.*');
    foreach ($files as $file) {
        if (is_file($file)) {
            unlink($file);
コード例 #29
0
ファイル: runtest.php プロジェクト: VinkenCheng/webpagetest
/**
* Create a single test and return the test ID
*
* @param mixed $test
* @param mixed $url
*/
function CreateTest(&$test, $url, $batch = 0, $batch_locations = 0)
{
    global $settings;
    $testId = null;
    if (is_file('./settings/block.txt')) {
        $forceBlock = trim(file_get_contents('./settings/block.txt'));
    }
    if (CheckUrl($url) && WptHookValidateTest($test)) {
        // generate the test ID
        $test_num;
        $id = uniqueId($test_num);
        if ($test['private']) {
            $id = ShardKey($test_num) . md5(uniqid(rand(), true));
        } else {
            $id = ShardKey($test_num) . $id;
        }
        $today = new DateTime("now", new DateTimeZone('UTC'));
        $testId = $today->format('ymd_') . $id;
        $test['path'] = './' . GetTestPath($testId);
        // make absolutely CERTAIN that this test ID doesn't already exist
        while (is_dir($test['path'])) {
            // fall back to random ID's
            $id = ShardKey($test_num) . md5(uniqid(rand(), true));
            $testId = $today->format('ymd_') . $id;
            $test['path'] = './' . GetTestPath($testId);
        }
        // create the folder for the test results
        if (!is_dir($test['path'])) {
            mkdir($test['path'], 0777, true);
        }
        // write out the ini file
        $testInfo = "[test]\r\n";
        $testInfo .= "fvonly={$test['fvonly']}\r\n";
        $testInfo .= "timeout={$test['timeout']}\r\n";
        $resultRuns = $test['runs'] - $test['discard'];
        $testInfo .= "runs={$resultRuns}\r\n";
        $testInfo .= "location=\"{$test['locationText']}\"\r\n";
        $testInfo .= "loc={$test['location']}\r\n";
        $testInfo .= "id={$testId}\r\n";
        $testInfo .= "batch={$batch}\r\n";
        $testInfo .= "batch_locations={$batch_locations}\r\n";
        $testInfo .= "sensitive={$test['sensitive']}\r\n";
        if (strlen($test['login'])) {
            $testInfo .= "authenticated=1\r\n";
        }
        $testInfo .= "connections={$test['connections']}\r\n";
        if (strlen($test['script'])) {
            $testInfo .= "script=1\r\n";
        }
        if (strlen($test['notify'])) {
            $testInfo .= "notify={$test['notify']}\r\n";
        }
        if (strlen($test['video'])) {
            $testInfo .= "video=1\r\n";
        }
        if (strlen($test['uid'])) {
            $testInfo .= "uid={$test['uid']}\r\n";
        }
        if (strlen($test['owner'])) {
            $testInfo .= "owner={$test['owner']}\r\n";
        }
        if (strlen($test['type'])) {
            $testInfo .= "type={$test['type']}\r\n";
        }
        if (strlen($test['industry']) && strlen($test['industry_page'])) {
            $testInfo .= "industry=\"{$test['industry']}\"\r\n";
            $testInfo .= "industry_page=\"{$test['industry_page']}\"\r\n";
        }
        if (isset($test['connectivity'])) {
            $testInfo .= "connectivity={$test['connectivity']}\r\n";
            $testInfo .= "bwIn={$test['bwIn']}\r\n";
            $testInfo .= "bwOut={$test['bwOut']}\r\n";
            $testInfo .= "latency={$test['latency']}\r\n";
            $testInfo .= "plr={$test['plr']}\r\n";
        }
        $testInfo .= "\r\n[runs]\r\n";
        if ($test['median_video']) {
            $testInfo .= "median_video=1\r\n";
        }
        file_put_contents("{$test['path']}/testinfo.ini", $testInfo);
        // for "batch" tests (the master) we don't need to submit an actual test request
        if (!$batch && !$batch_locations) {
            // build up the actual test commands
            $testFile = '';
            if (strlen($test['domElement'])) {
                $testFile .= "\r\nDOMElement={$test['domElement']}";
            }
            if ($test['fvonly']) {
                $testFile .= "\r\nfvonly=1";
            }
            if ($test['timeout']) {
                $testFile .= "\r\ntimeout={$test['timeout']}";
            }
            if ($test['web10']) {
                $testFile .= "\r\nweb10=1";
            }
            if ($test['ignoreSSL']) {
                $testFile .= "\r\nignoreSSL=1";
            }
            if ($test['tcpdump']) {
                $testFile .= "\r\ntcpdump=1";
            }
            if ($test['standards']) {
                $testFile .= "\r\nstandards=1";
            }
            if ($test['timeline']) {
                $testFile .= "\r\ntimeline=1";
                $testFile .= "\r\ntimelineStackDepth={$test['timelineStackDepth']}";
            }
            if ($test['trace']) {
                $testFile .= "\r\ntrace=1";
            }
            if ($test['swrender']) {
                $testFile .= "\r\nswRender=1";
            }
            if ($test['netlog']) {
                $testFile .= "\r\nnetlog=1";
            }
            if ($test['spdy3']) {
                $testFile .= "\r\nspdy3=1";
            }
            if ($test['noscript']) {
                $testFile .= "\r\nnoscript=1";
            }
            if ($test['fullsizevideo']) {
                $testFile .= "\r\nfullSizeVideo=1";
            }
            if ($test['blockads']) {
                $testFile .= "\r\nblockads=1";
            }
            if ($test['video']) {
                $testFile .= "\r\nCapture Video=1";
            }
            if (GetSetting('save_mp4') || $test['keepvideo']) {
                $testFile .= "\r\nkeepvideo=1";
            }
            if (strlen($test['type'])) {
                $testFile .= "\r\ntype={$test['type']}";
            }
            if ($test['block']) {
                $testFile .= "\r\nblock={$test['block']}";
                if (isset($forceBlock)) {
                    $testFile .= " {$forceBlock}";
                }
            } elseif (isset($forceBlock)) {
                $testFile .= "\r\nblock={$forceBlock}";
            }
            if ($test['noopt']) {
                $testFile .= "\r\nnoopt=1";
            }
            if ($test['noimages']) {
                $testFile .= "\r\nnoimages=1";
            }
            if ($test['noheaders']) {
                $testFile .= "\r\nnoheaders=1";
            }
            if ($test['discard']) {
                $testFile .= "\r\ndiscard={$test['discard']}";
            }
            $testFile .= "\r\nruns={$test['runs']}\r\n";
            if (isset($test['connectivity'])) {
                $testFile .= "bwIn={$test['bwIn']}\r\n";
                $testFile .= "bwOut={$test['bwOut']}\r\n";
                $testFile .= "latency={$test['testLatency']}\r\n";
                $testFile .= "plr={$test['plr']}\r\n";
            }
            if (isset($test['browserExe']) && strlen($test['browserExe'])) {
                $testFile .= "browserExe={$test['browserExe']}\r\n";
            }
            if (isset($test['browser']) && strlen($test['browser'])) {
                $testFile .= "browser={$test['browser']}\r\n";
            }
            if ($test['pngss'] || $settings['pngss']) {
                $testFile .= "pngScreenShot=1\r\n";
            }
            if ($test['iq']) {
                $testFile .= "imageQuality={$test['iq']}\r\n";
            } elseif ($settings['iq']) {
                $testFile .= "imageQuality={$settings['iq']}\r\n";
            }
            if ($test['bodies']) {
                $testFile .= "bodies=1\r\n";
            }
            if ($test['htmlbody']) {
                $testFile .= "htmlbody=1\r\n";
            }
            if ($test['time']) {
                $testFile .= "time={$test['time']}\r\n";
            }
            if ($test['clear_rv']) {
                $testFile .= "clearRV={$test['clear_rv']}\r\n";
            }
            if ($test['keepua']) {
                $testFile .= "keepua=1\r\n";
            }
            if ($test['mobile']) {
                $testFile .= "mobile=1\r\n";
            }
            if (isset($test['dpr']) && $test['dpr'] > 0) {
                $testFile .= "dpr={$test['dpr']}\r\n";
            }
            if (isset($test['width']) && $test['width'] > 0) {
                $testFile .= "width={$test['width']}\r\n";
            }
            if (isset($test['height']) && $test['height'] > 0) {
                $testFile .= "height={$test['height']}\r\n";
            }
            if ($test['clearcerts']) {
                $testFile .= "clearcerts=1\r\n";
            }
            if ($test['orientation']) {
                $testFile .= "orientation={$test['orientation']}\r\n";
            }
            if (array_key_exists('continuousVideo', $test) && $test['continuousVideo']) {
                $testFile .= "continuousVideo=1\r\n";
            }
            if (array_key_exists('responsive', $test) && $test['responsive']) {
                $testFile .= "responsive=1\r\n";
            }
            if (array_key_exists('cmdLine', $test) && strlen($test['cmdLine'])) {
                $testFile .= "cmdLine={$test['cmdLine']}\r\n";
            }
            if (array_key_exists('addCmdLine', $test) && strlen($test['addCmdLine'])) {
                $testFile .= "addCmdLine={$test['addCmdLine']}\r\n";
            }
            if (array_key_exists('customBrowserUrl', $test) && strlen($test['customBrowserUrl'])) {
                $testFile .= "customBrowserUrl={$test['customBrowserUrl']}\r\n";
            }
            if (array_key_exists('customBrowserMD5', $test) && strlen($test['customBrowserMD5'])) {
                $testFile .= "customBrowserMD5={$test['customBrowserMD5']}\r\n";
            }
            if (array_key_exists('customBrowserSettings', $test) && is_array($test['customBrowserSettings']) && count($test['customBrowserSettings'])) {
                foreach ($test['customBrowserSettings'] as $setting => $value) {
                    $testFile .= "customBrowser_{$setting}={$value}\r\n";
                }
            }
            if (isset($test['uastring'])) {
                $testFile .= "uastring={$test['uastring']}\r\n";
            }
            $UAModifier = GetSetting('UAModifier');
            if ($UAModifier && strlen($UAModifier)) {
                $testFile .= "UAModifier={$UAModifier}\r\n";
            }
            if (isset($test['appendua'])) {
                $testFile .= "AppendUA={$test['appendua']}\r\n";
            }
            // see if we need to add custom scan rules
            if (array_key_exists('custom_rules', $test)) {
                foreach ($test['custom_rules'] as &$rule) {
                    $rule = trim($rule);
                    if (strlen($rule)) {
                        $testFile .= "customRule={$rule}\r\n";
                    }
                }
            }
            // Add custom metrics
            if (array_key_exists('customMetrics', $test)) {
                foreach ($test['customMetrics'] as $name => $code) {
                    $testFile .= "customMetric={$name}:{$code}\r\n";
                }
            }
            if (!SubmitUrl($testId, $testFile, $test, $url)) {
                $testId = null;
            }
        }
        // log the test
        if (isset($testId)) {
            logTestMsg($testId, "Test Created");
            // store the entire test data structure JSON encoded (instead of a bunch of individual files)
            $oldUrl = @$test['url'];
            $test['url'] = $url;
            SaveTestInfo($testId, $test);
            $test['url'] = $oldUrl;
            if ($batch_locations) {
                LogTest($test, $testId, 'Multiple Locations test');
            } else {
                if ($batch) {
                    LogTest($test, $testId, 'Bulk Test');
                } else {
                    LogTest($test, $testId, $url);
                }
            }
        } else {
            // delete the test if we didn't really submit it
            delTree("{$test['path']}/");
        }
    } else {
        global $error;
        $error = 'Your test request was intercepted by our spam filters (or because we need to talk to you about how you are submitting tests)';
    }
    return $testId;
}
コード例 #30
0
ファイル: workdone.php プロジェクト: lucasRolff/webpagetest
             $testInfo['test_runs'][$runNumber]['done'] = true;
         } else {
             $testInfo['test_runs'][$runNumber] = array('done' => true);
         }
         $numSteps = $resultProcessing->countSteps();
         $reportedSteps = 0;
         if (!empty($testInfo['test_runs'][$runNumber]['steps'])) {
             $reportedSteps = $testInfo['test_runs'][$runNumber]['steps'];
             if ($reportedSteps != $numSteps) {
                 $testerError = "Number of steps for first and repeat view differ (fv: {$reportedSteps}, rv: {$numSteps})";
             }
         }
         $testInfo['test_runs'][$runNumber]['steps'] = max($numSteps, $reportedSteps);
         $testInfo_dirty = true;
     }
     if (!GetSetting('disable_video_processing')) {
         if ($testInfo['video']) {
             $workdone_video_start = microtime(true);
         }
         ProcessAVIVideo($testInfo, $testPath, $runNumber, $cacheWarmed, $max_load);
         if ($testInfo['video']) {
             $workdone_video_end = microtime(true);
         }
     }
 }
 if (strlen($location) && strlen($tester)) {
     $testerInfo = array();
     $testerInfo['ip'] = $_SERVER['REMOTE_ADDR'];
     if (!isset($testerError)) {
         $testerError = false;
     }