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/coopiak/amisdesseniors-fr/plugins/content/jlexreview/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/plugins/content/jlexreview/jlexreview.php
<?php
defined('_JEXEC') or die;

$j5 = JPATH_ROOT.'/administrator/components/com_jlexreview/libs/j5.php';
if(file_exists($j5))
    require_once $j5;

use Joomla\Component\Content\Site\Helper\RouteHelper;

class plgContentJlexreview extends JPlugin
{
    protected $component = "";

    protected $block = true;

    protected $input;

    public function __construct(& $subject, $config)
    {
        // Make sure JLex Review installed.
        if(!file_exists(JPATH_ROOT . '/components/com_jlexreview/jlexreview.php')) return;

        $app = JFactory::getApplication();
        $this->input = version_compare(JVERSION, "5.4.0", ">=")?$app->getInput():$app->input;

        parent::__construct($subject, $config);
    }

    protected function p2show($id, $context, $desc="", $catid=0, $star=false)
    {
        $app = JFactory::getApplication();
        $pieces = explode('.', $context);
        $this->component = preg_replace("/^com\_/", "", $pieces[0]);

        $allows = array(
            "com_content.article", 
            "com_k2.item", 
            "com_virtuemart.productdetails", 
            "com_icagenda.event",
            "com_jdownloads.download");

        // not support this extension
        if(!in_array($this->component, array("content", "k2", "virtuemart", "icagenda", "jdownloads"))) return false;

        // is item layout
        $reqContext = $this->input->getCmd("option", "").".".$this->input->getCmd("view", "");
        $isItem = in_array($reqContext, $allows);

        if(stripos($desc, '{jlexreview:off}')!==false) {
            return false;
        } elseif (stripos($desc, '{jlexreview:on}') !== false) {
            return true;
        }

        
        switch ($this->component) {
            case "content":
                if(!$this->params->get("jc", 0)) return false;
                if($star && !$this->params->get("jc_star",1)) return false;

                if($star && $isItem && !$this->params->get("jc_star_item",1)) return false;
                if(!$star && !$isItem) return false;

                if($this->params->get("jc_area", 0)==2) return false;

                if($this->params->get("jc_area", 0)==1)
                {
                    // category
                    $f = $this->params->get('jc_category', array());
                    if(empty($f) || !count($f)) return false;

                    if(in_array($catid, $f)) return true;

                    if(!$this->params->get('jc_child',1)) return false;

                    // child
                    $db = JFactory::getDbo();
                    $parent = $catid;

                    while ($parent>1) {
                        $query = "SELECT parent_id FROM #__categories WHERE extension='com_content' AND id=".$db->quote($parent);
                        $parent = $db->setQuery($query)->loadResult();
                        
                        if(!$parent) return false;

                        $parent*=1;
                        if (in_array($parent, $f)) return true;
                    }

                    return false;
                }
                break;

            case "k2":
                if(!$this->params->get("k2", 0)) return false;
                if($star && !$this->params->get("k2_star",1)) return false;

                if($star && $isItem && !$this->params->get("k2_star_item",1)) return false;
                if(!$star && !$isItem) return false;

                if($this->params->get("k2_area", 0)==2) return false;

                if($this->params->get("k2_area", 0)==1)
                {
                    // category
                    $f = $this->params->get('k2_category', array());
                    if(empty($f) || !count($f)) return false;

                    if(in_array($catid, $f)) return true;

                    if(!$this->params->get('k2_child',1)) return false;

                    // child
                    $db = JFactory::getDbo();
                    $parent = $catid;

                    while ($parent>1) {
                        $query = "SELECT parent FROM #__k2_categories WHERE id=".$db->quote($parent);
                        $parent = $db->setQuery($query)->loadResult();
                        
                        if(!$parent) return false;

                        $parent*=1;
                        if (in_array($parent, $f)) return true;
                    }

                    return false;
                }
                break;
            
            case "virtuemart":
                if(!$this->params->get("vm", 0)) return false;
                if(!$star && !$isItem) return false;

                if($this->params->get("vm_area", 0)==2) return false;

                if($this->params->get("vm_area", 0)==1)
                {
                    // category
                    $f = $this->params->get('vm_category', array());
                    if(empty($f) || !count($f)) return false;

                    if(in_array($catid, $f)) return true;

                    if(!$this->params->get('vm_child',1)) return false;

                    // child
                    $db = JFactory::getDbo();
                    $parent = $catid;

                    while ($parent>1) {
                        $query = "SELECT category_parent_id FROM #__virtuemart_category_categories WHERE id=".$db->quote($parent);
                        $parent = $db->setQuery($query)->loadResult();
                        
                        if(!$parent) return false;

                        $parent*=1;
                        if (in_array($parent, $f)) return true;
                    }

                    return false;
                }
                break;

            case "icagenda":
                if(!$this->params->get("ida", 0)) return false;
                if($star && !$this->params->get("ida_star",1)) return false;

                if($star && $isItem && !$this->params->get("ida_star_item",1)) return false;
                if(!$star && !$isItem) return false;

                if($this->params->get("ida_area", 0)==2) return false;

                if($this->params->get("ida_area", 0)==1)
                {
                    $f = $this->params->get('ida_category', array());
                    if(empty($f) || !count($f)) return false;
                    if(in_array($catid, $f)) return true;
                }
                break;

            case "jdownloads":
                if(!$this->params->get("jdownloads", 0)) return false;
                if($star && !$this->params->get("jdownloads_star",1)) return false;

                if($star && $isItem && !$this->params->get("jdownloads_star_item",1)) return false;
                if(!$star && !$isItem) return false;
                break;
        }

        return true;
    }

