Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - thunderstrike

Pages: [1] 2 3 4 5 ... 7
1
Ok, we know what this is. No need for say description for this right ? ;)

[28-02-2008] - instruction update -

// Upload same file name (for media and thumb) for each loop you select. ex: file1.jpg for media and file1.jpg for thumb. file2.jpg for media and file2.jpg for thumb in no 2 upload window (read instruction for integrate resize on upload - version 1 or 2 or V@no in my first post or second post - ((// Integrate with auto-resize) step)).

[28-02-2008] - end instruction update -

I full code this myself and now is work purfect. I patch all pass problem in forum with MOD.

No Kai - no demo Kai :!:

// Package:

- Single value number in ACP for say how number images is upload to gallery (yes, 1 include so no need for remove MOD to go back single upload).
- Multiupload / Single image upload button is change from 1 to 2 in categories page.
- New code for templates and media template folder for view upload images.
- User is possible for select value of file upload (max limit to admin setting: ACP - > Setting).
- If user access page with URL for multiupload form, auto change to 1 upload for this user.
- Each file is say for upload in media template (@Ivan: Is fix).
- Each content is regroup with thumb and media file so is detect right in mySQL.
- Each count file is match with upload form.
- $action = multiupload - REMOVE (no need).
- Captcha include.
- Convert string to array - ALL (axcept captcha).
- Additional image fields include with counter.
- HTML template: ALL parse and register for template.
- Single email for notify with all upload file - same time in email template.
- Possible for integrate other MOD in forum.
- I post screenshot.

This is VERY BIG MOD. Make FULL BACKUP of gallery (include mySQL) - or test with fresh gallery (4images v1.76).

// Step 1

In member.php file (very big step):

I change all 'uploadimage' and 'uploadform' and add 'requestuploadform' action to multiupload so you need replace this (test in fresh gallery if like) - to this:

Code: [Select]
if ($action == "uploadimage") {
  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 .= $lang['user_upload'];
  
  $num_counter = (isset($HTTP_POST_VARS['num_counter'])) ? intval(trim($HTTP_POST_VARS['num_counter'])) : 1;  
  
  for ($i = 0; $i < $num_counter; $i++) {      
      $remote_media_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_media_file' . $i])));
      $remote_thumb_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_thumb_file' . $i])));
      
      $image_name = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_name' . $i]));
      $image_description = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_description' . $i]));
      $image_keywords = un_htmlspecialchars(trim((string)$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)));      

      $image_active = (isset($HTTP_POST_VARS['image_active' . $i]) && $HTTP_POST_VARS['image_active' . $i] == 0) ? 0 : 1;
      $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments' . $i]) && $HTTP_POST_VARS['image_allow_comments' . $i] == 0) ? 0 : 1;
      $image_download_url = (isset($HTTP_POST_VARS['image_download_url' . $i])) ? format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_download_url' . $i]))) : "";            
  } // End for.

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

  $direct_upload = (check_permission("auth_directupload", $cat_id)) ? 1 : 0;
  $upload_cat = ($direct_upload) ? $cat_id : 0;

  $error = 0;
  $uploaderror = 0;

  if ($cat_id == 0)  {
    $error = 1;
    $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $lang['category']), $lang['field_required']);
    $msg .= (($msg != "") ? "<br />" : "").$field_error;
  }
  
  for ($i = 0; $i < $num_counter; $i++) {
      if ((empty($HTTP_POST_FILES['media_file' . $i]['tmp_name']) || $HTTP_POST_FILES['media_file' . $i]['tmp_name'] == "none") && (sizeof($remote_media_file) == 0 || !check_remote_media($remote_media_file))) {
          $error = 1;
          $msg .= (($msg != "") ? "<br />" : "").$lang['image_file_required'];
      }
      
      if (sizeof($image_name) == 0)  {
          $error = 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 />" : "").$field_error;
      }  
  } // End for.

  if ($captcha_enable_upload && !captcha_validate($captcha)) {
    $msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
    $error = 1;
  }

  if (!empty($additional_image_fields)) {
      foreach ($additional_image_fields as $key => $val) {
          for ($i = 0; $i < $num_counter; $i++) {
              if (isset($HTTP_POST_VARS[$key . $i]) && intval($val[2]) == 1 && sizeof($HTTP_POST_VARS[$key . $i]) == 0) {
                  $error = 1;
                  $field_error = preg_replace("/".$site_template->start."field_name".$site_template->end."/siU", str_replace(":", "", $val[0]), $lang['field_required']);
                  $msg .= (($msg != "") ? "<br />" : "").$field_error;
              }
          }          
       }
  }

  if (!$error) {
    // Start Upload
    include(ROOT_PATH.'includes/upload.php');
    $site_upload = new Upload();

    // Upload Media file
    
    for ($i = 0; $i < $num_counter; $i++) {        
        $remote_media_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_media_file' . $i])));        
        
        if (!empty($HTTP_POST_FILES['media_file' . $i]['tmp_name']) && $HTTP_POST_FILES['media_file' . $i]['tmp_name'] != "none") {
            $HTTP_POST_FILES['media_file' . $i]['name'] = $site_upload->upload_file("media_file" . $i, "media", $upload_cat);
            if (!$HTTP_POST_FILES['media_file' . $i]['name']) {
                $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".$HTTP_POST_FILES['media_file' . $i]['name']."</b><br />".$site_upload->get_upload_errors();
                $uploaderror = 1;
            }
        } else {            
                $HTTP_POST_FILES['media_file' . $i]['name'] = $remote_media_file;
        }      
    } // End for.        

    // Uplad thumb file
    require(ROOT_PATH.'includes/image_utils.php');
    $convert_options = init_convert_options();
    $do_create = 0;    
    
    for ($i = 0; $i < $num_counter; $i++) {        
        $remote_thumb_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_thumb_file' . $i])));            
        
        if (!empty($HTTP_POST_FILES['thumb_file' . $i]['tmp_name']) && $HTTP_POST_FILES['thumb_file' . $i]['tmp_name'] != "none" && !$uploaderror) {
            $HTTP_POST_FILES['thumb_file' . $i]['name'] = $site_upload->upload_file("thumb_file" . $i, "thumb", $upload_cat, get_basefile($HTTP_POST_FILES['media_file' . $i]['name']));
            if (get_basefile(stripslashes(trim(!$HTTP_POST_FILES['thumb_file' . $i]['name'])))) {
                $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['thumb_upload_error'].": ".$HTTP_POST_FILES['thumb_file' . $i]['name']."</b><br />".$site_upload->get_upload_errors();
                @unlink(MEDIA_TEMP_PATH."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))));
                $uploaderror = 1;
            }        
        
         } elseif (check_remote_thumb($remote_thumb_file)) {            
             $HTTP_POST_FILES['thumb_file' . $i]['name'] = $remote_thumb_file;
        
         } elseif ($config['auto_thumbnail'] == 1 && !empty($HTTP_POST_FILES['media_file' . $i]['tmp_name']) && $HTTP_POST_FILES['media_file' . $i]['tmp_name'] != "none" && !$uploaderror) {
             if ($direct_upload) {
                 $src = MEDIA_PATH."/".$cat_id."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
                 $dest = THUMB_PATH."/".$cat_id."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
            
             } else {
                 $src = MEDIA_TEMP_PATH."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
                 $dest = THUMB_TEMP_PATH."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
             }            
             if ($image_info = @getimagesize($src)) {
                 if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
                     $do_create = 1;
                 }
             }
             if ($do_create) {                
                 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)) {
                         $HTTP_POST_FILES['thumb_file' . $i]['name'] = get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
                     }
                 }
             }
         }
    } // End for.

    if (!$uploaderror) {
      $current_time = time();
      
      if ($direct_upload) {
          include(ROOT_PATH.'includes/search_utils.php');
          $search_words = array();
          
          for ($i = 0; $i < $num_counter; $i++) {
              
              $remote_media_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_media_file' . $i])));
              $remote_thumb_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_thumb_file' . $i])));
              
              $image_name = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_name' . $i]));
              $new_name = (isset($remote_media_file) && !empty($remote_media_file)) ? $remote_media_file : get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
              $new_thumb_name = (isset($remote_thumb_file) && !empty($remote_thumb_file)) ? $remote_thumb_file : get_basefile(stripslashes(trim($HTTP_POST_FILES['thumb_file' . $i]['name'])));
              $image_description = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_description' . $i]));
              $image_keywords = un_htmlspecialchars(trim((string)$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)));
              
              $image_active = (isset($HTTP_POST_VARS['image_active' . $i]) && $HTTP_POST_VARS['image_active' . $i] == 0) ? 0 : 1;
              $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments' . $i]) && $HTTP_POST_VARS['image_allow_comments' . $i] == 0) ? 0 : 1;
              $image_download_url = (isset($HTTP_POST_VARS['image_download_url' . $i])) ? format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_download_url' . $i]))) : "";                          
              
              $additional_field_sql = "";
              $additional_value_sql = "";
              if (!empty($additional_image_fields)) {
                  $table_fields = $site_db->get_table_fields(IMAGES_TABLE);
                  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]))."'";
                      }
                  }
              }
              
              $sql = "INSERT INTO ".IMAGES_TABLE."
              (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_active, image_media_file, image_thumb_file, image_download_url, image_allow_comments".$additional_field_sql.")
              VALUES ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, $image_active, '$new_name', '$new_thumb_name', '$image_download_url', $image_allow_comments".$additional_value_sql.")";
              $result = $site_db->query($sql);
              $image_id = $site_db->get_insert_id();
              if ($result) {                  
                  foreach ($search_match_fields as $image_column => $match_column) {
                      if (isset($HTTP_POST_VARS[$image_column])) {
                          $search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column]);
                      }
                  }
              }                                
              add_searchwords($image_id, $search_words);
          } // End for.      
      }
      else {
          for ($i = 0; $i < $num_counter; $i++) {
              
              $remote_media_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_media_file' . $i])));
              $remote_thumb_file = format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['remote_thumb_file' . $i])));
              
              $image_name = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_name' . $i]));
              $new_name = (isset($remote_media_file) && !empty($remote_media_file)) ? $remote_media_file : get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
              $new_thumb_name = (isset($remote_thumb_file) && !empty($remote_thumb_file)) ? $remote_thumb_file : get_basefile(stripslashes(trim($HTTP_POST_FILES['thumb_file' . $i]['name'])));
              $image_description = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_description' . $i]));
              $image_keywords = un_htmlspecialchars(trim((string)$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)));
              
              $image_active = (isset($HTTP_POST_VARS['image_active' . $i]) && $HTTP_POST_VARS['image_active' . $i] == 0) ? 0 : 1;
              $image_allow_comments = (isset($HTTP_POST_VARS['image_allow_comments' . $i]) && $HTTP_POST_VARS['image_allow_comments' . $i] == 0) ? 0 : 1;
              $image_download_url = (isset($HTTP_POST_VARS['image_download_url' . $i])) ? format_url(un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_download_url' . $i]))) : "";            
              
              $additional_field_sql = "";
              $additional_value_sql = "";
              if (!empty($additional_image_fields)) {
                  $table_fields = $site_db->get_table_fields(IMAGES_TEMP_TABLE);
                  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]))."'";
                      }
                  }
              }
              
              $sql = "INSERT INTO ".IMAGES_TEMP_TABLE."
              (cat_id, user_id, image_name, image_description, image_keywords, image_date, image_media_file, image_thumb_file, image_download_url".$additional_field_sql.")                
              VALUES ($cat_id, ".$user_info['user_id'].", '$image_name', '$image_description', '$image_keywords', $current_time, '$new_name', '$new_thumb_name', '$image_download_url'".$additional_value_sql.")";
              $result = $site_db->query($sql);
          }
      }

      if ($config['upload_notify'] == 1 && !$direct_upload) {
        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']);
        
        for ($i = 0; $i < $num_counter; $i++) {
            $image_name = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_name' . $i]));
            
            $site_email->register_vars(array(
               "image_name" => format_text(trim($image_name), 2),
               "media_file_name" => get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))),
               "thumb_file_name" => get_basefile(stripslashes(trim($HTTP_POST_FILES['thumb_file' . $i]['name'])))
            ));            
        } // End for.
        $site_email->register_vars(array(
          "cat_name" => format_text(trim($cat_cache[$cat_id]['cat_name']), 2),
          "validation_url" => $validation_url,
          "site_name" => format_text(trim($config['site_name']), 2)
        ));
        $site_email->set_body("upload_notify", $config['language_dir_default']);
        $site_email->set_bcc($emails);
        $site_email->send_email();
      }
      
      $bgcounter = 0;
      $total_files_uploaded = 0;
      for ($i = 0; $i < $num_counter; $i++) {          
          $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
          
          $image_name = un_htmlspecialchars(trim((string)$HTTP_POST_VARS['image_name' . $i]));
          
          $msg .= $lang['image_add_success'].": <b>".format_text(stripslashes($image_name), 2)."</b> (" . get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))).")<br />";
          $msg .= (!$direct_upload) ? "<br />".$lang['new_upload_validate_desc'] : "";          
          
          $file_extension = get_file_extension(get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))));
          $file = (is_remote($HTTP_POST_FILES['media_file' . $i]['name'])) ? get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))) : (($direct_upload) ? MEDIA_PATH."/".$cat_id."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))) : MEDIA_TEMP_PATH."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))));
          $width_height = "";
          if (!is_remote($file) && $imageinfo = @getimagesize($file)) {
              $width_height = " ".$imageinfo[3];
          }
          $media_icon = "<img src=\"".ICON_PATH."/".$file_extension.".gif\" border=\"0\" alt=\"\" />";
          $site_template->register_vars(array(
             "media_src" => $file,
             "media_icon" => $media_icon,
             "image_name" => format_text(stripslashes($image_name)),
             "width_height" => $width_height
          ));
          $media = $site_template->parse_template("media/".$file_extension);
          $site_template->register_vars(array(
             "lang_multiupload_media_file_name" => preg_replace("/" . $site_template->start . "media_file_name" . $site_template->end . "/siU", get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name']))), $lang['multiupload_media_file_name']),
             "media" => $media,
             "counter" => $row_bg_number
          ));          
          $content .= $site_template->parse_template("member_multiupload_media");          
          
          $total_files_uploaded++;
      } // End for.    
      
    }
    else {
      $action = "uploadform";
      $sendprocess = 1;
    }
  }
  else {
    $action = "uploadform";
    $sendprocess = 1;
  }
}

