# HG changeset patch # User Matti Hamalainen # Date 1382432907 -10800 # Node ID 91660a9d50f05eff6f2ac481cad68016bf91897a # Parent ac1df74619cd3c2a2484fc10ff4819d633c29bf3 Add some error checking to compo id updating vs. compo entries. diff -r ac1df74619cd -r 91660a9d50f0 admajax.php --- a/admajax.php Tue Oct 22 00:34:35 2013 +0300 +++ b/admajax.php Tue Oct 22 12:08:27 2013 +0300 @@ -408,16 +408,24 @@ stChkRequestItem("name") && stChkRequestItem("author") && stChkRequestItem("compo_id")) { - $sql = stPrepareSQLUpdate("entries", - "WHERE id=".intval(stGetRequestItem("id")), - array( - "name" => "S", - "author" => "S", - "filename" => "S", - "compo_id" => "D", - )); + $cid = stGetRequestItem("compo_id"); + if (stFetchSQLColumn("SELECT id FROM compos WHERE id=".$cid) === FALSE) + { + stSetStatus(903, "No such compo id."); + } + else + { + $sql = stPrepareSQLUpdate("entries", + "WHERE id=".intval(stGetRequestItem("id")), + array( + "name" => "S", + "author" => "S", + "filename" => "S", + "compo_id" => "D", + )); - stExecSQLCond($sql, "OK, entry updated."); + stExecSQLCond($sql, "OK, entry updated."); + } } else if ($type == "settings")