Example #1
0
 function download($idUpload)
 {
     $Upload = $this->Upload->find("first", array('conditions' => array('Upload.id' => $idUpload)));
     $get_url = realpath('../../app/webroot/img/uploads/') . "\\" . $Upload['Upload']['name'];
     //$get_url=realpath("../../".$Upload['Upload']['path']."/").$Upload['Upload']['name'];
     if (!File_exists($get_url)) {
         print $get_url;
         print "File's not exits";
         exit;
     }
     $size = Filesize($get_url);
     header("Content-Type: application/save");
     header("Content-Length: {$size}");
     header("Content-Disposition: attachment; Filename=\"" . $Upload['Upload']['name'] . "\"");
     header("Content-Transfer-Encoding: binary");
     if ($fh = fopen("{$get_url}", "rb")) {
         fpassthru($fh);
         fclose($fh);
     } else {
         print "Permission denied: " . $get_url;
         exit;
     }
     $this->Upload->updateAll(array('Upload.dem' => 'Upload.dem+1'), array('Upload.id' => $idUpload));
     //$sql="select dem from uploads where  name='".$get_name."'";
     //$query=mysql_query($sql);
     //$row=mysql_fetch_array($query);
     //		$dem=$row['dem'];
     //		echo $dem;
     //		$sql1="update uploads set dem='".($dem+1)."' where  name='".$get_name."'";
     //		mysql_query($sql1);
     $this->render('index');
 }
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
}