Mercurial > hg > fapweb
diff msitegen.inc.php @ 208:8985d2bdb29b
More work on error handling etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 17 Nov 2013 20:04:50 +0200 |
parents | 96ab189e5c03 |
children | cafc05949a19 |
line wrap: on
line diff
--- a/msitegen.inc.php Sun Nov 17 19:26:46 2013 +0200 +++ b/msitegen.inc.php Sun Nov 17 20:04:50 2013 +0200 @@ -8,6 +8,8 @@ // Globals and definitions $errorSet = FALSE; $errorMsg = ""; +$statusSet = 0; +$statusMsg = ""; // Value types define("VT_STR", 1); @@ -38,6 +40,14 @@ } +function stSetStatus($status, $msg) +{ + global $statusSet, $statusMsg; + $statusMsg = $msg; + $statusSet = $status; +} + + function stCheckHTTPS() { return isset($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] != "" && $_SERVER["HTTPS"] != "off"); @@ -249,7 +259,7 @@ function stChkRequestItem($name, &$sdata) { if (!isset($_REQUEST[$name])) - return FALSE; + return stErrorStrF("Required data item '".$name."' not set.", $name); $data = trim($_REQUEST[$name]); $slen = strlen($data); @@ -482,28 +492,17 @@ } -function stSetStatus($val, $msg) -{ - global $statusSet; - if (!$statusSet) - { - header("Status: ".$val." ".$msg); - } - $statusSet = TRUE; -} - - -function stExecSQLCond($sql, $okmsg) +function stExecSQLCond($sql, $msg = FALSE) { if (($res = stExecSQL($sql)) !== FALSE) { - if ($okmsg != "") - stSetStatus(200, $okmsg); + if ($msg !== FALSE) + stSetStatus(200, $msg); return $res; } else { - stSetStatus(900, "Error in SQL execution."); + stSetStatus(902, "Error in SQL execution."); return FALSE; } }