annotate faptool.php @ 1013:720078ca799e

Oops, a missing bracket. Fixed.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Nov 2015 00:05:50 +0200
parents cb23b23a2d8b
children 22b6442d5cb3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #!/usr/bin/php
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 <?
943
f1c2cce5a5d5 Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 942
diff changeset
3 //
f1c2cce5a5d5 Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 942
diff changeset
4 // FAPWeb - Simple Web-based Demoparty Management System
f1c2cce5a5d5 Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 942
diff changeset
5 // Special entry/preview/etc backend management commandline utility
1001
ffacd904fd1f Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 993
diff changeset
6 // (C) Copyright 2012-2015 Tecnic Software productions (TNSP)
943
f1c2cce5a5d5 Add copyright blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 942
diff changeset
7 //
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 require_once "mconfig.inc.php";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 require_once "msite.inc.php";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
12 function wtConvertImage($inFilename, $outFilename, $outDim, $outFormat, $outQuality, $thumb, $useGfxConv)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
13 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
14 global $setPreviewPath;
912
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
15 $isTemp = FALSE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
16
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
17 if ($useGfxConv)
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
18 {
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
19 // Oh great .. we need gfxconv here because Imagick handles ILBM like shit
951
6549fb84a814 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 950
diff changeset
20 $tmpFilename = tempnam($setPreviewPath, "tmp");
912
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
21 $isTemp = TRUE;
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
22 if (wtExec(
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
23 "/usr/local/bin/gfxconv",
970
9c93a3c4f95c Clean out the debug code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 969
diff changeset
24 escapeshellarg($inFilename)." -f png -o ".escapeshellarg($tmpFilename),
9c93a3c4f95c Clean out the debug code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 969
diff changeset
25 0) === false)
912
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
26 return FALSE;
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
27
951
6549fb84a814 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 950
diff changeset
28 if (!file_exists($tmpFilename))
912
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
29 {
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
30 echo "ERROR: gfxconv did not output a temporary conversion inbetween.\n";
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
31 return FALSE;
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
32 }
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
33 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
34 else
951
6549fb84a814 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 950
diff changeset
35 $tmpFilename = $inFilename;
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
36
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
37 // Create conversion entity
951
6549fb84a814 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 950
diff changeset
38 $img = new Imagick($tmpFilename);
1004
76e26fc5d544 false/FALSE.
Matti Hamalainen <ccr@tnsp.org>
parents: 1001
diff changeset
39 if ($img === FALSE)
912
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
40 {
951
6549fb84a814 Rename a variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 950
diff changeset
41 echo "ERROR: Oh noes! ImageMagick could not digest the file '".$tmpFilename."' (".$inFilename.")\n";
912
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
42 return FALSE;
514d460c60a9 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 902
diff changeset
43 }
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
44
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
45 if ($outDim !== FALSE)
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
46 {
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
47 // Get dimensions, setup background
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
48 $dim = $img->getImageGeometry();
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
49 // $img->setBackgroundColor(imagick::COLOR_BLACK);
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
50 $img->setGravity(imagick::GRAVITY_CENTER);
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
51
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
52 // Act based on image size vs. desired size and $thumb mode
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
53 if ($thumb || $dim["width"] > $outDim[0] || $dim["height"] > $outDim[1])
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
54 {
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
55 // Image is larger
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
56 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_QUADRATIC, 1);
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
57 $img->setImageExtent($outDim[0], $outDim[1]);
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
58 $img->normalizeImage();
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
59 $img->unsharpMaskImage(0, 0.5, 1, 0.05);
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
60 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
61 else
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
62 if ($dim["width"] < $outDim[0] || $dim["height"] < $outDim[1])
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
63 {
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
64 // Image is smaller than requested dimension(s)?
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
65 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_POINT, 1);
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
66 $img->setImageExtent($outDim[0], $outDim[1]);
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
67 }
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
68 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
69
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
70 $img->setFormat($outFormat);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
71 $img->setCompressionQuality($outQuality);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
72
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
73 $img->stripImage();
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
74 $img->writeImage($outFilename);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
75 $img->removeImage();
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
76 return TRUE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
77 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
78
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
79
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
80 function wtRenderSample($inFilename, $outFilename)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
81 {
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
82 $sfreq = intval(stGetSetting("sampleFreq"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
83 $sduration = intval(stGetSetting("sampleDuration"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
84 $schannels = intval(stGetSetting("sampleChannels"));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
85
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
86 return wtExec(
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
87 "/usr/local/bin/openmpt123"
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
88 ,
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
89 "--force --quiet ".
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
90 "--samplerate ".$sfreq." ".
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
91 "--channels ".$schannels." ".
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
92 "--playtime ".$sduration." ".
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
93 escapeshellarg($inFilename)." -o ".escapeshellarg($outFilename),
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
94 0);
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
95 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
96
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
97
948
1334b93939a3 Change how output options are handled in wtConvertSample().
Matti Hamalainen <ccr@tnsp.org>
parents: 947
diff changeset
98 function wtConvertSample($inFilename, $outFilename, $outOpts)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
99 {
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
100 $sfreq = intval(stGetSetting("sampleFreq"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
101 $sduration = intval(stGetSetting("sampleDuration"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
102 $schannels = intval(stGetSetting("sampleChannels"));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
103
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
104 $optStr = "";
948
1334b93939a3 Change how output options are handled in wtConvertSample().
Matti Hamalainen <ccr@tnsp.org>
parents: 947
diff changeset
105 foreach ($outOpts as $okey => $oval)
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
106 $optStr .= $okey." ".$oval." ";
939
dc3ac7470ec0 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 938
diff changeset
107
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
108 return wtExec(
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
109 "/usr/local/bin/avconv",
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
110 "-y -v 1 -t ".intval($sduration)." ".
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
111 "-i ".escapeshellarg($inFilename).
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
112 " ".$optStr." -ac ".$schannels.
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
113 " -map_metadata -1 ".
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
114 escapeshellarg($outFilename));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
115 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
116
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
117
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
118 function wtEntryToSource($compo, $inFilename, $edata, $entryFilename, &$outData, &$outFilename, $force)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
119 {
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
120 // Does compo preview type match this file class?
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
121 if ($edata["class"] != $compo["preview_type"])
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
122 return FALSE;
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
123
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
124 switch ($edata["class"])
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
125 {
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
126 case EFILE_AUDIO: $fext = "wav"; break;
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
127 case EFILE_IMAGE: $fext = "png"; break;
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
128 default:
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
129 return FALSE;
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
130 }
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
131
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
132 $outFilename = stReplaceFileExt($entryFilename, "_preview.".$fext);
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
133 if (!$force && file_exists($outFilename) && filemtime($outFilename) >= filemtime($entryFilename))
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
134 return TRUE;
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
135
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
136 printf("GENERATING: %s -> %s\n", $inFilename, $outFilename);
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
137
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
138 switch ($edata["class"])
939
dc3ac7470ec0 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 938
diff changeset
139 {
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
140 case EFILE_AUDIO:
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
141 if ($edata["mime"] == "audio/x-mod")
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
142 $res = wtRenderSample($inFilename, $outFilename);
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
143 else
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
144 $res = wtConvertSample($inFilename, $outFilename,
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
145 array("-f" => "wav"));
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
146 break;
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
147
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
148 case EFILE_IMAGE:
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
149 $res = wtConvertImage(
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
150 $inFilename,
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
151 $outFilename,
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
152 FALSE, "PNG", 9,
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
153 FALSE, ($edata["mime"] == "gfx"));
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
154 break;
939
dc3ac7470ec0 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 938
diff changeset
155 }
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
156
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
157 return $res;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
158 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
159
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
160
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
161 function wtUnpackArchiveTo($atype, $filename, $path)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
162 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
163 // Check file type before doing anything
953
3b18afe14e46 Message consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 951
diff changeset
164 echo "INFO: Preparing to unpack archive file '".$filename."' ...\n";
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
165 switch ($atype)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
166 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
167 case "LHA":
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
168 $exe = "/usr/bin/lha";
967
62c90ec5edce Use extract.
Matti Hamalainen <ccr@tnsp.org>
parents: 966
diff changeset
169 $args = "x ".escapeshellarg($filename);
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
170 break;
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
171
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
172 case "ZIP":
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
173 $exe = "/usr/bin/unzip";
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
174 $args = "-d ".escapeshellarg($path)." ".escapeshellarg($filename);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
175 break;
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
176
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
177 case "RAR":
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
178 $exe = "/usr/bin/rar";
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
179 $args = "x -w".escapeshellarg($path)." ".escapeshellarg($filename);
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
180 break;
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
181
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
182 case "7ZIP":
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
183 $exe = "/usr/bin/7z";
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
184 $args = "x -o".escapeshellarg($path)." ".escapeshellarg($filename);
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
185 break;
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
186
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
187 default:
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
188 echo "Unsupported archive file type: ".$atype."\n";
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
189 return FALSE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
190 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
191
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
192 // Delete any pre-existing directory
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
193 wtPurgeDir($path);
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
194
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
195 // Create temporary directory for unpacking
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
196 wtMakeDir($path, 0700);
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
197
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
198 // Save current working directory and chdir to target
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
199 $cwd = getcwd();
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
200 if (!is_dir($path) || chdir($path) === false)
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
201 {
953
3b18afe14e46 Message consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 951
diff changeset
202 echo "ERROR: Failed to chdir to '".$path."', can't unpack archive.\n";
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
203 return FALSE;
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
204 }
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
205
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
206 // Unpack archive
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
207 $ret = wtExec($exe, $args);
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
208
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
209 // Return to stored cwd
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
210 chdir($cwd);
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
211 return $ret;
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
212 }
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
213
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
214
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
215 function wtHandleEntryPreview($compo, $entry, $mode)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
216 {
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
217 global $fileTypeData, $setEntryPath;
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
218
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
219 // Get current preview file(s) data
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
220 if (!stGetPreviewFileData($compo, $entry, $pdata))
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
221 return FALSE;
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
222
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
223 // Get entry file data
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
224 $efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["file_id"]);
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
225
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
226 // Check preview file(s) status
949
2179600710d1 Add "lis" as alias to "sta".
Matti Hamalainen <ccr@tnsp.org>
parents: 948
diff changeset
227 if ($mode == "sta" || $mode == "lis")
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
228 {
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
229 printf(" %03d | %s%s%s | %-40s | %-5s | %s\n",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
230 $entry["id"],
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
231 ($efile !== false) ? "E" : ".",
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
232 isset($pdata["file"]) ? "P" : ".",
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
233 $pdata["valid"] ? "V" : ".",
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
234 substr($entry["name"]." by ".$entry["author"], 0, 40),
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
235 isset($pdata["file"]) ? $pdata["file"]["filetype"] : "",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
236 isset($pdata["file"]) ? $pdata["file"]["filename"] : ""
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
237 );
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
238 return TRUE;
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
239 }
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
240 else
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
241 if ($mode != "gen" && $mode != "upd")
953
3b18afe14e46 Message consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 951
diff changeset
242 die("ERROR: Unsupported previews mode ".$mode."\n");
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
243
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
244 $force = ($mode == "upd");
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
245
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
246 // Check validity of previews
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
247 if ($pdata["valid"] && !$force)
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
248 return TRUE;
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
249
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
250 // Okay, no valid previews .. lets see what we can do ..
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
251 // First, check if we have a source preview file
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
252 if (!isset($pdata["file"]))
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
253 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
254 // No source preview, check if we have entry file either?
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
255 if ($efile === false)
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
256 {
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
257 echo
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
258 "INFO: No entry file for ".wtNiceName($compo, $entry, $efile).
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
259 ", can't attempt to generate preview.\n";
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
260 return FALSE;
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
261 }
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
262
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
263 // Actual entry filename + path
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
264 $filename = stMakePath(FALSE, TRUE, array($setEntryPath, $compo["cpath"], $efile["filename"]));
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
265 if (!file_exists($filename))
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
266 {
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
267 echo "ERROR: Entry file '".$filename."' for ".wtNiceName($compo, $entry, FALSE)." does not exist!\n";
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
268 return FALSE;
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
269 }
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
270
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
271 // Preview source file does not exist, let's see ..
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
272 $edata = stProbeFileInfo($filename, TRUE);
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
273 if ($edata === false)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
274 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
275 echo
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
276 "ERROR: Invalid/unsupported file type for entry ".wtNiceName($compo, $entry, $efile)."\n";
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
277 return FALSE;
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
278 }
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
279
942
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
280 $found = FALSE;
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
281 if ($edata["class"] == EFILE_ARCHIVE)
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
282 {
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
283 // Entry is an archive file ..
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
284 $path = stMakePath(FALSE, FALSE, array($setEntryPath, "UNPACKS", $efile["filename"]));
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
285
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
286 if (wtUnpackArchiveTo($efile["filetype"], $filename, $path) === false)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
287 return FALSE;
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
288
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
289 // Scan through files ...
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
290 $dir = opendir($path);
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
291 while (($dentry = readdir($dir)) !== false)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
292 {
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
293 $fname = $path."/".$dentry;
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
294 if ($dentry != "." && $dentry != "..")
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
295 {
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
296 if (is_dir($fname))
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
297 echo "XXX: ".$dentry." :: ".$fname."\n";
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
298 else
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
299 if (is_file($fname) &&
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
300 ($mdata = stProbeFileInfo($fname, TRUE)) !== false &&
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
301 ($found = wtEntryToSource($compo, $fname, $mdata, $filename, $pdata, $outFilename, $force)) === true)
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
302 break;
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
303 }
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
304 }
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
305
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
306 // Cleanup
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
307 closedir($dir);
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
308 wtPurgeDir($path);
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
309 }
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
310 else
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
311 if ($edata["class"] == $compo["preview_type"])
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
312 {
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
313 // Single file
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
314 $found = wtEntryToSource($compo, $filename, $edata, $filename, $pdata, $outFilename, $force);
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
315 }
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
316
950
527e62f39af6 More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
317 if (!$found)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
318 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
319 echo "WARNING: Could not generate preview from entry ".wtNiceName($compo, $entry, $efile)."\n";
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
320 return FALSE;
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
321 }
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
322
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
323 $inFilename = $outFilename;
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
324 }
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
325 else
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
326 $inFilename = stMakePath(FALSE, TRUE, array($setEntryPath, $compo["cpath"], $pdata["file"]["filename"]));
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
327
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
328 // Check validity vs.
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
329 if (!$force)
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
330 {
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
331 $valid = TRUE;
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
332 $inMTime = filemtime($inFilename);
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
333 foreach ($pdata["files"] as $stype => $sdata)
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
334 {
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
335 if (!file_exists($sdata["file"]) || filemtime($sdata["file"]) < $inMTime)
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
336 {
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
337 $valid = FALSE;
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
338 break;
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
339 }
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
340 }
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
341 if ($valid)
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
342 return TRUE;
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
343 }
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
344
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
345 //
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
346 // Either we now have a "user specified" source file or
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
347 // a generated source file - in any case, now convert it
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
348 // to the final form(s).
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
349 //
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
350 switch ($compo["preview_type"])
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
351 {
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
352 case EFILE_AUDIO:
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
353 // Convert to each specified sample type (MP3, Ogg, etc.)
950
527e62f39af6 More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
354 foreach (stGetSetting("sampleTypes") as $stype => $sopts)
942
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
355 {
950
527e62f39af6 More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
356 wtConvertSample(
527e62f39af6 More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
357 $inFilename,
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
358 $pdata["files"][$stype]["file"],
950
527e62f39af6 More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
359 $sopts
527e62f39af6 More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
360 );
942
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
361 }
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
362 break;
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
363
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
364 case EFILE_IMAGE:
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
365 // Images we convert to bigger image and thumbnail
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
366 wtConvertImage(
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
367 $inFilename,
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
368 $pdata["files"]["image"]["file"],
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
369 stGetSetting("previewImageSize"),
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
370 stGetSetting("previewImageType"),
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
371 stGetSetting("previewImageQuality"),
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
372 FALSE, FALSE);
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
373
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
374 wtConvertImage(
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
375 $inFilename,
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
376 $pdata["files"]["thumb"]["file"],
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
377 stGetSetting("previewThumbSize"),
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
378 stGetSetting("previewThumbType"),
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
379 stGetSetting("previewThumbQuality"),
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
380 TRUE, FALSE);
942
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
381 break;
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
382 }
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
383
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
384 return TRUE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
385 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
386
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
387
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
388 function wtHandleEntry($compo, $entry, $mode)
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
389 {
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
390 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
391
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
392
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
393 //
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
394 // Crop a filename to specified length
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
395 //
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
396 function wtCropFilename($filename, $len)
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
397 {
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
398 if ($len !== FALSE && strlen($filename) > $len)
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
399 {
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
400 // Check if the filename has a path and attempt
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
401 // to get the filename extension
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
402 $fext = "";
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
403 $dpos = strrpos($filename, "/");
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
404 if (($spos = strrpos($filename, ".")) !== FALSE &&
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
405 ($dpos === FALSE || $dpos < $spos))
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
406 $fext = substr($filename, $spos);
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
407
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
408 // Is the filename extension too long, if yes, just dump it
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
409 if (strlen($fext) >= $len)
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
410 $fext = "";
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
411
987
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
412 return substr($filename, 0, $len - strlen($fext) - 1).$fext;
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
413 }
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
414 else
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
415 return $filename;
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
416 }
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
417
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
418
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
419 //
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
420 // Recursively goes through directory/files and subdirectories,
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
421 // cropping file/dir names to specified length.
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
422 //
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
423 function wtCropFilenamesRec($path, $len)
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
424 {
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
425 $dir = opendir($path);
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
426 while (($dentry = readdir($dir)) !== false)
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
427 {
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
428 $fname = $path."/".$dentry;
987
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
429 $nname = $path."/".wtCropFilename($dentry, $len);
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
430 if ($dentry != "." && $dentry != "..")
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
431 {
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
432 if (is_dir($fname))
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
433 {
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
434 wtCropFilenamesRec($fname, $len);
987
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
435 if (rename($fname, $nname) === false)
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
436 {
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
437 echo "ERROR: Could not rename DIR '".$fname."' -> '".$nname."'.\n";
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
438 return FALSE;
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
439 }
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
440 }
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
441 else
987
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
442 if (is_file($fname) && rename($fname, $nname) === false)
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
443 {
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
444 echo "ERROR: Could not rename FILE '".$fname."' -> '".$nname."'.\n";
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
445 return FALSE;
06e45615b46b Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 986
diff changeset
446 }
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
447 }
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
448 }
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
449 closedir($dir);
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
450 }
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
451
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
452
991
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
453 function wtUnpackEntry($compo, $entry, $pathPrefix, $useOrig, $cropNames, $copyOnly)
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
454 {
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
455 global $setEntryPath;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
456
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
457 // Get latest file for the entry
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
458 if (($efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["file_id"])) === false)
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
459 {
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
460 echo "INFO: No entry file for ".wtNiceName($compo, $entry, $efile)."\n";
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
461 return FALSE;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
462 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
463
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
464 // Create source file full path
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
465 $filename = stMakePath(FALSE, TRUE, array($setEntryPath, $compo["cpath"], $efile["filename"]));
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
466
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
467 // Check if the file exists
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
468 if (!file_exists($filename))
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
469 {
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
470 echo "ERROR: Entry file '".$filename."' for ".wtNiceName($compo, $entry, FALSE)." does not exist!\n";
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
471 return FALSE;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
472 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
473
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
474 // Get file data
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
475 $edata = stProbeFileInfo($filename, TRUE);
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
476 if ($edata === false)
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
477 {
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
478 echo
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
479 "ERROR: Invalid/unsupported file type for entry ".wtNiceName($compo, $entry, $efile)."\n";
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
480 return FALSE;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
481 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
482
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
483 // Create the destination directory
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
484 if (wtMakeDir(stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"])), 0755) === false)
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
485 return FALSE;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
486
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
487 // Form the destination path and/or filename
991
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
488 if ($copyOnly)
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
489 $dstFileBase = $useOrig ? $efile["origname"] : $efile["filename"];
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
490 else
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
491 $dstFileBase = wtCropFilename($entry["show_id"]."-".($useOrig ? $efile["origname"] : $efile["filename"]), $cropNames);
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
492
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
493
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
494 // Handle based on class/type and whether we are just copying or not
991
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
495 if (!$copyOnly && $edata["class"] == EFILE_ARCHIVE)
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
496 {
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
497 // Entry is an archive file, so unpack it
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
498 $dstPath = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], stReplaceFileExt($dstFileBase, "")));
964
280dc9b01297 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 963
diff changeset
499 if (wtUnpackArchiveTo($edata["id"], $filename, $dstPath) === false)
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
500 return FALSE;
986
a8ed8295fcd2 Implement name cropping.
Matti Hamalainen <ccr@tnsp.org>
parents: 985
diff changeset
501
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
502 // Crop the filenames from the unpacked archive, if we need to
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
503 if ($cropNames !== false)
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
504 wtCropFilenamesRec($dstPath, $cropNames);
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
505 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
506 else
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
507 {
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
508 // We have a single file (or copyOnly mode)
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
509 $dstFilename = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], $dstFileBase));
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
510 if (copy($filename, $dstFilename) === false)
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
511 {
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
512 echo "ERROR: Failed to copy '".$filename."' to '".$dstFilename."'\n";
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
513 return FALSE;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
514 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
515 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
516
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
517 return TRUE;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
518 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
519
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
520
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 //
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
522 // Misc helper functions
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 //
993
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
524
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
525 function wtNiceName($compo, $entry, $efile = FALSE)
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
526 {
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
527 return sprintf(
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
528 "%d: %s by %s%s",
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
529 $entry["id"],
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
530 $entry["name"],
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
531 $entry["author"],
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
532 ($efile !== false) ? " [".$efile["filename"]." / TYPE: '".$efile["filetype"]."']" : "");
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
533 }
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
534
fbc2e6514dfa Cleanups and improved comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 991
diff changeset
535
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
536 function wtExec($exe, $args, $expect = 0)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
537 {
984
03b245ef3a47 Various fixes to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 983
diff changeset
538 echo "EXEC: ".$exe." @ ".$args."\n";
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
539 exec(escapeshellcmd($exe)." ".$args, $output, $code);
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
540 if ($code !== $expect)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
541 {
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
542 echo
953
3b18afe14e46 Message consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 951
diff changeset
543 "ERROR: Executing ".$exe.": ".$code."\n".$args."\n".
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
544 "------------------------------------------------\n".
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
545 implode("\n", $output).
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
546 "------------------------------------------------\n";
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
547 return FALSE;
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
548 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
549 return TRUE;
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
550 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
551
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
552
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
553 function wtExecOrDie($exe, $args)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
554 {
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
555 if (wtExec($exe, $args) === false)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
556 die();
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
557 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
558
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
559
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
560 function wtPurgeDir($path)
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
561 {
942
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
562 if ($path != "" && $path !== false && file_exists($path) && is_dir($path))
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
563 {
969
26ae3f21a3bb Moar work on previews.
Matti Hamalainen <ccr@tnsp.org>
parents: 968
diff changeset
564 // echo "PURGING: ".$path."\n";
942
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
565 foreach (scandir($path) as $file)
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
566 if ($file !== "." && $file !== "..")
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
567 {
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
568 $sub = $path."/".$file;
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
569 if (is_dir($sub))
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
570 wtPurgeDir($sub);
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
571 else
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
572 unlink($sub);
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
573 }
7fa6c39ef851 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
574 rmdir($path);
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
575 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
576 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
577
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
578
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
579 function wtMakeDir($path, $perm)
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580 {
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581 if (!file_exists($path))
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 {
953
3b18afe14e46 Message consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 951
diff changeset
583 echo "INFO: Creating ".$path."\n";
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
584 if (mkdir($path, $perm, TRUE) === false)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
585 die("Could not create directory '".$path."'\n");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
588
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
589
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
590 function wtInitializeDirs()
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
591 {
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
592 global
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
593 $setEntryPath, $setPreviewPath, $setThumbDir,
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
594 $setEntryPathPerms, $setPrevPathPerms;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
595
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
596 echo "Checking for missing directories ...\n";
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
597 wtMakeDir($setEntryPath, $setEntryPathPerms);
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
598 wtMakeDir($setPreviewPath, $setPrevPathPerms);
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
599
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
600 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
601 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
602 wtMakeDir(stMakePath(FALSE, FALSE, array($setEntryPath, $compo["cpath"])), $setEntryPathPerms);
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
603 wtMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"])), $setPrevPathPerms);
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
604 wtMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"], $setThumbDir)), $setPrevPathPerms);
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
605 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
607
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
609 function wtPrintCompoHeader($compo)
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
610 {
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
611 global $setTermWidth;
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
612 printf("==%'=-".($setTermWidth-2)."s\n",
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
613 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40))
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
614 );
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
615 }
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
616
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
617
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
618 function wtPrintDivider($chr = "-")
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
619 {
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
620 global $setTermWidth;
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
621 echo str_repeat($chr, $setTermWidth)."\n";
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
622 }
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
623
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
624
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
625 function wtShowHelp()
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
626 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
627 global $argv;
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
628 echo
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
629 "faptool - Do stuff with FAPWeb database\n".
1001
ffacd904fd1f Update copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 993
diff changeset
630 "(C) Copyright 2015 ccr/TNSP\n".
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
631 "\n".
917
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
632 "Usage: ".$argv[0]." <command> [args]\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
633 "Where command is one of following:\n".
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634 "\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
635 " init\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
636 " Create directories for entries and previews, if needed.\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
637 "\n".
928
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
638 /*
917
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
639 " clean [delete|crap]\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
640 " Clean files marked to be deleted and 'stale' files. This includes\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
641 " any old or stale preview files and entry files.\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
642 " Without 'delete' parameter just checks and shows what would deleted.\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
643 " 'crap' parameter will purge EVERYTHING that is NOT in the database,\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
644 " e.g. any other files, like temp files, etc. DANGEROUS IF YOU DO NOT\n".
eda104823649 Work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 912
diff changeset
645 " KNOW WHAT YOU ARE DOING!!!!!\n".
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
646 "\n".
928
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
647 */
938
7accae8e896c More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 935
diff changeset
648 " probe <filename> [filename2 ..]\n".
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
649 " Probe specified file for file information.\n".
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
650 "\n".
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
651 " previews <cmd> [args]\n".
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
652 " Where <cmd> is one of:\n".
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
653 " status [cid] - List files and show what is missing, etc. (All or <cid>)\n".
970
9c93a3c4f95c Clean out the debug code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 969
diff changeset
654 " generate - Generate preview files that are missing OR out of date.\n".
928
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
655 " (older then preview source file OR entry file where appropriate)\n".
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
656 // " add <entry_id> <filename> - Add file as preview for entry_id.\n".
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
657 "\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
658 " entry <cmd> [args]\n".
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
659 " status [cid] - List entries for all compos or <cid>.\n".
966
eea2b92287ca Update help.
Matti Hamalainen <ccr@tnsp.org>
parents: 964
diff changeset
660 " unpack <path> - Create subdirs and copy all entries UNPACKED there.\n".
991
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
661 " release <path> - Like unpack, but just copies files (does not unpack archives).\n".
928
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
662 /*
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
663 " add <filename> '<name>' '<author>' - Add file as entry file\n".
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
664 " (works same as uploading from admin interface)\n".
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
665 " package <lha|zip|rar|7z>\n".
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
666 " Repackages/packages entries (unpacks first if archive),\n".
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
667 " and adds generated infofile.txt to packages.\n".
980f15768103 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 927
diff changeset
668 */
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
669 "\n";
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
670 }
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
671
1005
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
672
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
673 function wtSigHandler($signo)
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
674 {
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
675 global $flagQuit;
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
676 switch ($signo)
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
677 {
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
678 case SIGTERM:
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
679 mgFatal("Received SIGTERM.\n");
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
680 break;
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
681
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
682 case SIGQUIT:
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
683 case SIGINT:
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
684 $flagQuit = TRUE;
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
685 break;
1013
720078ca799e Oops, a missing bracket. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 1006
diff changeset
686 }
1005
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
687 }
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
688
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
689
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
690 //
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
691 // Main program starts
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
692 //
944
535466595a5a Move CLI exec check to program start.
Matti Hamalainen <ccr@tnsp.org>
parents: 943
diff changeset
693 stCheckCLIExec();
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
694 if ($argc < 2)
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
695 {
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
696 wtShowHelp();
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
697 exit;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
698 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
699
1005
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
700 pcntl_signal(SIGTERM, "wtSigHandler");
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
701 pcntl_signal(SIGHUP, "wtSigHandler");
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
702 pcntl_signal(SIGQUIT, "wtSigHandler");
f650ae251d8c Add signal handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 1004
diff changeset
703 pcntl_signal(SIGINT, "wtSigHandler");
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
704
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
705 // Try to connect to database
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
706 $spec = stGetSetting("sqlDB");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 if (($db = stConnectSQLDBSpec($spec)) === false)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
708 die("Could not connect to SQL database '".$spec."'.\n");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
709
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
710 echo "Using database spec '".$spec."'.\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
711
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
712 // Fetch non-"hardcoded" settings from SQL database
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
713 stReloadSettings();
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
714
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
715 // Set some globals for our benefit
922
b92549a3372d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 917
diff changeset
716 $setTermWidth = 75;
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717 $setEntryPath = stGetSetting("entryPath");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
718 $setPreviewPath = stGetSetting("previewPath");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
719 $setPreviewURL = stGetSetting("previewURL");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
720 $setThumbDir = stGetSetting("thumbnailSubDir");
832
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
721 $setEntryPathPerms = stGetSetting("entryPathPerms");
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
722 $setPrevPathPerms = stGetSetting("previewPathPerms");
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
723
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
724 if ($setEntryPath === FALSE || $setPreviewPath === FALSE ||
832
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
725 $setPreviewURL === FALSE || $setThumbDir === FALSE ||
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
726 $setEntryPathPerms === FALSE || $setPrevPathPerms === FALSE)
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
727 {
922
b92549a3372d Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 917
diff changeset
728 die("Some required settings are not defined in mconfig.inc.php!\n");
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
730
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
731
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
732 // Act according to specified command
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
733 switch (stCArgLC(1, 3))
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
734 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
735 case "-?": case "--h":
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
736 wtShowHelp();
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
737 exit;
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
738 break;
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
739
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
740 case "ini":
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
741 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
742 // Initialize the data directories etc
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
743 //
953
3b18afe14e46 Message consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 951
diff changeset
744 echo "INFO: Checking for missing directories ...\n";
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
745 wtInitializeDirs();
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
746 break;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
747
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
748 case "pro":
945
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
749 //
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
750 // Probe specified files
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
751 //
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
752 if ($argc < 2)
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
753 die("No filename specified.\n");
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
754
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
755 if (($finfo = finfo_open()) === false)
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
756 die("Internal error. Failed to initialize finfo().");
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
757
945
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
758 for ($i = 2; $i < $argc; $i++)
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
759 {
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
760 // Probe one file
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
761 $filename = $argv[$i];
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
762 $sdata = @finfo_file($finfo, $filename, FILEINFO_NONE);
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
763 $smime = @finfo_file($finfo, $filename, FILEINFO_MIME_TYPE);
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
764
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
765 echo
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
766 "\n".
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
767 "File : ".$filename."\n".
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
768 "Probed : ".$sdata."\n".
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
769 "Mime : ".$smime."\n";
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
770
954
24f155a2e501 More work ... on faptool!
Matti Hamalainen <ccr@tnsp.org>
parents: 953
diff changeset
771 if (($info = stProbeFileInfo($filename, TRUE)) !== false)
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
772 {
945
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
773 $tmp = array();
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
774 foreach ($info as $ikey => $ival)
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
775 $tmp[] = $ikey."='".$ival."'";
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
776
025f5e3e27d7 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 944
diff changeset
777 echo "Data : ".implode(", ", $tmp)."\n";
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
778 }
946
99086b6afcdb Oops, 10L!
Matti Hamalainen <ccr@tnsp.org>
parents: 945
diff changeset
779 }
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
780
946
99086b6afcdb Oops, 10L!
Matti Hamalainen <ccr@tnsp.org>
parents: 945
diff changeset
781 finfo_close($finfo);
925
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
782 break;
5d53b9d6c319 Add 'probe' function to faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 922
diff changeset
783
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
784 case "cle":
947
f709816c71cd Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
785 //
f709816c71cd Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
786 // File cleanup / deletion
f709816c71cd Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 946
diff changeset
787 //
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
788 $doDelete = (stCArgLC(2) == "delete");
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
789 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
790 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
791 {
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
792 wtPrintCompoHeader($compo);
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
793 wtPrintDivider();
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
794
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
795 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
796 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
797 foreach (stExecSQL("SELECT * FROM files WHERE entry_id=".$entry["id"]) as $efile)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
798 {
935
7fdf03e6a80d More work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
799 if ($efile["deleted"] != 0)
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
800 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
801 echo "X";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
802 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
803 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
804 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
805 echo "\n";
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
806 wtPrintDivider();
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
807 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
808 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
809
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
810 case "ent":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
811 //
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
812 // Entry files handling
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
813 //
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
814 $mode = stCArgLC(2, 3);
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
815 switch ($mode)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
816 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
817 case "sta":
949
2179600710d1 Add "lis" as alias to "sta".
Matti Hamalainen <ccr@tnsp.org>
parents: 948
diff changeset
818 case "lis":
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
819 $sql = (stCArg(3) !== FALSE) ? " AND id=".intval(stCArg(3)) : "";
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
820 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo)
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
821 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
822 {
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
823 wtPrintCompoHeader($compo);
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
824 wtPrintDivider();
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
825
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
826 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
827 wtHandleEntry($compo, $entry, $mode);
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
828
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
829 wtPrintDivider();
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
830 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
831 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
832
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
833 case "unp":
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
834 if (($setPrefix = stCArg(3)) === FALSE)
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
835 die("Unpack needs a destination path.\n");
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
836
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
837 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
838 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
839 {
991
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
840 // wtUnpackEntry($compo, $entry, $setPrefix, TRUE, 32, FALSE);
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
841 wtUnpackEntry($compo, $entry, $setPrefix, TRUE, FALSE, FALSE);
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
842 }
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
843 break;
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
844
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
845 case "rel":
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
846 if (($setPrefix = stCArg(3)) === FALSE)
991
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
847 die("Releases needs a destination path.\n");
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
848
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
849 if (!file_exists($setPrefix) || is_dir($setPrefix))
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
850 {
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
851 // Create new one
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
852 wtMakeDir($setPrefix, 0755);
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
853
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
854 // Create results.txt if it does not exist
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
855 $resultsFile = stMakePath(FALSE, TRUE, array($setPrefix, "results.txt"));
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
856 if (!file_exists($resultsFile))
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
857 {
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
858 // Use a header file if it exists
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
859 $resultsHeader = "results.logo";
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
860 if (file_exists($resultsHeader) && is_file($resultsHeader))
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
861 $resultsText = file_get_contents($resultsHeader);
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
862 else
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
863 {
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
864 $resultsText = $pageTitle." results";
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
865 $resultsText .= "\n".str_repeat("=", strlen($resultsText))."-- -\n\n";
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
866 }
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
867
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
868 file_put_contents(
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
869 $resultsFile,
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
870 $resultsText.stGetCompoResultsASCIIStr(FALSE, 0)
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
871 );
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
872 }
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
873
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
874 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
875 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
876 {
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
877 wtUnpackEntry($compo, $entry, $setPrefix, TRUE, FALSE, TRUE);
3e9e0aa21a18 Add releases dumping.
Matti Hamalainen <ccr@tnsp.org>
parents: 987
diff changeset
878 }
963
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
879 }
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
880 break;
003af1c4ae1f Implement 'entry unpack'.
Matti Hamalainen <ccr@tnsp.org>
parents: 954
diff changeset
881
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
882 case "pac":
929
Matti Hamalainen <ccr@tnsp.org>
parents: 928
diff changeset
883 echo "Not implemented. :D\n";
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
884 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
885
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
886 case "add":
929
Matti Hamalainen <ccr@tnsp.org>
parents: 928
diff changeset
887 echo "Not implemented. :D\n";
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
888 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
889
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
890 default:
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
891 if ($mode == "")
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
892 die("ERROR! Entry command requires a sub-command argument.\n");
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
893 else
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
894 die("ERROR! Invalid entry sub-command '".stCArg(2)."'.\n");
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
895 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
896 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
897 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
898
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
899 case "pre":
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
900 //
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
901 // Preview files handling
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
902 //
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
903 $mode = stCArgLC(2, 3);
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
904 switch ($mode)
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
905 {
970
9c93a3c4f95c Clean out the debug code, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 969
diff changeset
906 case "gen":
983
1e347288712d Add "upd" option to previews generation.
Matti Hamalainen <ccr@tnsp.org>
parents: 971
diff changeset
907 case "upd":
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
908 case "sta":
949
2179600710d1 Add "lis" as alias to "sta".
Matti Hamalainen <ccr@tnsp.org>
parents: 948
diff changeset
909 case "lis":
1006
cb23b23a2d8b Improve commandline parsing, fix some potential bug situations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
910 $sql = (stCArg(3) !== FALSE) ? " AND id=".intval(stCArg(3)) : "";
933
f05c896622e1 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 929
diff changeset
911 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo)
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
912 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0)
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
913 {
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
914 wtPrintCompoHeader($compo);
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
915 printf(
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
916 "PrevType : %s\n",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
917 $previewTypeList[$compo["preview_type"]][0]);
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
918
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
919 if ($mode == "sta" || $mode == "lis")
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
920 {
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
921 printf(" %-3s | %-3s | %-40s |\n",
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
922 "#ID", "EPV", "Entry name/author");
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
923 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
924
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
925 wtPrintDivider("-");
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
926
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
927 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry)
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
928 wtHandleEntryPreview($compo, $entry, $mode);
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
929
968
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
930 wtPrintDivider("=");
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
931 }
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
932 if ($mode == "sta" || $mode == "lis")
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
933 {
c71afc1a3a85 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 967
diff changeset
934 echo "Flags: E = Entry has file, P = Has preview file, V = Generated previews are up to date.\n";
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
935 }
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
936 break;
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
937
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
938 case "add":
929
Matti Hamalainen <ccr@tnsp.org>
parents: 928
diff changeset
939 echo "Not implemented. :D\n";
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
940 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
941
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
942 default:
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
943 if ($mode == "")
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
944 die("ERROR! Previews command requires a sub-command argument.\n");
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
945 else
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
946 die("ERROR! Invalid previews sub-command '".stCArg(2)."'.\n");
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
947 break;
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
948 }
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
949 break;
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
950
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
951 default:
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
952 echo "ERROR! Invalid operation mode '".stCArg(1)."'.\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
953 break;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
954 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
955
941
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
956 /* Dummy
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
957 {
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
958
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
959 }
f3c6c56098ed And moar.
Matti Hamalainen <ccr@tnsp.org>
parents: 939
diff changeset
960 */
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
961 ?>