| 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/annonces/plugins/user/djcfplans/ |
Upload File : |
<?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 plgUserdjcfplans extends JPlugin
{
public function onUserAfterLogin($options)
{
$user = $options['user'];
$db = JFactory::getDBO();
$query = "SELECT * FROM #__djcf_plans_subscr WHERE user_id=".$user->id." ORDER BY id DESC ";
$db->setQuery($query);
$user_plans = $db->loadObjectList();
$query = "SELECT * FROM #__djcf_plans";
$db->setQuery($query);
$plans = $db->loadObjectList('id');
$plans_plugin = JPluginHelper::getPlugin('djclassifieds', 'plans');
if(!$plans_plugin){
return;
}
$plugin_params = new JRegistry($plans_plugin->params);
$free_expiration = $plugin_params->get('ps_free_plan_expiration','0'); // 'expiration date or 0 adverts limit reached' OR 'only when expiration date reached'
for($i=0;$i<10;$i++){
$plan_id = $this->params->get('plan_id'.$i, '');
if($plan_id && isset($plans[$plan_id])){
if(isset($user->groups[$this->params->get('usergroup'.$i, '')])){
$plan_found = 0;
$plan_active = 0;
foreach($user_plans as $uplan){
if($plan_id==$uplan->plan_id){
$plan_found++;
$free_expiration_check = $free_expiration == '0' ? $uplan->adverts_available : true;
if(($uplan->date_exp > JFactory::getDate()->toSQL() || $uplan->date_exp == '0000-00-00 00:00:00') && ($plans[$plan_id]->price > 0 || ($plans[$plan_id]->price == 0 && $free_expiration_check))){
$plan_active++;
break;
}
}
}
if($plan_active==0 && ($plan_found==0 || $this->params->get('plan_renew'.$i, '')==1)){
$plan = $plans[$plan_id];
$registry = new JRegistry();
$registry->loadString($plan->params);
$plan_params = $registry->toObject();
$date_exp = $plan_params->days_limit ? JFactory::getDate('now +'.$plan_params->days_limit.'day') : '0000-00-00 00:00:00';
$query = "INSERT INTO #__djcf_plans_subscr (`user_id`,`plan_id`,`adverts_limit`,`adverts_available`,`date_start`,`date_exp`,`plan_params`) "
."VALUES (".$user->id.",".$plan->id.",".$plan_params->ad_limit.",".($plan_params->ad_limit == '-1' ? '9999999' : $plan_params->ad_limit).",".$db->q(JFactory::getDate()->toSQL()).",".$db->q($date_exp).",".$db->q(addslashes($plan->params)).")";
$db->setQuery($query);
$db->execute();
}
}
}
}
}
}