EOT; $DA['FOOTER'] = << EOT; // admin filter if($_COOKIE["admin"] == $password) $admin=true;else $admin=false; // ACTION SWITCH if ($admin){ switch ($_GET['action']) { case 'img_upload': ImageUploadPage(); break; case 'img_browse': ImageBrowsePage(); break; case 'wwwwww': break; } } else { echo "Not admin"; } ############################### function ImageUploadPage(){ global $admin, $DA; echo $DA['HEADER']; $input_field_name = "picturefile"; $accepted_mime_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/pjpeg'); $destination_folder = "../images/"; $overwrite = false; //Overwrite the file if it exists $upload = new upload($input_field_name); /** * The following three lines are optional. * They set some upload-limits. */ $upload->set_max_file_size(5120000); $upload->set_max_image_size(2048, 1536); //in pixels $upload->set_accepted_mime_types($accepted_mime_types); //$upload->draw_form('Upload pictures', 'index.php'); //the second argument is optional $result = $upload->move($destination_folder, $overwrite); echo '
'; if ($result == true) { $da_file = $destination_folder.$upload->file['name']; chmod ($da_file, 0644); echo $da_file." was successfully uploaded
"; // DESIRED MAX SIZE list($width, $height) = explode("x", $_POST['selected_size_img']); // ACTUAL SIZE list($orig_width, $orig_height) = getimagesize($da_file); $orig_ratio = $orig_width/$orig_height; // DOIT if ($width/$height > $orig_ratio) { $width = $height*$orig_ratio; } else { $height = $width/$orig_ratio; } $myImage = new image($da_file); $myImage->Resize($width, $height); // $prim_name = $myImage->WriteFile($destination_folder, "2"); $prim_name = $myImage->WriteFile($destination_folder, ""); if ($_POST['dothumb'] == "y") { // DESIRED MAX THUMB SIZE list($tb_width, $tb_height) = explode("x", $_POST['selected_size_thumb']); // DOIT if ($tb_width/$tb_height > $orig_ratio) { $tb_width = $tb_height*$orig_ratio; } else { $tb_height = $tb_width/$orig_ratio; } $myImage->Resize($tb_width, $tb_height); $thumbname = $myImage->WriteFile($destination_folder, "_thumb"); if (file_exists($destination_folder.$thumbname)) { echo $thumbname." was successfully Created
"; } else { echo "No thumb
"; $nothumb = TRUE; } } echo '
'; if ($_POST['dothumb'] != "y" || $nothumb) { $thumbname = $upload->file['name']; } $wiki_image = "[((images/".$thumbname."))|images/".$upload->file['name']."?]"; echo '
Pour afficher l\'image sur une page : '.$wiki_image; ?> " . $upload->error_msg . ""; } echo $DA['FOOTER']; } function ImageBrowsePage(){ global $admin, $DA; /* print_r($_GET); print_r($_POST); */ $exts = Array('.png', '.jpg', '.gif'); $nav = New Browser('../images/', $exts); echo $DA['HEADER']; $nav->DisplayNav(); // print_r($nav->GetFileList('../images/')); // echo exec('pwd'); $nav->DisplayDir(); echo $DA['FOOTER']; } ?>