AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.94
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/c/o/o/coopiak/amisdesseniors-fr/nice2/components/com_jlexreview/libs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/c/o/o/coopiak/amisdesseniors-fr/nice2/components/com_jlexreview/libs/helper.php
<?php
/**
 * @package     JLex Review
 * @version     4.2.3
 * @copyright   Copyright (c) 2013-2018 JLexArt. All rights reserved
 * @license     GNU General Public License version 2 or later;
 * @author      www.jlexart.com
 */

defined ( "_JEXEC" ) or die;

class JLexReviewHelperSite
{
    /**
     * Shorten string by word length
     *
     * @param string $text            
     * @param int $num            
     * @param string $end            
     * @return string
     */
    public static function subwords($text, $num = 10, $end = '')
    {
        $text = trim(strip_tags(nl2br($text)));
        $words = explode(' ', $text);
        if (count($words) <= $num)
            return $text;
        $subword = array_slice($words, 0, $num);
        $subword = implode(' ', $subword) . '...' . $end;
        return $subword;
    }

    static $emoticons = null;
    
    public static function emoticons(&$string){}

    /**
     * Remove all tags both html and bbcode
     *
     * @param string $str            
     * @return string
     * @since 2.0.0
     */
    public static function mixtoString($str, $html = true)
    {
        $str = preg_replace('#\[[^\]]+\]#', '', $str);
        if ($html)
            $str = strip_tags($str);
        return $str;
    }

    /**
     * Convert and filter mix array to array contain numbers.
     *
     * @param array $array            
     * @return array Array of numbers
     *        
     * @since 2.0.0
     */
    public static function filterNumber($array)
    {
        if (! is_array($array) || count($array) == 0)
            return array();
        $d = array();
        foreach ($array as $i) {
            $i = intval($i);
            if ($i > 0)
                $d[] = $i;
        }
        return $d;
    }

    /**
     * Compare length of strings
     *
     * @param str $string            
     * @param int $limit            
     * @param str $type
     *            : word or str(character)
     * @return boolean
     *
     * @since 2.0.0
     */
    public static function compareLength($string, $limit = 10, $type = 'word')
    {
        if ($type == 'str') {
            if (strlen(trim($string)) < $limit) {
                return false;
            }
            return true;
        }
        $string = explode(' ', trim($string));
        if (count($string) < $limit) {
            return false;
        }
        return true;
    }

    /**
     * Get current URL of browser of client
     *
     * @return string
     * @since 3.2.7
     */
    public static function getReturnURL()
    {
        $uri = JFactory::getURI();
        $url = $uri->toString(array(
            'path',
            'query',
            'fragment'
        ));
        
        return $url;
    }