if ($action == "requestuploadform") {    
    
    if ($cat_id != 0 && (!isset($cat_cache[$cat_id]) || !check_permission("auth_upload", $cat_id))) {
        show_error_page($lang['no_permission']);
        exit;
    }
    $txt_clickstream = get_category_path($cat_id, 1).$config['category_separator'] . $lang['multiupload_select_title'];
    
    if (isset($config['multiupload_size'])) {        
        if ($config['multiupload_size'] > 1) {            
            $request_uploadform_content = "";            
            for ($i = $config['multiupload_size']; $i > 0; $i--) {                
                $site_template->register_vars("i", $i);
                $request_uploadform_content .= $site_template->parse_template("member_multiuploadform_select_content");                                                
            }
            $site_template->register_vars(array(
            "lang_member_multiuploadform_select" => $lang['member_multiuploadform_select'],
            "lang_multiupload_select_title" => $lang['multiupload_select_title'],
            "member_multiuploadform_select_content" => $request_uploadform_content,
            "cat_id" => $cat_id,
            "request_uploadform_value" => $cat_id            
            ));
            $content .= $site_template->parse_template("member_multiuploadform_select");
        }
    }    
}

if ($action == "uploadform") {
  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 .= $lang['user_upload'];
  
  if (isset($HTTP_POST_VARS['request_uploadform_value'])) {
      $request_uploadform_value = (isset($HTTP_POST_VARS['request_uploadform_value'])) ? intval(trim($HTTP_POST_VARS['request_uploadform_value'])) : "";
  } else {
      $request_uploadform_value = 1;
  }

  if (!$sendprocess) {
    $remote_media_file = "";
    $remote_thumb_file = "";
    $image_name = "";
    $image_description = "";
    $image_keywords = "";
    $image_download_url = "";
    $image_allow_comments = 1;
  }
  
  if ($sendprocess) {
      $site_template->register_vars(array(
         "cat_id" => $cat_id,
         "cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id)
      ));      
      
      for ($i = 0; $i < $num_counter; $i++) {
          
          $site_template->register_vars(array(          
            "remote_media_file" => format_text(stripslashes($remote_media_file), 2),
            "remote_thumb_file" => format_text(stripslashes($remote_thumb_file), 2),
            "image_name" => format_text(stripslashes($image_name), 2),
            "image_description" => format_text(stripslashes($image_description), 2),
            "image_keywords" => format_text(stripslashes($image_keywords), 2),
            "image_allow_comments_yes" => ($image_allow_comments) ? " checked=\"checked\"" : "",
            "image_allow_comments_no" => (!$image_allow_comments) ? " checked=\"checked\"" : "",
            "image_download_url" => format_text(stripslashes($image_download_url), 2),
            "lang_category" => $lang['category'],            
            "lang_user_upload" => $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_max_filesize" => $lang['max_filesize'],
            "lang_max_imagewidth" => $lang['max_imagewidth'],
            "lang_max_imageheight" => $lang['max_imageheight'],
            "max_thumb_filsize" => $config['max_thumb_size']."&nbsp;".$lang['kb'],
            "max_thumb_imagewidth" => $config['max_thumb_width']."&nbsp;".$lang['px'],
            "max_thumb_imageheight" => $config['max_thumb_height']."&nbsp;".$lang['px'],
            "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'],
            "lang_image_name" => $lang['image_name'],
            "lang_description" => $lang['description'],
            "lang_keywords" => $lang['keywords_ext'],
            "lang_allow_comments" => isset($lang['allow_comments']) ? $lang['allow_comments'] : "",          
            "lang_submit" => $lang['submit'],
            "lang_reset" => $lang['reset'],
            "lang_yes" => $lang['yes'],
            "lang_no" => $lang['no'],
            "lang_captcha" => $lang['captcha'],
            "lang_captcha_desc" => $lang['captcha_desc'],
            "captcha_upload" => (bool)$captcha_enable_upload
          ));
          
          if (!empty($additional_image_fields)) {
              $additional_field_array = array();        
              foreach ($additional_image_fields as $key => $val) {                            
                  if ($val[1] == "radio") {
                      $value = (isset($HTTP_POST_VARS[$key . $i])) ? intval($HTTP_POST_VARS[$key . $i]) : 1;
                      if ($value == 1) {
                          $additional_field_array[$key.'_yes'] = " checked=\"checked\"";
                          $additional_field_array[$key.'_no'] = "";
                      } else {
                              $additional_field_array[$key.'_yes'] = "";
                              $additional_field_array[$key.'_no'] = " checked=\"checked\"";
                      }
                  } else {
                      $value = (isset($HTTP_POST_VARS[$key . $i])) ? format_text(trim($HTTP_POST_VARS[$key . $i]), 1) : "";
                  }
                  $additional_field_array[$key] = $value;
                  $additional_field_array['lang_'.$key] = $val[0];        
              }
              if (!empty($additional_field_array)) {
                  $site_template->register_vars($additional_field_array);
              }
          }
          
      } // End for.
  
  } elseif (!$send_process) {
      
      $site_template->register_vars(array(
        "cat_id" => $cat_id,
        "cat_name" => ($cat_id != 0) ? format_text($cat_cache[$cat_id]['cat_name'], 2) : get_category_dropdown($cat_id),    
        "remote_media_file" => format_text(stripslashes($remote_media_file), 2),
        "remote_thumb_file" => format_text(stripslashes($remote_thumb_file), 2),
        "image_name" => format_text(stripslashes($image_name), 2),
        "image_description" => format_text(stripslashes($image_description), 2),
        "image_keywords" => format_text(stripslashes($image_keywords), 2),
        "image_allow_comments_yes" => ($image_allow_comments) ? " checked=\"checked\"" : "",
        "image_allow_comments_no" => (!$image_allow_comments) ? " checked=\"checked\"" : "",
        "image_download_url" => format_text(stripslashes($image_download_url), 2),
        "lang_category" => $lang['category'],
        "lang_user_upload" => $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_max_filesize" => $lang['max_filesize'],
        "lang_max_imagewidth" => $lang['max_imagewidth'],
        "lang_max_imageheight" => $lang['max_imageheight'],
        "max_thumb_filsize" => $config['max_thumb_size']."&nbsp;".$lang['kb'],
        "max_thumb_imagewidth" => $config['max_thumb_width']."&nbsp;".$lang['px'],
        "max_thumb_imageheight" => $config['max_thumb_height']."&nbsp;".$lang['px'],
        "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'],
        "lang_image_name" => $lang['image_name'],
        "lang_description" => $lang['description'],
        "lang_keywords" => $lang['keywords_ext'],
        "lang_allow_comments" => isset($lang['allow_comments']) ? $lang['allow_comments'] : "",
        "lang_submit" => $lang['submit'],
        "lang_reset" => $lang['reset'],
        "lang_yes" => $lang['yes'],
        "lang_no" => $lang['no'],
        "lang_captcha" => $lang['captcha'],
        "lang_captcha_desc" => $lang['captcha_desc'],
        "captcha_upload" => (bool)$captcha_enable_upload
      ));  
  }

  if (!empty($additional_image_fields)) {
    $additional_field_array = array();        
    foreach ($additional_image_fields as $key => $val) {                            
        if ($val[1] == "radio") {
            $value = (isset($HTTP_POST_VARS[$key])) ? intval($HTTP_POST_VARS[$key]) : 1;
            if ($value == 1) {
                $additional_field_array[$key.'_yes'] = " checked=\"checked\"";
                $additional_field_array[$key.'_no'] = "";
            } else {
                $additional_field_array[$key.'_yes'] = "";
                $additional_field_array[$key.'_no'] = " checked=\"checked\"";
            }
        } else {
            $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 1) : "";
        }
        $additional_field_array[$key] = $value;
        $additional_field_array['lang_'.$key] = $val[0];        
    }
    if (!empty($additional_field_array)) {
      $site_template->register_vars($additional_field_array);
    }
  }  
  $multiupload_content = "";
  $counter = 0;
  for ($i = 1; $i <= $request_uploadform_value; $i++) {      
      $lang_multiupload_title_content = preg_replace("/" . $site_template->start . "counter" . $site_template->end . "/siU", $counter + 1, $lang['multiupload_file_title']);      
      $site_template->register_vars("lang_multiupload_file_title", $lang_multiupload_title_content);
      $site_template->register_vars("counter", $counter);
      $multiupload_content .= $site_template->parse_template("member_multiupload_form");
      
      $counter++;
  }
  $site_template->register_vars("member_multiupload_form", $multiupload_content);
  $site_template->register_vars("num_counter", $counter);  
  $content = $site_template->parse_template("member_uploadform");
  unset ($multiupload_file_title);
  unset ($multiupload_content);  
}

(paste full code from uploadimage and stop right before: emailuser action).

// Step 2

In lang/english/main.php file,

add in top ?>:

Code: [Select]
//-----------------------------------------------------
//--- Multiupload (Thunderstrike version) -------------
//-----------------------------------------------------
$lang['multiupload_file_title'] = "File no. {counter}";
$lang['multiupload_media_file_name'] = "Filename: {media_file_name}";
$lang['member_multiuploadform_select'] = "Select the number of images for upload:<br /><span class=\"smalltext\"><font color=\"red\">Note:</font> Check all field before upload.</span>";
$lang['multiupload_select_title'] = "Multiupload - select";

// Step 3

In categories.php file,

find:

Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}

replace:

Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
elseif (check_permission("auth_upload", $cat_id) && isset($config['multiupload_size']) && $config['multiupload_size'] == 1) {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}
elseif (check_permission("auth_upload", $cat_id) && isset($config['multiupload_size']) && $config['multiupload_size'] > 1) {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=requestuploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("multiupload.gif")."\" border=\"0\" alt=\"\" /></a>";
}

// Step 4

In lang/english/admin.php file,

add in top ?>:

Code: [Select]
/*-- Setting-Group XX --*/
$setting_group[XX] = "Multiupload";
$setting['multiupload_size'] = "Set max value for user to upload images to gallery";

Replace XX with last value in list.

// Step 5

In admin/settings.php file,

find:

Code: [Select]
show_form_footer($lang['save_changes'], "", 2);

add before :

Code: [Select]
show_table_separator($setting_group[XX], 2, "setting_group_XX");  
show_setting_row("multiupload_size");

Replace XX with last value in list.

// Step 6

In templates/your_template/member_uploadform.html file,

find:

Code: [Select]
   <input type="submit" name="uploadbutton" value="{lang_submit}" class="button" />

add before :

Code: [Select]
<input type="hidden" name="num_counter" value="{num_counter}">

// Step 7

In templates/your_template - create new file: member_multiupload_form.html file,

add:

Code: [Select]
 <tr>
            <td colspan="2" valign="top" class="head1">{lang_multiupload_file_title}</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 class="row2">
              <b>Upload:</b><br />
 <input type="file" name="media_file{counter}" class="input" /><br />
 <b>URL:</b><br />
 <input type="text" name="remote_media_file{counter}"  size="30" value="{remote_media_file}" class="input" /><br />
 <span class="smalltext"><b>{lang_allowed_file_types}</b> {allowed_media_types}</span>
            </td>
          </tr>
          <tr>
            <td class="row1" valign="top">
 <b>{lang_thumb_file}</b><br />
 <span class="smalltext">
 {lang_max_filesize}<b>{max_thumb_filsize}</b><br />
 {lang_max_imagewidth}<b>{max_thumb_imagewidth}</b><br />
 {lang_max_imageheight}<b>{max_thumb_imageheight}</b><br />
 </span>
</td>
            <td class="row1">
              <b>Upload:</b><br />
 <input type="file" name="thumb_file{counter}" class="input" /><br />
 <b>URL:</b><br />
 <input type="text" name="remote_thumb_file{counter}"  size="30" value="{remote_thumb_file}" class="input" /><br />
 <span class="smalltext"><b>{lang_allowed_file_types}</b> {allowed_thumb_types}</span>
            </td>
          </tr>
          <tr>
            <td class="row2"><b>{lang_image_name}</b></td>
            <td class="row2"><input type="text" name="image_name{counter}"  size="30" value="{image_name}" class="input" /></td>
          </tr>
          <tr>
            <td class="row1" valign="top"><b>{lang_description}</b></td>
            <td class="row1">
              <textarea name="image_description{counter}" cols="30" class="textarea" rows="10" wrap="VIRTUAL">{image_description}</textarea>
            </td>
          </tr>
          <tr>
            <td class="row2" valign="top"><b>{lang_keywords}</b></td>
            <td class="row2">
              <textarea cols="30" class="textarea" rows="10" wrap="VIRTUAL" name="image_keywords{counter}">{image_keywords}</textarea>
            </td>
          </tr>

// Step 8

In templates/your_template - create new file: member_multiupload_media.html file,

add:

Code: [Select]
<table border="0" width="100%" cellpadding="0" cellspacing="0" class="tablebottom">
<tr>
<td class="head1">&nbsp;{lang_multiupload_media_file_name}</td>
</tr>
<tr>
<td class="row{counter}" align="center"><br />{media}<br /></td>
</tr>
</table>

// Step 9

In templates/your_template - create new file: member_multiuploadform_select_content.html file,

add:

Code: [Select]
<option value="{i}">{i}</option>

// Step 10

I attach ZIP file for screenshot and multiupload button so upload in templates/your_template/images folder (or same place for upload.gif file).

// Step 11

In SQL Patches (expert mode),

use:

Code: [Select]
INSERT INTO 4images_settings (setting_name, setting_value) VALUES ('multiupload_size', '2');

// Integrate with auto-resize

Ok so if use this:

http://www.4homepages.de/forum/index.php?topic=7700.0

(step 1 of V@no for member.php file) -

replace:

