mirror of
				https://github.com/slawkens/myaac.git
				synced 2025-11-04 01:36:23 +01:00 
			
		
		
		
	Merge branch 'develop' into feature/migrations-up-down
This commit is contained in:
		@@ -14,7 +14,7 @@ class PluginInstallCommand extends Command
 | 
			
		||||
	{
 | 
			
		||||
		$this->setName('plugin:install')
 | 
			
		||||
			->setDescription('This command installs plugin')
 | 
			
		||||
			->addArgument('plugin', InputArgument::REQUIRED, 'Path to zip file (plugin) that you want to install');
 | 
			
		||||
			->addArgument('pathToPluginZip', InputArgument::REQUIRED, 'Path to zip file (plugin) that you want to install');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	protected function execute(InputInterface $input, OutputInterface $output): int
 | 
			
		||||
@@ -23,7 +23,7 @@ class PluginInstallCommand extends Command
 | 
			
		||||
 | 
			
		||||
		$io = new SymfonyStyle($input, $output);
 | 
			
		||||
 | 
			
		||||
		$pathToFile = $input->getArgument('plugin');
 | 
			
		||||
		$pathToFile = $input->getArgument('pathToPluginZip');
 | 
			
		||||
 | 
			
		||||
		$ext = strtolower(pathinfo($pathToFile, PATHINFO_EXTENSION));
 | 
			
		||||
		if($ext !== 'zip') {// check if it is zipped/compressed file
 | 
			
		||||
 
 | 
			
		||||
@@ -72,7 +72,7 @@ class Forum
 | 
			
		||||
			'post_smile' => 0, 'post_html' => 1,
 | 
			
		||||
			'post_date' => time(),
 | 
			
		||||
			'last_edit_aid' => 0, 'edit_date' => 0,
 | 
			
		||||
			'post_ip' => $_SERVER['REMOTE_ADDR']
 | 
			
		||||
			'post_ip' => get_browser_real_ip()
 | 
			
		||||
		))) {
 | 
			
		||||
			$thread_id = $db->lastInsertId();
 | 
			
		||||
			$db->query("UPDATE `" . FORUM_TABLE_PREFIX . "forum` SET `first_post`=".(int) $thread_id." WHERE `id` = ".(int) $thread_id);
 | 
			
		||||
@@ -94,7 +94,7 @@ class Forum
 | 
			
		||||
			'post_smile' => $smile,
 | 
			
		||||
			'post_html' => $html,
 | 
			
		||||
			'post_date' => time(),
 | 
			
		||||
			'post_ip' => $_SERVER['REMOTE_ADDR']
 | 
			
		||||
			'post_ip' => get_browser_real_ip()
 | 
			
		||||
		));
 | 
			
		||||
	}
 | 
			
		||||
	public static function add_board($name, $description, $access, $guild, &$errors)
 | 
			
		||||
 
 | 
			
		||||
