# HG changeset patch # User Matti Hamalainen # Date 1417310125 -7200 # Node ID 5d04bd1a7a10767a31a3c03ac3b0a1dfd0f30958 # Parent 0a8cb8f9f55560f120c228e76b4df38f42f2e348# Parent 3e9e0aa21a18bda1a505e2e87352ccfb1c7342cf Merge. diff -r 0a8cb8f9f555 -r 5d04bd1a7a10 faptool.php --- a/faptool.php Sat Nov 29 20:03:33 2014 +0200 +++ b/faptool.php Sun Nov 30 03:15:25 2014 +0200 @@ -446,7 +446,7 @@ } -function wtUnpackEntry($compo, $entry, $pathPrefix, $useOrig, $cropNames) +function wtUnpackEntry($compo, $entry, $pathPrefix, $useOrig, $cropNames, $copyOnly) { global $setEntryPath; @@ -474,9 +474,12 @@ if (wtMakeDir(stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"])), 0755) === false) return FALSE; - $dstFileBase = wtCropFilename($entry["show_id"]."-".($useOrig ? $efile["origname"] : $efile["filename"]), $cropNames); + if ($copyOnly) + $dstFileBase = $useOrig ? $efile["origname"] : $efile["filename"]; + else + $dstFileBase = wtCropFilename($entry["show_id"]."-".($useOrig ? $efile["origname"] : $efile["filename"]), $cropNames); - if ($edata["class"] == EFILE_ARCHIVE) + if (!$copyOnly && $edata["class"] == EFILE_ARCHIVE) { // Entry is an archive file .. $dstPath = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], stReplaceFileExt($dstFileBase, ""))); @@ -627,6 +630,7 @@ " entry [args]\n". " status [cid] - List entries for all compos or .\n". " unpack - Create subdirs and copy all entries UNPACKED there.\n". + " release - Like unpack, but just copies files (does not unpack archives).\n". /* " add '' '' - Add file as entry file\n". " (works same as uploading from admin interface)\n". @@ -783,7 +787,45 @@ foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo) foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) { - wtUnpackEntry($compo, $entry, $setPrefix, TRUE, 32); +// wtUnpackEntry($compo, $entry, $setPrefix, TRUE, 32, FALSE); + wtUnpackEntry($compo, $entry, $setPrefix, TRUE, FALSE, FALSE); + } + break; + + case "rel": + if (($setPrefix = stCArg(3)) == "") + die("Releases needs a destination path.\n"); + + if (!file_exists($setPrefix) || is_dir($setPrefix)) + { + // Create new one + wtMakeDir($setPrefix, 0755); + + // Create results.txt if it does not exist + $resultsFile = stMakePath(FALSE, TRUE, array($setPrefix, "results.txt")); + if (!file_exists($resultsFile)) + { + // Use a header file if it exists + $resultsHeader = "results.logo"; + if (file_exists($resultsHeader) && is_file($resultsHeader)) + $resultsText = file_get_contents($resultsHeader); + else + { + $resultsText = $pageTitle." results"; + $resultsText .= "\n".str_repeat("=", strlen($resultsText))."-- -\n\n"; + } + + file_put_contents( + $resultsFile, + $resultsText.stGetCompoResultsASCIIStr(FALSE, 0) + ); + } + + foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo) + foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) + { + wtUnpackEntry($compo, $entry, $setPrefix, TRUE, FALSE, TRUE); + } } break;