4images Modifications / Modifikationen > Mods & Plugins (Releases & Support)

[Mod] Multiupload with jQuery

(1/21) > >>

Rembrandt:
Hi!

Here is the new Multiupload,  works with jQuery and Uploadify.
About Style and all others, can you read here.

 - With this multi-upload you can upload more than one hundred images simultaneously.
 - Large Images are automatically scaled. (Update 01.07.2013)
 - Automatically upload in temp folder or direct,for each Categorie.
 - When uploading Image Preview.
 - Write Description and Keywords for all Images.
 - Select Category for each image.


1.) create a new folder in your root and call it "js", and copy all files, from Attachment (multi.zip), in the new Folder.
Copy all Images,  form (multi.zip), in your template/images folder.

2.) search in includes/upload_definitions.php:

$mime_type_match['jpg'] = array("image/jpg", "image/jpeg", "image/pjpeg");
$mime_type_match['jpeg'] = array("image/jpg", "image/jpeg", "image/pjpeg");

$mime_type_match['gif'] = array("image/gif");

$mime_type_match['png'] = array("image/png", "image/x-png");

and replace:

$mime_type_match['jpg'] = array("image/jpg", "image/jpeg", "image/pjpeg", "application/octet-stream");
$mime_type_match['jpeg'] = array("image/jpg", "image/jpeg", "image/pjpeg","application/octet-stream");

$mime_type_match['gif'] = array("image/gif","application/octet-stream");

$mime_type_match['png'] = array("image/png", "image/x-png","application/octet-stream");


3.) search in your lang/main.php "?>" and insert above:
(deutsch)

 $lang['image'] = "Bild";
 $lang['queueSizeLimit'] = " Bilder können gleichzeitig hochgeladen werden.";
 $lang['for_all'] = "Beschreibung und Schlüsselwörter für alle Bilder:";

(english)

 $lang['image'] = "Image";
 $lang['queueSizeLimit'] = " Images can be uploaded at the same time.";
 $lang['for_all'] = "Description and Keywords for all Images:"; 


4.) search in your Template/header.html "</head>" and insert above:

<script type="text/javascript" src="./js/multiupload/jquery-1.7.2.min.js"></script>


5.) create a new file, call it "member_multi_upload.html" and copy it in your Template Folder.

--- Code: ---<script type="text/javascript" src="./js/multiupload/jquery.uploadify-3.1.min.js"></script>
  <script type="text/javascript" >
  $(function() {        
    $('#file_upload').uploadify({
      formData : {
        '__csrf' : '{token}',
        'user_id' : '{user_id}',
        'sessionid': '{session_id}',
        'session_user_id' :'{session_user_id}'
      },
      'swf': './js/multiupload/uploadify.swf',
      'uploader' : 'member.php?action=multi_uploadimage',
      'fileObjName' : 'media_file',
      'queueSizeLimit' : '{queueSizeLimit}',
      'fileTypeExts' : '{allowed_mediatypes_js}',
      'fileSizeLimit' : '{max_media_size_js}',
      'height'        : 20,
      'width'         : 100,
      'buttonText': 'Select',
      'progressData': 'speed',
      'onQueueComplete' : function(queueData) {
        location.href="./member.php?action=multi_upload&cat_id={cat_id}";
      }
    });
  });
  </script>
  <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <tr>
      <td valign="top" class="head1">
        <table width="100%" border="0" cellpadding="4" cellspacing="0">
          <tr>
            <td colspan="2" valign="top" class="head1">{lang_user_upload}</td>
          </tr>
          <tr>
            <td class="row2" valign="top">
            <b>{lang_media_file}</b><br>
            <span class="smalltext">
            {lang_max_filesize}<b>{max_media_filsize}</b><br>
            {lang_max_imagewidth}<b>{max_media_imagewidth}</b><br>
            {lang_max_imageheight}<b>{max_media_imageheight}</b><br>
            </span>
            </td>
            <td valign="top" class="row2" colspan="2"><b>Upload:</b><br>
            <input class="buttonClass" type="file" name="media_file" id="file_upload">
            <br>
            <span class="smalltext"><b>{queueSizeLimit}</b>{lang_queueSizeLimit}<br><b>{lang_allowed_file_types}</b> {allowed_media_types}</span>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

--- End code ---

6.) create a new file, call it "member_multi_uploadform.html" and copy it in your Template Folder.