Code: [Select]
//--------------------------------------------
//--------- Auto Image Resizing --------------
//--------------------------------------------
if ($config['auto_image'] && !$uploaderror) {
    $do_resize = 0;
    for ($i = 0; $i < $num_counter; $i++) {
        if ($direct_upload) {
            $HTTP_POST_FILES['media_file' . $i]['name'] = MEDIA_PATH."/".$cat_id."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
        } else {
            $HTTP_POST_FILES['media_file' . $i]['name'] = MEDIA_TEMP_PATH."/".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
        }
        
        if ($image_info = @getimagesize($HTTP_POST_FILES['media_file' . $i]['name'])) {
            if ($image_info[2] == 1 || $image_info[2] == 2 || $image_info[2] == 3) {
                $do_resize = 1;
            }
        }
    }
    if ($do_resize) {
        if (!function_exists(init_convert_options)) {
            require(ROOT_PATH.'includes/image_utils.php');
        }
        
        if ($image_info[0] > $config['max_image_width'] || $image_info[1] > $config['max_image_height']) {
            $convert_options = init_convert_options();
            if (!$convert_options['convert_error']) {
                $quality = (intval($config['auto_image_quality']) && intval($config['auto_image_quality']) <= 100) ? intval($config['auto_image_quality']) : 100;
                for ($i = 0; $i < $num_counter; $i++) {
                    if (!resize_image($HTTP_POST_FILES['media_file' . $i]['name'], $quality, $config['max_image_width'], 1, $config['max_image_height'])) {
                        $msg .= (($msg != "") ? "<br />" : "")."<b>".$lang['file_upload_error'].": ".get_basefile(stripslashes(trim($HTTP_POST_FILES['media_file' . $i]['name'])));
                        $uploaderror = 1;
                    }
                }
            }
        }
    }
}
//-------------------------------------------


[29-02-2008] - Subject update by Nicky

2
This MOD is for add user IDs from editprofile so other user see your profile. If fail check, user is redirect to 4images error page. Same user ID value is check too.
Note: Use space for each ID add.

NO KAI - NO DEMO KAI :!:

I post screenshot.

// Step 1

In member.php file - showprofile action,

find:

Code: [Select]
if ($user_row = get_user_info($user_id)) {      

add after:

Code: [Select]
if (function_exists('check_user_access_profile_field') && !check_user_access_profile_field($user_info['user_id'], $user_row['user_access_profile']) && $user_row['user_id'] != $user_info['user_id'] && $user_info['user_level'] != ADMIN) {
          show_error_page($lang['user_access_profile_no_permission']);
}

// Step 1.1

find:

Code: [Select]
if ($action == "editprofile") {
  $txt_clickstream = $lang['control_panel'];
  if ($user_info['user_level'] == GUEST) {
    show_error_page($lang['no_permission']);
    exit;
  }

add before :

Code: [Select]
if ($action == "exec_edit_user_access_profile") {
    if (isset($HTTP_POST_VARS['user_access_profile'])) {
        $user_access_profile = (isset($HTTP_POST_VARS['user_access_profile'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['user_access_profile'])) : "";
    } else {
        $user_access_profile = "";
    }
    
    if (empty($user_access_profile)) {
        $action = "editprofile";
    }
    
    if (isset($user_access_profile) && !empty($user_access_profile)) {
        if (function_exists('check_same_user_access_ids') && check_same_user_access_ids($user_info['user_id'], $user_access_profile)) {
            $msg = $lang['user_access_profile_same_ids_error'];
            $action = "editprofile";
        } else {
            $result = $site_db->query("UPDATE " . USERS_TABLE . " SET user_access_profile = '" . $user_access_profile . "' WHERE " . get_user_table_field("", "user_id") . " = " . $user_info['user_id']);      
            if ($result) {
                $msg = $lang['user_access_profile_edit_success'];
                $action = "editprofile";
            }
        }
    }
    
}

if ($action == "edit_user_access_profile") {
    $txt_clickstream = $lang['user_access_profile'];
    
    $site_template->register_vars(array(
    "lang_user_access_profile_textarea_title" => $lang['user_access_profile_textarea_title'],
    "user_access_profile" => $user_info['user_access_profile'],
    "lang_submit" => $lang['submit'],
    "lang_reset" => $lang['reset']
    ));
    $content = $site_template->parse_template("member_access_profile");    
}

// Step 1.2

In editprofile action,

find:

Code: [Select]
"lang_icq" => $lang['icq'],

add after:

Code: [Select]
"url_user_access_profile" => $site_sess->url(ROOT_PATH . "member.php?action=edit_user_access_profile"),

// Step 2

In lang/english/main.php file,

add in top ?>:

Code: [Select]
//-----------------------------------------------------
//--- User access page --------------------------------
//-----------------------------------------------------
$lang['user_access_profile'] = "User Access Profile";
$lang['user_access_profile_textarea_title'] = "User Access Profile - Edit";
$lang['user_access_profile_edit_success'] = "Edit success !";
$lang['user_access_profile_no_permission'] = "You do not have permission to access this profile.";
$lang['user_access_profile_same_ids_error'] = "You cannot add your ID for viewing your own profile. Please try again without your own ID.";

// Step 3

In includes/functions.php file,

add in top ?>:

Code: [Select]
if (!function_exists('check_same_user_access_ids')) {
    function check_same_user_access_ids($user_id, $user_access_profile) {
        global $check_same_user_ids;  
        if (!isset($check_same_user_ids)) {
            $ids = trim($user_access_profile);
            $ids = preg_replace("/[\n\r]/is", " ", $ids);
            $ids = str_replace(",", " ", $ids);
            $ids = preg_quote($ids);
            $ids = str_replace('/', '\\/', $ids);
            $check_same_user_ids = preg_split("/\s+/", $ids);
        }
        foreach ($check_same_user_ids as $key => $val) {            
            if ($val == $user_id) {                
                return $user_id;
                return $user_access_profile;
            }
        }        
    }
}

if (!function_exists('check_user_access_profile_field')) {
    function check_user_access_profile_field($user_id, $user_access_profile) {
        global $split_other_user_ids;  
        if (!isset($split_user_ids)) {
            $ids = trim($user_access_profile);
            $ids = preg_replace("/[\n\r]/is", " ", $ids);
            $ids = str_replace(",", " ", $ids);
            $ids = preg_quote($ids);
            $ids = str_replace('/', '\\/', $ids);
            $split_other_user_ids = preg_split("/\s+/", $ids);
        }
        foreach ($split_other_user_ids as $key => $val) {            
            if ($val == $user_id) {                
                return $user_id;
                return $user_access_profile;
            }
        }
    }
}

// Step 4

In templates/your_template/member_editprofile.html file,

find:

Code: [Select]
<p align="center">
    <input type="submit" value="{lang_save}" class="button" />
    <input type="reset" value="{lang_reset}" class="button" />
  </p>
</form>
<br />

add after:

Code: [Select]
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td valign="top" class="head1">{lang_user_access_profile}</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="row1" width="100%" align="center"><a href="{url_user_access_profile}">{lang_user_access_profile}</a></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
</table>

// Step 5

In templates/your_template , create new file: member_access_profile.html .

Add:

Code: [Select]
<form method="post" action="{url_member}">
<input type="hidden" name="action" value="exec_edit_user_access_profile">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td valign="top" class="head1">{lang_user_access_profile_textarea_title}</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="row1" width="100%" align="center"><textarea name="user_access_profile" class="textarea" />{user_access_profile}</textarea></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="row1" width="50%" align="right"><input type="submit" name="submit" value="{lang_submit}" class="button">&nbsp;&nbsp;</td>
<td class="row1" width="50%" align="left">&nbsp;&nbsp;<input type="reset" name="reset" value="{lang_reset}" class="button"></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="head1" width="100%" align="center">&nbsp;</td>
</tr>
</table>
</form>

// Step 6

In includes/db_field_definitions.php file,

add in top ?>:

Code: [Select]
$additional_user_fields['user_access_profile'] = array($lang['user_access_profile'], "textarea", 0);

// Step 8

In SQL Patches MOD,

add:

Code: [Select]
ALTER TABLE 4images_users ADD user_access_profile TEXT NOT NULL default '';

3
This is very special MOD. Thank to Jan for add function for format textarea for each value. ;)

// Description:

- Is check for each user ID, each user level and each action name (if have action name) with ROOT PHP file.
- Is auto-create SQL table if no exist in DB.
- Is auto-add filename in SQL table if no exist in SQL table (or add in exclude list).
- Exclude filename list for detect in ROOT_PATH.
- Active / Inactive MOD check.
- Auto-add setting in SETTINGS_TABLE.
- Add multiple user IDs
- Add multiple user groups (axcept admin tag with user level - for gallery safety - if need debug - create test user account).
- FAQ include in MOD in plugin page - read instruction how all switch work.
- Search filename include.

- Is auto-detect file include this:

Quote
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: filename.php                                            *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.4                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) fweitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

// If have other user level - is possible for add in MOD ?
Yes, is possible. E.g - moderator MOD . If have, is possible for integrate. ;)

NO KAI - NO DEMO KAI :!:

I post screenshot.

// Note:

Backup full gallery (SQL include).

// Step 1

In includes/page_header.php file,

find:

