From 3278f6e799bad1a7bc189c62a6539aa255ddb32b Mon Sep 17 00:00:00 2001 From: danpros Date: Mon, 27 Nov 2023 16:10:50 +0700 Subject: [PATCH] PHP 5.3 backward compatibility --- system/admin/admin.php | 12 ++++++++++-- system/includes/functions.php | 10 ++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/system/admin/admin.php b/system/admin/admin.php index 15929fd..4effd81 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -120,7 +120,11 @@ function add_content($title, $tag, $url, $content, $user, $draft, $category, $ty $post_date = date('Y-m-d-H-i-s'); $post_title = safe_html($title); - $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media ?? '')); + if (defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION < 7) { + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media)); + } else { + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media ?? '')); + } $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag))); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); @@ -260,7 +264,11 @@ function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publ } $post_title = safe_html($title); - $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media ?? '')); + if (defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION < 7) { + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media)); + } else { + $post_media = preg_replace('/\s\s+/', ' ', strip_tags($media ?? '')); + } $post_tag = strtolower(preg_replace(array('/[^a-zA-Z0-9,. \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($post_tag))); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); $description = safe_html($description); diff --git a/system/includes/functions.php b/system/includes/functions.php index e60f981..a48e44e 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -570,8 +570,14 @@ function get_category_info($category) } } - if (strtolower($category ?? '') == 'uncategorized') { - return default_category(); + if (defined('PHP_MAJOR_VERSION') && PHP_MAJOR_VERSION < 7) { + if (strtolower($category) == 'uncategorized') { + return default_category(); + } + } else { + if (strtolower($category ?? '') == 'uncategorized') { + return default_category(); + } } return $tmp;