Example #1
0
function BL2($DIR = './', $type = '.', $exclude = 'µù', $MiT = 1, $MaT = 2115286871, $max = 9999, $MinFS = 0, $keyac = 0, $MaxFS = 99999999)
{
    #whatever
    #USED @ A BAD PLACE ../
    $type = $type ? $type : '.';
    GT('l' . __LINE__);
    memuse();
    $files = scandir($DIR);
    if (!$files) {
        return;
    }
    Memuse();
    //$type="\.jpg|\.gif"
    #[[12-Jan-2012 16:00:31] PHP Fatal error:  Allowed memory size of 209715200 bytes exhausted (tried to allocate 71 bytes) in /home/ovh/fun.php on line 601] => 1
    foreach ($files as $file) {
        if (is_dir($DIR . $file)) {
            continue;
        }
        $w = @filemtime($DIR . $file);
        #if(J9)echo"<li>".(strlen($file)<4).';'.($w<$MiT).';'.$MaxFS.';'.(filesize($DIR.$file)).';'.(filesize($DIR.$file)>$MaxFS);
        if (Preg_Match('~' . $exclude . "|htaccess|index\\.php~is", $file) or strlen($file) < 4 or $w < $MiT or $w > $MaT or filesize($DIR . $file) < $MinFS or filesize($DIR . $file) > $MaxFS) {
            continue;
        }
        if ($type != '.') {
            if (Preg_Match("~{$type}~is", $file)) {
                if ($keyac) {
                    if ($T) {
                        while (array_key_exists($w, $T)) {
                            $w++;
                        }
                    }
                    if (is_file($DIR . $file)) {
                        Touch($DIR . $file, $w);
                    }
                    $T[$w] = $file;
                    $i++;
                } else {
                    $T[] = $file;
                }
            }
        } else {
            $T[] = $file;
        }
    }
    if (count($T) < 1) {
        return;
    }
    if ($keyac) {
        krsort($T);
    }
    if (count($T) > $max) {
        $T = Array_slice($T, 0, $max, 1);
    }
    return $T;
}
Example #2
0
function CacheInit($N = 0)
{
    static $t;
    timelong('cache');
    if ($_POST || e('nocache,toolong,badurl', 1) || isset($_COOKIE['nocache']) or !isgoodurl(SU) || preg_match('#administrator#', U)) {
        return;
    }
    #$apc=1;#IF(ereg('!R22',u))@unlink(cachepath);
    if (headers_sent($f, $line)) {
        e(',headersent:' . $f . '/' . $line);
        Db("headers!{$f},{$line}");
    }
    #-algo de compression non reconnu car ligne 1063 #AV('cacheinti',$_POST,'nocache:'.e(',nocache',1),'headersent:'.e(',headersent',1),$_COOKIE['nocache'],'goodurl:'.isgoodurl(SU));
    if (!defined('REWRITE') && ($t && RS == 404)) {
        R404();
    }
    #Si la page doit ordinairement retourner une erreur 404 -- problème de certains rewritings sur erreur 404 --- Db("cache404".SU);-la génération de l'erreur 404 est passée par qqch[QUERY_STRING] => x=404
    if ($t && ob_get_length() == 0) {
        return;
    }
    #appel de trop
    #if(ereg("go=",q)){ob_end_clean();$u=str_replace('?go=1','',SU);@unlink(cachepath);R301($u,3);}
    #$apc=1;gt('apc1');if(apc_exists($a))$apc=1;gt('apc2');
    $a = str_replace(TMP . 'cache/', '', CACHEPATH);
    if ($apc && bots) {
        GT('apcgetcache-bots');
        kill(APCG($a));
    }
    #ram
    if ($apc && isgoodurl()) {
        Gt('apcread-start');
        $_ENV['cacheread'] = 1;
        $x = APCG($a);
        Gt('apcread-get');
        echo $x;
        kill("<!--readapccache:{$_ENV['lasttime']}ms-->");
    }
    #str_replace(TMP,SHM,CACHEPATH),
    $path = array(CACHEPATH);
    Array_unique($path);
    #Mem en préférence
    foreach ($path as $cachepath) {
        if ($_ENV['yt']['erasecache'] && H == 'anciensinterneslyon.fr' && !J9) {
            e(',erasecache');
            @unlink($cachepath);
            continue;
        }
        if (is_file(DR . '.lastmod.db') && is_file($cachepath)) {
            if (filemtime(DR . '.lastmod.db') > filectime($cachepath)) {
                unlink($cachepath);
            }
        }
        #pour le joomla#cma-lib-joo-datab-datab-mysqli:391
        if (is_file($cachepath)) {
            r304($cachepath);
            $fs = Filesize($cachepath);
            if (bots || isgoodurl() && $fs > 100 && filemtime($cachepath) > $_ENV['expires']) {
                $_ENV['cacheread'] = 1;
                e(',cacheread,die,noperf,' . $cachepath . ',cachesize:' . $fs);
                Gt('cachepath:read:0');
                #ob_end_clean();
                #if(H=='anciensinternesdelyon.fr'){$x=utf2a(file_get_contents($cachepath));echo $x;}else{
                readfile($cachepath);
                #78,18,25	$x=FGC($cachepath);echo$x);
                Gt("cachepath:read:1:size:{$fs}");
                header('A: cacheread:' . $_ENV['lasttime'], 1);
                die;
            }
        }
    }
    #ob_end_clean(); was taking the more time
    #écriture
    $cachepath = Re($_ENV['c']['htmlcache'][0], CACHEPATH);
    #html local override
    #e(',t:'.$t.','.$cachepath);
    #unlink $path=Array(str_replace(TMP,SHM,CACHEPATH),CACHEPATH);A
    if ($t) {
        GT('cache:write');
        $page = ob_get_contents();
        #GT('flush:0');ob_flush();gt('flush:1');
        #ob_get_flush,ob_get_clean
        $exp = NOW + $_ENV['lasttime'] * $_ENV['c']['cachetime'];
        e('die,noperf,cachesize:' . strlen($page) . ',' . $_ENV['lasttime'] . ',' . Date('Y-m-d H', $exp));
        if ($_ENV['c']['htmlcache'][0]) {
            Av($_ENV['c']['htmlcache']);
            #manuellement déterminé
            foreach ($path as $v) {
                @unlink($v);
            }
            #unlink tous fichiers de cache antérieurs
            $page = $_ENV['c']['htmlcache'][1] . $page . $_ENV['c']['htmlcache'][2] . '<?kill();?>';
            #Ya
        }
        if ($_ENV['lasttime'] > 0.3 || strlen($page) > 50000) {
            #
            #$cachepath=str_replace(TMP,SHM,$cachepath);e(',shm');
            if ($apc) {
                $apc = 2;
                APCP($a, $page);
                gt('apc-write');
            }
        }
        if ($apc != 2) {
            FPC($cachepath, $page);
            Touch($cachepath, $exp);
            r304($exp);
        }
        #if(GT()>500)Dbt();chown($cachepath,'www-data');
        #uniquement si owner = the same :)
        #if(h=='anciensinternesdelyon.fr')av(cachepath,$exp);
        #Gt('echo page');echo $page;Gt('echo page-done');
        header('Acachegen: ' . $_ENV['lasttime']);
        die;
    }
    if (!$t) {
        $t = 1;
        if (!$_ENV['expires']) {
            $_ENV['expires'] = now;
        }
        GT('cache:init');
    }
    #sinon initialisation du cache
}
Example #3
0
function fmt($f)
{
    $f2 = fmkt($f);
    if ($f2 == 2000000000) {
        null;
    } else {
        $f2++;
    }
    if (Touch($f, $f2)) {
        return $f2;
    } else {
        Db("touch:{$f}", null, '1');
    }
}
Example #4
0
 function prepare_cache_file()
 {
     // Prepare Cache file
     if (!Is_Dir($this->cache_dir_path) && !Is_File($this->cache_dir_path) && Is_Writable(DirName($this->cache_dir_path))) {
         MkDir($this->cache_dir_path);
         ChMod($this->cache_dir_path, 0755);
     }
     if (Is_Dir($this->cache_dir_path) && Is_Writable($this->cache_dir_path)) {
         Touch($this->cache_file_path);
     }
 }