@@ -37,17 +37,29 @@ class News
 | 
			
		||||
		if(!self::verify($title, $body, $article_text, $article_image, $errors))
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
		ModelsNews::create([
 | 
			
		||||
			'title' => $title,
 | 
			
		||||
			'body' => $body,
 | 
			
		||||
			'type' => $type,
 | 
			
		||||
			'date' => time(),
 | 
			
		||||
			'category' => $category,
 | 
			
		||||
			'player_id' => isset($player_id) ? $player_id : 0,
 | 
			
		||||
		$currentTime = time();
 | 
			
		||||
 | 
			
		||||
		$params = [
 | 
			
		||||
			'title' => $title, 'body' => $body,
 | 
			
		||||
			'type' => $type, 'category' => $category,
 | 
			
		||||
			'date' => $currentTime,
 | 
			
		||||
			'player_id' => $player_id ?? 0,
 | 
			
		||||
			'comments' => $comments,
 | 
			
		||||
			'article_text' => ($type == 3 ? $article_text : ''),
 | 
			
		||||
			'article_image' => ($type == 3 ? $article_image : '')
 | 
			
		||||
		]);
 | 
			
		||||
		];
 | 
			
		||||
 | 
			
		||||
		global $hooks;
 | 
			
		||||
		if (!$hooks->trigger(HOOK_ADMIN_NEWS_ADD_PRE, $params)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$newsModel = ModelsNews::create($params);
 | 
			
		||||
 | 
			
		||||
		$hooks->trigger(HOOK_ADMIN_NEWS_ADD,
 | 
			
		||||
			$params + ['id' => $newsModel->id],
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		self::clearCache();
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -58,30 +70,55 @@ class News
 | 
			
		||||
 | 
			
		||||
	static public function update($id, $title, $body, $type, $category, $player_id, $comments, $article_text, $article_image, &$errors)
 | 
			
		||||
	{
 | 
			
		||||
		if(!self::verify($title, $body, $article_text, $article_image, $errors))
 | 
			
		||||
		if(!self::verify($title, $body, $article_text, $article_image, $errors)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ModelsNews::where('id', $id)->update([
 | 
			
		||||
			'title' => $title,
 | 
			
		||||
			'body' => $body,
 | 
			
		||||
			'type' => $type,
 | 
			
		||||
			'category' => $category,
 | 
			
		||||
			'last_modified_by' => isset($player_id) ? $player_id : 0,
 | 
			
		||||
			'last_modified_date' => time(),
 | 
			
		||||
		$currentTime = time();
 | 
			
		||||
 | 
			
		||||
		$params = [
 | 
			
		||||
			'id' => $id,
 | 
			
		||||
			'title' => $title, 'body' => $body,
 | 
			
		||||
			'type' => $type, 'category' => $category,
 | 
			
		||||
			'last_modified_by' => $player_id ?? 0, 'last_modified_date' => $currentTime,
 | 
			
		||||
			'comments' => $comments,
 | 
			
		||||
			'article_text' => $article_text,
 | 
			
		||||
			'article_image' => $article_image
 | 
			
		||||
		]);
 | 
			
		||||
			'article_text' => ($type == 3 ? $article_text : ''),
 | 
			
		||||
			'article_image' => ($type == 3 ? $article_image : ''),
 | 
			
		||||
		];
 | 
			
		||||
 | 
			
		||||
		global $hooks;
 | 
			
		||||
		if (!$hooks->trigger(HOOK_ADMIN_NEWS_UPDATE_PRE, $params)) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		unset($params['id']);
 | 
			
		||||
 | 
			
		||||
		ModelsNews::where('id', $id)->update($params);
 | 
			
		||||
 | 
			
		||||
		$hooks->trigger(HOOK_ADMIN_NEWS_UPDATE,
 | 
			
		||||
			$params + ['id' => $id]
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		self::clearCache();
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	static public function delete($id, &$errors)
 | 
			
		||||
	{
 | 
			
		||||
		global $hooks;
 | 
			
		||||
 | 
			
		||||
		if(isset($id)) {
 | 
			
		||||
			$row = ModelsNews::find($id);
 | 
			
		||||
			if($row) {
 | 
			
		||||
				if (!$row->delete()) {
 | 
			
		||||
				$params = ['id' => $id];
 | 
			
		||||
 | 
			
		||||
				if (!$hooks->trigger(HOOK_ADMIN_NEWS_DELETE_PRE, $params)) {
 | 
			
		||||
					return false;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if ($row->delete()) {
 | 
			
		||||
					$hooks->trigger(HOOK_ADMIN_NEWS_DELETE, $params);
 | 
			
		||||
				} else {
 | 
			
		||||
					$errors[] = 'Fail during delete News.';
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@@ -103,22 +140,35 @@ class News
 | 
			
		||||
 | 
			
		||||
	static public function toggleHide($id, &$errors, &$status)
 | 
			
		||||
	{
 | 
			
		||||
		if(isset($id))
 | 
			
		||||
		{
 | 
			
		||||
		global $hooks;
 | 
			
		||||
 | 
			
		||||
		if(isset($id)) {
 | 
			
		||||
			$row = ModelsNews::find($id);
 | 
			
		||||
			if($row)
 | 
			
		||||
			{
 | 
			
		||||
				$row->hide = $row->hide == 1 ? 0 : 1;
 | 
			
		||||
				if (!$row->save()) {
 | 
			
		||||
			if($row) {
 | 
			
		||||
				$row->hide = ($row->hide == 1 ? 0 : 1);
 | 
			
		||||
 | 
			
		||||
				$params = ['hide' => $row->hide];
 | 
			
		||||
 | 
			
		||||
				if (!$hooks->trigger(HOOK_ADMIN_NEWS_TOGGLE_HIDE_PRE, $params)) {
 | 
			
		||||
					return false;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if ($row->save()) {
 | 
			
		||||
					$hooks->trigger(HOOK_ADMIN_NEWS_TOGGLE_HIDE, $params);
 | 
			
		||||
				}
 | 
			
		||||
				else {
 | 
			
		||||
					$errors[] = 'Fail during toggle hide News.';
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$status = $row->hide;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			else {
 | 
			
		||||
				$errors[] = 'News with id ' . $id . ' does not exists.';
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		else {
 | 
			
		||||
			$errors[] = 'News id not set.';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(count($errors)) {
 | 
			
		||||
			return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ class Visitors
 | 
			
		||||
		$this->sessionTime = $sessionTime;
 | 
			
		||||
		$this->cleanVisitors();
 | 
			
		||||
 | 
			
		||||
		$ip = $_SERVER['REMOTE_ADDR'];
 | 
			
		||||
		$ip = get_browser_real_ip();
 | 
			
		||||
		$userAgentShortened = substr($_SERVER['HTTP_USER_AGENT'] ?? 'unknown', 0, 255);
 | 
			
		||||
 | 
			
		||||
		if($this->visitorExists($ip))
 | 
			
		||||
 
 | 
			
		||||
@@ -71,6 +71,14 @@ define('HOOK_ADMIN_BODY_START', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_BODY_END', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_BEFORE_PAGE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_MENU', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_ADD_PRE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_ADD', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_UPDATE_PRE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_UPDATE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_DELETE_PRE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_DELETE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_TOGGLE_HIDE_PRE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_NEWS_TOGGLE_HIDE', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_LOGIN_AFTER_ACCOUNT', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_LOGIN_AFTER_PASSWORD', ++$i);
 | 
			
		||||
define('HOOK_ADMIN_LOGIN_AFTER_SIGN_IN', ++$i);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user