Code: [Select]
$site_template->register_vars(array(
  "media_url" => MEDIA_PATH,

add before:

Code: [Select]
//-----------------------------------------------------
//--- Check page permission table ---------------------
//-----------------------------------------------------
if (function_exists('check_page_permission_table')) {
    check_page_permission_table();
}

// Step 2

In lang/english/admin.php file,

find:

Code: [Select]
//-----------------------------------------------------
//--- Settings ----------------------------------------
//-----------------------------------------------------
$lang['save_settings_success'] = "Settings saved";

add before:

Code: [Select]
//-----------------------------------------------------
//--- User page permission ----------------------------
//-----------------------------------------------------
$lang['user_page_permission_title'] = "User page permission";
$lang['user_page_permission_page_name'] = "Page name";
$lang['user_page_permission_page_date'] = "Date";
$lang['user_page_permission_page_options'] = "Options";
$lang['user_page_permission_search_page_text'] = "Search page (full filename): ";
$lang['user_page_permission_search_page_result'] = "Search result";
$lang['user_page_permission_search_no_result'] = "<font color=\"red\">No result.</font>";
$lang['user_page_permission_edit_permission'] = "<span class=\"smalltext\">Edit permission</span>";
$lang['user_page_permission_delete_page'] = "<span class=\"smalltext\">Delete page</span>";
$lang['user_page_permission_go_back'] = "<span class=\"smalltext\">[ Go back ]</span>";
$lang['user_page_permission_delete_success'] = "<font color=\"green\">Delete success !</font>";
$lang['user_page_permission_confirm_delete_page_message'] = "This is for delete filename ONLY if no exist in FTP / file manager or no 4images tag. Is ok ?";
$lang['user_page_permission_update_success'] = "<font color=\"green\">Update success !</font>";
$lang['user_page_permission_edit_action'] = "<span class=\"smalltext\">Edit action</span>";
$lang['user_page_permission_faq_title'] = "FAQ";
$lang['user_page_permission_instructions'] = "&nbsp;This is key use for <b>edit permission</b> textarea of each (action include if like).<br /><br />

&nbsp;User level:<br /><br />

&nbsp;// guest = all<br />
&nbsp;// user = kick guest but allow for user and admin.<br />
&nbsp;// admin = kick all axcept admin.<br />
&nbsp;// self = self user (e.g: private page for each user ID session so other user ID is no see content - like PM inbox).<br /><br />

&nbsp;// Is possible for grant access for all user and no user ID + action empty ?<br />
&nbsp;Yes, is possible. In <b>edit permission</b> use: <b>guest</b> .<br /><br />

&nbsp;// Is possible for grant access for user level and no user ID + action empty ?<br />
&nbsp;Yes, is possible. In <b>edit permission</b> use: <b>user</b> .<br /><br />

&nbsp;// Is possible for grant access for admin and no user ID + action empty ?<br />
&nbsp;Yes, is possible. In <b>edit permission</b> use: <b>admin</b> .<br /><br />

&nbsp;// Is possible for grant access for self user and no user ID + action empty ?<br />
&nbsp;Yes, is possible. In <b>edit permission</b> use: <b>self</b> .<br /><br />

&nbsp;// Is possible for use multiple keys for user ID with user level ?<br />
&nbsp;Yes, is possible. Each user ID and user level is link for each and <b>" . strtolower($lang['user_page_permission_title']) . "</b> MOD is detect each.<br /><br />

&nbsp;// Is possible for use single / multiple key for user ID, user level and action ?<br />
&nbsp;Yes, is possible. all is work if like (foreach user or for user level with action).<br /><br />

&nbsp;// Is work for user ID (no action or user level) ?<br />
&nbsp;Ok, how is work -<br /><br />

&nbsp;<b>edit permission</b> link: <b>1 2 3 4 5 6</b><br />
&nbsp;<b>" . strtolower($lang['user_page_permission_title']) . "</b> MOD is check for each user ID and see if match with user info to access page (use space for each user ID).<br /><br />

&nbsp;// Is work for user ID and action name ?<br />
&nbsp;Ok, how is work - e.g: member.php file - (use space for each action name) -<br /><br />

&nbsp;<b>edit permission</b> link: <b>1 2</b><br />
&nbsp;<b>edit action</b> link: <b>showprofile editprofile</b> .<br /><br />

&nbsp;Is mean: User ID <b>1</b> is access <b>showprofile</b> and user ID <b>2</b> is access <b>editprofile</b> (is for each user ID).<br /><br />

&nbsp;// How I get what I add in SQL after install this MOD ?<br />
&nbsp;Nothing. <b>" . strtolower($lang['user_page_permission_title']) . "</b> MOD is detect if SQL table exist. If !exist, is create auto, is detect ROOT files, is add <b>guest</b> in <b>edit permission</b> link (default).<br /><br />

&nbsp;// Is ROOT filename add in SQL table each time I visit gallery ?<br />
&nbsp;No need. Each file is detect each visit <b>but " . strtolower($lang['user_page_permission_title']) . "</b> MOD is check if exist filename in SQL table. If exist, is skip.<br /><br />

&nbsp;// I use <b>Delete page</b> link and page is back after I visit gallery.<br />
&nbsp;If see this, is no problem. <b>ACP - > Setting - > User page permission - > Set exclude filename so MOD is no scan 4images file you add</b> and set ROOT filename in textarea so detect is skip.<br /><br />

&nbsp;// Is <b>user_info['user_level']</b> need after install this MOD ?<br />
&nbsp;No ! - Jan object is no need after install this MOD but need replace object with <b>" . strtolower($lang['user_page_permission_title']) . " function</b>.<br /><br />

&nbsp;// Is possible for add <b>admin</b> tag and add user ID of user (no admin, guest but USER level) ?<br />
&nbsp;For safety, is <u>!possible</u>. <b>admin</b> is use override for all gallery from Jan session class file.<br /><br />

&nbsp;// Is possible for add <b>user</b> tag and add <b>admin</b> tag ?<br />
&nbsp;Yes, is possible. Is mean - <b>admin level</b> and <b>user level</b> is grant access (with action or no action add).<br />

";

// Step 2.1

Same file - add in top ?>:

Code: [Select]
/*-- Setting-Group XX --*/
$setting_group[XX] = "User page permission";
$setting['user_page_permission_use'] = "Activate user page permission";
$setting['user_page_permission_exclude_file'] = "Set exclude filename so MOD is no scan 4images file you add<br /><span class=\"smalltext\">(Note: E.g: <b>categories.php details.php</b> - <b>and 'yes' - use space for each add filename</b>)</span>.";

Note: Replace XXs with last value.

// Step 3

In admin/settings.php file,

find:

Code: [Select]
show_form_footer($lang['save_changes'], "", 2);

add before:

Code: [Select]
show_table_separator($setting_group[XX], 2, "setting_group_XX");
show_setting_row("user_page_permission_use", "radio");
show_setting_row("user_page_permission_exclude_file", "textarea");    

Note: Replace XXs with last value.

// Step 4

In admin/plugins , create new file: user_page_permission.php .

Add:

Code: [Select]
<?php // PLUGIN_TITLE: User page permission

$nozip 1;
define('IN_CP'1);
define('ROOT_PATH'"./../../");
require(
ROOT_PATH.'admin/admin_global.php');

if (!
defined('PAGES_RESTRICT_TABLE')) {
    
define('PAGES_RESTRICT_TABLE'$table_prefix 'pages_restrict');
}

show_admin_header();

if (
$action == "") {
    
$action "main_menu";
}

if (
$action == "delete_page") {
    
    if (isset(
$HTTP_GET_VARS['page_id']) || isset($HTTP_POST_VARS['page_id'])) {
        
$page_id = (isset($HTTP_GET_VARS['page_id'])) ? intval(trim($HTTP_GET_VARS['page_id'])) : intval(trim($HTTP_POST_VARS['page_id']));
    } else {
        
$page_id 0;
    }
    
    if (empty(
$page_id)) {
        
$action "main_menu";
    }
    
    if (isset(
$page_id) && !empty($page_id)) {
        
$result $site_db->query("DELETE FROM " PAGES_RESTRICT_TABLE " WHERE page_id = " $page_id);
        if (
$result) {
            
$msg $lang['user_page_permission_delete_success'];            
        }
        
$action "main_menu";
    }
}

if (
$action == "search_page") {
    
    if (isset(
$HTTP_POST_VARS['search_result'])) {
        
$search_result = (isset($HTTP_POST_VARS['search_result'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['search_result'])) : "";
    } else {
        
$search_result "";
    }
    
    if (empty(
$search_result)) {
        
$action "main_menu";
    }
    
    if (isset(
$search_result) && !empty($search_result)) {
        
        
$sql "
        
        SELECT page_id, page_name, page_date
        FROM " 
PAGES_RESTRICT_TABLE "
        WHERE page_name = '" 
$search_result "'
        
        "
;
        
        
$result $site_db->query($sql);
        
$num_rows $site_db->get_numrows($result);        
        
        
?>
       
        <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
        <tr class="tableseparator">
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_title']; ?></td>    
        </tr>    
        </table>        
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" valign="top" align="left"><a href="<?php echo $site_sess->url('user_page_permission.php'); ?>"><span class=\"smalltext\"><?php echo $lang['user_page_permission_go_back']; ?></a></span><br /><br /></td>
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['search']; ?><br /></td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" align="right"><br />
        <form method="post" action="<?php echo $site_sess->url('user_page_permission.php'); ?>">
        <input type="hidden" name="action" value="search_page">
        <?php echo $lang['user_page_permission_search_page_text']; ?><input type="text" name="search_result">&nbsp;<input type="submit" name="submit" value="<?php echo $lang['search']; ?>" class="button" />&nbsp;
        </form>    
        </td>    
        </tr>    
        </table>
        <?php
        
if (empty($num_rows)) {
        
?>

        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>    
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_search_page_result']; ?></td>        
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>    
        <td width="100%" class="tablerow">&nbsp;</td>        
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>    
        <td width="100%" class="tablerow" align="center"><?php echo $lang['user_page_permission_search_no_result']; ?></td>
        </tr>
        </table>        
        <?php
        
} else {
        
?>

        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>    
        <td width="33%" class="tableheader" align="center"><?php echo $lang['user_page_permission_page_name']; ?></td>
        <td width="33%" class="tableheader" align="center"><?php echo $lang['user_page_permission_page_date']; ?></td>    
        <td width="33%" class="tableheader" align="center"><?php echo $lang['user_page_permission_page_options']; ?></td>    
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow">&nbsp;</td>    
        </tr>    
        </table>
        <table border="1" width="100%" cellpadding="0" cellspacing="0" class="tableheader" />    
        
        <?php    
        
while ($page_row $site_db->fetch_array($result)) {
            
$page_id $page_row['page_id'];
            
$page_name format_text(trim($page_row['page_name']), 2);
            
$page_date = (function_exists('get_universal_field_date')) ? get_universal_field_date($page_row['page_date']) : format_date($config['date_format'], $page_row['page_date']);        
        
?>
           
        <tr class="tableseparator">
        <td width="33%" class="tablerow" align="center"><?php echo $page_name?></td>    
        <td width="33%" class="tablerow" align="center"><?php echo $page_date?></td>            
        <td width="33%" class="tablerow" align="center"><a href="<?php echo $site_sess->url('user_page_permission.php?action=edit_permission&page_id=' $page_id); ?>">[ <?php echo $lang['user_page_permission_edit_permission']; ?> ]</a> | <a href="<?php echo $site_sess->url('user_page_permission.php?action=edit_action&page_id=' $page_id); ?>">[ <?php echo $lang['user_page_permission_edit_action']; ?> ]</a> | <a href="<?php echo $site_sess->url('user_page_permission.php?action=delete_page&page_id=' $page_id); ?>" onclick="return confirm('<?php echo $lang['user_page_permission_confirm_delete_page_message']; ?>')">[ <?php echo $lang['user_page_permission_delete_page']; ?></a> ]</td>
        </tr>            
        <?php
        
}
    }
    
?>

    </table>    
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow">&nbsp;</td>    
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;</td>    
    </tr>    
    </table>
    <?php
    
}
}

if (
$action == "exec_edit_permission") {
    
    if (isset(
$HTTP_GET_VARS['page_id']) || isset($HTTP_POST_VARS['page_id'])) {
        
$page_id = (isset($HTTP_POST_VARS['page_id'])) ? intval(trim($HTTP_POST_VARS['page_id'])) : intval(trim($HTTP_GET_VARS['page_id']));
    } else {
        
$page_id 0;
    }
    
    if (isset(
$HTTP_GET_VARS['page_user_ids']) || isset($HTTP_POST_VARS['page_user_ids'])) {
        
$page_user_ids = (isset($HTTP_POST_VARS['page_user_ids'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['page_user_ids'])) : un_htmlspecialchars(trim((string)$HTTP_GET_VARS['page_user_ids']));
    } else {
        
$page_user_ids "";
    }
    
    if (empty(
$page_id)) {
        
$action "main_menu";
    }
    
    if (isset(
$page_user_ids)) {        
        
$result $site_db->query("UPDATE " PAGES_RESTRICT_TABLE " SET page_user_ids = '" $page_user_ids "', page_date = '" time() . "' WHERE page_id = " $page_id);
        if (
$result) {
            
$msg $lang['user_page_permission_update_success'];
        }
        
$action "main_menu";
    }
}

if (
$action == "edit_permission") {
    
    if (isset(
$HTTP_GET_VARS['page_id'])) {
        
$page_id = (isset($HTTP_GET_VARS['page_id'])) ? intval(trim($HTTP_GET_VARS['page_id'])) : 0;
    } else {
        
$page_id 0;
    }
    
    if (empty(
$page_id)) {
        
$action "main_menu";
    }
    
    if (isset(
$page_id) && !empty($page_id)) {
        
        
$sql "
        
        SELECT page_user_ids
        FROM " 
PAGES_RESTRICT_TABLE "
        WHERE page_id = " 
$page_id;
        
        
$row $site_db->query_firstrow($sql);
        
$page_user_ids format_text($row['page_user_ids'], 101);
        
?>

        <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
        <tr class="tableseparator">
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_title']; ?></td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" valign="top" align="left"><a href="<?php echo $site_sess->url('user_page_permission.php'); ?>"><span class=\"smalltext\"><?php echo $lang['user_page_permission_go_back']; ?></a></span><br /><br /></td>
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['search']; ?><br /></td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" align="right"><br />
        <form method="post" action="<?php echo $site_sess->url('user_page_permission.php'); ?>">
        <input type="hidden" name="action" value="search_page">
        <?php echo $lang['user_page_permission_search_page_text']; ?><input type="text" name="search_result">&nbsp;<input type="submit" name="submit" value="<?php echo $lang['search']; ?>" class="button" />&nbsp;
        </form>    
        </td>    
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>    
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_edit_permission']; ?></td>        
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow">&nbsp;</td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" align="center">
        <form method="post" action="<?php echo $site_sess->url('user_page_permission.php'); ?>">
        <input type="hidden" name="action" value="exec_edit_permission">
        <input type="hidden" name="page_id" value="<?php echo $page_id?>">
        <textarea name="page_user_ids" rows="20" cols="60" value="<?php echo $page_user_ids?>" class="textarea" /><?php echo $page_user_ids?></textarea><br />
        <input type="submit" name="submit" value="<?php echo $lang['edit']; ?>" class="button" />        
        </td>    
        </tr>    
        </table>        
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tableheader">&nbsp;</td>    
        </tr>    
        </table>
        <?php
    
}
}

if (
$action == "exec_edit_action") {
    
    if (isset(
$HTTP_GET_VARS['page_id']) || isset($HTTP_POST_VARS['page_id'])) {
        
$page_id = (isset($HTTP_POST_VARS['page_id'])) ? intval(trim($HTTP_POST_VARS['page_id'])) : intval(trim($HTTP_GET_VARS['page_id']));
    } else {
        
$page_id 0;
    }
    
    if (isset(
$HTTP_GET_VARS['page_action']) || isset($HTTP_POST_VARS['page_action'])) {
        
$page_action = (isset($HTTP_POST_VARS['page_action'])) ? un_htmlspecialchars(trim((string)$HTTP_POST_VARS['page_action'])) : un_htmlspecialchars(trim((string)$HTTP_GET_VARS['page_action']));
    } else {
        
$page_action "";
    }
    
    if (empty(
$page_id)) {
        
$action "main_menu";
    }
    
    if (isset(
$page_action)) {        
        
$result $site_db->query("UPDATE " PAGES_RESTRICT_TABLE " SET page_action = '" $page_action "', page_date = '" time() . "' WHERE page_id = " $page_id);
        if (
$result) {
            
$msg $lang['user_page_permission_update_success'];
        }
        
$action "main_menu";
    }
}

if (
$action == "edit_action") {
    
    if (isset(
$HTTP_GET_VARS['page_id'])) {
        
$page_id = (isset($HTTP_GET_VARS['page_id'])) ? intval(trim($HTTP_GET_VARS['page_id'])) : 0;
    } else {
        
$page_id 0;
    }
    
    if (empty(
$page_id)) {
        
$action "main_menu";
    }
    
    if (isset(
$page_id) && !empty($page_id)) {
        
        
$sql "
        
        SELECT page_action
        FROM " 
PAGES_RESTRICT_TABLE "
        WHERE page_id = " 
$page_id;
        
        
$row $site_db->query_firstrow($sql);
        
$page_action format_text($row['page_action'], 101);
        
?>

        <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
        <tr class="tableseparator">
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_title']; ?></td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" valign="top" align="left"><a href="<?php echo $site_sess->url('user_page_permission.php'); ?>"><span class=\"smalltext\"><?php echo $lang['user_page_permission_go_back']; ?></a></span><br /><br /></td>
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['search']; ?><br /></td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" align="right"><br />
        <form method="post" action="<?php echo $site_sess->url('user_page_permission.php'); ?>">
        <input type="hidden" name="action" value="search_page">
        <?php echo $lang['user_page_permission_search_page_text']; ?><input type="text" name="search_result">&nbsp;<input type="submit" name="submit" value="<?php echo $lang['search']; ?>" class="button" />&nbsp;
        </form>    
        </td>    
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>    
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_edit_action']; ?></td>        
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow">&nbsp;</td>    
        </tr>    
        </table>
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tablerow" align="center">
        <form method="post" action="<?php echo $site_sess->url('user_page_permission.php'); ?>">
        <input type="hidden" name="action" value="exec_edit_action">
        <input type="hidden" name="page_id" value="<?php echo $page_id?>">
        <textarea name="page_action" rows="20" cols="60" value="<?php echo $page_action?>" class="textarea" /><?php echo $page_action?></textarea><br />
        <input type="submit" name="submit" value="<?php echo $lang['edit']; ?>" class="button" />        
        </td>    
        </tr>    
        </table>        
        <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
        <td width="100%" class="tableheader">&nbsp;</td>    
        </tr>    
        </table>
        <?php
    
}
}

if (
$action == "main_menu") {
            
    
$sql "
    
    SELECT page_id, page_name, page_date
    FROM " 
PAGES_RESTRICT_TABLE "    
    ORDER BY page_name ASC"
;
    
    
$result $site_db->query($sql);
    
?>

    
    <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
    <tr class="tableseparator">
    <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_title']; ?></td>    
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow" align="center"><?php echo (isset($msg) && !empty($msg)) ? "<br />" $msg "<br /><br />" REPLACE_EMPTY "<br />"?></td>
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;<?php echo $lang['user_page_permission_faq_title']; ?><br /></td>    
    </tr>    
    </table>    
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow"><?php echo $lang['user_page_permission_instructions']; ?><br /></td>    
    </tr>    
    </table>  
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;<?php echo $lang['search']; ?><br /></td>    
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow" align="right"><br />
    <form method="post" action="<?php echo $site_sess->url('user_page_permission.php'); ?>">
    <input type="hidden" name="action" value="search_page">
    <?php echo $lang['user_page_permission_search_page_text']; ?><input type="text" name="search_result">&nbsp;<input type="submit" name="submit" value="<?php echo $lang['search']; ?>" class="button" />&nbsp;
    </form>    
    </td>    
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>    
    <td width="33%" class="tableheader" align="center"><?php echo $lang['user_page_permission_page_name']; ?></td>
    <td width="33%" class="tableheader" align="center"><?php echo $lang['user_page_permission_page_date']; ?></td>    
    <td width="33%" class="tableheader" align="center"><?php echo $lang['user_page_permission_page_options']; ?></td>    
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow">&nbsp;</td>    
    </tr>    
    </table>
    <table border="1" width="100%" cellpadding="0" cellspacing="0" class="tableheader" />    
    
    <?php    
    
while ($page_row $site_db->fetch_array($result)) {
        
$page_id $page_row['page_id'];
        
$page_name format_text(trim($page_row['page_name']), 2);
        
$page_date = (function_exists('get_universal_field_date')) ? get_universal_field_date($page_row['page_date']) : format_date($config['date_format'], $page_row['page_date']);        
        
?>
       
        
        <tr class="tableseparator">
        <td width="33%" class="tablerow" align="center"><?php echo $page_name?></td>    
        <td width="33%" class="tablerow" align="center"><?php echo $page_date?></td>            
        <td width="33%" class="tablerow" align="center"><a href="<?php echo $site_sess->url('user_page_permission.php?action=edit_permission&page_id=' $page_id); ?>">[ <?php echo $lang['user_page_permission_edit_permission']; ?> ]</a> | <a href="<?php echo $site_sess->url('user_page_permission.php?action=edit_action&page_id=' $page_id); ?>">[ <?php echo $lang['user_page_permission_edit_action']; ?> ]</a> | <a href="<?php echo $site_sess->url('user_page_permission.php?action=delete_page&page_id=' $page_id); ?>" onclick="return confirm('<?php echo $lang['user_page_permission_confirm_delete_page_message']; ?>')">[ <?php echo $lang['user_page_permission_delete_page']; ?></a> ]</td>
        </tr>            
        <?php
    
}
    
?>

    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow">&nbsp;</td>    
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;</td>    
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tablerow"><br /><span class="smalltext"><b>User page permission</b> - created by <a href="http://www.4homepages.de/forum/index.php?topic=19856.0" target="_blank" />Thunderstrike</a> - 2007-2008<br />Version 2.0</span><br /><br /></td>
    </tr>    
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;</td>    
    </tr>    
    </table>
    <?php
}

show_admin_footer();
?>


4
This is MOD for add link in member profile and new page for report user homepage link to gallery owner.

// Step 1

In member.php file,

find:

Code: [Select]
//-----------------------------------------------------
//--- Show Profile ------------------------------------
//-----------------------------------------------------

add before:

Code: [Select]
//-----------------------------------------------------
//--- Exec report user homepage link ------------------
//-----------------------------------------------------
if ($action == "exec_report_user_homepage_link") {
    
    if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
        $user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval(trim($HTTP_GET_VARS[URL_USER_ID])) : intval(trim($HTTP_POST_VARS[URL_USER_ID]));
    } else {
        $user_id = GUEST;
    }
    
    if (isset($HTTP_GET_VARS['user_email']) || isset($HTTP_POST_VARS['user_email'])) {
        $user_email = (isset($HTTP_GET_VARS['user_email'])) ? un_htmlspecialchars(trim((string)$HTTP_GET_VARS['user_email'])) : un_htmlspecialchars(trim((string)$HTTP_POST_VARS['user_email']));
    } else {
        $user_email = "";
    }
    
    if (isset($HTTP_GET_VARS['send_report']) || isset($HTTP_POST_VARS['send_report'])) {
        $send_report = (isset($HTTP_GET_VARS['send_report'])) ? un_htmlspecialchars(trim(intval($HTTP_GET_VARS['send_report']))) : un_htmlspecialchars(trim(intval($HTTP_POST_VARS['send_report'])));
    } else {
        $send_report = "";
    }
    
    if (!isset($user_id) || empty($user_id) || $user_id == GUEST || $user_info['user_level'] == GUEST && empty($user_email) || $user_id == $session_info['session_user_id'] && $user_info['user_level'] != ADMIN) {
        redirect($url);
    }
    
    if ($report_user_info = get_user_info($user_id)) {
        $report_user_id = $report_user_info[$user_table_fields['user_id']];        
    }
    
    include_once(ROOT_PATH . "includes/email.php");
    $site_email = new Email();
    
    $site_email->set_to(stripslashes(trim($config['site_email'])));
    $site_email->set_from($user_email);
    
    $site_email->set_subject($lang['report_user_homepage_email_subject_title']);
    $site_email->register_vars(array(
    "user_profile_link" => $script_url . "/member.php?action=showprofile&" . URL_USER_ID . "=" . $report_user_id,
    "user_name" => (!empty($user_info['user_name'])) ? format_text(trim($user_info['user_name']), 2) : $user_email,
    "user_ip" => $session_info['session_ip'],
    "send_report" => (isset($send_report) && !empty($send_report)) ? $send_report : "",
    "site_name" => format_text(trim($config['site_name']), 2),
    "site_email" => (stripslashes(trim($config['site_email'])))
    ));
    $site_email->set_body("admin_report_user_homepage_message", $config['language_dir_default']);
    $site_email->send_email();
    
    redirect("member.php?action=showprofile&" . URL_USER_ID . "=" . $user_id);
}

//-----------------------------------------------------
//--- Show report user homepage link ------------------
//-----------------------------------------------------
if ($action == "show_report_user_homepage_link") {    
    $txt_clickstream = $lang['report_user_homepage_link_title'];
    
    if (isset($HTTP_GET_VARS[URL_USER_ID]) || isset($HTTP_POST_VARS[URL_USER_ID])) {
        $user_id = (isset($HTTP_GET_VARS[URL_USER_ID])) ? intval(trim($HTTP_GET_VARS[URL_USER_ID])) : intval(trim($HTTP_POST_VARS[URL_USER_ID]));
    } else {
        $user_id = GUEST;
    }
    
    if (!isset($user_id) || empty($user_id) || $user_id == GUEST) {
        redirect($url);
    }
    
    if (isset($user_id) && $user_id > 0) {
        if ($report_user_info = get_user_info($user_id)) {
            $user_id = $report_user_info[$user_table_fields['user_id']];
            $user_homepage = (isset($report_user_info[$user_table_fields['user_homepage']]) && !empty($report_user_info[$user_table_fields['user_homepage']])) ? format_url($report_user_info[$user_table_fields['user_homepage']]) : "";
        }
        $site_template->register_vars(array(
        "lang_report_user_homepage_link_title" => $lang['report_user_homepage_link_title'],
        "lang_report_user_homepage_link" => $lang['report_user_homepage_link'],
        "user_id" => (isset($user_id) && !empty($user_id)) ? $user_id : "",
        "user_homepage" => (isset($user_homepage) && !empty($user_homepage)) ? $user_homepage : "",
        "url_go_back" => $site_sess->url(ROOT_PATH . "member.php?action=showprofile&" . URL_USER_ID . "=" . $user_id),
        "lang_report_user_email" => $lang['report_user_email'],
        "lang_url_go_back" => $lang['report_user_homepage_go_back'],
        "url_exec_report_user_homepage_link" => $site_sess->url(ROOT_PATH . "member.php?action=exec_report_user_homepage_link"),
        "lang_report_user_homepage_reason" => $lang['report_user_homepage_reason'],
        "lang_submit" => $lang['submit'],
        "lang_reset" => $lang['reset'],
        ));
        $content = $site_template->parse_template("member_profile_user_homepage_report");
    }    
}

find:

Code: [Select]
"lang_homepage" => $lang['homepage'],

add after:

Code: [Select]
"lang_user_homepage_report_link_from_profile" => (isset($user_row[$user_table_fields['user_id']]) && $user_info['user_id'] == $user_row[$user_table_fields['user_id']] && $user_info['user_level'] != ADMIN) ? "" : (isset($user_row[$user_table_fields['user_id']]) && $user_info['user_id'] != $user_row[$user_table_fields['user_id']] && $user_info['user_level'] == ADMIN) ? $lang['user_homepage_report_link_from_profile'] : $lang['user_homepage_report_link_from_profile'],
      "url_user_homepage_report_link_from_profile" => $site_sess->url(ROOT_PATH . "member.php?action=show_report_user_homepage_link&" . URL_USER_ID . "=" . $user_row[$user_table_fields['user_id']]),

// Step 2

In lang/english/main.php file,

find:

Code: [Select]
$lang['homepage']

add after:

Code: [Select]
$lang['user_homepage_report_link_from_profile'] = "<span class=\"smalltext\">[ Report link ]</span>";
$lang['report_user_homepage_link'] = "Report for link: ";
$lang['report_user_homepage_reason'] = "Reason for report: ";
$lang['report_user_homepage_link_title'] = "Report user homepage";
$lang['report_user_homepage_go_back'] = "<span class=\"smalltext\">[ Go back ]</a>";
$lang['report_user_email'] = "Email address: ";
$lang['report_user_homepage_email_subject_title'] = "User homepage report notification";

Hope is good english.  :|

// Step 3

In lang/english/email , create file: admin_report_user_homepage_message.html .

Add:

Code: [Select]
Dear staff,

you have just received a new notification about
a user homepage link .

From: {user_name}
IP: {user_ip}

Report:

{send_report}

//===========================//

Target user profile: {user_profile_link}
(click on the user homepage link in the member's
profile).

This is an automated email message. DO NOT reply.

{site_name}
{site_email}

Hope is good english. I search this on google ... :|

// Step 4

In templates/your_template/member_profile.html file,

find:

Code: [Select]
<tr>
          <td class="row1"><b>{lang_homepage}</b></td>
          <td class="row1">{if user_homepage}<a href="{user_homepage}" target="_blank">{user_homepage}</a>{endif user_homepage}</td>
        </tr>

replace:

Code: [Select]
<tr>
          <td class="row1"><b>{lang_homepage}</b></td>
          <td class="row1">{if user_homepage}<a href="{user_homepage}" target="_blank">{user_homepage}</a><br /><a href="{url_user_homepage_report_link_from_profile}" class="link" />{lang_user_homepage_report_link_from_profile}</a>{endif user_homepage}</td>
        </tr>

// Step 5

In templates/your_template , create file: member_profile_user_homepage_report.html .

Add:

Code: [Select]
<form method="post" action="{url_exec_report_user_homepage_link}">
<input type="hidden" name="action" value="exec_report_user_homepage_link">
<input type="hidden" name="user_id" value="{user_id}">
<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 valign="top" class="row1"><a href="{url_go_back}">{lang_url_go_back}</a></td>          
        </tr>
        </table>
        <table width="100%" border="0" cellpadding="4" cellspacing="0">
        <tr>
          <td valign="top" class="head1">{lang_report_user_homepage_link_title}</td>          
        </tr>
        <tr>
          <td class="row1"><b>{lang_report_user_homepage_link}</b></td>
          <td class="row1">{user_homepage}</td>
        </tr>
        {if user_loggedout}
        <tr>
          <td class="row1"><b>{lang_report_user_email}</b></td>
          <td class="row1"><input type="text" name="user_email" class="input" /></td>
        </tr>
        {endif user_loggedout}
        <tr>
          <td class="row2"><b>{lang_report_user_homepage_reason}</b></td>
          <td class="row2"><textarea name="send_report" class="textarea" /></textarea></td>
        </tr>
        </table>
        <table width="100%" border="0" cellpadding="4" cellspacing="0">
        <tr>
          <td class="row1" align="center"><input type="submit" name="submit" value="{lang_submit}" class="button" /></td>
          <td class="row1" align="center"><input type="reset" name="reset" value="{lang_reset}" class="button" /></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>

// Is work

Member profile and see user homepage (if exist). See link: [ Report link ] after.

Finish.

5
This MOD is ban user homepage of user profile from ACP setting page. After add each domain, domain name is no show in profile or add in USERS_TABLE (url format fix include). ;)

// Step 1

In includes/functions.php file,

find:

Code: [Select]
function format_url($url) {
  if (empty($url)) {
    return '';
  }

  if (!preg_match("/^https?:\/\//i", $url)) {
    $url = "http://".$url;
  }

  return $url;
}

replace:

Code: [Select]
function format_url($url) {
    global $config;
    
    $ban_domain_name = $config['user_homepage_ban_list'];
    
    $url = preg_replace("/[^a-z0-9\_\-\/\.\:]+/i", "", $url);
    
    if (!preg_match("/[a-z0-9]+\.[a-z0-9_-]+\.[a-z]/i", $url)) {
        return '';
    }
    
    $flag = false;
    if (isset($config['use_user_homepage_ban_list']) && $config['use_user_homepage_ban_list'] == 1 && !empty($ban_domain_name)) {
        if (preg_match("/\www[0-9]\./", $url, $regs)) {
            $url = str_replace($regs[0], "", $url);          
        }
        $url = preg_replace("/http|https+/i", "", $url);
        $url = str_replace("://", "", $url);
        
        $ban_domain_name = explode(" ", $ban_domain_name);
        if (in_array($url, $ban_domain_name)) {          
            $url = "";
            $flag = true;          
        }      
    }
    if ($flag == false) {
        if (!preg_match("/^http?:\/\/\www.+[^a-z0-9_-]/i", $url)) {
            $url = preg_replace("/\www[0-9]\.+/i", "", $url);
            $url = "http://" . $url;
        } elseif (!preg_match("/^http?:\/\/\www.+[^a-z0-9_-]/i", $url)) {
            $url = "http://www." . $url;
        } elseif (!preg_match("/^http?:\/\/\/i", $url)) {
            $url = "http://" . $url;
        }
        return $url;
    }  
}

// Step 2

In admin/settings.php file,

find:

Code: [Select]
show_form_footer($lang['save_changes'], "", 2);

add before :

Code: [Select]
show_table_separator($setting_group[XX], 2, "setting_group_XX");
show_setting_row("use_user_homepage_ban_list", "radio");
show_setting_row("user_homepage_ban_list", "textarea");  

Replace XX in add code.

// Step 3

In lang/english/admin.php file,

add in top ?>:

Code: [Select]
/*-- Setting-Group XX --*/
$setting_group[XX] = "User homepage ban list";
$setting['use_user_homepage_ban_list'] = "Activate user homepage ban list";
$setting['user_homepage_ban_list'] = "Set user homepage to be ban from user's profile<br /><span class=\"smalltext\">(Note: E.g: <b>www.test.com www.test1.com</b> - <b>yes - 'www.' is go in front of each and space too for each add domain</b>)</span>.";

Replace XX in add code.

// Step 4

In SQL Patches plug in (expert mode),

add:

Code: [Select]
INSERT INTO `4images_settings` (setting_name, setting_value) VALUES ('use_user_homepage_ban_list', '0');

after, run this (same place):

Code: [Select]
INSERT INTO `4images_settings` (setting_name, setting_value) VALUES ('user_homepage_ban_list', '');

// Step 5

In lang/english/main.php file,

find:

Code: [Select]
$lang['homepage'] = "Homepage: ";

replace:

Code: [Select]
$lang['homepage'] = "Homepage:<br /><span class=\"smalltext\">(Note: If see blank homepage after submit form, is mean URL is ban from gallery)</span>";

// Is work

ACP - > Setting . Activate user homepage ban list and enter each URL (instruction left of textarea in ACP - > setting). ;)
See user profile (test account) . Try enter URL you ban, is work. ;)

