Plugin Directory

Changeset 775017


Ignore:
Timestamp:
09/19/2013 01:44:12 AM (13 years ago)
Author:
lagdonkey
Message:

Version 1.1 Wolowitz

  • Added the ability to create new galleries on the front end. Of course this can be configured by role, or disabled entirely.
  • Did some housekeeping, including extra error handling. Tried to make sure

almost all errors are handled by the plugin, so no PHP errors should ever be seen.

  • Made the entire front-end nicer, including menu streamlining and other nice touches.


Location:
nextgen-public-image-uploader/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • nextgen-public-image-uploader/trunk/Includes/filefunc.php

    r767294 r775017  
    7171}?>
    7272<?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']))) {
    7473$gal = ngg_pup_get_gallery_list('where gid IN ('.$shortcodes['gid'].')');
    75 }
    7674if(!empty($gal)) {
    7775return array(gal_id=>$shortcodes['gid'], gal_info=>$gal);
     
    197195}
    198196}?>
     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();
     214if (($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 {
     217return 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%%'");
     222if (!empty($gal_check)) {
     223foreach ($gal_check as $gal) {
     224$titles[]=$gal->title;
     225$names[]=$gal->name;
     226$slugs[]=$gal->slug;
     227}
     228$a=1;
     229while ($a <= 11) { //tries to find a clean name we can use.
     230if (!in_array($name."-".$a, $titles)&&(!in_array($name."-".$a, $names)) && (!in_array($name."-".$a, $slugs))) {
     231$name=$name."-".$a;
     232break;
     233}
     234$a++;   
     235}   
     236if ($a==11) {
     237return array('error_msg'=>"Could not create new gallery, because there are already galleries with that name.
     238Please 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";
     244if ((!is_dir($path)) && (!file_exists($path)) && (!is_dir($path)) && (!file_exists($path)))  {
     245if(!mkdir($path, 0777, true)) {
     246return array('error_msg'=>"Could not create gallery directory.", 'code'=>1);
     247}
     248if(!mkdir($thumbs_path, 0777, true)) {
     249return array('error_msg'=>"Could not create thumbnail directory.", 'code'=>1);
     250}   
     251} else {
     252return 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   );
     266ngg_pup_make_new_gallery($gal_info);
     267return array('error_msg'=>"Gallery $name created successfully", 'code'=>0, 'gal_info'=>$gal_info);
     268} ?>
  • nextgen-public-image-uploader/trunk/Includes/makethumb.php

    r767294 r775017  
    22// this expects $file to include:
    33// dir - where the $file is located
    4 // name - name name with extension
     4// name - file name with extension
    55$file_info = ngg_pup_get_true_extension($file['dir'].$file['name']);
    66$file['ext'] = $file_info['ext'];
     7
    78if (file_exists($args['target_dir'].$args['target_name'].$file['ext'])) { //checks to make sure thumb file doesn't exist.
    8 return "file already exists.";
     9return array(
     10msg=> "thumbs_$file[name] could not be created, file already exists.",
     11code=> 1);
    912}
     13
    1014if (!file_exists($file['dir'].$file['name'])) { //checks to make sure source image exists.
    11 return "source image does not exist.";
     15return array(
     16msg=> "thumbs_$file[name] could not be created source image does not exist.",
     17code=> 1); 
    1218}
     19
     20if (!file_exists($args['target_dir'])) {
     21return array(
     22msg=> "thumbs_$file[name] could not be created, destination directory does not exist or is not writeable.",
     23code=> 1); 
     24}
     25
    1326 if($file['ext'] == 'gif'){
    1427  $new_file = imagecreatefromgif($file['dir'].$file['name']);
     
    1831  $new_file = imagecreatefrompng($file['dir'].$file['name']);
    1932 }else{
    20   return false;
     33  return array(
     34msg=> "thumbs_$file[name] could not be created, unknown file extension $file[ext].",
     35code=> 1);
    2136 }
    2237 
     
    4863 imagedestroy($new_file);       
    4964 imagedestroy($dst_image);
    50  return array("File successfully created");
     65return array(
     66msg=> "thumbs_$file[name] thumbnail successfully created",
     67code=> 0);
     68
     69 
    5170} ?>
    5271<?php function thumbcreatefrombmp( $filename )
     
    92111        }
    93112    }
    94     return $image;
     113    return "Thumbnail created successfully.";
    95114}?>
  • nextgen-public-image-uploader/trunk/Includes/moderation.php

    r767294 r775017  
    88<?php } else {
    99if ($options['enable_moderation_queue'] =="checked") {
    10 ngg_pup_moderate_inital_checks (); ?>   
     10ngg_pup_moderate_inital_checks ($options); ?>   
    1111<?php } else { ?>
    1212<span class="ngg_pup_lockout_message">
     
    1717} ?>
    1818<?php function ngg_pup_process_results($files_array) {
     19$options = get_option('NGG_User_upload_option_array');     
    1920foreach ($files_array[0] as $file) {
    2021switch ($file->f_radio) { //checks what status of radio button is, either Batch process, move or delete.
     
    2324// all files flagged under "batch process" are reflagged based on what the batch proccess command was ie: delete or move/leave in queue.
    2425// 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);
     26ngg_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));
    2632break;
    2733case 1: //move
    2834if ($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);
     35ngg_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));
    3041} else {
    3142ngg_pup_moderate_process_move($file, $files_array);
     
    3344break;
    3445case 2: //delete
    35 ngg_pup_moderate_result_display ($file, "$file->file_name was successfully deleted.", 0);
     46ngg_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   
    3653if (file_exists($file->file_path."/".$file->file_name)) { //else it's already gone for some reason.
    3754unlink($file->file_path.DIRECTORY_SEPARATOR.$file->file_name);
     
    3956ngg_pup_remove_from_db ($file);
    4057break;
     58
     59
     60
    4161}
    4262}
    4363}?>
    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;
    6567if (count($queue)==0) { ?>
    6668<span class="ngg_pup_lockout_message">
     
    7476$cnt = 0; //used to make our forms. This makes each form have it's own identifier, to work
    7577// in conjuction with what we'll do with the files. ?>
    76 <span class="ngg_pup_upload_wrapper">
    7778<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?>">
    7980<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" />
    8383<label for="batch_processed1">
    8484Delete Files
    8585</label>
    8686</div>
    87 <div class="ngg_pup_moderate_left_bar_2">
     87<div class="ngg_pup_moderate_bar_box_2">
    8888<input type="radio" name="batch_radio[]" class="ngg_pup_radio" checked="checked" id="batch_processed2" name="batch_radio[]" value="1" />
    8989<label for="batch_processed2">
     
    9292</label>
    9393</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;">
     99Create 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 } ?>
    97105<?php //currently disabled.
    98106// until I can figure out tagging.
    99107//<input type="text" name="batch_tags" class="ngg_pup_moderate_bar_text_box" placeholder="Comma seperated tags">
    100108?>
    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
    104114<div class="ngg_pup_moderate_wrapper">
    105115<?php foreach ($queue as $file) {
     
    147157</div>
    148158<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 //
    150160//<input type="text" name="tags[<?php echo $cnt;]" class="ngg_pup_text_box" placeholder="Comma seperated tags list">
    151161?>
     
    160170<?php } ?>
    161171<?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">
    163173<selected><option value="00">Leave in queue.</option></selected>
    164174<?php foreach ($gallery_list as $gall_list) { // starts loop for each gallery ?>
     
    183193$errors = ngg_pup_check_transfer($file, $gal_info); //checks if sources exists, and makes sure target doesnt. 
    184194if (!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.
    186196array(name => $file->file_name, dir =>$file->file_path),
    187197array(
     
    193203));
    194204$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
     206ngg_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));
    196212ngg_pup_move_file ($file, $gal_info);
    197213ngg_pup_add_to_ngg_db($file); //adds to NGG_Gallery DB.
     
    199215} else {
    200216if ($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);
     217ngg_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));   
    202223}
    203224if ($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 } ?>
     225ngg_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}
     232if ($errors[2] == "error") {
     233ngg_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  
    110110            'setting_section_id'           
    111111        );
     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        );
    112119    }
    113120   
     
    144151           
    145152            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               
    147159                        }
    148160                     
     
    152164            $input['email_notification_on_upload'] = $this->check_form_box($input['email_notification_on_upload']);
    153165            $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']);
    154167           
    155168            global $wp_roles;
    156169            $roles = $wp_roles->get_names();
    157170            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           
    159182            if($input['Limit_Upload_by_user_role'] !="checked") { //if enabled, disables uploads, except for admin
    160183            $input[$role."_can_upload"] = "";
     
    177200            $allowed_roles_upload[]=$role;
    178201            }
    179                        
     202                                           
    180203            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.
    181204            $allowed_roles_moderate[]=$role;
     
    186209            $input['allowed_roles_upload'] = $allowed_roles_upload; //updates option array after loop
    187210            $input['allowed_roles_moderate'] = $allowed_roles_moderate; //updates option array after loop
    188            
     211            $input['allowed_roles_create_gal'] = $allowed_roles_create_gal;
    189212            foreach ($extensions as $ext) {
    190213            $input[$ext."_allowed"] = $this->check_form_box($input[$ext."_allowed"]);
     
    362385<?php } 
    363386
     387public function settings8(){ //gallery creation setting.?>
     388<?php $options = $this->getoptions();?>
     389<?php if ($options['enable_moderation_queue'] =="checked") {
     390} else {
     391return;   
     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']?>/>
     395Enabling 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
    364414}
    365415
  • 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
    23// First we get all the files, and set them in an easy to manage array //
    34// then we run each file individually through the validation checks, and at the end process
     
    78$user_info = wp_get_current_user();
    89$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
    1512foreach($temp_files_list as $file) {
     13$uploaded_directory = $stored_info['uploaded_directory'];   
    1614$errors = null; // we have to clear this array every loop because we reuse it.
    1715$file['uploader_name']= $user_name; // don't need to filter this, because it comes right from a wp function.
     
    4442$file['name'] = preg_replace("/\\.[^.\\s]{3,4}$/", "", $file['name']).".".$mime_info['ext'];
    4543$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'];
    5546$slug = explode(".", $file['name']);
    5647$file['dimensions'] = array(
     
    6455);
    6556$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 adds
    83 
    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 
    11157} else {
    11258// if the file fails one of our checks, we add it to the list, but we set a "failed" status and add the errors
     
    244190return $files_array;
    245191} ?>
    246 <?php function ngg_pup_moderate_inital_checks () {
     192<?php function ngg_pup_moderate_inital_checks ($options) {
    247193$token_id = stripslashes( $_POST['token'] );
    248194if (get_transient( 'token_' . $token_id )) { // checks for and kills token if it's been used.
    249195delete_transient( 'token_' . $token_id );
    250 $check_sum = "show_results";
     196if ($_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}
    251206} else {
    252207$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
    253208set_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 }
     209ngg_pup_create_mod_page($token_id, $options); // builds a moderation session page.
     210}
     211
    261212} ?>
    262213<?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.
     
    273224$b = "error";
    274225}
    275 return array($a, $b);
     226if  (file_exists($destination->path."/")) {
     227$c = "yes proceed";
     228} else {
     229$c = "error";
     230}
     231return array($a, $b, $c);
    276232}?>
    277233<?php function ngg_pup_sanitize_tags ($tag_string) { // sanitizes and builds tag list;
     
    301257return $uploader_ip;
    302258}?>
     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);
     262return $name;
     263}?>
  • nextgen-public-image-uploader/trunk/css/nggpup.css

    r767294 r775017  
    77width:100%;
    88float:left;
    9 
     9}
     10
     11.ngg_pup_moderate_bar_box_1{
     12float:left;
     13width:15%; 
     14}
     15.ngg_pup_moderate_bar_box_2 {
     16float:left;
     17width:30%; 
     18}
     19
     20.ngg_pup_moderate_bar_box_3 {
     21float:left;
     22width:40%; 
     23}
     24.ngg_pup_moderate_bar_box7 {
     25width:10%;
     26float:right;   
    1027}
    1128.ngg_pup_upload_wrapper {
     
    1532margin-bottom:40px;
    1633}   
    17 .ngg_pup_pulldown {
    18 width:60%;
     34.batch_ngg_pup_pulldown {
     35width:auto;
     36}
     37.ngg_pup_pulldown{
     38width:80%; 
    1939}
    2040
     
    6282width:100%;
    6383float:left;
     84line-height:1em;
    6485}
    6586.NggPup_Floated_text_top, .NggPup_Floated_text_bot {
     
    6990-webkit-hyphens:auto;
    7091-o-hyphens:auto;
    71 hyphens:auto;     
     92hyphens:auto; 
     93padding:0 0 3px;   
     94font-size:1em;
    7295top: 0px;
    7396left: 0px;
    74 color: white;
     97color: #fff;
    7598background: rgba(0,0,0,0.7);
    7699width: 100%;
     
    92115display: inline-block;
    93116margin:4px auto 4px auto;
    94 min-width:180px;
     117
    95118text-align:left;
    96119border:1px solid #859399;
     
    174197
    175198}
    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"] {
     200height: auto;
     201padding: 0% 5% 0% 5%;
     202font-size: 1em;
     203float: right;
     204border-radius: 6px;
     205border: 2px solid #C4C4C4;
     206}
     207
     208.ngg_pup_moderate_bar_text_box {
     209float:left;
    180210width: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;
     211padding:2px;
     212height:1.5em;
    192213border:1px solid #859399;
    193 margin:6px 5% 6px 0;
     214margin:2px;
    194215color:#000000;
    195216}
    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
    207218@media (min-width : 320px ) {
    208219.moderate_pic_wrap {
    209220width:100%;
    210221}
    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 {
     223width:100%;
     224}
     225.ngg_pup_moderate_bar_box_1, .ngg_pup_moderate_bar_box_2, .ngg_pup_moderate_bar_box_3{
     226width:48%; 
     227}
     228}
     229
     230@media (min-width : 400px ) {
    223231.moderate_pic_wrap {
    224232width:49%;
    225233}
    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 {
     236width:49%;
     237}
     238}
     239
     240@media (min-width : 550px ) {
     241.moderate_pic_wrap {
    233242width:32%;
    234243}
    235 }
    236 
    237 @media (min-width : 640px ) {
    238 .moderate_pic_wrap {
     244.NggPup_upload_wrapper {
    239245width:32%;
    240246}
    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 {
    267248width:40%;
    268249}
    269 .NggPup_upload_wrapper {
    270 width:24%;
    271 }
    272 }
     250}
     251
     252@media (min-width : 730px ) {
     253.moderate_pic_wrap {
     254width:24%;
     255}
     256.NggPup_upload_wrapper {
     257width:24%;
     258}
     259.ngg_pup_moderate_bar_box_1{
     260width:15%; 
     261}
     262
     263.ngg_pup_moderate_bar_box_2 {
     264width:32%; 
     265}
     266
     267.ngg_pup_moderate_bar_box_3 {
     268width:38%;
     269}
     270
     271}
     272
     273
  • nextgen-public-image-uploader/trunk/ngg_uploader.php

    r767294 r775017  
    1616?>
    1717<?php register_activation_hook(__FILE__, 'ngg_Pup_plugin_first_run');?>
     18<?php add_action('ngg_render_template' , 'ngg_test' );//get rid of this, useless. ?>
    1819<?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]?>
    1921<?php add_shortcode( "ngg_public_uploader" , "ngg_public_uploader" );//for the front end the shortcode is [ngg_public_uploader]?>
    2022<?php add_shortcode( "NGG_pup_Moderation" , "NGG_pup_Moderation" );//for the front end the shortcode is [ngg_public_uploader]?>
     
    3032// 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.
    3133// 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);
    3336if (get_transient( 'token_' . $token_id )) { // checks for and kills token if it's been used.
    3437delete_transient( 'token_' . $token_id );
     
    4043
    4144if(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
     45if (!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
     50ngg_pup_post_validation($final_list, $array, $options);
    4451ngg_pup_send_email($final_list,$options); // sends email notification if set in options.
    4552ngg_pup_upload_results($final_list, $gallery_list, $options); //then we display the results screen.
     
    4754ngg_pup_File_upload_Menu($options, $token_id); //if the user hasn't uploaded yet, they see the upload screen first.
    4855}
     56
    4957} else { ?>
    5058<span class="ngg_pup_lockout_message">
     
    5361<?php } 
    5462}?>
    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.
     64if(!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."/";
     69return $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'];
     74return $stored_info;
     75}
     76}?>
     77<?php function ngg_pup_post_validation($final_list, $array, $options){
     78foreach ($final_list as $file) {
     79if ($file['error']=="0") {
     80ngg_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
     86if(!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
     96ngg_pup_create_thumb( //builds our thumbnails.
     97array(name => $newfile->file_name, dir =>$file['stored']),
     98array(
     99max_width=> 250,
     100max_height=> 250,
     101quality=>85,
     102target_name=> "thumbs_".preg_replace("/\\.[^.\\s]{3,4}$/", "", $newfile->file_name),
     103target_dir=> $file['stored']."thumbs/" //ngg gallery stores its thumbnails in a subdirectory of the gallery dir.
     104));
     105   
     106ngg_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
     110if ($options['enable_moderation_queue'] =="checked") { //if not, we dont update queue because we're not using it.
     111update_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
    56122foreach($final_list as $file) {
    57123if($file['status'] == "successfully uploaded") { //iterates the array and shows the results.
     
    94160<?php echo $file['name'];?>
    95161</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'";}?>>
    97163<?php echo $file['status'];?>
    98164</div>
  • nextgen-public-image-uploader/trunk/readme.txt

    r767294 r775017  
    55Requires at least: Any
    66Tested up to: 3.6
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3232
    3333E-mail notification. This plugin can also be set up to notify you when a user uploads images.
     34
     35Create galleries. Yes, you can even make new galleries, right from the front-end.
    3436
    3537For a working demo of the plugin in action, visit: http://www.demo.amazinglyamusing.com/moderation/
     
    9294== Changelog ==
    9395
    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
     101almost 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 =
    95105* First released version.
    96106
    97107== 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
     114almost 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.
    98116
    99117= 1.0 =
Note: See TracChangeset for help on using the changeset viewer.