--- Code: ---  <script type="text/javascript">
    function CheckAll() {
      for (var i=0;i<document.multi_uploadform.elements.length;i++) {
        var e = document.multi_uploadform.elements[i];
        if ((e.name != 'allbox') && (e.type=='checkbox')) {
          e.checked = document.multi_uploadform.allbox.checked;
        }
      }
    }
  </script>
<form name="multi_uploadform" method="post" action="member.php" enctype="multipart/form-data" onsubmit="uploadbutton.disabled=true;">
<input type="hidden" name="action" value="multi_saveimages">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
  <tr>
    <td valign="top" class="head1">
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td class="head1"colspan="4"><input name="allbox" type="checkbox" checked="checked" onClick="CheckAll();"></td>
        </tr>
        <tr>
          <td>
          {uploadform_content}
          </td>
        </tr>
      </table>
      {if captcha_upload}
      <table width="100%" border="0" cellpadding="4" cellspacing="0">          
        <tr>
          <td class="row1" valign="top"><b>{lang_captcha}</b></td>
          <td class="row1" >
           <a href="javascript:new_captcha_image();"><img src="{url_captcha_image}" border="0" alt="" id="captcha_image" /></a> <br>
            <input type="text" name="captcha" size="30" value="" class="captchainput" id="captcha_input">
            <br>
            <table cellpadding="0" cellspacing="0" width="210">
              <tr>
                <td width="600">{lang_captcha_desc}</td>
               </tr>
            </table>
          </td>
        </tr>
      </table>
      {endif captcha_upload}
      </td>
    </tr>
  </table>
  <p align="center">
    <input type="hidden" name="cat_id" value="{cat_id}">
    <input type="submit" name="uploadbutton" value="{lang_submit}" class="button">
    <input type="reset" value="{lang_reset}" class="button">
  </p>
</form>

--- End code ---

7.) add in your Templates/style.css at the end of the file, a:

--- Code: ---.uploadify-button {
border: 1px solid #fcdc43;
background-color: #004c75;
  color: #fcdc43;
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  font-weight:bold;
text-align:center;
  padding:0;
  margin:0;
}

.uploadify:hover .uploadify-button {
  border:1px solid #fcdc43;
  background-color: #0f5475;
  color: red;
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  font-weight:bold;
  cursor:pointer;
}

.uploadify:active .uploadify-button {
border: 1px solid #fcdc43;
 }

.uploadify-queue {
margin-bottom: 1em;
}
.uploadify-queue-item {
background-color: #e1e1e1;
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  font-size: 11px;
margin-top: 5px;
max-width: 350px;
padding: 10px;
}
.uploadify-error {
background-color: #FDE5DD !important;
}
.uploadify-queue-item .cancel a {
background: url('images/uploadify-cancel.png') 0 0 no-repeat;
float: right;
height: 16px;
  width: 16px;
text-indent: -9999px;
}
.uploadify-queue-item.completed {
background-color: #f9f9f9;
  
}
.uploadify-progress {
background-color: #fcdc43;
margin-top: 10px;
width: 100%;
}
.uploadify-progress-bar {
background-color: #0099FF;
height: 3px;
width: 1px;
}
.uploadify-textarea{
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #0f5475;
  font-size: 11px;
  width: 280px;
  height:40px;
}

.uploadify-input{
  font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
  color: #0f5475;
  font-size: 11px;
  width: 190px;
}

--- End code ---

8.) search in root/categories.php:

$upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";

insert below:

  $multi_upload_url = "";
  $multi_upload_button = "<img src=\"".get_gallery_image("multiupload_off.gif")."\" border=\"0\" alt=\"\" />";
8.2) search:

$upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";

insert below:

  $multi_upload_url = $site_sess->url(ROOT_PATH."member.php?action=multi_upload&".URL_CAT_ID."=".$cat_id);
  $multi_upload_button = "<a href=\"".$multi_upload_url."\"><img src=\"".get_gallery_image("multiupload.gif")."\" border=\"0\" alt=\"\" /></a>";

8.3) search:

"upload_button" => $upload_button,

insert below:

  "multi_upload_url" => $multi_upload_url,
  "multi_upload_button" => $multi_upload_button,


9.) search in your template/categories.html

--- Code: ---<td align="right" valign="bottom">{upload_button}</td>

--- End code ---
replace:

--- Code: ---<td align="right" valign="bottom">{multi_upload_button}&nbsp;{upload_button}</td>

--- End code ---

10.) search in member.php:

