* */ /** * Class docserver : manage the docservers and the filename in the classment on the docservers * * @author Claire Figueras * @license GPL * @package Maarch LetterBox 2.0 * @version 1.1 */ class docserver { /** * Draw the filename * * @param string $path_template path * @return array filename array */ public function filename($path_template) { // Draw the filename if ($_SESSION['config']['system'] == "true") { // Draw the filename $file_tab = scandir($path_template); array_shift($file_tab); array_shift($file_tab); $nb_files = count($file_tab); if ($nb_files == 0 ) { //LB20060801 rights change : wrx if (!mkdir($path_template."1",0000755)) { $_SESSION['error'] = _FILE_SEND_ERROR.". "._TRY_AGAIN.". "._MORE_INFOS." : ".$_SESSION['config']['adminname'].""; header("location: file_index.php"); exit; } else { //LB20060801 $destination_rept = $path_template."1/"; $file_destination_name = "1"; return array("destination_rept" => $destination_rept, "file_destination_name" => $file_destination_name); } } else { //Get next usable tree for the docserver //LB20060801 $destination_rept = $path_template.count($file_tab)."/"; $file_tab2 = scandir($path_template.strval(count($file_tab))); //echo $path_template.strval(count($file_tab)); // delete the . and .. line array_shift($file_tab2); array_shift($file_tab2); $nb_files2 = count($file_tab2); //if number of files => 2000 then we create a new directory if ($nb_files2 >= 2000 ) { $new_rept = ($nb_files) + 1; //LB20060801 rights change : wrx if (!mkdir($path_template.$new_rept,0000755)) { $_SESSION['error'] = _FILE_SEND_ERROR.". "._TRY_AGAIN.". "._MORE_INFOS." : ".$_SESSION['config']['adminname'].""; header("location: file_index.php"); exit; } else { //LB20060801 $destination_rept = $path_template.$new_rept."/"; $file_destination_name = "1"; return array("destination_rept" => $destination_rept, "file_destination_name" => $file_destination_name); } } else { $new_file_name = ($nb_files2) + 1; //echo $destination_rept.$new_file_name."
"; //print_r($file_tab2); //modifs cfi 30 07 2008: correction annomalie docserver $greater = $new_file_name; for($n=0;$n"; if((int)$greater <= (int)$current_file_name[0]) { //echo 'new file name : '.(int)$greater.'
current : '.(int)$current_file_name[0].'
'; //echo "
warning greater file already exists".$file_tab2[$n]."
"; //$new_file_name ++; //$nb_inc ++; if((int)$greater == (int)$current_file_name[0]) { $greater ++; } else // $greater < current { $greater = (int)$current_file_name[0] +1; } } } $file_destination_name = $greater ; //echo 'destinatation : '.$file_destination_name."
"; // echo $greater; // exit(); ///////////// Fin correctif return array("destination_rept" => $destination_rept, "file_destination_name" => $file_destination_name); } } } else { $file_tab = scandir($path_template); array_shift($file_tab); array_shift($file_tab); $nb_files = count($file_tab); if ($nb_files == 0 ) { if (!mkdir($path_template."1",0000200)) { $_SESSION['error'] = _FILE_SEND_ERROR.". "._TRY_AGAIN.". "._MORE_INFOS." : ".$_SESSION['config']['adminname'].""; header("location: file_index.php"); exit; } else { $destination_rept = $path_template."1\\"; $file_destination_name = "1"; return array("destination_rept" => $destination_rept, "file_destination_name" => $file_destination_name); } } else { //Get next usable tree for the docserver $destination_rept = $path_template.count($file_tab)."\\"; $file_tab2 = scandir($path_template.strval(count($file_tab))); // delete the . and .. line array_shift($file_tab2); array_shift($file_tab2); $nb_files2 = count($file_tab2); //if number of files => 2000 then we create a new directory if ($nb_files2 >= 2000 ) { $new_rept = ($nb_files) + 1; if (!mkdir($path_template.$new_rept,0000755)) { $_SESSION['error'] = _FILE_SEND_ERROR.". "._TRY_AGAIN.". "._MORE_INFOS." : ".$_SESSION['config']['adminname'].""; header("location: file_index.php"); exit; } else { $destination_rept = $path_template.$new_rept."\\"; $file_destination_name = "1"; return array("destination_rept" => $destination_rept, "file_destination_name" => $file_destination_name); } } else { $new_file_name = ($nb_files2) + 1; //echo $destination_rept.$new_file_name."
"; //print_r($file_tab2); //modifs cfi 30 07 2008: correction annomalie docserver $greater = $new_file_name; for($n=0;$n"; if((int)$greater <= (int)$current_file_name[0]) { //echo 'new file name : '.(int)$greater.'
current : '.(int)$current_file_name[0].'
'; //echo "
warning greater file already exists".$file_tab2[$n]."
"; //$new_file_name ++; //$nb_inc ++; if((int)$greater == (int)$current_file_name[0]) { $greater ++; } else // $greater < current { $greater = (int)$current_file_name[0] +1; } } } $file_destination_name = $greater ; //echo 'destinatation : '.$file_destination_name."
"; // echo $greater; // exit(); ///////////// Fin correctif return array("destination_rept" => $destination_rept, "file_destination_name" => $file_destination_name); } } } } } ?>