function __construct() { if (!$this->checkIsUser()) { Routes::redirect(); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $params = array(); $params['secret'] = '6Lf3ZxMTAAAAANVc5p92ISpeXZp8oTTrOr5WS6iD'; // Secret key if (!empty($_POST) && isset($_POST['g-recaptcha-response'])) { $params['response'] = urlencode($_POST['g-recaptcha-response']); } $params['remoteip'] = $_SERVER['REMOTE_ADDR']; $params_string = http_build_query($params); $requestURL = 'https://www.google.com/recaptcha/api/siteverify?' . $params_string; $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $requestURL)); $response = curl_exec($curl); curl_close($curl); $response = @json_decode($response, true); if ($response["success"] != true && !$this->checkIsUser()) { echo '<h3 class="alert alert-danger">Captcha - bład w weryfikacji</h3>'; } elseif ($response["success"] || self::$isLogged) { if ($this->addPost($_POST)) { header('Location: ' . parent::config()['url']); } } } else { $this->setPostModel(); } }
private function deleteContact($recordId) { if (is_int((int) $recordId)) { $db = Index::DB(); $query = $db->prepare("DELETE FROM address_book WHERE id = ?"); $result = $query->execute([$recordId]); if ($result) { header("Location: " . Index::config()['url'] . 'address-book'); } else { self::$data['error'] = 'Błąd przy usuwaniu kontaktu.'; } } }
public static function redirect() { header('Location: ' . Index::config()['url']); }