Example #1
0
function main()
{
    global $log;
    //this script can take a long time to run
    //we don't want it ending early
    set_time_limit(0);
    $timer = new timer();
    $log->writeLine("============================================");
    $log->writeLine("Begin upload processing.");
    $timer->start();
    //process all files in the upload directory
    do_process();
    $timer->stop();
    $log->writeLine("--------------------------------------------");
    $log->writeLine("End upload processing. Took " . $timer->taken() . " seconds.");
    $log->writeLine("============================================");
    $log->saveLog("blah.txt");
}
Example #2
0
 /**
  * @param $mod_reference
  * @return bool|mixed|string
  */
 function execute_module($mod_reference)
 {
     global $user, $prefs, $tiki_p_admin;
     $smarty = TikiLib::lib('smarty');
     $tikilib = TikiLib::lib('tiki');
     try {
         $defaults = array('style' => '', 'nonums' => 'n');
         $module_params = isset($mod_reference['params']) ? (array) $mod_reference['params'] : array();
         $module_params = array_merge($defaults, $module_params);
         // not sure why style doesn't get set sometime but is used in the tpl
         $mod_reference = array_merge(array('moduleId' => null, 'ord' => 0, 'position' => 0, 'rows' => 10), $mod_reference);
         $module_rows = $mod_reference["rows"];
         $info = $this->get_module_info($mod_reference);
         $cachefile = $this->get_cache_file($mod_reference, $info);
         foreach ((array) $info['prefs'] as $preference) {
             if ($prefs[$preference] != 'y') {
                 $smarty->loadPlugin('smarty_block_remarksbox');
                 return smarty_block_remarksbox(array('type' => 'warning', 'title' => tr('Failed to execute "%0" module', $mod_reference['name'])), tr('Missing dependencies'), $smarty, $repeat);
             }
         }
         if (!$cachefile || $this->require_cache_build($mod_reference, $cachefile) || $this->is_admin_mode()) {
             if ($this->is_admin_mode()) {
                 require_once 'lib/setup/timer.class.php';
                 $timer = new timer('module');
                 $timer->start('module');
             }
             if ($info['type'] == "function") {
                 // Use the module name as default module title. This can be overriden later. A module can opt-out of this in favor of a dynamic default title set in the TPL using clear_assign in the main module function. It can also be overwritten in the main module function.
                 $smarty->assign('tpl_module_title', tra($info['name']));
             }
             $smarty->assign('nonums', $module_params['nonums']);
             if ($info['type'] == 'include') {
                 $phpfile = 'modules/mod-' . $mod_reference['name'] . '.php';
                 if (file_exists($phpfile)) {
                     include $phpfile;
                 }
             } elseif ($info['type'] == 'function') {
                 $function = 'module_' . $mod_reference['name'];
                 $phpfuncfile = 'modules/mod-func-' . $mod_reference['name'] . '.php';
                 if (file_exists($phpfuncfile)) {
                     include_once $phpfuncfile;
                 }
                 if (function_exists($function)) {
                     $function($mod_reference, $module_params);
                 }
             }
             $ck = getCookie('mod-' . $mod_reference['name'] . $mod_reference['position'] . $mod_reference['ord'], 'menu', 'o');
             $smarty->assign('module_display', $prefs['javascript_enabled'] == 'n' || $ck == 'o');
             $smarty->assign_by_ref('module_rows', $mod_reference['rows']);
             $smarty->assign_by_ref('module_params', $module_params);
             // module code can unassign this if it wants to hide params
             $smarty->assign('module_ord', $mod_reference['ord']);
             $smarty->assign('module_position', $mod_reference['position']);
             $smarty->assign('moduleId', $mod_reference['moduleId']);
             if (isset($module_params['title'])) {
                 $smarty->assign('tpl_module_title', tra($module_params['title']));
             }
             $smarty->assign('tpl_module_name', $mod_reference['name']);
             $tpl_module_style = empty($mod_reference['module_style']) ? '' : $mod_reference['module_style'];
             if ($tiki_p_admin == 'y' && $this->is_admin_mode() && (!$this->filter_active_module($mod_reference) || $prefs['modhideanonadmin'] == 'y' && (empty($mod_reference['groups']) || $mod_reference['groups'] == serialize(array('Anonymous'))))) {
                 $tpl_module_style .= 'opacity: 0.5;';
             }
             if (isset($module_params['overflow']) && $module_params['overflow'] === 'y') {
                 $tpl_module_style .= 'overflow:visible !important;';
             }
             $smarty->assign('tpl_module_style', $tpl_module_style);
             $template = 'modules/mod-' . $mod_reference['name'] . '.tpl';
             if (file_exists('templates/' . $template)) {
                 $data = $smarty->fetch($template);
             } else {
                 $data = $this->get_user_module_content($mod_reference['name'], $module_params);
             }
             $smarty->clear_assign('module_params');
             // ensure params not available outside current module
             $smarty->clear_assign('tpl_module_title');
             $smarty->clear_assign('tpl_module_name');
             $smarty->clear_assign('tpl_module_style');
             if ($this->is_admin_mode() && $timer) {
                 $elapsed = round($timer->stop('module'), 3);
                 $data = preg_replace('/<div /', '<div title="Module Execution Time ' . $elapsed . 's" ', $data, 1);
             }
             if (!empty($cachefile) && !$this->is_admin_mode()) {
                 file_put_contents($cachefile, $data);
             }
         } else {
             $data = file_get_contents($cachefile);
         }
         return $data;
     } catch (Exception $e) {
         $smarty->loadPlugin('smarty_block_remarksbox');
         if ($tiki_p_admin == 'y') {
             $message = $e->getMessage();
         } else {
             $message = tr('Contact the system administrator');
         }
         $repeat = false;
         return smarty_block_remarksbox(array('type' => 'warning', 'title' => tr('Failed to execute "%0" module', $mod_reference['name'])), html_entity_decode($message), $smarty, $repeat);
     }
 }
