X-Git-Url: http://git.cyclocoop.org/?p=ptitvelo%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fplugins%2Faccesrestreint_3_5%2Faction%2Fapi_docrestreint.php;h=d805a9cfb26e9ffda35f4696949cc4af783a34cb;hp=7737ed02b5175c649bc0fb2e6bdc830e617e9bf2;hb=bca3db9e1ab94e469b01f7e994a5e095de5f88c4;hpb=b97874b04ea8ca43d21b7ef7309feff8ef0e4a07 diff --git a/www/plugins/accesrestreint_3_5/action/api_docrestreint.php b/www/plugins/accesrestreint_3_5/action/api_docrestreint.php index 7737ed0..d805a9c 100644 --- a/www/plugins/accesrestreint_3_5/action/api_docrestreint.php +++ b/www/plugins/accesrestreint_3_5/action/api_docrestreint.php @@ -33,6 +33,18 @@ function action_api_docrestreint_dist($arg=null) { $arg = explode("/",$arg); + // supprimer et vider les buffers qui posent des problemes de memory limit + // http://www.php.net/manual/en/function.readfile.php#81032 + @ini_set("zlib.output_compression","0"); // pour permettre l'affichage au fur et a mesure + @ini_set("output_buffering","off"); + @ini_set('implicit_flush', 1); + @ob_implicit_flush(1); + $level = ob_get_level(); + while ($level--){ + @ob_end_clean(); + } + + if (count($arg)>=3){ $id_document = intval(array_shift($arg)); @@ -53,6 +65,8 @@ function action_api_docrestreint_dist($arg=null) { spip_log($file,'dbg'); $status = $dcc = false; + $dossiers_a_exclure = array('nl'); + // securite : on refuse tout ../ ou url absolue if (strpos($f,'../') !== false OR preg_match(',^\w+://,', $f)) { @@ -61,6 +75,12 @@ function action_api_docrestreint_dist($arg=null) { else if (!file_exists($file) OR !is_readable($file)) { $status = 404; } + // Si c'est dans un sous-dossier explicitement utilisé pour autre chose que les documents + // (exemple : les newsletters) + // et bien on ne teste pas l'accès + elseif (preg_match('%^(' . join('|', $dossiers_a_exclure) . ')/%', $f)){ + $status = 200; + } else { $where = "documents.fichier=".sql_quote(set_spip_doc($file)) . ($id_document ? " AND documents.id_document=".intval($id_document): ''); @@ -158,4 +178,4 @@ function action_api_docrestreint_dist($arg=null) { } -?> \ No newline at end of file +?>