Fixed database access in Satori scripts.

This commit is contained in:
flash 2023-07-12 17:17:44 +00:00
parent d34bf5a4af
commit 5a5915c707
9 changed files with 250 additions and 383 deletions

View file

@ -1,39 +1,25 @@
<?php <?php
$config = parse_ini_file(__DIR__ . '/../config/flashii.ini'); $config = parse_ini_file(__DIR__ . '/../config/flashii.ini');
require_once $config['msz-path'] . '/lib/index/index.php';
define('STR_CONFIG', $config['msz-config-path']);
header('Content-Type: application/json; charset=utf-8'); header('Content-Type: application/json; charset=utf-8');
if(!is_file(STR_CONFIG)) { if(!is_file($config['msz-config-path'])) {
echo '{"error":101}'; echo '{"error":101}';
exit; exit;
} }
$config = parse_ini_file(STR_CONFIG); $config = parse_ini_file($config['msz-config-path']);
if(empty($config['driver']) || empty($config['unix_socket']) if(empty($config['dsn'])) {
|| empty($config['username']) || empty($config['database'])) {
echo '{"error":102}'; echo '{"error":102}';
exit; exit;
} }
if(empty($config['password']))
$config['password'] = '';
if(empty($config['charset']))
$config['charset'] = 'utf8mb4';
try { try {
$db = new PDO("{$config['driver']}:unix_socket={$config['unix_socket']};charset={$config['charset']};dbname={$config['database']}", $config['username'], $config['password'], [ $db = \Index\Data\DbTools::create($config['dsn']);
PDO::ATTR_CASE => PDO::CASE_NATURAL, $db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, } catch(Exception $ex) {
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, echo json_encode(['error' => 103, 'msg' => $ex->getMessage()]);
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET SESSION time_zone = \'+00:00\''
. ', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\'',
]);
} catch(PDOException $ex) {
echo '{"error":103}';
exit; exit;
} }

View file

@ -1,72 +0,0 @@
<?php
require_once '_flashii.php';
ini_set('display_errors', 'on');
error_reporting(-1);
header('Content-Type: text/plain; charset=utf-8');
printf('dataSetVersion = "%s";%s', date('Y-m-d'), PHP_EOL);
printf('dataSet[dataSetVersion] = {};%s', PHP_EOL);
echo PHP_EOL;
printf('dataSet[dataSetVersion].options = [%s', PHP_EOL);
printf(' {%s', PHP_EOL);
printf(' name: "Filter by Role",%s', PHP_EOL);
printf(' key: "role",%s', PHP_EOL);
printf(' tooltip: "Check this to restrict to certain roles",%s', PHP_EOL);
printf(' checked: false,%s', PHP_EOL);
printf(' sub: [%s', PHP_EOL);
$getRoles = $db->prepare('SELECT `role_id`, `role_name` FROM `msz_roles` WHERE `role_hidden` = 0 ORDER BY `role_id` ASC');
$getRoles->execute();
while(($role = $getRoles->fetch()) !== false)
printf(' { name: "%s", key: "R%d" },%s', $role[1], $role[0], PHP_EOL);
printf(' ],%s', PHP_EOL);
printf(' },%s', PHP_EOL);
printf(' {%s', PHP_EOL);
printf(' name: "Remove inactive members",%s', PHP_EOL);
printf(' key: "inactive",%s', PHP_EOL);
printf(' tooltip: "Limits the selection to people who have showed up within the last year.",%s', PHP_EOL);
printf(' },%s', PHP_EOL);
printf(' {%s', PHP_EOL);
printf(' name: "Remove members with no posts",%s', PHP_EOL);
printf(' key: "noposts",%s', PHP_EOL);
printf(' tooltip: "Removes members that have not made any forum posts yet.",%s', PHP_EOL);
printf(' },%s', PHP_EOL);
printf('];%s', PHP_EOL);
echo PHP_EOL;
printf('dataSet[dataSetVersion].characterData = [%s', PHP_EOL);
$getUsers = $db->prepare('SELECT `user_id`, `username`, `user_active` > NOW() - INTERVAL 1 YEAR AS `user_active`, (SELECT COUNT(*) FROM `msz_forum_posts` WHERE `user_id` = u.`user_id` AND `post_deleted` IS NULL) AS `user_posts` FROM `msz_users` AS u WHERE `user_deleted` IS NULL ORDER BY `user_id` ASC');
$getUsers->execute();
while(($user = $getUsers->fetch()) !== false) {
printf(' {%s', PHP_EOL);
printf(' name: "%s",%s', $user[1], PHP_EOL);
printf(' img: "https://flashii.net/assets/avatar/%d?res=300",%s', $user[0], PHP_EOL);
printf(' opts: {%s', PHP_EOL);
printf(' role: [', PHP_EOL);
$getRoles = $db->prepare('SELECT `role_id` FROM `msz_user_roles` WHERE `user_id` = :user');
$getRoles->bindValue('user', $user[0]);
$getRoles->execute();
while(($role = $getRoles->fetchColumn()) !== false)
printf(' "R%d", ', $role);
printf('],%s', PHP_EOL);
if(!$user[2])
printf(' inactive: true,%s', PHP_EOL);
if($user[3] < 1)
printf(' noposts: true,%s', PHP_EOL);
printf(' },%s', PHP_EOL);
printf(' },%s', PHP_EOL);
}
printf('];%s', PHP_EOL);