if ($action == "emailuser") {

insert above:

//############################## Start Multiupload ###################################
if ($action == "multi_saveimages") {
  $txt_clickstream = "";
  if ($cat_id && isset($cat_cache[$cat_id])) {
    $txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  }
  $txt_clickstream .= $lang['user_upload'];

  $num_newimages = intval(trim($HTTP_POST_VARS['sum_images']));
  $captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";

  $error = array();

  for ($i = 1; $i <= $num_newimages; $i++) {
   
    $image_id = intval(trim($HTTP_POST_VARS['image_id_'.$i]));
    $addimage = (isset($HTTP_POST_VARS['addimage_'.$i]) && $HTTP_POST_VARS['addimage_'.$i] == 1) ? 1 : 0;
    $old_media_path = MEDIA_TEMP_PATH."/".un_htmlspecialchars(trim($HTTP_POST_VARS['image_media_file_'.$i]));
    $old_thumb_path = THUMB_TEMP_PATH."/".un_htmlspecialchars(trim($HTTP_POST_VARS['image_thumb_file_'.$i]));
    $image_description =  un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_description_'.$i])));
    $image_keywords =  un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_keywords_'.$i])));

    if ($addimage) {
      $count_add_image++;
      $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
      $cat_id = intval($HTTP_POST_VARS['cat_id_'.$i]);

      if ($image_name == "")  {
        $error['image_name_'.$i] = 1;
        $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['image_name']), $lang['field_required']);
        $msg .= (($msg != "") ? "<br />" : "").$lang['image']." ".$i." ".$field_error;
      }
      
      if ($cat_id == 0) {
        $error['cat_id'.$i] = 1;
        $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required']);
        $msg .= (($msg != "") ? "<br />" : "").$lang['image']." ".$i." ".$field_error;
      }
      
      if (!empty($additional_image_fields)) {
        foreach ($additional_image_fields as $key => $val) {
          if (isset($HTTP_POST_VARS[$key.'_'.$i]) && intval($val[2]) == 1 && trim($HTTP_POST_VARS[$key.'_'.$i]) == "") {
            $error[$key.'_'.$i] = 1;
            $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
            $msg .= (($msg != "") ? "<br />" : "").$lang['image']." ".$i." ".$field_error;
          }
        }
      }
    }
    else{
      $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
      $sql = "DELETE FROM ".IMAGES_TEMP_TABLE."
              WHERE image_id = $image_id
             ";
      $site_db->query($sql);
      @unlink($old_media_path);
      @unlink($old_thumb_path);
      $msg .=  "<br><b>".$i.".)</b>&nbsp;".$lang['image_delete_success'].":";
      $msg .= "&nbsp;<b>".format_text(stripslashes($image_name))."";
    }  
  }//end for
  
  if ($addimage && $captcha_enable_upload && !captcha_validate($captcha)) {
    $msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
    $error = 1;
  }

  if (!$error) {
    include(ROOT_PATH.'includes/upload.php');
    $save_all = intval(trim($HTTP_POST_VARS['save_all']));
    
    for ($i = 1; $i <= $num_newimages; $i++){
      $addimage = (isset($HTTP_POST_VARS['addimage_'.$i]) && $HTTP_POST_VARS['addimage_'.$i] == 1) ? 1 : 0;
      $save_all = intval(trim($HTTP_POST_VARS['save_all']));
      
      if ($addimage) {
        $cat_id = intval(trim($HTTP_POST_VARS['cat_id_'.$i]));
        $temp_image_id = intval(trim($HTTP_POST_VARS['image_id_'.$i]));
        $image_name = un_htmlspecialchars(trim($HTTP_POST_VARS['image_name_'.$i]));
        $image_media_file = un_htmlspecialchars(trim($HTTP_POST_VARS['image_media_file_'.$i]));
        $image_thumb_file = un_htmlspecialchars(trim($HTTP_POST_VARS['image_thumb_file_'.$i]));
        $old_media_path = MEDIA_TEMP_PATH."/".$image_media_file;
        $old_thumb_path = THUMB_TEMP_PATH."/".$image_thumb_file;
        $image_description = ($save_all) ? un_htmlspecialchars(trim($HTTP_POST_VARS['image_description_1'])) : un_htmlspecialchars(trim($HTTP_POST_VARS['image_description_'.$i]));
        $image_keywords = ($save_all) ?  un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords_1'])) :  un_htmlspecialchars(trim($HTTP_POST_VARS['image_keywords_'.$i]));
        $image_keywords = preg_replace("/[\n\r]/is", ",", $image_keywords);
        $image_keywords_arr = explode(',', $image_keywords);
        array_walk($image_keywords_arr, 'trim_value');
        $image_keywords = implode(',', array_unique(array_filter($image_keywords_arr)));
        $direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
      
        $additional_field_sql = "";
        $additional_value_sql = "";
        if (!empty($additional_image_fields)) {
          $table = ($direct_upload) ? IMAGES_TABLE : IMAGES_TEMP_TABLE;
          $table_fields = $site_db->get_table_fields($table);
//################# Start Exif IPTC #####################
      $src_file = $old_media_path;
      $size = getimagesize ($src_file, $info);
        if(isset($info['APP13'])){
          $iptc_array = get_iptc_info($info['APP13']);
          foreach ($iptc_array as $key => $val) {
            $additional_field_sql .= ',image_'.$key;
            $additional_value_sql .= ",'".$val."'";
          }
        }
//################# End Exif IPTC ########################         
          foreach ($additional_image_fields as $key => $val) {
            if (isset($HTTP_POST_VARS[$key.'_'.$i]) && isset($table_fields[$key])) {
              $additional_field_sql .= ", $key";
              $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key.'_'.$i]))."'";
              $additional_sql .= ", $key = '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key.'_'.$i]))."'";
            }
          }
        }  

        $current_time = time();
        if (!$direct_upload) {
      
          $sql = "UPDATE ".IMAGES_TEMP_TABLE."
                  SET cat_id = $cat_id, image_name = '$image_name', image_description = '$image_description', image_keywords = '$image_keywords', image_date = $current_time".$additional_sql."
                  WHERE user_id = ".$user_info['user_id']." AND image_id = ".$temp_image_id."
                 ";
          $result = $site_db->query($sql);
          
          $cat_id_array[] = $cat_id;
          $image_name_array[] = $image_name;
          $new_name_array[] = $image_media_file;
        
          $msg .= "<br><b>".$i.".)</b>&nbsp;".$lang['new_upload_validate_desc'].":"; 
          $msg .= "&nbsp;<b>".format_text(stripslashes($image_name), 2)."</b> (".$image_media_file.")<br />";
          $sendprocess = 1;
        }
        else {
          $new_name = multi_copy_media($image_media_file, "-1", $cat_id);
          $new_thumb_name = multi_copy_thumbnail($new_name, $image_thumb_file, "-1", $cat_id);
          
          if($new_name){
            $sql = "INSERT INTO ".IMAGES_TABLE."
                    (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file".$additional_field_sql.")
                    VALUES
                    ($cat_id, ".$user_info['user_id'].", '$image_name', '".mysql_real_escape_string($image_description)."', '".mysql_real_escape_string($image_keywords)."', $current_time, '$new_name', '$new_thumb_name'".$additional_value_sql.")";
            $result = $site_db->query($sql);
            $image_id = $site_db->get_insert_id();
        
            if ($result) {
              include_once(ROOT_PATH.'includes/search_utils.php');
              $search_words = array();              
              foreach ($search_match_fields as $image_column => $match_column) {

              if($save_all){
                if (isset($HTTP_POST_VARS[$image_column.'_1'])) {
                  $search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column.'_1']);
                }
                }else{
                  if (isset($HTTP_POST_VARS[$image_column.'_'.$i])) {
                    $search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column.'_'.$i]);
                  }
                }
              }
              add_searchwords($image_id, $search_words);
