<?php function http_status_string($status) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); } function http_status($status) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); http_response_code($status); } function http_get_full_url($url) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); if (empty($url) || mb_substr($url, 0, 1) === '?') { $url = $_SERVER['PHP_SELF'].$url; } return $url; } function file_get_contents_utf8($url) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); $content = http_get_contents($url); if (!$content || $content[0] != 200) { return false; } return $content[2]; } function http_get_contents($url, array $headers = array()) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, false); $response = curl_exec($ch); if (curl_errno($ch)) { curl_close($ch); return false; } $info = curl_getinfo($ch); curl_close($ch); if ($info['http_code'] != 200) { return false; } // $response = http_parse_response($response); // $response = http_response_to_utf8($response); return $response; } function http_parse_response($response) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); if (mb_strlen($response, '8bit') > 500000) { return array(404, array(), ''); } preg_match('/^(.*?)\r\n\r\n(.*)$/su', $response, $matches); $response_headers = $matches[1]; $response_body = $matches[2]; $response_header_lines = preg_split('/\r?\n/su', $response_headers); $http_response_line = array_shift($response_header_lines); if (preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@u', $http_response_line, $matches)) { $response_code = $matches[1]; } else { $response_code = 'Error'; } $response_header_array = array(); foreach ($response_header_lines as $header_line) { list($header, $value) = explode(': ', $header_line, 2); $response_header_array[$header] = $value; } return array($response_code, $response_header_array, $response_body); } function http_response_to_utf8($response) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); if (!isset($response[1]['Content-Type'])) { return $response; } if (!preg_match('/charset=([a-zA-Z0-9-_]+)/iu', $response[1]['Content-Type'], $matches)) { return $response; } $charset = mb_strtoupper($matches[1]); if (in_array($charset, array('WINDOWS-1251', 'KOI8-R', 'ISO-8859-1'))) { $response[2] = iconv($charset, 'UTF-8', $response[2]); } return $response; }
trigger_error("Function "http_status" is deprecated.")
<?php function http_status_string($status) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); } function http_status($status) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); http_response_code($status); } function http_get_full_url($url) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); if (empty($url) || mb_substr($url, 0, 1) === '?') { $url = $_SERVER['PHP_SELF'].$url; } return $url; } function file_get_contents_utf8($url) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); $content = http_get_contents($url); if (!$content || $content[0] != 200) { return false; } return $content[2]; } function http_get_contents($url, array $headers = array()) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POST, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, false); $response = curl_exec($ch); if (curl_errno($ch)) { curl_close($ch); return false; } $info = curl_getinfo($ch); curl_close($ch); if ($info['http_code'] != 200) { return false; } // $response = http_parse_response($response); // $response = http_response_to_utf8($response); return $response; } function http_parse_response($response) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); if (mb_strlen($response, '8bit') > 500000) { return array(404, array(), ''); } preg_match('/^(.*?)\r\n\r\n(.*)$/su', $response, $matches); $response_headers = $matches[1]; $response_body = $matches[2]; $response_header_lines = preg_split('/\r?\n/su', $response_headers); $http_response_line = array_shift($response_header_lines); if (preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@u', $http_response_line, $matches)) { $response_code = $matches[1]; } else { $response_code = 'Error'; } $response_header_array = array(); foreach ($response_header_lines as $header_line) { list($header, $value) = explode(': ', $header_line, 2); $response_header_array[$header] = $value; } return array($response_code, $response_header_array, $response_body); } function http_response_to_utf8($response) { trigger_error(sprintf('Function "%s" is deprecated.', __FUNCTION__), E_USER_DEPRECATED); if (!isset($response[1]['Content-Type'])) { return $response; } if (!preg_match('/charset=([a-zA-Z0-9-_]+)/iu', $response[1]['Content-Type'], $matches)) { return $response; } $charset = mb_strtoupper($matches[1]); if (in_array($charset, array('WINDOWS-1251', 'KOI8-R', 'ISO-8859-1'))) { $response[2] = iconv($charset, 'UTF-8', $response[2]); } return $response; }
http_status()
<?php // Клик по баннеру define('BOOTSTRAP', 'Site'); require_once dirname(__FILE__).'/index.php'; $Banners = COBJ_TypesType::create('Banners'); $banner = $Banners->id(@$_GET['id'])->getRow(); if (!$banner || !$banner['url']) { http_status(404); exit; } // TODO Проверить есть ли баннер в списке активных // // Счётчик кликов $Banners->click($banner['id']); // Перенаправление на реальный адрес http_location($banner['url']);