PHP
5
Вклад в тег
function number_name($number)
{
$count = array("", "k", "M", "G", "T");
$i = 0;
while (abs($number) > 1000) {
$number /= 1000;
$i++;
}
return $number.$count[$i];
}
echo number_name(5)."\n";
echo number_name(5000)."\n";
echo number_name(-5000)."\n";
echo number_name(5000000)."\n";
echo number_name(5000000000)."\n";
echo number_name(5000000000000);
require_once "simple_html_dom.php";
error_reporting(E_ALL);
ini_set('display_errors', '1');
$conn = oci_connect('ddd', 'ddd', '127.0.0.1/orcl', 'AL32UTF8');
$brands = array();
$html = str_get_html(file_get_contents('https://kolesa.kz/cars/'));
$i = 'INSERT INTO kolesa_brands (id, name) VALUES';
$select = $html->find('select[id=auto-car-mm-0]', 0);
foreach($select->find('option') as $opt)
{
if($opt->value == '') continue;
$i .= ' ('.$opt->value.', \''.$opt->plaintext.'\'),';
$brands[$opt->value] = $opt->plaintext;
}
$insert = oci_parse($conn, rtrim($i, ',').';');
oci_execute($insert);
server {
listen *:80;
listen *:443 ssl;
server_name site.ru;
ssl_certificate sert.pem;
ssl_certificate_key sert.pem;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://site.ru/api/telegram/bot.php;
client_max_body_size 100M;
}
}
<?php
require_once "C:/OSPanel/domains/site.ru/vendor/autoload.php";
use Proxy\Proxy;
use Proxy\Adapter\Guzzle\GuzzleAdapter;
use Proxy\Filter\RemoveEncodingFilter;
use Zend\Diactoros\ServerRequestFactory;
// Create a PSR7 request based on the current browser request.
$request = ServerRequestFactory::fromGlobals();
// Create a guzzle client
$guzzle = new GuzzleHttp\Client();
// Create the proxy instance
$proxy = new Proxy(new GuzzleAdapter($guzzle));
// Add a response filter that removes the encoding headers.
$proxy->filter(new RemoveEncodingFilter());
// Forward the request and get the response.
$response = $proxy->forward($request)->to('https://site.ru/api/telegram/bot.php');
// Output response to the browser.
(new Zend\Diactoros\Response\SapiEmitter)->emit($response);
?>