    public function onAjaxJlexreview()
    {
        $app = JFactory::getApplication();
        if($app->isClient("site")) return;
        // administrator/index.php?option=com_ajax&plugin=vmprocess&format=json&group=content

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);
        $s = $this->input->getBool("status", false);

        $query->select("template")
              ->from("#__template_styles")
              ->where(array(
                    "client_id=0",
                    "home=1"
                ));

        $t = $db->setQuery($query)->loadResult();
        if(!$t) return array("status"=>400);

        jimport('joomla.filesystem.file');
        jimport('joomla.filesystem.folder');

        $path = JPATH_ROOT."/templates/".$t."/html/com_virtuemart";
        $files = array(
            $path."/productdetails/default_reviews.php" => dirname(__FILE__)."/vm/default_reviews.php",
            $path."/sublayouts/rating.php" => dirname(__FILE__)."/vm/rating.php",
            $path."/sublayouts/snippets.php" => dirname(__FILE__)."/vm/snippets.php",
        );

        JFolder::create($path."/productdetails");
        JFolder::create($path."/sublayouts");

        if($s)
        {
            // override files
            foreach($files as $c=>$r)
            {
                if(file_exists($c)) rename($c, $c.".bk");
                JFile::copy($r, $c);
            }
        } else {
            // restore
            foreach($files as $c=>$r)
            {
                if(file_exists($c)) JFile::delete($c);
                if(file_exists($c.".bk")) rename($c.".bk", $c);
            }
        }

