annotate faptool.php @ 902:5d7e525b0eb5

Moar work.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 27 Nov 2014 08:47:52 +0200
parents dfa1277786c1
children 514d460c60a9
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 <?
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 require_once "mconfig.inc.php";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 require_once "msite.inc.php";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 stCheckCLIExec();
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
9 function wtExec($exe, $args)
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
10 {
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
11 echo "@@EXEC: ".$exe." ".$args."\n";
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
12 if (passthru($exe." ".$args) == 0)
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
13 {
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
14 echo "Error executing ".$exe.":\n".$args."\n";
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
15 return FALSE;
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
16 }
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
17 return TRUE;
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
18 }
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
19
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
20 function wtExecOrDie($exe, $args)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
21 {
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
22 if (wtExec($exe, $args) === false)
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
23 die();
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
24 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
25
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
26
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
27 function wtConvertImage($inFilename, $inFileType, $outFilename, $setDim, $setFormat, $setQuality, $thumb)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
28 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
29 global $setPreviewPath;
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
30
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
31 if (($outDim = stGetSetting($setDim)) === FALSE ||
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
32 ($outFormat = stGetSetting($osetFormat)) === FALSE ||
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
33 ($outQuality = stGetSetting($setQuality)) === FALSE)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
34 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
35 die("Missing one of res/format/quality settings for '".$outFilename."'\n");
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
36 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
37
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
38 if ($inFileType == "gfx")
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
39 {
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
40 // Oh great .. we need gfxconv here because Imagick handles ILBM like shit
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
41 $filename = tempnam($setPreviewPath, "tmp");
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
42 wtExecOrDie(
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
43 "/usr/local/bin/gfxconv",
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
44 escapeshellarg($inFilename)." -f png -o ".escapeshellarg($filename));
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
45 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
46 else
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
47 $filename = $inFilename;
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
48
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
49 // convert -resize 640x480 -background black -gravity center -extent 640x480
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
50 // -unsharp "0x0.75+0.75+0.008" lol.lbm -quality 95 test.jpg
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
51
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
52 // Create conversion entity
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
53 $img = new Imagick($filename);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
54 if ($img === false)
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
55 die("Oh noes! ImageMagick could not digest the file '".$filename."' (".$inFilename.")\n");
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
56
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
57 // Get dimensions, setup background
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
58 $dim = $img->getImageGeometry();
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
59 $img->setBackgroundColor(imagick::COLOR_BLACK);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
60 $img->setGravity(imagick::GRAVITY_CENTER);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
61
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
62 // Act based on image size vs. desired size and $thumb mode
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
63 if ($thumb || $dim["width"] > $outDim[0] || $dim["height"] > $outDim[1])
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
64 {
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
65 // Image is larger
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
66 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_QUADRATIC, 1);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
67 $img->setExtent($outDim[0], $outDim[1]);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
68 $img->normalizeImage();
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
69 $img->unsharpMaskImage(0, 0.5, 1, 0.05);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
70 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
71 else
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
72 if ($dim["width"] < $outDim[0] || $dim["height"] < $outDim[1])
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
73 {
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
74 // Image is smaller than requested dimension(s)?
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
75 $img->resizeImage($outDim[0], $outDim[1], Imagick::FILTER_POINT, 1);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
76 $img->setExtent($outDim[0], $outDim[1]);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
77 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
78
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
79 $img->setFormat($outFormat);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
80 $img->setCompressionQuality($outQuality);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
81
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
82 $img->stripImage();
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
83 $img->writeImage($outFilename);
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
84 $img->removeImage();
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
85 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
86
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
87
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
88 function wtRenderSample($inFilename, $outFilename)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
89 {
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
90 $sfreq = intval(stGetSetting("sampleFreq"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
91 $sduration = intval(stGetSetting("sampleDuration"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
92 $schannels = intval(stGetSetting("sampleChannels"));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
93
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
94 return wtExec(
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
95 "/usr/local/bin/openmpt123"
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
96 ,
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
97 "--quiet --render ".
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
98 "--samplerate ".$sfreq." ".
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
99 "--channels ".$schannels." ".
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
100 "--playtime ".$sduration." ".
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
101 escapeshellarg($inFilename)." -o ".escapeshellarg($outFilename));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
102 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
103
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
104
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
105 function wtConvertSample($inFilename, $outFilename, $opts)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
106 {
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
107 $sfreq = intval(stGetSetting("sampleFreq"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
108 $sduration = intval(stGetSetting("sampleDuration"));
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
109 $schannels = intval(stGetSetting("sampleChannels"));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
110
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
111 foreach ($opts as $okey => $oval)
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
112 $optStr .= $okey." ".$oval." ";
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
113
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
114 return wtExec(
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
115 "/usr/local/bin/avconv",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
116 "-y -t ".intval($sduration)." ".
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
117 "-i ".escapeshellarg($inFilename).
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
118 " ".$optStr." -ac ".$schannels.
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
119 " -map_metadata -1 ".
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
120 escapeshellarg($outFilename));
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
121 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
122
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
123
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
124 function wtPurgeDir($path)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
125 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
126 if (file_exists($path))
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
127 wtExecOrDie("/bin/echo", "-fR ".escapeshellarg($path));
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
128 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
129
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
130
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
131 function wtUnpackArchiveTo($atype, $filename, $path)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
132 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
133 // Check file type before doing anything
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
134 echo "Preparing to unpack archive file '".$filename."' ...\n";
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
135 switch ($atype)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
136 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
137 case "LHA":
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
138 $exe = "/usr/bin/lha";
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
139 $args = "e ".escapeshellarg($filename);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
140 break;
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
141
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
142 case "ZIP":
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
143 $exe = "/usr/bin/unzip";
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
144 $args = "-d ".escapeshellarg($path)." ".escapeshellarg($filename);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
145 break;
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
146
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
147 case "RAR":
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
148 $exe = "/usr/bin/rar";
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
149 $args = "e ".escapeshellarg($filename);
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
150 break;
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
151
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
152 default:
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
153 echo "Unsupported archive file type: ".$atype."\n";
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
154 return FALSE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
155 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
156
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
157 // Create temporary directory
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
158 wtPurgeDir($path);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
159 stMakeDir($path, 0700);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
160
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
161 if (!is_dir($path) || chdir($path) === false)
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
162 {
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
163 echo "Failed to chdir to '".$path."', can't unpack archive.\n";
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
164 return FALSE;
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
165 }
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 // Unpack archive
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
168 return wtExec($exe, $args);
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
169 }
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
170
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
171
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
172 function wtScanArchive($efile, $filename)
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
173 {
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
174 global $setEntryPath;
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
175
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
176 $path = stMakePath(FALSE, FALSE, array($setEntryPath, "UNPACKS", $filename));
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
177
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
178 echo "Attempting to scan archive file '".$filename."' ...\n";
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
179
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
180 if (wtUnpackArchiveTo($efile["filetype"], $filename, $path)) === false)
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
181 return FALSE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
182
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
183 // Scan through files ...
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
184 $dir = opendir($path);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
185 while (($dentry = readdir($dir)) !== false)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
186 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
187 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
188 closedir($dir);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
189
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
190 wtPurgeDir($path);
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
191 return TRUE;
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
192 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
193
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
194
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
195 function wtHandleEntryPreview($compo, $entry, $mode)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
196 {
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
197 // Get current preview file data
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
198 if (!stGetPreviewFileData($compo, $entry, $pdata))
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
199 return FALSE;
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
200
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
201 if ($entry["file_id"] != 0)
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
202 $efile = stFetchSQL("SELECT * FROM files WHERE deleted=0 AND id=".$entry["file_id"]);
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
203 else
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
204 $efile = FALSE;
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
205
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
206 // Check preview file(s) status
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
207 if ($mode == "sta")
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
208 {
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
209 printf(" %03d | %s%s%s | %-40s | %-5s | %s\n",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
210 $entry["id"],
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
211 ($efile !== false) ? "1" : ".",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
212 isset($pdata["file"]) ? "2" : ".",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
213 $pdata["valid"] ? "3" : ".",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
214 $entry["name"]." by ".$entry["author"],
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
215 isset($pdata["file"]) ? $pdata["file"]["filetype"] : "",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
216 isset($pdata["file"]) ? $pdata["file"]["filename"] : ""
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
217 );
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
218 }
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
219 else
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
220 if ($mode == "upd")
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
221 {
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
222 /*
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
223 if (previewSourceFile does not exist)
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
224 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
225 if (entry is module file)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
226 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
227 render sample
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
228 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
229 else
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
230 if (entry is image file)
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
231 {
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
232 convert image
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
233 }
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
234 else
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
235 if (entry is archive)
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
236 {
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
237 if compo preview type is image, scan archive for images ..
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
238 }
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
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
241 if (previewFiles older than previewSourceFile)
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
242 {
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
243 if (source == audio)
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
244 convert via avconv
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
245 else
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
246 if (source == image)
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
247 convert via imagick
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
248 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
249
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
250 // Based on compo / entry preview type ..
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
251
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
252 // Convert preview image file, if any
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
253 // Create thumbnail for it, too
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
254 wtConvertImage($inFilename, $outFilename,
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
255 "previewImageSize", "previewImageType",
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
256 "previewImageQuality", FALSE);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
257
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
258 wtConvertImage($inFilename, $outFilename,
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
259 "previewThumbSize", "previewThumbType",
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
260 "previewThumbQuality", TRUE);
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
261 */
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
262 }
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
263 else
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
264 die("OMG!\n");
882
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
265 }
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
266
25bcbd6d5682 Moar work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 881
diff changeset
267
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
268 function wtHandleEntry($compo, $entry, $mode)
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
269 {
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
270 }
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
271
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
272
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 // Create directories
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 function stMakeDir($path, $perm)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
278 if (!file_exists($path))
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 {
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 echo " - Creating ".$path."\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 if (mkdir($path, $perm, TRUE) === false)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 die("Could not create directory '".$path."'\n");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
286
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287 function stInitializeDirs()
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 {
902
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
289 global
5d7e525b0eb5 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 901
diff changeset
290 $setEntryPath, $setPreviewPath, $setThumbDir,
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 $setEntryPathPerms, $setPrevPathPerms;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 echo "Checking for missing directories ...\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 stMakeDir($setEntryPath, $setEntryPathPerms);
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 stMakeDir($setPreviewPath, $setPrevPathPerms);
880
6db8ef2bb1b5 Changed stMakePath() API.
Matti Hamalainen <ccr@tnsp.org>
parents: 832
diff changeset
296 stMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $setThumbDir)), $setPrevPathPerms);
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 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
299 {
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 stMakeDir(stMakePath(FALSE, FALSE, array($setEntryPath, $compo["cpath"])), $setEntryPathPerms);
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 // Main program starts
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 if ($argc < 2)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 {
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 echo
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 "faptool - Do stuff with FAPWeb database\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 "(C) Copyright 2014 ccr/TNSP\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 "\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 "Usage: ".$argv[0]." <mode> [args]\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 "Where mode is one of following:\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 "\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 " init\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 " Create directories for entries and previews, if needed.\n".
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 "\n".
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
320 " clean [delete]\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
321 " Clean files marked to be deleted. This includes any old\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
322 " or stale preview files and entry files.\n"
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
323 " Without 'delete' parameter just checks and shows what would\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
324 " be deleted, but with it ACTUALLY DELETES THE FILES, SO BE CAREFUL!\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
325 "\n".
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
326 " previews <cmd> [args]\n".
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
327 " Where <cmd> is one of:\n".
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
328 " status - List files and show what is missing, etc.\n".
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
329 "\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
330 " entry <cmd> [args]\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
331 " status - List entries for all compos.\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
332 " unpack - Create subdirs and unpack archives under them.\n".
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 "\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 exit;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 // Try to connect to database
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 $spec = stGetSetting("sqlDB");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 if (($db = stConnectSQLDBSpec($spec)) === false)
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 die("Could not connect to SQL database '".$spec."'.\n");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 echo "Using database spec '".$spec."'.\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344 // Fetch non-"hardcoded" settings from SQL database
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 stReloadSettings();
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 // Set some globals for our benefit
900
b147f99934f6 Add screen width.
Matti Hamalainen <ccr@tnsp.org>
parents: 898
diff changeset
348 $setWidth = 75;
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 $setEntryPath = stGetSetting("entryPath");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 $setPreviewPath = stGetSetting("previewPath");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 $setPreviewURL = stGetSetting("previewURL");
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 $setThumbDir = stGetSetting("thumbnailSubDir");
832
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
353 $setEntryPathPerms = stGetSetting("entryPathPerms");
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
354 $setPrevPathPerms = stGetSetting("previewPathPerms");
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 if ($setEntryPath === FALSE || $setPreviewPath === FALSE ||
832
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
357 $setPreviewURL === FALSE || $setThumbDir === FALSE ||
Matti Hamalainen <ccr@tnsp.org>
parents: 831
diff changeset
358 $setEntryPathPerms === FALSE || $setPrevPathPerms === FALSE)
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 {
831
40546d6f9254 Typofix.
Matti Hamalainen <ccr@tnsp.org>
parents: 827
diff changeset
360 die("Some required settings not defined in mconfig.inc.php!\n");
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 // Act according to specified command
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
365 switch (substr(stCArgLC(1), 0, 3))
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 {
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
367 case "ini":
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 // Initialize the data directories etc
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 //
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 stInitializeDirs();
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 break;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
374 case "cle":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
375 $doDelete = (stCArgLC(2) == "delete");
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
376 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
377 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
378 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
379 printf(
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
380 "==%'=-".($setWidth-2)."s\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
381 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40))
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
382 );
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
383 echo str_repeat("-", $setWidth)."\n";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
384
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
385 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
386 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
387 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
388 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
389 if ($efile["delete"] != 0)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
390 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
391 echo "X";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
392 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
393 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
394 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
395 echo "\n";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
396 echo str_repeat("-", $setWidth)."\n";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
397 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
398 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
399
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
400 case "ent":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
401 //
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
402 // Entry files handling
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
403 //
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
404 $mode = substr(stCArgLC(2), 0, 3);
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
405 switch ($mode)
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
406 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
407 case "unp":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
408 case "sta":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
409 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
410 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
411 {
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
412 printf(
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
413 "==%'=-".($setWidth-2)."s\n".
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
414 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40))
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
415 );
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
416 echo str_repeat("-", $setWidth)."\n";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
417
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
418 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
419 wtHandleEntry($compo, $entry, $mode);
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
420
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
421 echo str_repeat("-", $setWidth)."\n";
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
422 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
423 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
424
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
425 case "pac":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
426 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
427
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
428 case "add":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
429 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
430
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
431 default:
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
432 if ($mode == "")
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
433 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
434 else
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
435 die("ERROR! Invalid entry sub-command '".stCArg(2)."'.\n");
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
436 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
437 }
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
438 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
439
884
bc64949e7a97 Moar work.
Matti Hamalainen <ccr@tnsp.org>
parents: 882
diff changeset
440 case "pre":
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
441 //
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
442 // Preview files handling
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
443 //
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
444 $mode = substr(stCArgLC(2), 0, 3);
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
445 switch ($mode)
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
446 {
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
447 case "upd":
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
448 case "sta":
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
449 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo)
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
450 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
451 {
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
452 printf(
900
b147f99934f6 Add screen width.
Matti Hamalainen <ccr@tnsp.org>
parents: 898
diff changeset
453 "==%'=-".($setWidth-2)."s\n".
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
454 "PrevType : %s\n",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
455 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40)),
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
456 $previewTypeList[$compo["preview_type"]][0]);
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
457
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
458 printf(" %-3s | %-3s | %-40s |\n",
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
459 "#ID", "FLG", "Entry name/author");
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
460
900
b147f99934f6 Add screen width.
Matti Hamalainen <ccr@tnsp.org>
parents: 898
diff changeset
461 echo str_repeat("-", $setWidth)."\n";
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
462
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
463 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
464 wtHandleEntryPreview($compo, $entry, $mode);
898
750b3b57ec61 More prototyping.
Matti Hamalainen <ccr@tnsp.org>
parents: 884
diff changeset
465
900
b147f99934f6 Add screen width.
Matti Hamalainen <ccr@tnsp.org>
parents: 898
diff changeset
466 echo str_repeat("=", $setWidth)."\n\n";
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
467 }
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
468 break;
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
469
901
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
470 case "add":
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
471 break;
dfa1277786c1 Some more work on faptool.
Matti Hamalainen <ccr@tnsp.org>
parents: 900
diff changeset
472
881
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
473 default:
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
474 if ($mode == "")
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
475 die("ERROR! Previews command requires a sub-command argument.\n");
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
476 else
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
477 die("ERROR! Invalid previews sub-command '".stCArg(2)."'.\n");
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
478 break;
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
479 }
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
480 break;
7c805dccd4f7 Work on the tool.
Matti Hamalainen <ccr@tnsp.org>
parents: 880
diff changeset
481
827
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 default:
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
483 echo "ERROR! Invalid operation mode '".stCArg(1)."'.\n";
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 break;
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 }
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486
2e18d8102504 Initial import of faptool.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 ?>