}
                         ///
                         ///End Blog Searching API
                         ///
                     } else {
                         $json_array['success'] = false;
                         $json_array['message'][] = "No endpoint found with that name";
                     }
                 }
             } else {
                 $json_array['success'] = false;
                 $json_array['message'][] = "Please specify API endpoint";
             }
         } else {
             if ($api_user == "guest") {
                 checkIfCookieExists($json_array, true);
                 $json_array['success'] = false;
                 $json_array['message'][] = "Reset API key";
             } else {
                 $json_array['success'] = false;
                 $json_array['message'][] = "Supplied API key has been disabled";
             }
         }
     } else {
         $json_array['success'] = false;
         $json_array['message'][] = "API Key not found";
     }
     mysqli_close($GLOBALS['conn']);
     $GLOBALS['conn'] = null;
 } else {
     $json_array['success'] = false;
Exemple #2
0
ob_start();
session_start();
$max_session_time = 36000;
$cmp_pass = array();
$cmp_pass[] = md5($pulse_pass);
$max_attempts = 10;
$session_expires = $_SESSION["mpass_session_expires"];
$max_attempts++;
function checkIfCookieExists()
{
    if (isset($_COOKIE["mpass_pass"])) {
        $_SESSION["mpass_pass"] = $_COOKIE['mpass_pass'];
    }
}
checkIfCookieExists();
if (!empty($_POST["mpass_pass"])) {
    if (in_array(md5($_POST["mpass_pass"]), $cmp_pass)) {
        $_SESSION["mpass_pass"] = md5($_POST["mpass_pass"]);
        setcookie("mpass_pass", md5($_POST["mpass_pass"]), time() + 3600 * 24 * 7, '/');
        header("Location: index.php");
    }
}
if (empty($_SESSION["mpass_attempts"])) {
    $_SESSION["mpass_attempts"] = 0;
}
if ($max_session_time > 0 && !empty($session_expires) && time() > $session_expires || empty($_SESSION["mpass_pass"]) || !in_array($_SESSION["mpass_pass"], $cmp_pass)) {
    if (!in_array($_SESSION["mpass_pass"], $cmp_pass)) {
        $_SESSION["mpass_attempts"]++;
    }
    if ($max_attempts > 1 && $_SESSION["mpass_attempts"] >= $max_attempts) {