function dbFlexigrid($innerFunction, $headers = TRUE) { $userid = getUserID(); $profilingID = beginProfilingEntry(array("activity" => "database", "userid" => $userid)); $page = getSoft($_REQUEST, "page", -1); //flexigrid required $rp = getSoft($_REQUEST, "rp", -1); //flexigrid required: results per page if (!is_numeric($page) || $page <= 0) { $page = 1; } if (!is_numeric($rp) || $rp < 0) { $rp = 1; } // $rp == 0 means you just want the count, it is not a real interface with flexigrid $sortname = trim(getSoft($_REQUEST, "sortname", NULL)); if ($sortname == "undefined") { $sortname = NULL; } $sortorder = trim(getSoft($_REQUEST, "sortorder", "")); // not yet utilized: sortname, sortorder, qtype, query if (strtoupper($sortorder) != "ASC") { $sortorder = "DESC"; } global $db_query_info; $result = $innerFunction(" LIMIT " . ($page - 1) * $rp . ", " . $rp . " ", $sortname, $sortorder); if ($headers) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-type: text/x-json"); } $activity = "database-"; if (array_key_exists('type', $db_query_info)) { $activity .= $db_query_info['type']; unset($db_query_info['type']); } if (is_array($result)) { // success case $result['page'] = $page; $db_query_info['result'] = 'success'; endProfilingEntry($profilingID, array("activity" => $activity, "meta" => $db_query_info)); return json_encode($result); } else { $db_query_info['result'] = 'error'; endProfilingEntry($profilingID, array("activity" => $activity, "meta" => $db_query_info)); return json_encode("Error: " . $result); // failure case; just sending a string. } }
function submit_code_main($post, $_log_it) { global $log_it; $log_it = $_log_it; global $submit_code_stderr, $submit_code_errnice; $submit_code_stderr = NULL; $submit_code_errnice = NULL; $result = run_submission($post); if ($log_it) { //rest of the query logging global $wpdb, $logRow, $mainProfilingID, $meta; $crossref = NULL; if ($logRow != FALSE) { $logRow['result'] = $result[0]; $table_name = $wpdb->prefix . "pb_submissions"; $wpdb->insert($table_name, $logRow); $crossref = $wpdb->insert_id; } $meta['ipaddress'] = $_SERVER['REMOTE_ADDR']; endProfilingEntry($mainProfilingID, array("crossref" => $crossref, "meta" => $meta)); } return $result; }