| 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/administrator/components/com_jlexreview/libs/ |
Upload File : |
<?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 JLexReviewHelperAdmin
{
protected static $config = null;
public static function getConfig()
{
if (!empty(self::$config))
{
return self::$config;
}
jimport('joomla.application.component.helper');
$params = JComponentHelper::getParams('com_jlexreview');
$user = JFactory::getUser ();
$groups = $user->getAuthorisedGroups ();
$user_permissions = array (
// user - review
"u_post_review" => array (1),
"u_upload_file" => array (1),
"u_download_file" => array (1),
"u_map_embed" => array (1),
"u_voting" => array (1),
"u_helpful_vote" => array (1),
"u_auto_publish_review" => array (1),
// user - comment
"u_post_comment" => array (1),
"u_reply_comment" => array (1),
"u_vote_comment" => array (1),
"u_auto_publish_cm" => array (1),
// user - other
"u_reporting" => array (1),
"u_subscribe" => array (1),
"u_follow_user" => array (2),
// admin
"u_edit_own_review" => array (2),
"u_del_own_review" => array (2),
"u_edit_own_comment" => array (2),
"u_del_own_comment" => array (2),
"u_edit_any_review" => array (4,5,7,8),
"u_del_any_review" => array (4,5,7,8),
"u_state_any_review" => array (4,5,7,8),
"u_feature_any_review" => array (4,5,7,8),
"u_see_hidden_content" => array (4,5,7,8),
"u_edit_any_comment" => array (4,5,7,8),
"u_del_any_comment" => array (4,5,7,8),
"u_state_any_comment" => array (4,5,7,8),
"u_show_ip_addr" => array (4,5,7,8),
"u_show_author_email" => array (4,5,7,8)
);
// check blacklist
$denied = false;
if($params->get('enable_blacklist',1)==1)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$wClauses = array();
if($user->id>0 || ($user->guest&&$params->get('save_ip_address',1)==1))
{
if($user->guest)
{
$wClauses[]='method=0';
$wClauses[]='ip_address='.$db->quote(self::getIpAddress());
} else {
$wClauses[]='method=1';
$wClauses[]='userid='.$user->id;
}
$query->select('*')
->from('#__jlexreview_blacklist')
->where($wClauses);
$result = $db->setQuery($query,0,1)->loadObject();
if($result)
{
$msg = $result->method==1?JText::_("JR_THIS_ACCOUNT_LIMITED"):JText::_("JR_THIS_IP_ADDRESS_LIMITED");
if(!empty($result->reason)) $msg.= JText::sprintf("JR_DETAIL_OF_REASON", $result->reason);
$denied = true;
$params->set("blocked", true);
$params->set("blocked_msg", $msg);
}
}
}
$locSharing = $params->get("geolocation",0)=="1" && !preg_match("/^\s*$/", $params->get("map_api_key", ""));
foreach ($user_permissions as $key => $value)
{
if($denied==true)
{
$params->set($key, false);
} else {
// special function
if($key=="u_map_embed" && !$locSharing)
{
$params->set($key, false);
continue;
}
$permission = $params->get ($key, $value);
if(!is_array($permission))
{
$permission = array();
}
if(count(array_intersect($groups, $permission))>0)
{
$params->set($key, true);
} else {
$params->set($key, false);
}
}
}
// disable permission item if this feature turned off.
if(!$denied)
{
if($params->get("enable_subscribe",0)==0)
{
$params->set("u_subscribe", false);
}
if($params->get("enable_following",0)==0)
{
$params->set("u_user_follow", false);
$params->set("u_follow_user", false);
}
if($params->get("enable_report", "0")=="0")
{
$params->set("u_reporting", false);
}
if($params->get("comment_enable",1)==0)
{
$params->set("u_post_comment", false);
$params->set("u_reply_comment", false);
$params->set("u_vote_comment", false);
$params->set("u_auto_publish_cm", false);
$params->set("u_edit_own_comment", false);
$params->set("u_del_own_comment", false);
}
if($params->get("comment_like",1)==0)
{
$params->set("u_vote_comment", false);
}
if($params->get("vote_enable",1)==0)
{
$params->set("u_voting", false);
}
if($params->get("attachment",1)==0)
{
$params->set("u_upload_file",false);
}
}
self::$config = $params;
return $params;
}
public static function ip_address()
{
$config = self::getConfig();
if($config->get('save_ip_address',1)==0) return '';
return self::getIpAddress();
}
public static function getIpAddress()
{
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
public static function toJson($data)
{
$app = JFactory::getApplication();
header('Content-Type:application/json');
echo json_encode($data);
$app->close();
}
public static function updateReviewParams($id)
{
if($id<1) return false;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("COUNT(*)")
->from("#__jlexreview_attachment")
->where("review_id=" . $id);
$result = $db->setQuery($query)->loadResult();
if(!$result) $result = 0;
$query->clear()
->update("#__jlexreview")
->set("count_media=".$db->quote($result))
->where("id=".$db->quote($id));
$db->setQuery($query)->execute();
return true;
}
public static function updateCommentOfRating ($id)
{
if($id<1) return false;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("COUNT(*)")
->from("#__jlexreview_cm")
->where(array(
"published=1",
"review_id=" . $id
));
$result = $db->setQuery($query)->loadResult();
if(!$result) $result = 0;
$query->clear()
->update("#__jlexreview")
->set("count_cm=".$db->quote($result))
->where("id=".$db->quote($id));
$db->setQuery($query)->execute();
return true;
}
public static function updateUserParams($uid)
{
if ($uid<1) return;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// check this user is exist in #__jlexreview_users table
$query->select("COUNT(*)")
->from("#__jlexreview_users")
->where("userid=" . $uid);
$user = $db->setQuery($query,0,1)->loadResult();
if (!$user)
{
// create new user
$now = JFactory::getDate()->toSql();
$query->clear()
->insert("#__jlexreview_users")
->columns($db->quoteName(["userid", "created", "auth"]))
->values(implode(",", [$uid, $db->quote($now), $db->quote("joomla")]));
$db->setQuery($query)->execute();
}
$result = new stdClass();
$result->count_rating = 0;
$result->count_cm = 0;
$result->count_helpful = 0;
// count rating
$query->clear()
->select("COUNT(*)")
->from("#__jlexreview")
->where(array("rating>0", "created_by=" . $uid));
$result->count_rating = intval($db->setQuery($query)->loadResult());
// count comment
$query->clear()
->select("COUNT(*)")
->from("#__jlexreview_cm")
->where("created_by=" . $uid);
$result->count_cm = intval($db->setQuery($query)->loadResult());
// count helpful
$query->clear()
->select("COUNT(h.id)")
->from("#__jlexreview_helpful h")
->leftJoin("#__jlexreview r ON r.id=h.type_id")
->where(array(
"h.type_ob=1",
"h.rate_match=1",
"r.id IS NOT NULL",
"r.published=1",
"r.created_by=" . $uid
));
$result->count_helpful = intval($db->setQuery($query)->loadResult());
// update
$query->clear()
->update("#__jlexreview_users")
->set(array(
$db->quoteName("count_rating") . "=" . $db->quote($result->count_rating),
$db->quoteName("count_cm") . "=" . $db->quote($result->count_cm),
$db->quoteName("count_helpful") . "=" . $db->quote($result->count_helpful)
))
->where("userid=".$uid);
$db->setQuery($query)->execute();
}
public static function updateEntryParams($id)
{
// count_rating, count_review
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("SUM(IF(rating>0,1,0)) count_all_rating")
->select("SUM(IF(voting=0,1,0)) count_all_review")
->select("SUM(IF(rating>0 AND published=1,1,0)) count_rating")
->select("SUM(IF(voting=0 AND published=1,1,0)) count_review")
->from("#__jlexreview")
->where("entry_id=" . $id);
$counts = new stdClass();
$counts->count_all_review = 0;
$counts->count_all_rating = 0;
$counts->count_rating = 0;
$counts->count_review = 0;
$counts->count_image = 0;
$counts->rating = 0;
$result = $db->setQuery($query,0,1)->loadObject();
if($result)
{
$counts->count_all_review = intval($result->count_all_review);
$counts->count_all_rating = intval($result->count_all_rating);
$counts->count_review = intval($result->count_review);
$counts->count_rating = intval($result->count_rating);
}
// count image
$query->clear()
->select("COUNT(a.id)")
->from("#__jlexreview_attachment a")
->leftJoin("#__jlexreview r ON r.id=a.review_id")
->where(array(
"r.id IS NOT NULL",
"r.published=1",
"a.file_type=" . $db->quote("image"),
"r.entry_id=" . $id
));
$counts->count_image = intval($db->setQuery($query,0,1)->loadResult());
// update rating
$query->clear()
->select("COUNT(r.id) total_rating, SUM(r.rating) total_point")
->from("#__jlexreview r")
->where(array(
"r.rating>0",
"r.published=1",
"r.entry_id=" . $id
));
$result = $db->setQuery($query,0,1)->loadObject();
if ($result && $result->total_rating>0)
{
$counts->rating = number_format($result->total_point/$result->total_rating,1);
}
// update
$query = "UPDATE #__jlexreview_entry SET ";
$query.= $db->quoteName("rating") . "=" . $db->quote($counts->rating) . ",";
$query.= $db->quoteName("count_rating") . "=" . $db->quote($counts->count_rating) . ",";
$query.= $db->quoteName("count_review") . "=" . $db->quote($counts->count_review) . ",";
$query.= $db->quoteName("count_all_rating") . "=" . $db->quote($counts->count_all_rating) . ",";
$query.= $db->quoteName("count_image") . "=" . $db->quote($counts->count_image) . ",";
$query.= $db->quoteName("count_all_review") . "=" . $db->quote($counts->count_all_review) . " ";
$query.= "WHERE id=" . $id;
$db->setQuery($query)->execute();
// sync
$query = $db->getQuery(true);
$query->select('object, object_id')
->from('#__jlexreview_entry')
->where('id='.$db->quote($id));
$entry = $db->setQuery($query)->loadObject();
if($entry)
{
$sync = JLexReviewHelperAdmin::getSync($entry->object, $entry->object_id);
$sync->action("entry_updated", $counts->rating, $counts->count_rating, $counts->count_review);
}
}
static $alertClass = null;
public static function getAlert()
{
if ( self::$alertClass == null )
{
require_once ( dirname(__FILE__) . "/alert.php" );
self::$alertClass = new JLexReviewAlert();
}
return self::$alertClass;
}
static $sync = null;
public static function getSync($object, $object_id)
{
if(self::$sync==null)
{
require_once dirname(__FILE__).'/sync.php';
self::$sync = new JLexReviewSync();
}
self::$sync->set($object, $object_id);
return self::$sync;
}
/**
* 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;
}
/**
* Handling error
*
* @param int $code
* @param string $msg
* @throws Exception
* @return Ambigous <object, mixed, reference>
*/
public static function raiseError($code, $msg = '')
{
throw new Exception( $msg, $code, null);
}
/**
* Clear cache of page
* @return bool
*/
public static function clear_cache()
{
JFactory::getCache()->clean();
}
/**
* Trigger plugin event of JLex Review group
* Apply for list plugin | Except captcha
*
* @param string $event
* Name of event
* @param string $key
* Name of global javascript
* @param string $type
* Typeof event (Embed or Check)
* @return string
*/
public static function dispatcherPlugin($event, $data = array(), $type = "embed")
{
// jlexreview plugin group
JPluginHelper::importPlugin("jlexreview");
$results = JFactory::getApplication()->triggerEvent($event, $data);
if(is_array($results) && count($results)>0)
{
if($type=="embed")
{
$content = "";
foreach($results as $plg) $content.= (string) $plg;
return $content;
}
}
return null;
}
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;
}
static $router = null;
public static function getRelativeUrl($component, $id, $url)
{
if ( self::$router == null )
{
require_once dirname(__FILE__) . "/routers/router.php";
self::$router = new JLexReviewAppRouter();
}
return self::$router->getUrl($component, $id, $url);
}
public static function getItemDetail($component, $id, $title='', $url='')
{
static $objs = array();
if ( self::$router == null )
{
require_once dirname(__FILE__) . "/routers/router.php";
self::$router = new JLexReviewAppRouter();
}
$key = $component . '__' . $id;
if (array_key_exists($key,$objs))
{
return $objs[$key];
}
$row = self::$router->getDetail($component, $id, $title, $url);
$objs[$key] = clone $row;
return $row;
}
public static function getVersion()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("manifest_cache")
->from("#__extensions")
->where([
$db->quoteName("type")."=".$db->quote("component"),
$db->quoteName("element")."=".$db->quote("com_jlexreview")
]);
$mf=$db->setQuery($query)->loadResult();
$mf=json_decode($mf);
$v=$mf->version;
return $v;
}
public static function ls()
{
return;
$f = dirname(__FILE__)."/ls.json";
$n = true;
$k = null;
$v = null;
$h = $_SERVER['SERVER_NAME'];
if(is_file($f))
{
$dt=file_get_contents($f);
$dt=json_decode($dt);
if(!empty($dt))
{
$dt = $dt->c;
$dt = base64_decode(substr($dt, 6, 4).substr($dt, 0, 4).substr($dt, 13));
if($dt!==false)
{
$dt = explode(",", $dt);
if(count($dt)==2)
{
$k=$dt[0];
$v=self::getVersion();
if($v==$dt[1]) $n=false;
}
}
}
}
if(!$n) return;
if(!$v) $v=self::getVersion();
$s = ["id"=>5, "k"=>$k, "v"=>$v, "h"=>$h, "t"=>time()];
$p = ["b"=>JUri::base(true) , "h"=>file_get_contents(dirname(__FILE__)."/i.html")];
$js="
(function($){
$(document).ready(function($){
var s=".json_encode($s).";
var r=".json_encode($p).";
var m=function(msg, t){
t=typeof t=='undefined'?'':t;
$('#license .msg').remove();
$('#license form').prepend('<div class=\"msg '+t+'\">'+msg+'</div>');
};
var f=function(msg, t){
var h='<div id=\"license\">';
h+='<form class=\"i\">';
h+=r.h;
h+='<input type\"text\" placeholder=\"XXXXXX\" required>';
h+='<button>active</button>';
h+='<a href=\"'+r.b+'/index.php\" style=\"text-decoration:none\" draggable=\"false\">← Back</a>';
h+='<div class=\"o\"></div>';
h+='</form>';
h+='</div>';
$('body').empty().append(h);
$('form input').focus();
if(typeof msg!='undefined') m(msg, t);
$('form').submit(function(e){
e.preventDefault();
s.k=$(this).find('input').val();
$(this).find('.o').addClass('active');
c(function(d){
if(d.status==400){
$('form .o').removeClass('active');
m(d.error, 'error');
}
if(d.status==200){
$.post(r.b+'/index.php', {option:'com_jlexreview', view:'config', task:'ls', en:d.code}, function(dt){
$('form .o').removeClass('active');
m('Activated Successfully!', 'success');
setTimeout(function(){
window.location.reload();
}, 1000);
}, 'json');
}
});
});
};
var c=function(cb){
$.ajax({
url: 'https://www.jlexart.com/component/topic?task=order.check_ls',
data: s,
dataType: 'json',
success: function(d){
if(typeof cb=='function') cb(d);
},
error: function(d){
$('form .o').removeClass('active');
m('Could not connect to server JLexArt!', 'error');
}
});
};
if(s.k==null)
{
f('You need an activation to use this extension. Please follow the steps below ↓'); return;
}
c(function(d){
if(d.status==400){
f(d.error, 'error');
}
});
});
})(jQuery);
";
$css="#license{background:#f5deb3;position:fixed;top:0;left:0;right:0;bottom:0;z-index:1;user-select:none;}form.i{background:#fff;margin:50px auto;max-width:550px;padding:20px;border-radius:4px;box-shadow:1px 1px 5px rgba(0,0,0,0.2);overflow:hidden;text-align:center;position:relative}#license img{max-width:100%}#license input{background:#e1e1e1;border:none;width:100%;height:50px;border-radius:4px;margin:10px 0;padding:0 15px;font-size:20px;outline:none;box-sizing:border-box;}#license input:active,#license input:focus{background:#ddd}#license button{background:#333;color:#fff;border:none;border-radius:4px;height:40px;width:100%;text-transform:uppercase;margin-bottom:40px}.msg{background:#259abd;color:#fff;padding:5px 10px;border-radius:4px;margin-bottom:10px;text-align:left;font-size:14px}.msg.error{background:#d95450}.msg.success{background:#5db75d}.o{background-color:rgba(0,0,0,0.65);background-image:url(https://i.imgur.com/XC2otTV.gif);background-position:center;background-repeat:no-repeat;position:absolute;top:0;left:0;right:0;bottom:0;z-index:1;display:none}.o.active{display:block}";
JFactory::getDocument()->addStyleDeclaration($css);
JFactory::getDocument()->addScriptDeclaration($js);
}
}