| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 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/components/com_jlexreview/controllers/ |
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 JLexReviewControllerProfile extends JControllerLegacy
{
protected $params = [];
public function setParam($name, $value)
{
$this->params[$name] = $value;
}
protected function getParam($name, $default=null)
{
return array_key_exists($name, $this->params)?$this->params[$name]:$default;
}
public function display($cachable = false, $urlparams = array())
{
$app = JFactory::getApplication ();
$model = $this->getModel("profile");
$view = $this->getView("profile", "html");
$view->setModel($model);
JLexReviewHelperSite::loadThemes($view);
$view->display();
}
public function render()
{
require_once (dirname(__FILE__) . "/../models/profile.php");
$uid = $this->getParam("uid", 0);
$model = $this->getModel("profile");
$view = $this->getView("profile", "html");
$view->setModel($model);
JLexReviewHelperSite::loadThemes($view);
$view->set("uid", $uid);
return $view->render($this->getParam("avatar", false));
}
public function thumb()
{
$app = JFactory::getApplication();
$this->addModelPath ( JREVIEW_ADMIN . '/models', 'JLexReview' );
$uid = JFactory::getUser()->id;
$model = $this->getModel ('user');
$model->set("uid", $uid);
$return = $model->thumb();
if ($return===false)
{
$response = array(
"status" => 400,
"error" => $model->getError()
);
} else {
$response = array("status" => 200);
}
JLexReviewHelperAdmin::toJson($response);
}
public function activity()
{
$app = JFactory::getApplication();
$uid = $app->input->getInt("uid", 0);
$type = $app->input->getCmd("filter", "all");
$offset = $app->input->getInt("offset", 0);
$sort = $app->input->getCmd("sort", "desc");
$model = $this->getModel("profile");
if ($uid > 0)
{
$model->set( "uid", $uid );
}
if ($offset >= 0)
{
$model->set( "offset", $offset );
}
if (in_array($type, array("all","review","cm")))
{
$model->set("filter", $type);
}
if (in_array($sort, array("asc", "desc")))
{
$model->set("sort", $sort);
}
$activities = $model->getActivities();
if ($activities===false)
{
$response = array(
"status" => 400,
"error" => $model->getError()
);
} else {
$response = array(
"status" => 200,
"data" => $activities
);
}
JLexReviewHelperAdmin::toJson($response);
}
public function subscribe()
{
$app = JFactory::getApplication();
$config = JLexReviewHelperAdmin::getConfig();
$user = JFactory::getUser();
$id = $app->input->getInt("id", 0);
$type = $app->input->getInt("type", 0);
$model = $this->getModel("profile");
if ($id > 0)
{
$model->set( "id", $id );
}
if ($type>0)
{
if ($config->def("u_subscribe",false)==false)
{
JLexReviewHelperAdmin::toJson(array(
"status" => 400,
"error" => JText::_("JR_FEATURE_INVALID_WITH_YOU")
));
}
} else {
if ($config->def("u_follow_user",false)==false)
{
JLexReviewHelperAdmin::toJson(array(
"status" => 400,
"error" => JText::_("JR_FEATURE_INVALID_WITH_YOU")
));
}
}
$return = $model->subscribe($type>0?1:0);
if ($return===false)
{
$response = array(
"status" => 400,
"error" => $model->getError()
);
} else {
// extra session
$session = JFactory::getSession();
$key = "item_" . $id . "_" . $type;
$session->set( $key, $return, "jreviewsubscribe" );
$response = array("status" => 200 );
}
JLexReviewHelperAdmin::toJson( $response );
}
public function unsubscribe()
{
$app = JFactory::getApplication();
$id = $app->input->getInt("id", 0);
$type = $app->input->getInt("type", 0);
$model = $this->getModel("profile");
$sid = JLexReviewHelperSite::isSubscribe($id, $type);
if ( !$sid )
{
$response = array(
"status" => 400,
"error" => JText::_("JR_PERMISSION_DENIED")
);
}
$model->set( "id", $sid );
$return = $model->unsubscribe();
if ($return===false)
{
$response = array(
"status" => 400,
"error" => $model->getError()
);
} else {
$session = JFactory::getSession();
$key = "item_" . $id . "_" . $type;
$session->clear( $key, "jreviewsubscribe" );
$response = array("status" => 200 );
}
JLexReviewHelperAdmin::toJson( $response );
}
public function login()
{
$app = JFactory::getApplication();
$model = $this->getModel ('profile');
$return = $model->login ();
if ( $return==false )
{
$response = array ('status'=>400, 'error'=>$model->getError());
} else {
$response = array ('status'=>200);
}
JLexReviewHelperAdmin::toJson($response);
}
public function logout()
{
$app = JFactory::getApplication();
$app->logout();
JLexReviewHelperAdmin::toJson(['status'=>200]);
}
public function oauth()
{
$app = JFactory::getApplication();
$app->input->set ('tmpl', 'component');
$modelPath = dirname(__FILE__) . "/../models/oauth.php";
if (!JFile::exists($modelPath))
{
return;
}
$model = $this->getModel ('oauth');
$return = $model->action ();
if ( !$return)
{
$app->enqueueMessage ( $model->getError() , 'error');
return false;
} else {
$js = '<p>Just moment...</p>';
$js .= '<script type="text/javascript">';
$js .= 'window.setTimeout(function(){';
$js .= 'window.opener.location.reload(false);';
$js .= 'window.close();';
$js .= '},1000);';
$js .= '</script>';
echo $js;
$app->close ();
}
}
public function notification()
{
$app = JFactory::getApplication();
$model = $this->getModel("profile");
$offset = $app->input->getInt("offset", 0);
$unread = $app->input->getInt("unread", 0);
if ($offset>0)
{
$model->set("offset", $offset);
}
$unread = $unread>0 ? 1 : 0;
$model->set("unread", $unread);
$alerts = $model->getAlerts();
JLexReviewHelperAdmin::toJson($alerts);
}
public function read()
{
$model = $this->getModel("profile");
$model->setRead();
JLexReviewHelperAdmin::toJson(["status"=>200]);
}
public function getAvatar()
{
$app = JFactory::getApplication();
$uid = $app->input->getInt("id", 0);
$config = JLexReviewHelperAdmin::getConfig();
$default = JUri::base(true)."/media/jlexreview/system/avatar_default.png";
$thumb = null;
if($uid>0 && preg_match("/^[1-9][0-9]*$/", $config->get("user_field_id", 0)))
{
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$fields = FieldsHelper::getFields('com_users.user', JFactory::getUser($uid), true);
if(!empty($fields))
{
foreach($fields as $field)
{
if($field->id==(int) $config->get("user_field_id"))
{
$thumb = strip_tags($field->rawvalue?$field->rawvalue:$field->value);
if(preg_match("/\{/", $thumb))
{
// json format
$thumb = json_decode($thumb);
$thumb = $thumb[0]->value;
}
$ext = strtolower(pathinfo($thumb, PATHINFO_EXTENSION));
if(in_array($ext, ["jpg", "jpeg", "png", "gif"]))
{
$thumb = JPATH_ROOT."/".trim($thumb, "/");
if(file_exists($thumb))
{
// create thumb
$nfile = md5($thumb).".jpg";
$url = JUri::base(true).'/media/jlexreview/avatar/'.$nfile;
if(file_exists(JPATH_ROOT."/media/jlexreview/avatar/".$nfile))
{
// redirect to this file
$app->redirect($url);
} else {
// create thumb
require_once JPATH_ADMINISTRATOR.'/components/com_jlexreview/libs/class.image.php';
$resizeObj = new abeautifulsite\SimpleImage($thumb);
try {
$nthumb = JPATH_ROOT.'/media/jlexreview/avatar/' . $nfile;
$resizeObj->thumbnail(160, 160)
->save($nthumb);
} catch (Exception $e) {}
$app->redirect($url);
}
}
}
break;
}
}
}
}
$app->redirect($default);
}
}