Finish.

6
This is MOD no like other. Is good after restore backup (or switch server) and see if all images is there in server with single click.

1 - Is scan for thumbnails and media folder (in media) and match cat ID folder with cat_id CATEGORIES_TABLE and IMAGES_TABLE table.
2 - Is scan for match image filename in all thumbnails and media folder with IMAGES_TABLE table - image_thumb_file and image_media_file field.

If different for 1 or 2, is show error in HTML table and say count of error and show log of no correct or rename data in gallery (data folder - thumbnails and media with inside - sub-folder).

I create plug in file. ;)

If 1 and 2 is show all good in gallery, nothing is show in plug in file page for error. ;)

Note: PHP v5.2+ is need for this. If no get PHP version, ACP - > phpinfo() .
Note: Sub cat ID is no include (I try for code).

// Step 1

In admin/plugins folder, create file: images_gallery_diagnostic.php .

Add:

Code: [Select]
<?php // PLUGIN_TITLE: Images Gallery Diagnostic

$nozip 1;
define('IN_CP'1);
define('ROOT_PATH'"./../../");
require(
ROOT_PATH.'admin/admin_global.php');

show_admin_header();

if (
$action == "") {
    
$action "main_menu";
}

if (
$action == "main_menu") {
?>
   
        <form>
        <?php echo $lang['sql_fields_diagnostic_select_folder']; ?>
        <select name="users" onchange="showDirs(this.value)" class="select" />        
        <option>---</option>                    
        <option value="thumbnails">Thumbnails</option>
        <option value="media">Media</option>
        </select>
        </form>      
        
        <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
        <tr class="tableseparator">
        <td width="100%" class="tableheader">&nbsp;<?php echo $lang['images_gallery_diagnostic_title']; ?></td>
        </tr>
        <tr class="tableseparator">
        <td width="100%" class="tablerow">&nbsp;</td>
        </tr>
        <tr class="tableseparator">
        <td width="100%"><div id="dirHint">&nbsp;</div></td>
        </tr>        
        </table>
        <?php
}

