# HG changeset patch # User Matti Hamalainen # Date 1455114056 -7200 # Node ID 7298b2898a6db04c3d4eee0e537e0c0dd7f6ac49 # Parent 280de0770798b5ff41741b27ea7fa102320414e2# Parent 6db0ab61dadf7a54a7eb9e914c99051c8c378971 Merged. diff -r 280de0770798 -r 7298b2898a6d admajax.php --- a/admajax.php Wed Feb 10 16:18:46 2016 +0200 +++ b/admajax.php Wed Feb 10 16:20:56 2016 +0200 @@ -227,6 +227,17 @@ } +function stGetCompoVoting($compo, $outer) +{ + return + ($outer ? "" : ""). + stGetFormCheckBoxInput( + "votingbutton", $compo["id"], "co", $compo["voting"], "Voting ".($compo["voting"] ? "IS ACTIVE" : "disabled"), + "class=\"votingactive\" onChange=\"updateCompoVoting(".$compo["id"].")\"", ""). + ($outer ? "" : ""); +} + + function stPrintEntryItemData($item, $row, $tr, $prefix, $compo, $mode) { global $entryFlagsList, $previewTypeList, $compoModeData; @@ -396,7 +407,12 @@ { $nkeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys WHERE active=1"); $totalKeys = stFetchSQLColumn("SELECT COUNT(*) FROM votekeys"); - return "Info: ".$nkeys." of ".$totalKeys." votekeys are activated."; + + $nvoters = stFetchSQLColumn("SELECT COUNT(DISTINCT(key_id)) FROM votes"); + + return + "Info: ".$nkeys." of ".$totalKeys." votekeys are activated. ". + "Also, ".$nvoters." keys have been used for voting."; } @@ -878,7 +894,7 @@ } } if ($ncompos > 0) - echo "
  • VOTING COMPOS: ".$nentries." compo entries in ".$ncompos." compos.
  • \n"; + echo "
  • VOTING COMPOS: ".$nentries." entries in ".$ncompos." compos.
  • \n"; $nentries = $ncompos = 0; foreach (stExecSQL("SELECT * FROM compos WHERE ctype <> ".COMPO_NORMAL) as $compo) @@ -1211,13 +1227,14 @@ stGetShowModeButton(SMODE_DISABLED, "Off/disabled", $showMode)."\n". stGetShowModeButton(SMODE_ROTATE, "Slide rotation", $showMode)."\n". stGetShowModeButton(SMODE_COMPO, "Compo mode", $showMode)."\n". - "Open info window\n". - stGetFormButtonElement("showForceReload", "", "", "Showscreen reload", "showScreenCmd('reload')")."\n". - "\n". - "
    \n". - stGetFormButtonInput("syscheck", "", "", "Perform system check", "performSystemCheck()")."\n". - stGetFormButtonInput("generate", "", "", "Add missing show positions", "generateEntryPositions(0, 1)")."\n". - stGetFormButtonInput("regenerate", "", "", "ReGenerate ALL show positions", "generateEntryPositions(0, 0)")."\n". + stGetFormButtonInput("openShowScreen", "", "", "Showscreen window", "window.open('show.php')")."\n". + stGetFormButtonInput("reloadShowScreen", "", "", "Showscreen reload", "showScreenCmd('reload')")."\n". + //"
    \n". + //"
    \n". + stGetFormButtonInput("systemCheck", "", "", "System check", "performSystemCheck()")."\n". + stGetFormButtonInput("generateShowPositions", "", "", "Add show positions", "generateEntryPositions(0, 1)")."\n". + // XXX: disable this button for now + // stGetFormButtonInput("regenerate", "", "", "RESET show positions", "generateEntryPositions(0, 0)")."\n". "
    \n"; echo @@ -1434,7 +1451,16 @@ } } - // List of votekeys + // Some information + echo + "
    \n". + " Show printable key list\n". + " Printable results\n". + " Printable full results (shows also disqualified entries)\n". + " Printable FULL results (shows also hidden and empty compos)\n". + "
    ".stGetVoteKeyInfo()."
    \n". + "
    \n"; + echo "
    Voting mode: "; @@ -1442,14 +1468,10 @@ echo $voteModeData[$setVoteKeyMode][0].". ".$voteModeData[$setVoteKeyMode][1]; else echo "VOTE MODE NOT SET! CHECK CONFIGURATION!"; - - echo - "
    \n". - "
    \n". - "Show printable key list\n". - "
    ".stGetVoteKeyInfo()."
    \n". - "
    \n"; + echo "\n"; + + // List of votekeys switch ($setVoteKeyMode) { case VOTE_FREELY: @@ -1498,13 +1520,10 @@ case "compos": echo - "
    \n". - " Printable results\n". - " Printable full results (shows also disqualified entries)\n". - " Printable FULL results (shows also hidden and empty compos)\n". - "
    \n". "
    \n". + "Name:". " ".stGetFormTextInput(64, SET_LEN_COMPO_NAME, "", "ncname", "", "")."
    \n". + "Description:". " ".stGetFormTextArea(5, 60, "", "ncdescription", "", "")."
    \n". " ".stGetFormSubmitInput("nccompo", "Add compo")."\n". " ".stGetFormButtonInput("", "", "", "Clear", "this.form.reset()")."\n". @@ -1605,6 +1624,12 @@ } break; + case "compovoting": + $id = intval(stGetRequestItem("id", 0)); + if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) + echo stGetCompoVoting($compo, FALSE); + break; + case "entries": $id = intval(stGetRequestItem("id", 0)); if (($compo = stFetchSQL("SELECT * FROM compos WHERE id=".$id)) !== false) @@ -1618,7 +1643,8 @@ { echo stGetFormButtonInput("generate", "", "", " Add missing show positions ", "generateEntryPositions(".$id.", 1)")."\n". - stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n"; + stGetFormButtonInput("regenerate", "", "", " ReGenerate show positions ", "generateEntryPositions(".$id.", 0)")."\n". + stGetCompoVoting($compo, TRUE)."\n"; } stPrintEntryItemData(array( @@ -1741,8 +1767,8 @@ if ($type == "compo" && stValidateRequestCompoData(FALSE, 0)) { $sql = stPrepareSQL( - "INSERT INTO compos (name,description,notes,visible,voting,show_authors,preview_type) VALUES (%S,%Q,%Q,0,0,0,0)", - "name", "description", "notes"); + "INSERT INTO compos (name,description,visible,voting,show_authors,preview_type) VALUES (%S,%Q,0,0,0,0)", + "name", "description"); stExecSQLCond($sql, "OK, compo added."); } @@ -1822,6 +1848,15 @@ stExecSQLCond($sql, "OK, compo updated."); } else + if ($type == "compovoting" && + stChkRequestItem("voting", $compovoting, $qres, + array(CHK_TYPE, VT_BOOL, "Invalid data.") + )) + { + $sql = stPrepareSQL("UPDATE compos SET voting=%b WHERE id=%d", $compovoting, $id); + stExecSQLCond($sql, "OK, compo updated."); + } + else if ($type == "compo") { // Check if compo ID exists diff -r 280de0770798 -r 7298b2898a6d admin.js --- a/admin.js Wed Feb 10 16:18:46 2016 +0200 +++ b/admin.js Wed Feb 10 16:20:56 2016 +0200 @@ -60,7 +60,7 @@ if (tabContent && tabHead) { tabContent.style.display = (tab == id) ? "block" : "none"; - tabHead.style.borderTop = (tab == id) ? "4px solid white" : "none"; + tabHead.className = (tab == id) ? "active" : "inactive"; if (tab == id) { // Set active tab and refresh contents @@ -361,7 +361,7 @@ // function addCompo() { - var args = jsMakePostArgs({"name":1, "description":1, "notes":1}, "nc", ""); + var args = jsMakePostArgs({"name":1, "description":1}, "nc", ""); var msuccess = function(txt) { @@ -385,6 +385,17 @@ } +function updateCompoVoting(id) +{ + var msuccess = function(txt) + { + jsRefreshItems("covoting"+id, "compovoting", "&id="+id); + } + + jsSendPOSTRequest("action=update&type=compovoting&id="+id+"&voting="+jsGetValue("covotingbutton"+id, 3), msuccess); +} + + function updateCompo(id) { var args = jsMakePostArgs({"name":1, "description":1, "notes":1, "visible":3, "voting":3, "show_authors":3, "cpath":1, "preview_type":4}, "co", id, true); diff -r 280de0770798 -r 7298b2898a6d faptool.php --- a/faptool.php Wed Feb 10 16:18:46 2016 +0200 +++ b/faptool.php Wed Feb 10 16:20:56 2016 +0200 @@ -221,7 +221,7 @@ wtPurgeDir($path); // Create temporary directory for unpacking - wtMakeDir($path, 0700); + wtMakeDir($path, 0755); // Save current working directory and chdir to target $cwd = getcwd(); @@ -508,6 +508,34 @@ return FALSE; } + // Make information file contents + $sbinfo = [ + "FAP Entry Information", + "=====================", + "Compo : ".$compo["name"]." (ID #".$compo["id"].")", + "Entry : '".$entry["name"]."' by ".$entry["author"]." (ID #".$entry["id"].")", + "Show # : ".($entry["show_id"] > 0 ? $entry["show_id"] : "NOT SET!"), + ]; + + if (strlen($entry["info"]) > 0) + { + $sbinfo[] = ""; + $sbinfo[] = "INFO:"; + foreach (preg_split("/\r\n|\n|\r/", $entry["info"]) as $sline) + $sbinfo[] = $sline; + } + + if (strlen($entry["notes"]) > 0) + { + $sbinfo[] = ""; + $sbinfo[] = "INTERNAL NOTES:"; + foreach (preg_split("/\r\n|\n|\r/", $entry["notes"]) as $sline) + $sbinfo[] = $sline; + } + + $sbinfo[] = ""; + + // Create the destination directory if (wtMakeDir(stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"])), 0755) === false) return FALSE; @@ -518,23 +546,37 @@ else $dstFileBase = wtCropFilename($entry["show_id"]."-".($useOrig ? $efile["origname"] : $efile["filename"]), $cropNames); + $dstPath = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], stReplaceFileExt($dstFileBase, ""))); // Handle based on class/type and whether we are just copying or not - if (!$copyOnly && $edata["class"] == EFILE_ARCHIVE) + if ($copyOnly) + { + $dstFilename = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], $dstFileBase)); + if (copy($filename, $dstFilename) === false) + { + echo "ERROR: Failed to copy '".$filename."' to '".$dstFilename."'\n"; + return FALSE; + } + } + else + if ($edata["class"] == EFILE_ARCHIVE) { // Entry is an archive file, so unpack it - $dstPath = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], stReplaceFileExt($dstFileBase, ""))); if (wtUnpackArchiveTo($edata["id"], $filename, $dstPath) === false) return FALSE; // Crop the filenames from the unpacked archive, if we need to if ($cropNames !== false) wtCropFilenamesRec($dstPath, $cropNames); + } else { // We have a single file (or copyOnly mode) - $dstFilename = stMakePath(FALSE, FALSE, array($pathPrefix, $compo["cpath"], $dstFileBase)); + if (wtMakeDir($dstPath, 0755) === false) + return FALSE; + + $dstFilename = stMakePath(FALSE, FALSE, array($dstPath, wtCropFilename($efile["origname"], $cropNames))); if (copy($filename, $dstFilename) === false) { echo "ERROR: Failed to copy '".$filename."' to '".$dstFilename."'\n"; @@ -542,6 +584,13 @@ } } + $dstFilename = stMakePath(FALSE, FALSE, array($dstPath, "fapinfo.txt")); + if (@file_put_contents($dstFilename, implode("\r\n", $sbinfo)) === FALSE) + { + echo "ERROR: Failed to output '".$dstFilename."'\n"; + return FALSE; + } + return TRUE; } diff -r 280de0770798 -r 7298b2898a6d msite.inc.php --- a/msite.inc.php Wed Feb 10 16:18:46 2016 +0200 +++ b/msite.inc.php Wed Feb 10 16:20:56 2016 +0200 @@ -273,6 +273,7 @@ "class" => EFILE_ARCHIVE, "mime" => "application/x-lha", "fext" => "lha", + "test" => "^LHarc 1\.x", ), "ZIP" => array( "class" => EFILE_ARCHIVE,