class_name = self::class; parent::__construct($id); if(!empty($this->parameters['id_rep'])) { $this->up_rep = new upload_folder($this->parameters['id_rep']); } } public function get_params_form(){ global $charset,$msg; $req="select repertoire_id, repertoire_nom from upload_repertoire order by repertoire_nom"; $res = pmb_mysql_query($req); if(pmb_mysql_num_rows($res)){ $params_form= "
"; $params_form.=" "; }else{ $params_form.="
"; } $params_form.= "
"; return $params_form; } public function add($file){ if($this->parameters['id_rep']){ $filepath = $this->get_filepath($file); if(file_exists("./temp/".$file)){ if (rename("./temp/".$file,$filepath)) { return $filepath; } } } return false; } public function get_filepath($file){ $chemin_hasher = "/"; if($this->up_rep->isHashing()){ $rep = $this->up_rep->hachage($file); @mkdir($rep); $chemin_hasher = $this->up_rep->formate_path_to_nom($rep); $file_name = $rep.$file; $chemin = $this->up_rep->formate_path_to_save($chemin_hasher); }else{ $file_name = $this->up_rep->get_path($file).$file; $chemin = $this->up_rep->formate_path_to_save("/"); } $file_name = $this->up_rep->encoder_chaine($file_name); $i=1; while(file_exists($file_name)){ if($i==1){ $file_name = substr($file_name,0,strrpos($file_name,"."))."_".$i.substr($file_name,strrpos($file_name,".")); }else{ $file_name = substr($file_name,0,strrpos($file_name,($i-1).".")).$i.substr($file_name,strrpos($file_name,".")); } $i++; } return $file_name; } public function delete($filepath){ if($this->parameters['id_rep']){ if(!file_exists(str_replace("//","/",$this->up_rep->repertoire_path.$filepath))){ return false; } return unlink(str_replace("//","/",$this->up_rep->repertoire_path.$filepath)); } return false; } public function get_uploaded_fileinfos($filepath){ $infos =array(); if($filepath){ $infos['title'] =""; $infos['description'] =""; $infos['filename'] = basename($filepath); $infos['mimetype'] = $this->get_mimetype($filepath); $infos['filesize'] = filesize($filepath); $infos['vignette'] = construire_vignette($filepath); $infos['url'] = ""; $infos['path'] = str_replace($this->up_rep->repertoire_path,"",$filepath); $infos['path'] = str_replace(basename($filepath),"",$infos['path']); if(empty($info['path'])) { $infos['path'] = "/"; } $infos['create_date'] = date('Y-m-d'); $infos['num_storage'] = $this->id; } return $infos; } public function get_storage_infos(){ global $charset,$msg; return $this->name." (".$msg['local_storage'].")"; } public function get_infos(){ return $this->up_rep->repertoire_path; } public function duplicate($source_path,$dest_path){ return copy(str_replace("//","/",$this->up_rep->repertoire_path.$source_path),$dest_path); } public function get_content($file_path){ if(file_exists(str_replace("//","/",$this->up_rep->repertoire_path.$file_path))){ return file_get_contents(str_replace("//","/",$this->up_rep->repertoire_path.$file_path)); }else{ return false; } } }