    /* V4 */
    public static function loadThemes(&$view)
    {
        $app    = JFactory::getApplication();
        $config = JLexReviewHelperAdmin::getConfig();

        $themes = [];
        $subfolder = $view->getName();

        $theme = $config->get("theme","default");
        $default_path = JPATH_ROOT."/components/com_jlexreview/templates/default/".$subfolder;
        $set_path = JPATH_ROOT."/components/com_jlexreview/templates/".$theme."/".$subfolder;
        $css = JPATH_ROOT . "/media/jlexreview/assets/".$theme."_style.css";

        if(JFolder::exists($default_path))
            $themes[]=$default_path;

        if($theme!="default" && JFolder::exists($set_path)) $themes[]=$set_path;

        if(JFile::exists($css))
        {
            $doc = JFactory::getDocument();
            $doc->addStyleSheet(JUri::base(true) . "/media/jlexreview/assets/".$theme."_style.css?v=5.3.5");
        
            // font-awesome
            switch ($config->get('fontawesome','cdn')) {
                case 'cdn':
                    $doc->addStyleSheet('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
                    break;
                
                case 'local':
                    if(!empty($config->get('fontawesome_url')))
                    {
                        $fontUrl = $config->get('fontawesome_url');
                        $fontUrl = preg_match('/^http/', $fontUrl)?$fontUrl:(JUri::root(true).'/'.$fontUrl);
                        $doc->addStyleSheet($fontUrl);
                    }
                    break;
            }
        }

        // adding from template pack
        $tpl_path = JPATH_ROOT . "/templates/" . $app->getTemplate() . "/html/com_jlexreview/" . $theme . "/" . $subfolder;
        if(JFolder::exists($tpl_path))
            $themes[]=$tpl_path;

        // special for reviews
        if($subfolder=="reviews")
        {
            $themes[] = JPATH_ROOT . "/components/com_jlexreview/templates/" . $theme . "/comments";
            $themes[] = JPATH_ROOT . "/templates/" . $app->getTemplate() . "/html/com_jlexreview/" . $theme . "/reviews";
        }

        if(count($themes))
            foreach($themes as $t) $view->addTemplatePath($t);
    }

    public static function formatTime($time, $now, $format = null)
    {
        if($format!=null)
        {
            return JHtml::date($time, $format);
        }

        if ($now==null)
        {
            $now = JFactory::getDate()->toUnix();
        } else {
            $now = JFactory::getDate($now)->toUnix();
        }
        
        $time = JFactory::getDate($time)->toUnix();
        $elstime = $now - $time;

        if ($elstime < 60)
        {
            $return = JText::_("JR_T_RECENT");
        } elseif ($elstime < 3600) {
            $min = intval($elstime/60);
            $return = $min>1 ? JText::plural("JR_T_MINUTES_AGO",$min) : JText::_("JR_T_MINUTE_AGO");
        } elseif ($elstime < 24 * 3600) {
            $hour = intval($elstime / 3600);
            $return = $hour>1 ? JText::plural("JR_T_HOURS_AGO",$hour) : JText::_("JR_T_HOUR_AGO");
        } elseif ($elstime < 24 * 3600 * 30) {
            $day = intval($elstime/(3600*24));
            $return = $day>1 ? JText::plural("JR_T_DAYS_AGO",$day) : JText::_("JR_T_DAY_AGO");;
        } elseif ($elstime < 24 * 3600 * 30 * 12) {
            $month = intval($elstime/(3600*24*30));
            $return = $month>1 ? JText::plural("JR_T_MONTHS_AGO",$month) : JText::_("JR_T_MONTH_AGO");
        } else {
            $year = intval($elstime/(3600*24*30*12));
            $return = $year>1 ? JText::plural("JR_T_YEARS_AGO",$year) : JText::_("JR_T_YEAR_AGO");
        }

        return $return;
    }

    static $profile = null;

    public static function getProfile()
    {
        if(self::$profile==null)
        {
            require_once JPATH_ROOT . '/components/com_jlexreview/libs/profile.php';
            
            $params = JLexReviewHelperAdmin::getConfig();
            self::$profile = new JLexReviewProfile($params->get('3rd', 'jlexreview'));
        }

        return self::$profile;
    }

    static $badWords = null;

    public static function lowWords(&$string)
    {
        $config = JLexReviewHelperAdmin::getConfig();

        if(self::$badWords==null)
        {
            $words = $config->get("bad_words","");

            if($config->get("filter_bad_words",0)==1 && !preg_match("/^\s*$/", $words))
            {
                $words = explode("," , $words);

                if(count($words))
                {
                    foreach($words as $word)
                    {
                        $word = trim($word);
                        if(preg_match("/^\s*$/", $word)) continue;

                        if(strlen($word)==mb_strlen($word, 'utf-8') && $config->get('filter_bad_hide', 2)==2)
                        {
                            $word_encode = '';
                            for($i=0;$i<strlen($word);$i++)
                            {
                                $word_encode.= $i%2==0?$word[$i]:'*';
                            }
                        } else {
                            $word_encode = '***';
                        }

                        self::$badWords[strtolower($word)] = $word_encode;
                    }
                }
            } else {
                self::$badWords = [];
            }
        }

        if(!count(self::$badWords)) return;

        foreach(self::$badWords as $f=>$r)
        {
            if($config->get('filter_bad_method',2)==1)
            {
                $e = ['f'=>$f, 'r'=>$r];
                $string = preg_replace_callback(
                    "/\w+/",
                    function($matches) use($e){
                        if(strtolower($matches[0])==$e['f'])
                            return $e['r'];

                        return $matches[0];
                    },
                    $string);
            } else {
                $string = str_ireplace($f, '<span class="jreview-bad-word">'.$r.'</span>', $string);
            }
        }
    }

    public static function isSubscribe($id, $type=1)
    {
        $session = JFactory::getSession();
        $user    = JFactory::getUser();
        $key     = "item_" . $id . "_" . $type;

        $result  = $session->get($key, false, "jreviewsubscribe" );

        if ($result!=false)
        {
            return $result;
        }

        if ($user->guest)
        {
            return false;
        }

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $query->select("id")
              ->from("#__jlexreview_subscribe")
              ->where(array(
                    "sub_value=" . $db->quote($id),
                    "userid=" . $user->id,
                    "sub_type=" . $type
                ));

        $result = $db->setQuery($query,0,1)->loadResult();

        if (!$result)
        {
            return false;
        }

        return $result;
    }

    public static function hashState()
    {
        $app = JFactory::getApplication();
        $id  = $app->input->getString("id", null);

        if (!preg_match("/^([1-9][0-9]*)(\,([1-9][0-9]*))?$/", $id, $matches))
        {
            return false;
        }

        $config = JLexReviewHelperAdmin::getConfig();
        $emails = explode(",", $config->get("admin_alert_emails", ""));

        if ($config->get("admin_alert",0)==0 || $config->get("admin_alert_quicktask",1)==0)
        {
            return false;
        }

        $hashCorrect = md5("jlexreview-" . implode(",", $emails) . $id);
        $hashRequest = $app->input->getString("hash");

        if ($hashRequest!=$hashCorrect)
        {
            return false;
        }

        $response = new stdClass();
        $response->id       = $id;
        $response->type     = isset($matches[3]) ? "cm" : "review";
        $response->type_id  = isset($matches[3]) ? $matches[3] : $matches[1];

        return $response;
    }

    public static function getUrl ($url, $method = false, $params = null)
    {
        if (! function_exists('curl_init'))
        {
            // ERROR: CURL library not found!');
            return false;
        }
        
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, $method);
        if ($method == true && isset($params)) {
            if (is_array($params))
            {
                $params = http_build_query($params, '', '&');
            }
            curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
        }
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Length: ' . strlen($params),
            'Cache-Control: no-store, no-cache, must-revalidate',
            "Expires: " . date("r")
        ));

        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        
        // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        
        $result = curl_exec($ch);
        curl_close($ch);
        
        return $result;
    }

    public static function getItemInfo ($object, $object_id, $url, $section_id=0, $object_name="")
    {
        JTable::addIncludePath( JPATH_ADMINISTRATOR . "/components/com_jlexreview/tables" );

        $db  = JFactory::getDbo();
        $row = JTable::getInstance("Object", "TableJR");
        $row->load(array(
                "object"    => $object,
                "object_id" => $object_id
            ));

        if ($row->id > 0)
        {
            return $row;
        }

        // create new entry item
        $config  = JLexReviewHelperAdmin::getConfig();
        $query   = $db->getQuery(true);
        $form_id = $config->get("jsection",1);

        $query->select("section_file")
              ->from("#__jlexreview_section")
              ->where(array(
                    "(section_id=0 OR section_id=" . $section_id . ")",
                    $db->quoteName("object") . "=" . $db->quote($object)
                ))
              ->order("section_id ASC");

        $list_form_ids = $db->setQuery($query)->loadObjectList();
        if ($list_form_ids)
        {
            if ($list_form_ids>1)
            {
                $form_id = end($list_form_ids);
            } else {
                $form_id = $list_form_ids[0];
            }
        }

        $row->bind(array(
                "object"        => $object,
                "object_name"   => $object_name,
                "object_id"     => $object_id,
                "section_id"    => $section_id,
                "section_file"  => $form_id,
                "url"           => $url
            ));

        if (!$row->check() || !$row->store())
        {
            return false;
        }

        return $row;
    }

    public static function loadModules($position)
    {
        jimport('joomla.application.module.helper');
        $modules = JModuleHelper::getModules($position);

        $html = ""; 
        if(count($modules))
        {
            foreach($modules as $module)
            {
                $html.= "\n" . JModuleHelper::renderModule($module);
            }
        }

        return $html;
    }

    public static function routeMenuId($view)
    {
        static $cid=[];
        if(array_key_exists($view, $cid))
            return $cid[$view];

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $url = 'index.php?option=com_jlexreview&view='.$view;

        $query->select('id')
              ->from('#__menu')
              ->where([
                    'published=1',
                    'client_id=0',
                    'link='.$db->quote($url)
                ]);

        $id = $db->setQuery($query)->loadResult();

        $cid[$view]=$id;
        return $id;
    }

    public static function route($url)
    {
        $uri = Joomla\CMS\Uri\Uri::getInstance($url);
        $vars = $uri->getQuery();

        if($vars=="") return $url;

        $view = null; $menuId=null;
        $vars = explode("&", $vars);

        foreach($vars as $var)
        {
            $var=explode("=", $var);
            if($var[0]=="view") $view=$var[1];
        }
        
        if(!empty($view) && in_array($view, ["profile", "ranking"]))
        {
            $viewId = self::routeMenuId($view);
            if($viewId) $menuId=$viewId;
        }
    
        if($menuId) $url.="&Itemid=".$menuId;

        return JRoute::_($url, false);
    }

    protected static $usersRoles = [];

    public static function roles($uid=0)
    {
        if(!$uid) return null;

        if(array_key_exists($uid, self::$usersRoles))
        {
            return self::$usersRoles[$uid];
        }

        // based on group id
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query->select("role.title, role.colour")
              ->from("#__user_usergroup_map gm")
              ->innerJoin("#__jlexreview_roles as role ON gm.group_id=role.group_id")
              ->where("gm.user_id=".$db->quote($uid)." AND role.published=1 AND role.method=1");
        

        self::$usersRoles[$uid] = $db->setQuery($query)->loadObjectList();

        // condition files
        $query->clear()
              ->select("condition_file, title, colour")
              ->from("#__jlexreview_roles")
              ->where("method=0 AND published=1");
        
        $items = $db->setQuery($query)->loadObjectList();

        if($items)
        {
            foreach($items as $item)
            {
                $file = JREVIEW_ADMIN . "/libs/conditions/" . $item->condition_file;
                if(is_file($file))
                {
                    require_once $file;
                    $fn = "jlexCondition" . preg_replace("/\.php$/", "", $item->condition_file);
                    if (function_exists($fn) && $fn($uid)==true)
                    {
                        if (is_array(self::$usersRoles[$uid]))
                        {
                            self::$usersRoles[$uid][] = $item;
                        } else {
                            self::$usersRoles[$uid] = [$item];
                        }
                    }
                }
            }
        }

        return self::$usersRoles[$uid];
    }
}

Anon7 - 2022
AnonSec Team