Author Topic: Enter any additional comments to a moderated photo. validateimages.php  (Read 4594 times)

0 Members and 1 Guest are viewing this topic.

Offline bma2004

  • Newbie
  • *
  • Posts: 32
    • View Profile
Hi!
Make modifications allowing to enter comments to scanned photos. And faced with the problem of how to pass data from intput fields when adding / removing.

Added to the code action == "validateimages" checkbox and the input line
while ($image_row $site_db->fetch_array($result)) {
      echo 
"<tr class=\"".get_row_bg()."\">";

      
$image_path = (is_remote($image_row['image_media_file'])) ? $image_row['image_media_file'] : MEDIA_TEMP_PATH."/".$image_row['image_media_file'];
      
$file_src get_file_path($image_row['image_media_file'], "media"01);

      echo 
"<td ROWSPAN=3><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"1\" ></td>";
      echo 
"<td ROWSPAN=3 ><input type=\"radio\" name=\"image_list[".$image_row['image_id']."]\" value=\"0\" ></td>";
      echo 
"<td  ROWSPAN=3><a href=\"".$image_path."\" target=\"_blank\"><img src=\"".$file_src."\" border=\"1\" height=\"50\"></a></td>";
      echo 
"<td><b><a href=\"".$image_path."\" target=\"_blank\">".format_text($image_row['image_name'], 2)."</a></b> </td>\n";
	
   echo 
"<td>".format_text($image_row['image_Mesto'], 2)."</td>";
	
   echo 
"<td>".format_text($image_row['image_NOmarsh'], 2)."</td>";
      echo 
"<td><a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$image_row['cat_id'])."\" target=\"_blank\">".format_text($cat_cache[$image_row['cat_id']]['cat_name'], 2)."</a></td>\n";
      
$show_user_name format_text($image_row[$user_table_fields['user_name']], 2);
      if (
$image_row['user_id'] != GUEST && empty($url_show_profile)) {
        
$show_user_name "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$image_row['user_id'])."\" target=\"_blank\">$show_user_name</a>";
      }
      echo 
"<td>".$show_user_name."</td>\n";

      echo 
"<td >".format_date($config['date_format']." ".$config['time_format'], $image_row['image_date'])."</td>\n";
	
  
      echo 
"<td  ROWSPAN=3><p>";
	
  
      
show_text_link($lang['edit'],"validateimages.php?action=editimage&image_id=".$image_row['image_id']);

      echo 
"</p></td>\n";
      echo 
"</tr>\n";

	
   echo 
"<tr class=\"".get_row_bg()."\">  ";
	
	

     echo 
"<td  colspan=6> <table border=0 align=center >
	
 <tr align=center>
	
	
 <td width=80>Photo size </ td> <td width=60> not sharp </ td> <td width=60> Dark </ td> <td width=80> Relight </ td> <td width=110> Unsuccessful perspective </ td> <td width=130> Foreign objects </ td> <td width=130> little information </ td>
  </ tr> <tr align=center>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" size photo does not comply;\"> </ td>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" sharp enough;\"> </ td>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" Dark;\"> </ td>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" Relight;\"> </ td>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" Poor angle;\"> </ td>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" Foreign objects in the frame;\"> </ td>
<td> <input type=\"checkbox\" name=\"my_check[]\" value=\" little information;\"> </ td>
	

	
	
</tr> </table>
	
	
 </td>"
	
   
	
  echo 
"</tr>\n";
	
	
  
	
	
  
	
   echo 
"<tr class=\"".get_row_bg()."\">";
	
     
	
	
    echo 
"<td colspan=6 align=\"center\"><input name=\"my_check[]\" type=\"text\" size=\"110\"></td>"

	
  echo 
"</tr>\n";
    }


The problem is that I use
 
$my_check = $_POST['my_check'];
    $note = implode(" ", $my_check);


to enter into the database. But when checking several photos at the same time - notes are the same for all photos.


$action == "saveimages"
while ($row $site_db->fetch_array($result)) {
      
$image_cache[$row['image_id']] = $row;
    }

    foreach (
$image_list as $key => $val) {
      
flush();
      
$image_name addslashes($image_cache[$key]['image_name']);
      
$cat_id $image_cache[$key]['cat_id'];
      
$user_id $image_cache[$key]['user_id'];
	
  
$image_Mesto addslashes($image_cache[$key]['image_Mesto']);
	
  
$image_NOmarsh addslashes($image_cache[$key]['image_NOmarsh']);
      
$image_description addslashes($image_cache[$key]['image_description']);
      
$image_keywords addslashes($image_cache[$key]['image_keywords']);
      
$image_date $image_cache[$key]['image_date'];
      
$image_media_file addslashes($image_cache[$key]['image_media_file']);
      
$image_thumb_file addslashes($image_cache[$key]['image_thumb_file']);
      
$image_download_url addslashes($image_cache[$key]['image_download_url']);
      
$note trim($HTTP_POST_VARS['note']);
      
$old_media_path MEDIA_TEMP_PATH."/".$image_media_file;
      
$old_thumb_path THUMB_TEMP_PATH."/".$image_thumb_file;
	
 
          
$current_time time();
       
	
  
	
 
$my_check $_POST['my_check'];
	
 
 
	
$note implode(" "$my_check);

      if (
$val == 1) {
	
    
$status=1;
        
$new_name copy_media($image_media_file"-1"$cat_id);
        
$new_thumb_name copy_thumbnail($new_name$image_thumb_file"-1"$cat_id);

        if (
$new_name) {
          
$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 $key2 => $val2) {
              if (isset(
$image_cache[$key][$key2]) && isset($image_cache[$key][$key2])) {
                
$additional_field_sql .= ", $key2";
                
$additional_value_sql .= ", '".addslashes($image_cache[$key][$key2])."'";
              }
            }
          }
          
$sql1 "INSERT INTO ".IMAGES_TEMP1_TABLE."
                  (cat_id, user_id, image_name, image_Mesto, image_NOmarsh,  image_description, image_date, note, status) 
                  VALUES
                  (
$cat_id$user_id, '$image_name', '$image_Mesto','$image_NOmarsh','$image_description', $current_time,  '$note','$status')";
          
$result1 $site_db->query($sql1);


How to make $note data were entered correctly for each of the entries photo?

PS sorry for my english :)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Enter any additional comments to a moderated photo. validateimages.php
« Reply #1 on: January 20, 2011, 12:42:24 AM »
First of all, never use $_POST in 4images, use $HTTP_POST_VARS instead, unless for some reason you need unprotected/unfiltered data.

Second, you'll need specify image_id for each my_check field, like so:
Code: [Select]
<input type=\"checkbox\" name=\"my_check[".$image_row['image_id']."][]\" value=\" size photo does not comply;\">
Then, you can retrieve the data with something like this:
foreach ($image_list as $key => $val) {
  
$note "";
  if (isset(
$HTTP_POST_VARS['my_check'][$key]))
    
$note implode(" "$HTTP_POST_VARS['my_check'][$key]);
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bma2004

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Enter any additional comments to a moderated photo. validateimages.php
« Reply #2 on: January 20, 2011, 01:19:13 PM »
V@no. Thank You!

another little question:
Is there a possibility to receive and record in the database, which image_id get photos, if you add in 4images_images?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Enter any additional comments to a moderated photo. validateimages.php
« Reply #3 on: January 20, 2011, 02:05:33 PM »
Sorry, I don't understand the question.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline bma2004

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Enter any additional comments to a moderated photo. validateimages.php
« Reply #4 on: January 20, 2011, 04:52:43 PM »
I want to Record obtained by downloading photos image_id (Table 4images_images) to another database table