Your IP : 216.73.216.172


Current Path : /proc/thread-self/root/proc/thread-self/root/proc/1908984/root/tmp/
Upload File :
Current File : //proc/thread-self/root/proc/thread-self/root/proc/1908984/root/tmp/phpGhehMy

home/digilove/public_html/plugins/system/forseo/platform/helpers/urls.php000064400000004206152352676720023107 0ustar00<?php
/**
 * Project: 4SEO
 *
 * @package          4SEO
 * @copyright        Copyright Weeblr llc - 2020-2024
 * @author           Yannick Gaultier - Weeblr llc
 * @license          GNU General Public License version 3; see LICENSE.md
 * @version          6.2.0.2478
 * @date        2024-10-03
 */

namespace Weeblr\Forseo\Platform\Helpers;

use Weeblr\Wblib\Forseo\Base;
use Weeblr\Wblib\Forseo\System;
use Weeblr\Wblib\Forseo\Wb;
use Weeblr\Wblib\Forseo\Joomla\StringHelper\StringHelper;
use Weeblr\Wblib\Forseo\Joomla\Uri;

// no direct access
defined('_JEXEC') || defined('WBLIB_EXEC') || die;

/**
 * Helper to check if a redirect exists for the current requested URL.
 */
class urls extends Base\Base
{
	/**
	 * Redirect a request to the same path and query with the path
	 * converted to lowercase.
	 *
	 * 4SEF/sh404SEF ensures that requests are redirected to the correct
	 * case, not just to lowercase, so we don't want to interfere with that.
	 * Therefore we do not do anything if either of them are running.
	 *
	 */
	public function enforceLowerCaseUrls()
	{
		if (
			!defined('4SEF_IS_RUNNING')
			&&
			!defined('SH404SEF_IS_RUNNING')
			&&
			$this->factory->getThis('forseo.config', 'pages')->isTruthy('enforceLowerCaseUrls')
			&&
			$this->platform->isFrontend()
		)
		{
			$this->doEnforceLowerCaseUrls();
		}
	}

	/**
	 * Actually enforce a possible redirect to the lowercase version of a URL.
	 *
	 * @return void
	 */
	private function doEnforceLowerCaseUrls()
	{
		// must only convert the path, not query or fragment
		$currentUrl = $this->factory
			->getThe('forseo.requestInfo')
			->get('page_url');
		$uri        = $this->factory->getA(
			Uri\Uri::class,
			$currentUrl
		);

		$path          = Wb\lTrim(
			$uri->getPath(),
			$this->platform->getBaseUrl()
		);
		$path          = rawurldecode($path);
		$lowerCasePath = StringHelper::strtolower($path);
		if ($lowerCasePath === $path)
		{
			return;
		}

		$uri->setPath($lowerCasePath);
		$targetUrl = $uri->toString();
		if ($this->platform->canRedirect($currentUrl, $targetUrl))
		{
			// do redirect
			$this->platform->redirectTo(
				$targetUrl,
				System\Http::RETURN_MOVED
			);
		}
	}
}
home/digilove/public_html/plugins/system/nrframework/helpers/urls/urls.php000064400000006326152432211670023301 0ustar00<?php 

/**
 * @author          Tassos Marinos <info@tassos.gr>
 * @link            https://www.tassos.gr
 * @copyright       Copyright © 2024 Tassos All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/

defined('_JEXEC') or die;

use \NRFramework\Cache;

class NRURLs {

    private $url;
    private $shortener;
    private $cache;

    function __construct($url = null)
    {
        if (isset($url)) {
            $this->set($url);
        }

        $this->setCache(true);
    }

    public function set($url)
    {
        $url = trim(filter_var($url, FILTER_SANITIZE_URL));
        return ($this->url = $url);
    }

    public function setCache($state)
    {
        $this->cache = (bool) $state;
    }

    public function setShortener($service)
    {
        $this->shortener = $service;
    }

    public function get()
    {
        return $this->url;
    }

    public function validate($url_ = null)
    {
        $url = isset($url_) ? $url_ : $this->url;

        if (!$url)
        {
            return false;
        }

        // Remove all illegal characters from the URL
        $url = filter_var($url, FILTER_SANITIZE_URL);

        // Validate URL
        if (!filter_var($url, FILTER_VALIDATE_URL) === false) {
            return true;
        }

        return false;
    }

    public function getShort()
    {
        if (!$this->validate() || !isset($this->shortener))
        {
            return false;
        }

        $hash  = MD5($this->shortener->name . $this->url);
        $cache = Cache::read($hash, true);

        if ($cache)
        {
            return $cache;
        }

        // Load Shorten Service Class
        $file   = __DIR__ . "/" . strtolower($this->shortener->name) . '.php';
        $class  = 'nrURLShort' . $this->shortener->name;
        $method = "get";

        require_once(__DIR__ . "/shortener.php");

        if (!class_exists($class) && file_exists($file)) {
            require_once($file);
        }

        if (!class_exists($class) || !method_exists($class, $method))
        {
            return false;
        }

        $class_ = new $class($this->shortener, $this->url);
        $data = $class_->$method();

        // Return the original URL if we don't have a valid short URL
        if (!$this->validate($data))
        {  
            return false;
        }

        Cache::set($hash, $data);

        // Store to cache
        if ($this->cache)
        {
            Cache::write($hash, $data);
        }

        return $data;
    }

    /**
     *  Appends extra parameters to the end of the URL
     *
     *  @param   String  $url     Pass URL
     *  @param   String  $params  String of parameters (param=1&param=2)
     *
     *  @return  string           Returns new url
     */
    public function appendParams($params)
    {

        if (!$params)
        {
            return $this;
        }

        $url = $this->url;

        $query = parse_url($url, PHP_URL_QUERY);
        $params = trim($params, "?");
        $params = trim($params, "&");

        if ($query) 
        {
            $url .= '&' . $params;
        } else 
        {
            $url .= '?' . $params;
        }

        $this->set($url);

        return $this;
    }

}

?>