Mercurial > hg > fapweb
changeset 907:affd8bd8c910
Add new check type(s) CHK_ARRAY_KEY and CHK_ARRAY_VAL, remove CHK_ARRAY as
we need to be specific.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 27 Nov 2014 10:05:26 +0200 |
parents | 0fe53c3ddcfb |
children | 21b163500ed6 |
files | admajax.php msite.inc.php msitegen.inc.php |
diffstat | 3 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/admajax.php Thu Nov 27 09:59:53 2014 +0200 +++ b/admajax.php Thu Nov 27 10:05:26 2014 +0200 @@ -46,7 +46,7 @@ stChkRequestItemFail("preview_type", $fake, $res, array(CHK_TYPE, VT_INT, "Invalid data."), - array(CHK_ARRAY, $previewTypeList, "Invalid preview type value.")); + array(CHK_ARRAY_KEY, $previewTypeList, "Invalid preview type value.")); stChkRequestItemFail("cpath", $fake, $res, array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long (%1 chars, must be less than %2)."));
--- a/msite.inc.php Thu Nov 27 09:59:53 2014 +0200 +++ b/msite.inc.php Thu Nov 27 10:05:26 2014 +0200 @@ -1141,7 +1141,7 @@ // Check basics if (!stChkRequestItem("type", $uploadType, array(CHK_TYPE, VT_STR, "Invalid upload type."), - array(CHK_ARRAY, array("entry", "preview"), "Invalid upload type.")) + array(CHK_ARRAY_VAL, array("entry", "preview"), "Invalid upload type class.")) || !stChkRequestItem("entry_id", $entryID, array(CHK_TYPE, VT_INT, "Invalid entry ID.")))
--- a/msitegen.inc.php Thu Nov 27 09:59:53 2014 +0200 +++ b/msitegen.inc.php Thu Nov 27 10:05:26 2014 +0200 @@ -26,7 +26,8 @@ define("CHK_LTEQ", 6); define("CHK_RANGE", 7); define("CHK_CUSTOM", 8); -define("CHK_ARRAY", 9); +define("CHK_ARRAY_KEY", 9); +define("CHK_ARRAY_VAL", 9); function stDebug($msg) @@ -475,11 +476,16 @@ } break; - case CHK_ARRAY: + case CHK_ARRAY_KEY: if (!isset($check[1][$data])) return stErrorStrF($check[2], $data); break; + case CHK_ARRAY_VAL: + if (!in_array($data, $check[1], TRUE)) + return stErrorStrF($check[2], $data); + break; + case CHK_CUSTOM: // Call a custom function (or closure) $func = $check[1];