/application/controllers/main.php
PHP | 515 lines | 403 code | 90 blank | 22 comment | 40 complexity | 67d823e7a7ebe6ae7b5fab6df20c0a02 MD5 | raw file
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class Main extends MY_Controller
- {
- public function __construct()
- {
- parent::__construct();
- $referrerId = get_cookie('ref');
- $referrerData = $referrerId ? $this->ion_auth->user($referrerId)->row() : null;
- $this->layoutData['registerForm'] = $this->loadPartialView('partial/register', compact('referrerData'));
- $this->layoutData['loginForm'] = $this->loadPartialView('partial/login');
- $this->layoutData['forgotForm'] = $this->loadPartialView('partial/forgot');
- $this->layoutData['activationForm'] = $this->loadPartialView('partial/activation');
- $this->load->driver('cache', array('adapter' => 'file'));
- $this->load->model('investment_model', 'Investment');
- $this->load->model('result_model', 'Result');
- //$this->output->enable_profiler(true);
- }
- public function index()
- {
- if ($this->ion_auth->logged_in())
- redirect(site_url('member.html'), 'refresh');
- $this->load->model('user_model', 'User');
- $usersCount = $this->User->getActiveUsersCount();
- $trafficValue = $this->User->getProvenTrafficValue();
- $this->loadView('start', 'My Traffic Value', compact('usersCount', 'trafficValue'));
- }
- public function referral($username)
- {
- // Set referrer cookie here and redirect to the index page
- // only if not already set
- if (!get_cookie('ref'))
- {
- $refData = $this->ion_auth->where('username', $username)->limit(1, 0)->users()->row();
- if ($refData)
- {
- $cookie = array(
- 'name' => 'ref',
- 'value' => $refData->id,
- 'expire' => '86500'
- );
- $this->input->set_cookie($cookie);
- }
- }
- redirect ('/', 'refresh');
- }
- public function languages()
- {
- if (!$this->input->is_ajax_request())
- {
- show_404(); // prevents direct access to this function - Request has to be AJAX
- }
- $this->setLayout(null);
- echo $this->loadPartialView('languages');
- }
- public function contact()
- {
- if (!$this->input->is_ajax_request())
- {
- $this->loadView('contact', 'My Traffic Value: Contact Form');
- }
- else
- {
- $data = null;
- if ($this->form_validation->run('contact')) //Defined in form_validation
- {
- $this->load->model('contact_model', 'Contact');
- $post = $this->input->post();
- $contactData = array(
- 'email' => $post['email'],
- 'name' => $post['name'],
- 'subject' => $post['subject'],
- 'message' => $post['message']
- );
- if ($this->Contact->store($contactData)===TRUE)
- {
- $data = array(
- 'success' => 'success',
- 'html' => '<strong>Thank you for your message!</strong>'
- );
- }
- else
- {
- $data = array(
- 'error' => 'Your message was not sent'
- );
- }
- }
- else
- {
- $data = array(
- 'errorElements' => array(
- 'name' => form_error('name'), //It must take all errors separately
- 'email' => form_error('email'),
- 'subject' => form_error('subject'),
- 'message' => form_error('message')
- )
- );
- }
- echo json_encode($data);
- }
- }
- public function support($code = null)
- {
- if ($this->ion_auth->logged_in())
- {
- // Force logged in users to use the proper support features
- redirect(site_url('member/support.html'), 'refresh');
- }
- if ($code)
- {
- $this->load->model('support_ticket_model', 'Ticket');
- $ticketData = $this->Ticket->get($code);
- if (!$ticketData)
- {
- $this->session->set_flashdata('error', 'There is no support ticket with that code');
- redirect(site_url('support.html'), 'refresh');
- }
- $ticket = $ticketData['ticket'];
- $messages = $ticketData['messages'];
- }
- if (!$this->input->is_ajax_request())
- {
- if ($code)
- $this->loadView('support/guest/view', 'My Traffic Value: Support for Guest', compact('ticket', 'messages'));
- else $this->loadView('support/guest/index', 'My Traffic Value: Support for Guest');
- }
- else
- {
- $data = null;
- if ($code)
- {
- if ($this->form_validation->run('support_reply')) // Defined in form_validation
- {
- $post = $this->input->post();
- $ticketData = null;
- if (isset ($post['status']))
- {
- $ticketData = array(
- 'status' => $post['status']
- );
- }
- $messageData = array(
- 'ticket_id' => $ticket->id,
- 'message' => $post['message']
- );
- if ($this->Ticket->store($messageData, $ticketData) === TRUE)
- {
- $data = array(
- 'success' => 'success',
- 'html' => '<strong>Thank you for your message!</strong>',
- 'redirect' => array(
- 'url' => site_url('support/' . $code . '.html'),
- 'timeout' => 1000
- )
- );
- }
- else
- {
- $data = array(
- 'error' => 'Your message was not sent'
- );
- }
- }
- else
- {
- $data = array(
- 'errorElements' => array(
- 'message' => form_error('message')
- )
- );
- }
- }
- else
- {
- if ($this->form_validation->run('support')) // Defined in form_validation
- {
- $this->load->model('support_ticket_model', 'Ticket');
- $code = uniqid();
- $post = $this->input->post();
- $ticketData = array(
- 'code' => $code,
- 'email' => $post['email'],
- 'subject' => $post['subject']
- );
- $messageData = array(
- 'message' => $post['message']
- );
- if ($this->Ticket->store($messageData, $ticketData) === TRUE)
- {
- $this->load->model('email_model', 'EmailQueue');
- // Send the email to the guest so he/she can refer back to it
- $ticketUrl = site_url('support/' . $code . '.html');
- $this->EmailQueue->store($post['email'], 'Support Ticket #' . $ticketData['id'], 'emails/support/ticket_created.php' , compact('ticketUrl'));
- $data = array(
- 'success' => 'success',
- 'html' => $this->loadPartialView('support/guest/created', compact('code'))
- );
- }
- else
- {
- $data = array(
- 'error' => 'Your message was not sent'
- );
- }
- }
- else
- {
- $data = array(
- 'errorElements' => array(
- 'email' => form_error('email'),
- 'subject' => form_error('subject'),
- 'message' => form_error('message')
- )
- );
- }
- }
- echo json_encode($data);
- }
- }
- public function blackhole()
- {
- $this->session->set_flashdata('info', 'Page is not yet available');
- redirect('/');
- }
- //About us
- public function aboutus()
- {
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('About Us');
- $this->loadView('common/aboutus', 'My Traffic Value: About Us', compact('guest'));
- }
- //Advertise
- public function ads()
- {
- $this->addStyleSheet(asset('styles/ads.css'));
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('Adversising');
- $this->loadView('common/ads', 'My Traffic Value: Advertising', compact('guest'));
- }
- //Terms and conditions
- public function terms()
- {
- // If there is a logged in user then we need to load a different template
- // which comes with different data to be displayed
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('Terms and Conditions');
- $this->loadView('common/terms', 'My Traffic Value: Terms and Conditions', compact('guest'));
- }
- //Deposit Methods
- public function depositmethods()
- {
- $this->addStyleSheet(asset('styles/depositmethods.css'));
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('Deposit Methods');
- $this->load->model('payment_method_model', 'PaymentMethod');
- $accounts = array();
- $accountList = $this->PaymentMethod->getList();
- foreach ($accountList as $account)
- $accounts[$account->code] = $this->PaymentMethod->getLatestBillDetails($account->code);
- $this->loadView('common/depositmethods', 'My Traffic Value: Deposit Methods', compact('guest', 'accounts'));
- }
- //Results
- public function results()
- {
- $this->addStyleSheet(asset('styles/results.css'));
- $this->addJavascript(asset('scripts/paging.js'));
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('Results');
- $results = $this->result_page(1, 5, true);
- $this->loadView('results/index', 'My Traffic Value: Results', compact('guest', 'results'));
- }
- public function result_page($page = 1, $perPage = 5, $return = false)
- {
- $count = $this->Result->getResultCount();
- $data = $this->Result->getResultSubset($page);
- $paging = generatePagination(site_url('main/result_page'), $count, $page, 5, true);
- $hasPages = $count > 5;
- $results = $this->load->view('results/partial/results', compact ('data', 'method', 'paging', 'hasPages'), true);
- if ($return)
- return $results;
- echo $results;
- }
- public function result_details($date)
- {
- $data = $this->Result->card_data($date, true);
- if (!$data)
- {
- $this->session->set_flashdata('error', 'No result for that date');
- redirect('results.html');
- }
- $this->addStyleSheet(asset('styles/results.css'));
- $this->addJavascript(asset('scripts/paging.js'));
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup(anchor('results.html', 'Results') . ' - ' . date("l jS, F Y", $data->date));
- $this->loadView('results/details', 'My Traffic Value: Results - ' . date("d/m/Y", $data->date), compact('guest', 'data', 'date'));
- }
- public function fast_track_details($date, $page = 1, $perPage = 15)
- {
- $firstLoad = false;
- if ($page == 0)
- {
- // little hack
- $page = 1;
- $firstLoad = true;
- }
- $count = $this->Result->getFastTrackCount($date);
- $data = $this->Result->getFastTrackSubset($date, $page, $perPage);
- $paging = generatePagination(site_url('main/fast_track_details/' . $date), $count, $page, $perPage, true);
- $hasPages = $count > $perPage;
- $fastTrack = $this->load->view('results/partial/fast_track_details', compact ('data', 'method', 'paging', 'hasPages'), true);
- if (!$firstLoad)
- echo $fastTrack;
- else $this->load->view('results/fast_track_details', compact ('fastTrack'));
- }
- public function invest_log($cyclerId = 1)
- {
- $roundData = $this->Investment->getCyclerData($cyclerId);
- if (!$roundData || is_null($roundData->start_date))
- {
- $this->session->set_flashdata('error', 'Sorry this round has not been found');
- redirect('investment/log.html');
- }
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('Invest Log');
- $lastRound = $this->Investment->lastOpenRound();
- $active = $this->Investment->getActiveCycler();
- $paid110 = $this->Investment->getCycledAmount($cyclerId);
- $paid125 = $this->Investment->getDailyPaidAmount($cyclerId);
- $participants = $this->Investment->getParticipants($cyclerId);
- $invested = $this->Investment->getTotalInvested($cyclerId);
- $longest = $this->Investment->getLongest($cyclerId);
- $log110 = $this->log110($cyclerId, 1, 20, true);
- $log125 = $this->log125($cyclerId, 1, 20, true);
- $this->addStyleSheet(asset('styles/investments.css'));
- $this->addJavascript(asset('scripts/invest.js'));
- $this->addJavascript(asset('scripts/paging.js'));
- $this->loadView('investment/log', 'My Traffic Value: Invest Log', compact('guest', 'roundData', 'active', 'lastRound', 'paid110', 'paid125', 'participants', 'invested', 'longest', 'log110', 'log125'));
- }
- public function log110($cyclerId, $page = 1, $perPage = 20, $return = false)
- {
- $count = $this->Investment->getCycledUnitsCount($cyclerId);
- $data = $this->Investment->getCycledUnitsSubset($cyclerId, $page, $perPage);
- $paging = generatePagination(site_url('main/log110/' . $cyclerId), $count, $page, $perPage, true);
- $hasPages = $count > $perPage;
- $investments = $this->load->view('investment/partial/log110', compact ('data', 'method', 'paging', 'hasPages'), true);
- if ($return)
- return $investments;
- echo $investments;
- }
- public function log125($cyclerId, $page = 1, $perPage = 20, $return = false)
- {
- $count = $this->Investment->getDailyPayCount($cyclerId);
- $data = $this->Investment->getDailyPaySubset($cyclerId, $page, $perPage);
- $paging = generatePagination(site_url('main/log125/' . $cyclerId), $count, $page, $perPage, true);
- $hasPages = $count > $perPage;
- $dailypay = $this->load->view('investment/partial/log125', compact ('data', 'method', 'paging', 'hasPages'), true);
- if ($return)
- return $dailypay;
- echo $dailypay;
- }
- //Traffic Value
- public function trafficvalue()
- {
- $this->addStyleSheet(asset('styles/trafficvalue.css'));
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('Results');
- $this->load->model('user_model', 'User');
- $levelsValueData = $this->User->getLevelsValueData();
- $this->layoutData['member_page'] = 'Traffic Value';
- $this->loadView('common/trafficvalue', 'My Traffic Value: Traffic Value', compact('guest', 'levelsValueData'));
- }
- //COI Future Business Group Ltd
- public function coi()
- {
- echo $this->loadPartialView('common/coi');
- }
- /**
- * Loading Pop-up view of arranging a meeting Main > Arrange a meeting
- */
- public function meeting()
- {
- echo $this->loadPartialView('common/meeting');
- }
- //Graph for Money Flow
- public function moneyflow()
- {
- echo $this->loadPartialView('common/moneyflow');
- }
- //FAQ
- public function faq()
- {
- $this->addJavascript(asset('scripts/faq.js'));
- $this->load->model('faq_model','Faq');
- $faqs = $this->Faq->getFaqs();
- $this->load->library('text_format');
- $guest = !$this->ion_auth->logged_in();
- if (!$guest)
- $this->__memberPageSetup('FAQ');
- $isAdmin = false;
- $this->loadView('common/faq', 'My Traffic Value: FAQ', compact('guest','faqs','isAdmin'));
- }
- // This will be called to set up a page viewed from a member's eye
- private function __memberPageSetup($title)
- {
- $this->layoutData['member_page'] = $title;
- $this->profile = $this->ion_auth->user()->row();
- $this->setLayout('layout/member');
- $this->layoutData['name'] = $this->profile->username;
- // If admin, link to admin zone:
- if ($this->ion_auth->is_admin())
- $this->layoutData['name'] .= ' - ' . anchor('admin', 'Admin');
- }
- public function video()
- {
- echo $this->loadPartialView('partial/video');
- }
- }