//######################### Start Exif IPTC  #########################
          $sql = "SELECT image_id".$additional_field_sql."
                  FROM ".IMAGES_TABLE."
                  WHERE image_id = $image_id
                  ";
          $result = $site_db->query($sql);
          while ($row = $site_db->fetch_array($result)) {
            $additional_search_words = array();
            foreach ($search_match_fields as $image_column => $match_column) {
              if (isset($row[$image_column])) {
                $additional_search_words[$image_column] = $row[$image_column];
              }
            }
            add_searchwords($image_id, $additional_search_words);
          };
//####################### End Exif IPTC ##########################               
              $sql = "DELETE FROM ".IMAGES_TEMP_TABLE."
                      WHERE image_id = $temp_image_id
                     ";
              $site_db->query($sql);
            }
          }
          else {
            $msg .= "<br><b>".$i.".)</b>&nbsp;".$lang['image_add_error'].":"; 
            $msg .= "&nbsp;<b>".format_text(stripslashes($image_name), 2)."</b> (".$image_media_file.")<br>";
          }
          $msg .= "<br><b>".$i.".)</b>&nbsp;".$lang['image_add_success'].":";
          $msg .= "&nbsp;<b>".format_text(stripslashes($image_name), 2)."</b> (".$image_media_file.")<br>"; 
        }
      }//add_image
    } //end for 
  }//error
  else {
    $action = "multi_upload";
  }  
  
  if ($config['upload_notify'] == 1 && $sendprocess) {
    $cat_id_send = "";
    $image_name_send = "";
    $new_name_send = "";

    $cat_id_send = implode("\",\" ", $cat_id_array);
    $image_name_send = implode("\",\" ", $image_name_array);
    $new_name_send = implode("\",\" ", $new_name_array);

    include(ROOT_PATH.'includes/email.php');
    $site_email = new Email();

    $config['upload_emails'] = str_replace(" ", "", $config['upload_emails']);
    $emails = explode(",", $config['upload_emails']);
    $validation_url = $script_url."/admin/index.php?goto=".urlencode("validateimages.php?action=validateimages");

    $site_email->set_to($config['site_email']);
    $site_email->set_subject($lang['new_upload_emailsubject']);
    $site_email->register_vars(array(
      "image_name" => stripslashes('"'.$image_name_send.'"'),
      "file_name" => '"'.$new_name_send.'"',
      "cat_name" => '"'.$cat_id_send.'"',
      "validation_url" => $validation_url,
      "site_name" => $config['site_name']
    ));
      $site_email->set_body("multi_upload_notify", $config['language_dir_default']);
      $site_email->set_bcc($emails);
      $site_email->send_email();
  }  
  $action = "multi_upload";
}

