NexusLeads Webshell
NexusLeads


Server : LiteSpeed
System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64
User : alsaif ( 1057)
PHP Version : 7.4.33
Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/alsaif/domains/alsaif.group/private_html/plugins/system/nrframework/helpers/urls/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/alsaif/domains/alsaif.group/private_html/plugins/system/nrframework/helpers/urls/urls.php
<?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;
    }

}

?>

NexusLeads