function checkAdminForReportByReportId($report_id) { session_start(); $pdo = getPDOConnection(); $query = "SELECT admin_id FROM `ezpz-report-g`.`report_report` WHERE id = :report_id"; $admin_id = getPDOParametrizedQueryScalarValue($pdo, $query, array(":report_id" => $report_id), __FILE__, __LINE__); if (!$admin_id) { throw new Exception("Cannot get the admin_id!"); } if ($_SESSION['ezpz_sb_admin_id'] == $admin_id) { return True; } else { return False; } }
$query = "INSERT INTO `ezpz-report-g`.report_players(sid, ip, nick) VALUES (:trg_sid, :trg_ip, :trg_nick)"; $parameters = array(":trg_sid" => $_GET["trg_sid"], ":trg_ip" => $_GET["trg_ip"], ":trg_nick" => $_GET["trg_nick"]); PDOExecParametrizedQuery($pdo, $query, $parameters, __FILE__, __LINE__); } $target_id = $pdo->lastInsertId(); } else { $target_id = getPDOParametrizedQueryScalarValue($pdo, "SELECT id FROM `ezpz-report-g`.report_players WHERE sid = :trg_sid", array(":trg_sid" => $_GET["trg_sid"]), __FILE__, __LINE__); $parameters = array(":trg_ip" => $_GET["trg_ip"], ":trg_nick" => $_GET["trg_nick"], ":target_id" => intval($target_id)); PDOExecParametrizedQuery($pdo, "UPDATE `ezpz-report-g`.report_players SET ip = :trg_ip, nick = :trg_nick WHERE id = :target_id", $parameters, __FILE__, __LINE__); } // INSERT map to report_map if map doesn't exist there if (PDOcheckEmptyQuery($pdo, "SELECT id FROM `ezpz-report-g`.report_map WHERE map = :map", __FILE__, __LINE__, array(":map" => $_GET["map"]))) { PDOExecParametrizedQuery($pdo, "INSERT INTO `ezpz-report-g`.report_map(map) VALUES (:map)", array(":map" => $_GET["map"]), __FILE__, __LINE__); $map_id = $pdo->lastInsertId(); } else { $map_id = getPDOParametrizedQueryScalarValue($pdo, "SELECT id FROM `ezpz-report-g`.report_map WHERE map = :map", array(":map" => $_GET["map"]), __FILE__, __LINE__); } // check if target was reported today // if true, use the same admin id for this report // if false, assign new admin id $query = "SELECT admin_id FROM `ezpz-report-g`.report_report AS r JOIN `ezpz-report-g`.report_players AS p ON p.id = r.target_id\n WHERE DATE(r.time_create) = :time_create AND p.sid LIKE :sid"; $parameters = array(":time_create" => date("Y-m-d"), ":sid" => "%" . $_GET["trg_sid"]); $result = getPDOParametrizedQueryResult($pdo, $query, $parameters, __FILE__, __LINE__); // find suitable admin for this report (his id) if (count($result) == 0) { $result = getPDOQueryResult($pdo, "SELECT id, name FROM `soe-csgo`.sb_admins WHERE active = 1", __FILE__, __LINE__); $admin_id = $result[array_rand($result)]["id"]; /* // first find admins with lowest number of finished reports $admins = getAdminsReports();