diff --git a/README.md b/README.md index b4b760c..ac4ad4b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The Nameless-Resources module allows users to share zip files, GitHub projects and external links to your website, either freely or requiring a PayPal purchase. ## Requirements -- NamelessMC version 2 pre-release 13 +- NamelessMC version 2.1.0 ## Installation - Upload the contents of the **upload** directory straight into your NamelessMC installation's directory diff --git a/upload/modules/Resources/classes/Resources_Sitemap.php b/upload/modules/Resources/classes/Resources_Sitemap.php index cdf25cf..6c34ed3 100644 --- a/upload/modules/Resources/classes/Resources_Sitemap.php +++ b/upload/modules/Resources/classes/Resources_Sitemap.php @@ -25,7 +25,7 @@ public static function generateSitemap(Sitemap $sitemap = null){ $authors = []; foreach($resources as $resource){ - $sitemap->addItem(URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name))), 0.5, 'weekly', date('Y-m-d', $resource->updated)); + $sitemap->addItem(URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name))), 0.5, 'weekly', date('Y-m-d', $resource->updated)); if(!in_array($resource->creator_id, $authors)) $authors[] = $resource->creator_id; } @@ -47,7 +47,7 @@ public static function generateSitemap(Sitemap $sitemap = null){ $categories = $db->query('SELECT id, `name` FROM nl2_resources_categories WHERE id IN (SELECT category_id FROM nl2_resources_categories_permissions WHERE group_id = 0 AND `view` = 1)')->results(); foreach($categories as $category){ - $sitemap->addItem(URL::build('/resources/category/' . Output::getClean($category->id . '-' . Util::stringToURL($category->name))), 0.5, 'daily'); + $sitemap->addItem(URL::build('/resources/category/' . Output::getClean($category->id . '-' . URL::urlSafe($category->name))), 0.5, 'daily'); } } } \ No newline at end of file diff --git a/upload/modules/Resources/module.php b/upload/modules/Resources/module.php index bc6ab48..ead9bce 100644 --- a/upload/modules/Resources/module.php +++ b/upload/modules/Resources/module.php @@ -2,7 +2,7 @@ /* * Made by Samerton * https://github.com/NamelessMC/Nameless/ - * NamelessMC version 2.0.2 + * NamelessMC version 2.1.0 * * License: MIT * @@ -18,8 +18,8 @@ public function __construct($pages, $language, $resource_language){ $name = 'Resources'; $author = 'Samerton'; - $module_version = '1.7.2'; - $nameless_version = '2.0.2'; + $module_version = '1.8.0'; + $nameless_version = '2.1.0'; parent::__construct($this, $name, $author, $module_version, $nameless_version); @@ -49,28 +49,13 @@ public function __construct($pages, $language, $resource_language){ public function onInstall(){ try { - $engine = Config::get('mysql/engine'); - $charset = Config::get('mysql/charset'); - } catch(Exception $e){ - $engine = 'InnoDB'; - $charset = 'utf8mb4'; - } - - if(!$engine || is_array($engine)) - $engine = 'InnoDB'; - - if(!$charset || is_array($charset)) - $charset = 'latin1'; - - $queries = new Queries(); - try { - $data = $queries->createTable("resources_categories", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, `description` text, `display_order` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); - $data = $queries->createTable("resources", " `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) NOT NULL, `creator_id` int(11) NOT NULL, `name` varchar(64) NOT NULL, `short_description` varchar(64) NULL DEFAULT NULL, `has_icon` tinyint(1) NOT NULL DEFAULT '0', `icon` varchar(512) NULL DEFAULT NULL, `icon_updated` int(11) NOT NULL DEFAULT '0', `description` mediumtext NOT NULL, `contributors` text, `views` int(11) NOT NULL DEFAULT '0', `downloads` int(11) NOT NULL DEFAULT '0', `created` int(11) NOT NULL, `updated` int(11) NOT NULL, `github_url` varchar(128) DEFAULT NULL, `github_username` varchar(64) DEFAULT NULL, `github_repo_name` varchar(64) DEFAULT NULL, `rating` int(11) NOT NULL DEFAULT '0', `latest_version` varchar(32) DEFAULT NULL, `type` tinyint(1) NOT NULL DEFAULT '0', `price` varchar(16) DEFAULT NULL, `payment_email` varchar(256) DEFAULT NULL, PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); - $data = $queries->createTable("resources_releases", " `id` int(11) NOT NULL AUTO_INCREMENT, `resource_id` int(11) NOT NULL, `category_id` int(11) NOT NULL, `release_title` varchar(128) NOT NULL, `release_description` mediumtext NOT NULL, `release_tag` varchar(16) NOT NULL, `created` int(11) NOT NULL, `downloads` int(11) NOT NULL DEFAULT '0', `rating` int(11) NOT NULL DEFAULT '0', `download_link` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); - $data = $queries->createTable("resources_comments", " `id` int(11) NOT NULL AUTO_INCREMENT, `resource_id` int(11) NOT NULL, `author_id` int(11) NOT NULL, `content` mediumtext NOT NULL, `release_tag` varchar(16) NOT NULL, `created` int(11) NOT NULL, `reply_id` int(11) DEFAULT NULL, `rating` int(11) NOT NULL DEFAULT '0', `hidden` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); - $data = $queries->createTable("resources_categories_permissions", " `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) NOT NULL, `group_id` int(11) NOT NULL, `view` tinyint(1) NOT NULL DEFAULT '1', `post` tinyint(1) NOT NULL DEFAULT '1', `move_resource` tinyint(1) NOT NULL DEFAULT '1', `edit_resource` tinyint(1) NOT NULL DEFAULT '1', `delete_resource` tinyint(1) NOT NULL DEFAULT '1', `edit_review` tinyint(1) NOT NULL DEFAULT '1', `delete_review` tinyint(1) NOT NULL DEFAULT '1', `download` tinyint(1) NOT NULL DEFAULT '0', `premium` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); - $data = $queries->createTable("resources_payments", " `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `resource_id` int(11) NOT NULL, `transaction_id` varchar(32) NOT NULL, `created` int(11) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); - $data = $queries->createTable("resources_users_premium_details", " `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `paypal_email` varchar(256) DEFAULT NULL, PRIMARY KEY (`id`)", "ENGINE=$engine DEFAULT CHARSET=$charset"); + DB::getInstance()->createTable("resources_categories", " `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(32) NOT NULL, `description` text, `display_order` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)"); + DB::getInstance()->createTable("resources", " `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) NOT NULL, `creator_id` int(11) NOT NULL, `name` varchar(64) NOT NULL, `short_description` varchar(64) NULL DEFAULT NULL, `has_icon` tinyint(1) NOT NULL DEFAULT '0', `icon` varchar(512) NULL DEFAULT NULL, `icon_updated` int(11) NOT NULL DEFAULT '0', `description` mediumtext NOT NULL, `contributors` text, `views` int(11) NOT NULL DEFAULT '0', `downloads` int(11) NOT NULL DEFAULT '0', `created` int(11) NOT NULL, `updated` int(11) NOT NULL, `github_url` varchar(128) DEFAULT NULL, `github_username` varchar(64) DEFAULT NULL, `github_repo_name` varchar(64) DEFAULT NULL, `rating` int(11) NOT NULL DEFAULT '0', `latest_version` varchar(32) DEFAULT NULL, `type` tinyint(1) NOT NULL DEFAULT '0', `price` varchar(16) DEFAULT NULL, `payment_email` varchar(256) DEFAULT NULL, PRIMARY KEY (`id`)"); + DB::getInstance()->createTable("resources_releases", " `id` int(11) NOT NULL AUTO_INCREMENT, `resource_id` int(11) NOT NULL, `category_id` int(11) NOT NULL, `release_title` varchar(128) NOT NULL, `release_description` mediumtext NOT NULL, `release_tag` varchar(16) NOT NULL, `created` int(11) NOT NULL, `downloads` int(11) NOT NULL DEFAULT '0', `rating` int(11) NOT NULL DEFAULT '0', `download_link` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`)"); + DB::getInstance()->createTable("resources_comments", " `id` int(11) NOT NULL AUTO_INCREMENT, `resource_id` int(11) NOT NULL, `author_id` int(11) NOT NULL, `content` mediumtext NOT NULL, `release_tag` varchar(16) NOT NULL, `created` int(11) NOT NULL, `reply_id` int(11) DEFAULT NULL, `rating` int(11) NOT NULL DEFAULT '0', `hidden` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)"); + DB::getInstance()->createTable("resources_categories_permissions", " `id` int(11) NOT NULL AUTO_INCREMENT, `category_id` int(11) NOT NULL, `group_id` int(11) NOT NULL, `view` tinyint(1) NOT NULL DEFAULT '1', `post` tinyint(1) NOT NULL DEFAULT '1', `move_resource` tinyint(1) NOT NULL DEFAULT '1', `edit_resource` tinyint(1) NOT NULL DEFAULT '1', `delete_resource` tinyint(1) NOT NULL DEFAULT '1', `edit_review` tinyint(1) NOT NULL DEFAULT '1', `delete_review` tinyint(1) NOT NULL DEFAULT '1', `download` tinyint(1) NOT NULL DEFAULT '0', `premium` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)"); + DB::getInstance()->createTable("resources_payments", " `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `resource_id` int(11) NOT NULL, `transaction_id` varchar(32) NOT NULL, `created` int(11) NOT NULL, `status` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)"); + DB::getInstance()->createTable("resources_users_premium_details", " `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `paypal_email` varchar(256) DEFAULT NULL, PRIMARY KEY (`id`)"); } catch(Exception $e){ // Error } @@ -80,13 +65,13 @@ public function onInstall(){ } public function onUninstall(){ - DB::getInstance()->createQuery('DROP TABLE resources_categories'); - DB::getInstance()->createQuery('DROP TABLE resources'); - DB::getInstance()->createQuery('DROP TABLE resources_releases'); - DB::getInstance()->createQuery('DROP TABLE resources_comments'); - DB::getInstance()->createQuery('DROP TABLE resources_categories_permissions'); - DB::getInstance()->createQuery('DROP TABLE resources_payments'); - DB::getInstance()->createQuery('DROP TABLE resources_users_premium_details'); + DB::getInstance()->query('DROP TABLE resources_categories'); + DB::getInstance()->query('DROP TABLE resources'); + DB::getInstance()->query('DROP TABLE resources_releases'); + DB::getInstance()->query('DROP TABLE resources_comments'); + DB::getInstance()->query('DROP TABLE resources_categories_permissions'); + DB::getInstance()->query('DROP TABLE resources_payments'); + DB::getInstance()->query('DROP TABLE resources_users_premium_details'); } public function onEnable(){ @@ -196,10 +181,10 @@ public function onPageLoad($user, $pages, $cache, $smarty, $navs, $widgets, $tem // Update to 1.6.0 private static function updateTo160($cache) { try { - DB::getInstance()->createQuery('ALTER TABLE `nl2_resources` ADD `short_description` varchar(64) NULL DEFAULT NULL'); - DB::getInstance()->createQuery('ALTER TABLE `nl2_resources` ADD `has_icon` tinyint(1) NOT NULL DEFAULT \'0\''); - DB::getInstance()->createQuery('ALTER TABLE `nl2_resources` ADD `icon` varchar(512) NULL DEFAULT NULL'); - DB::getInstance()->createQuery('ALTER TABLE `nl2_resources` ADD `icon_updated` int(11) NOT NULL DEFAULT \'0\''); + DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `short_description` varchar(64) NULL DEFAULT NULL'); + DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `has_icon` tinyint(1) NOT NULL DEFAULT \'0\''); + DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `icon` varchar(512) NULL DEFAULT NULL'); + DB::getInstance()->query('ALTER TABLE `nl2_resources` ADD `icon_updated` int(11) NOT NULL DEFAULT \'0\''); $cache->store('160', true); diff --git a/upload/modules/Resources/pages/resources/author.php b/upload/modules/Resources/pages/resources/author.php index 2e60502..6b73cb6 100644 --- a/upload/modules/Resources/pages/resources/author.php +++ b/upload/modules/Resources/pages/resources/author.php @@ -74,7 +74,7 @@ $category_count = $category_count->count(); $to_array = [ 'name' => Output::getClean($category->name), - 'link' => URL::build('/resources/category/' . $category->id . '-' . Util::stringToURL($category->name)), + 'link' => URL::build('/resources/category/' . $category->id . '-' . URL::urlSafe($category->name)), 'count' => Output::getClean($category_count) ]; $category_array[] = $to_array; @@ -87,7 +87,7 @@ // Pagination $paginator = new Paginator((isset($template_pagination) ? $template_pagination : [])); $results = $paginator->getLimited($latest_releases, 10, $p, count($latest_releases)); -$pagination = $paginator->generate(7, URL::build('/resources/author/' . $author->data()->id . '-' . Util::stringToURL($author->getDisplayname(true)) . '/', true)); +$pagination = $paginator->generate(7, URL::build('/resources/author/' . $author->data()->id . '-' . URL::urlSafe($author->getDisplayname(true)) . '/', true)); $smarty->assign('PAGINATION', $pagination); @@ -112,7 +112,7 @@ if (!isset($releases_array[$results->data[$n]->id])) { $releases_array[$results->data[$n]->id] = [ - 'link' => URL::build('/resources/resource/' . $results->data[$n]->id . '-' . Util::stringToURL($results->data[$n]->name)), + 'link' => URL::build('/resources/resource/' . $results->data[$n]->id . '-' . URL::urlSafe($results->data[$n]->name)), 'name' => Output::getClean($results->data[$n]->name), 'short_description' => Output::getClean($results->data[$n]->short_description), 'description' => mb_substr(strip_tags(Output::getDecoded($results->data[$n]->description)), 0, 50) . '...', @@ -137,7 +137,7 @@ if($results->data[$n]->has_icon == 1 ) { $releases_array[$results->data[$n]->id]['icon'] = $results->data[$n]->icon; } else { - $releases_array[$results->data[$n]->id]['icon'] = rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; + $releases_array[$results->data[$n]->id]['icon'] = rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; } } diff --git a/upload/modules/Resources/pages/resources/category.php b/upload/modules/Resources/pages/resources/category.php index 4949d60..fee14eb 100644 --- a/upload/modules/Resources/pages/resources/category.php +++ b/upload/modules/Resources/pages/resources/category.php @@ -49,9 +49,9 @@ $current_category = $current_category->first(); $sort_types = []; -$sort_types['updated'] = ['type' => 'updated', 'sort' => $resource_language->get('resources', 'last_updated'), 'link' => URL::build('/resources/category/' . $current_category->id . '-' . Util::stringToURL($current_category->name), 'sort=updated')]; -$sort_types['newest'] = ['type' => 'created', 'sort' => $resource_language->get('resources', 'newest'), 'link' => URL::build('/resources/category/' . $current_category->id . '-' . Util::stringToURL($current_category->name), 'sort=newest')]; -$sort_types['downloads'] = ['type' => 'downloads', 'sort' => $resource_language->get('resources', 'downloads'), 'link' => URL::build('/resources/category/' . $current_category->id . '-' . Util::stringToURL($current_category->name), 'sort=downloads')]; +$sort_types['updated'] = ['type' => 'updated', 'sort' => $resource_language->get('resources', 'last_updated'), 'link' => URL::build('/resources/category/' . $current_category->id . '-' . URL::urlSafe($current_category->name), 'sort=updated')]; +$sort_types['newest'] = ['type' => 'created', 'sort' => $resource_language->get('resources', 'newest'), 'link' => URL::build('/resources/category/' . $current_category->id . '-' . URL::urlSafe($current_category->name), 'sort=newest')]; +$sort_types['downloads'] = ['type' => 'downloads', 'sort' => $resource_language->get('resources', 'downloads'), 'link' => URL::build('/resources/category/' . $current_category->id . '-' . URL::urlSafe($current_category->name), 'sort=downloads')]; if(isset($_GET['sort']) && array_key_exists($_GET['sort'], $sort_types)){ $sort_type = $_GET['sort']; @@ -61,7 +61,7 @@ } else { $sort_by = 'updated'; $sort_by_text = $resource_language->get('resources', 'last_updated'); - $url = URL::build('/resources/category/' . $current_category->id . '-' . Util::stringToURL($current_category->name), ''); + $url = URL::build('/resources/category/' . $current_category->id . '-' . URL::urlSafe($current_category->name), ''); } if ($user->isLoggedIn()) { @@ -91,7 +91,7 @@ $category_count = $category_count->count(); $to_array = [ 'name' => Output::getClean($category->name), - 'link' => URL::build('/resources/category/' . $category->id . '-' . Util::stringToURL($category->name)), + 'link' => URL::build('/resources/category/' . $category->id . '-' . URL::urlSafe($category->name)), 'count' => Output::getClean($category_count) ]; if($current_category->id == $category->id){ @@ -132,7 +132,7 @@ if (!isset($releases_array[$resource->id])) { $resource_author = new User($resource->creator_id); $releases_array[$resource->id] = [ - 'link' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'link' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'name' => Output::getClean($resource->name), 'short_description' => Output::getClean($resource->short_description), 'description' => mb_substr(strip_tags(Output::getPurified(Output::getDecoded($resource->description))), 0, 50) . '...', @@ -157,7 +157,7 @@ if($resource->has_icon == 1 ) { $releases_array[$resource->id]['icon'] = $resource->icon; } else { - $releases_array[$resource->id]['icon'] = rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; + $releases_array[$resource->id]['icon'] = rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; } } diff --git a/upload/modules/Resources/pages/resources/icon_upload.php b/upload/modules/Resources/pages/resources/icon_upload.php index 212c855..de11b8e 100644 --- a/upload/modules/Resources/pages/resources/icon_upload.php +++ b/upload/modules/Resources/pages/resources/icon_upload.php @@ -72,12 +72,12 @@ } DB::getInstance()->update('resources', $resource->id, [ - 'icon' => rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/'. $resource->id . '.' . $upload->getMime(), + 'icon' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/'. $resource->id . '.' . $upload->getMime(), 'has_icon' => 1, 'icon_updated' => date('U') ]); - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } else { http_response_code(400); diff --git a/upload/modules/Resources/pages/resources/index.php b/upload/modules/Resources/pages/resources/index.php index 2bce5a8..850949e 100644 --- a/upload/modules/Resources/pages/resources/index.php +++ b/upload/modules/Resources/pages/resources/index.php @@ -70,7 +70,7 @@ $category_count = $category_count->count(); $category_array[] = [ 'name' => Output::getClean($category->name), - 'link' => URL::build('/resources/category/' . $category->id . '-' . Util::stringToURL($category->name)), + 'link' => URL::build('/resources/category/' . $category->id . '-' . URL::urlSafe($category->name)), 'count' => Output::getClean($category_count) ]; } @@ -108,7 +108,7 @@ if(!isset($releases_array[$resource->id])){ $resource_author = new User($resource->creator_id); $releases_array[$resource->id] = [ - 'link' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'link' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'name' => Output::getClean($resource->name), 'short_description' => Output::getClean($resource->short_description), 'description' => mb_substr(strip_tags(Output::getDecoded($resource->description)), 0, 60) . '...', @@ -132,7 +132,7 @@ if ($resource->has_icon == 1) { $releases_array[$resource->id]['icon'] = $resource->icon; } else { - $releases_array[$resource->id]['icon'] = rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; + $releases_array[$resource->id]['icon'] = rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; } } diff --git a/upload/modules/Resources/pages/resources/new.php b/upload/modules/Resources/pages/resources/new.php index 58266e0..d332d3f 100644 --- a/upload/modules/Resources/pages/resources/new.php +++ b/upload/modules/Resources/pages/resources/new.php @@ -262,7 +262,7 @@ 'content_full' => str_replace(' ', '', strip_tags(Output::getDecoded($content))), 'avatar_url' => $user->getAvatar(128, true), 'title' => Output::getClean($_SESSION['new_resource']['name']), - 'url' => rtrim(Util::getSelfURL(), '/') . URL::build('/resources/resource/' . $resource_id . '-' . Util::stringToURL(Output::getClean($_SESSION['new_resource']['name']))) + 'url' => rtrim(URL::getSelfURL(), '/') . URL::build('/resources/resource/' . $resource_id . '-' . URL::urlSafe(Output::getClean($_SESSION['new_resource']['name']))) ]); unset($_SESSION['new_resource']); @@ -479,7 +479,7 @@ 'content_full' => str_replace(' ', '', strip_tags(Output::getDecoded($content))), 'avatar_url' => $user->getAvatar(128, true), 'title' => Output::getClean($_SESSION['new_resource']['name']), - 'url' => rtrim(Util::getSelfURL(), '/') . URL::build('/resources/resource/' . $resource_id . '-' . Util::stringToURL(Output::getClean($_SESSION['new_resource']['name']))) + 'url' => rtrim(URL::getSelfURL(), '/') . URL::build('/resources/resource/' . $resource_id . '-' . URL::urlSafe(Output::getClean($_SESSION['new_resource']['name']))) ]); unset($_SESSION['new_resource']); @@ -582,7 +582,7 @@ 'content_full' => str_replace(' ', '', strip_tags(Output::getDecoded($content))), 'avatar_url' => $user->getAvatar(128, true), 'title' => Output::getClean($_SESSION['new_resource']['name']), - 'url' => rtrim(Util::getSelfURL(), '/') . URL::build('/resources/resource/' . $resource_id . '-' . Util::stringToURL(Output::getClean($_SESSION['new_resource']['name']))) + 'url' => rtrim(URL::getSelfURL(), '/') . URL::build('/resources/resource/' . $resource_id . '-' . URL::urlSafe(Output::getClean($_SESSION['new_resource']['name']))) ]); unset($_SESSION['new_resource']); diff --git a/upload/modules/Resources/pages/resources/purchase.php b/upload/modules/Resources/pages/resources/purchase.php index 9630c25..2b59997 100644 --- a/upload/modules/Resources/pages/resources/purchase.php +++ b/upload/modules/Resources/pages/resources/purchase.php @@ -63,7 +63,7 @@ if($already_purchased == 0 || $already_purchased == 1){ // Already purchased - Redirect::to(URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name)))); + Redirect::to(URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name)))); } } @@ -75,7 +75,7 @@ if(!isset($_SESSION['resource_purchasing'])){ // Error, resource ID has been lost Session::flash('purchase_resource_error', $resource_language->get('resources', 'sorry_please_try_again')); - Redirect::to(URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name)))); + Redirect::to(URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name)))); } else { $paymentId = $_GET['paymentId']; @@ -92,7 +92,7 @@ } catch(Exception $e){ Session::flash('purchase_resource_error', $resource_language->get('resources', 'error_while_purchasing')); ErrorHandler::logCustomError($e->getMessage()); - Redirect::to(URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name)))); + Redirect::to(URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name)))); } if(isset($already_purchased_id) && $already_purchased == 2){ @@ -168,8 +168,8 @@ $transaction->setDescription(Output::getClean($resource->name)); $redirectUrls = new \PayPal\Api\RedirectUrls(); - $redirectUrls->setReturnUrl(rtrim(Util::getSelfURL(), '/') . URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name)) . '/', 'do=complete')) - ->setCancelUrl(rtrim(Util::getSelfURL(), '/') . URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name)) . '/', 'do=cancel')); + $redirectUrls->setReturnUrl(rtrim(URL::getSelfURL(), '/') . URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name)) . '/', 'do=complete')) + ->setCancelUrl(rtrim(URL::getSelfURL(), '/') . URL::build('/resources/purchase/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name)) . '/', 'do=cancel')); $payment = new \PayPal\Api\Payment(); $payment->setIntent('sale') @@ -204,7 +204,7 @@ $smarty->assign([ 'PURCHASING_RESOURCE' => $resource_language->get('resources', 'purchasing_resource_x', ['resource' => Output::getClean($resource->name)]), 'PURCHASE_COMPLETE' => $resource_language->get('resources', 'purchase_complete'), - 'BACK_LINK' => URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name))), + 'BACK_LINK' => URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name))), 'BACK' => $language->get('general', 'back') ]); @@ -213,7 +213,7 @@ $smarty->assign([ 'PURCHASING_RESOURCE' => $resource_language->get('resources', 'purchasing_resource_x', ['resource' => Output::getClean($resource->name)]), 'PURCHASE_CANCELLED' => $resource_language->get('resources', 'purchase_cancelled'), - 'BACK_LINK' => URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name))), + 'BACK_LINK' => URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name))), 'BACK' => $language->get('general', 'back') ]); @@ -237,7 +237,7 @@ 'PURCHASING_RESOURCE' => $resource_language->get('resources', 'purchasing_resource_x', ['resource' => Output::getClean($resource->name)]), 'CANCEL' => $language->get('general', 'cancel'), 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), - 'CANCEL_LINK' => URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . Util::stringToURL($resource->name))), + 'CANCEL_LINK' => URL::build('/resources/resource/' . Output::getClean($resource->id . '-' . URL::urlSafe($resource->name))), 'PRE_PURCHASE_INFO' => $pre_purchase_info, 'PURCHASE' => $resource_language->get('resources', 'purchase'), 'TOKEN' => Token::get() diff --git a/upload/modules/Resources/pages/resources/resource.php b/upload/modules/Resources/pages/resources/resource.php index da9fab6..1256109 100644 --- a/upload/modules/Resources/pages/resources/resource.php +++ b/upload/modules/Resources/pages/resources/resource.php @@ -211,7 +211,7 @@ $cache->setCache('resource-comments-' . $resource->id); $cache->erase('comments'); - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } } else { @@ -247,7 +247,7 @@ // Pagination $paginator = new Paginator((isset($template_pagination) ? $template_pagination : [])); $results = $paginator->getLimited($comments, 10, $p, count($comments)); - $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . Util::stringtoURL($resource->name) . '/', true)); + $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', true)); if(count($comments)) $smarty->assign('PAGINATION', $pagination); @@ -285,7 +285,7 @@ 'replies' => (isset($replies_array[$results->data[$n]->id]) ? $replies_array[$results->data[$n]->id] : []), 'rating' => $results->data[$n]->rating, 'release_tag' => Output::getClean($results->data[$n]->release_tag), - 'delete_link' => (isset($can_delete_reviews) ? URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=delete_review&review=' . $results->data[$n]->id) : '') + 'delete_link' => (isset($can_delete_reviews) ? URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=delete_review&review=' . $results->data[$n]->id) : '') ]; } @@ -316,18 +316,18 @@ 'CHANGE_ICON_ACTION' => URL::build('/resources/icon_upload'), 'BACK_LINK' => URL::build('/resources'), 'OVERVIEW_TITLE' => $resource_language->get('resources', 'overview'), - 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'RELEASES_TITLE' => $resource_language->get('resources', 'releases_x', ['count' => Output::getClean($releases)]), 'VERSIONS_TITLE' => $resource_language->get('resources', 'versions_x', ['count' => Output::getClean($releases)]), - 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions'), + 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'versions'), 'REVIEWS_TITLE' => $resource_language->get('resources', 'reviews_x', ['count' => Output::getClean($reviews)]), - 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'reviews'), + 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'reviews'), 'RESOURCE_NAME' => Output::getClean($resource->name), 'RESOURCE_ID' => Output::getClean($resource->id), 'RESOURCE_SHORT_DESCRIPTION' => Output::getClean($resource->short_description), 'RESOURCE_INDEX' => $resource_language->get('resources', 'resource_index'), 'AUTHOR' => $resource_language->get('resources', 'author'), - 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . Util::stringToURL($author->getDisplayname(true))), + 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . URL::urlSafe($author->getDisplayname(true))), 'VIEW_OTHER_RESOURCES' => $resource_language->get('resources', 'view_other_resources', ['user' => $author->getDisplayname()]), 'DESCRIPTION' => Output::getPurified(Output::getDecoded($resource->description)), 'CREATED' => $timeago->inWords(date('d M Y, H:i', $resource->created), $language), @@ -356,7 +356,7 @@ 'RATING' => $resource_language->get('resources', 'rating'), 'RATING_VALUE' => round($resource->rating / 10), 'OTHER_RELEASES' => $resource_language->get('resources', 'other_releases'), - 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=all'), + 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=all'), 'RELEASE' => $resource_language->get('resources', 'release'), 'RELEASE_TITLE' => Output::getClean($latest_update->release_title), 'RELEASE_DESCRIPTION' => Output::getPurified(Output::getDecoded($latest_update->release_description)), @@ -385,7 +385,7 @@ ]); } else { $smarty->assign([ - 'RESOURCE_ICON' => rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' + 'RESOURCE_ICON' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' ]); } @@ -405,7 +405,7 @@ if ($resources->canDownloadResourceFromCategory($groups, $resource->category_id)) { $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } } else { @@ -416,7 +416,7 @@ // Author can download their own resources $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } else { @@ -430,7 +430,7 @@ // Purchased $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } else if($paid->status == 0){ @@ -443,7 +443,7 @@ // Cancelled $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } @@ -451,7 +451,7 @@ // Needs to purchase $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } } @@ -469,7 +469,7 @@ $smarty->assign([ 'CAN_UPDATE' => true, 'UPDATE' => $resource_language->get('resources', 'update'), - 'UPDATE_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=update') + 'UPDATE_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=update') ]); } @@ -478,7 +478,7 @@ $smarty->assign([ 'CAN_EDIT' => true, 'EDIT' => $language->get('general', 'edit'), - 'EDIT_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=edit'), + 'EDIT_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=edit'), 'CHANGE_ICON' => $resource_language->get('resources', 'resource_change_icon') ]); } @@ -487,20 +487,20 @@ $moderation = []; if($resources->canMoveResources($resource->category_id, $groups)){ $moderation[] = [ - 'link' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=move'), + 'link' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=move'), 'title' => $resource_language->get('resources', 'move_resource') ]; } if($resources->canDeleteResources($resource->category_id, $groups)){ $moderation[] = [ - 'link' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=delete'), + 'link' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=delete'), 'title' => $resource_language->get('resources', 'delete_resource') ]; } if (Resources::canManageLicenses($resource->id, $user)) { $moderation[] = [ - 'link' => URL::build('/user/resources/licenses/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'link' => URL::build('/user/resources/licenses/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'title' => $resource_language->get('resources', 'manage_licenses') ]; } @@ -539,7 +539,7 @@ // Pagination $paginator = new Paginator((isset($template_pagination) ? $template_pagination : [])); $results = $paginator->getLimited($comments, 10, $p, count($comments)); - $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'reviews=all&')); + $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'reviews=all&')); if(count($comments)) $smarty->assign('PAGINATION', $pagination); @@ -568,7 +568,7 @@ 'replies' => (isset($replies_array[$results->data[$n]->id]) ? $replies_array[$results->data[$n]->id] : []), 'rating' => $results->data[$n]->rating, 'release_tag' => Output::getClean($results->data[$n]->release_tag), - 'delete_link' => (isset($can_delete_reviews) ? URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=delete_review&review=' . $results->data[$n]->id) : '') + 'delete_link' => (isset($can_delete_reviews) ? URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=delete_review&review=' . $results->data[$n]->id) : '') ]; } $n++; @@ -611,7 +611,7 @@ 'RESOURCE_SHORT_DESCRIPTION' => Output::getClean($resource->short_description), 'COMMENT_ARRAY' => $comments_array, 'AUTHOR' => $resource_language->get('resources', 'author'), - 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . Util::stringToURL($author->getDisplayname(true))), + 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . URL::urlSafe($author->getDisplayname(true))), 'VIEW_OTHER_RESOURCES' => $resource_language->get('resources', 'view_other_resources', ['user' => $author->getDisplayname()]), 'AUTHOR_NICKNAME' => $author->getDisplayname(), 'AUTHOR_NAME' => $author->getDisplayname(true), @@ -620,14 +620,14 @@ 'AUTHOR_PROFILE' => URL::build('/profile/' . $author->getDisplayname(true)), 'NO_REVIEWS' => $resource_language->get('resources', 'no_reviews'), 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'OVERVIEW_TITLE' => $resource_language->get('resources', 'overview'), - 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'RELEASES_TITLE' => $resource_language->get('resources', 'releases_x', ['count' => Output::getClean($releases)]), 'VERSIONS_TITLE' => $resource_language->get('resources', 'versions_x', ['count' => Output::getClean($releases)]), - 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions'), + 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'versions'), 'REVIEWS_TITLE' => $resource_language->get('resources', 'reviews_x', ['count' => Output::getClean($reviews)]), - 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'reviews'), + 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'reviews'), 'RESOURCE' => $resource_language->get('resources', 'resource'), 'FIRST_RELEASE' => $resource_language->get('resources', 'first_release'), 'FIRST_RELEASE_DATE' => date('d M Y', $resource->created), @@ -644,7 +644,7 @@ 'RATING' => $resource_language->get('resources', 'rating'), 'RATING_VALUE' => round($resource->rating / 10), 'OTHER_RELEASES' => $resource_language->get('resources', 'other_releases'), - 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=all'), + 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=all'), 'RELEASE' => $resource_language->get('resources', 'release'), 'RELEASE_TITLE' => Output::getClean($latest_update->release_title), 'RELEASE_DESCRIPTION' => Output::getPurified(Output::getDecoded($latest_update->release_description)), @@ -663,7 +663,7 @@ ]); } else { $smarty->assign([ - 'RESOURCE_ICON' => rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' + 'RESOURCE_ICON' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' ]); } @@ -673,7 +673,7 @@ if ($resources->canDownloadResourceFromCategory($groups, $resource->category_id)) { $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } } else { @@ -684,7 +684,7 @@ // Author can download their own resources $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } else { @@ -698,7 +698,7 @@ // Purchased $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } else if($paid->status == 0){ @@ -711,7 +711,7 @@ // Cancelled $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } @@ -719,7 +719,7 @@ // Needs to purchase $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } } @@ -740,7 +740,7 @@ $release_count = $releases->count(); if (!$release_count) { - Redirect::to('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)); + Redirect::to('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)); } $releases = $releases->results(); @@ -748,7 +748,7 @@ // Pagination $paginator = new Paginator((isset($template_pagination) ? $template_pagination : [])); $results = $paginator->getLimited($releases, 10, $p, $release_count); - $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions=all&')); + $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'versions=all&')); $smarty->assign('PAGINATION', $pagination); @@ -757,8 +757,8 @@ foreach($results->data as $release){ $releases_array[] = [ 'id' => $release->id, - 'url' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=' . $release->id), - 'download_url' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download&release=' . $release->id), + 'url' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=' . $release->id), + 'download_url' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download&release=' . $release->id), 'tag' => Output::getClean($release->release_tag), 'name' => Output::getClean($release->release_title), 'description' => Output::getPurified(nl2br(Output::getDecoded($release->release_description))), @@ -804,7 +804,7 @@ 'RESOURCE_NAME' => Output::getClean($resource->name), 'RESOURCE_SHORT_DESCRIPTION' => Output::getClean($resource->short_description), 'AUTHOR' => $resource_language->get('resources', 'author'), - 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . Util::stringToURL($author->getDisplayname(true))), + 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . URL::urlSafe($author->getDisplayname(true))), 'VIEW_OTHER_RESOURCES' => $resource_language->get('resources', 'view_other_resources', ['user' => $author->getDisplayname()]), 'AUTHOR_NICKNAME' => $author->getDisplayname(), 'AUTHOR_NAME' => $author->getDisplayname(true), @@ -813,14 +813,14 @@ 'AUTHOR_PROFILE' => URL::build('/profile/' . $author->getDisplayname(true)), 'RELEASES' => $releases_array, 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'OVERVIEW_TITLE' => $resource_language->get('resources', 'overview'), - 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'RELEASES_TITLE' => $resource_language->get('resources', 'releases_x', ['count' => Output::getClean($releases)]), 'VERSIONS_TITLE' => $resource_language->get('resources', 'versions_x', ['count' => Output::getClean($releases)]), - 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions'), + 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'versions'), 'REVIEWS_TITLE' => $resource_language->get('resources', 'reviews_x', ['count' => Output::getClean($reviews)]), - 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'reviews'), + 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'reviews'), 'RESOURCE' => $resource_language->get('resources', 'resource'), 'FIRST_RELEASE' => $resource_language->get('resources', 'first_release'), 'FIRST_RELEASE_DATE' => date('d M Y', $resource->created), @@ -837,7 +837,7 @@ 'RATING' => $resource_language->get('resources', 'rating'), 'RATING_VALUE' => round($resource->rating / 10), 'OTHER_RELEASES' => $resource_language->get('resources', 'other_releases'), - 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=all'), + 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=all'), 'RELEASE' => $resource_language->get('resources', 'release'), 'RELEASE_TITLE' => Output::getClean($latest_update->release_title), 'RELEASE_DESCRIPTION' => Output::getPurified(Output::getDecoded($latest_update->release_description)), @@ -856,7 +856,7 @@ ]); } else { $smarty->assign([ - 'RESOURCE_ICON' => rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' + 'RESOURCE_ICON' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' ]); } @@ -866,7 +866,7 @@ if ($resources->canDownloadResourceFromCategory($groups, $resource->category_id)) { $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } } else { @@ -877,7 +877,7 @@ // Author can download their own resources $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } else { @@ -891,7 +891,7 @@ // Purchased $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download') + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download') ]); } else if($paid->status == 0){ @@ -904,7 +904,7 @@ // Cancelled $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } @@ -912,7 +912,7 @@ // Needs to purchase $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } } @@ -933,14 +933,14 @@ $releases = DB::getInstance()->orderWhere('resources_releases', 'resource_id = ' . $resource->id, 'created', 'DESC')->results(); if (!count($releases)){ - Redirect::to('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)); + Redirect::to('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)); die(); } // Pagination $paginator = new Paginator((isset($template_pagination) ? $template_pagination : [])); $results = $paginator->getLimited($releases, 10, $p, count($releases)); - $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=all&')); + $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=all&')); $smarty->assign('PAGINATION', $pagination); @@ -949,7 +949,7 @@ foreach($releases as $release){ $releases_array[] = [ 'id' => $release->id, - 'url' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=' . $release->id), + 'url' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=' . $release->id), 'tag' => Output::getClean($release->release_tag), 'name' => Output::getClean($release->release_title), 'description' => Output::getPurified(nl2br(Output::getDecoded($release->release_description))), @@ -982,7 +982,7 @@ 'RESOURCE_NAME' => Output::getClean($resource->name), 'RESOURCE_SHORT_DESCRIPTION' => Output::getClean($resource->short_description), 'AUTHOR' => $resource_language->get('resources', 'author'), - 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . Util::stringToURL($author->getDisplayname(true))), + 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . URL::urlSafe($author->getDisplayname(true))), 'VIEW_OTHER_RESOURCES' => $resource_language->get('resources', 'view_other_resources', ['user' => $author->getDisplayname()]), 'AUTHOR_NICKNAME' => $author->getDisplayname(), 'AUTHOR_NAME' => $author->getDisplayname(true), @@ -990,12 +990,12 @@ 'AUTHOR_AVATAR' => $author->getAvatar(), 'AUTHOR_PROFILE' => URL::build('/profile/' . $author->getDisplayname(true)), 'OVERVIEW_TITLE' => $resource_language->get('resources', 'overview'), - 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'RELEASES_TITLE' => $resource_language->get('resources', 'releases_x', ['count' => Output::getClean($releases)]), 'VERSIONS_TITLE' => $resource_language->get('resources', 'versions_x', ['count' => Output::getClean($releases)]), - 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions'), + 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'versions'), 'REVIEWS_TITLE' => $resource_language->get('resources', 'reviews_x', ['count' => Output::getClean($reviews)]), - 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'reviews'), + 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'reviews'), 'RESOURCE' => $resource_language->get('resources', 'resource'), 'FIRST_RELEASE' => $resource_language->get('resources', 'first_release'), 'FIRST_RELEASE_DATE' => date('d M Y', $resource->created), @@ -1011,7 +1011,7 @@ 'RATING' => $resource_language->get('resources', 'rating'), 'RATING_VALUE' => round($resource->rating / 10), 'OTHER_RELEASES' => $resource_language->get('resources', 'other_releases'), - 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=all'), + 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=all'), 'RELEASE' => $resource_language->get('resources', 'release'), 'RELEASE_TITLE' => Output::getClean($latest_update->release_title), 'RELEASE_DESCRIPTION' => Output::getPurified(Output::getDecoded($latest_update->release_description)), @@ -1022,7 +1022,7 @@ 'RELEASE_DATE' => $timeago->inWords(date('d M Y, H:i', $latest_update->created), $language), 'RELEASE_DATE_FULL' => date('d M Y, H:i', $latest_update->created), 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)) + 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)) ]); // Check if resource icon uploaded @@ -1032,7 +1032,7 @@ ]); } else { $smarty->assign([ - 'RESOURCE_ICON' => rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' + 'RESOURCE_ICON' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' ]); } @@ -1071,19 +1071,19 @@ 'RESOURCE_SHORT_DESCRIPTION' => Output::getClean($resource->short_description), 'RESOURCE_NAME' => Output::getClean($resource->name), 'BACK' => $language->get('general', 'back'), - 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'BACK_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'OVERVIEW_TITLE' => $resource_language->get('resources', 'overview'), - 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'OVERVIEW_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'RELEASES_TITLE' => $resource_language->get('resources', 'releases_x', ['count' => Output::getClean($releases)]), 'VERSIONS_TITLE' => $resource_language->get('resources', 'versions_x', ['count' => Output::getClean($releases)]), - 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions'), + 'VERSIONS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'versions'), 'REVIEWS_TITLE' => $resource_language->get('resources', 'reviews_x', ['count' => Output::getClean($reviews)]), - 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'reviews'), + 'REVIEWS_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'reviews'), 'DOWNLOADS' => $resource_language->get('resources', 'x_downloads', ['count' => $release->downloads]), 'RATING' => round($release->rating / 10), 'DESCRIPTION' => Output::getPurified(nl2br(Output::getDecoded($release->release_description))), 'AUTHOR' => $resource_language->get('resources', 'author'), - 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . Util::stringToURL($author->getDisplayname(true))), + 'AUTHOR_RESOURCES' => URL::build('/resources/author/' . $resource->creator_id . '-' . URL::urlSafe($author->getDisplayname(true))), 'VIEW_OTHER_RESOURCES' => $resource_language->get('resources', 'view_other_resources', ['user' => $author->getDisplayname()]), 'AUTHOR_NICKNAME' => $author->getDisplayname(), 'AUTHOR_NAME' => $author->getDisplayname(true), @@ -1105,7 +1105,7 @@ 'RATING' => $resource_language->get('resources', 'rating'), 'RATING_VALUE' => round($resource->rating / 10), 'OTHER_RELEASES' => $resource_language->get('resources', 'other_releases'), - 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=all'), + 'OTHER_RELEASES_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'releases=all'), 'RELEASE' => $resource_language->get('resources', 'release'), 'RELEASE_TITLE' => Output::getClean($latest_update->release_title), 'RELEASE_DESCRIPTION' => Output::getPurified(Output::getDecoded($latest_update->release_description)), @@ -1126,7 +1126,7 @@ ]); } else { $smarty->assign([ - 'RESOURCE_ICON' => rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' + 'RESOURCE_ICON' => rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png' ]); } @@ -1147,7 +1147,7 @@ if ($resources->canDownloadResourceFromCategory($groups, $resource->category_id)) { $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download&release=' . $release->id) + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download&release=' . $release->id) ]); } } else { @@ -1158,7 +1158,7 @@ // Author can download their own resources $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download&release=' . $release->id) + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download&release=' . $release->id) ]); } else { @@ -1172,7 +1172,7 @@ // Purchased $smarty->assign([ 'DOWNLOAD' => $resource_language->get('resources', 'download'), - 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'do=download&release=' . $release->id) + 'DOWNLOAD_URL' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name) . '/', 'do=download&release=' . $release->id) ]); } else if($paid->status == 0){ @@ -1185,7 +1185,7 @@ // Cancelled $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } @@ -1193,7 +1193,7 @@ // Needs to purchase $smarty->assign([ 'PURCHASE_FOR_PRICE' => $resource_language->get('resources', 'purchase_for_x', ['price' => Output::getClean($resource->price) . ' ' . Output::getClean($currency)]), - 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(Util::stringToURL($resource->name))) + 'PURCHASE_LINK' => URL::build('/resources/purchase/' . Output::getClean($resource->id) . '-' . Output::getClean(URL::urlSafe($resource->name))) ]); } } @@ -1626,10 +1626,10 @@ 'content_full' => str_replace(['&', ' ', '''], ['&', '', '\''], strip_tags($content)), 'avatar_url' => $user->getAvatar(128, true), 'title' => Output::getClean($resource->name), - 'url' => Util::getSelfURL() . ltrim(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), '/') + 'url' => URL::getSelfURL() . ltrim(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), '/') ]); - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } } else { $error = $language->get('general', 'invalid_token'); @@ -1692,7 +1692,7 @@ $smarty->assign([ 'UPDATE_RESOURCE' => $resource_language->get('resources', 'update'), 'CANCEL' => $language->get('general', 'cancel'), - 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), 'RELEASE_TYPE' => $resource_language->get('resources', 'release_type'), 'CHOOSE_FILE' => $resource_language->get('resources', 'choose_file'), @@ -1786,7 +1786,7 @@ 'price' => $price ]); - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL(Input::get('title')))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe(Input::get('title')))); } catch(Exception $e){ $errors[] = $e->getMessage(); @@ -1801,7 +1801,7 @@ } } } else { - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } if(isset($errors) && count($errors)) @@ -1831,7 +1831,7 @@ 'RESOURCE_CONTRIBUTORS' => Output::getClean($resource->contributors), 'CANCEL' => $language->get('general', 'cancel'), 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), - 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'TOKEN' => Token::get(), 'SUBMIT' => $language->get('general', 'submit') ]); @@ -1893,7 +1893,7 @@ } } - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } catch (Exception $e) { $errors[] = $e->getMessage(); @@ -1915,7 +1915,7 @@ 'TOKEN' => Token::get(), 'CANCEL' => $language->get('general', 'cancel'), 'CONFIRM_CANCEL' => $language->get('general', 'confirm_cancel'), - 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'SUBMIT' => $language->get('general', 'submit'), 'MOVE_TO' => $resource_language->get('resources', 'move_to') ]); @@ -1923,7 +1923,7 @@ $template_file = 'resources/move.tpl'; } else { - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } } else if($_GET['do'] == 'delete'){ // Check user can delete @@ -1963,14 +1963,14 @@ 'CONFIRM_DELETE_RESOURCE' => $resource_language->get('resources', 'confirm_delete_resource', ['resource' => Output::getClean($resource->name)]), 'TOKEN' => Token::get(), 'CANCEL' => $language->get('general', 'cancel'), - 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'CANCEL_LINK' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'DELETE' => $language->get('general', 'delete') ]); $template_file = 'resources/delete.tpl'; } else { - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } } else if($_GET['do'] == 'delete_review'){ @@ -1980,7 +1980,7 @@ } if($resources->canDeleteReviews($resource->category_id, $groups)){ if(!isset($_GET['review']) || !is_numeric($_GET['review'])){ - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } // Ensure review exists $review = DB::getInstance()->get('resources_comments', ['id', '=', $_GET['review']]); @@ -2066,7 +2066,7 @@ // error } } - Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name))); + Redirect::to(URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name))); } } else { Redirect::to(URL::build('/resources')); diff --git a/upload/modules/Resources/pages/user/resources.php b/upload/modules/Resources/pages/user/resources.php index bc4fb7a..c81cc1c 100644 --- a/upload/modules/Resources/pages/user/resources.php +++ b/upload/modules/Resources/pages/user/resources.php @@ -86,7 +86,7 @@ 'latest_version' => Output::getClean($resource->version), 'updated' => $timeago->inWords($resource->updated, $language), 'updated_full' => date(DATE_FORMAT, $resource->updated), - 'link' => URL::build('/resources/resource/' . Output::getClean($resource->id) . '-' . Util::stringToURL($resource->name)) + 'link' => URL::build('/resources/resource/' . Output::getClean($resource->id) . '-' . URL::urlSafe($resource->name)) ]; } } @@ -99,7 +99,7 @@ $premium_array[] = [ 'name' => Output::getClean($resource->name), 'latest_version' => Output::getClean($resource->version), - 'link' => URL::build('/user/resources/licenses/' . Output::getClean($resource->id) . '-' . Util::stringToURL($resource->name)), + 'link' => URL::build('/user/resources/licenses/' . Output::getClean($resource->id) . '-' . URL::urlSafe($resource->name)), 'license_count' => $purchase_count->count == 1 ? $resource_language->get('resources', '1_license') : $resource_language->get('resources', 'x_licenses', ['count' => $purchase_count->count]) ]; } diff --git a/upload/modules/Resources/paypal_default.php b/upload/modules/Resources/paypal_default.php index 481b9ab..42f64bf 100644 --- a/upload/modules/Resources/paypal_default.php +++ b/upload/modules/Resources/paypal_default.php @@ -31,7 +31,7 @@ $webhookEventTypes[] = new \PayPal\Api\WebhookEventType('{"name":"PAYMENT.SALE.REFUNDED"}'); $webhookEventTypes[] = new \PayPal\Api\WebhookEventType('{"name":"PAYMENT.SALE.REVERSED"}'); - $webhook->setUrl(rtrim(Util::getSelfURL(), '/') . URL::build('/resources/listener/', 'key=' . $key)); + $webhook->setUrl(rtrim(URL::getSelfURL(), '/') . URL::build('/resources/listener/', 'key=' . $key)); $webhook->setEventTypes($webhookEventTypes); $output = $webhook->create($apiContext); $id = $output->getId(); diff --git a/upload/modules/Resources/widgets/LatestResources.php b/upload/modules/Resources/widgets/LatestResources.php index c20acb4..c9504cb 100644 --- a/upload/modules/Resources/widgets/LatestResources.php +++ b/upload/modules/Resources/widgets/LatestResources.php @@ -75,7 +75,7 @@ public function initialise(): void { $latestResourcesArr[$resource->id] = [ 'name' => Output::getClean($resource->name), 'short_description' => Output::getClean($resource->short_description), - 'link' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'link' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'creator_id' => $resource->creator_id, 'creator_username' => $author->getDisplayname(), 'creator_style' => $author->getGroupStyle(), @@ -88,7 +88,7 @@ public function initialise(): void { if($resource->has_icon == 1 ) { $latestResourcesArr[$resource->id]['icon'] = Output::getClean($resource->icon); } else { - $latestResourcesArr[$resource->id]['icon'] = rtrim(Util::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; + $latestResourcesArr[$resource->id]['icon'] = rtrim(URL::getSelfURL(), '/') . (defined('CONFIG_PATH') ? CONFIG_PATH . '/' : '/') . 'uploads/resources_icons/default.png'; } } diff --git a/upload/modules/Resources/widgets/TopResources.php b/upload/modules/Resources/widgets/TopResources.php index 1e1d33d..9f78a59 100644 --- a/upload/modules/Resources/widgets/TopResources.php +++ b/upload/modules/Resources/widgets/TopResources.php @@ -75,7 +75,7 @@ public function initialise(): void { $topResourcesArr[$resource->id] = [ 'name' => Output::getClean($resource->name), 'short_description' => Output::getClean($resource->short_description), - 'link' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)), + 'link' => URL::build('/resources/resource/' . $resource->id . '-' . URL::urlSafe($resource->name)), 'creator_id' => $resource->creator_id, 'creator_username' => $author->getDisplayname(), 'creator_style' => $author->getGroupStyle(),