Files
2021-10-09 21:59:14 -04:00

144 lines
5.0 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Mobile extends Mobile_Controller {
public function index() {
$data = array();
$this->login();
}
public function login() {
$data = array();
$data["login_message"] = "";
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() !== false) {
$data['username'] = strtolower($this->input->post('username')); // '08174596144';
$data['password'] = $this->input->post('password'); //'7978';
$data['sessionid'] = rand(10000, 99999) . "A" . rand(10000, 99999);
$data['action'] = WRENCHBOARD_ACCOUNT_LOGIN;
$this->load->model('backend_model');
$out = array();
$res = $this->backend_model->wrenchboard_api($data, $out);
$is_live = $this->backend_model->cfgReadChar("system.live");
//print_r($out);
if ($res == PHP_LOGIN_OK) {
$this->load->model('account_model');
$ret = $this->account_model->username_data($data);
if ($res !== false) {
$data["login_message"] = "Welcome...";
// yes person has an account
$_SESSION['session_id'] = $out["session"];
$_SESSION['username'] = $this->input->post('username');
$_SESSION['name'] = $this->input->post('username');
$_SESSION['firstname'] = $ret->firstname;
$_SESSION['lastname'] = $ret->lastname;
$_SESSION['email'] = $ret->email;
$_SESSION['member_id'] = $ret->id;
$_SESSION['log_count'] = 0;
$_SESSION['mesaage_count'] = 0;
$this->findOffers($_SESSION['email']);
$_SESSION['message_snapshot'] = $this->myMessagesSnapshot();
$_SESSION['total_jobs'] = 0;
if (trim($ret->profile_pic) == '') {
// Show default picture
$_SESSION['profile_picture'] = "../smedia/DEFAULTS/default-profile.png";
} else {
// show the profile picture
$_SESSION['profile_picture'] = "../smedia/" . ($is_live ? "LIVE" : "TEST") . "/profile/" . $ret->profile_pic;
}
$this->logUser('Account login');
$this->refreshAccountDetail($_SESSION['member_id']);
// $this->getSessionArray();
redirect('mobile/mobiledash');
}
} else {
//$data["login_message"] = "<div class=\"alert alert-danger no-border\">Invalid username or password</div>";
$data["login_message"] = "Invalid username or password";
}
$res = false; // $this->login_model->verify_login($data);
} else {
echo validation_errors();
}
$this->renderMobileExtPage('mobile_index', $data);
// $this->home2();
}
public function mobiledash() {
$data = array();
$this->renderMobileSecurePage('mobile_dash', $data);
}
public function signup() {
$data = array();
$data["signup_error"] = "";
$firstname = NULL;
$country = 'NG';
$lastname = NULL;
$email = NULL;
$password = NULL;
$terms = NULL;
$news = NULL;
$terms = NULL;
$submit = NULL;
extract($_POST);
$this->load->model('combo_model');
$this->combo_model->defaultComboMessage = 'Select your Country';
$data['country_combo'] = $this->combo_model->getCountryCombo('country', $country);
$this->renderMobileExtPage('mobile_signup', $data);
// $this->home2();
}
public function refreshAccountDetail($member_id) {
$this->load->model('account_model');
$qr = $this->account_model->loadAccountData($member_id);
// print_r($qr);
$_SESSION['current_balance'] = $qr[0]['balance'];
$_SESSION['active_task'] = $this->account_model->loadActiveTaskCount($member_id);
}
private function renderMobileExtPage($mobile_page_name, $data) {
$this->load->view('mobile/mobile_ext_header', $data);
$this->load->view('mobile/' . $mobile_page_name, $data);
$this->load->view('mobile/mobile_ext_footer', $data);
}
private function renderMobileSecurePage22($mobile_page_name, $data) {
$this->load->view('mobile/secure/mobile_secure_header', $data);
$this->load->view('mobile/secure/' . $mobile_page_name, $data);
$this->load->view('mobile/secure/mobile_secure_footer', $data);
}
public function logout() {
$data = array();
$this->login();
}
}