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
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
|
#!/usr/bin/perl
#
# wacsupdinfo - Update info files
# (formerly known as updateinfo)
#
# (C) Copyright 2006,2007,2008,2009,2010,2011,2012,2013,2015,2017,2019,
# 2021 B King
# This file is part of WACS.
#
# WACS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# WACS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WACS. If not, see <http://www.gnu.org/licenses/>.
#
use Wacs;
use Wacs::WacsId;
use Wacs::WacsDnl;
use Wacs::WacsStd;
use File::Basename;
use DBI;
use Data::Dumper;
# initialise Wacs
read_conf;
# no need to check_auth on a console application
#
# Global Variables
$treetop=conf_get_attr("fsloc","images");
$startpoint=$treetop;
$title="Unnamed"; # Title
$debug=conf_get_attr("debug","tool_wacsupdinfo");
$name="";
$hair="";
$modelno="";
$setno="";
$setname="";
$srank="";
$attire="";
$curinfo="";
$source="unknown";
$foundry="unknown";
$idlogo="";
$notes="";
$sauto="";
$imagesread=0;
$indexread=0;
$catinfo="";
$catflag="";
$location="";
$locdetail="";
$officon="";
$imagecount=0;
$indexcount=0;
$newone=0;
$sizerecalc=0;
$imgarea="";
$imgcategory="";
$imgdirectory="";
$namestem="";
$download="";
$reldate="";
$proddate="";
$branding="";
$today="";
$land_x=0;
$land_y=0;
$port_x=0;
$port_y=0;
$photog="";
$descfile="";
$updates=0;
$inserts=0;
$relocs=0;
$nodownload=0;
$forceupdate=0;
$updcmd='';
$updflag=0;
%unpackinfo=();
#
# MAIN
# ----
#
init_stuff( "wacsupdinfo" );
if( $ARGV[0] ne "" )
{
if( $ARGV[0] eq "--force" )
{
if( $ARGV[1] eq "" )
{
print "Usage: wacsupdinfo [--force] wacs_sarea\n";
exit -1;
}
$forceupdate=1;
shift @ARGV;
}
$title = $ARGV[0];
$startpoint = $treetop."/".$ARGV[0];
if( $debug )
{
print "Starting wacsupdinfo from: $startpoint\n";
}
}
doscandir( $startpoint );
print "COMPLETED: $inserts new records inserted, $updates updated.\n";
if( $relocs > 0 )
{
print " $relocs of the updates were relocations.\n";
}
if( $nodownload > 0 )
{
print " $nodownload of the updates had no download record.\n";
}
exit 0;
sub init_stuff( $ )
{
my( $myname )=@_;
# database initialisation
$dbienv = conf_get_attr( "database","dbienvvar" );
if( $dbienv ne "" )
{
$ENV{$dbienv}= conf_get_attr( "database","dbienvvalue" );
}
$dbhandle=DBI->connect( conf_get_attr("database","dbiconnect"),
conf_get_attr("database","dbuser"),
conf_get_attr("database","dbpass") ) ||
die("Can't connect to database\nReason given was $DBI::errstr\n");
# tune DBI parameters - insist on lower case fieldnames
$dbhandle->{FetchHashKeyName} = "NAME_lc";
$today = gettoday;
}
sub doscandir( $ )
{
my( $currentdir )=@_;
my( $dirh, $file, $retval, $dnldno );
$curinfo="None";
$imagecount=0;
$sizerecalc=0;
opendir( $dirh, $currentdir );
while( $file = readdir( $dirh ))
{
if( $curinfo ne $currentdir )
{
# print "We enter $currentdir\n";
$imagecount=0;
$indexcount=0;
$land_x = 0;
$land_y = 0;
$port_x = 0;
$port_y = 0;
$dnldno = 0;
# FIXME: try reading the .info.xml file in the
# directory above first.
if( -f $currentdir."/.info" )
{
# print "Reading info file...\n";
readinfo( $currentdir."/.info", $currentdir );
$newone=0;
}
else
{
# print "New Details - setting defaults\n";
$newone=1;
}
$curinfo=$currentdir;
}
$retval = processinfo( filename=>$file,
currentdir=>$currentdir,
newone=>$newone,
sizerecalc=>$sizerecalc );
if( $retval eq "none" )
{
$dnldno = "none";
if( $debug > 2 )
{
print "doscandir: no download but may be ".
"info in .unpack.\n";
}
}
elsif( $retval > 0 )
{
$dnldno = $retval;
if( $debug > 2 )
{
print "doscandir: dnldno = ".$dnldno."\n";
}
}
}
closedir( $dirh );
if( $imagecount > 0 && $title ne "")
{
# FIXME: Check for both types - need to see if .info.xml
# contains this set yet?
if( ! -f "$currentdir/.info" )
{
if( $debug > 2 )
{
print "Images found but no info in $currentdir";
print " - writing new .info\n";
}
adddetails_db( setno=>$setno,
currentdir=>$currentdir,
downloadno=>$dnldno );
adddetails_text( legacy=>$currentdir."/.info",
xml=>$currentdir."/../.info.xml" );
}
else
{
if( $debug > 2 )
{
print "Existing info file in $currentdir";
print " - considering updates\n";
}
decode_directory( $currentdir );
do_update( $setno, $currentdir, $forceupdate );
if( $debug > 2 )
{
print "writing $currentdir/.info with catinfo";
print " of $catinfo\n";
}
adddetails_text( legacy=>$currentdir."/.info",
xml=>$currentdir."/../.info.xml" );
}
# clear down now we've written it
$title="";
$imagecount=0;
$indexcount=0;
$foundry="unknown";
$source="usenet";
$location="";
$attire="";
$reldate="";
$proddate="";
$branding="";
$photog="";
$setno=0;
$newone=0;
$sizerecalc=0;
}
}
sub readinfo( $$ )
{
my( $infofile, $curname )=@_;
my( $key, $value, $unused );
# set defaults
( $key, $value, $unused )= fileparse( $curname );
$title = $curname;
$title =~ s/_/ /g;
$name="";
$hair="";
$modelno="";
$setno="";
$source = "usenet";
$foundry = "unknown";
$location = "";
$attire = "";
$notes = "";
$reldate = "";
$proddate = "";
$branding = "";
$photog = "";
$idlogo = "no";
$imagesread = 0;
$indexread = 0;
# get what is there
open( info, "< $infofile" ) || die "No such file as $infofile\n";
while( <info> )
{
chomp;
( $key, $value ) = split( /=/, $_, 2 );
if ( $key eq "title" )
{
$title = $value;
}
if( $key eq "name" )
{
$name = $value;
}
if( $key eq "hair" )
{
$hair = $value;
}
if( $key eq "setno" )
{
$setno = $value;
}
if( $key eq "modelno" )
{
$modelno = $value;
}
if( $key eq "source" )
{
$source = $value;
}
if( $key eq "foundry" )
{
$foundry = $value;
}
if( $key eq "notes" )
{
$notes = $value;
}
if( $key eq "indexes" )
{
$indexread = $value;
}
if( $key eq "images" )
{
$imagesread = $value;
}
if( $key eq "idlogo" )
{
$idlogo = $value;
}
if( $key eq "catinfo" )
{
$catinfo = $value;
}
if( $key eq "location" )
{
$location = $value;
}
if( $key eq "attire" )
{
$attire = $value;
}
if( $key eq "sreldate" )
{
$reldate = $value;
}
if( $key eq "sproddate" )
{
$proddate = $value;
}
if( $key eq "sbranding" )
{
$branding = $value;
}
if( $key eq "photog" )
{
$photog = $value;
}
}
close( INFO );
}
sub processinfo( % )
{
my( %params )=@_;
my( $pifile, $picurrentdir, $pinewone, $pisizerecalc );
my( $pidnldno );
$pifile = $params{'filename'};
$picurrentdir = $params{'currentdir'};
$pinewone = $params{'newone'};
$pisizerecalc = $params{'sizerecalc'};
if( $debug > 4 )
{
print STDERR "processinfo: called with ".$pifile.
" and ".$picurrentdir."\n";
}
# check for being an excluded file
if( ! checkexclude( $pifile ) )
{
# is it a directory?
if( -d $picurrentdir."/".$pifile )
{
# if it's not spares, recursively call doscandir
if( $file ne "spares" && $file ne ".index" )
{
doscandir( "$picurrentdir/$pifile" );
}
}
else
{
# it's (most likely) a regular file
$_ = $pifile;
# sanity checks first
$imagecount++;
# check the sizes for each file, not just the first.
if( $pisizerecalc == 1 )
{
getsizes( $picurrentdir, $pifile );
}
# is this a new record?
if( $pinewone == 1 )
{
print "New One: Generating defaults.\n";
guessinfo( $picurrentdir );
getsizes( $picurrentdir, $pifile );
$namestem = find_namestem($picurrentdir);
if( -f $picurrentdir."/.unpack" )
{
print "Reading .unpack file".
" in ".$picurrentdir."\n";
# read_unpack calls dnld_img
$pidnldno = read_unpack(
$picurrentdir."/.unpack",
$namestem );
}
else
{
$pidnldno = dnld_img(
'dfname'=>$namestem,
'dbhandle'=>$dbhandle );
}
guesscatflag( $pidnldno, $catinfo,
$picurrentdir);
if( $photog eq "" )
{
# try namestem method if not known
# from the download record
$photog = extractphotog( $namestem,
conf_get_attr("tables","photographer"),
$dbhandle );
}
# updating globals
$sizerecalc = 1;
$newone = 0;
if( $pidnldno == 0 )
{
$nodownload++;
}
}
}
}
return( $pidnldno );
}
sub adddetails_text( % )
{
my( %adtparams )=@_;
my( $adtoutfile, $adtxmlout, $adtsethash );
my( $adgroup, $adnewone );
$adtoutfile = $adtparams{'legacy'};
$adtxmlout = $adtparams{'xml'};
$adnewone = 0;
$adtsethash = {};
# FIXME: needs to look for setno object in XML file
if( ! -f $adtoutfile )
{
$adnewone++;
}
# write to the file
open( OUTFILE, "> $adtoutfile" ) || die "Can't open $adtoutfile\n";
print OUTFILE "title=$title\n";
print OUTFILE "name=$name\n";
print OUTFILE "hair=$hair\n";
print OUTFILE "setno=$setno\n";
print OUTFILE "modelno=$modelno\n";
print OUTFILE "source=$source\n";
print OUTFILE "foundry=$foundry\n";
print OUTFILE "location=$location\n";
print OUTFILE "attire=$attire\n";
print OUTFILE "notes=$notes\n";
print OUTFILE "indexes=$indexcount\n";
print OUTFILE "images=$imagecount\n";
print OUTFILE "idlogo=$idlogo\n";
print OUTFILE "catinfo=$catinfo\n";
print OUTFILE "sreldate=$reldate\n";
print OUTFILE "sproddate=$proddate\n";
print OUTFILE "sbranding=$branding\n";
print OUTFILE "photog=$photog\n";
close( OUTFILE );
# start working on new XML version of this file
# FIXME: should check for existing entry for this set number
$adtsethash->{name} = "set".$setno;
$adtsethash->{stitle} = $title;
$adtsethash->{mname} = $name;
$adtsethash->{mhair} = $hair;
$adtsethash->{asetno} = $setno;
$adtsethash->{amodelno} = $modelno;
$adtsethash->{ssource} = $source;
$adtsethash->{sfoundry} = $foundry;
$adtsethash->{slocation} = $location;
$adtsethash->{sattire} = $attire;
$adtsethash->{snotes} = $notes;
$adtsethash->{sindexes} = $indexcount;
$adtsethash->{simages} = $imagecount;
$adtsethash->{sidlogo} = $idlogo;
$adtsethash->{scatinfo} = $catinfo;
$adtsethash->{sreldate} = $reldate;
$adtsethash->{sproddate} = $proddate;
$adtsethash->{sbranding} = $branding;
$adtsethash->{photog} = $photog;
info_addupdate( filename=> $adtxmlout,
setno=>$setno,
setinfo=>$adtsethash );
# set it's permissions correctly so it isn't inaccessible to the
# web user (or vice versa) but ONLY IF WE'RE CREATING THIS FILE
if( $adnewone == 1 )
{
$adgroup = conf_get_attr("security","admingroup");
if( $adgroup ne "" )
{
print "adddetails_text: chgrp ".$adgroup." ".
$adtoutfile."\n";
# old individual file
system( "chgrp ".$adgroup." ".$adtoutfile ) ||
print STDERR "adddetails_text: chgrp ".$adgroup.
" failed on ".$adtoutfile."\n";
system( "chmod ug+rwX ".$adtoutfile );
# new shared XML file
system( "chgrp ".$adgroup." ".$adtxmlout ) ||
print STDERR "adddetails_text: chgrp ".$adgroup.
" failed on ".$adtxmlout."\n";
system( "chmod ug+rwX ".$adtxmlout );
}
}
}
sub adddetails_db( % )
{
my( %params )=@_;
my( $adrefno, $addirectory, $adisdnl, $adoffdir, $adoffarchive );
my( $adsrank, $adsprev, $adsduplicates, $adsaltmedia, $adsdownload );
my( $adsproddate, $adsreldate, $adsbranding, $adphotog, $adsdesc );
my( $nextsql, $nextcsr, @nextrec );
my( $vendsql, $vendcsr, @vendrec );
my( $modsql, $modcsr, @modrec, $modattr, $setinfo, $inssql );
my( $nextref, $shortid, $addnldno, $setpos, $desctext );
my( %adnew, $adinssql, $adkey );
$adrefno = $params{'setno'};
$addirectory = $params{'currentdir'};
$adisdnl = $params{'downloadno'};
decode_directory( $addirectory );
if( $adrefno > 0 )
{
if( $debug > 1 )
{
print "WARNING: reached do_update() from adddetails\n";
}
# maybe do an update here
do_update( $adrefno, $addirectory );
# write back any changes to the .info file
adddetails_text( legacy=>$addirectory."/.info",
xml=>$addirectory."../.info.xml" );
return;
}
# sort out the id and set name
$shortid = "";
if( lc($idlogo) eq "yes" )
{
$shortid="Y";
}
if( lc($idlogo) eq "no" )
{
$shortid="N";
}
if( lc($idlogo) eq "unknown" )
{
$shortid="U";
}
$setname = id_get_setname;
$modelno = id_get_modelno;
# see if we have a set description file
# fetch the model attributes
$modattr = '';
if( int( $modelno ) > 0 )
{
$modsql = "select mattributes from ".
conf_get_attr("tables","models")." where ".
"modelno = '".int( $modelno )."' ";
$modcsr = $dbhandle->prepare( $modsql );
$modcsr->execute;
if( @modrec = $modcsr->fetchrow_array )
{
$modattr = $modrec[0];
}
}
if( $debug > 1 )
{
print "retrieved model no in adddetails_db is: ".$modelno.
" and downloadno=".$adisdnl."\n";
if( $modattr ne "" )
{
print "model attributes for ".$modelno." are: ".
$modattr."\n";
}
}
$foundry = id_get_vendor;
$catflag = id_get_flag;
$setinfo = $catinfo; # catinfo should be a global var with stuff in it
if( $modattr ne "" )
{
$setinfo = removeconflicts( model=>$modattr,
existing=>$catinfo );
$setinfo .= " ".$modattr." ".$catinfo; # FixMe: May replace
# clashing attribs
$setinfo = removedups( $setinfo );
}
# new additions for Wacs 0.9.x
$adsrank = id_get_srank;
$adsprev = id_get_sprev;
$sduplicates = id_get_sduplicates;
$adsaltmedia = id_get_saltmedia;
$adsdownload = id_get_sdownload;
# new additions for Wacs 1.0.x
$adsproddate = id_get_sproddate;
$adsreldate = id_get_sreldate;
print "id_get_sreldate = ".$adsreldate."\n";
$adsbranding = id_get_sbranding;
$adphotog = id_get_attr('download','photog');
# get the vendor shortname from the database
$vendsql = "select vshortname from ".conf_get_attr("tables","vendor");
$vendsql .= " where vsite = ? ";
$vendcsr = $dbhandle->prepare( $vendsql );
$vendcsr->execute( id_get_vendor );
if( @vendrec = $vendcsr->fetchrow_array )
{
if( $vendrec[0] ne "" )
{
$foundry = $vendrec[0];
if( $adisdnl > 0 )
{
$source = "subscription";
}
}
}
# catch-all for non-existant download record
if( $debug > 2 )
{
print "adddetails_db: setname is ".$setname.".\n";
print "adddetails_db: modelno is ".$modelno.".\n";
print "adddetails_db: setinfo is ".$setinfo.".\n";
print "adddetails_db: catinfo is ".$catinfo.".\n";
print "adddetails_db: catflag is ".$catflag.".\n";
print "adddetails_db: foundry is ".$foundry.".\n";
print "adddetails_db: reldate is ".$adsreldate.".\n";
print "adddetails_db: proddate is ".$adsproddate.".\n";
print "adddetails_db: branding is ".$adsbranding.".\n";
}
# check for a pre-existing official icon and work out what
# it would be called - this now includes converting the
# possible archive names in to .jpg extensions.
$adoffdir='';
$adoffarchive=$adsdownload;
$adoffarchive=~ s/\.zip$//;
$adoffarchive=~ s/\.tar$//;
$adoffarchive=~ s/\.tgz$//;
$adoffarchive=~ s/\.rar$//;
if( $imgarea ne "" )
{
$adoffdir = $imgarea."/";
}
if( $imgcategory ne "" )
{
$adoffdir.= $imgcategory."/";
}
if( $imgdirectory ne "" )
{
# is there an icon file called the name of the directory?
if( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
$imgdirectory.".jpg" )
{
$officon = $adoffdir.$imgdirectory.".jpg";
}
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
$imgdirectory.".png" )
{
$officon = $adoffdir.$imgdirectory.".png";
}
# is there an icon file called the name of the archive but
# with a image extension instead of the archive extension?
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
$adoffarchive.".jpg" )
{
$officon = $adoffdir.$adoffarchive.".jpg";
}
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
$adoffarchive.".png" )
{
$officon = $adoffdir.$adoddarchive.".png";
}
# is there an icon file called the modelkey_setkey?
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
id_get_key."_".id_get_setkey.".jpg" )
{
$officon = $adoffdir."/".id_get_key."_".
id_get_setkey.".jpg";
}
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
id_get_key."_".id_get_setkey.".png" )
{
$officon = $adoffdir."/".id_get_key."_".
id_get_setkey.".png";
}
# is there an icon file called the modelkey-setkey?
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
id_get_key."-".id_get_setkey.".jpg" )
{
$officon = $adoffdir."/".id_get_key."-".
id_get_setkey.".jpg";
}
elsif( -f conf_get_attr("fsloc","officons")."/".$adoffdir.
id_get_key."-".id_get_setkey.".png" )
{
$officon = $adoffdir."/".id_get_key."-".
id_get_setkey.".png";
}
# hopefully it was one of those options....
if( $debug )
{
if( $officon ne "" )
{
print "Found official icon at ".$officon."\n";
}
}
}
# see if we have a text description file passed from .unpack
$desctext='';
if( $debug > 1 )
{
print STDERR "adddetails_db: descfile: ".$descfile."\n";
}
if( -f $descfile )
{
# confirm
#if( debug > 2 )
#{
print STDERR "adddetails_db: .unpack specified a file ".
"containing the set description. (".
$descfile.")\n";
#}
# it exists
open( DESCFILE, "< ".$descfile ) ||
print STDERR "Could not open specified description ".
$descfile."\n";
while( $descline = <DESCFILE> )
{
chomp( $descline );
$desctext .= $descline." ";
}
close( DESCFILE );
# remove last space, then check is it too long for the field?
chop( $desctext );
if( length($desctext) < 2048 )
{
$adsdesc = makedbsafe( string=>$desctext );
}
else
{
print STDERR "adddetails_db: description text ".
"excluded because ".length($desctext).
" is too big.\n";
}
}
# calculate next number
$nextsql = "select max(setno) from ".conf_get_attr("tables","sets");
$nextcsr = $dbhandle->prepare( $nextsql );
$nextcsr->execute;
@nextrec = $nextcsr->fetchrow_array;
$nextref = ( $nextrec[0] +1 );
print "Adding to database - next no is $nextref (".$adsrank.")\n";
if( $nextref < 1 )
{
die "Can't get next number\n";
}
# OK, got the number, lets insert
# OLD METHOD FIRST THEN NEW
$setno = $nextref;
$inssql = "insert into ".conf_get_attr("tables","sets");
# 0 1 2 3
$inssql .= " ( setno, stype, sstatus, sformat, ";
# 4 5 6 7 8 9
$inssql .= "stitle, sname, shair, smodelno, ssource, sfoundry, ";
# 10 11 12 13 14
$inssql .= "snotes, sindexes, simages, sidlogo, scatinfo, ";
# 15 16 17 18 19 20
$inssql .= "sarea, scategory, sdirectory, slandx, slandy, sportx, ";
# 21 22 23 24 25 26
$inssql .= "sporty, snamestem, sphotog, sauto, sofftitle, slocation, ";
# 27 28 29 30 31 32
$inssql .= "scatflag, sattire, slocdetail, sofficon, srank, sprev, ";
# 33 34 35 36 37
$inssql .= "sduplicates, saltmedia, sdownload, sproddate, sreldate, ";
# 38 39 40
$inssql .= "sbranding, sdesc, sadded ) ";
$inssql .= "values (";
# and now the contents
# NEW METHOD FOLLOWS OLD
# 0 - 3 - what
$inssql .= "'".$setno."','I','A','JPEG','";
$adnew{setno} = $setno;
$adnew{stype} = 'I';
$adnew{sstatus} = 'A';
$adnew{sformat} = 'JPEG';
# 4 - 7 - who
$inssql .= $title."','".$name."','".$hair."','".$modelno."','";
$adnew{stitle} = $title;
$adnew{sname} = $name;
$adnew{shair} = $hair;
$adnew{smodelno} = $modelno;
# 8 - 10 - where
$inssql .= $source."','".$foundry."','".$notes."','";
$adnew{ssource} = $source;
$adnew{sfoundry} = $foundry;
$adnew{snotes} = $notes;
# 11 - 12 - stats
$inssql .= $indexcount."','".$imagecount."','";
$adnew{sindexes} = $indexcount;
$adnew{simages} = $imagecount;
# 13 - 15 - misc, type and path component
$inssql .= $shortid."','".$setinfo."','".$imgarea."','";
$adnew{sidlogo} = $shortid;
$adnew{scatinfo} = $setinfo;
$adnew{sarea} = $imgarea;
# 16 - 17 - more path components
$inssql .= $imgcategory."','".$imgdirectory."','";
$adnew{scategory} = $imgcategory;
$adnew{sdirectory} = $imgdirectory;
# 18-21 - image size
$inssql .= $land_x."','". $land_y."','". $port_x."','". $port_y ."','";
$adnew{slandx} = $land_x;
$adnew{slandy} = $land_y;
$adnew{sportx} = $port_x;
$adnew{sporty} = $port_y;
# 22-25 - namestem, photographer, sauto and setname (official title)
$inssql .= $namestem."','".$photog."','F','".$setname."','";
$adnew{snamestem} = $namestem;
$adnew{sphotog} = $photog;
$adnew{sauto} = 'F';
$adnew{sofftitle} = $setname;
# 26-29 - location, catflag, and attire
$inssql .= $location."','".$catflag."','".$attire."','";
$adnew{slocation} = $location;
$adnew{scatflag} = $catflag;
$adnew{sattire} = $attire;
# 29-32 - location detail, official icon, rank, previous
$inssql .= $locdetail."','".$officon."','".$adsrank."','".
$adsprev."','";
$adnew{slocdetail} = $locdetail;
$adnew{sofficon} = $officon;
$adnew{srank} = $adsrank;
$adnew{sprev} = $adsprev;
# 33-35 - duplicates, alternative media and download filename
$inssql .= $adsduplicates."','".$adsaltmedia."','".$adsdownload."','";
$adnew{sduplicates} = $adsduplicates;
$adnew{saltmedia} = $adsaltmedia;
$adnew{sdownload} = $adsdownload;
# 36-38 - dates and branding
$inssql .= $adsproddate."','".$adsreldate."','".$adsbranding."','";
$adnew{sproddate} = $adsproddate;
$adnew{sreldate} = $adsreldate;
$adnew{sbranding} = $adsbranding;
# 39-40 - desc and date stamp
$inssql .= $adsdesc."','".$today."') ";
$adnew{sdesc} = $adsdesc;
$adnew{sadded} = $today;
# create new method insert statement
$adinssql = "insert into ".conf_get_attr("tables","sets")."(";
foreach $adkey ( keys %adnew )
{
$adinssql .= $adkey.",";
}
chop( $adinssql ); # remove stray comma
$adinssql .= ") values (";
foreach $adkey( keys %adnew )
{
if( $adnew{$adkey} eq "" )
{
$adinssql .= "null,";
}
else
{
$adinssql .= "'".$adnew{$adkey}."',";
}
}
chop( $adinssql ); # remove stray comma
$adinssql .= ") ";
if( $debug > 1 )
{
print "adddetails_db: old SQL is: ".$inssql."\n";
print "adddetails_db: New version SQL is: ".$adinssql."\n";
}
$dbhandle->do( $adinssql ) ||
die( "Can't insert record into database\n".
"Command: $inssql\nReason given was $DBI::errstr\n");
$inserts++;
# if we have no download record, push our set number back into the
# unpack file
if( $adisdnl eq "none" )
{
# add the set number to the .unpack file
if( -f $addirectory."/.unpack" )
{
open( UNPACK,">> ".$addirectory."/.unpack");
print UNPACK "setno=".$setno."\n";
close UNPACK;
}
else
{
if( $debug > 2 )
{
print "adddetails_db: couldn't find .unpack".
" file in ".$addirectory."/.unpack\n"
}
}
}
# associate the model with this set
if( $modelno > 0 )
{
addassoc( 'setno'=>$setno,
'modelno'=>$modelno,
'asstype'=>'G',
'dbhandle'=>$dbhandle );
}
else
{
# if we're even slightly checking, grumble
if( $debug > 0 )
{
print STDERR "adddetails_db: can't associate model ".
$modelno." with set ".$setno."\n";
}
}
# get the download information stored earlier
$addnldno = id_get_dnldno;
if( $addnldno > 0 )
{
dnld_markdone( 'setno'=>$setno,
'downloadno'=>$addnldno,
'dbhandle'=>$dbhandle );
}
if( $addnldno ne $adisdnl )
{
print "adddetails_db: download details mismatch: ".
"id_get_dnldno=".$addnldno." param=".
$adisdnl."\n";
}
# check for any related record connections we need to add
# this code matches code from genvideo
if( $adsrank eq "C" )
{
# FIXME: TOTALLY WRONG but will work right for 90%+ sets!
$setpos = 2;
# all of these parameters are from OUR viewpoint not
# that of the set to be updated
linkfromprevious( setno=>$setno,
previous=>$adsprev,
setpos=>$setpos,
dbhandle=>$dbhandle );
}
elsif( $adsrank eq "S" )
{
# all of these parameteres are from OUR viewpoint not
# that of the set to be updated
linkrelated( setno=>$setno,
relatedno=>$adsduplicates,
relationtype=>"duplicate",
dbhandle=>$dbhandle );
}
# and finally do we have an altmedia?
if( int( $adsaltmedia ) > 0 )
{
# once again specified from the viewpoint of the current set
linkrelated( setno=>$setno,
relatedno=>$adsaltmedia,
relationtype=>"altmedia",
dbhandle=>$dbhandle );
}
# now nobble the values so there's none hanging around
reset_attr( 'images');
}
sub decode_directory( $ )
{
my( $wherearewe )=@_;
my( $rest, $junk );
# reset the variables
$imgarea = "";
$imgcategory = "";
$imgdirectory = "";
# remove the top of the tree and then clean the ends
$wherearewe =~ s/$treetop//g;
$wherearewe =~ s/^\///g;
$wherearewe =~ s/\/$//g;
( $imgarea, $rest ) = split( /\//, $wherearewe, 2 );
if( $rest ne "" )
{
( $imgdirectory, $imgcategory, $junk ) = fileparse( $rest );
}
# imgcategory can be left with a trailing slash here, so clean it
# of (or at least try to)
$imgcategory =~ s/\/$//;
}
sub guessinfo( $ )
{
my( $directory )=@_;
my( $fname, $path, $suffix, $kwscat, $kwsloc, $kwsattrib, $kwsattire );
my( $kwslocdet );
my( $vcsql, $vccsr, @vcrec );
# set defaults
( $fname, $path, $suffix ) = fileparse( $directory );
$title = $fname;
$title =~ s/_/ /g;
$fname="";
$hair="";
$modelno="";
$modelattr="";
$source = "usenet";
$foundry = "unknown";
$notes = ""; # changed - sauto now controls this (or should)
$sauto = "F";
$idlogo = "unknown";
$indexread = 0;
$imagesread = 0;
$catinfo = "";
$location = "";
$locdetail = "";
$reldate = "";
$proddate = "";
$branding = "";
# check for toplevel (sarea) directory being a vendor name
$vcsql = "select vsite, vshortname from ";
$vcsql.= conf_get_attr("tables","vendor")." ";
$vcsql.= "where vshortname = ? ";
$vccsr = $dbhandle->prepare( $vcsql );
if( $debug > 3 )
{
print STDERR "directory is: ".$directory."\n";
}
$vccsr->execute( $directory );
if( @vcrec = $vccsr->fetchrow_array )
{
# found a vendor record
$source = "subscription";
$foundry = $vcrec[1];
}
else
{
if( $debug > 2 )
{
print STDERR "Directory: ".$directory.
" not a vendor name\n";
}
}
# do the processing
$_ = $title;
$_ =~ y/A-Z/a-z/;
# new (keyword db based) version
kwscore_reset( 'all' );
kwscore_process( 'string'=>$title,
'dbhandle'=>$dbhandle );
$kwscat=kwscore_get( 'what'=>'cat', 'default'=>'S' );
$kwsloc=kwscore_get( 'what'=>'loc' );
$kwslocdet=kwscore_get( 'what'=>'det' );
$kwsattrib=kwscore_get( 'what'=>'attr' );
$kwsattire=kwscore_get( 'what'=>'other' );
# remove duplicates
$location=$kwsloc;
$locdetail=$kwslocdet;
$attire= removedups( $kwsattire );
$catinfo= removedups( $kwsattrib );
print "Done.\n";
}
sub do_update( $$$ )
{
my( $setno, $curdir, $force )=@_;
my( $chksql, $chkcsr, @chkrec );
my( $modsql, $modcsr, @modrec );
my( $vcsql, $vccsr, @vcrec );
my( $dcsql, $dccsr, @dcrec );
my( $chkattr, $chkcatinfo, $chkphotog, $kwscat, $kwsloc, $kwsattrib );
my( $kwsattire, $kwslocdet, $chkimgcount );
my( $lesbo, $changes, $imgdirh, $imgfile, $chkcatflag, $vendch );
if( $debug > 5 )
{
print "Entering Update routines for $setno ($curdir)\n";
}
$updcmd = "update ".conf_get_attr("tables","sets")." set ";
$updflag=0;
$lesbo=0;
$vendch=0;
$changes='';
$chkimgcount=0;
# 0 1 2 3
$chksql = "select stitle, sarea, scategory, sdirectory, ";
# 4 5 6 7 8 9
$chksql .= "sname, shair, ssource, sfoundry, snotes, scatinfo, ";
# 10 11 12 13 14
$chksql .= "snamestem, sdownload, smodelno, sauto, slandx, ";
# 15 16 17 18 19 20
$chksql .= "slandy, sportx, sporty, sphotog, scatflag, slocation, ";
# 21 22 23 24 25
$chksql .= "sattire, sofftitle, sdesc, slocdetail, simages ";
$chksql .= "from ".conf_get_attr("tables","sets");
$chksql .= " where setno = '".$setno."' ";
$chkcsr = $dbhandle->prepare( $chksql );
$chkcsr->execute;
@chkrec = $chkcsr->fetchrow_array;
if( $chkrec[0] eq "" )
{
print "ERROR: Lack of sensible result for set no $setno\n";
print "Directory was $curdir.\n";
exit -1;
}
# these location checks aren't really conditional
doareacheck( $chkrec[1], $imgarea, $imgdirectory );
docategorycheck( $chkrec[2], $imgcategory, $imgdirectory );
dodircheck( $chkrec[3], $imgdirectory, $chkrec[0] );
# other checks - chkrec8 is notes, chkrec9 is catinfo
if( $chkrec[13] eq "" )
{
# start getting values into the sauto field
# and zero off the old notes field
if( $chkrec[8] eq "auto" )
{
$updcmd .= "sauto = 'F', snotes = '', ";
$updflag++;
}
}
# this routine should trigger ever more rarely as we manage
# to populate the sauto field - it is depricated
if( $chkrec[13] eq "" && $chkrec[8] eq "auto" && $notes ne "auto" )
{
# the text file has been updated and the database
# has not
print "WARNING: found text file newer than DB";
print " - updating $setno\n";
$updcmd .= "snotes = '', ";
$updcmd .= "sname = '".$name."', ";
$updcmd .= "shair = '".$hair."', ";
$updcmd .= "ssource = '".$source."', ";
$updcmd .= "sfoundry = '".$foundry."', ";
$updcmd .= "scatinfo = '".$catinfo."', ";
$updflag++;
}
# Attempt to run the keyword scoring process only once using all
# of the possible fields for processing
kwscore_reset( 'all' );
# process all possible fields: stitle, sofftitle and sdesc
kwscore_process( 'string'=>$chkrec[0],
'dbhandle'=>$dbhandle );
# check if sofftitle or sdesc contain anything before checking
if( $chkrec[22] ne "" )
{
kwscore_process( 'string'=>$chkrec[22],
'dbhandle'=>$dbhandle );
}
if( $chkrec[23] ne "" )
{
kwscore_process( 'string'=>$chkrec[23],
'dbhandle'=>$dbhandle );
}
# rebuild the catinfo for this set if it's either append or
# fully auto
if( $chkrec[13] eq "F" || $chkrec[13] eq "A" )
{
# redo the catinfo guesses
$catinfo = "";
if( $chkrec[13] eq "A" )
{
# for F (Full Auto) we start from scratch
# for A (Append) we only append so we preset
# catinfo to what's in the database
$catinfo = $chkrec[9];
# if we're type A (Append) bring across any
# different value from the catflag field
if( $chkrec[19] eq "F" )
{
$catinfo .= " fuck ";
}
if( $chkrec[19] eq "L" )
{
$catinfo .= " lesbian ";
}
if( $chkrec[19] eq "A" )
{
# All girl is lesbian and (at least) fff
$catinfo .= " lesbian fff ";
}
if( $chkrec[19] eq "T" )
{
$catinfo .= " dildo ";
}
}
$chkattr = impinfofrommodel( $setno );
$kwsattrib=kwscore_get( 'what'=>'attr', 'default'=>$chkrec[9] );
if( $chkattr ne "" )
{
# add model sourced info to that collected by
# guesscatinfo (and placed into catinfo).
$kwsattrib .= " ".removeconflicts( model=>$chkattr,
existing=>$kwsattrib );
}
$kwsattrib= removedups( $kwsattrib );
if( $debug > 2 )
{
print "Catinfo guessed to be: $kwsattrib\n";
}
if( $kwsattrib ne $chkrec[9] )
{
$catinfo = $kwsattrib;
if( $debug )
{
print "Catinfo changed to: [".$kwsattrib.
"] - was [".$chkrec[9]."]\n";
}
$updcmd .= "scatinfo = '".$kwsattrib."', ";
$changes = $changes . " catinfo";
$updflag++;
}
}
# rebuild the location info as well but only if not set in A
if( $chkrec[13] eq "F" )
{
$kwsloc=kwscore_get( 'what'=>'loc' );
$kwslocdet=kwscore_get( 'what'=>'det' );
if( $kwsloc ne $chkrec[20] && $kwsloc ne "" )
{
print "Location changed to: ".$kwsloc." was ".
$chkrec[20]."\n";
$updcmd .= "slocation = '".$kwsloc."', ";
$changes = $changes . " location";
$updflag++;
}
if( $kwslocdet ne $chkrec[24] && $kwslocdet ne "" )
{
print "Location detail changed to: ".$kwslocdet.
" was ".$chkrec[24]."\n";
$updcmd .= "slocdetail = '".$kwslocdet."', ";
$changes = $changes . " locdetail";
$updflag++;
}
}
# and now the attire field if fully automatic
if( $chkrec[13] eq "F" )
{
$kwsattire=kwscore_get( 'what'=>'other' );
if( $kwsattire ne $chkrec[21] && $kwsattire ne "" )
{
if( $debug > 1 )
{
print "Attire changed to: ".$kwsattire." was ".
$chkrec[21]."\n";
}
$updcmd .= "sattire = '".$kwsattire."', ";
$changes = $changes . " attire";
$updflag++;
}
}
# back to the location field, now for append only
if( $chkrec[13] eq "A" && $chkrec[20] eq "" )
{
$kwsloc=kwscore_get( 'what'=>'loc' );
if( $kwsloc ne $chkrec[20] && $kwsloc ne "" )
{
print "Location set to: ".$kwsloc."\n";
$updcmd .= "slocation = '".$kwsloc."', ";
$changes = $changes . " location";
$updflag++;
}
}
# and location detail too
if( $chkrec[13] eq "A" && $chkrec[24] eq "" )
{
$kwslocdet=kwscore_get( 'what'=>'det' );
if( $kwslocdet ne $chkrec[24] && $kwslocdet ne "" )
{
print "Detailed Location set to: ".$kwslocdet."\n";
$updcmd .= "slocdetail = '".$kwsloc."', ";
$changes = $changes . " locdetail";
$updflag++;
}
}
# and again for the attire field for append only
if( $chkrec[13] eq "A" && $chkrec[21] eq "" )
{
$kwsattire=kwscore_get( 'what'=>'other' );
if( $kwsattire ne $chkrec[21] && $kwsattire ne "" )
{
if( $debug > 1 )
{
print "Attire set to: ".$kwsattire."\n";
}
$updcmd .= "sattire = '".$kwsattire."', ";
$changes = $changes . " attire";
$updflag++;
}
}
# recheck the catflag as well
if( $chkrec[19] eq "" || $chkrec[19] eq "N" || $force == 1)
{
# keyword version
$kwscat=kwscore_get( 'what'=>'cat', 'default'=>'S' );
$updcmd .= "scatflag = '".$kwscat."', ";
$changes = $changes . " attributes";
$updflag++;
}
# since solo is the default, and toys is a subset of solo
# we just do a quick recheck that a toys keyword has not
# been added
# FIXME: Do this better now we have several toy keywords
if( $chkrec[19] eq "S" && $catinfo =~ /dildo/ )
{
# WARNING: this will cause a keyword reset
$chkcatflag = guessflag( $catinfo, $chkrec[0] );
$updcmd .= "scatflag = '".$chkcatflag."', ";
$changes = $changes . " attributes";
$updflag++;
}
if( $chkrec[19] eq "S" && $catinfo =~ /vibrator/ )
{
# WARNING: this will cause a keyword reset
$chkcatflag = guessflag( $catinfo, $chkrec[0] );
$updcmd .= "scatflag = '".$chkcatflag."', ";
$changes = $changes . " attributes";
$updflag++;
}
if( $chkrec[19] eq "S" && $catinfo =~ /massager/ )
{
# WARNING: this will cause a keyword reset
$chkcatflag = guessflag( $catinfo, $chkrec[0] );
$updcmd .= "scatflag = '".$chkcatflag."', ";
$changes = $changes . " attributes";
$updflag++;
}
if( $chkrec[10] eq "" || $force == 1 )
{
$namestem = find_namestem( $curdir );
if( $namestem ne "" )
{
$updcmd .= "snamestem = '".$namestem."', ";
$changes = $changes . " namestem";
$updflag++;
if( $chkrec[11] eq "" &&
$chkrec[1] eq "sapphicerotica" )
{
$download = $namestem .".zip";
$updcmd .= "sdownload = '".$download."', ";
$updflag++;
}
}
}
if( $chkrec[14] == 0 && $chkrec[16] == 0 || $force == 1 )
{
# update image sizes
print "Calculating image size information\n";
$changes = $changes . " imgsize";
opendir( $imgdirh, $curdir );
while( $imgfile = readdir( $imgdirh ))
{
if( ! checkexclude( $imgfile) )
{
getsizes( $curdir, $imgfile );
}
}
closedir( $imgdirh );
print "image sizes are: landscape ";
print "$land_x by $land_y\n";
print " : portrait ";
print "$port_x by $port_y\n";
if( $land_x > 0 )
{
if( $land_y > 0 )
{
$updcmd .= "slandx = '$land_x', ";
$updcmd .= "slandy = '$land_y', ";
}
$updflag++;
}
if( $port_x > 0 )
{
if( $port_y > 0 )
{
$updcmd .= "sportx = '$port_x', ";
$updcmd .= "sporty = '$port_y', ";
}
$updflag++;
}
}
# check image counts
if( $chkrec[25] == 0 || $force == 1 )
{
# update image count
print "Calculating image count information\n";
$changes = $changes . " imgcount";
opendir( $imgdirh, $curdir );
while( $imgfile = readdir( $imgdirh ))
{
if( ! checkexclude( $imgfile) )
{
$chkimgcount++;
}
}
closedir( $imgdirh );
$updcmd .= "simages = '".$chkimgcount."', ";
$updflag++;
}
# recheck the photographer info
if( $chkrec[18] eq "" || $force == 1 )
{
# no photographer set
$chkphotog = extractphotog( $chkrec[10],
conf_get_attr("tables","photographer"), $dbhandle );
if( $chkphotog ne "" )
{
$updcmd .= "sphotog = '".$chkphotog."', ";
$changes = $changes . " photographer";
$updflag++;
}
}
# recheck for vendor site name from path
if( $chkrec[13] eq "F" || $chkrec[13] eq "A" )
{
# check for toplevel (sarea) directory being a vendor name
$vcsql = "select vsite, vshortname from ";
$vcsql.= conf_get_attr("tables","vendor")." ";
$vcsql.= "where vshortname = ? ";
$vccsr = $dbhandle->prepare( $vcsql );
if( $debug > 3 )
{
print STDERR "directory is: ".$chkrec[1]."\n";
}
$vccsr->execute( $chkrec[1] );
if( @vcrec = $vccsr->fetchrow_array )
{
# if the foundry isn't specified and the sarea
# is a vendor name, set the foundry to the vendor
# NB: This is a fix from an overzealous previous
# version which didn't work for third-party
# licensed content (ie baremaidens sets on
# adulttime).
if( $chkrec[7] eq "" && $chkrec[1] eq $vcrec[1])
{
# found a vendor record
$updcmd .= "sfoundry = '".$vcrec[1]."', ";
$changes = $changes . " foundry";
$updflag++;
$vendch++;
}
}
}
# check for download record if default values
if( $chkrec[7] eq "unknown" && $vendch == 0 &&
( $chkrec[13] eq "F" || $chkrec[13] eq "A" ))
{
# 0 1 2 3 4
$dcsql = "select downloadno, dsite, dstatus, dtype, dmodelno ";
$dcsql.= "from ".conf_get_attr("tables","download")." ";
$dcsql.= "where dsetno = ? ";
$dccsr = $dbhandle->prepare( $dcsql );
$dccsr->execute( $setno );
if( @dcrec = $dccsr->fetchrow_array )
{
if( $debug > 1 )
{
print STDERR "Found vendor ".$dcrec[1].
" via download for ".$setno."\n";;
}
$vcsql = "select vsite, vshortname from ";
$vcsql.= conf_get_attr("tables","vendor")." ";
$vcsql.= "where vsite = ? ";
$vccsr = $dbhandle->prepare( $vcsql );
$vccsr->execute( $dcrec[1] );
if( @vcrec = $vccsr->fetchrow_array )
{
# found a vendor record
$updcmd .= "ssource = 'subscription', ";
$updcmd .= "sfoundry = '".$vcrec[1]."', ";
$changes = $changes . " source foundry";
$updflag++;
}
}
}
if( $updflag == 0 )
{
# nothing to do
return;
}
# do the update
$updcmd .= "samended = '".$today."' where setno = '".$setno."' ";
print "Updating set no $setno with changed";
print "$changes in database\n";
if( $debug > 2 )
{
print "SQL is: $updcmd\n";
}
$dbhandle->do( $updcmd );
if( $DBI::errstr ne "" )
{
print "ERROR: Database routines report $DBI::errstr\n";
print "SQL Query was: $updcmd\n";
exit -1;
}
# keep stats
$updates++;
}
sub doareacheck( $$$ )
{
my( $curarea, $newarea, $newdir )=@_;
# image area check
if( $curarea eq "" && $newarea ne "" )
{
$updcmd .= "sarea = '".$newarea."', ";
$updflag++;
}
if( $curarea ne "" && $curarea ne $newarea )
{
# check for relocation
if( $debug )
{
print "$newdir appears to have moved ";
print "from $curarea to $newarea\n";
}
$updcmd .= "sarea = '".$newarea."', ";
$changes = $changes . " fsloc";
$updflag++;
$relocs++;
}
}
sub docategorycheck( $$$ )
{
my( $curcateg, $newcateg, $newdir )=@_;
# image category check
if( $curcateg eq "" && $newcateg ne "" )
{
$updcmd .= "scategory = '".$newcateg."', ";
$updflag++;
}
if( $curcateg ne "" && $curcateg ne $newcateg )
{
# relocation check
if( $debug )
{
print "$newdir appears to have moved ";
print "from $curcateg to $newcateg\n";
}
$updcmd .= "scategory = '".$newcateg."', ";
$updflag++;
$relocs++;
}
}
sub dodircheck( $$$ )
{
my( $curdir, $newdir, $prevtitle )=@_;
my( $chktitle );
# image directory check
if( $curdir eq "" && $newdir ne "" )
{
$updcmd .= "sdirectory = '".$newdir."', ";
$updflag++;
}
if( $curdir ne "" && $curdir ne $newdir )
{
# the directory name appears to have changed
print "$newdir appears to have been ";
print "renamed from $curdir\n";
# change stitle and imgdirectory
$chktitle = $curdir;
$chktitle =~ s/_/ /g;
if( $chktitle eq $prevtitle )
{
# the old title was the directory name with spaces
print "The old title was the directory ";
print "name ($prevtitle).\n";
$chktitle = $newdir;
$chktitle =~ s/_/ /g;
if( $chktitle ne "" )
{
$updcmd .= "stitle = '".$chktitle."', ";
$updflag++;
print "Title changed from $prevtitle ";
print "to $chktitle\n";
$title = $chktitle;
}
}
# change the directory entry anyway
$updcmd .= "sdirectory = '".$newdir."', ";
$changes = $changes . " title";
$updflag++;
$relocs++;
}
}
sub impinfofrommodel( $ )
{
my( $targetset )=@_;
my( $chkhair, $chkname, $retattr, $islesbo );
$islesbo = 0;
# Auto or no modelno set
if( $targetset ne "" )
{
$modelno="";
$chkhair="";
$chkname="";
$retattr="";
$modsql = "select modelno, mname, mhair, mattributes ";
$modsql .= "from ".conf_get_attr("tables","models");
$modsql .= ", ".conf_get_attr("tables","assoc");
$modsql .= " where amodelno = modelno and ";
$modsql .= "asetno = '".$targetset."' ";
$modcsr = $dbhandle->prepare( $modsql );
$modcsr->execute;
while( @modrec = $modcsr->fetchrow_array )
{
if( $modrec[0] ne "" )
{
if( $modelno eq "" )
{
# first model
$modelno = $modrec[0];
$chkname = $modrec[1];
$chkhair = $modrec[2];
$retattr = $modrec[3];
}
else
{
# looking lesbo
$modelno .= ",".$modrec[0];
$chkname .= ",".$modrec[1];
$chkhair .= ",".$modrec[2];
$retattr .= " ".$modrec[3];
$islesbo++;
}
}
}
if( $modelno ne "" )
{
# this seems to always happen which it
# probably shouldn't
$updcmd .= "smodelno = '".$modelno."', ";
# lets say this isn't an update unless
# something else changes
#$updflag++;
}
if( $name ne $chkname )
{
$name = $chkname;
$updcmd .= "sname = '".$name."', ";
$changes = $changes . " names";
$updflag++;
}
if( $hair ne $chkhair )
{
$hair = $chkhair;
$updcmd .= "shair = '".$hair."', ";
$updflag++;
}
if( $islesbo > 0 )
{
$retattr .= " lesbian";
}
return( $retattr );
}
return( undef );
}
sub getsizes( $$ )
{
my( $sizedir, $sizefile )=@_;
my( $gsmediaobj );
my( $valuex, $valuey, $result );
if( $sizefile eq ".info" )
{
return;
}
# updated to use media_scan (ExifTool)
$gsmediaobj = media_scan( $sizedir."/".$sizefile );
$valuex = media_get_attr( $gsmediaobj, "width" );
$valuey = media_get_attr( $gsmediaobj, "height" );
if( $valuex == 0 && $valuey == 0 )
{
print "NULL return for $sizefile in $sizedir\n";
return;
}
# print "$sizefile: [$valuex][$valuey]\n";
if( $valuex > 0 && $valuex > $valuey )
{
# should be landscape - width(x) is bigger than height(y)
if( $land_x > 0 )
{
# existing value for landscape
if( $land_x < $valuex )
{
print "new image $sizefile is bigger than ";
print "previous landscape image.\n";
$land_x = $valuex;
$land_y = $valuey;
}
elsif( $land_x > $valuex )
{
print "new image $sizefile is smaller than ";
print "previous landscape image.\n";
}
}
else
{
if( $valuex > 0 && $valuey > 0 )
{
$land_x = $valuex;
$land_y = $valuey;
}
}
}
if( $valuex > 0 && $valuey > $valuex )
{
# should be portrait - height(y) is bigger than width(x)
if( $port_x > 0 )
{
# existing value for portrait
if( $port_x < $valuex )
{
print "new image $sizefile is bigger than ";
print "previous portrait image.\n";
$port_x = $valuex;
$port_y = $valuey;
}
elsif( $port_x > $valuex )
{
print "new image $sizefile is smaller than ";
print "previous portrait image.\n";
}
}
else
{
if( $valuex > 0 && $valuey > 0 )
{
$port_x = $valuex;
$port_y = $valuey;
}
}
}
}
sub guessflag( $$ )
{
my( $curcatinfo, $curtitle )=@_;
my( $flagout );
# check for backstage case
if( lc( $curtitle ) =~ /backstage/ ||
lc( $curtitle ) =~ /behindthescenes/ )
{
# this overrides all other settings
$flagout = "B";
return( $flagout );
}
# normal set
if( $curcatinfo =~ /fuck/ && $curcatinfo =~ /lesbian/ )
{
# lesbian and fuck means orgy
$flagout = "G";
}
else
{
if( $curcatinfo =~ /lesbian/ )
{
# two girls in clothes not lesbian
if( $curcatinfo =~ /clothed/ )
{
$flagout = "C";
}
else
{
if( $curcatinfo =~ /fff/ )
{
# three or more girls
$flagout = "A";
}
else
{
# two girls - lesbian
$flagout = "L";
}
}
}
elsif( $curcatinfo =~ /fuck/ )
{
# fuck only there if it is
$flagout = "F";
}
elsif( $curcatinfo =~ /blowjob/ )
{
# blowjob is classed as fuck (aka Straight)
$flagout = "F";
}
elsif( $curcatinfo =~ /clothed/ )
{
# flag clothed sets as such
$flagout = "C";
}
elsif( $curcatinfo =~ /dildo/ )
{
# if nothing else but includes toys, toy set
$flagout = "T";
}
elsif( $curcatinfo =~ /vibrator/ )
{
# if nothing else but includes toys, toy set (2)
$flagout = "T";
}
elsif( $curcatinfo =~ /massager/ )
{
# if nothing else but includes toys, toy set (3)
$flagout = "T";
}
else
{
# everything else solo
$flagout = "S";
}
}
return( $flagout );
}
sub read_unpack( $$ )
{
my( $rupath, $runamestem )=@_;
my( $rukeyword, $ruvalue, $ruretval );
my( $rudownloadno, $ruvendor, $rumodelno, $rusetname, $rusetno );
my( $rusreldate, $rusproddate, $rusbranding, $ruphotog, $rudescfile );
unless( open( UNPACK, "< ".$rupath ) )
{
print STDERR "read_unpack: failed to open ".$rupath."\n";
return 0;
}
while( <UNPACK> )
{
chomp;
if( /=/ )
{
($rukeyword, $ruvalue) = split( /=/, $_, 2 );
$unpackinfo{$rukeyword}=$ruvalue;
if( $rukeyword eq "downloadno" )
{
if( $ruvalue eq "none" )
{
$rudownloadno = "none";
}
elsif( $ruvalue > 0 )
{
$rudownloadno = $ruvalue;
id_set_attr("dnldno",$ruvalue);
}
}
if( $rukeyword eq "vendor" )
{
if( $ruvalue ne "" )
{
$ruvendor = $ruvalue;
id_set_attr("vendor",$ruvalue);
}
}
if( $rukeyword eq "modelno" )
{
if( $ruvalue ne "" )
{
$rumodelno = $ruvalue;
id_set_attr("modelno",$ruvalue);
}
}
if( $rukeyword eq "setname" )
{
if( $ruvalue ne "" )
{
$rusetname = $ruvalue;
id_set_attr("setname",$ruvalue);
}
}
if( $rukeyword eq "setno" )
{
if( $ruvalue ne "" )
{
$rusetno = $ruvalue;
id_set_attr("setno",$ruvalue);
}
}
if( $rukeyword eq "sreldate" )
{
if( $ruvalue ne "" )
{
$rusreldate = $ruvalue;
id_set_attr("sreldate",$ruvalue);
}
}
if( $rukeyword eq "sproddate" )
{
if( $ruvalue ne "" )
{
$rusproddate = $ruvalue;
id_set_attr("sproddate",$ruvalue);
}
}
if( $rukeyword eq "sbranding" )
{
if( $ruvalue ne "" )
{
$rusbranding = $ruvalue;
id_set_attr("sbranding",$ruvalue);
}
}
if( $rukeyword eq "photog" )
{
if( $ruvalue ne "" )
{
$ruphotog = $ruvalue;
id_set_attr("photog",$ruvalue);
}
}
if( $rukeyword eq "descfile" )
{
if( $ruvalue ne "" )
{
$rudescfile = $ruvalue;
# set the global one as well
$descfile = $ruvalue;
id_set_attr("descfile",$ruvalue);
}
}
}
}
close UNPACK;
if( $debug > 1 )
{
print STDERR "read_unpack: downloadno is ".$rudownloadno."\n";
print STDERR "read_unpack: setname ".$rusetname.
" featuring modelno ".$rumodelno."\n";
}
if( $rudownloadno eq "none" )
{
# this is the new case of a web-based install of an
# unknown set. We need to make a fake download entry
# for other parts to use.
reset_attr('images');
id_set_attr( "dnldno","none");
if( exists $unpackinfo{'vendor'} )
{
id_set_attr("vendor",$unpackinfo{'vendor'});
}
if( exists $unpackinfo{'setname'} )
{
id_set_attr("setname",$unpackinfo{'setname'});
}
if( exists $unpackinfo{'setflag'} )
{
id_set_attr("setflag",$unpackinfo{'setflag'});
}
if( exists $updateinfo{'unpackinfo'} )
{
id_set_attr("archive",$unpackinfo{'archive'});
}
if( exists $unpackinfo{'modelno'} )
{
id_set_attr("modelno",$unpackinfo{'modelno'});
}
if( exists $unpackinfo{'setno'} )
{
id_set_attr("setno",$unpackinfo{'setno'});
}
if( exists $unpackinfo{'srank'} )
{
id_set_attr("srank",$unpackinfo{'srank'});
}
if( exists $unpackinfo{'sprev'} )
{
id_set_attr("sprev",$unpackinfo{'sprev'});
}
if( exists $unpackinfo{'sduplicates'} )
{
id_set_attr("sduplicates",$unpackinfo{'sduplicates'});
}
if( exists $unpackinfo{'saltmedia'} )
{
id_set_attr("saltmedia",$unpackinfo{'saltmedia'});
}
if( exists $unpackinfo{'sdownload'} )
{
id_set_attr("sdownload",$unpackinfo{'sdownload'});
}
if( exists $unpackinfo{'sproddate'} )
{
id_set_attr("sproddate",$unpackinfo{'sproddate'});
}
if( exists $unpackinfo{'sreldate'} )
{
id_set_attr("sreldate",$unpackinfo{'sreldate'});
}
if( exists $unpackinfo{'sbranding'} )
{
id_set_attr("sbranding",$unpackinfo{'sbranding'});
}
if( exists $unpackinfo{'photog'} )
{
id_set_attr("photog",$unpackinfo{'photog'});
}
if( exists $unpackinfo{'descfile'} )
{
id_set_attr("descfile",$unpackinfo{'descfile'});
}
# we got the proper clue that we should fake it up...
print "Stored model no ".id_get_modelno."\n";
return( "none" );
}
if( $rudownloadno > 0 )
{
# return what dnld_img returns because if we were given
# a duff downloadno by the .unpack file, this would come
# back as zero/null and the next actions would not proceed
$ruretval = dnld_img( 'downloadno' => $rudownloadno,
'vendor' => $ruvendor,
'dfname' => $runamestem,
'srank' => $unpackinfo{'srank'},
'sprev' => $unpackinfo{'sprev'},
'sduplicates' => $unpackinfo{'sduplicates'},
'saltmedia' => $unpackinfo{'saltmedia'},
'sdownload' => $unpackinfo{'sdownload'},
'sproddate' => $unpackinfo{'sproddate'},
'sreldate' => $unpackinfo{'sreldate'},
'sbranding' => $unpackinfo{'sbranding'},
'photog' => $unpackinfo{'photog'},
'descfile' => $unpackinfo{'descfile'},
'dbhandle' => $dbhandle );
return( $ruretval );
}
# not found
print STDERR "read_unpack: found unpack file but no downloadno\n";
return 0;
}
sub guesscatflag( $$$ )
{
my( $gcfdownloadno, $gcfcatinfo, $gcftitle )=@_;
my( $gcfsql, $gcfcsr, @gcfrec, $gcfold );
if( $gcfdownloadno eq "none" )
{
# use the values from the unpack file
if( exists $unpackinfo{'setflag'} )
{
# S is the default so don't return that
if( $unpackinfo{'setflag'} ne "" &&
$unpackinfo{'setflag'} ne "S" )
{
return( $unpackinfo{'setflag'} );
}
}
}
elsif( $gcfdownloadno > 0 )
{
# 0 1 2 3
$gcfsql = "select downloadno, dsetname, dmodelno, dsetflag, ";
# 4
$gcfsql.= "dnotes ";
$gcfsql.= "from ".conf_get_attr("tables","download")." ";
$gcfsql.= "where downloadno = ? ";
$gcfcsr= $dbhandle->prepare( $gcfsql );
$gcfcsr->execute( $gcfdownloadno );
if( $DBI::errstr ne "" )
{
print STDERR "guesscatflag: ".
"fetch of download record failed.\n";
print STDERR "guesscatflag: error was ".
$DBI::errstr."\n";
print STDERR "guesscatflag: query was ".$gcfsql."\n";
return null;
}
if( @gcfrec = $gcfcsr->fetchrow_array )
{
# dsetflag field first:
# since Solo is the default we ignore a specification
# of that
if( $gcfrec[3] ne "" && $gcfrec[3] ne "S" )
{
$catflag = $gcfrec[3];
return( $gcfrec[3] );
}
# second dnotes:
# now check dnotes for anything useful
if( $gcfrec[4] =~ /^Catflag: / )
{
$catflag = $gcfrec[4];
$catflag =~ s/^Catflag: //g;
return( $catflag );
}
}
}
# if we've still not found anything, try the derived catinfo
# keyword Technique
kwscore_reset( 'all' );
kwscore_process( 'string'=>$gcftitle,
'dbhandle'=>$dbhandle );
$catflag=kwscore_get( 'what'=>'cat', 'default'=>'S' );
return( $catflag );
}
|