Permalink
Browse files

Bunch of little fixes and tweaks

  • Loading branch information...
OtakuMegane committed Jan 14, 2019
1 parent 5f5cd48 commit d308888f585e42812335f81e5dc5471182dde970
Showing with 174 additions and 162 deletions.
  1. 0 {documentation → }/CHANGELOG.md
  2. +1 −1 assets/script/nel.js
  3. +3 −3 assets/script/ui.js
  4. +1 −1 assets/styles/nelliel_b/nelliel_b.css
  5. +1 −1 board_files/include/API/JSON/JSONContent.php
  6. +1 −1 board_files/include/API/JSON/JSONIndex.php
  7. +1 −1 board_files/include/API/JSON/JSONPost.php
  8. +1 −1 board_files/include/API/JSON/JSONThread.php
  9. +2 −2 board_files/include/Admin/AdminBans.php
  10. +3 −3 board_files/include/Admin/AdminBoardSettings.php
  11. +1 −1 board_files/include/Admin/AdminFileFilters.php
  12. +1 −1 board_files/include/Admin/AdminIconSets.php
  13. +1 −1 board_files/include/Admin/AdminPermissions.php
  14. +6 −7 board_files/include/Admin/AdminReports.php
  15. +1 −1 board_files/include/Admin/AdminSiteSettings.php
  16. +1 −1 board_files/include/Admin/AdminStyles.php
  17. +21 −18 board_files/include/Content/ContentPost.php
  18. +7 −7 board_files/include/Post/FilesUpload.php
  19. +5 −5 board_files/include/Post/NewPost.php
  20. +1 −1 board_files/include/Setup/SQLTables.php
  21. +1 −0 board_files/include/Setup/TableInsertData.php
  22. +11 −11 board_files/include/classes/ArchiveAndPrune.php
  23. +9 −8 board_files/include/classes/BanHammer.php
  24. +1 −1 board_files/include/classes/CAPTCHA.php
  25. +2 −2 board_files/include/classes/CacheHandler.php
  26. +6 −6 board_files/include/classes/ContentID.php
  27. +2 −2 board_files/include/classes/Domain.php
  28. +5 −5 board_files/include/classes/FileTypes.php
  29. +3 −3 board_files/include/classes/FrontEndData.php
  30. +1 −1 board_files/include/classes/INIParser.php
  31. +6 −6 board_files/include/classes/OutputFilter.php
  32. +1 −1 board_files/include/classes/ParametersAndData.php
  33. +1 −1 board_files/include/classes/Session.php
  34. +1 −1 board_files/include/classes/Snacks.php
  35. +1 −1 board_files/include/dispatch/central_dispatch.php
  36. +2 −2 board_files/include/dispatch/module_dispatch.php
  37. +14 −8 board_files/include/login.php
  38. +10 −10 board_files/include/output/main_generation.php
  39. +2 −2 board_files/include/output/management/thread_panel.php
  40. +9 −9 board_files/include/output/post.php
  41. +7 −7 board_files/include/output/thread_generation.php
  42. +5 −0 board_files/templates/nelliel_basic/management/site_settings_panel.html
  43. +15 −15 board_files/templates/nelliel_basic/thread.html
  44. +0 −3 configuration/config.php.example
