Advertisement
Guest User

controller.account_panel.php

a guest
May 12th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 62.60 KB | None | 0 0
  1. <?php
  2.     in_file();
  3.  
  4.     class account_panel extends controller
  5.     {
  6.         protected $vars = [], $errors = [];
  7.  
  8.         public function __construct()
  9.         {
  10.             parent::__construct();
  11.             $this->load->helper('website');
  12.             $this->load->lib('session', ['DmNCMS']);
  13.             $this->load->lib('csrf');                        
  14.             $this->load->model('character');
  15.             $this->load->helper('breadcrumbs', [$this->request]);
  16.             $this->load->helper('meta');
  17.             if($this->session->userdata(['user' => 'server'])){
  18.                 $this->load->lib(['game_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']))]);
  19.             }
  20.         }
  21.  
  22.         public function index()
  23.         {
  24.             if($this->session->userdata(['user' => 'logged_in'])){
  25.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.index', $this->vars);
  26.             } else{
  27.                 $this->login();
  28.             }
  29.         }
  30.  
  31.         public function level_reward()
  32.         {
  33.             if($this->session->userdata(['user' => 'logged_in'])){
  34.                 if($this->website->is_multiple_accounts() == true){
  35.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  36.                 } else{
  37.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  38.                 }
  39.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  40.                 $this->vars['level_rewards'] = $this->config->values('level_rewards_config');
  41.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.level_reward', $this->vars);
  42.             } else{
  43.                 $this->login();
  44.             }
  45.         }
  46.  
  47.         public function exchange_lucky_coins()
  48.         {
  49.             if($this->session->userdata(['user' => 'logged_in'])){
  50.                 if($this->website->is_multiple_accounts() == true){
  51.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  52.                 } else{
  53.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  54.                 }
  55.                 $this->vars['coin_config'] = $this->config->values('luckycoin_config', $this->session->userdata(['user' => 'server']));
  56.                 if($this->vars['coin_config']['active'] == 1){
  57.                     unset($this->vars['coin_config']['active']);
  58.                     $this->load->model('account');
  59.                     $this->load->lib('iteminfo');
  60.                     $this->load->model('shop');
  61.                     if(isset($_POST['exchange_coins'])){
  62.                         foreach($_POST as $key => $value){
  63.                             $this->Mcharacter->$key = trim($value);
  64.                         }
  65.                         if(!$this->Maccount->check_connect_stat())
  66.                             $this->vars['error'] = __('Please logout from game.'); else{
  67.                             if(!isset($this->Mcharacter->vars['character']))
  68.                                 $this->vars['error'] = __('Invalid Character'); else{
  69.                                 if(!$this->Mcharacter->check_char())
  70.                                     $this->vars['error'] = __('Character not found.'); else{
  71.                                     if(!isset($this->Mcharacter->vars['lucky_coin']))
  72.                                         $this->vars['error'] = __('Please select option for exchange.'); else{
  73.                                         if(!in_array($this->Mcharacter->vars['lucky_coin'], [10, 20, 30]))
  74.                                             $this->vars['error'] = __('Invalid exchange option selected.'); else{
  75.                                             $this->vars['coin_data'] = $this->Mcharacter->check_amount_of_coins();
  76.                                             if(array_sum($this->vars['coin_data']) < $this->Mcharacter->vars['lucky_coin']){
  77.                                                 $this->vars['error'] = __('You have insufficient amount of coins.');
  78.                                             } else{
  79.                                                 if(array_key_exists($this->Mcharacter->vars['lucky_coin'], $this->vars['coin_config'])){
  80.                                                     $max_prob = $this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']]['max_probability'];
  81.                                                     unset($this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']]['max_probability']);
  82.                                                     $chance = $this->Mcharacter->draw_chance($this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']], $max_prob);
  83.                                                     shuffle($this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']][$chance]);
  84.                                                     $item_key = array_rand($this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']][$chance], 1);
  85.                                                     $cat = $this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']][$chance][$item_key][1];
  86.                                                     $id = $this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']][$chance][$item_key][0];
  87.                                                     $new_coins = array_sum($this->vars['coin_data']) - $this->Mcharacter->vars['lucky_coin'];
  88.                                                     $this->iteminfo->setItemData($id, $cat, $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'item_size'));
  89.                                                     $data = $this->iteminfo->item_data;
  90.                                                     if($vault = $this->Mshop->get_vault_content()){
  91.                                                         $space = $this->Mshop->check_space($vault['Items'], $data['x'], $data['y'], $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'wh_multiplier'), $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'item_size'), $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'wh_hor_size'), $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'wh_ver_size'));
  92.                                                         if($space === null){
  93.                                                             $this->vars['error'] = $this->Mshop->errors[0];
  94.                                                         } else{
  95.                                                             $item_data = $this->vars['coin_config'][$this->Mcharacter->vars['lucky_coin']][$chance][$item_key];
  96.                                                             if(is_array($item_data[5])){
  97.                                                                 $lvl = rand($item_data[5][0], $item_data[5][1]);
  98.                                                             } else{
  99.                                                                 $lvl = $item_data[5];
  100.                                                             }
  101.                                                             if($item_data[6] == -1){
  102.                                                                 $skill = rand(0, 1);
  103.                                                             } else{
  104.                                                                 $skill = $item_data[6];
  105.                                                             }
  106.                                                             if($item_data[7] == -1){
  107.                                                                 $luck = rand(0, 1);
  108.                                                             } else{
  109.                                                                 $luck = $item_data[7];
  110.                                                             }
  111.                                                             if(is_array($item_data[8])){
  112.                                                                 $opt = rand($item_data[8][0], $item_data[8][1]);
  113.                                                             } else{
  114.                                                                 $opt = $item_data[8];
  115.                                                             }
  116.                                                             if($this->Mcharacter->remove_old_coins($this->vars['coin_data'])){
  117.                                                                 $this->load->lib("createitem", [MU_VERSION, SOCKET_LIBRARY]);
  118.                                                                 if($new_coins > 0){
  119.                                                                     if($new_coins > 255){
  120.                                                                         $coins_left = [];
  121.                                                                         while($new_coins >= 255){
  122.                                                                             $new_coins -= 255;
  123.                                                                             if($new_coins >= 255){
  124.                                                                                 $coins_left[] = 255;
  125.                                                                             } else{
  126.                                                                                 $coins_left[] = $new_coins;
  127.                                                                             }
  128.                                                                         }
  129.                                                                         $coins_left[] = 255;
  130.                                                                         $i = -1;
  131.                                                                         if($this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'item_size') == 64){
  132.                                                                             $serial2 = true;
  133.                                                                         }
  134.                                                                         foreach($this->vars['coin_data'] AS $key => $value){
  135.                                                                             $i++;
  136.                                                                             if(array_key_exists($i, $coins_left)){
  137.                                                                                 $this->vars['coin_data'][$key] = $this->createitem->make(100, 14, false, [], $coins_left[$i], array_values($this->Mshop->generate_serial())[0], $serial2)->to_hex();
  138.                                                                             } else{
  139.                                                                                 $this->vars['coin_data'][$key] = str_pad("", $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'item_size'), "F");
  140.                                                                             }
  141.                                                                         }
  142.                                                                         $this->Mcharacter->add_multiple_new_coins($this->vars['coin_data']);
  143.                                                                     } else{
  144.                                                                         $new_coin_item = $this->createitem->make(100, 14, false, [], $new_coins, array_values($this->Mshop->generate_serial())[0], $serial2)->to_hex();
  145.                                                                         $this->Mcharacter->add_new_coins(array_keys($this->vars['coin_data'])[0], $new_coin_item);
  146.                                                                     }
  147.                                                                 }
  148.                                                                 //$this->createitem->make($id, $cat, false, [], $new_coins, array_values($this->Mshop->generate_serial())[0], $serial2)->to_hex()
  149.                                                                 // $this->Mshop->generate_new_items($this->Mshop->generate_item_hex($id, $cat, $item_data[2], $item_data[3], $item_data[4], $lvl, $skill, $luck, $opt, $item_data[9], $item_data[10], $item_data[11], $item_data[12]), $space, $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'wh_multiplier'), $this->website->get_value_from_server($this->session->userdata(['user' => 'server']), 'item_size'));
  150.                                                                 $this->Maccount->add_account_log('Exchanged ' . $this->Mcharacter->vars['lucky_coin'] . ' Lucky coins to ' . $data['name'] . '', 0, $this->session->userdata(['user' => 'username']), $this->session->userdata(['user' => 'server']));
  151.                                                                 $this->Mshop->update_warehouse();
  152.                                                                 $this->vars['success'] = sprintf(__('Coins successfully exchanged To %s.'), $data['name']);
  153.                                                             } else{
  154.                                                                 $this->vars['error'] = __('Unable to remove lucky coins from inventory.');
  155.                                                             }
  156.                                                         }
  157.                                                     } else{
  158.                                                         $this->vars['error'] = __('Please open your warehouse in game first.');
  159.                                                     }
  160.                                                 } else{
  161.                                                     $this->vars['error'] = __('Configuration element not found.');
  162.                                                 }
  163.                                             }
  164.                                         }
  165.                                     }
  166.                                 }
  167.                             }
  168.                         }
  169.                     }
  170.                     $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  171.                     $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.exchnage_lucky_coin', $this->vars);
  172.                 } else{
  173.                     $this->disabled();
  174.                 }
  175.             } else{
  176.                 $this->login();
  177.             }
  178.         }
  179.  
  180.         public function reset()
  181.         {
  182.             if($this->session->userdata(['user' => 'logged_in'])){
  183.                 if($this->website->is_multiple_accounts() == true){
  184.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  185.                 } else{
  186.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  187.                 }
  188.                 $this->load->model('account');
  189.                 $reset_config = $this->config->values('reset_config', $this->session->userdata(['user' => 'server']));
  190.                 if(!$reset_config){
  191.                     $this->vars['error'] = __('Reset configuration for this server not found.');
  192.                 } else{
  193.                     if($reset_config['allow_reset'] == 0){
  194.                         $this->vars['error'] = __('Reset function is disabled for this server');
  195.                     } else{
  196.                         unset($reset_config['allow_reset']);
  197.                         $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  198.                         $this->vars['chars'] = [];
  199.                         $this->vars['res_info'] = [];
  200.                         if($this->vars['char_list'] != false){
  201.                             foreach($this->vars['char_list'] AS $char){
  202.                                 foreach($reset_config AS $key => $values){
  203.                                     list($start_res, $end_res) = explode('-', $key);
  204.                                     if($char['resets'] >= $start_res && $char['resets'] < $end_res){
  205.                                         $this->vars['res_info'][$char['name']] = $values;
  206.                                         break;
  207.                                     }
  208.                                 }
  209.                                 $this->vars['chars'][$char['name']] = ['level' => $char['level'], 'Class' => $char['Class'], 'resets' => $char['resets'], 'gresets' => $char['gresets'], 'money' => $char['money'], 'res_info' => isset($this->vars['res_info'][$char['name']]) ? $this->vars['res_info'][$char['name']] : false];
  210.                             }
  211.                         } else{
  212.                             $this->vars['error'] = __('Character not found.');
  213.                         }
  214.                     }
  215.                 }
  216.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.reset_character', $this->vars);
  217.             } else{
  218.                 $this->login();
  219.             }
  220.         }
  221.  
  222.         public function grand_reset()
  223.         {
  224.             if($this->session->userdata(['user' => 'logged_in'])){
  225.                 if($this->website->is_multiple_accounts() == true){
  226.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  227.                 } else{
  228.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  229.                 }
  230.                 $this->load->model('account');
  231.                 $reset_config = $this->config->values('reset_config', $this->session->userdata(['user' => 'server']));
  232.                 $greset_config = $this->config->values('greset_config', $this->session->userdata(['user' => 'server']));
  233.                 if(!$greset_config){
  234.                     $this->vars['error'] = __('Grand Reset configuration for this server not found.');
  235.                 } else{
  236.                     if($greset_config['allow_greset'] == 0){
  237.                         $this->vars['error'] = __('Grand Reset function is disabled for this server');
  238.                     } else{
  239.                         unset($greset_config['allow_greset']);
  240.                         if(isset($reset_config)){
  241.                             unset($reset_config['allow_reset']);
  242.                         }
  243.                         $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  244.                         $this->vars['chars'] = [];
  245.                         $this->vars['gres_info'] = [];
  246.                         if($this->vars['char_list'] != false){
  247.                             foreach($this->vars['char_list'] AS $char){
  248.                                 foreach($greset_config AS $key => $values){
  249.                                     list($start_gres, $end_gres) = explode('-', $key);
  250.                                     if($char['gresets'] >= $start_gres && $char['gresets'] < $end_gres){
  251.                                         $this->vars['gres_info'][$char['name']] = $values;
  252.                                     }
  253.                                 }
  254.                                 $bonus_reset_stats = 0;
  255.                                 if(isset($this->vars['gres_info'][$char['name']])){
  256.                                     if($this->vars['gres_info'][$char['name']]['bonus_reset_stats'] == 1){
  257.                                         $reset_data = [];
  258.                                         foreach($reset_config AS $key => $values){
  259.                                             $reset_range = explode('-', $key);
  260.                                             for($i = $reset_range[0]; $i < $reset_range[1]; $i++){
  261.                                                 $reset_data[$i] = $values['bonus_points'];
  262.                                             }
  263.                                         }
  264.                                         foreach($reset_data AS $res => $data){
  265.                                             if($char['resets'] <= $res)
  266.                                                 break;
  267.                                             $bonus_reset_stats += $data[$this->Mcharacter->class_code_to_readable($char['Class'])];
  268.                                         }
  269.                                     }
  270.                                 }
  271.                                 $this->vars['chars'][$char['name']] = ['level' => $char['level'], 'Class' => $char['Class'], 'resets' => $char['resets'], 'gresets' => $char['gresets'], 'money' => $char['money'], 'gres_info' => isset($this->vars['gres_info'][$char['name']]) ? $this->vars['gres_info'][$char['name']] : false, 'bonus_reset_stats' => $bonus_reset_stats];
  272.                             }
  273.                         } else{
  274.                             $this->vars['error'] = __('Character not found.');
  275.                         }
  276.                     }
  277.                 }
  278.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.greset_character', $this->vars);
  279.             } else{
  280.                 $this->login();
  281.             }
  282.         }
  283.  
  284.         public function add_stats($char = '')
  285.         {
  286.             if($this->session->userdata(['user' => 'logged_in'])){
  287.                 if($this->website->is_multiple_accounts() == true){
  288.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  289.                 } else{
  290.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  291.                 }
  292.                 $this->load->model('account');
  293.                 if(!$char){
  294.                     $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  295.                     $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.add_stats_info', $this->vars);
  296.                 } else{
  297.                     if(!$this->Mcharacter->check_char($this->website->hex2bin($char))){
  298.                         $this->vars['not_found'] = __('Character not found.');
  299.                     }
  300.                     if(count($_POST) > 0){
  301.                         foreach($_POST as $key => $value){
  302.                             $this->Mcharacter->$key = trim($value);
  303.                         }
  304.                         if(!$this->Maccount->check_connect_stat())
  305.                             $this->vars['error'] = __('Please logout from game.'); else{
  306.                             $this->Mcharacter->check_stats();
  307.                             if(!preg_match('/^(\s*|[0-9]+)$/', $this->Mcharacter->vars['str_stat']))
  308.                                 $this->vars['error'] = __('Only positive values allowed in') . ' ' . __('Strength') . '.'; else{
  309.                                 if(!preg_match('/^(\s*|[0-9]+)$/', $this->Mcharacter->vars['agi_stat']))
  310.                                     $this->vars['error'] = __('Only positive values allowed in') . ' ' . __('Agility') . '.'; else{
  311.                                     if(!preg_match('/^(\s*|[0-9]+)$/', $this->Mcharacter->vars['ene_stat']))
  312.                                         $this->vars['error'] = __('Only positive values allowed in') . ' ' . __('Energy') . '.'; else{
  313.                                         if(!preg_match('/^(\s*|[0-9]+)$/', $this->Mcharacter->vars['vit_stat']))
  314.                                             $this->vars['error'] = __('Only positive values allowed in') . ' ' . __('Vitality') . '.'; else{
  315.                                             if(!preg_match('/^(\s*|[0-9]+)$/', $this->Mcharacter->vars['com_stat']))
  316.                                                 $this->vars['error'] = __('Only positive values allowed in') . ' ' . __('Command') . '.'; else{
  317.                                                 $this->Mcharacter->set_new_stats();
  318.                                                 if(!$this->Mcharacter->check_max_stat_limit())
  319.                                                     $this->vars['error'] = $this->Mcharacter->vars['error']; else{
  320.                                                     if($this->Mcharacter->vars['new_lvlup'] < 0)
  321.                                                         $this->vars['error'] = __('Only positive values allowed in') . ' ' . __('Level Up Points') . '.'; else{
  322.                                                         $this->Mcharacter->add_stats($this->website->hex2bin($char));
  323.                                                         $this->Mcharacter->check_char($this->website->hex2bin($char));
  324.                                                         $this->vars['success'] = __('Stats Have Been Successfully Added.');
  325.                                                     }
  326.                                                 }
  327.                                             }
  328.                                         }
  329.                                     }
  330.                                 }
  331.                             }
  332.                         }
  333.                     }
  334.                     $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.add_stats', $this->vars);
  335.                 }
  336.             } else{
  337.                 $this->login();
  338.             }
  339.         }
  340.  
  341.         public function reset_stats()
  342.         {
  343.             if($this->session->userdata(['user' => 'logged_in'])){
  344.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  345.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.reset_stats', $this->vars);
  346.             } else{
  347.                 $this->login();
  348.             }
  349.         }
  350.  
  351.         public function hide_info()
  352.         {
  353.             if($this->session->userdata(['user' => 'logged_in'])){
  354.                 if($this->website->is_multiple_accounts() == true){
  355.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  356.                 } else{
  357.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  358.                 }
  359.                 $this->load->model('account');
  360.                 $this->vars['hide_time'] = $this->Maccount->check_hide_time();
  361.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.hide_info', $this->vars);
  362.             } else{
  363.                 $this->login();
  364.             }
  365.         }
  366.  
  367.         public function clear_skilltree()
  368.         {
  369.             if($this->session->userdata(['user' => 'logged_in'])){
  370.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  371.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.clear_skill_tree', $this->vars);
  372.             } else{
  373.                 $this->login();
  374.             }
  375.         }
  376.  
  377.         public function clear_inventory()
  378.         {
  379.             if($this->session->userdata(['user' => 'logged_in'])){
  380.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  381.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.clear_inventory', $this->vars);
  382.             } else{
  383.                 $this->login();
  384.             }
  385.         }
  386.  
  387.         public function buy_zen()
  388.         {
  389.             if($this->session->userdata(['user' => 'logged_in'])){
  390.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  391.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.buy_zen', $this->vars);
  392.             } else{
  393.                 $this->login();
  394.             }
  395.         }
  396.  
  397.         public function warp_char()
  398.         {
  399.             if($this->session->userdata(['user' => 'logged_in'])){
  400.                 if($this->website->is_multiple_accounts() == true){
  401.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  402.                 } else{
  403.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  404.                 }
  405.                 $this->load->model('account');
  406.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  407.                 if(isset($_POST['character'])){
  408.                     foreach($_POST as $key => $value){
  409.                         $this->Mcharacter->$key = trim($value);
  410.                     }
  411.                     if(!$this->Maccount->check_connect_stat())
  412.                         $this->vars['error'] = __('Please logout from game.');
  413.                     else{
  414.                         if(!$this->Mcharacter->check_char())
  415.                             $this->vars['error'] = __('Character not found.');
  416.                         else{
  417.                             if(!$this->Mcharacter->teleports($this->Mcharacter->vars['world']))
  418.                                 $this->vars['error'] = __('Invalid location selected.');
  419.                             else{
  420.                                 $this->Mcharacter->teleport_char();
  421.                                 $this->vars['success'] = __('Character successfully teleported.');
  422.                             }
  423.                         }
  424.                     }
  425.                 }
  426.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.warp_char', $this->vars);
  427.             } else{
  428.                 $this->login();
  429.             }
  430.         }
  431.  
  432.         public function recover_master()
  433.         {
  434.             if(defined('RES_CUSTOM_BACKUP_MASTER') && RES_CUSTOM_BACKUP_MASTER == true){
  435.                 if($this->session->userdata(['user' => 'logged_in'])){
  436.                     if($this->website->is_multiple_accounts() == true){
  437.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  438.                     } else{
  439.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  440.                     }
  441.                     $this->load->model('account');
  442.                     $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  443.                     if(isset($_POST['character'])){
  444.                         foreach($_POST as $key => $value){
  445.                             $this->Mcharacter->$key = trim($value);
  446.                         }
  447.                         if(!$this->Maccount->check_connect_stat())
  448.                             $this->vars['error'] = __('Please logout from game.');
  449.                         else{
  450.                             if(!$this->Mcharacter->check_char('', ', Master'))
  451.                                 $this->vars['error'] = __('Character not found.');
  452.                             else{
  453.                                 if(!in_array($this->Mcharacter->char_info['Class'], [2, 3, 7, 18, 19, 23, 34, 35, 39, 49, 50, 54, 65, 66, 70, 82, 83, 87, 97, 98, 102, 114, 118])){
  454.                                     if($this->Mcharacter->char_info['cLevel'] < 400 && $this->Mcharacter->char_info[$this->config->values('table_config', [$this->session->userdata(['user' => 'server']), 'resets', 'column'])] == 0){
  455.                                         $this->vars['error'] = __('Your lvl, or grand resets are too low.');
  456.                                     } else{
  457.                                         if($this->Mcharacter->char_info['Master'] >= 1){
  458.                                             $this->Mcharacter->restore_master_level();
  459.                                             $this->vars['success'] = __('Your master level and master class have been restored.');
  460.                                         } else{
  461.                                             $this->vars['error'] = __('You don\'t have master level points');
  462.                                         }
  463.                                     }
  464.                                 } else{
  465.                                     $this->vars['error'] = __('You are not allowed to recover master level.');
  466.                                 }
  467.                             }
  468.                         }
  469.                     }
  470.                     $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.recover_char', $this->vars);
  471.                 } else{
  472.                     $this->login();
  473.                 }
  474.             } else{
  475.                 $this->disabled();
  476.             }
  477.         }
  478.  
  479.         public function pk_clear()
  480.         {
  481.             if($this->session->userdata(['user' => 'logged_in'])){
  482.                 $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  483.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.pk_clear', $this->vars);
  484.             } else{
  485.                 $this->login();
  486.             }
  487.         }
  488.  
  489.         public function vote_reward()
  490.         {
  491.             if($this->session->userdata(['user' => 'logged_in']))
  492.             {
  493.                 $this->vars['votereward_config'] = $this->config->values('votereward_config', $this->session->userdata(['user' => 'server']));
  494.                
  495.                 if($this->vars['votereward_config']['active'] == 1)
  496.                 {
  497.                     if($this->website->is_multiple_accounts() == true){
  498.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  499.                     }
  500.                     else
  501.                     {
  502.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  503.                     }
  504.                    
  505.                     $this->load->model('account');
  506.                    
  507.                     if($this->vars['votereward_config']['req_char'] == 1)
  508.                     {
  509.                         $this->vars['has_char'] = ($info = $this->Mcharacter->load_char_list()) ? $info : false;
  510.                     }
  511.                    
  512.                     if(!isset($this->vars['has_char']) || $this->vars['has_char'] != false)
  513.                     {
  514.                         $votelinks = $this->Maccount->load_vote_links();
  515.                         $this->vars['content'] = [];
  516.                        
  517.                         foreach($votelinks as $links)
  518.                         {
  519.                             if($links['api'] == 1)
  520.                             {
  521.                                 $links['votelink'] = $links['votelink'] . '&amp;postback=' . $this->session->userdata(['user' => 'id']);
  522.                                 $countdown = $this->vars['votereward_config']['count_down'] + 20;
  523.                             }
  524.                             else if($links['api'] == 3)
  525.                             {
  526.                                 $links['votelink'] = $links['votelink'] . '&amp;pingUsername=' . $this->session->userdata(['user' => 'id']);
  527.                                 $countdown = $this->vars['votereward_config']['count_down'] + 20;
  528.                             }
  529.                             else if($links['api'] == 4)
  530.                             {
  531.                                 $links['votelink'] = $links['votelink'] . '-' . $this->session->userdata(['user' => 'id']);
  532.                                 $countdown = $this->vars['votereward_config']['count_down'] + 20;
  533.                             }
  534.                             else if($links['api'] == 5)
  535.                             {
  536.                                 $links['votelink'] = $links['votelink'] . '&amp;incentive=' . $this->session->userdata(['user' => 'id']);
  537.                                 $countdown = $this->vars['votereward_config']['count_down'] + 20;
  538.                             }
  539.                             else if($links['api'] == 6)
  540.                             {
  541.                                 $links['votelink'] = str_replace('[USER]', $this->session->userdata(['user' => 'id']), $links['votelink']);
  542.                                 $countdown = $this->vars['votereward_config']['count_down'];
  543.                             }
  544.                             else if($links['api'] == 8)
  545.                             {
  546.                                 $links['votelink'] = $links['votelink'] . '?postback=' . $this->session->userdata(['user' => 'id']);
  547.                                 $countdown = $this->vars['votereward_config']['count_down'] + 20;
  548.                             }
  549.                             else if($links['api'] == 9)
  550.                             {
  551.                                 $links['votelink'] = $links['votelink'] . '&amp;custom=' . $this->session->userdata(['user' => 'id']);
  552.                                 $countdown = $this->vars['votereward_config']['count_down'] + 20;
  553.                             }
  554.                             /** SUPREMETOP100 **/
  555.                             else if($links['api'] == 10)
  556.                             {
  557.                                 $links['votelink'] = $links['votelink'] . '&amp;username=' . $this->session->userdata(['user' => 'id']);
  558.                                 $countdown = $this->vars['votereward_config']['count_down'];
  559.                             }
  560.                             /** SUPREMETOP100 **/
  561.                             else
  562.                             {
  563.                                 $countdown = $this->vars['votereward_config']['count_down'];
  564.                             }
  565.                            
  566.                             $check_last_vote = $this->Maccount->get_last_vote($links['id'], $links['hours'], $links['api'], $this->vars['votereward_config']['xtremetop_same_acc_vote'], $this->vars['votereward_config']['xtremetop_link_numbers']);
  567.                            
  568.                             if($check_last_vote != false)
  569.                             {
  570.                                 $this->vars['content'][] = [
  571.                                     'id' => $links['id'],
  572.                                     'link' => $links['votelink'],
  573.                                     'name' => $links['name'],
  574.                                     'image' => $links['img_url'],
  575.                                     'voted' => 1,
  576.                                     'next_vote' => $this->Maccount->calculate_next_vote($check_last_vote, $links['hours']),
  577.                                     'api' => $links['api'],
  578.                                     'reward' => $links['reward'],
  579.                                     'reward_type' => $links['reward_type'],
  580.                                     'reward_sms' => ($links['api'] == 2) ? $links['mmotop_reward_sms'] : 0,
  581.                                     'countdown' => $countdown
  582.                                 ];
  583.                             }
  584.                             else
  585.                             {
  586.                                 $this->vars['content'][] = [
  587.                                     'id' => $links['id'],
  588.                                     'link' => $links['votelink'],
  589.                                     'name' => $links['name'],
  590.                                     'image' => $links['img_url'],
  591.                                     'voted' => 0,
  592.                                     'next_vote' => '',
  593.                                     'api' => $links['api'],
  594.                                     'reward' => $links['reward'],
  595.                                     'reward_type' => $links['reward_type'],
  596.                                     'reward_sms' => ($links['api'] == 2) ? $links['mmotop_reward_sms'] : 0,
  597.                                     'countdown' => $countdown];
  598.                             }
  599.                         }
  600.                     }
  601.                    
  602.                     if(defined('IS_GOOGLE_ADD_VOTE') && IS_GOOGLE_ADD_VOTE == true)
  603.                     {
  604.                         $this->vars['last_ads_vote'] = $this->Maccount->get_last_ads_vote(GOOGLE_ADD_TIME);
  605.                     }
  606.                    
  607.                     $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.votereward', $this->vars);
  608.                 }
  609.                 else
  610.                 {
  611.                     $this->disabled();
  612.                 }
  613.             }
  614.             else
  615.             {
  616.                 $this->login();
  617.             }
  618.         }
  619.  
  620.         public function settings()
  621.         {
  622.             if($this->session->userdata(['user' => 'logged_in'])){
  623.                 $this->vars['config'] = $this->config->values('registration_config');
  624.                 if(isset($_POST['recover_master_key'])){
  625.                     if($this->website->is_multiple_accounts() == true){
  626.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  627.                     } else{
  628.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  629.                     }
  630.                     $this->load->model('account');
  631.                     if(!$this->Maccount->check_connect_stat()){
  632.                         $this->vars['error'] = __('Please logout from game.');
  633.                     } else{
  634.                         if(!$this->Maccount->recover_master_key_process()){
  635.                             $this->vars['success'] = __('Your master key has been send to your email.');
  636.                         } else{
  637.                             if(isset($this->Maccount->error)){
  638.                                 $this->vars['error'] = $this->Maccount->error;
  639.                             } else{
  640.                                 $this->vars['error'] = __('Unable to recover master key.');
  641.                             }
  642.                         }
  643.                     }
  644.                 }
  645.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.settings', $this->vars);
  646.             } else{
  647.                 $this->login();
  648.             }
  649.         }
  650.  
  651.         public function email_confirm($code)
  652.         {
  653.             if($this->session->userdata(['user' => 'logged_in'])){
  654.                 if($this->website->is_multiple_accounts() == true){
  655.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  656.                 } else{
  657.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  658.                 }
  659.                 $this->load->model('account');
  660.                 $code = strtolower(trim(preg_replace('/[^0-9a-f]/i', '', $code)));
  661.                 $this->vars['set_new_email'] = false;
  662.                 if(strlen($code) <> 40){
  663.                     $this->vars['error'] = __('Invalid email confirmation code');
  664.                 } else{
  665.                     $data = $this->Maccount->load_email_confirmation_by_code($code);
  666.                     if($data){
  667.                         if($data['old_email'] == 0){
  668.                             if($this->Maccount->update_email($data['account'], $data['email'])){
  669.                                 $this->Maccount->delete_old_confirmation_entries($data['account']);
  670.                                 $this->vars['success'] = __('Email address successfully updated.');
  671.                             }
  672.                         } else{
  673.                             $this->vars['set_new_email'] = true;
  674.                         }
  675.                     } else{
  676.                         $this->vars['error'] = __('Confirmation code does not exist in database.');
  677.                     }
  678.                 }
  679.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.set_new_email', $this->vars);
  680.             } else{
  681.                 $this->login();
  682.             }
  683.         }
  684.  
  685.         public function exchange_wcoins()
  686.         {
  687.             if($this->session->userdata(['user' => 'logged_in'])){
  688.                 $this->vars['wcoin_config'] = $this->config->values('wcoin_exchange_config', $this->session->userdata(['user' => 'server']));
  689.                 if($this->vars['wcoin_config'] != false && $this->vars['wcoin_config']['active'] == 1){
  690.                     $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.exchange_wcoins', $this->vars);
  691.                 } else{
  692.                     $this->disabled();
  693.                 }
  694.             } else{
  695.                 $this->login();
  696.             }
  697.         }
  698.  
  699.         public function logs($page = 1)
  700.         {
  701.             if($this->session->userdata(['user' => 'logged_in'])){
  702.                 if($this->website->is_multiple_accounts() == true){
  703.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  704.                 } else{
  705.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  706.                 }
  707.                 $this->load->model('account');
  708.                 $this->load->lib("pagination");
  709.                 $this->vars['logs'] = $this->Maccount->load_logs($page, $this->config->config_entry('account|account_logs_per_page'));
  710.                 $this->pagination->initialize($page, $this->config->config_entry('account|account_logs_per_page'), $this->Maccount->count_total_logs(), $this->config->base_url . 'account-panel/logs/%s');
  711.                 $this->vars['pagination'] = $this->pagination->create_links();
  712.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.logs', $this->vars);
  713.             } else{
  714.                 $this->login();
  715.             }
  716.         }
  717.  
  718.         public function zen_wallet()
  719.         {
  720.             if($this->session->userdata(['user' => 'logged_in'])){
  721.                 if($this->website->is_multiple_accounts() == true){
  722.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  723.                 } else{
  724.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  725.                 }
  726.                 $this->load->model('account');
  727.                 if(!$this->Maccount->check_connect_stat())
  728.                     $this->vars['error'] = __('Please logout from game.'); else{
  729.                     $this->load->model('warehouse');
  730.                     if($this->Mwarehouse->get_vault_content()){
  731.                         $this->vars['wh_zen'] = $this->Mwarehouse->vault_money;
  732.                     }
  733.                     $this->vars['char_list'] = $this->Mcharacter->load_char_list();
  734.                     $this->vars['wallet_zen'] = $this->Maccount->load_wallet_zen();
  735.                     if(!$this->vars['wallet_zen']){
  736.                         $this->vars['wallet_zen']['credits3'] = 0;
  737.                     }                              
  738.                     if(isset($_POST['transfer_zen'])){
  739.                         $from = trim(isset($_POST['from']) ? $_POST['from'] : '');
  740.                         $to = trim(isset($_POST['to']) ? $_POST['to'] : '');
  741.                         $amount = trim(isset($_POST['zen']) ? $_POST['zen'] : '');
  742.                         if($from == '')
  743.                             $this->vars['error'] = __('You didn\'t select from where you want to send zen'); else{
  744.                             if($to == '')
  745.                                 $this->vars['error'] = __('You didn\'t select to where you want to send zen'); else{
  746.                                 if(!preg_match('/^[0-9]+$/', $amount))
  747.                                     $this->vars['error'] = __('Amount of zen you insert is invalid.'); else{
  748.                                     if($from == $to){
  749.                                         $this->vars['error'] = vsprintf(__('You can\'t send zen from %s to %s'), [$from, $to]);
  750.                                     } else{
  751.                                         if($from == 'webwallet'){
  752.                                             if($this->vars['wallet_zen']['credits3'] < $amount)
  753.                                                 $this->vars['error'] = __('Amount of zen in your web wallet is too low.');
  754.                                         } else if($from == 'warehouse'){
  755.                                             if($this->vars['wh_zen'] < $amount)
  756.                                                 $this->vars['error'] = __('Amount of zen in your warehouse is too low.');
  757.                                         } else{
  758.                                             if($this->Mcharacter->check_char($from)){
  759.                                                 if($this->Mcharacter->char_info['Money'] < $amount)
  760.                                                     $this->vars['error'] = sprintf(__('Amount of zen on %s is too low.'), $from);
  761.                                             } else{
  762.                                                 $this->vars['error'] = __('Character not found.');
  763.                                             }
  764.                                         }
  765.                                         if(!isset($this->vars['error'])){
  766.                                             if($to == 'webwallet'){
  767.                                                 $this->website->add_credits($this->session->userdata(['user' => 'username']), $this->session->userdata(['user' => 'server']), $amount, 3, false, $this->session->userdata(['user' => 'id']));
  768.                                                 if($from == 'warehouse'){
  769.                                                     $this->Mwarehouse->decrease_zen($this->session->userdata(['user' => 'username']), $amount);
  770.                                                 } else{
  771.                                                     $this->Mcharacter->decrease_zen($this->session->userdata(['user' => 'username']), $amount, $from);
  772.                                                 }
  773.                                             } else if($to == 'warehouse'){
  774.                                                 if($amount > $this->config->config_entry('account|max_ware_zen'))
  775.                                                     $this->vars['error'] = sprintf(__('Max zen than can be send to warehouse is %s'), $this->website->zen_format($this->config->config_entry('account|max_ware_zen'))); else{
  776.                                                     if(((int)$amount + $this->vars['wh_zen']) > $this->config->config_entry('account|max_ware_zen'))
  777.                                                         $this->vars['error'] = __('Your warehouse zen limit exceeded. Try to transfer lower amount.'); else{
  778.                                                         $this->Mwarehouse->add_zen($this->session->userdata(['user' => 'username']), $amount);
  779.                                                         if($from == 'webwallet'){
  780.                                                             $this->website->charge_credits($this->session->userdata(['user' => 'username']), $this->session->userdata(['user' => 'server']), $amount, 3, $this->session->userdata(['user' => 'id']));
  781.                                                         } else{
  782.                                                             $this->Mcharacter->decrease_zen($this->session->userdata(['user' => 'username']), $amount, $from);
  783.                                                         }
  784.                                                     }
  785.                                                 }
  786.                                             } else{
  787.                                                 if($amount > $this->config->config_entry('account|max_char_zen'))
  788.                                                     $this->vars['error'] = sprint(__('Max zen than can be send to character is %s'), $this->website->zen_format($this->config->config_entry('account|max_char_zen'))); else{
  789.                                                     $this->Mcharacter->check_char($to);
  790.                                                     if(((int)$amount + $this->Mcharacter->char_info['Money']) > $this->config->config_entry('account|max_char_zen'))
  791.                                                         $this->vars['error'] = __('Your character zen limit exceeded. Try to transfer lower amount.'); else{
  792.                                                         $this->Mcharacter->add_zen($this->session->userdata(['user' => 'username']), $amount, $to);
  793.                                                         if($from == 'webwallet'){
  794.                                                             $this->website->charge_credits($this->session->userdata(['user' => 'username']), $this->session->userdata(['user' => 'server']), $amount, 3, $this->session->userdata(['user' => 'id']));
  795.                                                         } else if($from == 'warehouse'){
  796.                                                             $this->Mwarehouse->decrease_zen($this->session->userdata(['user' => 'username']), $amount);
  797.                                                         } else{
  798.                                                             $this->Mcharacter->decrease_zen($this->session->userdata(['user' => 'username']), $amount, $from);
  799.                                                         }
  800.                                                     }
  801.                                                 }
  802.                                             }
  803.                                             if(!isset($this->vars['error'])){
  804.                                                 $this->vars['success'] = __('Zen was successfully transferred.');
  805.                                             }
  806.                                         }
  807.                                     }
  808.                                 }
  809.                             }
  810.                         }
  811.                     }
  812.                 }
  813.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.zen_wallet', $this->vars);
  814.             } else{
  815.                 $this->login();
  816.             }
  817.         }
  818.  
  819.         public function my_referral_list()
  820.         {
  821.             if($this->session->userdata(['user' => 'logged_in'])){
  822.                 if($this->website->is_multiple_accounts() == true){
  823.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  824.                 } else{
  825.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  826.                 }
  827.                 $this->load->model('account');
  828.                 $this->vars['my_referral_list'] = $this->Maccount->load_my_referrals();
  829.                 if(!empty($this->vars['my_referral_list'])){
  830.                     foreach($this->vars['my_referral_list'] as $key => $referrals){
  831.                         $this->vars['my_referral_list'][$key]['ref_chars'] = $this->Mcharacter->load_chars_from_ref($referrals['refferal'], $this->session->userdata(['user' => 'server']));
  832.                     }
  833.                     $this->vars['ref_rewards'] = $this->Maccount->load_referral_rewards();
  834.                 }
  835.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.my_referral_list', $this->vars);
  836.             } else{
  837.                 $this->login();
  838.             }
  839.         }
  840.  
  841.         public function get_reward()
  842.         {
  843.             if($this->session->userdata(['user' => 'logged_in'])){
  844.                 if($this->website->is_multiple_accounts() == true){
  845.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  846.                 } else{
  847.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  848.                 }
  849.                 if(isset($_POST['get_reward'])){
  850.                     if(!$this->Mcharacter->check_reward()){
  851.                         $this->Mcharacter->log_reward();
  852.                         $this->Mcharacter->add_reward();
  853.                         $this->vars['success'] = 'You have received 450 Wcoins for free.';
  854.                     } else{
  855.                         $this->vars['error'] = 'You have been already rewarded on this server';
  856.                     }
  857.                 }
  858.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.get_reward', $this->vars);
  859.             } else{
  860.                 $this->login();
  861.             }
  862.         }
  863.  
  864.         public function exchange_online()
  865.         {
  866.             if($this->session->userdata(['user' => 'logged_in'])){
  867.                 if($this->website->is_multiple_accounts() == true){
  868.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($this->session->userdata(['user' => 'server']), true)]);
  869.                 } else{
  870.                     $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  871.                 }
  872.                 $this->load->model('account');
  873.                 $this->vars['online_time'] = $this->Maccount->load_online_hours();
  874.                 if($this->vars['online_time'] == false){
  875.                     $this->vars['online_time'] = 0;
  876.                     $this->vars['minutes_left'] = 0;
  877.                 } else{
  878.                     $this->vars['OnlineMinutes'] = $this->vars['online_time']['OnlineMinutes'];
  879.                     $this->vars['online_time'] = floor($this->vars['OnlineMinutes'] / 60);
  880.                     $this->vars['minutes_left'] = $this->vars['OnlineMinutes'] - (floor($this->vars['OnlineMinutes'] / 60) * 60);
  881.                 }
  882.                 if(isset($_POST['trade_hours'])){
  883.                     if(!$this->Maccount->check_connect_stat())
  884.                         $this->vars['error'] = __('Please logout from game.'); else{
  885.                         if($this->vars['online_time'] <= 0)
  886.                             $this->vars['error'] = __('You don\'t have online time on this server'); else{
  887.                             if($this->Maccount->exchange_online_hours($this->vars['online_time'], $this->vars['minutes_left'])){
  888.                                 $this->vars['success'] = 'Online time successfully exchanged';
  889.                                 $this->vars['online_time'] = 0;
  890.                             } else{
  891.                                 $this->vars['error'] = __('Unable to exchange online time');
  892.                             }
  893.                         }
  894.                     }
  895.                 }
  896.                 $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.exchange_online', $this->vars);
  897.             } else{
  898.                 $this->login();
  899.             }
  900.         }
  901.  
  902.         public function login()
  903.         {
  904.             $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.login');
  905.         }
  906.  
  907.         public function login_with_facebook()
  908.         {
  909.             $this->load->lib('fb');
  910.             $this->fb->check_fb_user();
  911.             if(isset($_SESSION['fb_access_token'])){
  912.                 $email = $this->fb->getEmail();
  913.                 try{
  914.                     if($this->website->is_multiple_accounts() == true){
  915.                         if(isset($_POST['server'])){
  916.                             $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_db_from_server($_POST['server'], true)]);
  917.                             $this->load->model('account');
  918.                             if($info = $this->Maccount->check_fb_user($email, $_POST['server'])){
  919.                                 $this->Maccount->clear_login_attemts();
  920.                                 header('Location: ' . $this->config->base_url . 'account-panel');
  921.                             } else{
  922.                                 $this->fb_register($_POST['server'], $this->vars['user_profile']['email']);
  923.                             }
  924.                         }
  925.                         $this->load->view($this->config->config_entry('main|template') . DS . 'account_panel' . DS . 'view.fb_login');
  926.                     } else{
  927.                         $this->load->lib(['account_db', 'db'], [HOST, USER, PASS, $this->website->get_default_account_database()]);
  928.                         $this->load->model('account');
  929.                         $server_list = array_keys($this->website->server_list());
  930.                         if($info = $this->Maccount->check_fb_user($this->fb->getEmail(), $server_list[0])){
  931.                             $this->Maccount->clear_login_attemts();
  932.                             header('Location: ' . $this->config->base_url . 'account-panel');
  933.                         } else{
  934.                             header('Location: ' . $this->config->base_url . 'registration/create-account-with-fb/' . $server_list[0] . '/' . urlencode($email));
  935.                         }
  936.                     }
  937.                 } catch(FacebookApiException $e){
  938.                     unset($_SESSION['fb_access_token']);
  939.                     throw new exception($e->getMessage());
  940.                 }
  941.             }
  942.         }
  943.  
  944.         public function logout()
  945.         {
  946.             $email = $this->session->userdata(['user' => 'email']);
  947.             $id = $this->session->userdata(['user' => 'ipb_id']);
  948.             $this->session->unset_session_key('user');
  949.             $this->session->unset_session_key('vip');
  950.             if(defined('IPS_CONNECT') && IPS_CONNECT == true){
  951.                 $this->load->lib('ipb');
  952.                 if($this->ipb->checkEmail($email) == true){
  953.                     $this->ipb->crossLogout($id, $this->config->base_url);
  954.                 } else{
  955.                     header('Location: ' . $this->config->base_url);
  956.                 }
  957.             } else{
  958.                 header('Location: ' . $this->config->base_url);
  959.             }
  960.         }
  961.  
  962.         public function disabled()
  963.         {
  964.             $this->load->view($this->config->config_entry('main|template') . DS . 'view.module_disabled');
  965.         }
  966.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement