コード例 #1
0
ファイル: Misc.class.php プロジェクト: glowdemon1/LinkadeptV2
 public static function verifyCaptcha()
 {
     if (!($captcha = $_POST['g-recaptcha-response'])) {
         $errors['error'] = true;
         return $errors;
     }
     $secret = \Linkadept\LocalData::getReCaptchaSecret();
     $response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']), true);
     $errors['error'] = !$response['success'];
     return $errors;
 }
コード例 #2
0
ファイル: httpError.php プロジェクト: glowdemon1/LinkadeptV2
<?php

require_once 'vendor/autoload.php';
$title = 'Group and shorten links with Linkadept.com';
$announcement = \Linkadept\LocalData::getAnnouncement();
$stylesheet = 'error.css';
$popularLinks = \Linkadept\Misc::getPopularLinks();
$pageVars = array('title' => $title, 'announcement' => $announcement, 'stylesheet' => $stylesheet, 'popularLinks' => $popularLinks);
//Set up Twig Templating Engine
$loader = new Twig_Loader_Filesystem('views');
$twig = new Twig_Environment($loader, array('cache' => 'views/cache', 'debug' => true));
//Define error messages
$httpErrorMessages = array(0 => 'Something went wrong, please re-try and contact us if this persists.', 403 => 'You\'re not allowed access to this page.', 404 => 'The page you requested was not found.', 500 => 'Server error, please re-try or wait.');
//Define default values
$httpErrorCode = 0;
$httpErrorMessage = $httpErrorMessages[0];
if (isset($_GET['httpError'])) {
    $httpErrorCode = $_GET['httpError'];
}
if (isset($httpErrorMessages[$httpErrorCode])) {
    $httpErrorMessage = $httpErrorMessages[$httpErrorCode];
}
$error = array('error' => $httpErrorCode, 'errorMessage' => $httpErrorMessage);
echo $twig->render('View.httpError.html', ['pageVars' => $pageVars, 'error' => $error]);