if (
$action == "get_dirs") {
    
if (isset(
$HTTP_GET_VARS['dir_name'])) {
    
$dir_name = (isset($HTTP_GET_VARS['dir_name'])) ? get_basename(trim(stripslashes($HTTP_GET_VARS['dir_name']))) : "";
} else {
    
$dir_name "";
}
if (isset(
$dir_name) && empty($dir_name) || $dir_name == "---") {
    exit;
}
    
function 
scanDirectories($rootDir$allData = array()) {
    global 
$site_db$site_sess$lang$user_table_fields$config;
    
    
$sql "
    
    SELECT i.cat_id, i.image_date, i.image_thumb_file, i.image_media_file" 
get_user_table_field(", u.""user_id") . get_user_table_field(", u.""user_name") . "
    FROM (" 
IMAGES_TABLE " i, " CATEGORIES_TABLE " c)
    LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = i.user_id)
    WHERE i.cat_id = c.cat_id
    
    "
;
    
    
$image_row $site_db->query_firstrow($sql);
    
    
$cat_id = (int)$image_row['cat_id'];    
    
$image_date = (function_exists('get_universal_field_date')) ? get_universal_field_date($image_row['image_date']) : format_date($config['date_format'] . " " $config['time_format'], $image_row['image_date']);
    
$image_thumb_file get_file_name(basename($image_row['image_thumb_file']));
    
$image_media_file get_file_name(basename($image_row['image_media_file']));
    
$user_id = (int)$image_row[$user_table_fields['user_id']];
    
$user_name format_text(trim($image_row[$user_table_fields['user_name']]), 2);
    
    
// set filenames invisible if you want
    
$invisibleFileNames = array(".""..""index.html""index.htm""index.shtml""default.htm""default.html""default.shtml"".htaccess"".htpasswd");
    
    
// run through content of root directory
    
$dirContent = @scandir($rootDir);    
    
$error_files_counter "";
    
$error_files "";
    
$error_folders "";
    
    foreach (
$dirContent as $key => $content) {
        
        
// filter all files not accessible
        
$path $rootDir.'/'.$content;
        
        if (!
in_array($content$invisibleFileNames)) {
            
// if content is file & readable, add to array
            
            
if (is_file($path) && is_readable($path)) {
                
// save file name with path
                
$path str_replace(ROOT_PATH""$path);
                
$file_source preg_replace("/([a-z])+\/([a-z])+\/([0-9])+\/+/i"""$path);
            
                if (
preg_match("/(.+)\.(.+)/"get_file_name(basename($file_source)), $regs)) {
                    
$file_name $regs[1];
                    
$file_extension $regs[2];
                    
$full_file_name format_text(trim($regs[1] . "." $regs[2]), 2);                    
                }                
                if (isset(
$full_file_name) && !empty($full_file_name) && preg_match("/([a-z])+\/([a-z])+\/+/"$path$regs)) {                    
                    
$path_source substr(format_text(trim($regs[0]), 2), 0, -1);
                    
$path_source format_text(trim($path_source), 2);
                }                
                if (isset(
$path_source) && !empty($path_source) && preg_match("/([a-z])+\/([a-z])+\/([0-9])+\/+/"$path$regs)) {
                    
$folder_cat_id preg_replace("/[^0-9]+/i"""$regs[0]);
                    
$folder_cat_id format_text(trim($folder_cat_id), 2);
                }                
                if (isset(
$path_source) && isset($folder_cat_id) && isset($cat_id) && !is_dir(ROOT_PATH $path_source "/" $folder_cat_id) || (is_dir(ROOT_PATH $path_source "/" $folder_cat_id) && $folder_cat_id != $cat_id)) {
                    if (
sizeof($cat_id) > 0) {
                        
$use_cat_id $cat_id;
                        
$use_text = (str_replace(array("{use_cat_id}"), array($use_cat_id), $lang['images_gallery_diagnostic_use_cat_id']));
                    } elseif (
sizeof($folder_cat_id) > 0) {                        
                        
$use_cat_id $folder_cat_id;
                        
$use_text = (str_replace(array("{use_cat_id}"), array($folder_cat_id), $lang['images_gallery_diagnostic_use_folder_cat_id']));
                    } else {
                        
$use_cat_id "<>";
                    }
                    
$error_files_counter $key 1;
                    
$error_files .= "
                    &nbsp;" 
. (str_replace(array("{use_text}""{path_source}""{use_cat_id}""{images_table}"), array($use_text$path_source$use_cat_id$images_table), $lang['images_gallery_diagnostic_use_no_match_cat_id'])) 
                            . ((isset(
$image_thumb_file) && !empty($image_thumb_file)) ? (str_replace(array("{image_thumb_file}""{images_table}"), array($image_thumb_fileIMAGES_TABLE), $lang['images_gallery_diagnostic_use_if_thumb_file_found'])) : ""
                            . ((
$full_file_name == $image_thumb_file || $full_file_name == $image_media_file) ? (str_replace(array("{user_profile_link}"), array("<a href=\"" $site_sess->url(ROOT_PATH "member.php?action=showprofile&" URL_USER_ID "=" $user_id) . "\" target=\"_blank\">" $user_name "</a>"), $lang['images_gallery_diagnostic_use_user_profile_link'])) : ""
                            . ((isset(
$image_thumb_file) && !empty($image_thumb_file)) ? (str_replace(array("{use_text}""{image_thumb_file}"), array($use_text$image_thumb_file), $lang['images_gallery_diagnostic_another_if_thumb_file_found'])) : ""
                            . ((isset(
$full_file_name) && isset($image_thumb_file) && isset($folder_cat_id) && isset($path_source) && $full_file_name == $image_thumb_file) ? (str_replace(array("{path_source}""{folder_cat_id}"), array($path_source$folder_cat_id), $lang['images_gallery_diagnostic_use_match_filenames'])) : ".") . "<br />";
                    break;
                } elseif (isset(
$image_thumb_file) && isset($image_media_file) && isset($full_file_name) && isset($folder_cat_id) && $full_file_name != $image_thumb_file || $full_file_name != $image_media_file) {
                    if (
sizeof($full_file_name) > 0) {
                        
$use_file_name $full_file_name;
                    } elseif (
sizeof($image_thumb_file) > 0) {
                        
$use_file_name $image_thumb_name;
                    } elseif (
sizeof($image_media_file) > 0) {                        
                        
$use_file_name $image_media_name;
                    }
                    
$error_files_counter $key 2;                    
                    
$error_files .= (str_replace(array("{path_source}""{folder_cat_id}"), array($path_source$folder_cat_id), $lang['images_gallery_diagnostic_use_file_name'])) . ((isset($use_file_name) && !empty($use_file_name)) ? (str_replace(array("{use_file_name}""{images_table}"), array($use_file_nameIMAGES_TABLE), $lang['images_gallery_diagnostic_use_another_file_name'])) : "<>") . "<br />";
                }
                
                
// if content is a directory and readable, add path and name
                
} elseif (is_dir($path) && is_readable($path)) {                    
                    
// recursive callback to open new directory                                    
                    
echo scanDirectories($path$allData);                
                }                    
        }        
    }
    if (
$error_files_counter 0) {
        
?>

        <table border="0" width="75%" cellpadding="0" class="tableborder" />
        <tr class="tableseparator">
        <td width="75%" align="left" class="tableheader" /><?php echo (str_replace(array("{error_files_counter}"), array($error_files_counter), $lang['images_gallery_diagnostic_use_error_title'])); ?></td>
        </tr>        
        <tr>
        <td width="75%" align="left" class="tablerow" /><br /><?php echo $error_files?><br /></td>
        </tr>                
        </table>
        <?php
    
}
}
// End function.
    
    
?>

    <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
    <tr class="tableseparator">
    <td width="100%" class="tablerow" align="center"><?php echo scanDirectories(ROOT_PATH "data/" $dir_name); ?></td>    
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tablerow">&nbsp;</td>
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;</td>            
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tablerow"><br /><span class=\"smalltext\"><b>Images Gallery Diagnostic MOD</b> - created by <a href="http://www.4homepages.de/forum/index.php?topic=19856.0" target="_blank" />Thunderstrike</a> - 2007-2008<br />Version 1.0</span><br /><br /></td>
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" class="tableheader">&nbsp;</td>            
    </tr>
    </table>
    <?php
}

show_admin_footer();
?>


// Step 2

In lang/english/main.php file,

add in top ?>:

Code: [Select]
//-----------------------------------------------------
//--- Image Gallery Diagnostic ------------------------
//-----------------------------------------------------
$lang['images_gallery_diagnostic_title'] = "Images Gallery Diagnostic";
$lang['sql_fields_diagnostic_select_folder'] = "Select a folder: ";
$lang['images_gallery_diagnostic_use_error_title'] = "Error(s) found: {error_files_counter}";
$lang['images_gallery_diagnostic_use_cat_id'] = "cat ID value: {use_cat_id}";
$lang['images_gallery_diagnostic_use_folder_cat_id'] = "folder cat ID value: {use_cat_id}";
$lang['images_gallery_diagnostic_use_no_match_cat_id'] = "Cannot find <b>{use_text}</b> under FTP folder: {path_source}/<b>{use_cat_id}</b> and / or in <b>{images_table}</b> table";
$lang['images_gallery_diagnostic_use_if_thumb_file_found'] = ". <b>{image_thumb_file}</b> file has been found in &nbsp;<b>{images_table}</b>&nbsp;table";
$lang['images_gallery_diagnostic_use_user_profile_link'] = "<br />&nbsp;(uploaded by: {user_profile_link}).";
$lang['images_gallery_diagnostic_another_if_thumb_file_found'] = " Matched <b>{use_text}</b> for: <b>{image_thumb_file}</b> file.";
$lang['images_gallery_diagnostic_use_match_filenames'] = " ID matched on FTP: {path_source}/<b><font color=\"red\">{folder_cat_id}</font></b><br />";
$lang['images_gallery_diagnostic_use_file_name'] = "&nbsp;Cannot find file {path_source}/{folder_cat_id}";
$lang['images_gallery_diagnostic_use_another_file_name'] = "/<b>{use_file_name}</b> under FTP and / or in <b>{images_table}</b> table.";

I ask friend for english text, hope is good ...  :|

// Step 3

In admin/admin_functions.php file,

find:

Code: [Select]
<script type="text/javascript" language="javascript" src="<?php echo ROOT_PATH?>admin/calendar.js"></script>

add after:

Code: [Select]
<?php
    
// MOD: SQL Fields Diagnostic
    
if (preg_match("/images_gallery_diagnostic.php/"$self_url)) {
        
?>

        <script src="<?php echo ROOT_PATH?>admin/images_gallery_diagnostic.js"></script>
        <?php
    
// End of MOD: SQL Fields Diagnostic    
    
}
    
?>


// Step 4

In admin, create file: images_gallery_diagnostic.js ,

add:

Code: [Select]
var xmlHttp

function showDirs(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="./../../admin/plugins/images_gallery_diagnostic.php"
url=url+"?action=get_dirs&dir_name="+str
//url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById("dirHint").innerHTML=xmlHttp.responseText
 }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

Screenshot 1: If rename one cat_id folder in thumbnails folder and is no match for CATEGORIES_TABLE table (cat_id field), is show error message in plug in page. Is say cat ID detect in CATEGORIES_TABLE and IMAGES_TABLE but cat ID folder in FTP is 4 and match is 2. ;)

Screenshot 2: If upload image name in FTP and is no see in IMAGES_TABLE table, error is show in plug in page.

Finish.

7
Feedback & Suggestions / [FIX 1.7.5] - categories.php file (by order)
« on: January 17, 2008, 03:30:28 AM »
Is fix for order by prefix name with field.

In categories.php file,

find:

Code: [Select]
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort']."

replace:

Code: [Select]
ORDER BY i.".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."

8
This is VERY IMPORTANT fix :!:

Jan is code format_url function for check https:// and http:// protocol but rational chars is no check. Is say if empty, nothing is show in member profile for user_homepage field but if user enter no valid chars URL type, is still show. E.g: http://www. ... where is full URL ?  8O

So - I create fix (and include fix for check http and https). ;)

In includes/functions.php file,

find:

Code: [Select]
function format_url($url) {
  if (empty($url)) {
    return '';
  }

  if (!preg_match("/^https?:\/\//i", $url)) {
    $url = "http://".$url;
  }

  return $url;
}

replace:

Code: [Select]
function format_url($url) {
  $url = preg_replace("/[^a-z0-9\_\-\/\.\:]+/i", "", $url);
 
  if (!preg_match("/[a-z0-9]+\.[a-z0-9_-]+\.[a-z]/i", $url)) {
      return '';
  }

  if (!preg_match("/^http|https?:\/\//i", $url)) {
    $url = "http://".$url;
  }
 
  return $url;
}

After install fix:

1 - No possible for add empty URL, no valid chars or no full URL (http or https - no matter).
2 - Save ressource for member editprofile page (USERS_TABLE update SQL query). Empty result is no use action for update SQL query.

:)