if($action == "multi_upload"){

  $config['queueSizeLimit'] = 10;
  if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
    show_error_page($lang['no_permission']);
    exit;
  } 

  $txt_clickstream = "";
  if ($cat_id && isset($cat_cache[$cat_id])) {
    $txt_clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  }
  $txt_clickstream .= "Multi ".$lang['user_upload'];
  $site_template->register_vars(array(
    "cat_id" => $cat_id,
    "user_id" => $user_info['user_id'],
    "session_id" => session_id(),
    "session_user_id" => $session_info['session_user_id'],
    "token" => (string)csrf_token(),
    "lang_user_upload" => $lang['user_upload'],
    "queueSizeLimit" => $config['queueSizeLimit'],
    "allowed_mediatypes_js" => "*.".str_replace(",","; *.",$config['allowed_mediatypes']),
    "max_media_size_js" => $config['max_media_size']."KB",
    "lang_category" => $lang['category'],
    "lang_user_upload" => "Multi ".$lang['user_upload'],
    "lang_media_file" => $lang['media_file'],
    "lang_thumb_file" => $lang['thumb_file'],
    "lang_allowed_file_types" => $lang['allowed_mediatypes_desc'],
    "allowed_media_types" => str_replace(",",", ",$config['allowed_mediatypes']),
    "allowed_thumb_types" => "jpg, gif, png",
    "lang_queueSizeLimit" => $lang['queueSizeLimit'],
    "lang_max_filesize" => $lang['max_filesize'],
    "lang_max_imagewidth" => $lang['max_imagewidth'],
    "lang_max_imageheight" => $lang['max_imageheight'],
    "max_media_filsize" => $config['max_media_size']."&nbsp;".$lang['kb'],
    "max_media_imagewidth" => $config['max_image_width']."&nbsp;".$lang['px'],
    "max_media_imageheight" => $config['max_image_height']."&nbsp;".$lang['px'],
  ));
  
  $content = $site_template->parse_template("member_multi_upload");
  
  $sql = "SELECT COUNT(image_id) AS sum_images
          FROM ".IMAGES_TEMP_TABLE."
          WHERE user_id = ".$user_info['user_id']." AND cat_id = 0
         ";
  $sum = $site_db->query_firstrow($sql);
  $sum_images = $sum['sum_images'];

  if($sum_images){
    $sql = "SELECT image_id, cat_id, user_id, image_name, image_date, image_media_file, image_thumb_file".$additional_sql."
            FROM ".IMAGES_TEMP_TABLE."
            WHERE user_id = ".$user_info['user_id']." AND cat_id = 0
           ";
    $result = $site_db->query($sql);

    if($result){
      $save_all = "<br>
                  <b>Description and Keywords for all Images<br>
                  <input type=\"checkbox\" name=\"save_all\" value=\"1\">
                  ";

      $uploadform_content ="";
      $i = 1;
      $site_template->register_vars("save_all",$save_all);
      while ($image_row = $site_db->fetch_array($result)){
      
        $addimage = (isset($HTTP_POST_VARS['addimage_'.$i]) && $HTTP_POST_VARS['addimage_'.$i] == 1) ? 1 : 0;
        $cat_id = (isset($HTTP_POST_VARS['cat_id_'.$i])) ? intval($HTTP_POST_VARS['cat_id_'.$i]) : (($image_row['cat_id'])? $image_row['cat_id'] : $cat_id);// Cat_id
        $image_name = (isset($HTTP_POST_VARS['image_name_'.$i])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_name_'.$i]))) : $image_row['image_name'];
        $image_description = (isset($HTTP_POST_VARS['image_description_'.$i])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_description_'.$i]))) : $image_row['image_description'];
        $image_keywords = (isset($HTTP_POST_VARS['image_keywords_'.$i])) ? un_htmlspecialchars(stripslashes(trim($HTTP_POST_VARS['image_keywords_'.$i]))) : $image_row['image_keywords'];

        $row_bg_number = ($i % 2 == 0) ? 1 : 2;
        $save_all = ($i == 1) ? $save_all :"";
        $uploadform_content .= "
          <table cellpadding=\"4\" cellspacing=\"1\" border=\"0\">
            <tr class=\"row".$row_bg_number."\">
              <td>
                <table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">
                  <tr>
                    <td>
                      <input type=\"checkbox\" name=\"addimage_".$i."\" checked value=\"1\">
                     </td>
                    <td valign=\"top\" width=\"".$config['max_thumb_width']."\">
                      <img src=\"data/tmp_thumbnails/".$image_row['image_thumb_file']."\">
                    </td>
                    <td valign=\"top\"><b>".$i.".)  ".$lang['image_name']."</b></br>
                      <input class=\"input\" type=\"text\" name=\"image_name_".$i."\" size=\"20\" value=\"".format_text(stripslashes($image_name), 2)."\">
                      <input  type=\"hidden\" name=\"image_id_".$i."\"  value=\"".$image_row['image_id']."\">
                      <input  type=\"hidden\" name=\"image_media_file_".$i."\"  value=\"".$image_row['image_media_file']."\">
                      <input  type=\"hidden\" name=\"image_thumb_file_".$i."\"  value=\"".$image_row['image_thumb_file']."\">
                      <input  type=\"hidden\" name=\"sum_images\"  value=\"".$sum_images."\">
                   </td>
                    <td valign=\"top\">
                      <b>".$lang['category']."</b></br>
                     ".get_category_dropdown($cat_id,"",3,$i)."
                    </td>
                    <td valign=\"top\">
                      <b>".$lang['description']."</b></br>
                      <textarea class=\"textarea\" cols=\"20\"  rows=\"2\" name=\"image_description_".$i."\" >".$image_description."</textarea>
                      <br>
                      <b>".$lang['keywords']."</br>
                      <textarea  class=\"textarea\" cols=\"20\" rows=\"2\" name=\"image_keywords_".$i."\">".$image_keywords."</textarea>
                      ".$save_all."
                    </td>
                  </tr>
                  <tr>
                    <td colspan=\"5\"></td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        ";
        $i++;
      } //while
    }
    
    $site_template->register_vars(array(
      "uploadform_content" => $uploadform_content,
      "cat_id" => $cat_id,
      "lang_captcha" => $lang['captcha'],
      "lang_captcha_desc" => $lang['captcha_desc'],
      "captcha_upload" => (bool)$captcha_enable_upload,
      "lang_category" => $lang['category'],
      "lang_submit" => $lang['submit'],
      "lang_reset" => $lang['reset'],
      "lang_category" => $lang['category'],
      "lang_image" => $lang['image'],
    ));
    $content .= $site_template->parse_template("member_multi_uploadform");
  }else{
    $action="multi_upload";
  }
}

if($action == "multi_uploadimage"){

  if (isset($HTTP_GET_VARS['user_id']) || isset($HTTP_POST_VARS['user_id'])) {
    $user_id = (isset($HTTP_GET_VARS['user_id'])) ? intval($HTTP_GET_VARS['user_id']) : intval($HTTP_POST_VARS['user_id']);
    if (!$user_id) {
      $user_id = GUEST;
    }
  }
  else {
    $user_id = GUEST;
  }
  
  if($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))){
    show_error_page($lang['no_permission']);
    exit;
  }
  
  if(!empty($_FILES)){
    $uploaderror = 0;
    $image_name = utf8_decode(get_file_name(un_htmlspecialchars(trim($_FILES['media_file']['name']))));
    
    include(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();
    
    if(!empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none"){
      $new_name = ($site_upload->upload_file("media_file", "media"));
       if (!$new_name) {
          echo  $site_upload->get_upload_errors();
        $uploaderror = 1;
      }
    }
    
    $new_thumb_name = "";
    if($config['auto_thumbnail'] == 1 && !empty($new_name) && !$uploaderror && ((!empty($HTTP_POST_FILES['media_file']['tmp_name']) && $HTTP_POST_FILES['media_file']['tmp_name'] != "none") || is_remote($new_name))) {

      if (is_remote($new_name)){
        $src = $new_name;
        $thumb = create_unique_filename(THUMB_TEMP_PATH, filterFileName($new_name));
      }else{
        $src = MEDIA_TEMP_PATH."/".$new_name;
        $thumb = $new_name;
      }
      $dest = THUMB_TEMP_PATH."/".$thumb;
      
      $do_create = 0;
      if($image_info = @getimagesize($src)){
        if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
          $do_create = 1;
        }
      }
      if($do_create){
        require(ROOT_PATH.'includes/image_utils.php');
        $convert_options = init_convert_options();
      if (!$convert_options['convert_error']&& $image_info[2] == 2||$image_info[2] == 3){
        $quality = 100;
        if (!resize_image($src, $quality, $config['max_image_width'], 1, $config['max_image_height'])){
          $msg .= (($msg != "") ? "<br>" : "")."<b>".$lang['file_upload_error'].": ".$new_name;
          $uploaderror = 1;
        }
      }

        if(!$convert_options['convert_error']){
          $dimension = (intval($config['auto_thumbnail_dimension'])) ? intval($config['auto_thumbnail_dimension']) : 100;
          $resize_type = (intval($config['auto_thumbnail_resize_type'])) ? intval($config['auto_thumbnail_resize_type']) : 1;
          $quality = (intval($config['auto_thumbnail_quality']) && intval($config['auto_thumbnail_quality']) <= 100) ? intval($config['auto_thumbnail_quality']) : 100;

          if(create_thumbnail($src, $dest, $quality, $dimension, $resize_type)){
            $new_thumb_name = $thumb;
          }
        }
      }
    }
    if(!$uploaderror){
      $additional_field_sql = "";
      $additional_value_sql = "";
      if(!empty($additional_image_fields)) {
        $table = IMAGES_TEMP_TABLE;
        $table_fields = $site_db->get_table_fields($table);
        foreach ($additional_image_fields as $key => $val){
          if(isset($HTTP_POST_VARS[$key]) && isset($table_fields[$key])){
            $additional_field_sql .= ", $key";
            $additional_value_sql .= ", '".un_htmlspecialchars(trim($HTTP_POST_VARS[$key]))."'";
          }
        }
      } 
      $current_time = time();
      $sql = "INSERT INTO ".IMAGES_TEMP_TABLE."
              (cat_id, user_id, image_name, image_date, image_media_file, image_thumb_file".$additional_field_sql.")
              VALUES
              ($cat_id, '$user_id', '$image_name', $current_time, '$new_name', '$new_thumb_name'".$additional_value_sql.")
             ";
      $result = $site_db->query($sql);
    }
    echo 1;
  }
  else {
    echo 0;
  }
}
//############################ End Multiupload #################################################


