mirror of
				https://github.com/slawkens/myaac.git
				synced 2025-10-30 23:46:24 +01:00 
			
		
		
		
	Compare commits
	
		
			10 Commits
		
	
	
		
			v1.2
			...
			feature/ac
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 9d976256c3 | ||
|   | 3c1210fefa | ||
|   | 45af46b3c1 | ||
|   | 58feff50c6 | ||
|   | 464492d826 | ||
|   | 887b5068ad | ||
|   | 4c5cc8b573 | ||
|   | 529bdcf016 | ||
|   | 3e3f4bb5a5 | ||
|   | aa52df6e2e | 
| @@ -9,6 +9,7 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| use MyAAC\Models\Account as AccountModel; | use MyAAC\Models\Account as AccountModel; | ||||||
|  | use MyAAC\Models\AccountAction; | ||||||
| use MyAAC\Models\Player; | use MyAAC\Models\Player; | ||||||
|  |  | ||||||
| defined('MYAAC') or die('Direct access not allowed!'); | defined('MYAAC') or die('Direct access not allowed!'); | ||||||
| @@ -466,9 +467,8 @@ else if (isset($_REQUEST['search'])) { | |||||||
| 									</thead> | 									</thead> | ||||||
| 									<tbody> | 									<tbody> | ||||||
| 										<?php | 										<?php | ||||||
| 											$accountActions = \MyAAC\Models\AccountAction::where('account_id', $account->getId())->orderByDesc('date')->get(); | 											$accountActions = AccountAction::where('account_id', $account->getId())->orderByDesc('date')->get(); | ||||||
| 											foreach ($accountActions as $i => $log): | 											foreach ($accountActions as $i => $log): | ||||||
| 												$log->ip = ($log->ip != 0 ? long2ip($log->ip) : inet_ntop($log->ipv6)); |  | ||||||
| 												?> | 												?> | ||||||
| 											<tr> | 											<tr> | ||||||
| 												<td><?php echo $i + 1; ?></td> | 												<td><?php echo $i + 1; ?></td> | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ if (version_compare(phpversion(), '8.1', '<')) die('PHP version 8.1 or higher is | |||||||
|  |  | ||||||
| const MYAAC = true; | const MYAAC = true; | ||||||
| const MYAAC_VERSION = '1.2'; | const MYAAC_VERSION = '1.2'; | ||||||
| const DATABASE_VERSION = 43; | const DATABASE_VERSION = 44; | ||||||
| const TABLE_PREFIX = 'myaac_'; | const TABLE_PREFIX = 'myaac_'; | ||||||
| define('START_TIME', microtime(true)); | define('START_TIME', microtime(true)); | ||||||
| define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); | define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX')); | ||||||
|   | |||||||
| @@ -2,12 +2,12 @@ SET @myaac_database_version = 43; | |||||||
|  |  | ||||||
| CREATE TABLE `myaac_account_actions` | CREATE TABLE `myaac_account_actions` | ||||||
| ( | ( | ||||||
|  | 	`id` INT(11) NOT NULL AUTO_INCREMENT, | ||||||
| 	`account_id` INT(11) NOT NULL, | 	`account_id` INT(11) NOT NULL, | ||||||
| 	`ip` INT(10) UNSIGNED NOT NULL DEFAULT 0, | 	`ip` VARCHAR(45) NOT NULL DEFAULT '', | ||||||
| 	`ipv6` BINARY(16) NOT NULL DEFAULT 0, |  | ||||||
| 	`date` INT(11) NOT NULL DEFAULT 0, | 	`date` INT(11) NOT NULL DEFAULT 0, | ||||||
| 	`action` VARCHAR(255) NOT NULL DEFAULT '', | 	`action` VARCHAR(255) NOT NULL DEFAULT '', | ||||||
| 	KEY (`account_id`) | 	PRIMARY KEY (`id`) | ||||||
| ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4; | ) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4; | ||||||
|  |  | ||||||
| CREATE TABLE `myaac_admin_menu` | CREATE TABLE `myaac_admin_menu` | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ function getPlayerLink($name, $generate = true, bool $colored = false): string | |||||||
|  |  | ||||||
| function getMonsterLink($name, $generate = true): string | function getMonsterLink($name, $generate = true): string | ||||||
| { | { | ||||||
| 	$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'monsters/' . urlencode($name); | 	$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'monsters?name=' . urlencode($name); | ||||||
|  |  | ||||||
| 	if(!$generate) return $url; | 	if(!$generate) return $url; | ||||||
| 	return generateLink($url, $name); | 	return generateLink($url, $name); | ||||||
| @@ -129,16 +129,14 @@ function getMonsterLink($name, $generate = true): string | |||||||
|  |  | ||||||
| function getHouseLink($name, $generate = true): string | function getHouseLink($name, $generate = true): string | ||||||
| { | { | ||||||
| 	if(is_numeric($name)) | 	if(is_numeric($name)) { | ||||||
| 	{ |  | ||||||
| 		$house = House::find(intval($name), ['name']); | 		$house = House::find(intval($name), ['name']); | ||||||
| 		if ($house) { | 		if ($house) { | ||||||
| 			$name = $house->name; | 			$name = $house->name; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'houses?name=' . urlencode($name); | ||||||
| 	$url = BASE_URL . (setting('core.friendly_urls') ? '' : 'index.php/') . 'houses/' . urlencode($name); |  | ||||||
|  |  | ||||||
| 	if(!$generate) return $url; | 	if(!$generate) return $url; | ||||||
| 	return generateLink($url, $name); | 	return generateLink($url, $name); | ||||||
| @@ -984,31 +982,29 @@ function load_config_lua($filename) | |||||||
| 				continue; | 				continue; | ||||||
| 			} | 			} | ||||||
| 			$tmp_exp = explode('=', $line, 2); | 			$tmp_exp = explode('=', $line, 2); | ||||||
| 			if(strpos($line, 'dofile') !== false) | 			if(str_contains($line, 'dofile')) { | ||||||
| 			{ |  | ||||||
| 				$delimiter = '"'; | 				$delimiter = '"'; | ||||||
| 				if(strpos($line, $delimiter) === false) | 				if(!str_contains($line, $delimiter)) { | ||||||
| 					$delimiter = "'"; | 					$delimiter = "'"; | ||||||
|  | 				} | ||||||
|  |  | ||||||
| 				$tmp = explode($delimiter, $line); | 				$tmp = explode($delimiter, $line); | ||||||
| 				$result = array_merge($result, load_config_lua($config['server_path'] . $tmp[1])); | 				$result = array_merge($result, load_config_lua($config['server_path'] . $tmp[1])); | ||||||
| 			} | 			} | ||||||
| 			else if(count($tmp_exp) >= 2) | 			else if(count($tmp_exp) >= 2) { | ||||||
| 			{ |  | ||||||
| 				$key = trim($tmp_exp[0]); | 				$key = trim($tmp_exp[0]); | ||||||
| 				if(0 !== strpos($key, '--')) | 				if(!str_starts_with($key, '--')) { | ||||||
| 				{ |  | ||||||
| 					$value = trim($tmp_exp[1]); | 					$value = trim($tmp_exp[1]); | ||||||
| 					if(strpos($value, '--') !== false) {// found some deep comment | 					if(str_contains($value, '--')) {// found some deep comment | ||||||
| 						$value = preg_replace('/--.*$/i', '', $value); | 						$value = preg_replace('/--.*$/i', '', $value); | ||||||
| 					} | 					} | ||||||
|  |  | ||||||
| 					if(is_numeric($value)) | 					if(is_numeric($value)) | ||||||
| 						$result[$key] = (float) $value; | 						$result[$key] = (float) $value; | ||||||
| 					elseif(in_array(@$value[0], array("'", '"')) && in_array(@$value[strlen($value) - 1], array("'", '"'))) | 					elseif(in_array(@$value[0], array("'", '"')) && in_array(@$value[strlen($value) - 1], array("'", '"'))) | ||||||
| 						$result[$key] = (string) substr(substr($value, 1), 0, -1); | 						$result[$key] = substr(substr($value, 1), 0, -1); | ||||||
| 					elseif(in_array($value, array('true', 'false'))) | 					elseif(in_array($value, array('true', 'false'))) | ||||||
| 						$result[$key] = ($value === 'true') ? true : false; | 						$result[$key] = $value === 'true'; | ||||||
| 					elseif(@$value[0] === '{') { | 					elseif(@$value[0] === '{') { | ||||||
| 						// arrays are not supported yet | 						// arrays are not supported yet | ||||||
| 						// just ignore the error | 						// just ignore the error | ||||||
| @@ -1016,7 +1012,7 @@ function load_config_lua($filename) | |||||||
| 					} | 					} | ||||||
| 					else | 					else | ||||||
| 					{ | 					{ | ||||||
| 						foreach($result as $tmp_key => $tmp_value) // load values definied by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull | 						foreach($result as $tmp_key => $tmp_value) // load values defined by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull | ||||||
| 							$value = str_replace($tmp_key, $tmp_value, $value); | 							$value = str_replace($tmp_key, $tmp_value, $value); | ||||||
| 						$ret = @eval("return $value;"); | 						$ret = @eval("return $value;"); | ||||||
| 						if((string) $ret == '' && trim($value) !== '""') // = parser error | 						if((string) $ret == '' && trim($value) !== '""') // = parser error | ||||||
| @@ -1030,8 +1026,7 @@ function load_config_lua($filename) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	$result = array_merge($result, isset($config['lua']) ? $config['lua'] : array()); | 	return array_merge($result, $config['lua'] ?? []); | ||||||
| 	return $result; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| function str_replace_first($search,$replace, $subject) { | function str_replace_first($search,$replace, $subject) { | ||||||
|   | |||||||
| @@ -12,6 +12,8 @@ | |||||||
|  * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3 |  * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License, Version 3 | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | use MyAAC\Models\AccountAction; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * OTServ account abstraction. |  * OTServ account abstraction. | ||||||
|  * |  * | ||||||
| @@ -1010,26 +1012,16 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable | |||||||
|  |  | ||||||
| 	public function logAction($action) | 	public function logAction($action) | ||||||
| 	{ | 	{ | ||||||
| 		$ip = get_browser_real_ip(); | 		AccountAction::create([ | ||||||
| 		if(strpos($ip, ":") === false) { | 			'account_id' => $this->getId(), | ||||||
| 			$ipv6 = '0'; | 			'ip' => get_browser_real_ip(), | ||||||
| 		} | 			'date' => time(), | ||||||
| 		else { | 			'action' => $action, | ||||||
| 			$ipv6 = $ip; | 		]); | ||||||
| 			$ip = ''; |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		return $this->db->exec('INSERT INTO `' . TABLE_PREFIX . 'account_actions` (`account_id`, `ip`, `ipv6`, `date`, `action`) VALUES (' . $this->db->quote($this->getId()).', ' . ($ip == '' ? '0' : $this->db->quote(ip2long($ip))) . ', (' . ($ipv6 == '0' ? $this->db->quote('') : $this->db->quote(inet_pton($ipv6))) . '), UNIX_TIMESTAMP(NOW()), ' . $this->db->quote($action).')'); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public function getActionsLog($limit1, $limit2) | 	public function getActionsLog($limit) { | ||||||
| 	{ | 		return AccountAction::where('account_id', $this->data['id'])->orderByDesc('date')->limit($limit)->get()->toArray(); | ||||||
| 		$actions = array(); |  | ||||||
|  |  | ||||||
| 		foreach($this->db->query('SELECT `ip`, `ipv6`, `date`, `action` FROM `' . TABLE_PREFIX . 'account_actions` WHERE `account_id` = ' . $this->data['id'] . ' ORDER by `date` DESC LIMIT ' . $limit1 . ', ' . $limit2 . '')->fetchAll() as $a) |  | ||||||
| 			$actions[] = array('ip' => $a['ip'], 'ipv6' => $a['ipv6'], 'date' => $a['date'], 'action' => $a['action']); |  | ||||||
|  |  | ||||||
| 		return $actions; |  | ||||||
| 	} | 	} | ||||||
| /** | /** | ||||||
|  * Returns players iterator. |  * Returns players iterator. | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								system/migrations/44.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								system/migrations/44.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | <?php | ||||||
|  | /** | ||||||
|  |  * @var OTS_DB_MySQL $db | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | // 2025-02-27 | ||||||
|  | // remove ipv6, change to ip (for both ipv4 + ipv6) as VARCHAR(45) | ||||||
|  | $up = function () use ($db) { | ||||||
|  | 	$db->query("ALTER TABLE `myaac_account_actions` DROP KEY `account_id`;"); | ||||||
|  | 	$db->query("ALTER TABLE  `myaac_account_actions` ADD COLUMN `id` INT(11) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`);"); | ||||||
|  |  | ||||||
|  | 	$db->modifyColumn(TABLE_PREFIX . 'account_actions', 'ip', "VARCHAR(45) NOT NULL DEFAULT ''"); | ||||||
|  | 	$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET_NTOA(`ip`) WHERE `ip` != '0';"); | ||||||
|  | 	$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET6_NTOA(`ipv6`) WHERE `ip` = '0';"); | ||||||
|  | 	$db->dropColumn(TABLE_PREFIX . 'account_actions', 'ipv6'); | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | $down = function () use ($db) { | ||||||
|  | 	$db->query("ALTER TABLE `" . TABLE_PREFIX . "account_actions` DROP `id`;"); | ||||||
|  | 	$db->query("ALTER TABLE  `" . TABLE_PREFIX . "account_actions` ADD KEY (`account_id`);"); | ||||||
|  |  | ||||||
|  | 	$db->addColumn(TABLE_PREFIX . 'account_actions', 'ipv6', "BINARY(16) NOT NULL DEFAULT 0x00000000000000000000000000000000 AFTER ip"); | ||||||
|  | 	$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ipv6` = INET6_ATON(ip) WHERE NOT IS_IPV4(`ip`);"); | ||||||
|  | 	$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = INET_ATON(`ip`) WHERE IS_IPV4(`ip`);"); | ||||||
|  | 	$db->query("UPDATE `" . TABLE_PREFIX . "account_actions` SET `ip` = 0 WHERE `ipv6` != 0x00000000000000000000000000000000;"); | ||||||
|  | 	$db->modifyColumn(TABLE_PREFIX . 'account_actions', 'ip', "INT(11) UNSIGNED NOT NULL DEFAULT 0;"); | ||||||
|  | }; | ||||||
| @@ -85,12 +85,8 @@ if($email_new_time > 1) | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| $actions = array(); | $actions = $account_logged->getActionsLog(1000); | ||||||
| foreach($account_logged->getActionsLog(0, 1000) as $action) { |  | ||||||
| 	$actions[] = array('action' => $action['action'], 'date' => $action['date'], 'ip' => $action['ip'] != 0 ? long2ip($action['ip']) : inet_ntop($action['ipv6'])); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| $players = array(); |  | ||||||
| /** @var OTS_Players_List $account_players */ | /** @var OTS_Players_List $account_players */ | ||||||
| $account_players = $account_logged->getPlayersList(); | $account_players = $account_logged->getPlayersList(); | ||||||
| $account_players->orderBy('id'); | $account_players->orderBy('id'); | ||||||
|   | |||||||
| @@ -30,11 +30,11 @@ $state = ''; | |||||||
| $order = ''; | $order = ''; | ||||||
| $type = ''; | $type = ''; | ||||||
|  |  | ||||||
| if(isset($_GET['page']) && $_GET['page'] == 'view' && isset($_REQUEST['house'])) | if(isset($_REQUEST['name'])) | ||||||
| { | { | ||||||
| 	$beds = array("", "one", "two", "three", "fourth", "fifth"); | 	$beds = array("", "one", "two", "three", "fourth", "fifth"); | ||||||
| 	$houseName = $_REQUEST['house']; | 	$houseName = urldecode($_REQUEST['name']); | ||||||
| 	$houseId = (Validator::number($_REQUEST['house']) ? $_REQUEST['house'] : -1); | 	$houseId = (Validator::number($_REQUEST['name']) ? $_REQUEST['name'] : -1); | ||||||
| 	$selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId)); | 	$selectHouse = $db->query('SELECT * FROM ' . $db->tableName('houses') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($houseName) . ' OR `id` = ' . $db->quote($houseId)); | ||||||
|  |  | ||||||
| 	$house = array(); | 	$house = array(); | ||||||
| @@ -187,7 +187,7 @@ if(isset($_POST['town']) && isset($_POST['state']) && isset($_POST['order']) && | |||||||
| 				$houseRent = 'Free'; | 				$houseRent = 'Free'; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		$houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => ($hasTilesColumn ? $house['tiles'] : $house['size']), 'rent' => $house['rent'], 'rentedBy' => $houseRent); | 		$houses[] = array('owner' => $owner, 'name' => $house['name'], 'size' => ($hasTilesColumn ? $house['tiles'] : $house['size']), 'rent' => $house['rent'], 'rentedBy' => $houseRent, 'link' => getHouseLink($house['name'], false)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	$housesSearch = true; | 	$housesSearch = true; | ||||||
|   | |||||||
| @@ -1403,7 +1403,7 @@ Sent by MyAAC,<br/> | |||||||
| 			'name' => 'Outfit Images URL', | 			'name' => 'Outfit Images URL', | ||||||
| 			'type' => 'text', | 			'type' => 'text', | ||||||
| 			'desc' => 'Set to animoutfit.php for animated outfit', | 			'desc' => 'Set to animoutfit.php for animated outfit', | ||||||
| 			'default' => 'https://outfit-images.ots.me/outfit.php', | 			'default' => 'https://outfit-images.ots.me/latest/outfit.php', | ||||||
| 		], | 		], | ||||||
| 		'outfit_images_wrong_looktypes' => [ | 		'outfit_images_wrong_looktypes' => [ | ||||||
| 			'name' => 'Outfit Images Wrong Looktypes', | 			'name' => 'Outfit Images Wrong Looktypes', | ||||||
|   | |||||||
| @@ -9,6 +9,6 @@ class AccountAction extends Model { | |||||||
|  |  | ||||||
| 	public $timestamps = false; | 	public $timestamps = false; | ||||||
|  |  | ||||||
| 	protected $fillable = ['account_id', 'ip', 'ipv6', 'date', 'action']; | 	protected $fillable = ['account_id', 'ip', 'date', 'action']; | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -166,8 +166,14 @@ function get_template_menus(): array | |||||||
| 		$target_blank = ($menu['blank'] == 1 ? ' target="blank"' : ''); | 		$target_blank = ($menu['blank'] == 1 ? ' target="blank"' : ''); | ||||||
|  |  | ||||||
| 		$color = (empty($menu['color']) ? ($configMenuCategories[$menu['category']]['default_links_color'] ?? ($configMenuDefaultColor ?? '')) : $menu['color']); | 		$color = (empty($menu['color']) ? ($configMenuCategories[$menu['category']]['default_links_color'] ?? ($configMenuDefaultColor ?? '')) : $menu['color']); | ||||||
|  |  | ||||||
| 		$color = str_replace('#', '', $color); | 		$color = str_replace('#', '', $color); | ||||||
| 		$style_color = (empty($color) ? '' : 'style="color: #' . $color . '"'); |  | ||||||
|  | 		if (in_array('#' . $color, [$configMenuCategories[$menu['category']]['default_links_color'] ?? '', $configMenuDefaultColor])) { | ||||||
|  | 			$color = ''; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		$style_color = (empty($color) ? '' : 'style="color: #' . $color . ' !important"'); | ||||||
|  |  | ||||||
| 		$menus[$menu['category']][] = [ | 		$menus[$menu['category']][] = [ | ||||||
| 			'name' => $menu['name'], | 			'name' => $menu['name'], | ||||||
|   | |||||||
| @@ -56,10 +56,9 @@ the search criteria and start a new search. | |||||||
| 					</td> | 					</td> | ||||||
|  |  | ||||||
| 					<td> | 					<td> | ||||||
| 						<form action="{{ getLink('houses/view') }}" method="post"> | 						<a href="{{ house.link }}"> | ||||||
| 							<input type="hidden" name="house" value="{{ house.name }}"> |  | ||||||
| 							{{ include('buttons.view.html.twig') }} | 							{{ include('buttons.view.html.twig') }} | ||||||
| 						</form> | 						</a> | ||||||
| 					</td> | 					</td> | ||||||
| 				</tr> | 				</tr> | ||||||
| 			{% endfor %} | 			{% endfor %} | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ if(strlen($text) > 100) // max limit | |||||||
| putenv('GDFONTPATH=' . __DIR__); | putenv('GDFONTPATH=' . __DIR__); | ||||||
|  |  | ||||||
| // create image | // create image | ||||||
| $image = imagecreatetruecolor(250, 28); | $image = imagecreatetruecolor(600, 28); | ||||||
|  |  | ||||||
| // make the background transparent | // make the background transparent | ||||||
| imagecolortransparent($image, imagecolorallocate($image, 0, 0, 0)); | imagecolortransparent($image, imagecolorallocate($image, 0, 0, 0)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user