File renamed without changes.
@@ -194,7 +194,7 @@ nelliel.core.hashHandler = function () {
var hash_match = location.hash.match(/#t([0-9]+)p([0-9]+)/);

if (hash_match !== null) {
var content_id = nelliel.core.contentID('nci_' + hash_match[1] + '_' + hash_match[2] + '_0');
var content_id = nelliel.core.contentID('cid_' + hash_match[1] + '_' + hash_match[2] + '_0');
nelliel.ui.highlightPost(content_id);
}
}
@@ -2,7 +2,7 @@ nelliel.ui.hideShowThread = function(element, command) {
var content_id = nelliel.core.contentID(element.getAttribute("data-content-id"));
var post_files = document.getElementById("files-" + content_id.id_string);
var post_contents = document.getElementById("post-contents-" + content_id.id_string);
var thread_container = document.getElementById("thread-expand-" + "nci_" + content_id.thread_id + "_0_0");
var thread_container = document.getElementById("thread-expand-" + "cid_" + content_id.thread_id + "_0_0");

if (command === "hide-thread") {
dataBin.hidden_threads[content_id.id_string] = Date.now();
@@ -172,7 +172,7 @@ nelliel.ui.inlineExpandReduce = function(element, command) {
nelliel.ui.showLinkedPost = function(element, event) {
var href = element.getAttribute("href");
var anchor_matches = href.match(/#t([0-9]+)p([0-9]+)/);
var post_id = "nci_" + anchor_matches[1] + "_" + anchor_matches[2] + "_0";
var post_id = "cid_" + anchor_matches[1] + "_" + anchor_matches[2] + "_0";

if (document.getElementById("post-quote-popup-" + post_id) !== null) {
return;
@@ -220,7 +220,7 @@ nelliel.ui.showLinkedPost = function(element, event) {
nelliel.ui.hideLinkedPost = function(element, event) {
var href = element.getAttribute("href");
var anchor_matches = href.match(/#t([0-9]+)p([0-9]+)/);
var post_id = "nci_" + anchor_matches[1] + "_" + anchor_matches[2] + "_0";
var post_id = "cid_" + anchor_matches[1] + "_" + anchor_matches[2] + "_0";
var target_popup = document.getElementById("post-quote-popup-" + post_id);

if (target_popup !== null) {
@@ -410,7 +410,7 @@ a:hover {
}

.reply-post.post-highlight {
background-color: #DD99CC;
background-color: #CFCA9A;
}

.reply-poster-name {
@@ -45,7 +45,7 @@ public function prepareData($data, $store = false)
$this->addIfNotEmpty($content_array, 'url', $data['url'], 'string');
$this->addIfNotEmpty($content_array, 'exif', $data['exif'], 'string');
$this->addIfNotEmpty($content_array, 'meta', $data['meta'], 'string');
$content_array = nel_plugins()->processHook('nel-json-prepare-content', array($data), $content_array);
$content_array = nel_plugins()->processHook('nel-json-prepare-content', [$data], $content_array);
if ($store)
{
@@ -21,7 +21,7 @@ public function prepareData($data, $store = false)
{
$index_array = array();
$index_array['thread_count'] = nel_cast_to_datatype($data['thread_count'], 'integer');
$index_array = nel_plugins()->processHook('nel-json-prepare-post', array($data), $index_array);
$index_array = nel_plugins()->processHook('nel-json-prepare-post', [$data], $index_array);
if ($store)
{
@@ -40,7 +40,7 @@ public function prepareData($data, $store = false)
$post_array['op'] = nel_cast_to_datatype($data['op'], 'boolean');
$post_array['sage'] = nel_cast_to_datatype($data['sage'], 'boolean');
$this->addIfNotEmpty($post_array, 'mod_comment', $data['mod_comment'], 'string');
$post_array = nel_plugins()->processHook('nel-json-prepare-post', array($data), $post_array);
$post_array = nel_plugins()->processHook('nel-json-prepare-post', [$data], $post_array);
if ($store)
{
@@ -33,7 +33,7 @@ public function prepareData($data, $store = false)
$thread_array['sticky'] = nel_cast_to_datatype($data['sticky'], 'boolean');
$thread_array['locked'] = nel_cast_to_datatype($data['locked'], 'boolean');
$this->addIfNotEmpty($thread_array, 'slug', $data['slug'], 'string');
$thread_array = nel_plugins()->processHook('nel-json-prepare-thread', array($data), $thread_array);
$thread_array = nel_plugins()->processHook('nel-json-prepare-thread', [$data], $thread_array);
if ($store)
{
@@ -97,9 +97,9 @@ public function add($user)
$prepared = $this->database->prepare(
'UPDATE "' . $post_table . '" SET "mod_comment" = ? WHERE "post_number" = ?');
$this->database->executePrepared($prepared, array($_POST['mod_post_comment'], $_GET['post-id']));
$this->database->executePrepared($prepared, [$_POST['mod_post_comment'], $_GET['post-id']]);
$regen = new \Nelliel\Regen();
$regen->threads($this->domain, true, array($_GET['post-id']));
$regen->threads($this->domain, true, [$_GET['post-id']]);
$regen->index($this->domain);
}
}
@@ -121,7 +121,7 @@ private function setLock($config_table, $config_name, $setting)
{
$prepared = $this->database->prepare(
'UPDATE "' . $config_table . '" SET "edit_lock" = ? WHERE "config_name" = ?');
$this->database->executePrepared($prepared, array($setting, $config_name), true);
$this->database->executePrepared($prepared, [$setting, $config_name], true);
}
private function updateSetting($config_table, $config_name, $setting, $lock_override)
@@ -130,13 +130,13 @@ private function updateSetting($config_table, $config_name, $setting, $lock_over
{
$prepared = $this->database->prepare(
'UPDATE "' . $config_table . '" SET "setting" = ? WHERE "config_name" = ?');
$this->database->executePrepared($prepared, array($setting, $config_name), true);
$this->database->executePrepared($prepared, [$setting, $config_name], true);
}
else
{
$prepared = $this->database->prepare(
'UPDATE "' . $config_table . '" SET "setting" = ? WHERE "config_name" = ? AND "edit_lock" = 0');
$this->database->executePrepared($prepared, array($setting, $config_name), true);
$this->database->executePrepared($prepared, [$setting, $config_name], true);
}
}
@@ -87,7 +87,7 @@ public function remove($user)
$filter_id = $_GET['filter-id'];
$prepared = $this->database->prepare('DELETE FROM "' . FILE_FILTERS_TABLE . '" WHERE "entry" = ?');
$this->database->executePrepared($prepared, array($filter_id));
$this->database->executePrepared($prepared, [$filter_id]);
$this->renderPanel($user);
}
@@ -94,7 +94,7 @@ public function remove($user)
$icon_set_id = $_GET['icon-set-id'];
$prepared = $this->database->prepare('DELETE FROM "' . ASSETS_TABLE . '" WHERE "id" = ? AND "type" = ?');
$this->database->executePrepared($prepared, array($icon_set_id, 'icon-set'));
$this->database->executePrepared($prepared, [$icon_set_id, 'icon-set']);
$this->renderPanel($user);
}
@@ -80,7 +80,7 @@ public function remove($user)
$permission = $_GET['permission'];
$prepared = $this->database->prepare('DELETE FROM "' . PERMISSIONS_TABLE . '" WHERE "permission" = ?');
$this->database->executePrepared($prepared, array($permission));
$this->database->executePrepared($prepared, [$permission]);
$this->renderPanel($user);
}
}
@@ -26,11 +26,11 @@ public function actionDispatch($inputs)
$session = new \Nelliel\Session($this->authorization, true);
$user = $session->sessionUser();
if($inputs['action'] === 'dismiss')
if ($inputs['action'] === 'dismiss')
{
$this->dismiss($user, $_GET['report_id']);
}
else if(isset($_POST['form_submit_report']))
else if (isset($_POST['form_submit_report']))
{
$this->add($user);
}
@@ -69,11 +69,11 @@ public function add($user)
{
$report_data['content_id'] = $content_id->getIDString();
$query = 'INSERT INTO "' . REPORTS_TABLE .
'" ("board_id", "content_id", "reason", "reporter_ip") VALUES (?, ?, ?, ?)';
'" ("board_id", "content_id", "reason", "reporter_ip") VALUES (?, ?, ?, ?)';
$prepared = $this->database->prepare($query);
$this->database->executePrepared($prepared,
array($this->domain->id(), $report_data['content_id'], $report_data['reason'],
@inet_pton($report_data['reporter_ip'])));
[$this->domain->id(), $report_data['content_id'], $report_data['reason'],
@inet_pton($report_data['reporter_ip'])]);
}
}
}
@@ -98,7 +98,6 @@ public function dismiss($user, $report_id)
}
$prepared = $this->database->prepare('DELETE FROM "' . REPORTS_TABLE . '" WHERE "report_id" = ?');
$this->database->executePrepared($prepared, array($report_id));
$this->database->executePrepared($prepared, [$report_id]);
}
}
@@ -63,7 +63,7 @@ public function update($user)
while ($item = each($_POST))
{
$prepared = $this->database->prepare('UPDATE "nelliel_site_config" SET "setting" = ? WHERE "config_name" = ?');
$this->database->executePrepared($prepared, array($item[1], $item[0]), true);
$this->database->executePrepared($prepared, [$item[1], $item[0]], true);
}
$regen = new \Nelliel\Regen();
@@ -93,7 +93,7 @@ public function remove($user)
$style_id = $_GET['style-id'];
$prepared = $this->database->prepare('DELETE FROM "' . ASSETS_TABLE . '" WHERE "id" = ? AND "type" = \'style\'');
$this->database->executePrepared($prepared, array($style_id));
$this->database->executePrepared($prepared, [$style_id]);
$this->renderPanel($user);
}
@@ -18,7 +18,7 @@ function __construct($database, $content_id, $domain, $db_load = false)
$this->content_id = $content_id;
$this->domain = $domain;
if($db_load)
if ($db_load)
{
$this->loadFromDatabase();
}
@@ -75,7 +75,8 @@ public function writeToDatabase($temp_database = null)
$prepared->bindValue(':parent_thread',
$this->contentDataOrDefault('parent_thread', $this->content_id->thread_id), PDO::PARAM_INT);
$prepared->bindValue(':reply_to', $this->contentDataOrDefault('reply_to', $this->content_id->thread_id), PDO::PARAM_INT);
$prepared->bindValue(':reply_to', $this->contentDataOrDefault('reply_to', $this->content_id->thread_id),
PDO::PARAM_INT);
$prepared->bindValue(':poster_name', $this->contentDataOrDefault('poster_name', null), PDO::PARAM_STR);
$prepared->bindValue(':post_password', $this->contentDataOrDefault('post_password', null), PDO::PARAM_STR);
$prepared->bindValue(':tripcode', $this->contentDataOrDefault('tripcode', null), PDO::PARAM_STR);
@@ -100,13 +101,13 @@ public function reserveDatabaseRow($post_time, $post_time_milli, $temp_database
{
$parent_thread = $database = (!is_null($temp_database)) ? $temp_database : $this->database;
$prepared = $database->prepare(
'INSERT INTO "' . $this->domain->reference('post_table') . '" ("post_time", "post_time_milli") VALUES (?, ?)');
'INSERT INTO "' . $this->domain->reference('post_table') .
'" ("post_time", "post_time_milli") VALUES (?, ?)');
$database->executePrepared($prepared, [$post_time, $post_time_milli]);
$prepared = $database->prepare(
'SELECT "post_number" FROM "' . $this->domain->reference('post_table') .
'" WHERE "post_time" = ? AND post_time_milli = ?');
$result = $database->executePreparedFetch($prepared, [$post_time, $post_time_milli],
PDO::FETCH_COLUMN, true);
$result = $database->executePreparedFetch($prepared, [$post_time, $post_time_milli], PDO::FETCH_COLUMN, true);
$this->content_id->thread_id = ($this->content_id->thread_id == 0) ? $result : $this->content_id->thread_id;
$this->content_data['parent_thread'] = ($this->content_data['parent_thread'] == 0) ? $result : $this->content_data['parent_thread'];
$this->content_id->post_id = $result;
@@ -130,7 +131,7 @@ public function remove($perm_override = false)
return false;
}
if(!$perm_override && $this->domain->reference('locked'))
if (!$perm_override && $this->domain->reference('locked'))
{
nel_derp(52, _gettext('Cannot remove post. Board is locked.'));
}
@@ -150,7 +151,8 @@ protected function removeFromDatabase($temp_database = null)
}
$database = (!is_null($temp_database)) ? $temp_database : $this->database;
$prepared = $database->prepare('DELETE FROM "' . $this->domain->reference('post_table') . '" WHERE "post_number" = ?');
$prepared = $database->prepare(
'DELETE FROM "' . $this->domain->reference('post_table') . '" WHERE "post_number" = ?');
$database->executePrepared($prepared, [$this->content_id->post_id]);
return true;
}
@@ -159,23 +161,23 @@ protected function removeFromDisk()
{
$file_handler = new \Nelliel\FileHandler();
$file_handler->eraserGun(
$this->domain->reference('src_path') . $this->content_id->thread_id . '/' . $this->content_id->post_id, null,
true);
$this->domain->reference('src_path') . $this->content_id->thread_id . '/' . $this->content_id->post_id,
null, true);
$file_handler->eraserGun(
$this->domain->reference('thumb_path') . $this->content_id->thread_id . '/' . $this->content_id->post_id, null,
true);
$this->domain->reference('thumb_path') . $this->content_id->thread_id . '/' . $this->content_id->post_id,
null, true);
}
public function updateCounts()
{
$prepared = $this->database->prepare(
'SELECT COUNT("entry") FROM "' . $this->domain->reference('content_table') . '" WHERE "post_ref" = ?');
$file_count = $this->database->executePreparedFetch($prepared, array($this->content_id->post_id),
$file_count = $this->database->executePreparedFetch($prepared, [$this->content_id->post_id],
PDO::FETCH_COLUMN, true);
$prepared = $this->database->prepare(
'UPDATE "' . $this->domain->reference('post_table') . '" SET "file_count" = ? WHERE "post_number" = ?');
$this->database->executePrepared($prepared, array($file_count, $this->content_id->post_id));
$this->database->executePrepared($prepared, [$file_count, $this->content_id->post_id]);
}
public function verifyModifyPerms()
@@ -198,7 +200,7 @@ public function verifyModifyPerms()
}
else
{
if($session->isActive())
if ($session->isActive())
{
if ($user->boardPerm($this->domain->id(), 'perm_post_delete'))
{
@@ -238,21 +240,22 @@ public function convertToThread()
$new_thread->createDirectories();
$file_handler->moveDirectory(
$this->domain->reference('src_path') . $this->content_id->thread_id . '/' . $this->content_id->post_id,
$this->domain->reference('src_path') . '/' . $new_thread->content_id->thread_id . '/' .
$this->domain->reference('src_path') . '/' . $new_thread->content_id->thread_id . '/' .
$this->content_id->post_id, true);
$file_handler->moveDirectory(
$this->domain->reference('thumb_path') . $this->content_id->thread_id . '/' . $this->content_id->post_id,
$this->domain->reference('thumb_path') . '/' . $new_thread->content_id->thread_id . '/' .
$this->domain->reference('thumb_path') . '/' . $new_thread->content_id->thread_id . '/' .
$this->content_id->post_id, true);
$prepared = $this->database->prepare(
'SELECT entry FROM "' . $this->domain->reference('content_table') . '" WHERE "post_ref" = ?');
$files = $this->database->executePreparedFetchAll($prepared, array($this->content_id->post_id), PDO::FETCH_ASSOC);
$files = $this->database->executePreparedFetchAll($prepared, [$this->content_id->post_id], PDO::FETCH_ASSOC);
foreach ($files as $file)
{
$prepared = $this->database->prepare(
'UPDATE "' . $this->domain->reference('content_table') . '" SET "parent_thread" = ? WHERE "post_ref" = ?');
'UPDATE "' . $this->domain->reference('content_table') .
'" SET "parent_thread" = ? WHERE "post_ref" = ?');
$this->database->executePrepared($prepared,
[$new_thread->content_id->thread_id, $this->content_id->post_id]);
}
@@ -82,7 +82,7 @@ public function processFiles($post)
if ($this->domain->setting('timestamp_filename'))
{
$file->content_data['filename'] = $post->content_data['post_time'] .
$post->content_data['post_time_milli'];
$post->content_data['post_time_milli'];
$file->content_data['fullname'] = $file->content_data['filename'] . '.' .
$file->content_data['extension'];
}
@@ -111,8 +111,8 @@ public function getPathInfo($file)
public function checkForErrors($file)
{
$error_data = array('delete_files' => true, 'bad-filename' => $file['name'], 'files' => $this->uploaded_files,
'board_id' => $this->domain->id());
$error_data = ['delete_files' => true, 'bad-filename' => $file['name'], 'files' => $this->uploaded_files,
'board_id' => $this->domain->id()];
if ($file['size'] > $this->domain->setting('max_filesize') * 1024)
{
@@ -154,8 +154,8 @@ public function doesFileExist($response_to, $file)
{
$database = nel_database();
$snacks = new \Nelliel\Snacks($database, new \Nelliel\BanHammer($database));
$error_data = array('delete_files' => true, 'bad-filename' => $file->content_data['name'],
'files' => $this->uploaded_files, 'board_id' => $this->domain->id());
$error_data = ['delete_files' => true, 'bad-filename' => $file->content_data['name'],
'files' => $this->uploaded_files, 'board_id' => $this->domain->id()];
$is_banned = false;
$file->content_data['md5'] = hash_file('md5', $file->content_data['location'], true);
$is_banned = $snacks->fileHashIsBanned($file->content_data['md5'], 'md5');
@@ -230,8 +230,8 @@ public function doesFileExist($response_to, $file)
public function checkFiletype($file)
{
$filetypes = new \Nelliel\FileTypes(nel_database());
$error_data = array('delete_files' => true, 'bad-filename' => $file->content_data['name'],
'files' => $this->uploaded_files, 'board_id' => $this->domain->id());
$error_data = ['delete_files' => true, 'bad-filename' => $file->content_data['name'],
'files' => $this->uploaded_files, 'board_id' => $this->domain->id()];
$this->getPathInfo($file);
$test_ext = utf8_strtolower($file->content_data['extension']);
Oops, something went wrong.

0 comments on commit d308888

Please sign in to comment.