 |
|
Code (PHP)
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Gologin
*
* Glologin Controller
*
* @package gologin
* @author Nost radius
* @version 1.0
* @based on Nost radius management
* @license GPL/GNU License Copyright (c) 2008 Nost Computer
*/
Class Gologin extends Hotspotlogin_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper(array('security'));
$this->load->library(array('form_validation'));
$this->location = $this->uri->segment(3);
if($this->agent->browser()=='Internet Explorer' && $this->agent->version()<7) $this->ie6 = TRUE;
$use_template = (($this->agent->is_mobile()) || (isset($this->ie6))) ? TEMPLATES: $this->config->item('template');
$template_url = str_replace(':3990','',base_url());
$this->template->write('template_path',$template_url.'templates/hotspotlogin/'.$use_template.'/');
}
function index()
{
if($this->agent->browser()=='Internet Explorer' && $this->agent->version()<7) $ie6 = TRUE;
if($this->agent->is_mobile() || isset($this->ie6))
{
$state = $this->input->get('res', TRUE);
$userurl = $this->input->get('userurl', TRUE);
$redirurl = $this->input->get('redirurl', TRUE);
$reply = $this->input->get('reply', TRUE);
if($userurl!="") $gourl = $userurl;
if($redirurl!="") $gourl = $redirurl;
$form = array(
'challenge'=>$this->input->get('challenge', TRUE),
'uamip'=>$this->input->get('uamip', TRUE),
'uamport'=>$this->input->get('uamport', TRUE),
'userurl'=>$this->input->get('userurl', TRUE)
);
if($state=="success") $this->template->write('meta_refresh', meta('refresh', '0;url='.$gourl, 'equiv'));
if($reply) $this->template->write('message', $reply);
$post_url = str_replace(':3990','',site_url('/mobile'.$this->uri->segment(3)));
$this->template ->write('auth_url',$post_url)
->parse_view('hidden_form', 'public/mobile/hidden', $form);
}
$form['header'] = 'KP-Hotspot';
$config = $this->siteconfigmodel->getConfig('global_config');
$conf_data = $this->session->_unserialize($config->value);
$sigupnurl = ($conf_data['reg_on_off']==1) ? anchor('signup','Signup','id="signup"') : '';
$nas_id = ($this->agent->is_mobile()) ? $this->input->get('nasid', TRUE) : $this->session->userdata('nasid');
$ap = $this->remotemodel->getAccesspoint('accesspoint.login_page,accesspoint.register',array('nas.nasname'=>$nas_id));
$content_login = $ap->row();
$login_page = $content_login->login_page;
$content = (isset($this->ie6)) ? $this->template ->write_view('login_content','public/mobile/agen_view',array('login_page'=>$login_page)) : $this->template->write('login_content',$login_page);
$this->template ->write('site-name','Nost Hotspot')
->write('header',$form['header'])
->write('signup_url', ($content_login->register==1) ? $sigupnurl : '')
->parse_view('body', 'themes/hotspotlogin/loginform', $form)
->render();
}
function auth()
{
$ap = $this->remotemodel->getAccesspoint('nas.secret',array('nas.nasname'=>$this->session->userdata('nasid')));
$uamsecret = $ap->row();
$username = (isset($_GET['username'])) ? $_GET['username'] : '' ;
$password = (isset($_GET['password'])) ? $_GET['password'] : '' ;
$challenge = (isset($_GET['challenge'])) ? $_GET['challenge'] : '' ;
$user = $this->gologinmodel->getEncryption($username);
$hexchal = @pack ("H32", $challenge);
if ($uamsecret->secret) {
$newchal = pack ("H*", md5($hexchal . $uamsecret->secret));
} else {
$newchal = $hexchal;
}
$encryption = (isset($user->encryption) ? $user->encryption : '' );
switch($encryption) {
case 'md5' : $pass_decode = substr(md5($password),0,15);
break;
case 'crypt' : $pass_decode = crypt($password,"BL");
break;
case 'md5ums' : $pass_decode = substr(md5("O]O" . $password . "O[O"),0,15);
break;
default : $pass_decode = $password;
}
$response['response'] = md5("\0" . $pass_decode . $newchal);
print "chilliJSON.reply(".json_encode($response).")";
}
function popup()
{
$config = $this->siteconfigmodel->getConfig('global_config');
$conf_data = $this->session->_unserialize($config->value);
$ap = $this->remotemodel->getAccesspoint('accesspoint.popup_page',array('nas.nasname'=>$this->session->userdata('nasid')));
$content_login = $ap->row();
$form_data = array(
'changepwd_url'=>site_url('/gologin/changepass'),
'contract_url'=>site_url('/gologin/contract'),
'popup_message'=>$content_login->popup_page,
'popup_content'=>$conf_data['editor']
);
// โหลดป๊อบอัพ
$this->template ->add_css('forms.css')
->write('site-name','User status')
->parse_view('body', 'themes/hotspotlogin/popup', $form_data)
->render();
}
function dcontent($uid)
{
$data = $this->gologinmodel->getPopupcontent($uid);
print (isset($data->popup_page)) ? $data->popup_page : '';
}
function macdeny()
{
$this->template ->add_region('title')
->write('site-name','Your device is not allow')
->parse_view('body', 'themes/hotspotlogin/mac',array())
->render();
}
function changepass()
{
$data = array('username'=>$this->uri->segment(3));
$this->load->view('public/userform/changepass',$data);
}
function contract()
{
$this->load->model('usermodel');
$message_field = array(
array(
'field' => 'subject',
'label' => 'Subject',
'rules' => 'required'
),
array(
'field' => 'message',
'label' => 'Message',
'rules' => 'required'
)
);
$this->form_validation->set_rules($message_field);
if($this->form_validation->run() == TRUE)
{
$data = array(
'username'=>$_GET['uid'],
'subject'=>$_POST['subject'],
'message'=>$_POST['message'],
'date'=>date('Y-m-d H:i:s')
);
$this->db->insert('message',$data);
print json_encode(array('sucess'=>true,'message'=>'<div align="center">ข้อความถูกส่งแล้ว</div>'));
}
else
{
echo "<div id=\"message_box\">".
form_open('','name="msg_form" id="msg"').
form_label('หัวข้อ:'.nbs(5),'subject').
form_input('subject','','id="subject" autocomplete="off" class="validate[required] text-input"'). br(2).
form_label('ข้อความ:','message').
form_textarea(array('name'=>'message','style'=>'width:100%;','id'=>'message','class'=>'validate[required] text-input')).br(1)."
<input type=\"submit\" name=\"send\" id=\"send\" value=\"ส่งข้อความ\"/>".
form_close().
"</div>";
}
}
function changepw()
{
$old_password = $this->input->post('old_password', TRUE);
$new_passowrd = $this->input->post('new_password', TRUE);
$confirm_password = $this->input->post('comfirm_password', TRUE);
$username = $this->input->post('username', TRUE);
$this->load->model('usermodel');
$oldpass = $this->usermodel->getVoucher('password,billingplan',array('username'=>$username))->row();
if($oldpass->password==$old_password)
{
if($new_passowrd!=$confirm_password)
{
$rep['rep'] = FALSE;
$rep['msg'] = $this->lang->line('confirm_newpass');
}
else
{
$user_data = array('username'=>$username,'password'=>$new_passowrd);
$rep = $this->usermodel->editVoucher($user_data);
}
}
else
{
$rep['rep'] = FALSE;
$rep['msg'] = $this->lang->line('old_pass_false');
}
print json_encode($rep);
}
function check_user()
{
$die = $this->gologinmodel->checkUserdie($_GET['username']);
if($die)
{
$rep['rep'] = FALSE;
$rep['msg'] = sprintf($this->lang->line('online_check_false'),$_GET['username']);
}
else
{
$rep['rep'] = TRUE;
$rep['msg'] = sprintf($this->lang->line('online_check_true'),$_GET['username']);
}
print json_encode($rep);
}
function user_detail()
{
$this->load->helper('number');
$user_data = $this->gologinmodel->getUserdata($this->uri->segment(3));
$time = ($user_data->type=='timetofinish') ? unix_to_human(strtotime(date('Y-m-d H:i:s', strtotime($user_data->start_time)) . ' + '.$user_data->amount.' day'), TRUE, 'th') : unix_to_human(strtotime(date('Y-m-d H:i:s', strtotime($user_data->start_time)) . ' +60 day'), TRUE, 'th');
if($user_data->type=='timetofinish') {
$format_time = 'DHMS';
} else {
$format_time = 'HMS';
}
$profile = $this->session->_unserialize($user_data->userprofile);
$data = array(
'plan_type'=>$user_data->type,
'plan_name'=>$user_data->plan,
'start_time'=>$user_data->start_time,
'packet_used'=>$user_data->packet_used,
'end_time'=>$time,
'format_time'=>$format_time,
'userprofile'=>$profile
);
print json_encode($data);
}
function help()
{
return TRUE;
}
}
/* End of file gologin.php */
/* Location: ./system/nostradius/controllers/gologin.php */
ยาวหน่อยนะครับ
ปกติเมื่อ login ผ่าน มันก็จะเด้งเข้าเว็ปก่อนหน้านั้นอะครับ
แต่บางครั้งเมื่อ login แล้วมันก็ขึ้นหน้ามั่วๆครับ ไม่รู้จะทำยังไง
ขอบคุณล่วงหน้าครับผม
Tag : PHP
|
|
 |
 |
 |
 |
Date :
2011-09-11 14:34:51 |
By :
goradole |
View :
3187 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |