4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 02, 2014, 08:54:16 PM

Login with username, password and session length
Search:     Advanced search
4images is now on facebook. Click here and become a fan!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Issues / Ausgaben
| |-+  Discussion & Troubleshooting (Moderators: Acidgod, ivan, Rembrandt)
| | |-+  Check new Image...
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Check new Image...  (Read 2786 times)
batu544
Sr. Member
****
Offline Offline

Posts: 336

Thank You
-Given: 2
-Receive: 26


View Profile WWW
« on: July 04, 2009, 09:32:25 AM »

Hi All -
             I have been using the following checkimages.php file for adding new images for a long time and there is no problem it it.. But now I want to add the description field also as input while adding the images.The description field should be populated from the image name.  I have done some changes and now the Description: field is displaying and populating the field also. But  it is NOT updated in the database. Could anyone look into this and let me know what other changes I need to do..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: checkimages.php                                      *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7                                                  *
 *    File version: 2.11                                                  *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

define('IN_CP'1);
define('ROOT_PATH''./../');
if (isset(
$_GET['action']) && $_GET['action'] == "showthumb" && isset($_GET['mode']) && $_GET['mode'])
  
$no_zip 1;
require(
'admin_global.php');

//--------| Default Settings |-------------

$quality_default = (isset($config['auto_image_quality']) && $config['auto_image_quality']) ? $config['auto_image_quality'] : 85//image quality
$quality_thumbs_default $config['auto_thumbnail_quality']; //thumbnail quality
$dimension_default $config['max_image_width']; //image dimension
$dimension_thumbs_default $config['auto_thumbnail_dimension']; //thumbnail demension
$max_dimension_default 600//displayed in preview image dimension (not image resizing)
$num_newimages_default 30//images per circle
$big_folder_default "big"//name of the "big" folder where original image will be copied to, if its bigger then size set in the settings.
$big_annotate 0//add annotation to the "original" images in "big" folder? (0 or 1)
$backup_orig ""//leave empty if u dont want backup files when it needed resize or add watermark (to preserve IPTC and EXIF headers) NO TRAILING SLASH!
$filter 1//use a filter on filenames. Any non-standart characters will be replaced with _ or just be deleted. (0 or 1)
$thumbpreview 1//create temporary thumbnails for preview if no original was found. (only for none-detailed view) (0 or 1)
$thumbpreview_quality 70//quality for temporary thumbnails
$thumbpreview_dimensions 50//max dimensions for temporary thumbnails
$thumbpreview_tempdir ROOT_PATH.'data/temp'//directory for temporary files. Must be writable (CHMOD 777).
$rescan 1//rescan for new images after first portion of images added (0 or 1)
if (!$mode)
{
  
$annotate_default = (isset($config['annotation_use'])) ? $config['annotation_use'] : 0//add annotation to the images (require "Annotation MOD" by SLL)
  
$big_default 0//save original image (0 or 1)
  
$iptc_date_default 0//auto insert date from IPTC (0 or 1)
  
$iptc_keywords_default 0//auto insert keyword from IPTC (0 or 1)
  
$iptc_description_default 0//auto insert captions from IPTC (0 or 1)
  
$iptc_name_default 0//auto insert name from IPTC (0 or 1)
  
$detailed_default 0//detailed view (0 or 1)
  
$auto_resize_default 1//resize images (0 or 1)
  
$auto_thumbs_default 1//create thumbs (0 or 1)
  
$subcats_default 0//include subcategories (0 or 1)
}

//----------| End Settings |---------------

//----------| Language |------------
//you can move these into lang/<your language>/admin.php

$lang['cni_max_dim'] = "Max dimensions for images preview<br /><span class=\"smalltext\">When checked \"Detailed\", image will be resized on your screen acording this value.</span>";
$lang['cni_iptc_name'] = "Use name from IPTC value";
$lang['cni_iptc_description'] = "Use description from IPTC value";
$lang['cni_iptc_keywords'] = "Use keywords from IPTC value";
$lang['cni_iptc_date'] = "Use date from IPTC value";
$lang['cni_check_subcat'] = "Check subcategories";

$lang['cni_auto_resizer'] = "Auto resizer";
$lang['cni_save_orig'] = "Save original images";
$lang['cni_big_folder'] = "Folder name where to save original images";
$lang['cni_add_ann'] = "Add annotation (watermark)";
$lang['cni_auto_thumbnailer'] = "Auto thumbnailer";
$lang['cni_foundin'] = "Found in";
$lang['cni_root_folder'] = "root folder";
$lang['on'] = "On";
$lang['off'] = "Off";

//logs
$lang['cni_media_file_rename'] = "Media file renamed from <b>{from}</b> to <b>{to}</b>";
$lang['cni_media_file_rename_error'] = "<u>Error</u> renaming media file from <b>{from}</b> to <b>{to}</b>";
$lang['cni_thumb_file_rename'] = "Thumbnail file renamed from <b>{from}</b> to <b>{to}</b>";
$lang['cni_thumb_file_rename_error'] = "<u>Error</u> renaming thumbnail file from <b>{from}</b> to <b>{to}</b>";
$lang['cni_copy_success'] = "Copied file into <b>{name}</b> folder.";
$lang['cni_copy_thumb_success'] = "Copied thumbnail into <b>{name}</b> folder.";
$lang['cni_backup_success'] = "Backup original file into <b>{name}</b> folder.";
$lang['cni_backup_error'] = "<u>Error</u> copying original file into <b>{name}</b> folder.";
$lang['cni_annotation_success'] = "Added annotation in <b>{name}</b> file.";
$lang['cni_annotation_error'] = "<u>Error</u> adding annotation in <b>{name}</b> file.";
$lang['cni_create_folder_success'] = "Created <b>{name}/</b> folder.";
$lang['cni_create_folder_error'] = "<u>Error</u> creating <b>{name}/</b> folder.";

//----------| End Language |-----------

if ($action == "showthumb" && $mode)
{
  
$result true;
  if (!@
is_dir($thumbpreview_tempdir))
  {
    
$oldumask umask(0);
    
$result mkdir($thumbpreview_tempdir);
    
umask($oldumask);
    if (!@
is_dir($thumbpreview_tempdir) || !$result)
    {
      
$result mkdir($thumbpreview_tempdir0755);
    }
  }

  require(
ROOT_PATH.'includes/image_utils.php');
$convert_options init_convert_options();
  
$thumb ICON_PATH."/404.gif";
  
$file MEDIA_PATH."/".(($cat_id) ? $cat_id ."/" "").$mode;
  
$delete false;
  if (!
$convert_options['convert_error'] && $result && $img = @getimagesize($file))
  {
    if (
$img[2] >= && $img[2] < 4)
    {
      
$thumb $file;
    }
    else
    {
      
$thumb ICON_PATH."/".strtolower(substr(strrchr($mode,"."), 1)).".gif";
    }
}
  else
  {
    
$thumb ICON_PATH."/".strtolower(substr(strrchr($mode,"."), 1)).".gif";
  }
if (!$convert_options['convert_error'])
  {
  
$file $thumbpreview_tempdir."/".MD5(time().microtime());
  
$type substr(strrchr($thumb,"."), 1);
    if (
create_thumbnail($thumb$file$thumbpreview_quality$thumbpreview_dimensions1))
    {
      
$delete true;
      
$thumb $file;
    }
}
  
header("Content-Type: image/".$type);
  
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");             // turn off caching
  
header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT");
  
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  @
readfile($thumb);
  if (
$delete)
  {
    @
unlink($file);
  }
  exit;
}

include(
ROOT_PATH.'includes/search_utils.php');

function 
backup($src$dest$name$cat_id)
{
  
$dest .= "/".$cat_id;
  
$result true;
  if (!@
is_dir($dest))
  {
    
$oldumask umask(0);
    
$result mkdir($dest);
    
umask($oldumask);
    if (!@
is_dir($dest) || !$result)
    {
      
$result mkdir($dest0755);
    }
  }
  if (
$result)
  {
    return 
copy($src$dest."/".$name);
  }
  return 
false;
}
function 
get_subcats($cat_id 0$cid 0) {
  global 
$sub_cat_cache$cat_cache$cats;

  if (!isset(
$sub_cat_cache[$cid])) {
    return 
"";
  }
  foreach (
$sub_cat_cache[$cid] as $key => $category_id) {
    
$cats[] = $category_id;
    
get_subcats($cat_id$category_id);
  }
  unset(
$sub_cat_cache[$cid]);
}

if (
$action == "")
{
  
$action "checkimages";
}
$status 0;

function 
get_category_dropdown_check($cat_id 0)
{
  global 
$lang$drop_down_cat_cache$cat_parent_cache;
    
$category "\n<select name=\"cat_id_p\" class=\"categoryselect\">\n";
    
$category .= "<option value=\"0\">".$lang['all_categories']."</option>\n";
    
$category .= "<option value=\"0\">-------------------------------</option>\n";

  
$drop_down_cat_cache = array();
  
$drop_down_cat_cache $cat_parent_cache;
  
$category .= get_category_dropdown_bits($cat_id);
  
$category .= "</select>\n";
  return 
$category;
}
show_admin_header();

if (
$action == "savenewimages")
{
  @include(
ROOT_PATH."includes/db_field_definitions.php");

  
$date time();
  
$error = array();
  
$num_newimages $HTTP_POST_VARS['num_newimages'];
  
$detailed $HTTP_POST_VARS['detailed'];
  
$auto_resize = (isset($HTTP_POST_VARS['auto_resize']) && $HTTP_POST_VARS['auto_resize'] == 1) ? 0;
  
$auto_thumbs = (isset($HTTP_POST_VARS['auto_thumbs']) && $HTTP_POST_VARS['auto_thumbs'] == 1) ? 0;
  
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $dimension_default;
  
$resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : 1;
  
$quality = (isset($HTTP_POST_VARS['quality']) && intval($HTTP_POST_VARS['quality']) && intval($HTTP_POST_VARS['quality']) <= 100) ? intval($HTTP_POST_VARS['quality']) : $quality_default;
  
$dimension_thumbs = (isset($HTTP_POST_VARS['dimension_thumbs'])) ? intval($HTTP_POST_VARS['dimension_thumbs']) : $dimension_thumbs_default;
  
$resize_type_thumbs = (isset($HTTP_POST_VARS['resize_type_thumbs'])) ? intval($HTTP_POST_VARS['resize_type_thumbs']) : 1;
  
$quality_thumbs = (isset($HTTP_POST_VARS['quality_thumbs']) && intval($HTTP_POST_VARS['quality_thumbs']) && intval($HTTP_POST_VARS['quality_thumbs']) <= 100) ? intval($HTTP_POST_VARS['quality_thumbs']) : $quality_thumbs_default;
  
$big = (isset($HTTP_POST_VARS['big']) && $HTTP_POST_VARS['big'] == 1) ? $big_default;
  
$annotate = (isset($HTTP_POST_VARS['annotate']) && $HTTP_POST_VARS['annotate'] == 1) ? $annotate_default;
  
$big_folder = (isset($HTTP_POST_VARS['big_folder'])) ? trim($HTTP_POST_VARS['big_folder']) : $big_folder_default;
  for (
$i 1$i <= $num_newimages$i++)
  {
    
$addimage = (isset($HTTP_POST_VARS['addimage_'.$i]) && $HTTP_POST_VARS['addimage_'.$i] == 1) ? 0;
    if (
$addimage)
    {
      
$image_name trim($HTTP_POST_VARS['image_name_'.$i]);
      
$cat_id intval($HTTP_POST_VARS['cat_id_'.$i]);
      
$image_download_url = (isset($HTTP_POST_VARS['image_download_url_'.$i])) ? trim($HTTP_POST_VARS['image_download_url_'.$i]) : "";

      if (
$image_name == "")
      {
        
$error['image_name_'.$i] = 1;
      }
      if (
$cat_id == 0)
      {
        
$error['cat_id_'.$i] = 1;
      }
      if (
$image_download_url != "" && !is_remote($image_download_url) && !is_local_file($image_download_url))
      {
        
$error['image_download_url_'.$i] = 1;
      }

      if (!empty(
$additional_image_fields))
      {
        foreach (
$additional_image_fields as $key => $val)
        {
          if (isset(
$HTTP_POST_VARS[$key.'_'.$i]) && intval($val[2]) == && trim($HTTP_POST_VARS[$key.'_'.$i]) == "")
          {
            
$error[$key.'_'.$i] = 1;
          }
        }
      }
    }
  }
  if (empty(
$error))
  {
require(ROOT_PATH.'includes/image_utils.php');
$no_resize 0;
$convert_options init_convert_options();
if ($convert_options['convert_error'])
    {
$no_resize 1;
}
    
show_table_header($lang['nav_images_check']." log"1);
    echo 
"<tr>\n<td class=\"tablerow\">\n";
    echo 
"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td>&nbsp;</td><td>\n";
    
$n 0;
    for (
$i 1$i <= $num_newimages$i++)
    {
      
$log = array();
      
$backup false;
      
$addimage = (isset($HTTP_POST_VARS['addimage_'.$i]) && $HTTP_POST_VARS['addimage_'.$i] == 1) ? 0;
      if (
$addimage)
      {
        
$image_media_file trim($HTTP_POST_VARS['image_media_file_'.$i]);
        
$image_thumb_file trim($HTTP_POST_VARS['image_thumb_file_'.$i]);
        
$image_name trim($HTTP_POST_VARS['image_name_'.$i]);

        
$cat_id intval($HTTP_POST_VARS['cat_id_'.$i]);
        
$old_cat_id intval($HTTP_POST_VARS['old_cat_id_'.$i]);

        
$user_id = (isset($HTTP_POST_VARS['user_id_'.$i]) && intval($HTTP_POST_VARS['user_id_'.$i]) != 0) ? intval($HTTP_POST_VARS['user_id_'.$i]) : "";
        
$user_id = ($user_id) ? $user_id : ((isset($HTTP_POST_VARS['user_id']) && intval($HTTP_POST_VARS['user_id']) != 0) ? intval($HTTP_POST_VARS['user_id']) : $user_info['user_id']);

        
$image_description = (isset($HTTP_POST_VARS['image_description_'.$i])) ? trim($HTTP_POST_VARS['image_description_'.$i]) : "";
        
$image_date = (isset($HTTP_POST_VARS['image_date_'.$i])) ? ((trim($HTTP_POST_VARS['image_date_'.$i] != "")) ? "UNIX_TIMESTAMP('".trim($HTTP_POST_VARS['image_date_'.$i])."')" time()) : time();
        
$image_download_url = (isset($HTTP_POST_VARS['image_download_url_'.$i])) ? trim($HTTP_POST_VARS['image_download_url_'.$i]) : "";

        if (isset(
$HTTP_POST_VARS['image_keywords_'.$i]))
        {
          
$image_keywords trim($HTTP_POST_VARS['image_keywords_'.$i]);
          
$image_keywords preg_replace("/[\n\r]/is"" "$image_keywords);
          
$image_keywords str_replace(","," ",$image_keywords);
          
$image_keywords ereg_replace("( ){2,}"" "$image_keywords);
        }
        else
        {
          
$image_keywords "";
        }

If ($image_description ' ')
{
$image_description "Sexy $image_name  wallpapers, $cat_name gallery pictures, images, photo albums";
            
$image_keywords "Sexy $image_name wallpapers pictures gallery album Hollywood bollywood celebrity hot wallpapers";
}

        
$image_active intval($HTTP_POST_VARS['image_active_'.$i]);
        
$image_allow_comments intval($HTTP_POST_VARS['image_allow_comments_'.$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]))."'";
            }
          }
        }

        
$log[] = "Working on <b>".MEDIA_DIR.(($old_cat_id != 0) ? "/".$old_cat_id "")."/".stripslashes($image_media_file)."</b> file:";
        if (
$filter && preg_match("/( |%20|[^-\._a-zA-Z0-9])/"stripslashes($image_media_file)))
        {
          
$image_media_file_backup $image_media_file;
          
$image_media_file stripslashes($image_media_file);
          
$file str_replace(" ""_"$image_media_file);
          
$file str_replace("%20""_"$file);
          
$file preg_replace("/[^-\._a-zA-Z0-9]/"""$file);
          
$oldwd getcwd();
          
$n 2;
          
$copy "";
          
$file_name substr($file,0,(strlen($file)-strlen(strrchr($file,"."))));
          
$file_ext substr(strrchr($file,"."), 1);
          
chdir(realpath(MEDIA_PATH.(($old_cat_id != 0) ? "/".$old_cat_id "")));
          while (
file_exists($file_name.$copy.".".$file_ext)) {
            
$copy "_".$n;
            
$n++;
          }
          
$file $file_name.$copy.".".$file_ext;
          if (
rename(basename($image_media_file), basename($file)))
          {
            
$log[] = str_replace("{from}"$image_media_filestr_replace("{to}"$file$lang['cni_media_file_rename']));
            
$image_media_file $file;
          }
          else
          {
            
$log[] = str_replace("{from}"$image_media_filestr_replace("{to}"$file$lang['cni_media_file_rename_error']));
            
$image_media_file $image_media_file_backup;
          }
          
chdir($oldwd);
        }
        if (
$filter && preg_match("/( |%20|[^-\._a-zA-Z0-9])/"stripslashes($image_thumb_file)))
        {
          
$image_thumb_file_backup $image_thumb_file;
          
$image_thumb_file stripslashes($image_thumb_file);

          
$file str_replace(" ""_"$image_thumb_file);
          
$file str_replace("%20""_"$file);
          
$file preg_replace("/[^-\._a-zA-Z0-9]/"""$file);
          
$oldwd getcwd();
          
$n 2;
          
$copy "";
          
$file_name substr($file,0,(strlen($file)-strlen(strrchr($file,"."))));
          
$file_ext substr(strrchr($file,"."), 1);
          
chdir(realpath(THUMB_PATH.(($old_cat_id != 0) ? "/".$old_cat_id "")));
          while (
file_exists($file_name.$copy.".".$file_ext)) {
            
$copy "_".$n;
            
$n++;
          }
          
$file $file_name.$copy.".".$file_ext;
          if (
rename(basename($image_thumb_file), basename($file)))
          {
            
$log[] = str_replace("{from}"$image_thumb_filestr_replace("{to}"$file$lang['cni_thumb_file_rename']));
            
$image_thumb_file $file;
          }
          else
          {
            
$log[] = str_replace("{from}"$image_thumb_filestr_replace("{to}"$file$lang['cni_thumb_file_rename_error']));
            
$image_thumb_file $image_thumb_file_backup;
          }
          
chdir($oldwd);
        }
        if (
$cat_id != $old_cat_id)
        {
          
$image_media_file copy_media($image_media_file$old_cat_id$cat_id);
          if (
file_exists(MEDIA_PATH.(($old_cat_id != 0) ? "/".$old_cat_id "")."/".$image_media_file))
          {
            
$log[] = str_replace("{name}"MEDIA_DIR.(($cat_id != 0) ? "/".$cat_id ""), $lang['cni_copy_success']);
          }
          
$image_thumb_file copy_thumbnail($image_media_file$image_thumb_file$old_cat_id$cat_id);
          if (
file_exists(THUMB_PATH.(($old_cat_id != 0) ? "/".$old_cat_id "")."/".$image_thumb_file))
          {
            
$log[] = str_replace("{name}"THUMB_DIR.(($cat_id != 0) ? "/".$cat_id ""), $lang['cni_copy_success']);
          }
        }