9
This is fix for EXIF format_text if use: {exif_value} in template.

In includes/functions.php file,

find:

Code: [Select]
"exif_value" => format_text($val),

replace:

Code: [Select]
"exif_value" => format_text($val, 1),

10
This is MOD for see all upload today image in gallery index page (paging include). ;)

// Step 1

In index.php file,

find:

Code: [Select]
$site_template->register_vars("new_images", $new_images);
unset($new_images);

add after:

Code: [Select]
//-----------------------------------------------------
//--- Show Today Images -------------------------------
//-----------------------------------------------------

$today_images = time() - 60 * 60 * 24 * 1;
$sql = "SELECT COUNT(*) AS num_rows_all
        FROM (" . IMAGES_TABLE . " i, " . CATEGORIES_TABLE . " c)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.image_date >= " . $today_images . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ";
       
$row = $site_db->query_firstrow($sql);
$num_rows_all = (isset($row['num_rows_all'])) ? $row['num_rows_all'] : 0;

$link_arg = $site_sess->url(ROOT_PATH."index.php");

include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => (isset($num_rows_all) && $num_rows_all > 0) ? $getpaging->get_paging_stats() : ""
));


$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.image_date >= " . $today_images . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT " . $offset . ", " . $perpage;
       
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $today_new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $today_new_images .= $lang['no_today_images'];
  $today_new_images .= "</td></tr></table>";
}
else  {
  $today_new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)) {
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $today_new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $today_new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $today_new_images .= $site_template->parse_template("thumbnail_bit");
    $today_new_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $today_new_images .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $today_new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $today_new_images .= "</tr>\n";
    }
  }
  $today_new_images .= "</table>\n";
} // end else

$site_template->register_vars("today_images", $today_new_images);
unset($today_new_images);

// Step 2

In includes/page_header.php file,

find:

Code: [Select]
"lang_new_images" => $lang['new_images'],

add after:

Code: [Select]
"lang_today_images" => $lang['today_images'],

// Step 3

In lang/english/main.php file,

find:

Code: [Select]
$lang['new_images'] = "New images";

add after:

Code: [Select]
$lang['today_images'] = "Today images";
$lang['no_today_images'] = "There are no daily images at this time.";

// Step 4

In templates/your_template/home.html file,

find:

Code: [Select]
<tr>
                      <td class="head1">{new_images}</td>
                    </tr>                   
                  </table>

add after:

Code: [Select]
{if today_images}
                  <br />
                   <table width="450" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="head1" valign="top">{lang_today_images}</td>
                          </tr>
                        </table>
                        {if paging_stats}
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="row2" valign="top" align="center"><br />{paging_stats}<br /><br /></td>
                          </tr>                         
                        </table>
                        {endif paging_stats}
                        {if paging}
                        <table width="100%" border="0" cellspacing="0" cellpadding="4">
                          <tr>
                            <td class="row2" valign="top" align="right">{paging}&nbsp;</td>
                          </tr>                         
                        </table>
                        {endif paging}
                      </td>
                    </tr>
                    <tr>
                      <td class="head1">{today_images}</td>
                    </tr>                   
                  </table>
                  {endif today_images}

Finish.

11
Hi,

I like MOD so much - I publish FREE ! ;)
Some user is ask this before in forum. Is plan I code today. Is look right.

// Is do ?

MOD is check for today and yesterday (day before - I find definition !! :)). If upload date for image is same day now, is say: today . If user upload image day before - is say: yesterday image date. After 48 hour, is back for normal date. ;)

// Universal ?

This is right. Is no single 4images. Use for all MOD in forum with use: format_date and replace . ;)
Note: date field is MUST for microtime type.

// Test ?

Yes - here: http://www.4homepages.de/forum/index.php?topic=9598.msg109730#msg109730

[v1.0 - 01/12/2008]

Please backup all file:

- member.php
- details.php
- lightbox.php
- admin/home.php
- admin/users.php
- admin/admin_functions.php
- admin/images.php
- admin/comments.php
- admin/validateimages.php
- includes/functions.php

// Step 1

In member.php file

find:

Code: [Select]
"user_join_date" => (isset($user_row['user_joindate'])) ? format_date($config['date_format'], $user_row['user_joindate']) : REPLACE_EMPTY,
"user_last_action" => (isset($user_row['user_lastaction'])) ? format_date($config['date_format']." ".$config['time_format'], $user_row['user_lastaction']) : REPLACE_EMPTY,

replace:

Code: [Select]
"user_join_date" => (isset($user_row['user_joindate'])) ? get_universal_field_date($user_row['user_joindate']) : REPLACE_EMPTY,
"user_last_action" => (isset($user_row['user_lastaction'])) ? get_universal_field_date($user_row['user_lastaction']) : REPLACE_EMPTY,

// Step 2

In details.php file,

find:

Code: [Select]
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".format_date($config['date_format'], $comment_row[$i][$user_table_fields['user_joindate']]) : "";

replace:

Code: [Select]
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".get_universal_field_date($comment_row[$i][$user_table_fields['user_joindate']]) : "";

// Step 2.1

find:

Code: [Select]
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),

replace:

Code: [Select]
"comment_date" => get_universal_field_date($comment_row[$i]['comment_date']),

// Step 3

In lightbox.php file,

find:

Code: [Select]
$lightbox_lastaction = format_date($config['date_format']." ".$config['time_format'], $user_info['lightbox_lastaction']);

replace:

Code: [Select]
$lightbox_lastaction = get_universal_field_date($user_info['lightbox_lastaction']);

// Step 4

In admin/home.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $row[$user_table_fields['user_lastaction']])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($row[$user_table_fields['user_lastaction']])."</td>\n";

// Step 4.1

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $row['session_lastaction'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($row['session_lastaction'])."</td>\n";

// Step 5

In admin/users.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $user_row[$user_table_fields['user_joindate']])."</td>\n";
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $user_row[$user_table_fields['user_lastaction']])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($user_row[$user_table_fields['user_joindate']])."</td>\n";
echo "<td>".get_universal_field_date($user_row[$user_table_fields['user_lastaction']])."</td>\n";

// Step 6

In admin/admin_functions.php file,