11.) search in includes/functions..php "?>" and insert above:

//############################## Start Multiupload ###################################
function multi_copy_media($image_media_file, $from_cat = 0, $to_cat = 0) {
  global $config;

  if (is_remote($image_media_file)) {
    return $image_media_file;
  }

  $image_src = ($from_cat != -1) ? MEDIA_PATH.(($from_cat != 0) ? "/".$from_cat : "") : MEDIA_TEMP_PATH;
  $image_dest = ($to_cat != -1) ? MEDIA_PATH.(($to_cat != 0) ? "/".$to_cat : "") : MEDIA_TEMP_PATH;
  return multi_copy_file($image_src, $image_dest, $image_media_file, $image_media_file, $config['upload_mode']);
}


function multi_copy_thumbnail($image_media_file, $image_thumb_file, $from_cat = 0, $to_cat = 0) {
  if (is_remote($image_thumb_file)) {
    return $image_thumb_file;
  }

  $thumb_src = ($from_cat != -1) ? THUMB_PATH.(($from_cat != 0) ? "/".$from_cat : "") : THUMB_TEMP_PATH;
  $thumb_dest = ($to_cat != -1) ? THUMB_PATH.(($to_cat != 0) ? "/".$to_cat : "") : THUMB_TEMP_PATH;

  if ($image_thumb_file != "" && file_exists($thumb_src."/".$image_thumb_file)) {
    $thumb_extension = get_file_extension($image_thumb_file);
    $new_thumb = get_file_name($image_media_file).".".$thumb_extension;
    if ($new_thumb = multi_copy_file($thumb_src, $thumb_dest, $image_thumb_file, $new_thumb, 1))
    {
      $image_thumb_file = $new_thumb;
    }
  }
  return $image_thumb_file;
}