$file MEDIA_PATH.(($cat_id != 0) ? "/".$cat_id "")."/".$image_media_file;
if ($big)
        {
  $big_file MEDIA_PATH."/".$cat_id."/".$big_folder."/".$image_media_file;
          if (
file_exists($big_file))
          {
    
if ($big_annotate && $annotate && ($image_info getimagesize($big_file)) && $image_info[2] > && $image_info[2] < 4)
    
{
              if (
$backup_orig)
              {
            
if ($backup backup($big_file$backup_orig$image_media_file$cat_id))
            
{
$log[] = str_replace("{name}"$backup_orig."/".$cat_id$lang['cni_backup_success']);
}
else
{
$log[] = str_replace("{name}"$backup_orig."/".$cat_id$lang['cni_backup_error']);
}
            
}
    
  include_once(ROOT_PATH.'includes/annotate.php');
              if (
function_exists("annotate_image") && annotate_image($big_file))
    
  {
  $log[] = str_replace("{name}"MEDIA_DIR."/".$cat_id."/".$big_folder."/".stripslashes($image_media_file), $lang['cni_annotation_success']);
    
  }
    
  else
    
  {
  $log[] = str_replace("{name}"MEDIA_DIR."/".$cat_id."/".$big_folder."/".stripslashes($image_media_file), $lang['cni_annotation_error']);
    
  }
    
}
}
}
      if ($auto_resize && file_exists($file) && !$no_resize)
        {
        if ($image_info getimagesize($file))
          {
        if ($image_info[2] == || $image_info[2] == || $image_info[2] == 3)
            {
          $ok 0;
          if ($resize_type == && ($image_info[0] > $dimension || $image_info[1] > $dimension))
              {
            $ok 1;
          }
          elseif ($resize_type == && $image_info[0] > $dimension)
              {
            $ok 1;
          }
          elseif ($resize_type == && $image_info[1] > $dimension)
              {
            $ok 1;
          }
if ($ok)
              {
                if (
$backup_orig && !$backup)
                {
              
if ($backup backup($file$backup_orig$image_media_file$cat_id))
              
{
  $log[] = str_replace("{name}"$backup_orig."/".$cat_id$lang['cni_backup_success']);
 
}
else
{
  
$log[] = str_replace("{name}"$backup_orig."/".$cat_id$lang['cni_backup_error']);
}
              
}
if ($big)
                {
  $src MEDIA_PATH."/".$cat_id."/".$big_folder;
$result true;
  if (!@is_dir($src))
                  {
    $oldumask umask(0);
    $result mkdir($src);
    umask($oldumask);
    if (!@is_dir($src) || !$result)
                    {
      $result mkdir($src0755);

    }
                    if (
$result)
                    {
    $log[] = str_replace("{name}"$backup_orig."/".$cat_id$lang['cni_create_folder_success']);
                    }
                    else
                    {
 
    $log[] = str_replace("{name}"$backup_orig."/".$cat_id$lang['cni_create_folder_error']);
                   }
  }
if ($result == true){
  $big_file $src."/".$image_media_file;
if (copy($file$big_file))
{
  $log[] = "Copied original file into <b>".MEDIA_DIR."/".$cat_id."/".$big_folder."/</b> folder.";
  $image_info getimagesize($big_file);
              
if ($big_annotate && $annotate && $image_info && $image_info[2] > && $image_info[2] < 4)
              
{
              
  include_once(ROOT_PATH.'includes/annotate.php');
              
  if (function_exists("annotate_image") && annotate_image($big_file))
              
  {
              
    $log[] = "Added annotation in <b>".MEDIA_DIR."/".$cat_id."/".$big_folder."/".stripslashes($image_media_file)."</b> file.";
              
  }
              
  else
              
  {
              
    $log[] = "<u>Error</u> adding annotation in <b>".MEDIA_DIR."/".$cat_id."/".$big_folder."/".stripslashes($image_media_file)."</b> file.";
              
  }
              
}
}
else
{
  $log[] = "<u>Error</u> copying original file into <b>".MEDIA_DIR."/".$cat_id."/".$big_folder."/</b> folder.";
}
}
}
        if (resize_image($file$quality$dimension$resize_type))
                {
          $log[] = "Image resized.";
        }
        else
                {
           $log[] = "<u>Error</u> resizing image.";
        }
}
        }
      }
    }
$file MEDIA_PATH."/".$cat_id."/".stripslashes($image_media_file);
$image_info getimagesize($file);
if ($annotate && $image_info && $image_info[2] > && $image_info[2] < 4)
{
          if (
$backup_orig && !$backup)
          {
        
if ($backup backup($file$backup_orig$image_media_file$cat_id))
        
{
$log[] = "Backup original file into <b>".$backup_orig."/".$cat_id."/</b> folder.";
}
else
{
  $log[] = "<u>Error</u> copying original file into <b>".$backup_orig."/".$cat_id."/</b> folder.";
}
        
}
  include_once(ROOT_PATH.'includes/annotate.php');
  if (function_exists("annotate_image") && annotate_image($file))
  {
    $log[] = "Added annotation in <b>".MEDIA_DIR."/".$cat_id."/".stripslashes($image_media_file)."</b> file.";
  }
  else
  {
    $log[] = "<u>Error</u> adding annotation in <b>".MEDIA_DIR."/".$cat_id."/".stripslashes($image_media_file)."</b> file.";
  }
}
$file_thumb THUMB_PATH."/".$cat_id."/".stripslashes($image_media_file);
      if ($image_info && $image_info[2] > && $image_info[2] < && $auto_thumbs && $image_thumb_file == "" && file_exists($file) && !$no_resize && !file_exists($file_thumb))
        {
          
$ok 0;
          if (
$resize_type_thumbs == && ($image_info[0] > $dimension_thumbs || $image_info[1] > $dimension_thumbs))
          {
            
$ok 1;
          }
          elseif (
$resize_type_thumbs == && $image_info[0] > $dimension_thumbs)
          {
            
$ok 1;
          }
          elseif (
$resize_type_thumbs == && $image_info[1] > $dimension_thumbs)
          {
            
$ok 1;
          }
if ($ok)
          {
      
if (create_thumbnail($file, $file_thumb$quality_thumbs$dimension_thumbs$resize_type_thumbs))
            {
          $log[] = "Created thumbnail.";
          $image_thumb_file $image_media_file;
        }
        else
            {
        
$log[] = "<u>Error</u> creating thumbnail.";
        }
}
    }
        
$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_id, '$image_name', '$image_description', '$image_keywords', $image_date$image_active, '$image_media_file', '$image_thumb_file', '$image_download_url', $image_allow_comments".$additional_value_sql.")";
        
$result $site_db->query($sql);
        
$image_id $site_db->get_insert_id();

        if (
$result)
        {
          
$search_words = array();
          foreach (
$search_match_fields as $image_column => $match_column)
          {
            if (isset(
$HTTP_POST_VARS[$image_column.'_'.$i]))
            {
              
$search_words[$image_column] = stripslashes($HTTP_POST_VARS[$image_column.'_'.$i]);
            }
          }
          
add_searchwords($image_id$search_words);
          
$log[] = $lang['image_add_success'].": <b><a target=\"4images\" href=\"../details.php?image_id=".$image_id."\">".stripslashes($image_name)."</a></b>";
//ensure that rescaned images wont get same info as already added ones.
          
$n++;
        }
        else
        {
          
$log[] = "<u>Error</u> adding image!";
        }
        
$log[] = "";
        unset(
$HTTP_POST_VARS['image_name_'.$i]);
        unset(
$HTTP_POST_VARS['image_media_file_'.$i]);
        unset(
$HTTP_POST_VARS['image_thumb_file_'.$i]);
        unset(
$HTTP_POST_VARS['image_name_'.$i]);
        unset(
$HTTP_POST_VARS['cat_id_'.$i]);
        unset(
$HTTP_POST_VARS['old_cat_id_'.$i]);
        unset(
$HTTP_POST_VARS['user_id_'.$i]);
        unset(
$HTTP_POST_VARS['image_description_'.$i]);
        unset(
$HTTP_POST_VARS['image_date_'.$i]);
        unset(
$HTTP_POST_VARS['image_download_url_'.$i]);
        unset(
$HTTP_POST_VARS['image_keywords_'.$i]);
        unset(
$HTTP_POST_VARS['image_active_'.$i]);
        unset(
$HTTP_POST_VARS['image_allow_comments_'.$i]);
        unset(
$error['image_name_'.$i]);
        unset(
$error['image_media_file_'.$i]);
        unset(
$error['image_thumb_file_'.$i]);
        unset(
$error['image_name_'.$i]);
        unset(
$error['cat_id_'.$i]);
        unset(
$error['old_cat_id_'.$i]);
        unset(
$error['user_id_'.$i]);
        unset(
$error['image_description_'.$i]);
        unset(
$error['image_date_'.$i]);
        unset(
$error['image_download_url_'.$i]);
        unset(
$error['image_keywords_'.$i]);
        unset(
$error['image_active_'.$i]);
        unset(
$error['image_allow_comments_'.$i]);
        if (!empty(
$additional_image_fields))
        {
          foreach (
$additional_image_fields as $key => $val)
          {
            unset(
$HTTP_POST_VARS[$key.'_'.$i]);
            unset(
$error[$key.'_'.$i]);
          }
        }
      }
      if (
count($log))
      {
        foreach (
$log as $val)
        {
          echo 
$val."<br />";
        }
      }
    }
    if (!
$n)
    {
      echo 
$lang['no_newimages_added'];
    }
    echo 
