Skip to content

Commit

Permalink
PHP 5.3 backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
danpros committed Nov 27, 2023
1 parent 40181f0 commit 3278f6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions system/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 8 additions & 2 deletions system/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3278f6e

Please sign in to comment.