Example #3
0
        $excludeDirs = explode(',', $request->getProperty('excludeDirs'));
    }
    if ($request->hasProperty('includeFiles')) {
        $includeFiles = explode(',', $request->getProperty('includeFiles'));
    }
    if ($request->hasProperty('fileName')) {
        $options['fileName'] = $request->getProperty('fileName');
    }
}
$getStrings = new Language_GetStrings(new Language_CollectFiles(), new Language_WriteFile_Factory(), $options);
$getStrings->addFileType(new Language_FileType_Php());
$getStrings->addFileType(new Language_FileType_Tpl());
// skip the following directories
$getStrings->collectFiles->setExcludeDirs($excludeDirs);
// manually add the following files from skipped directories
$getStrings->collectFiles->setIncludeFiles($includeFiles);
echo formatOutput("Languages: " . implode(' ', $getStrings->getLanguages()) . "\n");
$getStrings->run();
echo formatOutput("\nTotal time spent: " . $timer->stop() . " seconds\n");
/**
 * @param $string
 * @return string
 */
function formatOutput($string)
{
    if (php_sapi_name() == 'cli') {
        return $string;
    } else {
        return nl2br($string);
    }
}
 function doMonitor($id)
 {
     $time = new timer();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->args['url']);
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     //post
     if ($this->args['type'] == 'POST' && $this->args['data'] != NULL) {
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->args['data']);
     }
     //cookie
     if (isset($this->args['cookie']) && $this->args['cookie'] != NULL) {
         curl_setopt($ch, CURLOPT_COOKIE, $this->args['cookie']);
     }
     $time->start();
     $res_content = curl_exec($ch);
     $time->stop();
     //$curl_close($ch);
     global $db;
     $max_time = $time->spent();
     $sql = "select * from history_record where data_id = {$id} order by time desc limit 1";
     $result = mysql_query($sql, $db);
     if ($result) {
         $row = mysql_fetch_array($result);
         if ($row != NULL && $max_time < $row['max_time']) {
             $max_time = $row['max_time'];
         } else {
             $update_sql = "update history_record set max_time='" . $max_time . "' where id=" . $row['id'];
             mysql_query($update_sql, $db);
         }
     }
     echo "最大响应时间:" . $max_time . "秒<br>";
     echo "当前响应时间:" . $time->spent() . "秒";
     echo "<br>返回内容<br>";
     #echo "<xmp>".$res_content."</xmp>";
     echo "<br>" . $res_content . "<br>";
 }
