config = $config;
$this->template = $template;
$this->user = $user;
$this->helper = $helper;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
$this->user->add_lang_ext('cartedesmembres/cdm', 'cdm');
}
/**
* Base controller to be accessed with the URL /newspage/{page}
* (where {page} is the placeholder for a value)
*
* @param int $page Page number taken from the URL
* @return Symfony\Component\HttpFoundation\Response A Symfony Response object
*/
public function cdm($page = 1)
{
global $db;
if (isset($_POST['protection'])){
if (request_var('protection','',false,false)!=md5($this->config['cdm_CODE'])){
$db->sql_close();
die('wrong protection code, cdm_CODE incorrect ?');
}
if (isset($_POST['type']) && request_var('type','',false,false)=='VERSION'){
echo '2';
$db->sql_close();
exit;
}
if (isset($_POST['type']) && request_var('type','',false,false)=='GET_LISTE_POSITIONNE'){
$sql = 'SELECT user_id FROM ' . USERS_TABLE . ' WHERE user_type IN ('.USER_NORMAL.','.USER_FOUNDER.') and user_cdm=1';
$result = $db->sql_query($sql);
$userscdm_ids=array();
while ($row = $db->sql_fetchrow($result)) { $userscdm_ids[] = $row['user_id']; }
echo implode(',',$userscdm_ids);
$db->sql_close();
exit;
}
if (isset($_POST['type']) && request_var('type','',false,false)=='UPDATE_LISTE_POSITIONNE'){
if (isset($_POST['add'])){
$lst=preg_replace('/[^0-9,]/', '',request_var('add','',false,false));
if ($lst!=''){
$sql = 'UPDATE ' . USERS_TABLE . ' SET user_cdm=1 WHERE user_id IN ('.$lst.')';
if( !($result = $db->sql_query($sql))){$db->sql_close();echo "ERROR ".$sql;exit;}
}
}
if (isset($_POST['del'])){
$lst=preg_replace('/[^0-9,]/', '',request_var('del','',false,false));
if ($lst!=''){
$sql = "UPDATE " . USERS_TABLE . " SET user_cdm=0 WHERE user_id IN (".$lst.")";
if( !($result = $db->sql_query($sql))){$db->sql_close();echo "ERROR ".$sql;exit;}
}
}
echo "OK";
$db->sql_close();
exit;
}
}
else{
if ($this->user->data['user_id'] != ANONYMOUS){
if ($this->config['cdm_ID']=='0' || strlen($this->config['cdm_CODE'])<4 || strlen($this->config['cdm_NOM'])<4){
// echo 'assign';
$this->template->assign_vars(array(
'cdm_INFO'=>$this->user->lang['CDM_NO_CONFIG'],
));
return $this->helper->render('cdm_body.html');
}
$t=time();
$redirect=$this->config['cdm_URL'].'/add?c='.md5($this->config['cdm_ID'].'_'.$this->user->data['user_id'].'_'.$this->user->data['username'].'_'.$t.'_'.$this->config['cdm_CODE']).'&ids='.$this->config['cdm_ID'].'&t='.$t.'&idp='.$this->user->data['user_id'].'&p='.urlencode($this->user->data['username']);
$redirectjs='redirect';
$this->template->assign_vars(array(
'cdm.USERNAME'=>$this->user->data['username'],
'cdm.USER_ID'=>$this->user->data['user_id'],
'cdm.CDM_ID'=>$this->config['cdm_ID'],
'cdm.CDM_CODE'=>$this->config['cdm_CODE'],
'cdm.CDM_URL'=>$this->config['cdm_URL'],
'cdm_INFO'=>$redirectjs,
));
//redirect($redirect); //non possible
//exit;
}
else{
//trigger_error('SORRY_AUTH_READ');
login_box('', $this->user->lang['CDM_HAVE_TO_LOGIN']);
}
}
/*
* The render method takes up to three other arguments
* @param string Name of the template file to display
* Template files are searched for two places:
* - phpBB/styles//template/
* - phpBB/ext//styles//template/
* @param string Page title
* @param int Status code of the page (200 - OK [ default ], 403 - Unauthorized, 404 - Page not found, etc.)
*/
return $this->helper->render('cdm_body.html');
}
}