View file

@ -1,20 +1,11 @@
<?php <?php
$config = parse_ini_file(__DIR__ . '/../config/flashii.ini'); $config = parse_ini_file(__DIR__ . '/../config/flashii.ini');
require_once $config['msz-path'] . '/lib/index/index.php';
try { try {
$pdo = new PDO($config['exrate-dsn'], $config['exrate-user'], $config['exrate-pass'], [ $db = \Index\Data\DbTools::create($config['exrate-dsn2']);
PDO::ATTR_CASE => PDO::CASE_NATURAL, $db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, } catch(Exception $ex) {
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => "
SET SESSION
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION',
time_zone = '+00:00';
",
]);
} catch(PDOException $ex) {
die((string)$ex); die((string)$ex);
} }
@ -23,8 +14,8 @@ define('EXRATE_COMMON', [
'EUR', 'AUD', 'GBP', 'CAD', 'USD', 'JPY', 'PLN', 'SGD', 'RUB', 'ILS', 'EUR', 'AUD', 'GBP', 'CAD', 'USD', 'JPY', 'PLN', 'SGD', 'RUB', 'ILS',
]); ]);
$from = strtoupper((string)filter_input(INPUT_GET, 'from', FILTER_SANITIZE_STRING)); $from = strtoupper((string)filter_input(INPUT_GET, 'from'));
$to = strtoupper((string)filter_input(INPUT_GET, 'to', FILTER_SANITIZE_STRING)); $to = strtoupper((string)filter_input(INPUT_GET, 'to'));
$amount = (string)(filter_input(INPUT_GET, 'amount', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) ?? '1'); $amount = (string)(filter_input(INPUT_GET, 'amount', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) ?? '1');
if((!empty($to) && strlen($to) !== 3) || strlen($from) !== 3) { if((!empty($to) && strlen($to) !== 3) || strlen($from) !== 3) {
@ -32,17 +23,20 @@ if((!empty($to) && strlen($to) !== 3) || strlen($from) !== 3) {
die('Invalid currency specified.'); die('Invalid currency specified.');
} }
$needsRefresh = $pdo->prepare('SELECT MAX(`rate_stored`) <= NOW() - INTERVAL 1 DAY FROM `exchange-rates` LIMIT 1'); $needsRefresh = $db->query('SELECT MAX(rate_stored) > NOW() - INTERVAL 1 DAY FROM `exchange-rates` LIMIT 1');
$needsRefresh = $needsRefresh->execute() ? $needsRefresh->fetchColumn() : 1; $needsRefresh->next();
if($needsRefresh !== 0) { $needsRefresh = $needsRefresh->isNull(0) || $needsRefresh->getInteger(0) < 1;
if($needsRefresh) {
$data = json_decode(file_get_contents('https://api.exchangerate.host/latest?base=' . EXRATE_INTER), true); $data = json_decode(file_get_contents('https://api.exchangerate.host/latest?base=' . EXRATE_INTER), true);
if($data !== null) { if($data !== null) {
$pdo->exec('TRUNCATE `exchange-rates`;'); $db->execute('TRUNCATE `exchange-rates`');
$insertCurrency = $pdo->prepare('REPLACE INTO `exchange-rates` (`rate_from`, `rate_to`, `rate_value`) VALUES (:from, :to, :value)'); $insertCurrency = $db->prepare('INSERT INTO `exchange-rates` (rate_from, rate_to, rate_value) VALUES (?, ?, ?)');
$insertCurrency->bindValue('from', $data['base']);
foreach($data['rates'] as $currency => $rate) { foreach($data['rates'] as $currency => $rate) {
$insertCurrency->bindValue('to', $currency); $insertCurrency->reset();
$insertCurrency->bindValue('value', $rate); $insertCurrency->addParameter(1, $data['base']);
$insertCurrency->addParameter(2, $currency);
$insertCurrency->addParameter(3, $rate);
$insertCurrency->execute(); $insertCurrency->execute();
} }
} }
@ -56,25 +50,41 @@ $result->amount = (float)$amount;
if($from === $to) { if($from === $to) {
$result->result = $result->amount; $result->result = $result->amount;
} else { } else {
$convertCurrency = $pdo->prepare('SELECT (SELECT (:amount / `rate_value`) FROM `exchange-rates` WHERE `rate_from` = \'' . EXRATE_INTER . '\' AND `rate_to` = :from) * `rate_value` FROM `exchange-rates` WHERE `rate_from` = \'' . EXRATE_INTER . '\' AND `rate_to` = :to;'); $convertCurrency = $db->prepare(sprintf(
$convertCurrency->bindValue('from', $from); 'SELECT (SELECT (? / rate_value) FROM `exchange-rates` WHERE rate_from = "%1$s" AND rate_to = ?) * rate_value FROM `exchange-rates` WHERE rate_from = "%1$s" AND rate_to = ?',
$convertCurrency->bindValue('amount', $amount); EXRATE_INTER
));
if(empty($to)) { if(empty($to)) {
$result->results = []; $result->results = [];
foreach(EXRATE_COMMON as $commonCurrency) { foreach(EXRATE_COMMON as $commonCurrency) {
if($commonCurrency === $from) if($commonCurrency === $from)
continue; continue;
$result->results[] = $current = new stdClass; $result->results[] = $current = new stdClass;
$current->to = $commonCurrency; $current->to = $commonCurrency;
$convertCurrency->bindValue('to', $commonCurrency);
$convertCurrency->reset();
$convertCurrency->addParameter(1, $amount);
$convertCurrency->addParameter(2, $from);
$convertCurrency->addParameter(3, $commonCurrency);
$convertCurrency->execute(); $convertCurrency->execute();
$current->result = $convertCurrency->fetchColumn() ?? 0;
$convertResult = $convertCurrency->getResult();
$convertResult->next();
$current->result = $convertResult->getFloat(0);
} }
} else { } else {
$convertCurrency->bindValue('to', $to); $convertCurrency->addParameter(1, $amount);
$convertCurrency->addParameter(2, $from);
$convertCurrency->addParameter(3, $to);
$convertCurrency->execute(); $convertCurrency->execute();
$result->result = $convertCurrency->fetchColumn() ?? 0;
$convertResult = $convertCurrency->getResult();
$convertResult->next();
$result->result = $convertResult->getFloat(0);
} }
} }

View file

@ -5,16 +5,15 @@ $userId = (int)filter_input(INPUT_GET, 'user', FILTER_SANITIZE_NUMBER_INT);
$fieldId = (int)filter_input(INPUT_GET, 'field', FILTER_SANITIZE_NUMBER_INT); $fieldId = (int)filter_input(INPUT_GET, 'field', FILTER_SANITIZE_NUMBER_INT);
try { try {
$fetch = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = :field AND `user_id` = :user'); $fetch = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = ? AND `user_id` = ?');
$fetch->bindValue('user', $userId); $fetch->addParameter(1, $fieldId);
$fetch->bindValue('field', $fieldId); $fetch->addParameter(2, $userId);
$fetch->execute(); $fetch->execute();
$data = $fetch->fetchObject(); $result = $fetch->getResult();
if($data)
echo json_encode($data); if($result->next())
else { echo json_encode(['field_value' => $result->getString(0)]);
echo '{"error":105}'; else echo '{"error":105}';
} } catch(Exception $ex) {
} catch(PDOException $ex) { echo json_encode(['error' => 104, 'msg' => $ex->getMessage()]);
echo '{"error":104}';
} }

View file

@ -1,52 +0,0 @@
<?php
$config = parse_ini_file(__DIR__ . '/../config/flashii.ini');
header('Content-Type: text/plain; charset=us-ascii');
$name = (string)filter_input(INPUT_GET, 'name', FILTER_SANITIZE_STRING);
if(empty($name))
die('-1');
$config = parse_ini_file($config['msz-config-path'], true, INI_SCANNER_TYPED);
if(empty($config))
die('-2');
$info = $config['Database'];
if(empty($config))
die('-2');
$dsn = 'mysql:';
if ($info['unix_socket'] ?? false) {
$dsn .= 'unix_socket=' . $info['unix_socket'] . ';';
} else {
$dsn .= 'host=' . ($info['host'] ?? '127.0.0.1') . ';';
$dsn .= 'port=' . intval($info['port'] ?? 3306) . ';';
}
$dsn .= 'charset=' . ($info['charset'] ?? 'utf8mb4') . ';';
$dsn .= 'dbname=' . ($info['database'] ?? 'misuzu') . ';';
try {
$flashii = new PDO($dsn, ($info['username'] ?? null), ($info['password'] ?? null), [
PDO::ATTR_CASE => PDO::CASE_NATURAL,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => "
SET SESSION
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION',
time_zone = '+00:00';
"
]);
} catch(PDOException $ex) {
die('-3');
}
$userId = $flashii->prepare('SELECT `user_id` FROM `msz_users` WHERE LOWER(`username`) = :username OR LOWER(`email`) = :email');
$userId->bindValue('username', $name);
$userId->bindValue('email', $name);
$userId->execute();
echo (int)$userId->fetchColumn();

View file

@ -1,65 +0,0 @@
<?php
$config = parse_ini_file(__DIR__ . '/../config/flashii.ini');
header('Content-Type: text/plain; charset=us-ascii');
$ids = filter_input(INPUT_GET, 'ids', FILTER_SANITIZE_STRING);
if(empty($ids))
die('-3:no ids');
$ids = explode(',', $ids);
if(count($ids) > 100)
die('-6:too many');
foreach($ids as $k => $id) {
$_id = intval($id);
if($id != $_id)
die('-4:format');
$ids[$k] = $_id;
}
$config = parse_ini_file($config['msz-config-path'], true, INI_SCANNER_TYPED);
if(empty($config))
die('-1:config gone');
$info = $config['Database'];
if(empty($config))
die('-2:config gone');
$dsn = 'mysql:';
if ($info['unix_socket'] ?? false) {
$dsn .= 'unix_socket=' . $info['unix_socket'] . ';';
} else {
$dsn .= 'host=' . ($info['host'] ?? '127.0.0.1') . ';';
$dsn .= 'port=' . intval($info['port'] ?? 3306) . ';';
}
$dsn .= 'charset=' . ($info['charset'] ?? 'utf8mb4') . ';';
$dsn .= 'dbname=' . ($info['database'] ?? 'misuzu') . ';';
try {
$flashii = new PDO($dsn, ($info['username'] ?? null), ($info['password'] ?? null), [
PDO::ATTR_CASE => PDO::CASE_NATURAL,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,
PDO::ATTR_STRINGIFY_FETCHES => false,
PDO::ATTR_EMULATE_PREPARES => false,
PDO::MYSQL_ATTR_INIT_COMMAND => "
SET SESSION
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION',
time_zone = '+00:00';
"
]);
} catch(PDOException $ex) {
die('-5:db gone');
}
$rows = $flashii->query('SELECT `user_id`, `username` FROM `msz_users` WHERE `user_id` IN (' . implode(',', $ids) . ')')->fetchAll(PDO::FETCH_ASSOC);
$out = '';
foreach($rows as $row)
$out .= "{$row['user_id']}:{$row['username']};";
echo substr($out, 0, -1);

View file

@ -9,429 +9,469 @@ $separator = "\r\n\r\nHOjGbeCdZHrVVFz3lBD0cIMGw2hPmkw4\r\n\r\n";
<h1>msz_changelog_changes -> change_log</h1> <h1>msz_changelog_changes -> change_log</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `change_log` FROM `msz_changelog_changes`'); $getShit = $db->query('SELECT `change_log` FROM `msz_changelog_changes`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_changelog_changes -> change_text</h1> <h1>msz_changelog_changes -> change_text</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `change_text` FROM `msz_changelog_changes`'); $getShit = $db->query('SELECT `change_text` FROM `msz_changelog_changes`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_changelog_tags -> tag_name</h1> <h1>msz_changelog_tags -> tag_name</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `tag_name` FROM `msz_changelog_tags`'); $getShit = $db->query('SELECT `tag_name` FROM `msz_changelog_tags`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_changelog_tags -> tag_description</h1> <h1>msz_changelog_tags -> tag_description</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `tag_description` FROM `msz_changelog_tags`'); $getShit = $db->query('SELECT `tag_description` FROM `msz_changelog_tags`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_comments_posts -> comment_text</h1> <h1>msz_comments_posts -> comment_text</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `comment_text` FROM `msz_comments_posts`'); $getShit = $db->query('SELECT `comment_text` FROM `msz_comments_posts`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_forum_categories -> forum_name</h1> <h1>msz_forum_categories -> forum_name</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `forum_name` FROM `msz_forum_categories`'); $getShit = $db->query('SELECT `forum_name` FROM `msz_forum_categories`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_forum_categories -> forum_description</h1> <h1>msz_forum_categories -> forum_description</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `forum_description` FROM `msz_forum_categories`'); $getShit = $db->query('SELECT `forum_description` FROM `msz_forum_categories`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_forum_posts -> post_text</h1> <h1>msz_forum_posts -> post_text</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `post_text` FROM `msz_forum_posts`'); $getShit = $db->query('SELECT `post_text` FROM `msz_forum_posts`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_forum_topics -> topic_title</h1> <h1>msz_forum_topics -> topic_title</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `topic_title` FROM `msz_forum_topics`'); $getShit = $db->query('SELECT `topic_title` FROM `msz_forum_topics`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_news_categories -> category_name</h1> <h1>msz_news_categories -> category_name</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `category_name` FROM `msz_news_categories`'); $getShit = $db->query('SELECT `category_name` FROM `msz_news_categories`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_news_categories -> category_description</h1> <h1>msz_news_categories -> category_description</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `category_description` FROM `msz_news_categories`'); $getShit = $db->query('SELECT `category_description` FROM `msz_news_categories`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_news_posts -> post_title</h1> <h1>msz_news_posts -> post_title</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `post_title` FROM `msz_news_posts`'); $getShit = $db->query('SELECT `post_title` FROM `msz_news_posts`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_news_posts -> post_text</h1> <h1>msz_news_posts -> post_text</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `post_text` FROM `msz_news_posts`'); $getShit = $db->query('SELECT `post_text` FROM `msz_news_posts`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_roles -> role_name</h1> <h1>msz_roles -> role_name</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `role_name` FROM `msz_roles`'); $getShit = $db->query('SELECT `role_name` FROM `msz_roles`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_roles -> role_title</h1> <h1>msz_roles -> role_title</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `role_title` FROM `msz_roles`'); $getShit = $db->query('SELECT `role_title` FROM `msz_roles`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_roles -> role_description</h1> <h1>msz_roles -> role_description</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `role_description` FROM `msz_roles`'); $getShit = $db->query('SELECT `role_description` FROM `msz_roles`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_users -> username</h1> <h1>msz_users -> username</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `username` FROM `msz_users`'); $getShit = $db->query('SELECT `username` FROM `msz_users`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_users -> user_about_content</h1> <h1>msz_users -> user_about_content</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `user_about_content` FROM `msz_users`'); $getShit = $db->query('SELECT `user_about_content` FROM `msz_users`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_users -> user_signature_content</h1> <h1>msz_users -> user_signature_content</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `user_signature_content` FROM `msz_users`'); $getShit = $db->query('SELECT `user_signature_content` FROM `msz_users`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_users -> user_title</h1> <h1>msz_users -> user_title</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `user_title` FROM `msz_users`'); $getShit = $db->query('SELECT `user_title` FROM `msz_users`');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 1</h1> <h1>msz_profile_fields_values -> field_value -> 1</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 1'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 1');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 2</h1> <h1>msz_profile_fields_values -> field_value -> 2</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 2'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 2');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 3</h1> <h1>msz_profile_fields_values -> field_value -> 3</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 3'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 3');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 4</h1> <h1>msz_profile_fields_values -> field_value -> 4</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 4'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 4');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 5</h1> <h1>msz_profile_fields_values -> field_value -> 5</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 5'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 5');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 6</h1> <h1>msz_profile_fields_values -> field_value -> 6</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 6'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 6');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 7</h1> <h1>msz_profile_fields_values -> field_value -> 7</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 7'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 7');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 8</h1> <h1>msz_profile_fields_values -> field_value -> 8</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 8'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 8');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 9</h1> <h1>msz_profile_fields_values -> field_value -> 9</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 9'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 9');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 10</h1> <h1>msz_profile_fields_values -> field_value -> 10</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 10'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 10');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 11</h1> <h1>msz_profile_fields_values -> field_value -> 11</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 11'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 11');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 12</h1> <h1>msz_profile_fields_values -> field_value -> 12</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 12'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 12');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 13</h1> <h1>msz_profile_fields_values -> field_value -> 13</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 13'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 13');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 14</h1> <h1>msz_profile_fields_values -> field_value -> 14</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 14'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 14');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 15</h1> <h1>msz_profile_fields_values -> field_value -> 15</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 15'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 15');
$getShit->execute(); $getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 16</h1> <h1>msz_profile_fields_values -> field_value -> 16</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 16'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 16');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 17</h1> <h1>msz_profile_fields_values -> field_value -> 17</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 17'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 17');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 18</h1> <h1>msz_profile_fields_values -> field_value -> 18</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 18'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 18');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>
<h1>msz_profile_fields_values -> field_value -> 19</h1> <h1>msz_profile_fields_values -> field_value -> 19</h1>
<textarea><?php <textarea><?php
$getShit = $db->prepare('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 19'); $getShit = $db->query('SELECT `field_value` FROM `msz_profile_fields_values` WHERE `field_id` = 19');
$getShit->execute();
while(($line = $getShit->fetchColumn()) !== false) while($getShit->next()) {
$line = $getShit->getString(0);
if(!empty($line)) if(!empty($line))
echo htmlspecialchars($line) . $separator; echo htmlspecialchars($line) . $separator;
}
?></textarea> ?></textarea>