add in top ?>:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $date_separator = preg_replace("/[a-zA-Z]+/i", "", $config['date_format']);               
       
        $day = getdate();
       
        // Today date.       
        $today_image_date = format_date($config['date_format'], $image_date);
       
        if ($config['date_format'][0] == "d" && $config['date_format'][2] == "m" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'];           
           
        } elseif ($config['date_format'][0] == "d" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);
       
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "d" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'] . $date_separator[0] . $day['year'];
           
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'] . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "m" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "d" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);           
        }
       
        $yesterday_upload = format_date($config['date_format'], time() + 60 * 60 * 24 * 1);       
               
        // Show today image date if uploaded in same day.
        if ($today == $today_upload_image) {
            return str_replace(array("{uploaded_today_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        } elseif ($today_upload_image == $yesterday_upload) {
            $calc_past_upload = $yesterday_upload - $today + 1 - 1;           
            if ($calc_past_upload == 1) {
                return str_replace(array("{uploaded_yesterday_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
            }
       
        } elseif ($today_upload_image > $yesterday_upload || $today_upload_image < $yesterday_upload) {
            return format_date($config['date_format'] . " " . $config['time_format'], $image_date);           
        }
    }   
}

// Step 7

In admin/images.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format'], $image_row['image_date'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($image_row['image_date'])."</td>\n";

// Step 8

In admin/comments.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $comment_row['comment_date'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($comment_row['comment_date'])."</td>\n";

// Step 9

In admin/validateimages.php file,

find:

Code: [Select]
echo "<td>".format_date($config['date_format']." ".$config['time_format'], $image_row['image_date'])."</td>\n";

replace:

Code: [Select]
echo "<td>".get_universal_field_date($image_row['image_date'])."</td>\n";

// Step 10

In includes/functions.php file,

add in top ?>:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $date_separator = preg_replace("/[a-zA-Z]+/i", "", $config['date_format']);               
       
        $day = getdate();
       
        // Today date.       
        $today_image_date = format_date($config['date_format'], $image_date);
       
        if ($config['date_format'][0] == "d" && $config['date_format'][2] == "m" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'];           
           
        } elseif ($config['date_format'][0] == "d" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['mday'] . $date_separator[0] . $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);
       
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "d" && $config['date_format'][4] == "Y") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $date_separator[0] . $today_image_date[6] . $today_image_date[7] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'] . $date_separator[0] . $day['year'];
           
        } elseif ($config['date_format'][0] == "m" && $config['date_format'][2] == "Y" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $date_separator[0] . $today_image_date[3] . $today_image_date[4] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['year'] . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "m" && $config['date_format'][4] == "d") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']) . $date_separator[0] . $day['mday'];
           
        } elseif ($config['date_format'][0] == "Y" && $config['date_format'][2] == "d" && $config['date_format'][4] == "m") {
            $today_upload_image = $today_image_date[0] . $today_image_date[1] . $today_image_date[2] . $today_image_date[3] . $date_separator[0] . $today_image_date[5] . $today_image_date[6] . $date_separator[0] . $today_image_date[8] . $today_image_date[9];
            $today = $day['year'] . $date_separator[0] . $day['mday'] . $date_separator[0] . (($day['mon'] < 10) ? "0" . $day['mon'] : $day['mon']);           
        }
       
        $yesterday_upload = format_date($config['date_format'], time() + 60 * 60 * 24 * 1);       
               
        // Show today image date if uploaded in same day.
        if ($today == $today_upload_image) {
            return str_replace(array("{uploaded_today_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        } elseif ($today_upload_image == $yesterday_upload) {
            $calc_past_upload = $yesterday_upload - $today + 1 - 1;           
            if ($calc_past_upload == 1) {
                return str_replace(array("{uploaded_yesterday_date}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
            }
       
        } elseif ($today_upload_image > $yesterday_upload || $today_upload_image < $yesterday_upload) {
            return format_date($config['date_format'] . " " . $config['time_format'], $image_date);           
        }
    }   
}

// Step 11

In lang/english/main.php file,

add in top ?>:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at: {uploaded_today_date}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> at: {uploaded_yesterday_date}";

// INTEGRATION

If use memberlist:

In memberlist.php file,

find:

Code: [Select]
format_date($config['date_format'], $user_row['user_joindate'])

replace:

Code: [Select]
get_universal_field_date($user_row[$user_table_fields['user_joindate']])

[v1.1 - upgrade - 01/13/2008]

I code upgrade (fix include with addon) .

// Is do ?

Is now say: today, yesterday, x days ago (if image is old - start of 2 days), x day(s) in near future (if image date is change from image owner or admin for after same day upload date). :)

// Upgrade file:

- includes/functions.php.
- admin/admin_functions.php
- lang/english/main.php

// Step 1

In includes/functions.php file,

replace full function with this:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $start_time = $image_date;
        $now = time();
       
        $total_secs = ($now - $start_time);
        $total_days = intval($total_secs / 86400);       
           
        // Show today image date if uploaded in same day.       
        if ($total_days == 0) {
            return str_replace(array("{uploaded_today_time}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        // Show yesterday image (if upload yesterday).
        } elseif ($total_days == 1) {
            return str_replace(array("{uploaded_yesterday_date}", "{uploaded_yesterday_time}"), array(format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
           
        // Show after 2 days image upload date.
        } elseif ($total_days > 1) {                       
            return str_replace(array("{total_days}", "{uploaded_days_ago_date}", "{uploaded_days_ago_time}"), array($total_days, format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_days_ago']);
               
        // Show invalid date set from image owner or admin (if set after date upload).
        } else {
            $total_days = preg_replace("/[^0-9]+/i", "", $total_days);
            return str_replace(array("{total_days}"), array($total_days), $lang['uploaded_images_near_future']);
        }
    }   
}

// Step 2

Replace full function but with this:

Code: [Select]
if (!function_exists('get_universal_field_date')) {
    function get_universal_field_date($image_date) {
        global $lang, $config;
       
        $start_time = $image_date;
        $now = time();
       
        $total_secs = ($now - $start_time);
        $total_days = intval($total_secs / 86400);       
           
        // Show today image date if uploaded in same day.       
        if ($total_days == 0) {
            return str_replace(array("{uploaded_today_time}"), array(format_date($config['time_format'], $image_date)), $lang['uploaded_images_today']);
           
        // Show yesterday image (if upload yesterday).
        } elseif ($total_days == 1) {
            return str_replace(array("{uploaded_yesterday_date}", "{uploaded_yesterday_time}"), array(format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_yesterday']);
           
        // Show after 2 days image upload date.
        } elseif ($total_days > 1) {                       
            return str_replace(array("{total_days}", "{uploaded_days_ago_date}", "{uploaded_days_ago_time}"), array($total_days, format_date($config['date_format'], $image_date), format_date($config['time_format'], $image_date)), $lang['uploaded_images_days_ago']);
               
        // Show invalid date set from image owner or admin (if set after date upload).
        } else {
            $total_days = preg_replace("/[^0-9]+/i", "", $total_days);
            return str_replace(array("{total_days}"), array($total_days), $lang['uploaded_images_near_future']);
        }
    }   
}

// Step 3

In lang/english/main.php file,

find:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at {uploaded_today_date}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> at {uploaded_yesterday_date}";

add after:

Code: [Select]
$lang['uploaded_images_days_ago'] = "<b>{calc_distant_days} days ago</b> at: {uploaded_days_ago_time}";
$lang['uploaded_images_near_future'] = "<b>{calc_distant_days}</b> day(s) in the near future";

[v1.1 - End upgrade - 01/13/2008]

[v1.2 - Upgrade - 01/13/2008]

Do same thing for v1.1 (replace code in includes/functions.php and admin/functions.php file). Fix and addon. Function is small for same thing now. ;)

Note: I post screenshot. ;)

After - in lang/english/main.php file,

find:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at {uploaded_today_date}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> at {uploaded_yesterday_date}";
$lang['uploaded_images_days_ago'] = "<b>{calc_distant_days} days ago</b> at: {uploaded_days_ago_time}";
$lang['uploaded_images_near_future'] = "<b>{calc_distant_days}</b> day(s) in the near future";

replace:

Code: [Select]
$lang['uploaded_images_today'] = "<b>Today</b> at {uploaded_today_time}";
$lang['uploaded_images_yesterday'] = "<b>Yesterday</b> ({uploaded_yesterday_date}) at {uploaded_yesterday_time}";
$lang['uploaded_images_days_ago'] = "<b>{total_days} days ago</b> ({uploaded_days_ago_date}) at {uploaded_days_ago_time}";
$lang['uploaded_images_near_future'] = "<b>{total_days}</b> day(s) in the near future";

Screenshot 1: Today image date.
Screenshot 2: Yesterday image date.
Screenshot 3: If more 2 day upload image date.
Screenshot 4: If image owner or admin is set image date day after today.

[v1.2 - End upgrade - 01/13/2008]

Finish.

12
Wooooh  8O
I like :)

// Step 1

In top.php file,

in // Rating block -

find:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"

replace:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."&top_list_rating=1&top_list_position=" . $i . "\"

in // Votes block -

find:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"

replace:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."&top_list_votes=1&top_list_position=" . $i . "\"

in // Hits block -

find:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"

replace:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."&top_list_hits=1&top_list_position=" . $i . "\"

in // Downloads block -

find:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"

replace:

Code: [Select]
".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."&top_list_downloads=1&top_list_position=" . $i . "\"

// Step 2

In details.php file,

find:

Code: [Select]
if (!$image_id) {
    redirect($url);
}

add after:

Code: [Select]
if (preg_match("/top.php/", $url)) {
   if (isset($HTTP_GET_VARS['top_list_rating']) || isset($HTTP_POST_VARS['top_list_rating'])) {
      $top_list_rating = (isset($HTTP_GET_VARS['top_list_rating'])) ? intval(trim($HTTP_GET_VARS['top_list_rating'])) : intval(trim($HTTP_POST_VARS['top_list_rating']));
   } else {
      $top_list_rating = 0;
   }

   if (isset($HTTP_GET_VARS['top_list_votes']) || isset($HTTP_POST_VARS['top_list_votes'])) {
      $top_list_votes = (isset($HTTP_GET_VARS['top_list_votes'])) ? intval(trim($HTTP_GET_VARS['top_list_votes'])) : intval(trim($HTTP_POST_VARS['top_list_votes']));
   } else {
      $top_list_votes = 0;
   }

   if (isset($HTTP_GET_VARS['top_list_hits']) || isset($HTTP_POST_VARS['top_list_hits'])) {
      $top_list_hits = (isset($HTTP_GET_VARS['top_list_hits'])) ? intval(trim($HTTP_GET_VARS['top_list_hits'])) : intval(trim($HTTP_POST_VARS['top_list_hits']));
   } else {
      $top_list_hits = 0;
   }

   if (isset($HTTP_GET_VARS['top_list_downloads']) || isset($HTTP_POST_VARS['top_list_downloads'])) {
      $top_list_downloads = (isset($HTTP_GET_VARS['top_list_downloads'])) ? intval(trim($HTTP_GET_VARS['top_list_downloads'])) : intval(trim($HTTP_POST_VARS['top_list_downloads']));
   } else {
      $top_list_downloads = 0;
   }

   if (isset($HTTP_GET_VARS['top_list_position']) || isset($HTTP_POST_VARS['top_list_position'])) {
      $top_list_position = (isset($HTTP_GET_VARS['top_list_position'])) ? intval(trim($HTTP_GET_VARS['top_list_position'])) : intval(trim($HTTP_POST_VARS['top_list_position']));
   } else {
      $top_list_position = 0;
   }
}

// Step 3

In includes/functions.php file,

find:

Code: [Select]
global $self_url,

add after (same line):

Code: [Select]
$top_list_rating, $top_list_votes, $top_list_hits, $top_list_downloads, $top_list_position,

find:

Code: [Select]
"thumbnail_openwindow" => get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, 1),

add after:

Code: [Select]
"top_list_position" => (preg_match("/top.php/", $self_url) && isset($top_list_rating) && $top_list_rating == 1 || isset($top_list_votes) && $top_list_votes == 1 || isset($top_list_hits) && $top_list_hits == 1 || isset($top_list_downloads) && $top_list_downloads == 1 && isset($top_list_position) && $top_list_position > 0) ? true : false,
"lang_top_list_position_title" => $lang['top_list_position_title'],
"lang_top_list_rating" => (isset($top_list_rating) && $top_list_rating == 1 && isset($top_list_position) && $top_list_position > 0) ? preg_replace("/" . $site_template->start . "top_list_position" . $site_template->end . "/siU", $top_list_position, $lang['top_list_rating_position']) : "",
"lang_top_list_votes" => (isset($top_list_votes) && $top_list_votes == 1 && isset($top_list_position) && $top_list_position > 0) ? preg_replace("/" . $site_template->start . "top_list_position" . $site_template->end . "/siU", $top_list_position, $lang['top_list_votes_position']) : "",
"lang_top_list_hits" => (isset($top_list_hits) && $top_list_hits == 1 && isset($top_list_position) && $top_list_position > 0) ? preg_replace("/" . $site_template->start . "top_list_position" . $site_template->end . "/siU", $top_list_position, $lang['top_list_hits_position']) : "",
"lang_top_list_downloads" => (isset($top_list_downloads) && $top_list_downloads == 1 && isset($top_list_position) && $top_list_position > 0) ? preg_replace("/" . $site_template->start . "top_list_position" . $site_template->end . "/siU", $top_list_position, $lang['top_list_downloads_position']) : "",

// Step 4

In lang/english/main.php file,

add in top ?>:

Code: [Select]
$lang['top_list_position_title'] = "Image position in top list";
$lang['top_list_rating_position'] = "This image is on position: <b>{top_list_position}</b> for ranking.";
$lang['top_list_votes_position'] = "This image is on position: <b>{top_list_position}</b> for votes.";
$lang['top_list_hits_position'] = "This image is on position: <b>{top_list_position}</b> for hits.";
$lang['top_list_downloads_position'] = "This image is on position: <b>{top_list_position}</b> for downloads.";

// Step 5

In templates/your_template/details.html file, design HTML table and use this - way you want:

Code: [Select]
{if top_list_position}
{if lang_top_list_rating}{lang_top_list_rating}{endif lang_top_list_rating}
{if lang_top_list_votes}{lang_top_list_votes}{endif lang_top_list_votes}
{if lang_top_list_hits}{lang_top_list_hits}{endif lang_top_list_hits}
{if lang_top_list_downloads}{lang_top_list_downloads}{endif lang_top_list_downloads}
{endif top_list_position}

;)

13
Hi, in forum - is BIG search for how integrate cookie of other MOD (forum) for ALL cookie prefix in includes/sessions.php file. Now - search finish. :twisted:
Tweak check for sequential cookie name you add in array. ;)

In includes/sessions.php file,

find:

Code: [Select]
//-----------------------------------------------------
//--- Start Session -----------------------------------
//-----------------------------------------------------
define('COOKIE_NAME', '4images_');
define('COOKIE_PATH', '');
define('COOKIE_DOMAIN', '');
define('COOKIE_SECURE', '0');

replace:

Code: [Select]
//-----------------------------------------------------
//--- Start Session -----------------------------------
//-----------------------------------------------------
//define('COOKIE_NAME', '4images_');
//define('COOKIE_PATH', '');
//define('COOKIE_DOMAIN', '');
//define('COOKIE_SECURE', '0');

$cookie_name = array("4images_");
$cookie_path = array("");
$cookie_domain = array("");
$cookie_secure = array("0");

Find:

Code: [Select]
function set_cookie_data($name, $value, $permanent = 1) {
      global $HTTP_COOKIE_VARS;
    $cookie_expire = ($permanent) ? $this->current_time + 60 * 60 * 24 * 365 : 0;
    $cookie_name = COOKIE_NAME.$name;
    setcookie($cookie_name, $value, $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
    $HTTP_COOKIE_VARS[$cookie_name] = $value;
  }

replace:

Code: [Select]
function set_cookie_data($name, $value, $permanent = 1) {
      global $HTTP_COOKIE_VARS, $cookie_name, $cookie_path, $cookie_domain, $cookie_secure;     
     
      if (isset($cookie_name) && is_array($cookie_name) && !empty($cookie_name)) {
          $cookie_name_array = array();
          foreach ($cookie_name as $key => $val) {
              $cookie_name_array[] = $val;
          }
      }
     
      if (isset($cookie_path) && is_array($cookie_path)) {
          $cookie_path_array = array();
          foreach ($cookie_path as $key => $val) {
              $cookie_path_array[] = $val;
          }
      }

      if (isset($cookie_domain) && is_array($cookie_domain)) {
          $cookie_domain_array = array();
          foreach ($cookie_domain as $key => $val) {
              $cookie_domain_array[] = $val;
          }
      }
     
      if (isset($cookie_secure) && is_array($cookie_secure) && !empty($cookie_name)) {
          $cookie_secure_array = array();
          foreach ($cookie_secure as $key => $val) {
              $cookie_secure_array[] = $val;
          }
      }
     
      $num_cookie_name = (isset($cookie_name_array)) ? sizeof($cookie_name_array) : "";
      $num_cookie_path = (isset($cookie_path_array)) ? sizeof($cookie_path_array) : "";
      $num_cookie_domain = (isset($cookie_domain_array)) ? sizeof($cookie_domain_array) : "";
      $num_cookie_secure = (isset($cookie_secure_array)) ? sizeof($cookie_secure_array) : "";

      $cookie_expire = ($permanent) ? $this->current_time + 60 * 60 * 24 * 365 : 0;
     
      for ($i = 0; $i < $num_cookie_name; $i++) {   
          $each_cookie_name = $cookie_name_array[$i] . $name;
          for ($j = 0; $j < $num_cookie_path; $j++) {       
              $each_cookie_path = $cookie_path_array[$i];
              for ($k = 0; $k < $num_cookie_domain; $k++) {           
                  $each_cookie_domain = $cookie_domain_array[$i];
                  for ($l = 0; $l < $num_cookie_secure; $l++) {
                      $each_cookie_secure = $cookie_secure_array[$i];
                      setcookie($each_cookie_name, $value, $cookie_expire, $each_cookie_path, $each_cookie_domain, $each_cookie_secure);
                      $HTTP_COOKIE_VARS[$each_cookie_name] = $value;
                      break;
                  }
                  break;
              }       
              break;       
          }
      }
      unset ($cookie_secure_array);
      unset ($cookie_domain_array);
      unset ($cookie_path_array);
      unset ($cookie_name_array);
  }

find:

Code: [Select]
function read_cookie_data($name) {
    global $HTTP_COOKIE_VARS;
    $cookie_name = COOKIE_NAME.$name;
    return (isset($HTTP_COOKIE_VARS[$cookie_name])) ? $HTTP_COOKIE_VARS[$cookie_name] : false;
  }

replace:

Code: [Select]
function read_cookie_data($name) {     
    global $HTTP_COOKIE_VARS, $cookie_name;
   
    if (isset($cookie_name) && is_array($cookie_name) && !empty($cookie_name)) {
        foreach ($cookie_name as $key => $val) {
            $each_cookie_name = $val . $name;
            return (isset($HTTP_COOKIE_VARS[$each_cookie_name])) ? $HTTP_COOKIE_VARS[$each_cookie_name] : false;
        }
    }
  }

// How:

Ok, e.g (NO REAL PREFIX :!: - is e.g) - for phpbb.

Quote
$cookie_name = array("4images_", "phpbb_");
$cookie_path = array("", "path_phpbb");
$cookie_domain = array("", "domain_phpbb");
$cookie_secure = array("0", "cookie_secure_value_phpbb"); // (1 for phpbb - e.g).

Note: Cookie name is must same name prefix for real phpbb.

Now - is easy for add table prefix in config and includes/constants.php + SQL table in includes/sessions.php file for check session. ;)

14
Feedback & Suggestions / [FIX] - includes/sessions.php file
« on: December 29, 2007, 06:37:03 PM »
Is problem with cookie create (is possible for create problem for user login if no add fix).

In includes/sessions.php file,

find:

Code: [Select]
function set_cookie_data($name, $value, $permanent = 1) {

add after:

Code: [Select]
global $HTTP_COOKIE_VARS;

15
Feedback & Suggestions / [NEWS] - PHP v5.25
« on: December 27, 2007, 06:19:55 PM »
Hi,

this is important news from php.net for upgrade to PHP v5.25 (if use PHP > 4 and PHP < 5.25) . This is fix include and problem big on forum for move upload file:

Quote
# Fixed move_uploaded_file() to always set file permissions of resulting file according to UMASK. (Andrew Sitnikov)

Jan is use umask with 4images for file transfer.

[edit] - $script_url is include with problem for 4images:

Quote
Fixed bug #42523 (PHP_SELF duplicates path)

Upgrade to PHP v5.25 is fix problem. ;)

Pages: [1] 2 3 4 5 ... 7