Example #5
0
$nick = $_SESSION['nick'];
$session = $_SESSION['topsession'];
$appKey = $_SESSION['appKey'];
$appSecret = $_SESSION['appSecret'];
if ($nick == '') {
    header("Location: Login.php");
}
$errormess = '';
if ($_REQUEST['banyue'] != '') {
    //获取淘宝订单总数
    $resultcount = getTaobaoOrderCount($rooturl, $session, $appKey, $appSecret, $start_created, $end_created);
    $page_size = 40;
    $page_no = intval($resultcount / $page_size) + 1;
    $taobaoorders_page = array();
    $taobaoorders = array();
    $timer->stop();
    $timemessage .= "计算订单个数的时间为 " . $timer->spent() . "\r\n";
    $timer->start();
    //获取淘宝订单信息
    $taobaoorders_page = getTaobaoOrderInfo($rooturl, $session, $appKey, $appSecret, $page_no, $page_size, $start_created, $end_created);
    //总数 > 40 处理数组 array[0][0] to array[0]
    if ($resultcount > 1) {
        foreach ($taobaoorders_page as $pageorders) {
            if (!empty($pageorders)) {
                foreach ($pageorders as $pageorder) {
                    $taobaoorders[] = $pageorder;
                }
            } else {
                $errormess .= "获取淘宝订单信息失败。\r\n";
            }
        }
    $sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
}
//	else if($irmod == '2')
//		$sphinx->SetMatchMode(SPH_MATCH_PHRASE);
#$sphinx->SetSortMode(SPH_SORT_RELEVANCE);
//	$sphinx->SetSortMode(SPH_SORT_EXTENDED,"@weight DESC");###########
$sphinx->SetSortMode(SPH_SORT_EXPR, "hits*0.1+@weight*5");
$sphinx->setLimits(0, 1000, 1000);
$sphinx->SetIndexWeights(array("title" => 50, "keywords" => 10, "description" => 5));
$result = $sphinx->query($keyword, "mysql");
echo "<pre>";
//	print_r($result);
echo "</pre>";
$ids = join(",", array_keys($result['matches']));
$row_num = $result['total'];
$Timer1->stop();
if ($row_num <= 0) {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;<font style='font-weight:bold;color:#f00;'>没有您想要的结果...</font>";
} else {
    #	$Timer2=new timer();
    #	$Timer2->start();////////////////
    $gPageSize = 10;
    //每页显示记录数
    $page = $_GET['page'];
    //页数
    if (!isset($page)) {
        $page = 1;
    }
    if ($page == 0) {
        $page = 1;
    }
Example #7
0
        if ($l == 1) {
            $sites = array(array("rapidshare\\.com\\/files\\/", 'class="downloadlink"', "/>\\|\\s(.*)</"), array("rapidshare\\.com\\/#", '', ""), array("megaupload\\.com\\/\\?d=", "down_txt_pad1", '/<strong>File\\s*size\\:[^>]+.\\s*([^<]+)/'), array("megashares\\.com\\/\\?d01=", "Click here to download", "/size:\\s(.*)</"), array("hotfile\\.com\\/dl\\/", "Downloading", '/Downloading:(?:[^\\|]+)\\|<\\/span>\\s<strong>(.*)<\\/strong/'), array("2shared\\.com\\/file\\/", "Download", '/File\\ssize:<\\/span>\\s(.*)\\s&nbsp;/'), array("4shared\\.com\\/file\\/", "fileNameText", '/(?:Size|Ukuran|Saiz|Tamanho|Tamaño|Taille|Rozmiar|Boyut|ขนาด|Dimensione|サイズ|크기|Kích\\scỡ|Размер)(?:\\s*|):(?:\\s*|)<\\/b>.+(?:\\r\\n*|\\r|\\n|).+finforight(?:[^>])>(.*)</'), array("filefactory\\.com\\/file\\/", "(download link)|(Please try again later)", '/\\t<span>(.*)\\sfile/'), array("rapidshare\\.de\\/files\\/", "You want to download"), array("mediafire\\.com\\/\\?", "download_file_title", '/sharedtabsfileinfo1-fs.+?([0-9.]+\\s\\w+)">/'), array("www.mediafire\\.com\\/file\\/", "You requested"), array("netload\\.in\\/datei[0-9a-zA-Z]{10}\\/", "File download", '/<span\\sstyle\\="color\\:\\s\\#8d8d8d\\;">\\,(.*)<\\/span>/'), array("depositfiles\\.com\\/([a-z]{2}\\/)?files\\/", "File Name", '/File\\ssize:\\s<b>(.*)<\\/b>/', "@(com\\/files\\/)|(com\\/[a-z]{2}\\/files\\/)@i", "com/en/files/"), array("sendspace\\.com\\/file\\/", "The download link is located below.", '/Size:<\\/b>\\s(.*)\\s/'), array("usaupload\\.net\\/d\\/", "This is the download page for file", '/File\\ssize:<\\/strong>\\s(.*)</'), array("uploading\\.com\\/files\\/", "File size", '/size:\\s<b>(.*)<\\/b>/'), array("savefile\\.com\\/files\\/", "link to this file", '/filesize: (.*)</'), array("axifile\\.com\\/?", "You have request", '/You\\shave\\srequest\\s.*file\\s\\((.*)\\)/', "@com\\?@i", "com/?"), array("cocoshare\\.cc\\/[0-9]+\\/", "Filesize:"), array("badongo\\.com\\/([a-z]{2}\\/)?(file)|(vid)\\/", "fileBoxMenu"), array("ifile\\.it\\/", "Request Download Ticket", ''), array("(d\\.turboupload\\.com\\/)|(turboupload.com\\/download\\/)", "(Please wait while we prepare your file.)|(You have requested the file)", '/You\\shave\\srequested\\s.*>\\s\\((.*)\\)/'), array("files\\.to\\/get\\/", "You requested the following file"), array("gigasize\\.com\\/get\\.php\\?d=", "Downloaded", '/Size:\\s<span>(.*)</'), array("ziddu\\.com\\/", "Download Link", '/File\\sSize\\s:.*normal12black">([\\d\\.\\s]+[\\w]+)\\s</s'), array("zshare\\.net\\/(download|audio|video)\\/", "Downloads:", '/File\\sSize:.*">(.*)</'), array("uploaded\\.to\\/(\\?id=|file\\/)", "Filename:", '/Filesize:.*<td>[\\s](.*)\\t<\\//'), array("filefront\\.com\\/", "http://static4.filefront.com/ffv6/graphics/b_download_still.gif"), array("speedyshare\\.com\\/files\\/[0-9]+\\/", "File download", '/<div\\sclass=result>File\\ssize\\s(.*),\\suploaded/'), array("momupload\\.com\\/files\\/", "You want to download the file"), array("rnbload\\.com\\/file/", "Filename:", '/Filesize:\\s(.*)</'), array("ifolder\\.ru\\/[0-9]+", "ints_code"), array("adrive\\.com\\/public\\/", "view"), array("easy-share\\.com", "Download", '/px18\\stxtgray\\sfamily2\\sc">.*\\s\\((.*)\\)</'), array("bitroad\\.net\\/download\\/[0-9a-z]+\\/", "Download a file", '/content_text.*\\[\\s(.*)\\]</'), array("megarotic\\.com/([a-z]{2}\\/)?\\?d=", "(Filename:)|(All download slots assigned to your country)", '/File\\ssize:.*">(.*)</'), array("egoshare\\.com", "You have requested"), array("flyupload\\.flyupload.com\\/get\\?fid", "Download Now"), array("megashare\\.com\\/[0-9]+", "Free"), array("kewlshare\\.com\\/dl\\/", "File Name"), array("filebase\\.to\\/files\\/", "Der Download wird vorbereitet..."), array("bigupload\\.com\\/files\\/", "You have requested"), array("yousendit\\.com\\/download\\/", "Download File"), array("uploadline\\.com\\/", "File Download Link Generated"), array("shareserver\\.net\\/files\\/get\\/", "Download Here"), array("getupload\\.org\\/en\\/file\\/", "File name"), array("uploadbox.com\\/files\\/", "File name"), array("vip-file\\.com\\/download\\/", "File name"), array("enterupload\\.com\\/", "file_download", '/>File\\s*size\\:[^\\d]+([^<]+)/'), array("share-now\\.net\\/files\\/", "Download Now"), array("upit\\.to\\/file:", "Download"), array("netgull\\.com\\/?\\?d=", "File name"), array("sms4file\\.com\\/download\\/", "File Name"), array("bigshare\\.eu\\/(download\\.php)?\\?", "File name"), array("sharebee\\.com\\/", "Filename"), array("sharecash\\.org\\/(download\\.php)?\\?id=", "File Info"), array("speedshare\\.org\\/(download\\.php)?\\?id=", "Sie haben"), array("letitbit\\.net\\/download\\/", "File::", '/file\\:\\:(?:[^\\s]+)(?:[\\s|])(.+)\\b<\\//'), array("saveqube\\.com\\/getfile\\/", "File size"), array("friendlyfiles\\.net\\/download\\/", "Download a file"), array("qubefiles\\.com\\/?\\?file=\\/getfile\\/", "File size"), array("uploadjockey\\.com\\/download\\/", "Download file from the following hosts"), array("wikisend\\.com\\/download\\/", "Download link"), array("ugotfile\\.com\\/file\\/", "embed", "/<span\\sstyle\\=\"font\\-size\\:\\s14px;\">(.*)<\\/span/"), array("misterupload\\.net\\/en\\/file\\/", "File name:"), array("filesavr\\.com\\/", "This file has been downloaded"), array("filedropper\\.com\\/", "File Details"), array("youshare\\.com\\/", "Download"), array("sharemobile\\.ro\\/file\\.php?\\?id=", "Filename"), array("file-rack\\.com\\/files\\/", "Download File"), array("indowebster\\.com\\/", "Download Link", '/Size:<\\/b>\\s(.*)<\\/div/'), array("storage\\.to\\/get\\/", "Downloading:", '/Downloading:(?:[^\\(]+)\\((.*)\\)/'), array("zippyshare\\.com\\/v\\/", "You have requested", '/Size:(?:[^>]+)>(.*)<\\/font/'), array("freakshare\\.net\\/files\\/", "box_heading", '/box_heading.+\\s-\\s(.*)<\\/h1/'), array("filesonic\\.com\\/file\\/", "fileInfo", '/<span\\s*class=[\'"][^\'"]+.>([^<]+)./'), array("fileserve\\.com\\/file\\/", "addthis_button", '/><strong>([^<]+).[^>]+.\\s*\\|\\s?Upl/'), array("oron\\.com\\/", "fname", '/File\\ssize\\:\\s*([^<]+)/'), array("shareflare\\.net\\/download\\/", "file-desc", '/Size\\:\\s*([^<]+)/'), array("bitshare\\.com\\/", "downloadbutton", '/<h1>[^-]+.\\s*([^<]+)/'));
            $LnkOccur = false;
            foreach ($sites as $site) {
                if (preg_match("/{$site[0]}/i", $link)) {
                    check(trim($link), $x, $site[1], $site[2], $site[3], $site[4]);
                    $x++;
                    $LnkOccur = true;
                    break;
                }
            }
            if (!$LnkOccur && $link != '') {
                echo "<span class=\"y\">&nbsp;<b><a alt='unknown link' title={$link}>?</a></b>\n</span>";
            }
            if ($x > $maxlinks) {
                echo "<p style=\"text-align:center\">Maximum No ({$maxlinks}) Of links have been reached.</p>";
                exit;
            }
        }
        // --end if
    }
    // --end foreach
    if (!$audl_sect) {
        $lnk_total = $lnk_timer->stop();
        $x--;
        $plural = $x == 1 ? "" : "s";
        $fgc == 0 ? $method = 'cURL' : ($method = 'file_get_contents');
        echo "<timerequire> link" . $plural . " checked in " . $lnk_total . " seconds. Method (" . (!$fgc ? "cURL" : "file_get_contents") . ")</timerequire>";
    }
    echo "</result>";
}
Example #8
0
                        break;
                    case "downloadlink":
                        // add colspan when downloadlink shown and it's in showdownloaded
                        if (!isset($_COOKIE["showAll"]) || isset($_COOKIE["showAll"]) && $_COOKIE["showAll"] != 1) {
                            $n_column++;
                        }
                        break;
                    default:
                        $n_column++;
                        break;
                }
            }
            //-end $colval enable
        }
        //-end foreach
        $totaltime2 = $tabletimer->stop();
        ?>
</tbody>
<tfoot>
<tr id="sffooter" align='center'>
 <td>&nbsp;</td>
 <td>Total :</td>
 <td><?php 
        $total_size = isset($list["files"]["totalsize"]) ? $list["files"]["totalsize"] : $total_size;
        $total_files = isset($list["files"]["totalfile"]) ? $list["files"]["totalfile"] : $total_files;
        echo str_replace(" ", "&nbsp;", bytesToKbOrMbOrGb($total_size));
        $n_column = $feat_ajax["ajax_delete"] == "1" ? $n_column + 1 : $n_column;
        ?>
</td>
 <?php 
        echo $n_column > 0 ? "<td colspan='{$n_column}'></td>" : "";
Example #9
0
 public function testStart()
 {
     timer::start();
     // not much to test here
     $this->assertTrue(is_float(timer::stop()));
 }