function info($sql, $comment = '', $onlyCounts = false) { global $opt_verbose; if ($opt_verbose) { if ($onlyCounts) { checkCount($sql, $comment); } else { check($sql, $comment); } } }
$type = 3; break; default: die(json_encode(array("status" => "fail"), 256)); } //=================================== Авторизация include '../mod_db.php'; include '../mod_auth.php'; if (!$user->isRegistered()) { die(json_encode(array("status" => "fail"), 256)); } //=================================== Описание функций function checkCount() { global $type, $object_id; $query = "SELECT COUNT(*) AS `complaint_count` FROM `complaint` WHERE `type` = {$type} AND `object_id` = {$object_id}"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); return $row["complaint_count"]; } //=================================== Основной код $object_id = $_POST["id"]; if (checkCount() == 0) { $uid = $user->uid; $query = "INSERT INTO `complaint`\n (`type`,\n `object_id`,\n `user_id`)\n VALUES\n ({$type},\n {$object_id},\n {$uid})"; $result = mysql_query($query); if (!$result) { die(json_encode(array("status" => "fail"), 256)); } } print json_encode(array("status" => "ok"), 256);
<?php echo date("Y-m-d") . "\n"; $count = 1; while (1) { echo "count:" . $count . "\n"; echo checkCount($count) . "\n"; if (!checkCount($count)) { break; } sleep(10); $count = $count + 1; } function checkCount($count) { if ($count < 5) { return true; } return false; }
$outputStr .= "<tr><td class='" . ($pass ? "OK" : "NG") . "'>{$text}</td></tr>\n"; if (!$pass) { $result = 0; } } checkVersion(); checkOrder("306-01", '$Path="/"', '$Domain="opera.com"'); checkNoAttribs("306-02"); checkNoPresence("306-03"); checkNoPresence("306-04"); checkOrder("306-05", '$Path="' . $path . '"', '$Domain=".opera.com"'); checkOrder('306-06', '$Domain="oPeRa.CoM"'); checkOrder('306-07', '$Path="/"'); checkOrder('306-08', '$Path="/"', '$Port="80"'); checkNoPresence("306-09"); checkCount(); echo "<p>" . ($result ? "PASS" : "FAIL") . "</p>\n"; echo "<table>\n{$outputStr}</table>\n"; ?> <style type="text/css"> .OK {background:green} .NG {background:red} #PHPValues {display:none} </style> <p id="PHPValues"><?php echo $_SERVER['HTTP_COOKIE']; ?> </p> <script type="text/javascript"> var php = document.getElementById("PHPValues").innerHTML; if (php.substr(0,9) == "$Version=") php = php.substr (php.indexOf(";") + 2);