diff --git a/common/framework/Korea.php b/common/framework/Korea.php index 774cda049..b7d57089d 100644 --- a/common/framework/Korea.php +++ b/common/framework/Korea.php @@ -349,7 +349,7 @@ class Korea return self::$_domain_cache[$domain] = false; } } - foreach (self::_getDNSRecords($domain, \DNS_A) as $mx_ip) + foreach (self::_getDNSRecords($mx, \DNS_A) as $mx_ip) { return self::$_domain_cache[$domain] = self::isKoreanIP($mx_ip); } diff --git a/common/framework/Mail.php b/common/framework/Mail.php index 72c226c95..00851a749 100644 --- a/common/framework/Mail.php +++ b/common/framework/Mail.php @@ -585,7 +585,7 @@ class Mail // Reset Message-ID in case send() is called multiple times. $random = substr(hash('sha256', mt_rand() . microtime() . getmypid()), 0, 32); $sender = $this->message->getFrom(); - $sender_email = strval(array_first_key($sender)); + $sender_email = strval(array_key_first($sender)); $id = $random . '@' . (preg_match('/^(.+)@([^@]+)$/', $sender_email, $matches) ? $matches[2] : 'swift.generated'); $this->message->getHeaders()->get('Message-ID')->setId($id); diff --git a/common/framework/Password.php b/common/framework/Password.php index 3182557fb..feb1943ec 100644 --- a/common/framework/Password.php +++ b/common/framework/Password.php @@ -112,7 +112,7 @@ class Password { unset($algos['argon2id']); } - return array_first_key($algos); + return array_key_first($algos); } /** diff --git a/common/framework/Router.php b/common/framework/Router.php index 021449f90..29931b635 100644 --- a/common/framework/Router.php +++ b/common/framework/Router.php @@ -608,7 +608,7 @@ class Router return false; } arsort($reordered_routes); - $best_route = array_first_key($reordered_routes); + $best_route = array_key_first($reordered_routes); return $best_route; } } diff --git a/common/framework/Storage.php b/common/framework/Storage.php index 5fe64c477..6637c5cc0 100644 --- a/common/framework/Storage.php +++ b/common/framework/Storage.php @@ -560,6 +560,7 @@ class Storage return false; } } + chmod($destination, 0666 & ~self::getUmask()); } elseif ($type === 'move') { @@ -570,6 +571,7 @@ class Storage return false; } } + chmod($destination, 0666 & ~self::getUmask()); } else { diff --git a/common/framework/Template.php b/common/framework/Template.php index f5919beab..105da4fa6 100644 --- a/common/framework/Template.php +++ b/common/framework/Template.php @@ -368,7 +368,10 @@ class Template $content = $this->parse(); if (!Storage::write($this->cache_path, $content)) { - throw new Exception('Cannot write template cache file: ' . $this->cache_path); + if (!Storage::write($this->cache_path, $content)) + { + throw new Exception('Cannot write template cache file: ' . $this->cache_path); + } } } diff --git a/common/framework/drivers/mail/brevo.php b/common/framework/drivers/mail/brevo.php index 4fe4625ff..613b0309e 100644 --- a/common/framework/drivers/mail/brevo.php +++ b/common/framework/drivers/mail/brevo.php @@ -69,7 +69,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface $from = $message->message->getFrom(); $to = $message->message->getTo(); $data = [ - 'sender' => ['email' => array_first_key($from), 'name' => array_first($from)], + 'sender' => ['email' => array_key_first($from), 'name' => array_first($from)], 'to' => array_map($format_callback, array_keys($to), array_values($to)), 'subject' => $message->message->getSubject(), 'htmlContent' => $message->message->getBody(), @@ -84,7 +84,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface } if ($reply_to = $message->message->getReplyTo()) { - $data['replyTo'] = ['email' => array_first_key($reply_to)]; + $data['replyTo'] = ['email' => array_key_first($reply_to)]; } foreach ($message->getAttachments() as $attachment) { @@ -93,7 +93,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface 'name' => $attachment->display_filename ?: $attachment->cid, ]; } - + // Prepare headers and options for Requests. $headers = [ 'api-key' => $this->_config['api_key'], @@ -103,7 +103,7 @@ class Brevo extends Base implements \Rhymix\Framework\Drivers\MailInterface $options = [ 'timeout' => 8, ]; - + // Send the API request. $request = \Rhymix\Framework\HTTP::post(self::$_url, $data, $headers, [], $options); $status_code = $request->getStatusCode(); diff --git a/common/framework/drivers/mail/sendgrid.php b/common/framework/drivers/mail/sendgrid.php index b135c79bd..8a7d84c96 100644 --- a/common/framework/drivers/mail/sendgrid.php +++ b/common/framework/drivers/mail/sendgrid.php @@ -108,7 +108,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface $from = $message->message->getFrom(); if ($from) { - $data['from']['email'] = array_first_key($from); + $data['from']['email'] = array_key_first($from); if (array_first($from)) { $data['from']['name'] = array_first($from); @@ -119,7 +119,7 @@ class SendGrid extends Base implements \Rhymix\Framework\Drivers\MailInterface $replyTo = $message->message->getReplyTo(); if ($replyTo) { - $data['reply_to']['email'] = array_first_key($from); + $data['reply_to']['email'] = array_key_first($from); } // Set the subject. diff --git a/common/framework/parsers/DBTableParser.php b/common/framework/parsers/DBTableParser.php index cbd50ea55..50874a7d8 100644 --- a/common/framework/parsers/DBTableParser.php +++ b/common/framework/parsers/DBTableParser.php @@ -304,7 +304,13 @@ class DBTableParser extends BaseParser if ($constraint->references) { $ref = explode('.', $constraint->references); - $info->refs[] = $ref[0]; + $reference_table_name = $ref[0]; + if ($reference_table_name === $table_name) + { + continue; // Ignore self-references. + } + + $info->refs[] = $reference_table_name; } } $ref_list[$table_name] = $info; @@ -328,7 +334,6 @@ class DBTableParser extends BaseParser } } } - $k++; } if (!$changed) { diff --git a/common/functions.php b/common/functions.php index 72b3e9e5b..84b923681 100644 --- a/common/functions.php +++ b/common/functions.php @@ -56,9 +56,12 @@ function lang(?string $code, $value = null) * @param array $array The input array * @return mixed */ -function array_first(array $array) +if (!function_exists('array_first')) { - return reset($array); + function array_first(array $array) + { + return reset($array); + } } /** @@ -69,8 +72,7 @@ function array_first(array $array) */ function array_first_key(array $array) { - reset($array); - return key($array); + return array_key_first($array); } /** @@ -79,9 +81,12 @@ function array_first_key(array $array) * @param array $array The input array * @return mixed */ -function array_last(array $array) +if (!function_exists('array_last')) { - return end($array); + function array_last(array $array) + { + return end($array); + } } /** @@ -92,8 +97,7 @@ function array_last(array $array) */ function array_last_key(array $array) { - end($array); - return key($array); + return array_key_last($array); } /** diff --git a/common/js/common.js b/common/js/common.js index 728085456..7504be4ad 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -614,7 +614,7 @@ Rhymix.ajaxForm = function(form, callback_success, callback_error) { } else { callback_success = function(data) { if (data.message && data.message !== 'success') { - alert(data.message); + rhymix_alert(data.message, data.redirect_url); } if (data.redirect_url) { Rhymix.redirectToUrl(data.redirect_url.replace(/&/g, '&')); diff --git a/modules/admin/controllers/AdminMenu.php b/modules/admin/controllers/AdminMenu.php index f9bc3880b..47aa98a3e 100644 --- a/modules/admin/controllers/AdminMenu.php +++ b/modules/admin/controllers/AdminMenu.php @@ -7,6 +7,7 @@ use MenuAdminController; use MenuAdminModel; use Rhymix\Framework\Cache; use Rhymix\Framework\Storage; +use Rhymix\Framework\Exceptions\TargetNotFound; use Rhymix\Modules\Admin\Models\AdminMenu as AdminMenuModel; use Rhymix\Modules\Admin\Models\Favorite as FavoriteModel; @@ -64,6 +65,10 @@ class AdminMenu extends Base { // Check if favorite exists. $module_name = Context::get('module_name'); + if (!$module_name) + { + throw new TargetNotFound(); + } $output = FavoriteModel::isFavorite($module_name); if(!$output->toBool()) { diff --git a/modules/admin/tpl/config_domains_edit.html b/modules/admin/tpl/config_domains_edit.html index 159227a62..f6d5c1aee 100644 --- a/modules/admin/tpl/config_domains_edit.html +++ b/modules/admin/tpl/config_domains_edit.html @@ -117,7 +117,7 @@
{$lang->about_board_combined_board}
diff --git a/modules/board/tpl/board_insert.html b/modules/board/tpl/board_insert.html index e3c0b5d91..f66a1d6e3 100644 --- a/modules/board/tpl/board_insert.html +++ b/modules/board/tpl/board_insert.html @@ -104,14 +104,14 @@{$lang->about_header_text}
{$lang->about_mobile_header_text}
{$lang->about_header_text}
{$lang->about_header_text}
{$lang->about_footer_text}
{$lang->about_header_text}