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/nice2/plugins/djclassifieds/ratings/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/nice2/plugins/djclassifieds/ratings/ratings.php
<?php
/**
 * @package DJ-Classifieds
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email: contact@dj-extensions.com
 */

defined ( '_JEXEC' ) or die ( 'Restricted access' );

class plgDJClassifiedsRatings extends JPlugin
{	
	public function __construct(& $subject, $config)
	{
		parent::__construct ( $subject, $config );
		$this->loadLanguage();
	}

	static function _getUserRatingData($rate_name, $user_id, $item_id, $type = 'item')
	{
		$db = JFactory::getDBO();

		$query = "SELECT * FROM #__djcf_ratings WHERE type=".$db->q($type)." AND name='".$rate_name."' AND user_id=".$user_id." AND item_id=".$item_id;
		$db->setQuery($query);
		
		$rating = $db->loadObject();

		return $rating;
	}

	static function _getRatingScore($rate_name, $item_id, $type = 'item')
	{
		$db = JFactory::getDBO();

		$query = "SELECT AVG(value) FROM #__djcf_ratings WHERE type=".$db->q($type)." AND name='".$rate_name."' AND item_id=".$item_id;
		$db->setQuery($query);
		$score = $db->loadResult();

		$score = ceil($score * 2) / 2; // floor($score);
		
		return $score;
	}

	function onAfterDJClassifiedsDisplay(&$item, &$par, $context)
	{
		if($context != 'item'){
			return;
		}

		JFactory::getDocument()->addStylesheet(Juri::root().'plugins/djclassifieds/ratings/assets/css/style.css', array('version' => 'auto'));

		$user = JFactory::getUser();
		$ratings = $this->params->get('ratings', array());

		if($user->id){
			foreach($ratings as $rating){
				$userrating = self::_getUserRatingData($rating->name, $user->id, $item->id);
				$rating->itemval = $userrating ? $userrating->value : 0;
			}
		}

		$layout = new JLayoutFile('userrating', JPATH_ROOT .'/plugins/djclassifieds/ratings/layouts');

		$content = $layout->render(array(
			'item' => $item,
			'ratings' => $ratings
		));

		return $content;
	}

	function onAfterDJClassifiedsDisplayContent(&$item, &$par, $context)
	{
		if($context != 'item'){
			return;
		}

		JFactory::getDocument()->addStylesheet(Juri::root().'plugins/djclassifieds/ratings/assets/css/style.css', array('version' => 'auto'));

		$ratings = $this->params->get('ratings', array());

		foreach($ratings as $rating){
			$score = self::_getRatingScore($rating->name, $item->id);
			$rating->itemval = $score ? $score : 0;
		}

		$layout = new JLayoutFile('itemrating', JPATH_ROOT .'/plugins/djclassifieds/ratings/layouts');

		$content = $layout->render(array(
			'item' => $item,
			'ratings' => $ratings
		));

		return $content;
	}

	function onAjaxRateItem()
	{
		$app = JFactory::getApplication();
		$db = JFactory::getDBO();
		$user = JFactory::getUser();

		$item_id = $app->input->get('item_id');
		$rate_name = $app->input->get('rate_name');
		$rate_val = $app->input->get('rate_val');

		if(!$user->id){
			echo JText::_('PLG_DJCLASSIFIEDS_RATINGS_LOG_IN_TO_RATE');
			$app->close();
		}
		if(!$rate_name){
			echo 'no rating name';
			$app->close();
		}
		if(!$rate_val){
			echo 'no rating value';
			$app->close();
		}

		$old_rating = self::_getUserRatingData($rate_name, $user->id, $item_id);

		if($old_rating){
			if($old_rating->value != $rate_val){
				$query = "UPDATE #__djcf_ratings SET value=".$rate_val.", modified=".$db->q(JFactory::getDate()->toSQL())." WHERE id=".$old_rating->id;
				$db->setQuery($query);
				$db->execute();
				echo JText::_('PLG_DJCLASSIFIEDS_RATINGS_RATING_UPDATED');
			}else{
				//echo 'same value - no action';
			}
		}else{
			$query = "INSERT INTO #__djcf_ratings(`type`, `item_id`, `user_id`, `name`, `value`, `created`) "
			."VALUES('item', ".$item_id.", ".$user->id.", ".$db->q($rate_name).", ".$rate_val.", ".$db->q(JFactory::getDate()->toSQL()).")";
			$db->setQuery($query);
			$db->execute();
			echo JText::_('PLG_DJCLASSIFIEDS_RATINGS_RATING_ADDED');
		}

		$app->close();
	}

}

Anon7 - 2022
AnonSec Team