Mercurial > hg > fapweb
comparison faptool.php @ 968:c71afc1a3a85
Moar work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 29 Nov 2014 08:38:34 +0200 |
parents | 62c90ec5edce |
children | 26ae3f21a3bb |
comparison
equal
deleted
inserted
replaced
967:62c90ec5edce | 968:c71afc1a3a85 |
---|---|
175 $args = "-d ".escapeshellarg($path)." ".escapeshellarg($filename); | 175 $args = "-d ".escapeshellarg($path)." ".escapeshellarg($filename); |
176 break; | 176 break; |
177 | 177 |
178 case "RAR": | 178 case "RAR": |
179 $exe = "/usr/bin/rar"; | 179 $exe = "/usr/bin/rar"; |
180 $args = "x ".escapeshellarg($filename); | 180 $args = "x -w".escapeshellarg($path)." ".escapeshellarg($filename); |
181 break; | |
182 | |
183 case "7ZIP": | |
184 $exe = "/usr/bin/7z"; | |
185 $args = "x -o".escapeshellarg($path)." ".escapeshellarg($filename); | |
181 break; | 186 break; |
182 | 187 |
183 default: | 188 default: |
184 echo "Unsupported archive file type: ".$atype."\n"; | 189 echo "Unsupported archive file type: ".$atype."\n"; |
185 return FALSE; | 190 return FALSE; |
482 { | 487 { |
483 wtMakeDir(stMakePath(FALSE, FALSE, array($setEntryPath, $compo["cpath"])), $setEntryPathPerms); | 488 wtMakeDir(stMakePath(FALSE, FALSE, array($setEntryPath, $compo["cpath"])), $setEntryPathPerms); |
484 wtMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"])), $setPrevPathPerms); | 489 wtMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"])), $setPrevPathPerms); |
485 wtMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"], $setThumbDir)), $setPrevPathPerms); | 490 wtMakeDir(stMakePath(FALSE, FALSE, array($setPreviewPath, $compo["cpath"], $setThumbDir)), $setPrevPathPerms); |
486 } | 491 } |
492 } | |
493 | |
494 | |
495 function wtPrintCompoHeader($compo) | |
496 { | |
497 global $setTermWidth; | |
498 printf("==%'=-".($setTermWidth-2)."s\n", | |
499 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40)) | |
500 ); | |
501 } | |
502 | |
503 | |
504 function wtPrintDivider($chr = "-") | |
505 { | |
506 global $setTermWidth; | |
507 echo str_repeat($chr, $setTermWidth)."\n"; | |
487 } | 508 } |
488 | 509 |
489 | 510 |
490 function wtShowHelp() | 511 function wtShowHelp() |
491 { | 512 { |
629 // | 650 // |
630 $doDelete = (stCArgLC(2) == "delete"); | 651 $doDelete = (stCArgLC(2) == "delete"); |
631 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo) | 652 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo) |
632 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) | 653 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) |
633 { | 654 { |
634 printf( | 655 wtPrintCompoHeader($compo); |
635 "==%'=-".($setTermWidth-2)."s\n", | 656 wtPrintDivider(); |
636 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40)) | |
637 ); | |
638 echo str_repeat("-", $setTermWidth)."\n"; | |
639 | 657 |
640 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) | 658 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) |
641 { | 659 { |
642 foreach (stExecSQL("SELECT * FROM files WHERE entry_id=".$entry["id"]) as $efile) | 660 foreach (stExecSQL("SELECT * FROM files WHERE entry_id=".$entry["id"]) as $efile) |
643 { | 661 { |
646 echo "X"; | 664 echo "X"; |
647 } | 665 } |
648 } | 666 } |
649 } | 667 } |
650 echo "\n"; | 668 echo "\n"; |
651 echo str_repeat("-", $setTermWidth)."\n"; | 669 wtPrintDivider(); |
652 } | 670 } |
653 break; | 671 break; |
654 | 672 |
655 case "ent": | 673 case "ent": |
656 // | 674 // |
663 case "lis": | 681 case "lis": |
664 $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : ""; | 682 $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : ""; |
665 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo) | 683 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo) |
666 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) | 684 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) |
667 { | 685 { |
668 printf( | 686 wtPrintCompoHeader($compo); |
669 "==%'=-".($setTermWidth-2)."s\n". | 687 wtPrintDivider(); |
670 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40)) | |
671 ); | |
672 echo str_repeat("-", $setTermWidth)."\n"; | |
673 | 688 |
674 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) | 689 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) |
675 wtHandleEntry($compo, $entry, $mode); | 690 wtHandleEntry($compo, $entry, $mode); |
676 | 691 |
677 echo str_repeat("-", $setTermWidth)."\n"; | 692 wtPrintDivider(); |
678 } | 693 } |
679 break; | 694 break; |
680 | 695 |
681 case "unp": | 696 case "unp": |
682 if (($setPrefix = stCArg(3)) == "") | 697 if (($setPrefix = stCArg(3)) == "") |
718 case "lis": | 733 case "lis": |
719 $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : ""; | 734 $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : ""; |
720 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo) | 735 foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo) |
721 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) | 736 if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) |
722 { | 737 { |
738 wtPrintCompoHeader($compo); | |
723 printf( | 739 printf( |
724 "==%'=-".($setTermWidth-2)."s\n". | |
725 "PrevType : %s\n", | 740 "PrevType : %s\n", |
726 sprintf("[ #%03d - %s ]", $compo["id"], substr($compo["name"], 0, 40)), | |
727 $previewTypeList[$compo["preview_type"]][0]); | 741 $previewTypeList[$compo["preview_type"]][0]); |
728 | 742 |
729 if ($mode == "sta") | 743 if ($mode == "sta" || $mode == "lis") |
730 { | 744 { |
731 printf(" %-3s | %-3s | %-40s |\n", | 745 printf(" %-3s | %-3s | %-40s |\n", |
732 "#ID", "FLG", "Entry name/author"); | 746 "#ID", "EPV", "Entry name/author"); |
733 } | 747 } |
734 | 748 |
735 echo str_repeat("-", $setTermWidth)."\n"; | 749 wtPrintDivider("-"); |
736 | 750 |
737 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) | 751 foreach (stExecSQL("SELECT * FROM entries WHERE compo_id=".$compo["id"]) as $entry) |
738 wtHandleEntryPreview($compo, $entry, $mode); | 752 wtHandleEntryPreview($compo, $entry, $mode); |
739 | 753 |
740 echo str_repeat("=", $setTermWidth)."\n\n"; | 754 wtPrintDivider("="); |
755 } | |
756 if ($mode == "sta" || $mode == "lis") | |
757 { | |
758 echo "Flags: E = Entry has file, P = Has preview file, V = Generated previews are up to date.\n"; | |
741 } | 759 } |
742 break; | 760 break; |
743 | 761 |
744 case "add": | 762 case "add": |
745 echo "Not implemented. :D\n"; | 763 echo "Not implemented. :D\n"; |