AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/amisdesseniors-fr/nantes/plugins/system/nrframework/helpers/urls/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/nantes/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 Tassos\Framework\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;
    }

}

?>

Anon7 - 2022
AnonSec Team