server { server_name www.example.com; listen *:80; listen [::]:80 ipv6only=on; if ($uri !~* ^/downloads/(.+)$) { return 301 https://example.com/downloads/$1; } }
if
лучше использовать location.server {
server_name example.com www.example.com;
listen *:80;
listen [::]:80 ipv6only=on;
location / {
return 301 https://example.com$request_uri;
}
location /downloads/ {
root /var/www/html;
}
}
SELECT 'Active Action' as `type`, * FROM `table` WHERE `start_date` IS NULL OR (NOW() BETWEEN `start_date` AND `end_date`)
UNION
SELECT 'Upcoming Action' as `type`, * FROM `table` WHERE `start_date` > NOW();
<?php
#region DB Connection
$dbName = "test";
$dbHost = "127.0.0.1";
$dbUser = "root";
$dbPassword = "";
$dbCharset = 'UTF8';
$connection = new PDO("mysql:host={$dbHost};dbname={$dbName};charset={$dbCharset}", $dbUser, $dbPassword);
#endregion
#region Pagination
$limit = empty($_GET['limit']) ? 10 : ((int)$_GET['limit']);
$offset = empty($_GET['page']) ? 0 : (($_GET['page'] - 1) * $limit);
#endregion
#region GetTypes
$query = " SELECT
`id`,
`type`
FROM `type`";
$result = $connection
->query($query)
->fetchAll(PDO::FETCH_ASSOC);
$types = array_combine(array_column($result, 'id'), array_column($result, 'type'));
#endregion
#region GetVIIII
$query = " SELECT
`id`,
`added_date`,
`title`,
`type`
FROM `viiii`
ORDER BY `id`
LIMIT {$offset},{$limit}";
$result = $connection
->query($query)
->fetchAll(PDO::FETCH_ASSOC);
#region Render
$output = "<table>";
foreach ($result as $row){
$typeList = explode(',',$row['type']);
$typeList = array_intersect_key($types, array_flip($typeList));
$threatType = implode(", ", $typeList);
$output.=" <tr>
<td>{$row['added_date']}</td>
<td>{$row['title']}</td>
<td>{$threatType}</td>
</tr>";
}
$output.= "</table>";
echo $output;
#endregion
POST - An HTTP POST to a URL of your choosing with transaction details (in either an XML or CSV format)
GET - An HTTP GET to a URL of your choosing with transaction detail you define in the query string.
var rel_left = (ui.position.left - startLeft) / (width_joystick * 2);
var rel_top = -(ui.position.top - startTop) / (height_joystick * 2);
<div class="wellprod" data-id="42(уникальный идентификатор из БД)"></div>
$(document).on('dblclick', '.wellprod', function() {
$('.wellprod').removeClass('active_c');
$(this).addClass('active_c');
location.href = 'http://site.com/view.php?id=' + $(this).attr("data-id");
});
<?php
define('SECRET', 'tostersecretcode2015');
/**
* Создаёт серийный номер с заданной проверочной частью.
*
* @param string $check Часть серийного номера, используемая для проверки.
*
* @return bool
*/
function sernum ($check = null)
{
$template = 'XXX99-XXX99-99XXX-99XXX';
$parts = explode('-', $template, 2);
if (!isset($check)) {
$check = '';
for ($i = 0; $i < strlen($parts[0]); $i++) {
switch ($parts[0][$i]) {
case 'X': $check .= chr(rand(65, 90)); break;
case '9': $check .= strval(rand(0,9)); break;
}
}
}
$sernum = $check . '-';
$hash = hash('sha256', $check . SECRET);
for ($i = 0; $i < strlen($parts[1]); $i++) {
switch ($parts[1][$i]) {
case 'X': $sernum .= chr(65 + ord($hash[$i]) % 26); break;
case '9': $sernum .= strval(ord($hash[$i]) % 10); break;
case '-': $sernum .= '-'; break;
}
}
return $sernum;
}
/**
* Проверяет серийный номер.
*
* @return bool
*/
function check_sernum ($sernum)
{
$parts = explode('-', $sernum, 2);
return (sernum($parts[0]) === $sernum);
}
echo '<pre>Десять случайных номеров:<br>';
for ($i = 0; $i < 10; $i++)
echo sernum(), '<br/>';
if (check_sernum('XCC58-AYA68-75ZUU-19TDZ')) {
echo 'Номер XCC58-AYA68-75ZUU-19TDZ прошёл проверку<br>';
}
if (!check_sernum('ESJ18-TBZ25-42XDX-38XWY')) {
echo 'Номер ESJ18-TBZ25-42XDX-38XWY не прошёл проверку<br>';
}