function multi_copy_file($image_src, $image_dest, $image_media_file, $dest_file_name, $type, $filter = 1, $move = 1)
{
  $image_src_file = $image_src."/".$image_media_file;
  $dest_file_name = ($filter) ? filterFileName($dest_file_name) : $dest_file_name;
  $ok = 0;
  if (!file_exists($image_dest) || !is_dir($image_dest))
  {
$oldumask = umask(0);
$result = _mkdir($image_dest);
        @chmod($image_dest, CHMOD_DIRS);
umask($oldumask);
  }
  switch ($type) {
  case 1: // overwrite mode
    if (file_exists($image_src."/".$image_media_file)) {
      if (file_exists($image_dest."/".$dest_file_name)) {
        unlink($image_dest."/".$dest_file_name);
      }
      $ok = copy($image_src."/".$image_media_file, $image_dest."/".$dest_file_name);
    }
    break;

  case 2: // create new with incremental extention
     if (file_exists($image_src."/".$image_media_file)) {
       $file_extension = get_file_extension($dest_file_name);
       $file_name = get_file_name($dest_file_name);

       $n = 2;
       $copy = "";
       while (file_exists($image_dest."/".$file_name.$copy.".".$file_extension)) {
         $copy = "_".$n;
         $n++;
       }
       $new_file = $file_name.$copy.".".$file_extension;
       $ok = copy($image_src."/".$image_media_file, $image_dest."/".$new_file);
       $dest_file_name = $new_file;
     }
     break;

   case 3: // do nothing if exists, highest protection
   default:
     if (file_exists($image_src."/".$image_media_file)) {
       if (file_exists($image_dest."/".$dest_file_name)) {
         $ok = 0;
       }
       else {
         $ok = copy($image_src."/".$image_media_file, $image_dest."/".$dest_file_name);
       }
     }
     break;
  }

  if ($ok) {
    if ($move)
    {
      @unlink($image_src_file);
    }
    @chmod($image_dest."/".$dest_file_name, CHMOD_FILES);
    return $dest_file_name;
  }
  else {
    return false;
  }
}
//############################## End Multiupload ###################################