        return array("status" => 200);
    }
    
    public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
    {
        if(JFactory::getApplication()->isClient("administrator")) return;

        $id = isset($row->virtuemart_product_id) ? $row->virtuemart_product_id : $row->id;
        $catid = isset($row->virtuemart_category_id) ? $row->virtuemart_category_id : @$row->catid;
        $desc = isset($row->text)?$row->text:@$row->product_desc;
        
        $star = $this->p2show($id, $context, $desc, $catid, true);
        
        if(!$star) return;
        
        $loader = JPATH_ROOT."/components/com_jlexreview/load.php";
        require_once $loader;
        
        $url = "";
        $count = false;

        switch($this->component)
        {
            case "content":
                if(in_array($context, array("com_content.categories"))) return;

                $url = JRoute::_(class_exists('ContentHelperRoute')?ContentHelperRoute::getArticleRoute($row->slug, @$row->catslug):RouteHelper::getArticleRoute($row->slug, @$row->catslug));
                $count = $this->params->get("jc_star_count", 0)==1;
                break;
            
            case "k2":
                $url = $row->link;
                $count = $this->params->get("k2_star_count", 0)==1;
                break;

            case "jdownloads":
                $count = $this->params->get("jdownloads_star_count", 0)==1;
                break;

            case "virtuemart":
                    // with VM, we will use override method
                    return;
                break;
        }

        return JLexReviewLoad::quick_init($this->component, $id, '', $count, $url, $catid);
    }

    public function onContentAfterDisplay($context, &$row, &$params, $page = 0)
    {
        if(JFactory::getApplication()->isClient("administrator")) return;

        $id = isset($row->virtuemart_product_id) ? $row->virtuemart_product_id : $row->id;
        $catid  = isset($row->virtuemart_category_id) ? $row->virtuemart_category_id : @$row->catid;
        $desc   = isset($row->text)?$row->text:@$row->product_desc;
        $title  = isset($row->title) ? $row->title:(isset($row->product_name)?$row->product_name:"PD:".$id);

        if(preg_match('/^com_virtuemart/', $context) && $context!='com_virtuemart.productdetails')
            return;
        
        $body = $this->p2show($id, $context, $desc, $catid, false);
        
        // strip code structre
        if(isset($row->text)){
            $row->text = str_replace(array(
                "{jlexreview:off}", "{jlexreview:on}"
            ), array(
                "", ""
            ), $row->text);
        } elseif(isset($row->product_desc)){
            $row->product_desc = str_replace(array(
                "{jlexreview:off}", "{jlexreview:on}"
            ), array(
                "", ""
            ), $row->product_desc);
        }

        if(!$body) return;
        
        $loader = JPATH_ROOT."/components/com_jlexreview/load.php";
        require_once $loader;

        $custom_schema = null;
        if($this->component=="virtuemart")
        {
            if(!empty($row->product_s_desc)){
                $desc = htmlspecialchars(strip_tags($row->product_s_desc));
            } else {
                $desc = htmlspecialchars(strip_tags($row->product_desc));
            }

            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
            $query->select('currency_code_3')
                  ->from("#__virtuemart_currencies")
                  ->where("virtuemart_currency_id=".$db->quote($row->prices['product_currency']));

            $priceCurrency = $db->setQuery($query)->loadResult();
            if(!$priceCurrency) $priceCurrency="USD";

            $custom_schema = array(
                    "description" => $desc,
                    "sku" => (!empty($row->product_sku)? $row->product_sku : ''),
                    "mpn" => (!empty($row->product_mpn)? $row->product_mpn : ''),
                    "offers" => array(
                            "@type" => "Offer",
                            "priceCurrency" => $priceCurrency,
                            "availability" => "InStock",
                            "price" => $row->prices['salesPrice'],
                            "itemCondition" => "NewCondition"
                        )
                );

            if($row->images[0]->virtuemart_media_id>0)
            {
                $custom_schema["image"]=array();
                foreach($row->images as $image)
                {
                    $custom_schema["image"][]=JURI::root().$image->file_url;
                }
            }
        }

        return JLexReviewLoad::init($title, $this->component, $id, $catid, (is_null($custom_schema)?array():array("custom_schema"=>$custom_schema)) );
    }

    /* iCagenda */
    public function onListAddEventInfo($context, &$item, &$params)
    {
        $star = $this->p2show($item->id, $context, $item->desc, $item->catid, true);
        if(!$star) return;
        
        $loader = JPATH_ROOT."/components/com_jlexreview/load.php";
        require_once $loader;

        $count = $this->params->get("ida_star_count", 0)==1;

        return JLexReviewLoad::quick_init($this->component, $item->id, "", $count, $item->url, $item->catid);
    }

    public function iCagendaOnEventBeforeDisplay($context, &$item, &$params)
    {
        $star = $this->p2show($item->id, $context, $item->desc, $item->catid, true);
        if(!$star) return;
        
        $loader = JPATH_ROOT."/components/com_jlexreview/load.php";
        require_once $loader;

        $count = $this->params->get("ida_star_count", 0)==1;

        return JLexReviewLoad::quick_init($this->component, $item->id, "", $count, $item->catid);
    }

    public function iCagendaOnEventAfterDisplay($context, &$item, &$params)
    {
        $body = $this->p2show($item->id, $context, $item->desc, $item->catid, false);
        if(!$body) return;

        $item->desc = str_replace(array(
            "{jlexreview:off}", "{jlexreview:on}"
        ), array(
            "", ""
        ), $item->desc);

        $loader = JPATH_ROOT."/components/com_jlexreview/load.php";
        require_once $loader;

        return JLexReviewLoad::init($item->title, $this->component, $item->id, $item->catid);
    }
}

Anon7 - 2022
AnonSec Team