"</td>\n</tr>\n</table>\n";
    echo 
"</td>\n</tr>\n";
    
show_table_footer();
    
$status 1;
    
$action "checkimages";
  }
  else
  {
    
$msg sprintf("<span class=\"marktext\">%s</span>"$lang['lostfield_error']);
    
$action "checkimages";
  }
  if (!
$rescan)
  {
    unset(
$HTTP_POST_VARS['action']);
  }
}

if (
$action == "checkimages")
{
  
$max_dimension = (isset($HTTP_POST_VARS['max_dimension'])) ? $HTTP_POST_VARS['max_dimension'] : $max_dimension_default;
  
$cat_id = (isset($HTTP_POST_VARS['cat_id_p'])) ? intval($HTTP_POST_VARS['cat_id_p']) : 0;
  
$num_newimages = (isset($HTTP_POST_VARS['num_newimages'])) ? intval($HTTP_POST_VARS['num_newimages']) : $num_newimages_default;
  
$detailed = (isset($HTTP_POST_VARS['detailed'])) ? intval($HTTP_POST_VARS['detailed']) : $detailed_default;
  
$detailed_checked = ($detailed == 1) ? " checked=\"checked\"" "";
  
$auto_resize = (isset($HTTP_POST_VARS['auto_resize'])) ? intval($HTTP_POST_VARS['auto_resize']) : $auto_resize_default;
  
$auto_resize_checked = ($auto_resize == 1) ? " checked=\"checked\"" "";
  
$auto_thumbs = (isset($HTTP_POST_VARS['auto_thumbs'])) ? intval($HTTP_POST_VARS['auto_thumbs']) : $auto_thumbs_default;
  
$auto_thumbs_checked = ($auto_thumbs == 1) ? " checked=\"checked\"" "";
  
$iptc_date = (isset($HTTP_POST_VARS['iptc_date'])) ? intval($HTTP_POST_VARS['iptc_date']) : $iptc_date_default;
  
$iptc_description = (isset($HTTP_POST_VARS['iptc_description'])) ? intval($HTTP_POST_VARS['iptc_description']) : $iptc_description_default;
  
$iptc_keywords = (isset($HTTP_POST_VARS['iptc_keywords'])) ? intval($HTTP_POST_VARS['iptc_keywords']) : $iptc_keywords_default;
  
$iptc_name = (isset($HTTP_POST_VARS['iptc_name'])) ? intval($HTTP_POST_VARS['iptc_name']) : $iptc_name_default;
  
$dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $dimension_default;
  
$user_id = (isset($HTTP_POST_VARS['user_id'])) ? intval($HTTP_POST_VARS['user_id']) : $user_info['user_id'];
  
$resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : 1;
  
$quality = (isset($HTTP_POST_VARS['quality']) && intval($HTTP_POST_VARS['quality']) && intval($HTTP_POST_VARS['quality']) <= 100) ? intval($HTTP_POST_VARS['quality']) : $quality_default;
  
$dimension_thumbs = (isset($HTTP_POST_VARS['dimension_thumbs'])) ? intval($HTTP_POST_VARS['dimension_thumbs']) : $dimension_thumbs_default;
  
$resize_type_thumbs = (isset($HTTP_POST_VARS['resize_type_thumbs'])) ? intval($HTTP_POST_VARS['resize_type_thumbs']) : 1;
  
$quality_thumbs = (isset($HTTP_POST_VARS['quality_thumbs']) && intval($HTTP_POST_VARS['quality_thumbs']) && intval($HTTP_POST_VARS['quality_thumbs']) <= 100) ? intval($HTTP_POST_VARS['quality_thumbs']) : $quality_thumbs_default;
  
$big = (isset($HTTP_POST_VARS['big'])) ? $HTTP_POST_VARS['big'] : $big_default;
  
$annotate = (isset($HTTP_POST_VARS['annotate'])) ? $HTTP_POST_VARS['annotate'] : $annotate_default;
  
$big_folder = (isset($HTTP_POST_VARS['big_folder'])) ? trim($HTTP_POST_VARS['big_folder']) : $big_folder_default;
  
$subcats = (isset($HTTP_POST_VARS['subcats'])) ? trim($HTTP_POST_VARS['subcats']) : $subcats_default;
  
$subcats_checked = ($subcats == 1) ? " checked=\"checked\"" "";
  if (
$num_newimages == "" || !$num_newimages)
  {
    
$num_newimages 30;
  }


  
show_form_header("checkimages.php""checkimages");
  
show_table_header($lang['nav_images_check'], 2);
  
show_input_row($lang['num_newimages_desc'], "num_newimages"$num_newimages);
  
show_input_row($lang['cni_max_dim'], "max_dimension"$max_dimension);
//  show_table_separator("IPTC info", 2);
show_radio_row($lang['cni_iptc_name'], "iptc_name"$iptc_name);
show_radio_row($lang['cni_iptc_description'], "iptc_description"$iptc_description);
show_radio_row($lang['cni_iptc_keywords'], "iptc_keywords"$iptc_keywords);
show_radio_row($lang['cni_iptc_date'], "iptc_date"$iptc_date);
show_radio_row($lang['detailed_version'], "detailed"$detailed);
  
$desc get_category_dropdown_check($cat_id);
  
$desc .= "&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"subcats\" value=\"1\"".$subcats_checked.">".$lang['cni_check_subcat'];
 
show_custom_row($desc"<input type=\"submit\" value=\"".$lang['nav_images_check']."\" class=\"button\">");
  
show_table_footer();
  echo 
"</form>";
}

