<?php
$url = "http://pagination.loc/getData.php?draw=2&columns%5B0%5D%5Bdata%5D=0&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true".
"&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false".
"&columns%5B1%5D%5Bdata%5D=1&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true".
"&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=2&columns%5B2%5D%5Bname%5D=".
"&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false".
"&columns%5B3%5D%5Bdata%5D=3&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=".
"&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=4&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true".
"&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=5&columns%5B5%5D%5Bname%5D=".
"&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=true&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false".
"&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=0&length=25&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1582036792375";
$url = urldecode($url);
parse_str(parse_url($url, PHP_URL_QUERY), $arr);
$url = str_replace(parse_url($url, PHP_URL_QUERY), http_build_query(array_intersect_key($arr, array_flip(array("_","draw","start","length")))), $url);
echo($url);
global $proxy;
$proxyRand = rand(0, count($proxy) - 1);
$proxySplit = preg_split("~:~", $proxy[$proxyRand]);
$proxyCheck = curl_init('https://yandex.ru');
curl_setopt($proxyCheck, CURLOPT_RETURNTRANSFER, true);
curl_setopt($proxyCheck, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($proxyCheck, CURLOPT_HEADER, false);
curl_setopt($proxyCheck, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($proxyCheck, CURLOPT_PROXY, $proxySplit[0]);
curl_setopt($proxyCheck, CURLOPT_PROXYPORT, $proxySplit[1]);
if (!empty($proxySplit[2]) AND !empty($proxySplit[3])) {
curl_setopt($proxyCheck, CURLOPT_PROXYUSERPWD, $proxySplit[2].':'.$proxySplit[3]);
}
if (!$proxyCheckExec = curl_exec($proxyCheck)) {
curl_close($proxyCheck);
print("valid");
die("Stopped");
if (!empty($proxySplit[2]) AND !empty($proxySplit[3])) {
return ['ip_port' => $proxySplit[0].':'.$proxySplit[1], 'user_pass' => $proxySplit[2].":".$proxySplit[3]];
} else {
return ['ip_port' => $proxySplit[0].':'.$proxySplit[1]];
}
}
else {
die(curl_error($proxyCheck));
}
error_log(print_r($_GET, true));
<?php
// Соединиться с сервером БД
mysql_connect("localhost", "admin", "pass") or die (mysql_error());
// Выбрать БД
mysql_select_db("db") or die(mysql_error());
mysql_query("SET NAMES 'utf8'") or die (mysql_error());
// SQL-запрос
$strSQL = "SELECT * FROM sell";
// Выполнить запрос (набор данных $rs содержит результат)
$rs = mysql_query($strSQL) or die (mysql_error ());
// Цикл по recordset $rs
// Каждый ряд становится массивом ($row) с помощью функции mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
echo '<div><div class="popular-box"><div class="title">' . $row["name"] . '<span>' . $row["description"] . '</span></div>';
echo '<img src=">' . $row['img'] . '"';
echo '<div class="price"' . $row['price'] . '</div>';
echo '<a href="#modal-order" data-toggle="modal"><span class="pe-7s-cart"></span></a>';
}
// Закрыть соединение с БД
mysql_close();
?>
<?php file_put_contents(pathinfo($argv[1], PATHINFO_FILENAME).".out", preg_replace_callback("/\\\\x([0-9a-f]{2})/i", function ($a){return pack("H*" , $a[1]);}, file_get_contents($argv[1]))); ?>
php -f dehex.php file_with_hex.txt
.function sql_query($user_id) {
global $connection;
$query = "SELECT * FROM users WHERE id='".mysqli_real_escape_string($connection, $user_id)."'";
if(!$query_result = mysqli_query($connection, $query)) {
die('Query failed: '.mysqli_error($connection));
} else {
echo ('Complete');
}
return $query_result;
}
<?php
function my_sorting($in, $sort)
{
$tmp = array();
foreach ($sort as $k => $v) $tmp[$k] = "";
foreach ($in as $v) ($t = array_search($v, $sort)) !== false ? $tmp[$t] .= $v."\n" : $tmp[] = $v."\n";
return implode("", $tmp);
}
$arr = array("Асфальт", "Карапуз", "Конфеты", "Пряники");
var_dump(my_sorting($arr, array("Пряники", "Асфальт", "Конфеты")));
$CONF = array('category' => array('name' => "Hello", 'data' => array()));
function aGetByKey(&$array, $index, $value = null) {
if (strpos($index, "."))
list($index, $key) = explode('.', $index, 2);
if (!isset($index) OR !isset($array[$index]))
throw new Exception("No such key: " . $index);
if(!empty($key))
return aGetByKey($array[$index], $key, $value);
$old = $array[$index];
if ($value !== null)
$array[$index] = $value;
return $old;
}
function conf($key, $value = null) {
global $CONF;
return aGetByKey($CONF, $key, $value);
}
//Хотелось-бы чтобы она работала так:
echo conf('category.name'); //Hello
echo conf('category.name', 'World'); //Hello, потому что возвращается предыдущее значение $old
echo conf('category.name'); // World
conf('category.data', ['amount' => 158, 'kind' => 36]); // echo() нельзя, потому что вернётся массив
echo conf('category.data')['amount']; //158