/**
  * Delete cache contents.
  * Originally from frostschutz's PluginLibrary
  * github.com/frostschutz
  *
  * @param string $name Cache name or title
  * @param boolean $greedy To delete a cache starting with name_
  */
 function delete($name, $greedy = false)
 {
     global $db, $mybb, $cache;
     // Prepare for database query.
     $dbname = $db->escape_string($name);
     $where = "title = '{$dbname}'";
     // Delete on-demand or handler cache
     if ($this->handler) {
         get_execution_time();
         $hit = $this->handler->delete($name);
         $call_time = get_execution_time();
         $this->call_time += $call_time;
         $this->call_count++;
         if ($mybb->debug_mode) {
             $this->debug_call('delete:' . $name, $call_time, $hit);
         }
     }
     // Greedy?
     if ($greedy) {
         $name .= '_';
         $names = array();
         $keys = array_keys($cache->cache);
         foreach ($keys as $key) {
             if (strpos($key, $name) === 0) {
                 $names[$key] = 0;
             }
         }
         $ldbname = strtr($dbname, array('%' => '=%', '=' => '==', '_' => '=_'));
         $where .= " OR title LIKE '{$ldbname}=_%' ESCAPE '='";
         if ($this->handler) {
             $query = $db->simple_select("datacache", "title", $where);
             while ($row = $db->fetch_array($query)) {
                 $names[$row['title']] = 0;
             }
             // ...from the filesystem...
             $start = strlen(MYBB_ROOT . "cache/");
             foreach ((array) @glob(MYBB_ROOT . "cache/{$name}*.php") as $filename) {
                 if ($filename) {
                     $filename = substr($filename, $start, strlen($filename) - 4 - $start);
                     $names[$filename] = 0;
                 }
             }
             foreach ($names as $key => $val) {
                 get_execution_time();
                 $hit = $this->handler->delete($key);
                 $call_time = get_execution_time();
                 $this->call_time += $call_time;
                 $this->call_count++;
                 if ($mybb->debug_mode) {
                     $this->debug_call('delete:' . $name, $call_time, $hit);
                 }
             }
         }
     }
     // Delete database cache
     $db->delete_query("datacache", $where);
 }
Esempio n. 2
0
 /**
  * Time how long it takes for a particular piece of code to run. Place calls above & below the block of code.
  *
  * @deprecated
  */
 function get_execution_time()
 {
     return get_execution_time();
 }
Esempio n. 3
0
$num = 20;
$i = 0;
while (TRUE) {
    $handler = fopen($file, 'ab');
    $str = str();
    fwrite($handler, "\t\t'" . $str . "' => '" . md5($str) . "',\n");
    $i++;
    $r = 10000 * ceil($i / 10000);
    if ($i != 0 && $i == $r) {
        fwrite($handler, "\t);");
        $num++;
        mkdir('/var/www/md5/files/HashPack ' . $num);
        mkdir('/var/www/md5/files/HashPack ' . $num . '/install/');
        $file = '/var/www/md5/files/HashPack ' . $num . '/install/update.php';
        $n_handler = fopen($file, 'wb');
        fwrite($n_handler, "<?php\n\n\t\$update\t= array(\n");
        fclose($n_handler);
        chmod('/var/www/md5/files/HashPack ' . $num . '/', 0777);
        chmod('/var/www/md5/files/HashPack ' . $num . '/install/', 0777);
        chmod($file, 0777);
    }
    fclose($handler);
    if (!isset($v) && get_execution_time() >= 10) {
        $v = $r;
    }
    if (isset($v) && $i == $v) {
        break;
    }
}
header('Location: write.php?i=' . $i . '&time=' . get_execution_time() . '&num=' . $num);
Esempio n. 4
0
function fatalErrorHandler()
{
    # Getting last error
    $error = error_get_last();
    # Checking if last error is a fatal error
    if ($error['type'] === E_ERROR || $error['type'] === E_USER_ERROR) {
        error_log(microtime(1) . ";" . $error['type'] . ";" . "DIED: " . $error['message'] . ";\n", 3, dirname($_SERVER['SCRIPT_FILENAME']) . "/log/error.log");
        print microtime(1) . ";" . $error['type'] . ";" . $error['message'] . PHP_EOL;
        flush();
        ob_flush();
        if (php_sapi_name() !== 'cli') {
            # Here we handle the error, displaying HTML, logging, ...
            print 'Sorry, a serious error has occured but don\'t worry, I\'ll redirect the user<br/>\\n';
            print "<br/>\n" . get_execution_time() . "<br/>\n\n<script> top.location = \"" . selfURL() . "\"</script>\n";
        }
    } else {
        error_log(microtime(1) . ";" . $error['type'] . ";" . $error['message'] . ";\n", 3, dirname($_SERVER['SCRIPT_FILENAME']) . "/log/error.log");
    }
}
Esempio n. 5
0
                    $GLOBALS['_MAX']['CONF']['table']['data_intermediate_ad_arrival'] = 'data_intermediate_ad_arrival';
                    $GLOBALS['_MAX']['CONF']['table']['data_summary_ad_arrival_hourly'] = 'data_summary_ad_arrival_hourly';
                    $start = microtime();
                    // Set longer time out
                    if (!ini_get('safe_mode')) {
                        $conf = $GLOBALS['_MAX']['CONF'];
                        @set_time_limit($conf['maintenance']['timeLimitScripts']);
                    }
                    //$file = $_GET['file'];
                    //$dir  = $_GET['dir'];
                    $simClass = $scenario;
                    //basename($scenario, '.php');
                    require_once SCENARIOS . '/' . $scenario . '.php';
                    $obj = new $simClass();
                    $obj->profileOn = false;
                    //$conf['simdb']['profile'];
                    $obj->run();
                    $execSecs = get_execution_time($start);
                    include SIM_TEMPLATES . '/execution_time.html';
                } else {
                    if (array_key_exists('submit', $_REQUEST)) {
                        include 'templates/frameheader.html';
                        include 'templates/initial.html';
                        exit;
                    }
                }
            }
        }
    }
}
include 'templates/body_action.html';
Esempio n. 6
0
function pageend()
{
    global $debug, $dspltime;
    if ($debug) {
        showRequest();
    }
    if ($dspltime) {
        echo "\n<p class=\"smallgray2\">" . round(get_execution_time(), 5) . " secs</p>\n";
    }
    ?>
</body></html><?php 
}
/**
 * XML Save
 *
 * @since 2.0
 * @todo create and chmod file before ->asXML call (if it doesnt exist already, if so, then just chmod it.)
 *
 * @param object $xml
 * @param string $file Filename that it will be saved as
 * @return bool
 */
function XMLsave($xml, $file)
{
    get_execution_time(true);
    $success = $xml->asXML($file) === TRUE;
    debugLog('XMLsave: ' . $file . ' ' . get_execution_time());
    if (defined('GSCHMOD')) {
        return $success && chmod($file, GSCHMOD);
    } else {
        return $success && chmod($file, 0755);
    }
}