if (isset(
$HTTP_POST_VARS['action']) && $action == "checkimages")
{
  if (isset(
$HTTP_POST_VARS['detailed']) && $HTTP_POST_VARS['detailed'] == 1)
  {
    
$detailed 1;
    
$colspan 2;
  }
  else
  {
    
$detailed 0;
    
$colspan 7;
  }
  
$cat_id = (isset($HTTP_POST_VARS['cat_id_p'])) ? intval($HTTP_POST_VARS['cat_id_p']) : 0;
  
$cat_id_p $cat_id;
$image_list_sql = array();
$cats = array($cat_id);
  if (
$cat_id)
  {
    if (
$subcats)
    {
      
$sub_cat_cache $cat_parent_cache;
      
get_subcats($cat_id$cat_id);
    }

  $image_list_all = array();
    foreach (
$cats as $key)
    {
  
  $cat_path "/".$key;
  
  if ($handle opendir(MEDIA_PATH.$cat_path))
  
  {
    
  while ($file = @readdir($handle))
        {
    
    if ($file != "." && $file != "..")
          {
    
      if (check_media_type($file))
            {
    
        $image_list_all[$key][] = $file;
    
      }
    
    }
    
  }
    
  closedir($handle);
      }
  
}
    
$cat_sql implode(", "$cats);
foreach ($image_list_all as $key => $val)
    {
  sort($image_list_all[$key]);
}
}
else
{
    
$image_list_all = array();
    
$cat_image = array();
  if ($handle opendir(MEDIA_PATH))
  {
  
  while ($file = @readdir($handle))
      {
  
    if ($file != "." && $file != "..")
        {
  
      if (check_media_type($file))
          {
  
   $image_list_all[0][] = $file;
  
      }
  
    }
  
  }
    
closedir($handle);
    }
foreach ($image_list_all as $key => $val)
    {
  sort($image_list_all[$key]);
}
  $sql "SELECT cat_id
          FROM "
.CATEGORIES_TABLE;
  $result $site_db->query($sql);
  while ($row $site_db->fetch_array($result))
    {
  $cat_id $cats[] = $row['cat_id'];
  $cat_path = ($cat_id == 0) ? "" "/".$cat_id;
  if ($handle opendir(MEDIA_PATH.$cat_path))
  {
  
  while ($file = @readdir($handle))
        {
  
    if ($file != "." && $file != "..")
          {
  
      if (check_media_type($file))
            {
  
   $image_list_all[$row['cat_id']][] = $file;
  
      }
  
    }
  
  }
    
  closedir($handle);
      }
}
foreach ($image_list_all as $key => $val)
    {
  sort($image_list_all[$key]);
}
    
$cat_sql implode(", "$cats);
}
  
$sql "SELECT image_media_file, cat_id
          FROM "
.IMAGES_TABLE."
          WHERE cat_id IN (
$cat_sql)
          ORDER BY cat_id"
;
  
$result $site_db->query($sql);

  while (
$row $site_db->fetch_array($result))
  {
    
$image_list_sql[$row['cat_id']][] = $row['image_media_file'];
  }
foreach ($image_list_sql as $key => $val)
  {
  sort($image_list_sql[$key]);
}

  
$image_list = array();
  
$image_counter 0;
foreach ($image_list_all as $key => $val)
  {
  for ($i 0$i count($image_list_all[$key]); $i++)
    {
    if ($image_counter == $num_newimages)
      {
      break;
    }
    if (!@in_array($image_list_all[$key][$i], $image_list_sql[$key]))
      {
      $image_list[$key][] = $image_list_all[$key][$i];
      $image_counter++;
    }
  }
}
foreach ($image_list as $key => $val)
  {
  
sort($image_list[$key]);
}
  
$num_all_newimages $image_counter;

  if (
$msg != "")
  {
    
printf("<b>%s</b>\n"$msg);
  }

  
show_form_header("checkimages.php""savenewimages""form");

  
show_table_header($lang['cni_auto_resizer']."&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"auto_resize\" value=\"1\"".(($auto_resize) ? " checked" "").">".$lang['on']."&nbsp;<input type=\"radio\" name=\"auto_resize\" value=\"\"".(($auto_resize) ? "" " checked" ).">".$lang['off'], 2);
  
show_input_row($lang['resize_dimension_desc'], "dimension"$dimension);

$resize "\n<select name=\"resize_type\">\n";
  foreach (
$auto_thumbnail_resize_type_optionlist as $key => $val)
  {
    
$resize .= "<option value=\"$key\"";
    if (
$resize_type == $key)
    {
      
$resize .= " selected=\"selected\"";
    }
    
$resize .= ">$val</option>\n";
  }
$resize .= "</select>\n";
  
show_custom_row($lang['resize_proportions_desc'], $resize);

  
show_input_row($lang['resize_quality_desc'], "quality"$quality);
show_radio_row($lang['cni_save_orig'], "big"$big);
  
show_input_row($lang['cni_big_folder'], "big_folder"$big_folder);
  
show_radio_row($lang['cni_add_ann'], "annotate"$annotate);
  
show_table_separator($lang['cni_auto_thumbnailer']."&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"auto_thumbs\" value=\"1\"".(($auto_thumbs) ? " checked" "").">".$lang['on']."&nbsp;<input type=\"radio\" name=\"auto_thumbs\" value=\"\"".(($auto_thumbs) ? "" " checked" ).">".$lang['off'], 2);
  
show_input_row($lang['convert_thumbnail_dimension'], "dimension_thumbs"$dimension_thumbs);

$resize "\n<select name=\"resize_type_thumbs\">\n";
  foreach (
$auto_thumbnail_resize_type_optionlist as $key => $val)
  {
    
$resize .= "<option value=\"$key\"";
    if (
$resize_type_thumbs == $key)
    {
      
$resize .= " selected=\"selected\"";
    }
    
$resize .= ">$val</option>\n";
  }
$resize .= "</select>\n";
  
show_custom_row($lang['resize_proportions_desc'], $resize);

  
show_input_row($lang['convert_thumbnail_quality'], "quality_thumbs"$quality_thumbs);
  if (!
$detailed)
  {
    
show_table_separator($lang['user'], 2);
  show_user_select_row("Add as user"$user_id);
  }
  
show_table_footer();

  
show_hidden_input("cat_id_p"$cat_id_p);
  
show_hidden_input("mode"1);
  
show_table_header(preg_replace("/".$site_template->start."num_all_newimages".$site_template->end."/siU"$num_all_newimages$lang['checkimages_note']), $colspan);

  if (
$num_all_newimages)
  {
    
show_description_row("<input name=\"allbox\" type=\"checkbox\" onClick=\"CheckAll();\"".(($status) ? "" " checked=\"checked\"")." /> <b>".$lang['check_all']."</b>"$colspan);
  }
  else
  {
    
show_description_row($lang['no_newimages'], $colspan);
  }
  
$ii 0;
foreach ($image_list as $key => $val)
  {
$cat_id $key;
  
$cat_path = ($cat_id == 0) ? "" "/".$cat_id;
  $sql "SELECT cat_id, cat_name
          FROM "
.CATEGORIES_TABLE."
          WHERE cat_id = 
$cat_id
          LIMIT 1"
;
  $result $site_db->query_firstrow($sql);
$cat_name $result['cat_name'];
  for ($i 1$i <= count($image_list[$key]); $i++)
    {
    $ii++;
   //Check Image
    $file_type get_file_extension($image_list[$key][$i-1]);
      
$iptc_auto_now = (($iptc_name || $iptc_date || $iptc_description || $iptc_keywords) && $imageinfo = @getimagesize(MEDIA_PATH.$cat_path."/".$image_list[$key][$i-1], $info)) ? 0;
    $image_name get_file_name($image_list[$key][$i-1]);
    $date date("Y-m-d H:i:s"time());

    $thumb_file 0;
    if (file_exists(THUMB_PATH.$cat_path."/".$image_name.".jpg"))
      {
      $thumb_file $image_name.".jpg";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".JPG"))
      {
      $thumb_file $image_name.".JPG";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".jpeg"))
      {
      $thumb_file $image_name.".jpeg";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".JPEG"))
      {
      $thumb_file $image_name.".JPEG";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".gif"))
      {
      $thumb_file $image_name.".gif";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".GIF"))
      {
      $thumb_file $image_name.".GIF";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".png"))
      {
      $thumb_file $image_name.".png";
    }
    elseif (file_exists(THUMB_PATH.$cat_path."/".$image_name.".PNG"))
      {
      $thumb_file $image_name.".PNG";
    }
      