View file

@ -25,18 +25,32 @@ try {
ON t.`topic_id` = p.`topic_id` ON t.`topic_id` = p.`topic_id`
LEFT JOIN `msz_forum_categories` AS f LEFT JOIN `msz_forum_categories` AS f
ON f.`forum_id` = p.`forum_id` ON f.`forum_id` = p.`forum_id`
WHERE `post_id` > :post_id WHERE `post_id` > ?
AND `post_deleted` IS NULL AND `post_deleted` IS NULL
AND `post_created` > NOW() - INTERVAL 7 DAY AND `post_created` > NOW() - INTERVAL 7 DAY
AND p.`forum_id` IN (2, 7, 24, 6, 5, 4, 16, 20, 8, 19, 10, 11, 13, 21, 15, 14, 27, 29, 28) AND p.`forum_id` IN (2, 7, 24, 6, 5, 4, 16, 20, 8, 19, 10, 11, 13, 21, 15, 14, 27, 29, 28)
ORDER BY `post_id` ORDER BY `post_id`
LIMIT 6 LIMIT 6
'); ');
$fetch->bindValue('post_id', $startId); $fetch->addParameter(1, $startId);
if($fetch->execute()) $fetch->execute();
echo json_encode($fetch->fetchAll(PDO::FETCH_ASSOC)); $result = $fetch->getResult();
else
echo '[]'; $sets = [];
} catch(PDOException $ex) { while($result->next())
$sets[] = [
'post_id' => $result->getInteger(0),
'topic_id' => $result->getInteger(1),
'topic_title' => $result->getString(2),
'forum_id' => $result->getInteger(3),
'forum_name' => $result->getString(4),
'user_id' => $result->getInteger(5),
'username' => $result->getString(6),
'user_colour' => $result->getInteger(7),
'is_opening_post' => $result->getInteger(8),
];
echo json_encode($sets);
} catch(Exception $ex) {
echo '{"error":104}'; echo '{"error":104}';
} }

View file

@ -7,16 +7,23 @@ try {
$fetch = $db->prepare(' $fetch = $db->prepare('
SELECT `user_id`, `username` SELECT `user_id`, `username`
FROM `msz_users` FROM `msz_users`
WHERE `user_id` > :user_id WHERE `user_id` > ?
AND `user_created` > NOW() - INTERVAL 7 DAY AND `user_created` > NOW() - INTERVAL 7 DAY
ORDER BY `user_id` ORDER BY `user_id`
LIMIT 10 LIMIT 10
'); ');
$fetch->bindValue('user_id', $startId); $fetch->addParameter(1, $startId);
if($fetch->execute()) $fetch->execute();
echo json_encode($fetch->fetchAll(PDO::FETCH_ASSOC)); $result = $fetch->getResult();
else
echo '[]'; $sets = [];
} catch(PDOException $ex) { while($result->next())
echo '{"error":104}'; $sets[] = [
'user_id' => $result->getInteger(0),
'username' => $result->getString(1),
];
echo json_encode($sets);
} catch(Exception $ex) {
echo json_encode(['error' => 104, 'msg' => $ex->getMessage()]);
} }