Changeset 775017
- Timestamp:
- 09/19/2013 01:44:12 AM (13 years ago)
- Location:
- nextgen-public-image-uploader/trunk
- Files:
-
- 8 edited
-
Includes/filefunc.php (modified) (2 diffs)
-
Includes/makethumb.php (modified) (4 diffs)
-
Includes/moderation.php (modified) (12 diffs)
-
Includes/options.php (modified) (6 diffs)
-
Includes/validation.php (modified) (7 diffs)
-
css/nggpup.css (modified) (6 diffs)
-
ngg_uploader.php (modified) (6 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nextgen-public-image-uploader/trunk/Includes/filefunc.php
r767294 r775017 71 71 }?> 72 72 <?php function ngg_pup_direct_to_gallery_precheck($shortcodes) { // because certain things will be handled differently, we have to prepare some of the data. 73 if (!empty($shortcodes)&& (is_numeric($shortcodes['gid']))) {74 73 $gal = ngg_pup_get_gallery_list('where gid IN ('.$shortcodes['gid'].')'); 75 }76 74 if(!empty($gal)) { 77 75 return array(gal_id=>$shortcodes['gid'], gal_info=>$gal); … … 197 195 } 198 196 }?> 197 <?php function ngg_pup_make_new_gallery($gal_info) { 198 global $wpdb; 199 $table_name = $wpdb->prefix . "ngg_gallery"; 200 $rows_affected = $wpdb->insert( $table_name, array( 201 'name' => $gal_info['gal_name'], 202 'slug' => $gal_info['gal_slug'], 203 'path' => $gal_info['gal_path'], 204 'title' => $gal_info['gal_title'], 205 'galdesc' => $gal_info['gal_desc'], 206 'pageid' => $gal_info['gal_page_id'], 207 'previewpic' => $gal_info['gal_preview_pic_id'], 208 'author' => $gal_info['user_name'], 209 ) ); 210 211 }?> 212 <?php function pup_create_gallery ($options) { 213 $user_ID = get_current_user_id(); 214 if (($options['Allow_user_gal_create']=="checked") &&(ngg_pup_check_role_allowed(wp_get_current_user(), $options['allowed_roles_create_gal'])=="passes")) { 215 //do nothing, proceed; 216 } else { 217 return array('error_msg'=>"Sorry, you do not have access to create galleries at this time.", 'code'=>1); 218 } 219 //initial check to see if role has access as extra security. 220 $name = ngg_pup_sanitize_gal_name ($_POST['create_gallery_name']); 221 $gal_check = ngg_pup_get_gallery_list("where name like '$name%%' OR title like '$name%%' OR slug like '$name%%'"); 222 if (!empty($gal_check)) { 223 foreach ($gal_check as $gal) { 224 $titles[]=$gal->title; 225 $names[]=$gal->name; 226 $slugs[]=$gal->slug; 227 } 228 $a=1; 229 while ($a <= 11) { //tries to find a clean name we can use. 230 if (!in_array($name."-".$a, $titles)&&(!in_array($name."-".$a, $names)) && (!in_array($name."-".$a, $slugs))) { 231 $name=$name."-".$a; 232 break; 233 } 234 $a++; 235 } 236 if ($a==11) { 237 return array('error_msg'=>"Could not create new gallery, because there are already galleries with that name. 238 Please try a different name.", 'code'=>1); 239 } 240 } // if gal_list comes back empty, no gallery with the name exists and we can just create normally. 241 242 $path=$options['Nextgen_full_directory'].$name."/"; 243 $thumbs_path = $path."/thumbs"; 244 if ((!is_dir($path)) && (!file_exists($path)) && (!is_dir($path)) && (!file_exists($path))) { 245 if(!mkdir($path, 0777, true)) { 246 return array('error_msg'=>"Could not create gallery directory.", 'code'=>1); 247 } 248 if(!mkdir($thumbs_path, 0777, true)) { 249 return array('error_msg'=>"Could not create thumbnail directory.", 'code'=>1); 250 } 251 } else { 252 return array('error_msg'=>"Could not make new directory, because it already exists. Try a different name.", 'code'=>1); 253 } 254 255 $path = $options['Nextgen_base_directory']."/".$name."/"; 256 $gal_info = array( 257 'gal_name' => $name, 258 'gal_slug' => $name, 259 'gal_path' => $path, 260 'gal_desc' => "none", 261 'gal_title' => $name, 262 'gal_page_id' => '', //will likely want to add an option for users to pick a default page. 263 'gal_preview_pic_id' =>"", 264 'user_name' => $user_ID, 265 ); 266 ngg_pup_make_new_gallery($gal_info); 267 return array('error_msg'=>"Gallery $name created successfully", 'code'=>0, 'gal_info'=>$gal_info); 268 } ?> -
nextgen-public-image-uploader/trunk/Includes/makethumb.php
r767294 r775017 2 2 // this expects $file to include: 3 3 // dir - where the $file is located 4 // name - name name with extension4 // name - file name with extension 5 5 $file_info = ngg_pup_get_true_extension($file['dir'].$file['name']); 6 6 $file['ext'] = $file_info['ext']; 7 7 8 if (file_exists($args['target_dir'].$args['target_name'].$file['ext'])) { //checks to make sure thumb file doesn't exist. 8 return "file already exists."; 9 return array( 10 msg=> "thumbs_$file[name] could not be created, file already exists.", 11 code=> 1); 9 12 } 13 10 14 if (!file_exists($file['dir'].$file['name'])) { //checks to make sure source image exists. 11 return "source image does not exist."; 15 return array( 16 msg=> "thumbs_$file[name] could not be created source image does not exist.", 17 code=> 1); 12 18 } 19 20 if (!file_exists($args['target_dir'])) { 21 return array( 22 msg=> "thumbs_$file[name] could not be created, destination directory does not exist or is not writeable.", 23 code=> 1); 24 } 25 13 26 if($file['ext'] == 'gif'){ 14 27 $new_file = imagecreatefromgif($file['dir'].$file['name']); … … 18 31 $new_file = imagecreatefrompng($file['dir'].$file['name']); 19 32 }else{ 20 return false; 33 return array( 34 msg=> "thumbs_$file[name] could not be created, unknown file extension $file[ext].", 35 code=> 1); 21 36 } 22 37 … … 48 63 imagedestroy($new_file); 49 64 imagedestroy($dst_image); 50 return array("File successfully created"); 65 return array( 66 msg=> "thumbs_$file[name] thumbnail successfully created", 67 code=> 0); 68 69 51 70 } ?> 52 71 <?php function thumbcreatefrombmp( $filename ) … … 92 111 } 93 112 } 94 return $image;113 return "Thumbnail created successfully."; 95 114 }?> -
nextgen-public-image-uploader/trunk/Includes/moderation.php
r767294 r775017 8 8 <?php } else { 9 9 if ($options['enable_moderation_queue'] =="checked") { 10 ngg_pup_moderate_inital_checks ( ); ?>10 ngg_pup_moderate_inital_checks ($options); ?> 11 11 <?php } else { ?> 12 12 <span class="ngg_pup_lockout_message"> … … 17 17 } ?> 18 18 <?php function ngg_pup_process_results($files_array) { 19 $options = get_option('NGG_User_upload_option_array'); 19 20 foreach ($files_array[0] as $file) { 20 21 switch ($file->f_radio) { //checks what status of radio button is, either Batch process, move or delete. … … 23 24 // all files flagged under "batch process" are reflagged based on what the batch proccess command was ie: delete or move/leave in queue. 24 25 // this is left in for error handling. 25 ngg_pup_moderate_result_display ($file, "There was a problem processing $file->file_name as part of the batch procces. Please try again.", 1); 26 ngg_pup_return_file_display (array( 27 'url'=>$file->file_url, 28 'name'=>$file->file_name, 29 'status'=>"There was a problem processing this file as part of the batch procces. Please try again.", 30 'error_code'=>1, 31 )); 26 32 break; 27 33 case 1: //move 28 34 if ($file->f_gid == 0) { //if 0, then "Leave in queue was selected and we do nothing" 29 ngg_pup_moderate_result_display ($file, "No gallery was selected for $file->file_name. The file was left in the queue.", 1); 35 ngg_pup_return_file_display (array( 36 'url'=>$file->file_url, 37 'name'=>$file->file_name, 38 'status'=>"No gallery selected. The file was left in the queue.", 39 'error_code'=>1, 40 )); 30 41 } else { 31 42 ngg_pup_moderate_process_move($file, $files_array); … … 33 44 break; 34 45 case 2: //delete 35 ngg_pup_moderate_result_display ($file, "$file->file_name was successfully deleted.", 0); 46 ngg_pup_return_file_display (array( 47 'url'=>$file->file_url, 48 'name'=>$file->file_name, 49 'status'=>"Successfully deleted.", 50 'error_code'=>0, 51 )); 52 36 53 if (file_exists($file->file_path."/".$file->file_name)) { //else it's already gone for some reason. 37 54 unlink($file->file_path.DIRECTORY_SEPARATOR.$file->file_name); … … 39 56 ngg_pup_remove_from_db ($file); 40 57 break; 58 59 60 41 61 } 42 62 } 43 63 }?> 44 <?php function ngg_pup_moderate_result_display ($file, $status, $code) { // shows results of moderation actions ?> 45 <?php if($code==1) { ?> 46 <div class="ngg_pup_moderate_results"> 47 <span class="error"> 48 <li> 49 <?php echo $status;?> 50 </li> 51 </span> 52 </div> 53 <?php } else { ?> 54 <div class="ngg_pup_moderate_results"> 55 <span class="success"> 56 <li> 57 <?php echo $status;?> 58 </li> 59 </span> 60 </div> 61 <?php } ?> 62 <?Php }?> 63 <?php function ngg_pup_create_mod_page($token_id) { //starts building mod page here. ?> 64 <?php $queue = ngg_pup_get_queue_info($optional); // builds file list; 64 <?php function ngg_pup_create_mod_page($token_id, $options) { //starts building mod page here. ?> 65 <?php 66 $queue = ngg_pup_get_queue_info($optional); // builds file list; 65 67 if (count($queue)==0) { ?> 66 68 <span class="ngg_pup_lockout_message"> … … 74 76 $cnt = 0; //used to make our forms. This makes each form have it's own identifier, to work 75 77 // in conjuction with what we'll do with the files. ?> 76 <span class="ngg_pup_upload_wrapper">77 78 <form name="moderation" action="" method="POST" enctype="multipart/form-data"> 78 < /span>79 <input type="hidden" name="token" value="<?php echo $token_id;//for ensuring refreshes don't screw things up?>"> 79 80 <div class="ngg_pup_moderate_batch_bar"> 80 <div class="ngg_pup_moderate_left_bar"> 81 <div class="ngg_pup_moderate_left_bar_1"> 82 <input type="radio" name="batch_radio[]" class="ngg_pup_radio" checked="checked" id="batch_processed1" name="batch_radio[]" value="2" /> 81 <div class="ngg_pup_moderate_bar_box_1"> 82 <input type="radio" name="batch_radio[]" class="ngg_pup_radio" id="batch_processed1" name="batch_radio[]" value="2" /> 83 83 <label for="batch_processed1"> 84 84 Delete Files 85 85 </label> 86 86 </div> 87 <div class="ngg_pup_moderate_ left_bar_2">87 <div class="ngg_pup_moderate_bar_box_2"> 88 88 <input type="radio" name="batch_radio[]" class="ngg_pup_radio" checked="checked" id="batch_processed2" name="batch_radio[]" value="1" /> 89 89 <label for="batch_processed2"> … … 92 92 </label> 93 93 </div> 94 </div> 95 <div class="ngg_pup_moderate_right_bar"> 96 <input type="submit" value="Submit" class="ngg_pup_submit_button"> 94 <?php if (($options['Allow_user_gal_create']=="checked") &&(ngg_pup_check_role_allowed(wp_get_current_user(), $options['allowed_roles_create_gal'])=="passes")) {?> 95 <div class="ngg_pup_moderate_bar_box_3"> 96 <label for="create_gallery"> 97 <input type="radio" name="batch_radio[]" class="ngg_pup_radio" id="create_gallery" name="batch_radio[]" value="3" /> 98 <span style="float:left;"> 99 Create Gallery 100 </span> 101 <input type="text" name="create_gallery_name" class="ngg_pup_moderate_bar_text_box" placeholder="Enter Gallery name"> 102 </label> 103 </div> 104 <?php } ?> 97 105 <?php //currently disabled. 98 106 // until I can figure out tagging. 99 107 //<input type="text" name="batch_tags" class="ngg_pup_moderate_bar_text_box" placeholder="Comma seperated tags"> 100 108 ?> 101 </div> 102 </div> 103 <input type="hidden" name="token" value="<?php echo $token_id;//for ensuring refreshes don't screw things up?>"> 109 <div class="ngg_pup_moderate_bar_box7"> 110 <input type="submit" value="Submit" class="ngg_pup_submit_button"> 111 </div> 112 </div> 113 104 114 <div class="ngg_pup_moderate_wrapper"> 105 115 <?php foreach ($queue as $file) { … … 147 157 </div> 148 158 <div class="moderate_pic_menu"> 149 <? Php // current disabled until I can figure out an alternative tagging system //159 <?php // current disabled until I can figure out an alternative tagging system // 150 160 //<input type="text" name="tags[<?php echo $cnt;]" class="ngg_pup_text_box" placeholder="Comma seperated tags list"> 151 161 ?> … … 160 170 <?php } ?> 161 171 <?php function NGG_pup_gal_pulldown($gallery_list, $optional) { //the $optional is to build a unique form name if we want. ?> 162 <select name="<?php echo $optional;?>gid[]" class=" ngg_pup_pulldown">172 <select name="<?php echo $optional;?>gid[]" class="<?php echo $optional;?>ngg_pup_pulldown"> 163 173 <selected><option value="00">Leave in queue.</option></selected> 164 174 <?php foreach ($gallery_list as $gall_list) { // starts loop for each gallery ?> … … 183 193 $errors = ngg_pup_check_transfer($file, $gal_info); //checks if sources exists, and makes sure target doesnt. 184 194 if (!in_array('error', $errors, true)) { // makes sure no error codes are returned from check_transfer. 185 ngg_pup_create_thumb( //builds our thumbnails.195 $thumb_result = ngg_pup_create_thumb( //builds our thumbnails. 186 196 array(name => $file->file_name, dir =>$file->file_path), 187 197 array( … … 193 203 )); 194 204 $file->meta_data = ngg_pup_build_meta_data ($file, $files_array); 195 ngg_pup_moderate_result_display ($file, "$file->file_name was successfully moved to gallery - $destination->title", 0); 205 206 ngg_pup_return_file_display (array( 207 'url'=>$file->file_url, 208 'name'=>$file->file_name, 209 'status'=>"Successfully moved to $gal_info->title", 210 'error_code'=>0, 211 )); 196 212 ngg_pup_move_file ($file, $gal_info); 197 213 ngg_pup_add_to_ngg_db($file); //adds to NGG_Gallery DB. … … 199 215 } else { 200 216 if ($errors[0] == "error") { 201 ngg_pup_moderate_result_display ($file, "$file->file_name could not be moved, because the image could not be found.", 1); 217 ngg_pup_return_file_display (array( 218 'url'=>$file->file_url, 219 'name'=>$file->file_name, 220 'status'=>"Could not be moved, because the image could not be found.", 221 'error_code'=>1, 222 )); 202 223 } 203 224 if ($errors[1] == "error") { 204 ngg_pup_moderate_result_display ($file, "$file->file_name could not be moved, because it already exists in the gallery - $destination->title", 1); 205 } 206 } 207 } ?> 225 ngg_pup_return_file_display (array( 226 'url'=>$file->file_url, 227 'name'=>$file->file_name, 228 'status'=>"Could not be moved, because it already exists in $gal_info->title", 229 'error_code'=>1, 230 )); 231 } 232 if ($errors[2] == "error") { 233 ngg_pup_return_file_display (array( 234 'url'=>$file->file_url, 235 'name'=>$file->file_name, 236 'status'=>"Could not be moved, because the target directory does not exist.", 237 'error_code'=>1, 238 )); 239 240 } 241 } 242 } ?> -
nextgen-public-image-uploader/trunk/Includes/options.php
r767294 r775017 110 110 'setting_section_id' 111 111 ); 112 add_settings_field( 113 'Field 8', 114 'Allow users to create galleries.', 115 array( $this, 'settings8' ), 116 'NGG_user_upload_settings', 117 'setting_section_id' 118 ); 112 119 } 113 120 … … 144 151 145 152 if ((!is_dir($path)) && (!file_exists($path))) { 146 mkdir($path, 0777, true); 153 154 if(!mkdir($path, 0777, true)){ 155 echo "Sorry, could not create $path . Please check to make sure the directory 156 does not exist, and you have proper access to create directories."; 157 } 158 147 159 } 148 160 … … 152 164 $input['email_notification_on_upload'] = $this->check_form_box($input['email_notification_on_upload']); 153 165 $input['enable_NGG_support'] = $this->check_form_box($input['enable_NGG_support']); 166 $input['Allow_user_gal_create'] = $this->check_form_box($input['Allow_user_gal_create']); 154 167 155 168 global $wp_roles; 156 169 $roles = $wp_roles->get_names(); 157 170 foreach ($roles as $role) { 158 171 172 if ($input['Allow_user_gal_create'] != "checked") { 173 $input[$role."_can_create_gal"] = ""; 174 } else { 175 $input[$role."_can_create_gal"] = $this->check_form_box($input[$role."_can_create_gal"]); 176 } 177 178 if ($input[$role."_can_create_gal"]=="checked") { // checks to see if role can create galleries. If so stores it in array. 179 $allowed_roles_create_gal[]=$role; 180 } 181 159 182 if($input['Limit_Upload_by_user_role'] !="checked") { //if enabled, disables uploads, except for admin 160 183 $input[$role."_can_upload"] = ""; … … 177 200 $allowed_roles_upload[]=$role; 178 201 } 179 202 180 203 if ($input[$role."_can_moderate"]=="checked") { // checks to see if role can moderate, if so stores the role in an array we can check against on the front end. 181 204 $allowed_roles_moderate[]=$role; … … 186 209 $input['allowed_roles_upload'] = $allowed_roles_upload; //updates option array after loop 187 210 $input['allowed_roles_moderate'] = $allowed_roles_moderate; //updates option array after loop 188 211 $input['allowed_roles_create_gal'] = $allowed_roles_create_gal; 189 212 foreach ($extensions as $ext) { 190 213 $input[$ext."_allowed"] = $this->check_form_box($input[$ext."_allowed"]); … … 362 385 <?php } 363 386 387 public function settings8(){ //gallery creation setting.?> 388 <?php $options = $this->getoptions();?> 389 <?php if ($options['enable_moderation_queue'] =="checked") { 390 } else { 391 return; 392 } ?> 393 <div class="options_box"> 394 <input type="checkbox" name="NGG_User_upload_option_array[Allow_user_gal_create]" value="<?php echo $options['Allow_user_gal_create']?>" <?php echo $options['Allow_user_gal_create']?>/> 395 Enabling this option will allow you to set which user levels are allowed to create new galleries in the moderation queue. If this is unchecked, gallery creation will be disabled. 396 <br> 397 <br><b>As with everything else, please be careful with this option, as users will be able to create as many new galleries as they like.</b> 398 </div> 399 <?php if ($options['Allow_user_gal_create'] == "checked") {?> 400 <div class="selection_box"> 401 <span class="options_box_header">Select which users can use create galleries. </span> 402 <?php global $wp_roles; $roles = $wp_roles->get_names();?> 403 <?php foreach ($roles as $role) {?> 404 <div class="options_checkbox_wrap"> 405 <input type="checkbox" name="NGG_User_upload_option_array[<?php echo $role."_can_create_gal"?>]" value="<?php echo $options[$role.'_can_create_gal'];?>" <?php echo $options[$role.'_can_create_gal'];?>/> 406 <?php echo $role;?> 407 </div> 408 <?php }?> 409 </div> 410 <?php } ?> 411 412 <?php } 413 364 414 } 365 415 -
nextgen-public-image-uploader/trunk/Includes/validation.php
r767294 r775017 1 <?php function ngg_pup_validate_files($options, $array) { //File upload section. Validates and returns results. 1 <?php function ngg_pup_validate_files($options, $stored_info) { //File upload section. Validates and returns results. 2 2 3 // First we get all the files, and set them in an easy to manage array // 3 4 // then we run each file individually through the validation checks, and at the end process … … 7 8 $user_info = wp_get_current_user(); 8 9 $user_name = $user_info->user_login; 9 if($array['gal_id'] !="0") { // checks if a GID is passed through short code, if it is we change the 10 // destination to be the relevant gallery info based on the GID and NGG's gallery. 11 $uploaded_directory = $options['Nextgen_full_directory'].$array['gal_info'][0]->slug."/"; 12 } else { 13 $uploaded_directory = $options['Upload_full_directory']; 14 } 10 11 15 12 foreach($temp_files_list as $file) { 13 $uploaded_directory = $stored_info['uploaded_directory']; 16 14 $errors = null; // we have to clear this array every loop because we reuse it. 17 15 $file['uploader_name']= $user_name; // don't need to filter this, because it comes right from a wp function. … … 44 42 $file['name'] = preg_replace("/\\.[^.\\s]{3,4}$/", "", $file['name']).".".$mime_info['ext']; 45 43 $file['status']="successfully uploaded"; 46 47 if($array['gal_id'] !="0") { //again based on shortcode passed, handles things a bit different 48 // because we are using gallery info to store file instead of throwing it in our own directory. 49 $file['url'] = $options['Nextgen_url_path'].$array['gal_info'][0]->slug; 50 $file['stored']=$options['Nextgen_full_directory'].$array['gal_info'][0]->slug; 51 } else { 52 $file['stored']=$options['Upload_full_directory']; 53 $file['url'] = ngg_pup_get_temporary_upload_url($options['Upload_directory']); 54 } 44 $file['url'] = $stored_info['url']; 45 $file['stored'] = $stored_info['stored']; 55 46 $slug = explode(".", $file['name']); 56 47 $file['dimensions'] = array( … … 64 55 ); 65 56 $final_list[]=$file; 66 67 if($array['gal_id'] !="0") {68 // we build an object, because that's what ngg_pup_add_to_ngg_db($newfile) expects.69 70 $newfile = (object) array(71 dimensions=>$file['dimensions'],72 f_gid=>$array['gal_id'],73 file_name=>$file['name'],74 upload_date=>$datenow,75 meta_data=>null);76 $newfile->meta_data = ngg_pup_build_meta_data($newfile, null);77 78 ngg_pup_save_the_files(array(79 source=>$file['tmp_name'],80 dest=>$uploaded_directory,81 file=>$file['name']82 )); //save the file in the upload directory. Also adds83 84 ngg_pup_add_to_ngg_db($newfile); // save it to the ngg db.85 86 ngg_pup_create_thumb( //builds our thumbnails.87 array(name => $newfile->file_name, dir =>$uploaded_directory),88 array(89 max_width=> 250,90 max_height=> 250,91 quality=>85,92 target_name=> "thumbs_".preg_replace("/\\.[^.\\s]{3,4}$/", "", $newfile->file_name),93 target_dir=> $uploaded_directory."thumbs/" //ngg gallery stores its thumbnails in a subdirectory of the gallery dir.94 ));95 96 97 } else { // if we're not storing it in a gallery, we throw it in the upload queue.98 99 ngg_pup_save_the_files(array(100 source=>$file['tmp_name'],101 dest=>$uploaded_directory,102 file=>$file['name']103 )); //save the file in the upload directory.104 105 if ($options['enable_moderation_queue'] =="checked") { //if not, we dont update queue because we're not using it.106 update_db_with_file($file);107 }108 109 }110 111 57 } else { 112 58 // if the file fails one of our checks, we add it to the list, but we set a "failed" status and add the errors … … 244 190 return $files_array; 245 191 } ?> 246 <?php function ngg_pup_moderate_inital_checks ( ) {192 <?php function ngg_pup_moderate_inital_checks ($options) { 247 193 $token_id = stripslashes( $_POST['token'] ); 248 194 if (get_transient( 'token_' . $token_id )) { // checks for and kills token if it's been used. 249 195 delete_transient( 'token_' . $token_id ); 250 $check_sum = "show_results"; 196 if ($_POST['batch_radio'][0]=="3") { // instead of proccessing results, we make a new gallery 197 $results = pup_create_gallery ($options); ?> 198 <span class="ngg_pup_lockout_message"> 199 <?php echo $results['error_msg']; ?> 200 </span> 201 <?php 202 } else { 203 $files_array = ngg_pup_sanitize_and_build_results();//sanitize 204 $results = ngg_pup_process_results($files_array); // process and siaply 205 } 251 206 } else { 252 207 $token_id = md5( uniqid( "", true ) ); //generates a new MD5 token to prevent form resubmission. we'll put this in a hidden feld in the upload form 253 208 set_transient( 'token_' . $token_id, 'safe_to_delete', 60*10 ); // Sets it to expire in 10 minute. 254 } 255 if ($check_sum == "show_results") { // then we're showing the results screen. 256 $files_array = ngg_pup_sanitize_and_build_results();//sanitize 257 $results = ngg_pup_process_results($files_array); // process and siaply 258 } else { 259 ngg_pup_create_mod_page($token_id); // builds a moderation session page. 260 } 209 ngg_pup_create_mod_page($token_id, $options); // builds a moderation session page. 210 } 211 261 212 } ?> 262 213 <?php function ngg_pup_check_transfer($file, $destination) { //double checks to make sure we have a file to move, and it doesnt already exist in the destination. … … 273 224 $b = "error"; 274 225 } 275 return array($a, $b); 226 if (file_exists($destination->path."/")) { 227 $c = "yes proceed"; 228 } else { 229 $c = "error"; 230 } 231 return array($a, $b, $c); 276 232 }?> 277 233 <?php function ngg_pup_sanitize_tags ($tag_string) { // sanitizes and builds tag list; … … 301 257 return $uploader_ip; 302 258 }?> 259 <?php function ngg_pup_sanitize_gal_name ($name) { 260 $name = mysql_real_escape_string($name); 261 $name = preg_replace("/[^a-zA-Z0-9-_]+/", "", $name); 262 return $name; 263 }?> -
nextgen-public-image-uploader/trunk/css/nggpup.css
r767294 r775017 7 7 width:100%; 8 8 float:left; 9 9 } 10 11 .ngg_pup_moderate_bar_box_1{ 12 float:left; 13 width:15%; 14 } 15 .ngg_pup_moderate_bar_box_2 { 16 float:left; 17 width:30%; 18 } 19 20 .ngg_pup_moderate_bar_box_3 { 21 float:left; 22 width:40%; 23 } 24 .ngg_pup_moderate_bar_box7 { 25 width:10%; 26 float:right; 10 27 } 11 28 .ngg_pup_upload_wrapper { … … 15 32 margin-bottom:40px; 16 33 } 17 .ngg_pup_pulldown { 18 width:60%; 34 .batch_ngg_pup_pulldown { 35 width:auto; 36 } 37 .ngg_pup_pulldown{ 38 width:80%; 19 39 } 20 40 … … 62 82 width:100%; 63 83 float:left; 84 line-height:1em; 64 85 } 65 86 .NggPup_Floated_text_top, .NggPup_Floated_text_bot { … … 69 90 -webkit-hyphens:auto; 70 91 -o-hyphens:auto; 71 hyphens:auto; 92 hyphens:auto; 93 padding:0 0 3px; 94 font-size:1em; 72 95 top: 0px; 73 96 left: 0px; 74 color: white;97 color: #fff; 75 98 background: rgba(0,0,0,0.7); 76 99 width: 100%; … … 92 115 display: inline-block; 93 116 margin:4px auto 4px auto; 94 min-width:180px; 117 95 118 text-align:left; 96 119 border:1px solid #859399; … … 174 197 175 198 } 176 .ngg_pup_submit_button { 177 float:right; 178 } 179 .ngg_pup_moderate_left_bar_1 { 199 .ngg_pup_moderate_bar_box7 input[type="submit"] { 200 height: auto; 201 padding: 0% 5% 0% 5%; 202 font-size: 1em; 203 float: right; 204 border-radius: 6px; 205 border: 2px solid #C4C4C4; 206 } 207 208 .ngg_pup_moderate_bar_text_box { 209 float:left; 180 210 width:130px; 181 float:left; 182 } 183 .ngg_pup_moderate_left_bar_2 { 184 width:224px; 185 float:left; 186 } 187 .ngg_pup_moderate_bar_text_box { 188 float:left; 189 width:160px; 190 padding:3px; 191 height:2em; 211 padding:2px; 212 height:1.5em; 192 213 border:1px solid #859399; 193 margin: 6px 5% 6px 0;214 margin:2px; 194 215 color:#000000; 195 216 } 196 .ngg_pup_moderate_left_bar { 197 float:left; 198 width:60%; 199 margin:6px; 200 201 } 202 .ngg_pup_moderate_right_bar { 203 float:right; 204 width:30%; 205 206 } 217 207 218 @media (min-width : 320px ) { 208 219 .moderate_pic_wrap { 209 220 width:100%; 210 221 } 211 .ngg_pup_moderate_left_bar, .ngg_pup_moderate_right_bar { 212 width:100%; 213 } 214 .ngg_pup_moderate_left_bar_2 { 215 float:left; 216 } 217 .NggPup_upload_wrapper { 218 width:47%; 219 } 220 } 221 222 @media (min-width : 480px ) { 222 .NggPup_upload_wrapper { 223 width:100%; 224 } 225 .ngg_pup_moderate_bar_box_1, .ngg_pup_moderate_bar_box_2, .ngg_pup_moderate_bar_box_3{ 226 width:48%; 227 } 228 } 229 230 @media (min-width : 400px ) { 223 231 .moderate_pic_wrap { 224 232 width:49%; 225 233 } 226 .ngg_pup_moderate_left_bar, .ngg_pup_moderate_right_bar { 227 width:100%; 228 } 229 .ngg_pup_moderate_left_bar_2 { 230 float:right; 231 } 232 .NggPup_upload_wrapper { 234 235 .NggPup_upload_wrapper { 236 width:49%; 237 } 238 } 239 240 @media (min-width : 550px ) { 241 .moderate_pic_wrap { 233 242 width:32%; 234 243 } 235 } 236 237 @media (min-width : 640px ) { 238 .moderate_pic_wrap { 244 .NggPup_upload_wrapper { 239 245 width:32%; 240 246 } 241 .ngg_pup_moderate_left_bar, .ngg_pup_moderate_right_bar { 242 width:100%; 243 } 244 .NggPup_upload_wrapper { 245 width:32%; 246 } 247 } 248 249 @media (min-width : 820px ) { 250 .moderate_pic_wrap { 251 width:24%; 252 } 253 .ngg_pup_moderate_left_bar, .ngg_pup_moderate_right_bar { 254 width:100%; 255 } 256 .NggPup_upload_wrapper { 257 width:24%; 258 } 259 } 260 261 262 @media (min-width : 850px ) { 263 .ngg_pup_moderate_left_bar { 264 width:50%; 265 } 266 .ngg_pup_moderate_right_bar { 247 .ngg_pup_moderate_bar_box_1, .ngg_pup_moderate_bar_box_2, .ngg_pup_moderate_bar_box_3 { 267 248 width:40%; 268 249 } 269 .NggPup_upload_wrapper { 270 width:24%; 271 } 272 } 250 } 251 252 @media (min-width : 730px ) { 253 .moderate_pic_wrap { 254 width:24%; 255 } 256 .NggPup_upload_wrapper { 257 width:24%; 258 } 259 .ngg_pup_moderate_bar_box_1{ 260 width:15%; 261 } 262 263 .ngg_pup_moderate_bar_box_2 { 264 width:32%; 265 } 266 267 .ngg_pup_moderate_bar_box_3 { 268 width:38%; 269 } 270 271 } 272 273 -
nextgen-public-image-uploader/trunk/ngg_uploader.php
r767294 r775017 16 16 ?> 17 17 <?php register_activation_hook(__FILE__, 'ngg_Pup_plugin_first_run');?> 18 <?php add_action('ngg_render_template' , 'ngg_test' );//get rid of this, useless. ?> 18 19 <?php add_action('admin_head', 'ngg_Pup_admin_register_head');?> 20 <?php add_shortcode( "ngg_test" , "ngg_test" );//for the front end the shortcode is [ngg_public_uploader]?> 19 21 <?php add_shortcode( "ngg_public_uploader" , "ngg_public_uploader" );//for the front end the shortcode is [ngg_public_uploader]?> 20 22 <?php add_shortcode( "NGG_pup_Moderation" , "NGG_pup_Moderation" );//for the front end the shortcode is [ngg_public_uploader]?> … … 30 32 // The great thing about doing it this way, is it's virtually impossible for someone to fake this in an attempt to mass resubmit the form. 31 33 // this also does not need to be sanitized, as WP does it behidn the scenes. 32 $token_id = stripslashes( $_POST['token'] ); 34 $token_id = htmlspecialchars( $_POST['token'] ); 35 $token_id = mysql_real_escape_string($token_id); 33 36 if (get_transient( 'token_' . $token_id )) { // checks for and kills token if it's been used. 34 37 delete_transient( 'token_' . $token_id ); … … 40 43 41 44 if(isset($_FILES['imgs']['tmp_name']) && ($check_sum == "show_files")) { //if the user has uploaded files 42 $array = ngg_pup_direct_to_gallery_precheck($shortcodes); // does a check to see if single gallery upload used, and if gallery exists. 43 $final_list = ngg_pup_validate_files($options, $array);//first we check if the files pass validation 45 if (!empty($shortcodes)&& (is_numeric($shortcodes['gid']))) { 46 $array = ngg_pup_direct_to_gallery_precheck($shortcodes); // does a check to see if single gallery upload used, and if gallery exists. 47 } 48 $stored_info = ngg_pup_pre_validation($shortcodes, $options, $array); 49 $final_list = ngg_pup_validate_files($options, $stored_info);//first we check if the files pass validation 50 ngg_pup_post_validation($final_list, $array, $options); 44 51 ngg_pup_send_email($final_list,$options); // sends email notification if set in options. 45 52 ngg_pup_upload_results($final_list, $gallery_list, $options); //then we display the results screen. … … 47 54 ngg_pup_File_upload_Menu($options, $token_id); //if the user hasn't uploaded yet, they see the upload screen first. 48 55 } 56 49 57 } else { ?> 50 58 <span class="ngg_pup_lockout_message"> … … 53 61 <?php } 54 62 }?> 55 <?php function ngg_pup_upload_results($final_list, $gallery_list, $options) { //this is the function that creates the screen the user sees after uploading files 63 <?php function ngg_pup_pre_validation($shortcodes, $options, $array){ //pre-validation handler. 64 if(!empty($array) && ($array['gal_id'] !="0")) { // checks if a GID is passed through short code, if it is we change the 65 // destination to be the relevant gallery info based on the GID and NGG's gallery. 66 $stored_info['uploaded_directory'] = $options['Nextgen_full_directory'].$array['gal_info'][0]->slug."/"; 67 $stored_info['url'] = $options['Nextgen_url_path'].$array['gal_info'][0]->slug; 68 $stored_info['stored']=$options['Nextgen_full_directory'].$array['gal_info'][0]->slug."/"; 69 return $stored_info; 70 } else { 71 $stored_info['uploaded_directory'] = $options['Upload_full_directory']; 72 $stored_info['url'] = ngg_pup_get_temporary_upload_url($options['Upload_directory']); 73 $stored_info['stored']=$options['Upload_full_directory']; 74 return $stored_info; 75 } 76 }?> 77 <?php function ngg_pup_post_validation($final_list, $array, $options){ 78 foreach ($final_list as $file) { 79 if ($file['error']=="0") { 80 ngg_pup_save_the_files(array( 81 source=>$file['tmp_name'], 82 dest=>$file['stored'], 83 file=>$file['name'] 84 )); //first we save the uploaded file 85 86 if(!empty($array) && ($array['gal_id'] !="0")) { // we're processing it as a gallery upload. 87 // we build an object, because that's what ngg_pup_add_to_ngg_db($newfile) expects. 88 $newfile = (object) array( 89 dimensions=>$file['dimensions'], 90 f_gid=>$array['gal_id'], 91 file_name=>$file['name'], 92 upload_date=>$datenow, 93 meta_data=>null); 94 $newfile->meta_data = ngg_pup_build_meta_data($newfile, null); 95 96 ngg_pup_create_thumb( //builds our thumbnails. 97 array(name => $newfile->file_name, dir =>$file['stored']), 98 array( 99 max_width=> 250, 100 max_height=> 250, 101 quality=>85, 102 target_name=> "thumbs_".preg_replace("/\\.[^.\\s]{3,4}$/", "", $newfile->file_name), 103 target_dir=> $file['stored']."thumbs/" //ngg gallery stores its thumbnails in a subdirectory of the gallery dir. 104 )); 105 106 ngg_pup_add_to_ngg_db($newfile); // save it to the ngg db. 107 108 } else { // if we're not storing it in a gallery, we throw it in the upload queue. 109 110 if ($options['enable_moderation_queue'] =="checked") { //if not, we dont update queue because we're not using it. 111 update_db_with_file($file); 112 } 113 114 } 115 116 } 117 118 } 119 120 }?> 121 <?php function ngg_pup_upload_results($final_list) { //this is the function that creates the screen the user sees after uploading files 56 122 foreach($final_list as $file) { 57 123 if($file['status'] == "successfully uploaded") { //iterates the array and shows the results. … … 94 160 <?php echo $file['name'];?> 95 161 </div> 96 <div class="NggPup_Floated_text_bot" >162 <div class="NggPup_Floated_text_bot" <?php if($file['error_code'] == "1"){ echo "style='color:#BEFF18'";}?>> 97 163 <?php echo $file['status'];?> 98 164 </div> -
nextgen-public-image-uploader/trunk/readme.txt
r767294 r775017 5 5 Requires at least: Any 6 6 Tested up to: 3.6 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 32 32 33 33 E-mail notification. This plugin can also be set up to notify you when a user uploads images. 34 35 Create galleries. Yes, you can even make new galleries, right from the front-end. 34 36 35 37 For a working demo of the plugin in action, visit: http://www.demo.amazinglyamusing.com/moderation/ … … 92 94 == Changelog == 93 95 94 = 1.0 = 96 = 1.1 Wolowitz = 97 98 * Added the ability to create new galleries on the front end. Of course this can be configured 99 by role, or disabled entirely. 100 * Did some housekeeping, including extra error handling. Tried to make sure 101 almost all errors are handled by the plugin, so no PHP errors should ever be seen. 102 * Made the entire front-end nicer, including menu streamlining and other nice touches. 103 104 = 1.0 Cooper = 95 105 * First released version. 96 106 97 107 == Upgrade Notice == 108 109 = 1.1 Wolowitz = 110 111 * Added the ability to create new galleries on the front end. Of course this can be configured 112 by role, or disabled entirely. 113 * Did some housekeeping, including extra error handling. Tried to make sure 114 almost all errors are handled by the plugin, so no PHP errors should ever be seen. 115 * Made the entire front-end nicer, including menu streamlining and other nice touches. 98 116 99 117 = 1.0 =
Note: See TracChangeset
for help on using the changeset viewer.