$image_name str_replace("_"" "$image_name);
      
$image_name str_replace("%20"" "$image_name);
      
$image_description $image_name;
//added the following line to get the cat name as the image name ..

  $image_name $cat_name;
    $checked = (isset($HTTP_POST_VARS['image_name_'.$ii]) && (!isset($HTTP_POST_VARS['addimage_'.$ii]) || $HTTP_POST_VARS['addimage_'.$ii] != 1) || $status) ? "" " checked=\"checked\"";

    if ($detailed)
      {
      show_table_separator("<input type=\"checkbox\" name=\"addimage_".$ii."\" value=\"1\"".$checked." /> ".$image_list[$key][$i-1], 2);
      show_custom_row($lang['cni_foundin']." ", ($cat_name == "" && !$key) ? "[".$lang['cni_root_folder']."]" $cat_name." (ID:$key)");
      if ($file_type == "gif" || $file_type == "jpg"  || $file_type == "png")
        {
        $file_src MEDIA_PATH.$cat_path."/".$image_list[$key][$i-1];
          
$img_info = @getimagesize($file_src);
          
$width $max_dimension;
          
$height $max_dimension;
          if (
$img_info[0] > && $img_info[1] > 0)
          {
        
if ($img_info[0] > $width || $img_info[1] > $height)
            {
        
   $ratio $img_info[0] / $img_info[1];
        
  if ($ratio 1)
              {
        
    $width $max_dimension;
        
    $height round(($max_dimension $img_info[0]) * $img_info[1]);
        
  }
        
  else
              {
        
    $width round(($max_dimension $img_info[1]) * $img_info[0]);
        
    $height $max_dimension;
        
  }
        
}
            else
            {
        
$width $img_info[0];
        
$height $img_info[1];
        
}
        
}
        show_image_row($lang['image']."<br /><span class=\"smalltext\">(".$img_info[0]."x".$img_info[1].")</span>"$file_src1""$height$width);
      }
      else
        {
        show_image_row($lang['image'], ICON_PATH."/".$file_type.".gif"1);
      }
      show_hidden_input("image_media_file_".$ii$image_list[$key][$i-1]);

      if ($thumb_file)
        {
        $thumb_src THUMB_PATH.$cat_path."/".$thumb_file;
          
$img_info = @getimagesize($thumb_src);
          
$width 48;
          
$height 48;
          
$dim $width;
          if (
$img_info[0] > && $img_info[1] > 0)
          {
        
if ($img_info[0] > $width || $img_info[1] > $height)
            {
        
   $ratio $img_info[0] / $img_info[1];
        
  if ($ratio 1)
              {
        
    $width $dim;
        
    $height round(($dim $img_info[0]) * $img_info[1]);
        
  }
        
  else
              {
        
    $width round(($dim $img_info[1]) * $img_info[0]);
        
    $height $dim;
        
  }
        
}
            else
            {
        
$width $img_info[0];
        
$height $img_info[1];
        
}
        
}
        show_image_row($lang['thumb'], $thumb_src1""$height$width);
        show_hidden_input("image_thumb_file_".$ii$thumb_file);
      }
      else
        {
        show_custom_row($lang['thumb'], $lang['no_thumb_newimages_ext']);
        show_hidden_input("image_thumb_file_".$ii"");
      }
      show_input_row($lang['field_download_url'].$lang['download_url_desc'], "image_download_url_".$ii""$textinput_size);


      $image_name = (isset($error['image_name_'.$ii]) && isset($HTTP_POST_VARS['image_name_'.$ii])) ? $HTTP_POST_VARS['image_name_'.$ii] : str_replace("_"," "$image_name);
        
$iptc "";
        if (isset(
$info['APP13']))
        {
          
$iptc iptcparse($info['APP13']);
        }
        if (
is_array($iptc) && $iptc_name)
        {
          if (isset(
$iptc['2#005'][0]))
          {
            
$image_name $iptc['2#005'][0];
          }
        }
      $title $lang['field_image_name'].((isset($file_src)) ? get_iptc_insert_link($file_src"object_name""image_name_".$ii0) : "");
      show_input_row($title"image_name_".$iistripslashes($image_name), $textinput_size);

      $title $lang['field_description_ext'].((isset($file_src)) ? get_iptc_insert_link($file_src"caption""image_description_".$ii) : "");
        
$caption "";
        if (
is_array($iptc) && $iptc_description)
        {
          
$caption = (isset($iptc['2#120'][0])) ? $iptc['2#120'][0] : "";
// Uncomment lines below, to add date into captions
/*
          if (isset($iptc['2#055'][0]))
          {
            $caption .= (($caption != "") ? "\n" : "").$iptc['2#055'][0];
            $caption = preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})/", "\\1-\\2-\\3", $caption);
          }
*/
        
}
        
show_textarea_row($title"image_description_".$i$caption$textarea_size);

      $title $lang['field_keywords_ext'].((isset($file_src)) ? get_iptc_insert_link($file_src"keyword""image_keywords_".$ii) : "");
        
$keywords "";
        if (
is_array($iptc) && $iptc_keywords)
        {
          if (isset(
$iptc['2#025']))
          {
            foreach (
$iptc['2#025'] as $val)
            {
              
$keywords .= (($keywords != "" ) ? " " "").$val;
            }
          }
        }
//added following line to get auto keywords
//     $keywords =  "sexy $cat_name wallpapers, $cat_name gallery pictures, images, photo albums";
        
show_textarea_row($title"image_keywords_".$i$keywords$textarea_size);
      if (isset($error['cat_id_'.$ii]))
        {
    $title sprintf("<span class=\"marktext\">%s *</span>"$lang['field_category']);
  
}
        else
        {
  
$title $lang['field_category'];
  
}
  echo "<tr class=\"".get_row_bg()."\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n<td>".get_category_dropdown($cat_id03$ii)."</td>\n</tr>\n";

      show_user_select_row($lang['user'], $user_id$ii);

        if (
is_array($iptc) && $iptc_date)
        {
          {
            
$date = (isset($iptc['2#055'][0])) ? preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})/""\\1-\\2-\\3"$iptc['2#055'][0]) : $date;
          }
        }
      $title $lang['field_date'].$lang['date_desc'].$lang['date_format'].((isset($file_src)) ? get_iptc_insert_link($file_src"date_created""image_date_".$ii0) : "");
      show_input_row($title"image_date_".$ii$date$textinput_size);

      show_hidden_input("old_cat_id_".$ii$cat_id);
      show_radio_row($lang['field_free'], "image_active_".$ii1);
      show_radio_row($lang['field_allow_comments'], "image_allow_comments_".$ii1);
      show_additional_fields("image", array(), IMAGES_TABLE$ii);
    }
    else
      {
      echo "<tr class=".get_row_bg().">\n";
      echo "<td><input type=\"checkbox\" name=\"addimage_".$ii."\" value=\"1\"$checked></td>\n";
      $link "<a href=\"".MEDIA_PATH.$cat_path."/".$image_list[$key][$i-1]."\" target=\"_blank\">".$image_list[$key][$i-1]."</a>";
      show_hidden_input("image_media_file_".$ii$image_list[$key][$i-1]);
      if ($thumb_file)
        {
        $file_src THUMB_PATH.$cat_path."/".$thumb_file;
          
$img_info = @getimagesize($file_src);
          
$width 48;
          
$height 48;
          
$dim $width;
          if (
$img_info[0] > && $img_info[1] > 0)
          {
        
if ($img_info[0] > $width || $img_info[1] > $height)
            {
        
   $ratio $img_info[0] / $img_info[1];
        
  if ($ratio 1)
              {
        
    $width $dim;
        
    $height floor(($dim $img_info[0]) * $img_info[1]);
        
  }
        
  else
              {
        
    $width floor(($dim $img_info[1]) * $img_info[0]);
        
    $height $dim;
        
  }
        
}
            else
            {
        
$width $img_info[0];
        
$height $img_info[1];
        
}
        
}
        $thumb_status $lang['thumb_newimages_exists'];
        $thumb_status .= "<br><img src=\"".$file_src."\" width=\"".$width."\" height=\"".$height."\">";
        show_hidden_input("image_thumb_file_".$ii$thumb_file);
      }
      else
        {
        $thumb_status $lang['no_thumb_newimages'];
          if (
$thumbpreview)
          {
          $thumb_status .= "<br><img src=\"checkimages.php?action=showthumb&mode=".$image_list[$key][$i-1]."&cat_id=".$cat_id."\">";
        }
        show_hidden_input("image_thumb_file_".$ii"");
      }
      echo "<td><b>".$link."</b><br />-&raquo; ".$thumb_status."</td>\n";
      echo "<td>Found in: ".(($cat_name == "" && !$key) ? "[root folder]" "$cat_name (ID:$key)")."</td>\n";
      if (isset($error['image_name_'.$ii]))
        {
        $field_image_name sprintf("<span class=\"marktext\">%s</span>"$lang['field_image_name']);
        $image_name $HTTP_POST_VARS['image_name_'.$ii];
      }
      else
        {
        $field_image_name $lang['field_image_name'];//sprintf("%s", $lang['field_image_name']);
        $image_name = (isset($HTTP_POST_VARS['image_name_'.$ii])) ? $HTTP_POST_VARS['image_name_'.$ii] : str_replace("_"," "$image_name);
          if (
$iptc_auto_now)
          {
            if (isset(
$info['APP13']))
            {
              
$iptc iptcparse($info['APP13']);
              if (
is_array($iptc))
              {
                if (
$iptc_name && isset($iptc['2#005'][0]))
                {
                  
$image_name =  $iptc['2#005'][0];
                }
                
$caption = ($iptc_description && isset($iptc['2#120'][0])) ? $iptc['2#120'][0] : "";
                
$keywords "";
                if (
$iptc_keywords && isset($iptc['2#025']))
                {
                  foreach (
$iptc['2#025'] as $val)
                  {
                    
$keywords .= (($keywords != "" ) ? " " "").$val;
                  }
                }
                if (
$iptc_date)
                {
                  
$date = (isset($iptc['2#055'][0])) ? preg_replace("/([0-9]{4})([0-9]{2})([0-9]{2})/""\\1-\\2-\\3"$iptc['2#055'][0]) : $date;
                }
              }
            }
          }
      }
      echo "<td>".$field_image_name.":<br /><input type=\"text\" name=\"image_name_".$ii."\" value=\"".stripslashes($image_name)."\">\n";
          
$field_description  $lang['field_description'];
      echo "<td>".$field_description.":<br /><input type=\"text\" name=\"image_description_".$ii."\" value=\"".stripslashes($image_description)."\">\n";
$field_category $lang['field_category'];
      if (isset($error['cat_id_'.$ii]))
        {
        $field_category sprintf("<span class=\"marktext\">%s</span>"$lang['field_category']);
      }
      $cat_id = (isset($HTTP_POST_VARS['cat_id_'.$ii])) ? intval($HTTP_POST_VARS['cat_id_'.$ii]) : $cat_id;
      echo "<td>".$field_category.":<br />".get_category_dropdown($cat_id03$ii)."</td>\n";
      show_hidden_input("old_cat_id_".$ii$cat_id);
      show_hidden_input("image_description_".$iihtmlspecialchars($caption));
      show_hidden_input("image_keywords_".$iihtmlspecialchars($keywords));
      show_hidden_input("image_date_".$iihtmlspecialchars($date));

      echo "<td>".$lang['field_free'].":<br />";
      if (isset($HTTP_POST_VARS['image_active_'.$ii]) && $HTTP_POST_VARS['image_active_'.$ii] == 0)
        {
        $c1 "";
        $c2 " checked=\"checked\"";
      }
      else
        {
        $c1 " checked=\"checked\"";
        $c2 "";
      }
      echo "<input type=\"radio\" name=\"image_active_".$ii."\" value=\"1\"".$c1."> ".$lang['yes']."&nbsp;&nbsp;&nbsp;\n";
      echo "<input type=\"radio\" name=\"image_active_".$ii."\" value=\"0\"".$c2."> ".$lang['no']." ";
      echo "</td>\n";

      echo "<td>".$lang['field_allow_comments'].":<br />";
      if (isset($HTTP_POST_VARS['image_allow_comments_'.$ii]) && $HTTP_POST_VARS['image_allow_comments_'.$ii] == 0)
        {
        $c1 "";
        $c2 " checked=\"checked\"";
      }
      else
        {
        $c1 " checked=\"checked\"";
        $c2 "";
      }
      echo "<input type=\"radio\" name=\"image_allow_comments_".$ii."\" value=\"1\"".$c1."> ".$lang['yes']."&nbsp;&nbsp;&nbsp;\n";
      echo "<input type=\"radio\" name=\"image_allow_comments_".$ii."\" value=\"0\"".$c2."> ".$lang['no']." ";
      echo "</td>\n";
      echo "</tr>\n";
//       show_hidden_input("user_id_".$ii, $user_id);
    }
  }
}
  if (
$num_all_newimages)
  {
  
show_hidden_input("max_dimension"$max_dimension);
  
show_hidden_input("num_newimages"$num_newimages);
    
show_hidden_input("detailed"$detailed);
    
show_hidden_input("subcats"$subcats);
    
show_hidden_input("mode"1);
    
show_form_footer($lang['add'], $lang['reset'], $colspan);
  }
  else
  {
    
show_table_footer();
  }
}
show_admin_footer();
?>




Thanks
Batu


Never mind... I fixed this..  Smile
« Last Edit: December 06, 2009, 06:47:38 AM by batu544 » Logged

Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.213 seconds with 19 queries.