Mercurial > hg > fapweb
diff faptool.php @ 1006:cb23b23a2d8b
Improve commandline parsing, fix some potential bug situations.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 05 Apr 2015 15:35:55 +0300 |
parents | f650ae251d8c |
children | 720078ca799e |
line wrap: on
line diff
--- a/faptool.php Sun Mar 29 15:55:54 2015 +0300 +++ b/faptool.php Sun Apr 05 15:35:55 2015 +0300 @@ -729,7 +729,7 @@ // Act according to specified command -switch (substr(stCArgLC(1), 0, 3)) +switch (stCArgLC(1, 3)) { case "-?": case "--h": wtShowHelp(); @@ -810,12 +810,12 @@ // // Entry files handling // - $mode = substr(stCArgLC(2), 0, 3); + $mode = stCArgLC(2, 3); switch ($mode) { case "sta": case "lis": - $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : ""; + $sql = (stCArg(3) !== FALSE) ? " AND id=".intval(stCArg(3)) : ""; foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo) if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) { @@ -830,7 +830,7 @@ break; case "unp": - if (($setPrefix = stCArg(3)) == "") + if (($setPrefix = stCArg(3)) === FALSE) die("Unpack needs a destination path.\n"); foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL") as $compo) @@ -842,7 +842,7 @@ break; case "rel": - if (($setPrefix = stCArg(3)) == "") + if (($setPrefix = stCArg(3)) === FALSE) die("Releases needs a destination path.\n"); if (!file_exists($setPrefix) || is_dir($setPrefix)) @@ -899,14 +899,14 @@ // // Preview files handling // - $mode = substr(stCArgLC(2), 0, 3); + $mode = stCArgLC(2, 3); switch ($mode) { case "gen": case "upd": case "sta": case "lis": - $sql = (stCArg(3) != "") ? " AND id=".intval(stCArg(3)) : ""; + $sql = (stCArg(3) !== FALSE) ? " AND id=".intval(stCArg(3)) : ""; foreach (stExecSQL("SELECT * FROM compos WHERE cpath <> '' AND cpath IS NOT NULL".$sql) as $compo) if (stFetchSQLColumn("SELECT COUNT(*) FROM entries WHERE compo_id=".$compo["id"]) > 0) {