analyser(); $download_options = $xml_print->table; if ($action_download=="download_prepare") { header ("Content-Type: text/html; charset=$charset"); print $std_header; print "

".$msg["download_options"]."

\n"; print "
"; print "".$msg["download_size"].""; print"


"; $sort_info = !empty($sort_id) ? '' : ''; print" ".$msg["download_output_title"]."


".$sort_info."  "; print "
"; } if ($action_download=="download") { if ($_SESSION["session_history"][$current_download]) { $_SESSION["DOWNLOAD"]=$_SESSION["session_history"][$current_download]["NOTI"]; $_SESSION["DOWNLOAD"]["pager"]=$pager; $_SESSION["DOWNLOAD"]["output_docnum"]=$output_docnum; if ($sort_id) $_SESSION["DOWNLOAD"]["sort_id"]=$sort_id; else $_SESSION["DOWNLOAD"]["sort_id"]=$_SESSION['tri']; echo ""; } else { echo ""; } } if (($action_download=="")&&($_SESSION["DOWNLOAD"])) { $environement=$_SESSION["DOWNLOAD"]; $limit=''; if ($environement["TEXT_QUERY"]) { if (count($environement["TEXT_LIST_QUERY"])) { foreach($environement["TEXT_LIST_QUERY"] as $query) { @pmb_mysql_query($query); } } $requete=preg_replace('/limit\s+[0-9]\s*,*\s*[0-9]*\s*$/','',$environement["TEXT_QUERY"],1); } else { switch ($environement["SEARCH_TYPE"]) { case "extended": $sh=new search(); $table=$sh->make_search(); $requete="select notice_id from $table"; break; case "cart": $requete="select object_id as notice_id from caddie_content join notices where caddie_id=".$idcaddie." and object_id=notice_id order by index_sew"; break; } } if ($environement["pager"]) { $start= $nb_per_page_search*($environement["PAGE"]-1); $nbLimit = $nb_per_page_search; $limit="limit ".$start.",$nb_per_page_search"; }else{ $start = 0; $nbLimit = -1; } if ($environement["sort_id"]) { $sort = new sort('notices','base'); $requete = $sort->appliquer_tri($environement["sort_id"] , $requete, "notice_id", $start, $nbLimit); }else{ $requete.=" $limit"; } $resultat=@pmb_mysql_query($requete); while (($r=pmb_mysql_fetch_object($resultat))) { $query = "SELECT explnum_id from explnum where explnum_notice=".$r->notice_id; $query .= " union "; $query .= " select explnum_id from explnum ,bulletins where explnum_bulletin=bulletin_id and num_notice=".$r->notice_id; $result = pmb_mysql_query($query,$dbh); if ($result) { while($row = pmb_mysql_fetch_object($result)){ $explnum_id=$row->explnum_id; $res = pmb_mysql_query("SELECT explnum_id, explnum_notice, explnum_bulletin, explnum_nom, explnum_mimetype, explnum_url, explnum_data, length(explnum_data) as taille,explnum_path, concat(repertoire_path,explnum_path,explnum_nomfichier) as path, repertoire_id FROM explnum left join upload_repertoire on repertoire_id=explnum_repertoire WHERE explnum_id = '$explnum_id' ", $dbh); $ligne = pmb_mysql_fetch_object($res); $id_for_rigths = $ligne->explnum_notice; if($ligne->explnum_bulletin != 0){ //si bulletin, les droits sont rattachés à la notice du bulletin, à défaut du pério... $req = "select bulletin_notice,num_notice from bulletins where bulletin_id =".$ligne->explnum_bulletin; $res = pmb_mysql_query($req,$dbh); if(pmb_mysql_num_rows($res)){ $r = pmb_mysql_fetch_object($res); $id_for_rigths = $r->num_notice; if(!$id_for_rigths){ $id_for_rigths = $r->bulletin_notice; } } } //droits d'acces utilisateur/notice if ($gestion_acces_active==1 && $gestion_acces_user_notice==1) { require_once("$class_path/acces.class.php"); $ac= new acces(); $dom_1= $ac->setDomain(1); $rights = $dom_1->getRights($PMBuserid,$id_for_rigths); } if( $rights & 4 || (is_null($dom_1))){ if (($ligne->explnum_data)||($ligne->explnum_path)) { $explnum_list[] = $ligne->explnum_id; } } } } } if (count($explnum_list)) { switch($environement['output_docnum']) { case 'singly': foreach ($explnum_list as $explnum_id) { print ""; } break; case 'zip': $zip = new ZipArchive(); $filename=microtime(); $filename=str_replace(".","",$filename); $filename=str_replace(" ","",$filename); $filename="temp/pmb_".$filename.".zip"; $res = $zip->open($filename, ZipArchive::CREATE); if ($res) { foreach ($explnum_list as $explnum_id) { $explnum = new explnum($explnum_id); $zip->addFromString(reg_diacrit($explnum->get_file_name()),$explnum->get_file_content()); } $zip->close(); header("Content-disposition: attachment; filename=\"".basename($filename)."\""); header("Content-Type: application/force-download"); header("Content-Transfer-Encoding: application/zip"); header("Content-Length: ".filesize($filename)); header("Pragma: no-cache"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public"); header("Expires: 0"); $fp = fopen($filename, 'rb'); fpassthru($fp); fclose($fp) ; @unlink($filename); } break; } } } ?>