<?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
CREATE TABLE IF NOT EXISTS `first` (
`name` varchar(50) CHARACTER SET utf8 NOT NULL,
`key` varchar(50) CHARACTER SET utf8 NOT NULL,
KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `second` (
`key` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`value` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `first` (`name`, `key`) VALUES
('color', 'green'),
('color', 'red'),
('color', 'blue');
INSERT INTO `second` (`key`, `value`) VALUES
('green', 'apple'),
('red', 'cherry'),
('blue', 'sky');
SELECT
CONCAT(f.`name`,':',s.value) AS result,
FROM `first` AS f
INNER JOIN `second` AS s ON s.`key` = f.`key`;
function searchKey($keyName, $sourceArray) {
if (!(is_string($keyName) || is_numeric($keyName)) || !isset($sourceArray[$keyName])) {
return null;
}
$keys = array_keys($sourceArray);
$nextScenario = @$keys[array_search($keyName, $keys) + 1];
return $nextScenario;
}
/**
* @property string $key;
* @property string $foreign_key;
* @property string $repository;
*/
class Helper {
private $data;
public function __construct($data) {
$this->data = $data;
}
public function __set($name, $value) {
$this->data[$name] = $value;
}
public function __get($name) {
return isset($this->data[$name]) ? $this->data[$name] : null;
}
}
$test = new Helper(array(
'key'=>12,
'foreign_key'=>'id',
'repository'=>'',
));
echo $test->key;
$test->key = '23';
echo $test->key;
class C1 {
public $name;
}
class C2 {
public $age;
}
class Helper {
/**
* @var C1|C2
*/
public static $app;
}
Helper::$app->age
<html><body>
<?php
header('Location: '.$url);
die();
<?php
echo "123";
header('Location: '.$url);
die();
{ПРОБЕЛ, ТАБУЛЯЦИЯ ИЛИ ДРУГОЙ СИМВОЛ}<?php
header('Location: '.$url);
die();
<Files ~ "\.(tpl|php)$">
deny from all
</Files>
<Files ~ "(login|index)\.(php)$">
allow from all
</Files>
<Files ~ "\/xml_rpc\/server\.php">
allow from all
</Files>