12.) create a new file, call it "multi_upload_notify.html" and copy it in your lang/your language/email Folder.
(deutsch)

--- Code: ---Neue Bilder wurden auf "{site_name}" hinzugefügt und muessen freigeschaltet werden.

Kategorie: {cat_name}
Bildnamen: {image_name}
Dateien: {file_name}

{validation_url}

--
Mit freundlichen Grüßen,
{site_name}

--- End code ---
(english)

--- Code: ---New images has been uploaded to "{site_name}" and awaits validation.

Category:  {cat_name}
Image Name:  {image_name}
File:  {file_name}

{validation_url}

--
Best regards,
{site_name}

--- End code ---

the queue Size Limit can you set in member.php, search in the new code:

//########## config ########
  $config['queueSizeLimit'] = 10;
//########## config ########


that's for sure, this is my last Multiupload.  :mrgreen:

mfg Andi

Sunny C.:
ENDLICH !!!!! :D

Rembrandt:

--- Quote from: Sumale.nin on July 26, 2012, 05:53:52 PM ---ENDLICH !!!!! :D

--- End quote ---

hast du ihn ausprobiert?
ich frage deshalb weil ich den Mod schon seit einen Monat herrum liegen hatte weil mir das *.swf im FF schwierigkeiten machte.

mfg Andi

Nosferatu:
irgendwie haut das bei mir nicht hin....

ich hoffe ihr seht den button ;) sollte eigentlich schon sei.
http://wallpapers.pj-firepower.com/categories.php?cat_id=432

Zur sicherheit hab ich noch 2 screenshots gemacht

habs nochmal extra durchgesehen :(

Edit:
ich hab jetzt zum testen auch einfach mach nur TEST TEST in die member_multi_upload.html geschrieben.
nicht einmal das wird geladen ...

Rembrandt:
sorry, war wieder mal mein Fehler hatte Step 8.2) aus dem alten Mod genommen und da stimmt der verweis natürlich nicht, jetzt sollte es klappen.

wenn du das änderst funktioniert es auf deiner Webseite, habs soeben ausprobiert :)

mfg Andi

Navigation

[0] Message Index

[#] Next page

Go to full version