· 7 years ago · Oct 31, 2018, 03:50 PM
1<?php if (! defined('BASEPATH')) {
2 exit('No direct script access allowed');
3}
4
5/**
6* @category controller
7* class home
8*/
9class Home extends CI_Controller
10{
11
12 /**
13 * load constructor
14 * @access public
15 * @return void
16 */
17 public $module_access;
18 public $language;
19 public $is_rtl;
20 public $user_id;
21
22 public $is_ad_enabled;
23 public $is_ad_enabled1;
24 public $is_ad_enabled2;
25 public $is_ad_enabled3;
26 public $is_ad_enabled4;
27
28 public $ad_content1;
29 public $ad_content1_mobile;
30 public $ad_content2;
31 public $ad_content3;
32 public $ad_content4;
33 public $app_product_id;
34 public $APP_VERSION;
35
36 public function __construct()
37 {
38 parent::__construct();
39 set_time_limit(0);
40 $this->load->helpers(array('my_helper','addon_helper'));
41
42 $this->is_rtl=FALSE;
43 $this->language="";
44 $this->_language_loader();
45
46 $this->is_ad_enabled=false;
47 $this->is_ad_enabled1=false;
48 $this->is_ad_enabled2=false;
49 $this->is_ad_enabled3=false;
50 $this->is_ad_enabled4=false;
51
52 $this->ad_content1="";
53 $this->ad_content1_mobile="";
54 $this->ad_content2="";
55 $this->ad_content3="";
56 $this->ad_content4="";
57 $this->app_product_id=1; // this is the first product of our update system
58 $this->APP_VERSION="";
59
60 ignore_user_abort(TRUE);
61
62 $seg = $this->uri->segment(2);
63 if ($seg!="installation" && $seg!= "installation_action") {
64 if (file_exists(APPPATH.'install.txt')) {
65 redirect('home/installation', 'location');
66 }
67 }
68
69 if (!file_exists(APPPATH.'install.txt')) {
70 $this->load->database();
71 $this->load->model('basic');
72 $this->_time_zone_set();
73 $this->user_id=$this->session->userdata("user_id");
74 $this->load->library('upload');
75 $this->load->helper('security');
76 $this->upload_path = realpath(APPPATH . '../upload');
77 $this->session->unset_userdata('set_custom_link');
78 $query = 'SET SESSION group_concat_max_len=9990000000000000000';
79 $this->db->query($query);
80 $q= "SET SESSION wait_timeout=50000";
81 $this->db->query($q);
82 /**Disable STRICT_TRANS_TABLES mode if exist on mysql ***/
83 $query="SET SESSION sql_mode = ''";
84 $this->db->query($query);
85 //loading addon language
86 $this->language_loader_addon();
87
88 if(function_exists('ini_set')){
89 ini_set('memory_limit', '-1');
90 }
91
92 $ad_config = $this->basic->get_data("ad_config");
93 if(isset($ad_config[0]["status"]))
94 {
95 if($ad_config[0]["status"]=="1")
96 {
97 $this->is_ad_enabled = ($ad_config[0]["status"]=="1") ? true : false;
98 if($this->is_ad_enabled)
99 {
100 $this->is_ad_enabled1 = ($ad_config[0]["section1_html"]=="" && $ad_config[0]["section1_html_mobile"]=="") ? false : true;
101 $this->is_ad_enabled2 = ($ad_config[0]["section2_html"]=="") ? false : true;
102 $this->is_ad_enabled3 = ($ad_config[0]["section3_html"]=="") ? false : true;
103 $this->is_ad_enabled4 = ($ad_config[0]["section4_html"]=="") ? false : true;
104
105 $this->ad_content1 = htmlspecialchars_decode($ad_config[0]["section1_html"],ENT_QUOTES);
106 $this->ad_content1_mobile = htmlspecialchars_decode($ad_config[0]["section1_html_mobile"],ENT_QUOTES);
107 $this->ad_content2 = htmlspecialchars_decode($ad_config[0]["section2_html"],ENT_QUOTES);
108 $this->ad_content3 = htmlspecialchars_decode($ad_config[0]["section3_html"],ENT_QUOTES);
109 $this->ad_content4 = htmlspecialchars_decode($ad_config[0]["section4_html"],ENT_QUOTES);
110 }
111 }
112
113 }
114 else
115 {
116 $this->is_ad_enabled = true;
117 $this->is_ad_enabled1 = true;
118 $this->is_ad_enabled2 = true;
119 $this->is_ad_enabled3 = true;
120 $this->is_ad_enabled4 = true;
121
122 $this->ad_content1="<img src='".base_url('assets/images/placeholder/reserved-section-1.png')."'>";
123 $this->ad_content1_mobile="<img src='".base_url('assets/images/placeholder/reserved-section-1-mobile.png')."'>";
124 $this->ad_content2="<img src='".base_url('assets/images/placeholder/reserved-section-2.png')."'>";
125 $this->ad_content3="<img src='".base_url('assets/images/placeholder/reserved-section-3.png')."'>";
126 $this->ad_content4="<img src='".base_url('assets/images/placeholder/reserved-section-4.png')."'>";
127
128 }
129
130 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') != 'Admin')
131 {
132 $package_info=$this->session->userdata("package_info");
133 $module_ids='';
134 if(isset($package_info["module_ids"])) $module_ids=$package_info["module_ids"];
135 $this->module_access=explode(',', $module_ids);
136 }
137
138 $version_data=$this->basic->get_data("version",array("where"=>array("current"=>"1")));
139 $appversion=isset($version_data[0]['version']) ? $version_data[0]['version'] : "";
140 $this->APP_VERSION=$appversion;
141
142 }
143
144 }
145
146
147
148 public function _insert_usage_log($module_id=0,$usage_count=0,$user_id=0)
149 {
150
151 if($module_id==0 || $usage_count==0) return false;
152 if($user_id==0) $user_id=$this->session->userdata("user_id");
153 if($user_id==0 || $user_id=="") return false;
154
155 $usage_month=date("n");
156 $usage_year=date("Y");
157 $where=array("module_id"=>$module_id,"user_id"=>$user_id,"usage_month"=>$usage_month,"usage_year"=>$usage_year);
158
159 $insert_data=array("module_id"=>$module_id,"user_id"=>$user_id,"usage_month"=>$usage_month,"usage_year"=>$usage_year,"usage_count"=>$usage_count);
160
161 if($this->basic->is_exist("view_usage_log",$where))
162 {
163 $this->db->set('usage_count', 'usage_count+'.$usage_count, FALSE);
164 $this->db->where($where);
165 $this->db->update('usage_log');
166 }
167 else $this->basic->insert_data("usage_log",$insert_data);
168
169 return true;
170 }
171
172
173 public function _delete_usage_log($module_id=0,$usage_count=0,$user_id=0)
174 {
175
176 if($module_id==0 || $usage_count==0) return false;
177 if($user_id==0) $user_id=$this->session->userdata("user_id");
178 if($user_id==0 || $user_id=="") return false;
179
180 $usage_month=date("n");
181 $usage_year=date("Y");
182 $where=array("module_id"=>$module_id,"user_id"=>$user_id,"usage_month"=>$usage_month,"usage_year"=>$usage_year);
183
184 $insert_data=array("module_id"=>$module_id,"user_id"=>$user_id,"usage_month"=>$usage_month,"usage_year"=>$usage_year,"usage_count"=>$usage_count);
185
186 if($this->basic->is_exist("view_usage_log",$where))
187 {
188 $this->db->set('usage_count', 'usage_count-'.$usage_count, FALSE);
189 $this->db->where($where);
190 $this->db->update('usage_log');
191 }
192 else $this->basic->insert_data("usage_log",$insert_data);
193
194 return true;
195 }
196
197
198 public function _check_usage($module_id=0,$request=0,$user_id=0)
199 {
200
201 if($module_id==0 || $request==0) return "0";
202 if($user_id==0) $user_id=$this->session->userdata("user_id");
203 if($user_id==0 || $user_id=="") return false;
204
205 if($this->basic->is_exist("modules",array("id"=>$module_id,"extra_text"=>""),"id")) // not monthly limit modules
206 {
207 $this->db->select_sum('usage_count');
208 $this->db->where('user_id', $user_id);
209 $this->db->where('module_id', $module_id);
210 $info = $this->db->get('usage_log')->result_array();
211
212 $usage_count=0;
213 if(isset($info[0]["usage_count"]))
214 $usage_count=$info[0]["usage_count"];
215 }
216 else
217 {
218 $usage_month=date("n");
219 $usage_year=date("Y");
220 $info=$this->basic->get_data("view_usage_log",$where=array("where"=>array("usage_month"=>$usage_month,"usage_year"=>$usage_year,"module_id"=>$module_id,"user_id"=>$user_id)));
221 $usage_count=0;
222 if(isset($info[0]["usage_count"]))
223 $usage_count=$info[0]["usage_count"];
224 }
225
226
227
228 $monthly_limit=array();
229 $bulk_limit=array();
230 $module_ids=array();
231
232 if($this->session->userdata("package_info")!="")
233 {
234 $package_info=$this->session->userdata("package_info");
235 if($this->session->userdata('user_type') == 'Admin') return "1";
236 }
237 else
238 {
239 $package_data = $this->basic->get_data("users", $where=array("where"=>array("users.id"=>$user_id)),"package.*,users.user_type",array('package'=>"users.package_id=package.id,left"));
240 $package_info=array();
241 if(array_key_exists(0, $package_data))
242 $package_info=$package_data[0];
243 if($package_info['user_type'] == 'Admin') return "1";
244 }
245
246 if(isset($package_info["bulk_limit"])) $bulk_limit=json_decode($package_info["bulk_limit"],true);
247 if(isset($package_info["monthly_limit"])) $monthly_limit=json_decode($package_info["monthly_limit"],true);
248 if(isset($package_info["module_ids"])) $module_ids=explode(',', $package_info["module_ids"]);
249
250 $return = "0";
251 if(in_array($module_id, $module_ids) && $bulk_limit[$module_id] > 0 && $bulk_limit[$module_id]<$request)
252 $return = "2"; // bulk limit crossed | 0 means unlimited
253 else if(in_array($module_id, $module_ids) && $monthly_limit[$module_id] > 0 && $monthly_limit[$module_id]<($request+$usage_count))
254 $return = "3"; // montly limit crossed | 0 means unlimited
255 else $return = "1"; //success
256
257 return $return;
258 }
259
260
261
262 public function print_limit_message($module_id=0,$request=0)
263 {
264 $status=$this->_check_usage($module_id,$request);
265 if($status=="2")
266 {
267 echo $this->lang->line("sorry, your bulk limit is exceeded for this module.")."<a href='".site_url('usage_history')."'>".$this->lang->line("click here to see usage log")."</a>";
268 exit();
269 }
270 else if($status=="3")
271 {
272 echo $this->lang->line("sorry, your monthly limit is exceeded for this module.")."<a href='".site_url('usage_history')."'>".$this->lang->line("click here to see usage log")."</a>";
273 exit();
274 }
275
276 }
277
278
279
280 public function _language_loader()
281 {
282
283 if(!$this->config->item("language") || $this->config->item("language")=="")
284 $this->language="english";
285 else $this->language=$this->config->item('language');
286
287 if($this->session->userdata("selected_language")!="")
288 $this->language = $this->session->userdata("selected_language");
289 else if(!$this->config->item("language") || $this->config->item("language")=="")
290 $this->language="english";
291 else $this->language=$this->config->item('language');
292
293 // if($this->language=="arabic")
294 // $this->is_rtl=TRUE;
295
296 $path=str_replace('\\', '/', APPPATH.'/language/'.$this->language);
297 $files=$this->_scanAll($path);
298 foreach ($files as $key2 => $value2)
299 {
300 $current_file=isset($value2['file']) ? str_replace('\\', '/', $value2['file']) : ""; //application/modules/addon_folder/language/language_folder/someting_lang.php
301 if($current_file=="" || !is_file($current_file)) continue;
302 $current_file_explode=explode('/',$current_file);
303 $filename=array_pop($current_file_explode);
304 $pos=strpos($filename,'_lang.php');
305 if($pos!==false) // check if it is a lang file or not
306 {
307 $filename=str_replace('_lang.php', '', $filename);
308 $this->lang->load($filename, $this->language);
309 }
310 }
311
312 // if (file_exists(APPPATH.'language/'.$this->language.'/front_lang.php'))
313 // $this->lang->load('front', $this->language);
314
315 // if (file_exists(APPPATH.'language/'.$this->language.'/front_one_lang.php'))
316 // $this->lang->load('front_one', $this->language);
317
318 // if (file_exists(APPPATH.'language/'.$this->language.'/sidebar_lang.php'))
319 // $this->lang->load('sidebar', $this->language);
320
321 // if (file_exists(APPPATH.'language/'.$this->language.'/common_lang.php'))
322 // $this->lang->load('common', $this->language);
323
324 // if (file_exists(APPPATH.'language/'.$this->language.'/message_lang.php'))
325 // $this->lang->load('message', $this->language);
326
327 // if (file_exists(APPPATH.'language/'.$this->language.'/admin_lang.php'))
328 // $this->lang->load('admin', $this->language);
329
330 // if (file_exists(APPPATH.'language/'.$this->language.'/user_setting_lang.php'))
331 // $this->lang->load('user_setting', $this->language);
332
333 // if (file_exists(APPPATH.'language/'.$this->language.'/calendar_lang.php'))
334 // $this->lang->load('calendar', $this->language);
335
336 // if (file_exists(APPPATH.'language/'.$this->language.'/date_lang.php'))
337 // $this->lang->load('date', $this->language);
338
339 // if (file_exists(APPPATH.'language/'.$this->language.'/db_lang.php'))
340 // $this->lang->load('db', $this->language);
341
342 // if (file_exists(APPPATH.'language/'.$this->language.'/email_lang.php'))
343 // $this->lang->load('email', $this->language);
344
345 // if (file_exists(APPPATH.'language/'.$this->language.'/form_validation_lang.php'))
346 // $this->lang->load('form_validation', $this->language);
347
348 // if (file_exists(APPPATH.'language/'.$this->language.'/ftp_lang.php'))
349 // $this->lang->load('ftp', $this->language);
350
351 // if (file_exists(APPPATH.'language/'.$this->language.'/imglib_lang.php'))
352 // $this->lang->load('imglib', $this->language);
353
354 // if (file_exists(APPPATH.'language/'.$this->language.'/migration_lang.php'))
355 // $this->lang->load('migration', $this->language);
356
357 // if (file_exists(APPPATH.'language/'.$this->language.'/number_lang.php'))
358 // $this->lang->load('number', $this->language);
359
360 // if (file_exists(APPPATH.'language/'.$this->language.'/pagination_lang.php'))
361 // $this->lang->load('pagination', $this->language);
362
363 // if (file_exists(APPPATH.'language/'.$this->language.'/profiler_lang.php'))
364 // $this->lang->load('profiler', $this->language);
365
366 // if (file_exists(APPPATH.'language/'.$this->language.'/unit_test_lang.php'))
367 // $this->lang->load('unit_test', $this->language);
368
369 // if (file_exists(APPPATH.'language/'.$this->language.'/upload_lang.php'))
370 // $this->lang->load('upload', $this->language);
371
372 // if (file_exists(APPPATH.'language/'.$this->language.'/misc_lang.php'))
373 // $this->lang->load('misc', $this->language);
374
375 // if (file_exists(APPPATH.'language/'.$this->language.'/misc2_lang.php'))
376 // $this->lang->load('misc2', $this->language);
377
378 // if (file_exists(APPPATH.'language/'.$this->language.'/misc3_lang.php'))
379 // $this->lang->load('misc3', $this->language);
380
381 // if (file_exists(APPPATH.'language/'.$this->language.'/merge_app_lang.php'))
382 // $this->lang->load('merge_app', $this->language);
383
384 // if (file_exists(APPPATH.'language/'.$this->language.'/admin_user_a_lang.php'))
385 // $this->lang->load('admin_user_a', $this->language);
386
387 // if (file_exists(APPPATH.'language/'.$this->language.'/admin_user_b_lang.php'))
388 // $this->lang->load('admin_user_b', $this->language);
389
390 // if (file_exists(APPPATH.'language/'.$this->language.'/admin_user_d_lang.php'))
391 // $this->lang->load('admin_user_c', $this->language);
392
393 // if (file_exists(APPPATH.'language/'.$this->language.'/admin_user_d_lang.php'))
394 // $this->lang->load('admin_user_d', $this->language);
395
396 // if (file_exists(APPPATH.'language/'.$this->language.'/admin_user_lang.php'))
397 // $this->lang->load('admin_user', $this->language);
398 }
399
400 /**
401 * method to install software
402 * @access public
403 * @return void
404 */
405 public function installation()
406 {
407 if (!file_exists(APPPATH.'install.txt')) {
408 redirect('home/login', 'location');
409 }
410 $data = array("body" => "page/install", "page_title" => "Install Package","language_info" => $this->_language_list());
411 $this->_front_viewcontroller($data);
412 }
413
414 /**
415 * method to installation action
416 * @access public
417 * @return void
418 */
419 public function installation_action()
420 {
421 if (!file_exists(APPPATH.'install.txt')) {
422 redirect('home/login', 'location');
423 }
424
425 if ($_POST) {
426 // validation
427 $this->form_validation->set_rules('host_name', '<b>Host Name</b>', 'trim|required');
428 $this->form_validation->set_rules('database_name', '<b>Database Name</b>', 'trim|required');
429 $this->form_validation->set_rules('database_username', '<b>Database Username</b>', 'trim|required');
430 $this->form_validation->set_rules('database_password', '<b>Database Password</b>', 'trim');
431 $this->form_validation->set_rules('app_username', '<b>Admin Panel Login Email</b>', 'trim|required|valid_email');
432 $this->form_validation->set_rules('app_password', '<b>Admin Panel Login Password</b>', 'trim|required');
433 $this->form_validation->set_rules('institute_name', '<b>Company Name</b>', 'trim');
434 $this->form_validation->set_rules('institute_address', '<b>Company Address</b>', 'trim');
435 $this->form_validation->set_rules('institute_mobile', '<b>Company Phone / Mobile</b>', 'trim');
436 $this->form_validation->set_rules('language', '<b>Language</b>', 'trim');
437
438 // go to config form page if validation wrong
439 if ($this->form_validation->run() == false) {
440 return $this->installation();
441 } else {
442 $host_name = addslashes(strip_tags($this->input->post('host_name', true)));
443 $database_name = addslashes(strip_tags($this->input->post('database_name', true)));
444 $database_username = addslashes(strip_tags($this->input->post('database_username', true)));
445 $database_password = addslashes(strip_tags($this->input->post('database_password', true)));
446 $app_username = addslashes(strip_tags($this->input->post('app_username', true)));
447 $app_password = addslashes(strip_tags($this->input->post('app_password', true)));
448 $institute_name = addslashes(strip_tags($this->input->post('institute_name', true)));
449 $institute_address = addslashes(strip_tags($this->input->post('institute_address', true)));
450 $institute_mobile = addslashes(strip_tags($this->input->post('institute_mobile', true)));
451 $language = addslashes(strip_tags($this->input->post('language', true)));
452
453 $con=@mysqli_connect($host_name, $database_username, $database_password);
454 if (!$con) {
455 $this->session->set_userdata('mysql_error', "Could not conenect to MySQL.");
456 return $this->installation();
457 }
458 if (!@mysqli_select_db($con,$database_name)) {
459 $this->session->set_userdata('mysql_error', "Database not found.");
460 return $this->installation();
461 }
462 mysqli_close($con);
463
464 // writing application/config/my_config
465 $app_my_config_data = "<?php ";
466 $app_my_config_data.= "\n\$config['default_page_url'] = '".$this->config->item('default_page_url')."';\n";
467 $app_my_config_data.= "\$config['product_name'] = '".$this->config->item('product_name')."';\n";
468 $app_my_config_data.= "\$config['product_short_name'] = '".$this->config->item('product_short_name')."' ;\n";
469 $app_my_config_data.= "\$config['product_version'] = '".$this->config->item('product_version')." ';\n\n";
470 $app_my_config_data.= "\$config['institute_address1'] = '$institute_name';\n";
471 $app_my_config_data.= "\$config['institute_address2'] = '$institute_address';\n";
472 $app_my_config_data.= "\$config['institute_email'] = '$app_username';\n";
473 $app_my_config_data.= "\$config['institute_mobile'] = '$institute_mobile';\n";
474 $app_my_config_data.= "\$config['developed_by'] = '".$this->config->item('developed_by')."';\n";
475 $app_my_config_data.= "\$config['developed_by_href'] = '".$this->config->item('developed_by_href')."';\n";
476 $app_my_config_data.= "\$config['developed_by_title'] = '".$this->config->item('developed_by_title')."';\n";
477 $app_my_config_data.= "\$config['developed_by_prefix'] = '".$this->config->item('developed_by_prefix')."' ;\n";
478 $app_my_config_data.= "\$config['support_email'] = '".$this->config->item('support_email')."' ;\n";
479 $app_my_config_data.= "\$config['support_mobile'] = '".$this->config->item('support_mobile')."' ;\n";
480 $app_my_config_data.= "\$config['time_zone'] = '' ;\n";
481 $app_my_config_data.= "\$config['language'] = '$language';\n";
482 $app_my_config_data.= "\$config['sess_use_database'] = FALSE;\n";
483 $app_my_config_data.= "\$config['sess_table_name'] = 'ci_sessions';\n";
484 file_put_contents(APPPATH.'config/my_config.php', $app_my_config_data, LOCK_EX);
485 //writting application/config/my_config
486
487 //writting application/config/database
488 $database_data = "";
489 $database_data.= "<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');\n
490 \$active_group = 'default';
491 \$active_record = true;
492 \$db['default']['hostname'] = '$host_name';
493 \$db['default']['username'] = '$database_username';
494 \$db['default']['password'] = '$database_password';
495 \$db['default']['database'] = '$database_name';
496 \$db['default']['dbdriver'] = 'mysqli';
497 \$db['default']['dbprefix'] = '';
498 \$db['default']['pconnect'] = TRUE;
499 \$db['default']['db_debug'] = TRUE;
500 \$db['default']['cache_on'] = FALSE;
501 \$db['default']['cachedir'] = '';
502 \$db['default']['char_set'] = 'utf8';
503 \$db['default']['dbcollat'] = 'utf8_general_ci';
504 \$db['default']['swap_pre'] = '';
505 \$db['default']['autoinit'] = TRUE;
506 \$db['default']['stricton'] = FALSE;";
507 file_put_contents(APPPATH.'config/database.php', $database_data, LOCK_EX);
508 //writting application/config/database
509
510 // writting client js
511 $client_js_content=file_get_contents('js/my_chat_custom.js');
512 $client_js_content_new=str_replace("base_url_replace/", site_url(), $client_js_content);
513 file_put_contents('js/my_chat_custom.js', $client_js_content_new, LOCK_EX);
514 // writting client js
515
516 // loding database library, because we need to run queries below and configs are already written
517 $this->load->database();
518 $this->load->model('basic');
519 // loding database library, because we need to run queries below and configs are already written
520
521 // dumping sql
522 $dump_file_name = 'initial_db.sql';
523 $dump_sql_path = 'assets/backup_db/'.$dump_file_name;
524 $this->basic->import_dump($dump_sql_path);
525 // dumping sql
526
527 // Insert Version
528 $this->db->insert('version', array('version' => trim($this->config->item('product_version')), 'current' => '1', 'date' => date('Y-m-d H:i:s')));
529
530 //generating hash password for admin and updaing database
531 $app_password = md5($app_password);
532 $this->basic->update_data($table = "users", $where = array("user_type" => "Admin"), $update_data = array("mobile" => $institute_mobile, "email" => $app_username, "password" => $app_password, "name" => $institute_name, "status" => "1", "deleted" => "0", "address" => $institute_address));
533 //generating hash password for admin and updaing database
534
535 //deleting the install.txt file,because installation is complete
536 if (file_exists(APPPATH.'install.txt')) {
537 unlink(APPPATH.'install.txt');
538 }
539 //deleting the install.txt file,because installation is complete
540 redirect('home/login');
541 }
542 }
543 }
544
545
546 /**
547 * method to index page
548 * @access public
549 * @return void
550 */
551 public function index()
552 {
553 $display_landing_page=$this->config->item('display_landing_page');
554 if($display_landing_page=='') $display_landing_page='0';
555
556 if($display_landing_page=='0')
557 $this->login_page();
558 else $this->_site_viewcontroller();
559 }
560
561
562 /**
563 * method to set time zone
564 * @access public
565 * @return void
566 */
567 public function _time_zone_set()
568 {
569 $time_zone = $this->config->item('time_zone');
570 if ($time_zone== '') {
571 $time_zone="Europe/Dublin";
572 }
573 date_default_timezone_set($time_zone);
574 }
575
576
577 /**
578 * method to show time zone list
579 * @access public
580 * @return array
581 */
582 public function _time_zone_list()
583 {
584 $all_time_zone=array(
585 'Kwajalein' => 'GMT -12.00 Kwajalein',
586 'Pacific/Midway' => 'GMT -11.00 Pacific/Midway',
587 'Pacific/Honolulu' => 'GMT -10.00 Pacific/Honolulu',
588 'America/Anchorage' => 'GMT -9.00 America/Anchorage',
589 'America/Los_Angeles' => 'GMT -8.00 America/Los_Angeles',
590 'America/Denver' => 'GMT -7.00 America/Denver',
591 'America/Chicago' => 'GMT -6.00 America/Chicago',
592 'America/New_York' => 'GMT -5.00 America/New_York',
593 'America/Caracas' => 'GMT -4.30 America/Caracas',
594 'America/Halifax' => 'GMT -4.00 America/Halifax',
595 'America/St_Johns' => 'GMT -3.30 America/St_Johns',
596 'America/Argentina/Buenos_Aires'=> 'GMT +-3.00 America/Argentina/Buenos_Aires',
597 'America/Sao_Paulo' =>' GMT -3.00 America/Sao_Paulo',
598 'Atlantic/South_Georgia' => 'GMT +-2.00 Atlantic/South_Georgia',
599 'Atlantic/Azores' => 'GMT -1.00 Atlantic/Azores',
600 'Europe/Dublin' => 'GMT Europe/Dublin',
601 'Europe/Belgrade' => 'GMT +1.00 Europe/Belgrade',
602 'Europe/Minsk' => 'GMT +2.00 Europe/Minsk',
603 'Asia/Kuwait' => 'GMT +3.00 Asia/Kuwait',
604 'Asia/Tehran' => 'GMT +3.30 Asia/Tehran',
605 'Asia/Muscat' => 'GMT +4.00 Asia/Muscat',
606 'Asia/Yekaterinburg' => 'GMT +5.00 Asia/Yekaterinburg',
607 'Asia/Kolkata' => 'GMT +5.30 Asia/Kolkata',
608 'Asia/Katmandu' => 'GMT +5.45 Asia/Katmandu',
609 'Asia/Dhaka' => 'GMT +6.00 Asia/Dhaka',
610 'Asia/Rangoon' => 'GMT +6.30 Asia/Rangoon',
611 'Asia/Krasnoyarsk' => 'GMT +7.00 Asia/Krasnoyarsk',
612 'Asia/Brunei' => 'GMT +8.00 Asia/Brunei',
613 'Asia/Seoul' => 'GMT +9.00 Asia/Seoul',
614 'Australia/Darwin' => 'GMT +9.30 Australia/Darwin',
615 'Australia/Canberra' => 'GMT +10.00 Australia/Canberra',
616 'Asia/Magadan' => 'GMT +11.00 Asia/Magadan',
617 'Pacific/Fiji' => 'GMT +12.00 Pacific/Fiji',
618 'Pacific/Tongatapu' => 'GMT +13.00 Pacific/Tongatapu'
619 );
620
621 return $all_time_zone;
622 }
623
624 /**
625 * method to disable cache
626 * @access public
627 * @return void
628 */
629 public function _disable_cache()
630 {
631 header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
632 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
633 header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
634 header("Cache-Control: post-check=0, pre-check=0", false);
635 header("Pragma: no-cache");
636 }
637
638 /**
639 * method to
640 * @access public
641 * @return void
642 */
643 public function access_forbidden()
644 {
645 $this->load->view('page/access_forbidden');
646 }
647
648 /**
649 * method to load front viewcontroller
650 * @access public
651 * @return void
652 */
653 public function _front_viewcontroller($data=array())
654 {
655 // $this->_disable_cache();
656 if (!isset($data['body'])) {
657 $data['body']=$this->config->item('default_page_url');
658 }
659
660 if (!isset($data['page_title'])) {
661 $data['page_title']="";
662 }
663
664 $this->load->view('front/theme_front', $data);
665 }
666
667
668 public function _viewcontroller($data=array())
669 {
670 if (!isset($data['body'])) {
671 $data['body']=$this->config->item('default_page_url');
672 }
673
674 if (!isset($data['page_title'])) {
675 $data['page_title']="Admin Panel";
676 }
677
678 if (!isset($data['crud'])) {
679 $data['crud']=0;
680 }
681
682 if (!isset($data['base_site']) || $data['base_site']=="")
683 {
684 $data['base_site']=0;
685 $data['compare']=0;
686 }
687 else $data['compare']=1;
688
689 if($this->session->userdata('download_id_front')=="")
690 $this->session->set_userdata('download_id_front', md5(time().$this->_random_number_generator(10)));
691
692 if($this->session->userdata('user_type') == 'Admin'|| in_array(65,$this->module_access))
693 {
694 $fb_rx_account_switching_info = $this->basic->get_data("facebook_rx_fb_user_info",array("where"=>array("user_id"=>$this->user_id)));
695 $data["fb_rx_account_switching_info"] =array();
696 foreach ($fb_rx_account_switching_info as $key => $value)
697 {
698 // if($value["id"] == $this->session->userdata("facebook_rx_fb_user_info"))
699 // $str= "Using as : ";
700 // else $str = "Switch to : ";
701
702 $str="";
703
704 $data["fb_rx_account_switching_info"][$value["id"]] = $str.$value["name"];
705 }
706 }
707 if(empty($data["fb_rx_account_switching_info"])) $data["fb_rx_account_switching_info"]["0"] = "No Account Imported";
708
709 $data["language_info"] = $this->_language_list();
710 $data["themes"] = $this->_theme_list();
711
712 $data['menus'] = $this->basic->get_data('menu','','','','','','serial asc');
713
714 $menu_child_1_map = array();
715 $menu_child_1 = $this->basic->get_data('menu_child_1','','','','','','serial asc');
716 foreach($menu_child_1 as $single_child_1)
717 {
718 $menu_child_1_map[$single_child_1['parent_id']][$single_child_1['id']] = $single_child_1;
719 }
720 $data['menu_child_1_map'] = $menu_child_1_map;
721
722 $menu_child_2_map = array();
723 $menu_child_2 = $this->basic->get_data('menu_child_2','','','','','','serial asc');
724 foreach($menu_child_2 as $single_child_2)
725 {
726 $menu_child_2_map[$single_child_2['parent_child']][$single_child_2['id']] = $single_child_2;
727 }
728 $data['menu_child_2_map'] = $menu_child_2_map;
729
730 $loadthemebody="skin-black-light";
731 if($this->config->item('theme')!="") $loadthemebody=$this->config->item('theme');
732 $data['loadthemebody']=$loadthemebody;
733
734 // announcement
735 $seen_data=$this->basic->get_data("announcement_seen",array("where"=>array("user_id"=>$this->user_id)));
736 $seen_announcements=array(); foreach ($seen_data as $key => $value)
737 {
738 $seen_announcements[]=$value["announcement_id"];
739 }
740 $where=array('where'=>array('status'=>'published'));
741 if(!empty($seen_announcements)) $where['where_not_in']=array("id"=>$seen_announcements);
742
743 $data['annoucement_data']=$this->basic->get_data("announcement",$where,'','','',NULL,'id DESC');
744
745 $this->load->view('admin/theme/theme', $data);
746 }
747
748
749
750 public function _site_viewcontroller($data=array())
751 {
752 if (!isset($data['page_title'])) {
753 $data['page_title']="";
754 }
755
756 $config_data=array();
757 $data=array();
758 $price=0;
759 $currency="USD";
760 $config_data=$this->basic->get_data("payment_config");
761 if(array_key_exists(0,$config_data))
762 {
763 $currency=$config_data[0]['currency'];
764 }
765 $data['price']=$price;
766 $data['currency']=$currency;
767
768 //catcha for contact page
769 $data['contact_num1']=$this->_random_number_generator(2);
770 $data['contact_num2']=$this->_random_number_generator(1);
771 $contact_captcha= $data['contact_num1']+ $data['contact_num2'];
772 $this->session->set_userdata("contact_captcha",$contact_captcha);
773 $data["language_info"] = $this->_language_list();
774 $data["payment_package"]=$this->basic->get_data("package",$where=array("where"=>array("is_default"=>"0","price > "=>0,"validity >"=>0)),$select='',$join='',$limit='',$start=NULL,$order_by='CAST(`price` AS SIGNED)');
775 $data["default_package"]=$this->basic->get_data("package",$where=array("where"=>array("is_default"=>"1","validity >"=>0,"price"=>"Trial")));
776
777 //catcha for contact page
778
779 $this->load->view('site/site_theme', $data);
780 }
781
782
783
784 public function login_page()
785 {
786 if (file_exists(APPPATH.'install.txt'))
787 {
788 redirect('home/installation', 'location');
789 }
790
791 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Admin')
792 {
793 redirect('facebook_ex_dashboard/index', 'location');
794 }
795 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Member')
796 {
797 redirect('facebook_ex_dashboard/index', 'location');
798 }
799
800 $this->load->library("google_login");
801 $data["google_login_button"]=$this->google_login->set_login_button();
802
803 $data['fb_login_button']="";
804 if(function_exists('version_compare'))
805 {
806 if(version_compare(PHP_VERSION, '5.4.0', '>='))
807 {
808 $this->load->library("fb_login");
809 $data['fb_login_button'] = $this->fb_login->login_for_user_access_token(site_url("home/fb_login_back"));
810 }
811 }
812
813 $this->load->view("page/login",$data);
814 }
815
816 public function login() //loads home view page after login (this )
817 {
818 if (file_exists(APPPATH.'install.txt'))
819 {
820 redirect('home/installation', 'location');
821 }
822
823 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Admin')
824 {
825 redirect('facebook_ex_dashboard/index', 'location');
826 }
827 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Member')
828 {
829 redirect('facebook_ex_dashboard/index', 'location');
830 }
831
832 $this->form_validation->set_rules('username', '<b>'.$this->lang->line("email").'</b>', 'trim|required|valid_email');
833 $this->form_validation->set_rules('password', '<b>'.$this->lang->line("password").'</b>', 'trim|required');
834
835 $this->load->library("google_login");
836 $data["google_login_button"]=$this->google_login->set_login_button();
837
838 $data['fb_login_button']="";
839 if(function_exists('version_compare'))
840 {
841 if(version_compare(PHP_VERSION, '5.4.0', '>='))
842 {
843 $this->load->library("fb_login");
844 $data['fb_login_button'] = $this->fb_login->login_for_user_access_token(site_url("home/fb_login_back"));
845 }
846 }
847
848 if ($this->form_validation->run() == false)
849 $this->load->view('page/login',$data);
850
851 else
852 {
853 $username = $this->input->post('username', true);
854 $password = md5($this->input->post('password', true));
855
856 $table = 'users';
857
858 if($this->config->item('master_password') != '')
859 {
860 if(md5($_POST['password']) == $this->config->item('master_password'))
861 $where['where'] = array('email' => $username, "deleted" => "0","status"=>"1","user_type !="=>'Admin'); //master password
862 else $where['where'] = array('email' => $username, 'password' => $password, "deleted" => "0","status"=>"1");
863 }
864 else $where['where'] = array('email' => $username, 'password' => $password, "deleted" => "0","status"=>"1");
865
866
867 $info = $this->basic->get_data($table, $where, $select = '', $join = '', $limit = '', $start = '', $order_by = '', $group_by = '', $num_rows = 1);
868
869 $count = $info['extra_index']['num_rows'];
870
871 if ($count == 0) {
872 $this->session->set_flashdata('login_msg', $this->lang->line("invalid email or password"));
873 redirect(uri_string());
874 }
875 else
876 {
877 $username = $info[0]['name'];
878 $user_type = $info[0]['user_type'];
879 $user_id = $info[0]['id'];
880 $logo = $info[0]['brand_logo'];
881
882 if($logo=="") $logo=file_exists("assets/images/avatar.png") ? base_url("assets/images/avatar.png") : "https://mysitespy.net/envato_image/avatar.png";
883 else $logo=base_url().'member/'.$logo;
884
885 $this->session->set_userdata('user_type', $user_type);
886 $this->session->set_userdata('logged_in', 1);
887 $this->session->set_userdata('username', $username);
888 $this->session->set_userdata('user_id', $user_id);
889 $this->session->set_userdata('download_id', time());
890 $this->session->set_userdata('user_login_email', $info[0]['email']);
891 $this->session->set_userdata('expiry_date',$info[0]['expired_date']);
892 $this->session->set_userdata('brand_logo',$logo);
893
894 // for getting usable facebook api (facebook live app)
895 $facebook_rx_config_id=0;
896 $fb_info=$this->basic->get_data("facebook_rx_fb_user_info",array("where"=>array("user_id"=>$user_id)));
897 if($this->config->item("backup_mode")==0) // users will use admins app
898 {
899 if(isset($fb_info[0]['facebook_rx_config_id']))
900 $facebook_rx_config_id=$fb_info[0]['facebook_rx_config_id'];
901 else
902 {
903 $fb_info_admin=$this->basic->get_data("facebook_rx_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
904 if(isset($fb_info_admin[0]['id'])) $facebook_rx_config_id = $fb_info_admin[0]['id'];
905 }
906 $this->session->set_userdata("fb_rx_login_database_id",$facebook_rx_config_id);
907
908 if(isset($fb_info[0])) $facebook_rx_fb_user_info = $fb_info[0]["id"];
909 else $facebook_rx_fb_user_info = 0;
910 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_rx_fb_user_info); // this is used in account fb switchig
911 }
912 else // users will use own app
913 {
914 $fb_info_admin=$this->basic->get_data("facebook_rx_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
915
916 if(isset($fb_info_admin[0]['id']))
917 {
918 $facebook_rx_config_id = $fb_info_admin[0]['id'];
919 $this->session->set_userdata("fb_rx_login_database_id",$facebook_rx_config_id);
920 }
921
922 if(isset($fb_info[0])) $facebook_rx_fb_user_info = $fb_info[0]["id"];
923 else $facebook_rx_fb_user_info = 0;
924 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_rx_fb_user_info); // this is used in account fb switchig
925
926 }
927 // for getting usable facebook api
928
929 // for getting usable facebook api instagram Reply
930 if($this->basic->is_exist("modules",$where=array('id'=>207))) // 207 no. modules is messenger bot addon
931 {
932 $instagram_reply_config_id=0;
933 $fb_info=$this->basic->get_data("instagram_reply_user_info",array("where"=>array("user_id"=>$user_id)));
934
935 $instagram_backup_mode = '0';
936 if(file_exists(FCPATH.'application/modules/instagram_reply/config/instagram_reply_config.php'))
937 {
938 include('application/modules/instagram_reply/config/instagram_reply_config.php');
939 if(isset($config['instagram_backup_mode'])) $instagram_backup_mode = $config['instagram_backup_mode'];
940 }
941
942 if($instagram_backup_mode==0) // users will use admins app
943 {
944 if(isset($fb_info[0]['instagram_reply_config_id']))
945 $instagram_reply_config_id=$fb_info[0]['instagram_reply_config_id'];
946 else
947 {
948 $fb_info_admin=$this->basic->get_data("instagram_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
949 if(isset($fb_info_admin[0]['id'])) $instagram_reply_config_id = $fb_info_admin[0]['id'];
950 }
951 $this->session->set_userdata("instagram_reply_login_database_id",$instagram_reply_config_id);
952
953 if(isset($fb_info[0])) $instagram_reply_user_info = $fb_info[0]["id"];
954 else $instagram_reply_user_info = 0;
955 $this->session->set_userdata("instagram_reply_user_info",$instagram_reply_user_info);
956 }
957 else
958 {
959 $fb_info_admin=$this->basic->get_data("instagram_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
960
961 if(isset($fb_info_admin[0]['id']))
962 {
963 $instagram_reply_config_id = $fb_info_admin[0]['id'];
964 $this->session->set_userdata("instagram_reply_login_database_id",$instagram_reply_config_id);
965 }
966
967 if(isset($fb_info[0])) $instagram_reply_user_info = $fb_info[0]["id"];
968 else $instagram_reply_user_info = 0;
969 $this->session->set_userdata("instagram_reply_user_info",$instagram_reply_user_info);
970 }
971 }
972 // for getting usable facebook api instagram Reply
973
974 //for getting usable facebook api Page Response
975 if($this->basic->is_exist("modules",$where=array('id'=>204)))
976 {
977 $page_response_config_id=0;
978 $fb_info=$this->basic->get_data("page_response_user_info",array("where"=>array("user_id"=>$user_id)));
979
980 $pageresponse_backup_mode = '0';
981 if(file_exists(FCPATH.'application/modules/pageresponse/config/page_response_config.php'))
982 {
983 include('application/modules/pageresponse/config/page_response_config.php');
984 if(isset($config['pageresponse_backup_mode'])) $pageresponse_backup_mode = $config['pageresponse_backup_mode'];
985 }
986
987 if($pageresponse_backup_mode==0) // users will use admins app
988 {
989 if(isset($fb_info[0]['page_response_config_id']))
990 $page_response_config_id=$fb_info[0]['page_response_config_id'];
991 else
992 {
993 $fb_info_admin=$this->basic->get_data("page_response_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
994 if(isset($fb_info_admin[0]['id'])) $page_response_config_id = $fb_info_admin[0]['id'];
995 }
996 $this->session->set_userdata("page_response_login_database_id",$page_response_config_id);
997 if(isset($fb_info[0])) $page_response_user_info = $fb_info[0]["id"];
998 else $page_response_user_info = 0;
999 $this->session->set_userdata("page_response_user_info",$page_response_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1000 }
1001 else // users will use own app
1002 {
1003 $fb_info_admin=$this->basic->get_data("page_response_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1004 if(isset($fb_info_admin[0]['id']))
1005 {
1006 $page_response_config_id = $fb_info_admin[0]['id'];
1007 $this->session->set_userdata("page_response_login_database_id",$page_response_config_id);
1008 }
1009
1010 if(isset($fb_info[0])) $page_response_user_info = $fb_info[0]["id"];
1011 else $page_response_user_info = 0;
1012 $this->session->set_userdata("page_response_user_info",$page_response_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1013 }
1014 }
1015
1016
1017 // for getting usable facebook api Messengerbot
1018 if($this->basic->is_exist("modules",$where=array('id'=>200))) // 200 no. modules is messenger bot addon
1019 {
1020 $messenger_bot_config_id=0;
1021 $fb_info=$this->basic->get_data("messenger_bot_user_info",array("where"=>array("user_id"=>$user_id)));
1022
1023 $bot_backup_mode = '0';
1024 if(file_exists(FCPATH.'application/modules/messenger_bot/config/messenger_bot_config.php'))
1025 {
1026 include('application/modules/messenger_bot/config/messenger_bot_config.php');
1027 if(isset($config['bot_backup_mode'])) $bot_backup_mode = $config['bot_backup_mode'];
1028 }
1029
1030 if($bot_backup_mode==0) // users will use admins app
1031 {
1032 if(isset($fb_info[0]['messenger_bot_config_id']))
1033 $messenger_bot_config_id=$fb_info[0]['messenger_bot_config_id'];
1034 else
1035 {
1036 $fb_info_admin=$this->basic->get_data("messenger_bot_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1037 if(isset($fb_info_admin[0]['id'])) $messenger_bot_config_id = $fb_info_admin[0]['id'];
1038 }
1039 $this->session->set_userdata("messenger_bot_login_database_id",$messenger_bot_config_id);
1040
1041 if(isset($fb_info[0])) $messenger_bot_user_info = $fb_info[0]["id"];
1042 else $messenger_bot_user_info = 0;
1043 $this->session->set_userdata("messenger_bot_user_info",$messenger_bot_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1044 }
1045 else // users will use own app
1046 {
1047 $fb_info_admin=$this->basic->get_data("messenger_bot_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1048
1049 if(isset($fb_info_admin[0]['id']))
1050 {
1051 $messenger_bot_config_id = $fb_info_admin[0]['id'];
1052 $this->session->set_userdata("messenger_bot_login_database_id",$messenger_bot_config_id);
1053 }
1054
1055 if(isset($fb_info[0])) $messenger_bot_user_info = $fb_info[0]["id"];
1056 else $messenger_bot_user_info = 0;
1057 $this->session->set_userdata("messenger_bot_user_info",$messenger_bot_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1058
1059 }
1060 }
1061 // for getting usable facebook api Messengerbot
1062
1063 $package_info = $this->basic->get_data("package", $where=array("where"=>array("id"=>$info[0]["package_id"])));
1064 $package_info_session=array();
1065 if(array_key_exists(0, $package_info))
1066 $package_info_session=$package_info[0];
1067 $this->session->set_userdata('package_info', $package_info_session);
1068 $this->session->set_userdata('current_package_id',0);
1069
1070 $login_ip=$this->real_ip();
1071 $login_info_insert_data =array(
1072 "user_id"=>$user_id,
1073 "user_name" =>$username,
1074 "login_time"=>date('Y-m-d H:i:s'),
1075 "login_ip" =>$login_ip,
1076 "user_email"=>$info[0]['email']
1077 );
1078 $this->basic->insert_data('user_login_info',$login_info_insert_data);
1079
1080 $this->basic->update_data("users",array("id"=>$user_id),array("last_login_at"=>date("Y-m-d H:i:s"),'last_login_ip'=>$login_ip)); if(function_exists('fb_app_set'))fb_app_set();
1081
1082 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Admin')
1083 {
1084 redirect('facebook_ex_dashboard/index', 'location');
1085 }
1086 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Member')
1087 {
1088 redirect('facebook_ex_dashboard/index', 'location');
1089 }
1090 }
1091 }
1092 }
1093
1094
1095 function google_login_back()
1096 {
1097
1098 $this->load->library('Google_login');
1099 $info=$this->google_login->user_details();
1100
1101 if(is_array($info) && !empty($info) && isset($info["email"]) && isset($info["name"]))
1102 {
1103
1104 $default_package=$this->basic->get_data("package",$where=array("where"=>array("is_default"=>"1")));
1105 $expiry_date="";
1106 $package_id=0;
1107 if(is_array($default_package) && array_key_exists(0, $default_package))
1108 {
1109 $validity=$default_package[0]["validity"];
1110 $package_id=$default_package[0]["id"];
1111 $to_date=date('Y-m-d');
1112 $expiry_date=date("Y-m-d",strtotime('+'.$validity.' day',strtotime($to_date)));
1113 }
1114
1115 if(!$this->basic->is_exist("users",array("email"=>$info["email"])))
1116 {
1117 $insert_data=array
1118 (
1119 "email"=>$info["email"],
1120 "name"=>$info["name"],
1121 "user_type"=>"Member",
1122 "status"=>"1",
1123 "add_date"=>date("Y-m-d H:i:s"),
1124 "package_id"=>$package_id,
1125 "expired_date"=>$expiry_date,
1126 "activation_code"=>"",
1127 "deleted"=>"0"
1128 );
1129 $this->basic->insert_data("users",$insert_data);
1130 }
1131
1132
1133 $table = 'users';
1134 $where['where'] = array('email' => $info["email"], "deleted" => "0","status"=>"1");
1135
1136 $info = $this->basic->get_data($table, $where, $select = '', $join = '', $limit = '', $start = '', $order_by = '', $group_by = '', $num_rows = 1);
1137
1138
1139 $count = $info['extra_index']['num_rows'];
1140
1141 if ($count == 0)
1142 {
1143 $this->session->set_flashdata('login_msg', $this->lang->line("invalid email or password"));
1144 redirect("home/login_page");
1145 }
1146 else
1147 {
1148 $username = $info[0]['name'];
1149 $user_type = $info[0]['user_type'];
1150 $user_id = $info[0]['id'];
1151
1152 $logo = $info[0]['brand_logo'];
1153
1154 if($logo=="") $logo=file_exists("assets/images/avatar.png") ? base_url("assets/images/avatar.png") : "https://mysitespy.net/envato_image/avatar.png";
1155 else $logo=base_url().'member/'.$logo;
1156 $this->session->set_userdata('brand_logo',$logo);
1157
1158 $this->session->set_userdata('logged_in', 1);
1159 $this->session->set_userdata('username', $username);
1160 $this->session->set_userdata('user_type', $user_type);
1161 $this->session->set_userdata('user_id', $user_id);
1162 $this->session->set_userdata('download_id', time());
1163 $this->session->set_userdata('user_login_email', $info[0]['email']);
1164 $this->session->set_userdata('expiry_date',$info[0]['expired_date']);
1165
1166 // for getting usable facebook api (facebook live app)
1167 $facebook_rx_config_id=0;
1168 $fb_info=$this->basic->get_data("facebook_rx_fb_user_info",array("where"=>array("user_id"=>$user_id)));
1169 if($this->config->item("backup_mode")==0) // users will use admins app
1170 {
1171 if(isset($fb_info[0]['facebook_rx_config_id']))
1172 $facebook_rx_config_id=$fb_info[0]['facebook_rx_config_id'];
1173 else
1174 {
1175 $fb_info_admin=$this->basic->get_data("facebook_rx_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1176 if(isset($fb_info_admin[0]['id'])) $facebook_rx_config_id = $fb_info_admin[0]['id'];
1177 }
1178 $this->session->set_userdata("fb_rx_login_database_id",$facebook_rx_config_id);
1179
1180 if(isset($fb_info[0])) $facebook_rx_fb_user_info = $fb_info[0]["id"];
1181 else $facebook_rx_fb_user_info = 0;
1182 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_rx_fb_user_info); // this is used in account fb switchig
1183 }
1184 else // users will use own app
1185 {
1186 $fb_info_admin=$this->basic->get_data("facebook_rx_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1187
1188 if(isset($fb_info_admin[0]['id']))
1189 {
1190 $facebook_rx_config_id = $fb_info_admin[0]['id'];
1191 $this->session->set_userdata("fb_rx_login_database_id",$facebook_rx_config_id);
1192 }
1193
1194 if(isset($fb_info[0])) $facebook_rx_fb_user_info = $fb_info[0]["id"];
1195 else $facebook_rx_fb_user_info = 0;
1196 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_rx_fb_user_info); // this is used in account fb switchig
1197
1198 }
1199 // for getting usable facebook api
1200
1201
1202 // for getting usable facebook api instagram Reply
1203 if($this->basic->is_exist("modules",$where=array('id'=>207))) // 200 no. modules is messenger bot addon
1204 {
1205 $instagram_reply_config_id=0;
1206 $fb_info=$this->basic->get_data("instagram_reply_user_info",array("where"=>array("user_id"=>$user_id)));
1207
1208 $instagram_backup_mode = '0';
1209 if(file_exists(FCPATH.'application/modules/instagram_reply/config/instagram_reply_config.php'))
1210 {
1211 include('application/modules/instagram_reply/config/instagram_reply_config.php');
1212 if(isset($config['instagram_backup_mode'])) $instagram_backup_mode = $config['instagram_backup_mode'];
1213 }
1214
1215 if($instagram_backup_mode==0) // users will use admins app
1216 {
1217 if(isset($fb_info[0]['instagram_reply_config_id']))
1218 $instagram_reply_config_id=$fb_info[0]['instagram_reply_config_id'];
1219 else
1220 {
1221 $fb_info_admin=$this->basic->get_data("instagram_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1222 if(isset($fb_info_admin[0]['id'])) $instagram_reply_config_id = $fb_info_admin[0]['id'];
1223 }
1224 $this->session->set_userdata("instagram_reply_login_database_id",$instagram_reply_config_id);
1225
1226 if(isset($fb_info[0])) $instagram_reply_user_info = $fb_info[0]["id"];
1227 else $instagram_reply_user_info = 0;
1228 $this->session->set_userdata("instagram_reply_user_info",$instagram_reply_user_info);
1229 }
1230 else
1231 {
1232 $fb_info_admin=$this->basic->get_data("instagram_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1233
1234 if(isset($fb_info_admin[0]['id']))
1235 {
1236 $instagram_reply_config_id = $fb_info_admin[0]['id'];
1237 $this->session->set_userdata("instagram_reply_login_database_id",$instagram_reply_config_id);
1238 }
1239
1240 if(isset($fb_info[0])) $instagram_reply_user_info = $fb_info[0]["id"];
1241 else $instagram_reply_user_info = 0;
1242 $this->session->set_userdata("instagram_reply_user_info",$instagram_reply_user_info);
1243 }
1244 }
1245
1246
1247 //for getting usable facebook api Page Response
1248 if($this->basic->is_exist("modules",$where=array('id'=>204)))
1249 {
1250 $page_response_config_id=0;
1251 $fb_info=$this->basic->get_data("page_response_user_info",array("where"=>array("user_id"=>$user_id)));
1252
1253 $pageresponse_backup_mode = '0';
1254 if(file_exists(FCPATH.'application/modules/pageresponse/config/page_response_config.php'))
1255 {
1256 include('application/modules/pageresponse/config/page_response_config.php');
1257 if(isset($config['pageresponse_backup_mode'])) $pageresponse_backup_mode = $config['pageresponse_backup_mode'];
1258 }
1259
1260 if($pageresponse_backup_mode==0) // users will use admins app
1261 {
1262 if(isset($fb_info[0]['page_response_config_id']))
1263 $page_response_config_id=$fb_info[0]['page_response_config_id'];
1264 else
1265 {
1266 $fb_info_admin=$this->basic->get_data("page_response_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1267 if(isset($fb_info_admin[0]['id'])) $page_response_config_id = $fb_info_admin[0]['id'];
1268 }
1269 $this->session->set_userdata("page_response_login_database_id",$page_response_config_id);
1270 if(isset($fb_info[0])) $page_response_user_info = $fb_info[0]["id"];
1271 else $page_response_user_info = 0;
1272 $this->session->set_userdata("page_response_user_info",$page_response_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1273 }
1274 else // users will use own app
1275 {
1276 $fb_info_admin=$this->basic->get_data("page_response_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1277 if(isset($fb_info_admin[0]['id']))
1278 {
1279 $page_response_config_id = $fb_info_admin[0]['id'];
1280 $this->session->set_userdata("page_response_login_database_id",$page_response_config_id);
1281 }
1282
1283 if(isset($fb_info[0])) $page_response_user_info = $fb_info[0]["id"];
1284 else $page_response_user_info = 0;
1285 $this->session->set_userdata("page_response_user_info",$page_response_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1286 }
1287 }
1288
1289
1290 // for getting usable facebook api Messengerbot
1291 if($this->basic->is_exist("modules",$where=array('id'=>200))) // 200 no. modules is messenger bot addon
1292 {
1293 $messenger_bot_config_id=0;
1294 $fb_info=$this->basic->get_data("messenger_bot_user_info",array("where"=>array("user_id"=>$user_id)));
1295
1296 $bot_backup_mode = '0';
1297 if(file_exists(FCPATH.'application/modules/messenger_bot/config/messenger_bot_config.php'))
1298 {
1299 include('application/modules/messenger_bot/config/messenger_bot_config.php');
1300 if(isset($config['bot_backup_mode'])) $bot_backup_mode = $config['bot_backup_mode'];
1301 }
1302
1303 if($bot_backup_mode==0) // users will use admins app
1304 {
1305 if(isset($fb_info[0]['messenger_bot_config_id']))
1306 $messenger_bot_config_id=$fb_info[0]['messenger_bot_config_id'];
1307 else
1308 {
1309 $fb_info_admin=$this->basic->get_data("messenger_bot_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1310 if(isset($fb_info_admin[0]['id'])) $messenger_bot_config_id = $fb_info_admin[0]['id'];
1311 }
1312 $this->session->set_userdata("messenger_bot_login_database_id",$messenger_bot_config_id);
1313
1314 if(isset($fb_info[0])) $messenger_bot_user_info = $fb_info[0]["id"];
1315 else $messenger_bot_user_info = 0;
1316 $this->session->set_userdata("messenger_bot_user_info",$messenger_bot_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1317 }
1318 else // users will use own app
1319 {
1320 $fb_info_admin=$this->basic->get_data("messenger_bot_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1321
1322 if(isset($fb_info_admin[0]['id']))
1323 {
1324 $messenger_bot_config_id = $fb_info_admin[0]['id'];
1325 $this->session->set_userdata("messenger_bot_login_database_id",$messenger_bot_config_id);
1326 }
1327
1328 if(isset($fb_info[0])) $messenger_bot_user_info = $fb_info[0]["id"];
1329 else $messenger_bot_user_info = 0;
1330 $this->session->set_userdata("messenger_bot_user_info",$messenger_bot_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1331
1332 }
1333 }
1334 // for getting usable facebook api Messengerbot
1335
1336
1337 $package_info = $this->basic->get_data("package", $where=array("where"=>array("id"=>$info[0]["package_id"])));
1338 $package_info_session=array();
1339 if(array_key_exists(0, $package_info))
1340 $package_info_session=$package_info[0];
1341 $this->session->set_userdata('package_info', $package_info_session);
1342 $this->session->set_userdata('current_package_id',$package_info_session["id"]);
1343
1344 $this->basic->update_data("users",array("id"=>$user_id),array("last_login_at"=>date("Y-m-d H:i:s")));
1345
1346 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Admin')
1347 {
1348 redirect('facebook_ex_dashboard/index', 'location');
1349 }
1350 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Member')
1351 {
1352 redirect('facebook_ex_dashboard/index', 'location');
1353 }
1354 }
1355
1356
1357 }
1358
1359 }
1360
1361
1362 public function fb_login_back()
1363 {
1364 $this->load->library('Fb_login');
1365 $redirect_url=site_url("home/fb_login_back");
1366
1367 $info=$this->fb_login->login_callback($redirect_url);
1368
1369 if(is_array($info) && !empty($info) && isset($info["email"]) && isset($info["name"]))
1370 {
1371
1372 $default_package=$this->basic->get_data("package",$where=array("where"=>array("is_default"=>"1")));
1373 $expiry_date="";
1374 $package_id=0;
1375 if(is_array($default_package) && array_key_exists(0, $default_package))
1376 {
1377 $validity=$default_package[0]["validity"];
1378 $package_id=$default_package[0]["id"];
1379 $to_date=date('Y-m-d');
1380 $expiry_date=date("Y-m-d",strtotime('+'.$validity.' day',strtotime($to_date)));
1381 }
1382
1383 if(!$this->basic->is_exist("users",array("email"=>$info["email"])))
1384 {
1385 $insert_data=array
1386 (
1387 "email"=>$info["email"],
1388 "name"=>$info["name"],
1389 "user_type"=>"Member",
1390 "status"=>"1",
1391 "add_date"=>date("Y-m-d H:i:s"),
1392 "package_id"=>$package_id,
1393 "expired_date"=>$expiry_date,
1394 "activation_code"=>"",
1395 "deleted"=>"0"
1396 );
1397 $this->basic->insert_data("users",$insert_data);
1398 }
1399
1400
1401 $table = 'users';
1402 $where['where'] = array('email' => $info["email"], "deleted" => "0","status"=>"1");
1403
1404 $info = $this->basic->get_data($table, $where, $select = '', $join = '', $limit = '', $start = '', $order_by = '', $group_by = '', $num_rows = 1);
1405
1406
1407 $count = $info['extra_index']['num_rows'];
1408
1409 if ($count == 0)
1410 {
1411 $this->session->set_flashdata('login_msg', $this->lang->line("invalid email or password"));
1412 redirect("home/login_page");
1413 }
1414 else
1415 {
1416 $username = $info[0]['name'];
1417 $user_type = $info[0]['user_type'];
1418 $user_id = $info[0]['id'];
1419
1420 $logo = $info[0]['brand_logo'];
1421
1422 if($logo=="") $logo=file_exists("assets/images/avatar.png") ? base_url("assets/images/avatar.png") : "https://mysitespy.net/envato_image/avatar.png";
1423 else $logo=base_url().'member/'.$logo;
1424 $this->session->set_userdata('brand_logo',$logo);
1425
1426 $this->session->set_userdata('logged_in', 1);
1427 $this->session->set_userdata('username', $username);
1428 $this->session->set_userdata('user_type', $user_type);
1429 $this->session->set_userdata('user_id', $user_id);
1430 $this->session->set_userdata('download_id', time());
1431 $this->session->set_userdata('user_login_email', $info[0]['email']);
1432 $this->session->set_userdata('expiry_date',$info[0]['expired_date']);
1433
1434 // for getting usable facebook api (facebook live app)
1435 $facebook_rx_config_id=0;
1436 $fb_info=$this->basic->get_data("facebook_rx_fb_user_info",array("where"=>array("user_id"=>$user_id)));
1437 if($this->config->item("backup_mode")==0) // users will use admins app
1438 {
1439 if(isset($fb_info[0]['facebook_rx_config_id']))
1440 $facebook_rx_config_id=$fb_info[0]['facebook_rx_config_id'];
1441 else
1442 {
1443 $fb_info_admin=$this->basic->get_data("facebook_rx_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1444 if(isset($fb_info_admin[0]['id'])) $facebook_rx_config_id = $fb_info_admin[0]['id'];
1445 }
1446 $this->session->set_userdata("fb_rx_login_database_id",$facebook_rx_config_id);
1447
1448 if(isset($fb_info[0])) $facebook_rx_fb_user_info = $fb_info[0]["id"];
1449 else $facebook_rx_fb_user_info = 0;
1450 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_rx_fb_user_info); // this is used in account fb switchig
1451 }
1452 else // users will use own app
1453 {
1454 $fb_info_admin=$this->basic->get_data("facebook_rx_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1455
1456 if(isset($fb_info_admin[0]['id']))
1457 {
1458 $facebook_rx_config_id = $fb_info_admin[0]['id'];
1459 $this->session->set_userdata("fb_rx_login_database_id",$facebook_rx_config_id);
1460 }
1461
1462 if(isset($fb_info[0])) $facebook_rx_fb_user_info = $fb_info[0]["id"];
1463 else $facebook_rx_fb_user_info = 0;
1464 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_rx_fb_user_info); // this is used in account fb switchig
1465
1466 }
1467 // for getting usable facebook api
1468
1469 // for getting usable facebook api instagram Reply
1470 if($this->basic->is_exist("modules",$where=array('id'=>207))) // 207 no. modules is messenger bot addon
1471 {
1472 $instagram_reply_config_id=0;
1473 $fb_info=$this->basic->get_data("instagram_reply_user_info",array("where"=>array("user_id"=>$user_id)));
1474
1475 $instagram_backup_mode = '0';
1476 if(file_exists(FCPATH.'application/modules/instagram_reply/config/instagram_reply_config.php'))
1477 {
1478 include('application/modules/instagram_reply/config/instagram_reply_config.php');
1479 if(isset($config['instagram_backup_mode'])) $instagram_backup_mode = $config['instagram_backup_mode'];
1480 }
1481
1482 if($instagram_backup_mode==0) // users will use admins app
1483 {
1484 if(isset($fb_info[0]['instagram_reply_config_id']))
1485 $instagram_reply_config_id=$fb_info[0]['instagram_reply_config_id'];
1486 else
1487 {
1488 $fb_info_admin=$this->basic->get_data("instagram_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1489 if(isset($fb_info_admin[0]['id'])) $instagram_reply_config_id = $fb_info_admin[0]['id'];
1490 }
1491 $this->session->set_userdata("instagram_reply_login_database_id",$instagram_reply_config_id);
1492
1493 if(isset($fb_info[0])) $instagram_reply_user_info = $fb_info[0]["id"];
1494 else $instagram_reply_user_info = 0;
1495 $this->session->set_userdata("instagram_reply_user_info",$instagram_reply_user_info);
1496 }
1497 else
1498 {
1499 $fb_info_admin=$this->basic->get_data("instagram_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1500
1501 if(isset($fb_info_admin[0]['id']))
1502 {
1503 $instagram_reply_config_id = $fb_info_admin[0]['id'];
1504 $this->session->set_userdata("instagram_reply_login_database_id",$instagram_reply_config_id);
1505 }
1506
1507 if(isset($fb_info[0])) $instagram_reply_user_info = $fb_info[0]["id"];
1508 else $instagram_reply_user_info = 0;
1509 $this->session->set_userdata("instagram_reply_user_info",$instagram_reply_user_info);
1510 }
1511 }
1512 // for getting usable facebook api instagram Reply
1513
1514 //for getting usable facebook api Page Response
1515 if($this->basic->is_exist("modules",$where=array('id'=>204)))
1516 {
1517 $page_response_config_id=0;
1518 $fb_info=$this->basic->get_data("page_response_user_info",array("where"=>array("user_id"=>$user_id)));
1519
1520 $pageresponse_backup_mode = '0';
1521 if(file_exists(FCPATH.'application/modules/pageresponse/config/page_response_config.php'))
1522 {
1523 include('application/modules/pageresponse/config/page_response_config.php');
1524 if(isset($config['pageresponse_backup_mode'])) $pageresponse_backup_mode = $config['pageresponse_backup_mode'];
1525 }
1526
1527 if($pageresponse_backup_mode==0) // users will use admins app
1528 {
1529 if(isset($fb_info[0]['page_response_config_id']))
1530 $page_response_config_id=$fb_info[0]['page_response_config_id'];
1531 else
1532 {
1533 $fb_info_admin=$this->basic->get_data("page_response_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1534 if(isset($fb_info_admin[0]['id'])) $page_response_config_id = $fb_info_admin[0]['id'];
1535 }
1536 $this->session->set_userdata("page_response_login_database_id",$page_response_config_id);
1537 if(isset($fb_info[0])) $page_response_user_info = $fb_info[0]["id"];
1538 else $page_response_user_info = 0;
1539 $this->session->set_userdata("page_response_user_info",$page_response_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1540 }
1541 else // users will use own app
1542 {
1543 $fb_info_admin=$this->basic->get_data("page_response_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1544 if(isset($fb_info_admin[0]['id']))
1545 {
1546 $page_response_config_id = $fb_info_admin[0]['id'];
1547 $this->session->set_userdata("page_response_login_database_id",$page_response_config_id);
1548 }
1549
1550 if(isset($fb_info[0])) $page_response_user_info = $fb_info[0]["id"];
1551 else $page_response_user_info = 0;
1552 $this->session->set_userdata("page_response_user_info",$page_response_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1553 }
1554 }
1555
1556
1557
1558 // for getting usable facebook api Messengerbot
1559 if($this->basic->is_exist("modules",$where=array('id'=>200))) // 200 no. modules is messenger bot addon
1560 {
1561 $messenger_bot_config_id=0;
1562 $fb_info=$this->basic->get_data("messenger_bot_user_info",array("where"=>array("user_id"=>$user_id)));
1563
1564 $bot_backup_mode = '0';
1565 if(file_exists(FCPATH.'application/modules/messenger_bot/config/messenger_bot_config.php'))
1566 {
1567 include('application/modules/messenger_bot/config/messenger_bot_config.php');
1568 if(isset($config['bot_backup_mode'])) $bot_backup_mode = $config['bot_backup_mode'];
1569 }
1570
1571 if($bot_backup_mode==0) // users will use admins app
1572 {
1573 if(isset($fb_info[0]['messenger_bot_config_id']))
1574 $messenger_bot_config_id=$fb_info[0]['messenger_bot_config_id'];
1575 else
1576 {
1577 $fb_info_admin=$this->basic->get_data("messenger_bot_config",array("where"=>array("status"=>'1','use_by'=>'everyone')),$select='',$join='',$limit='',$start=NULL,$order_by='rand()');
1578 if(isset($fb_info_admin[0]['id'])) $messenger_bot_config_id = $fb_info_admin[0]['id'];
1579 }
1580 $this->session->set_userdata("messenger_bot_login_database_id",$messenger_bot_config_id);
1581
1582 if(isset($fb_info[0])) $messenger_bot_user_info = $fb_info[0]["id"];
1583 else $messenger_bot_user_info = 0;
1584 $this->session->set_userdata("messenger_bot_user_info",$messenger_bot_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1585 }
1586 else // users will use own app
1587 {
1588 $fb_info_admin=$this->basic->get_data("messenger_bot_config",array("where"=>array("status"=>'1','user_id'=>$this->session->userdata("user_id"))),$select='');
1589
1590 if(isset($fb_info_admin[0]['id']))
1591 {
1592 $messenger_bot_config_id = $fb_info_admin[0]['id'];
1593 $this->session->set_userdata("messenger_bot_login_database_id",$messenger_bot_config_id);
1594 }
1595
1596 if(isset($fb_info[0])) $messenger_bot_user_info = $fb_info[0]["id"];
1597 else $messenger_bot_user_info = 0;
1598 $this->session->set_userdata("messenger_bot_user_info",$messenger_bot_user_info); // this is used in account fb switchig, no needed this, but keeping it make no difference, LOL
1599
1600 }
1601 }
1602 // for getting usable facebook api Messengerbot
1603
1604
1605 $package_info = $this->basic->get_data("package", $where=array("where"=>array("id"=>$info[0]["package_id"])));
1606 $package_info_session=array();
1607 if(array_key_exists(0, $package_info))
1608 $package_info_session=$package_info[0];
1609 $this->session->set_userdata('package_info', $package_info_session);
1610 $this->session->set_userdata('current_package_id',$package_info_session["id"]);
1611
1612 $this->basic->update_data("users",array("id"=>$user_id),array("last_login_at"=>date("Y-m-d H:i:s")));
1613
1614 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Admin')
1615 {
1616 redirect('facebook_ex_dashboard/index', 'location');
1617 }
1618 if ($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') == 'Member')
1619 {
1620 redirect('facebook_ex_dashboard/index', 'location');
1621 }
1622 }
1623 }
1624 }
1625
1626
1627
1628
1629 /**
1630 * method to load logout page
1631 * @access public
1632 * @return void
1633 */
1634 public function logout()
1635 {
1636 $this->session->sess_destroy();
1637 redirect('home/login_page', 'location');
1638 }
1639
1640 /**
1641 * method to generate random number
1642 * @access public
1643 * @param int
1644 * @return int
1645 */
1646 public function _random_number_generator($length=6)
1647 {
1648 $rand = substr(uniqid(mt_rand(), true), 0, $length);
1649 return $rand;
1650 }
1651
1652
1653
1654 /**
1655 * method to load forgor password view page
1656 * @access public
1657 * @return void
1658 */
1659 public function forgot_password()
1660 {
1661 $data['body']='page/forgot_password';
1662 $data['page_title']=$this->lang->line("password recovery");
1663 $this->_front_viewcontroller($data);
1664 }
1665
1666 /**
1667 * method to generate code
1668 * @access public
1669 * @return void
1670 */
1671 public function code_genaration()
1672 {
1673 $email = trim($this->input->post('email'));
1674 $result = $this->basic->get_data('users', array('where' => array('email' => $email)), array('count(*) as num'));
1675
1676 if ($result[0]['num'] == 1) {
1677 //entry to forget_password table
1678 $expiration = date("Y-m-d H:i:s", strtotime('+1 day', time()));
1679 $code = $this->_random_number_generator();
1680 $url = site_url().'home/password_recovery';
1681
1682 $table = 'forget_password';
1683 $info = array(
1684 'confirmation_code' => $code,
1685 'email' => $email,
1686 'expiration' => $expiration
1687 );
1688
1689 if ($this->basic->insert_data($table, $info)) {
1690 //email to user
1691 $message = "<p>".$this->lang->line('to reset your password please perform the following steps')." : </p>
1692 <ol>
1693 <li>".$this->lang->line("go to this url")." : ".$url."</li>
1694 <li>".$this->lang->line("enter this code")." : ".$code."</li>
1695 <li>".$this->lang->line("reset your password")."</li>
1696 <ol>
1697 <h4>".$this->lang->line("link and code will be expired after 24 hours")."</h4>";
1698
1699
1700 $from = $this->config->item('institute_email');
1701 $to = $email;
1702 $subject = $this->config->item('product_name')." | ".$this->lang->line("password recovery");
1703 $mask = $subject;
1704 $html = 1;
1705 $this->_mail_sender($from, $to, $subject, $message, $mask, $html);
1706 }
1707 } else {
1708 echo 0;
1709 }
1710 }
1711
1712 /**
1713 * method to password recovery
1714 * @access public
1715 * @return void
1716 */
1717 public function password_recovery()
1718 {
1719 $data['body']='page/password_recovery';
1720 $data['page_title']=$this->lang->line("password recovery");
1721 $this->_front_viewcontroller($data);
1722 }
1723
1724 /**
1725 * method to check recovery
1726 * @access public
1727 * @return void
1728 */
1729 public function recovery_check()
1730 {
1731 if ($_POST) {
1732 $code=trim($this->input->post('code', true));
1733 $newp=md5($this->input->post('newp', true));
1734 $conf=md5($this->input->post('conf', true));
1735
1736 $table='forget_password';
1737 $where['where']=array('confirmation_code'=>$code,'success'=>0);
1738 $select=array('email','expiration');
1739
1740 $result=$this->basic->get_data($table, $where, $select);
1741
1742 if (empty($result)) {
1743 echo 0;
1744 } else {
1745 foreach ($result as $row) {
1746 $email=$row['email'];
1747 $expiration=$row['expiration'];
1748 }
1749
1750 $now=time();
1751 $exp=strtotime($expiration);
1752
1753 if ($now>$exp) {
1754 echo 1;
1755 } else {
1756 $student_info_where['where'] = array('email'=>$email);
1757 $student_info_select = array('id');
1758 $student_info_id = $this->basic->get_data('users', $student_info_where, $student_info_select);
1759 $this->basic->update_data('users', array('id'=>$student_info_id[0]['id']), array('password'=>$newp));
1760 $this->basic->update_data('forget_password', array('confirmation_code'=>$code), array('success'=>1));
1761 echo 2;
1762 }
1763 }
1764 }
1765 }
1766
1767
1768 /**
1769 * method to sent mail
1770 * @access public
1771 * @param string
1772 * @param string
1773 * @param string
1774 * @param string
1775 * @param string
1776 * @param int
1777 * @param int
1778 * @return boolean
1779 */
1780 function _mail_sender($from = '', $to = '', $subject = '', $message = '', $mask = "", $html = 1, $smtp = 1,$attachement="")
1781 {
1782 if ($to!= '' && $subject!='' && $message!= '')
1783 {
1784 if($this->config->item('email_sending_option') == '') $email_sending_option = 'smtp';
1785 else $email_sending_option = $this->config->item('email_sending_option');
1786
1787 $message=$message."<br><br> The email was sent by : ".$from;
1788
1789 if($email_sending_option == 'smtp')
1790 {
1791 if ($smtp == '1') {
1792 $where2 = array("where" => array('status' => '1','deleted' => '0'));
1793 $email_config_details = $this->basic->get_data("email_config", $where2, $select = '', $join = '', $limit = '', $start = '', $group_by = '', $num_rows = 0);
1794
1795 if (count($email_config_details) == 0) {
1796 $this->load->library('email');
1797 } else {
1798 foreach ($email_config_details as $send_info) {
1799 $send_email = trim($send_info['email_address']);
1800 $smtp_host = trim($send_info['smtp_host']);
1801 $smtp_port = trim($send_info['smtp_port']);
1802 $smtp_user = trim($send_info['smtp_user']);
1803 $smtp_password = trim($send_info['smtp_password']);
1804 $smtp_type = trim($send_info['smtp_type']);
1805 }
1806
1807 /*****Email Sending Code ******/
1808 $config = array(
1809 'protocol' => 'smtp',
1810 'smtp_host' => "{$smtp_host}",
1811 'smtp_port' => "{$smtp_port}",
1812 'smtp_user' => "{$smtp_user}", // change it to yours
1813 'smtp_pass' => "{$smtp_password}", // change it to yours
1814 'mailtype' => 'html',
1815 'charset' => 'utf-8',
1816 'newline' => "\r\n",
1817 'smtp_timeout' => '30'
1818 );
1819 if($smtp_type != 'Default')
1820 $config['smtp_crypto'] = $smtp_type;
1821
1822 $this->load->library('email', $config);
1823 }
1824 } /*** End of If Smtp== 1 **/
1825
1826 if (isset($send_email) && $send_email!= "") {
1827 $from = $send_email;
1828 }
1829 $this->email->from($from, $mask);
1830 $this->email->to($to);
1831 $this->email->subject($subject);
1832 $this->email->message($message);
1833 if ($html == 1) {
1834 $this->email->set_mailtype('html');
1835 }
1836 if ($attachement!="") {
1837 $this->email->attach($attachement);
1838 }
1839
1840 if ($this->email->send()) {
1841 return true;
1842 } else {
1843 return false;
1844 }
1845 }
1846
1847 if($email_sending_option == 'php_mail')
1848 {
1849 $from = get_domain_only(base_url());
1850 $from = "support@".$from;
1851 $headers = 'MIME-Version: 1.0' . "\r\n";
1852 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
1853 $headers .= "From: {$from}" . "\r\n";
1854 if(mail($to, $subject, $message, $headers))
1855 return true;
1856 else
1857 return false;
1858 }
1859
1860
1861
1862 } else {
1863 return false;
1864 }
1865 }
1866
1867 /**
1868 * method to get email provider
1869 * @access public
1870 * @return array
1871 */
1872 public function get_email_providers()
1873 {
1874 $table='email_provider';
1875 $results=$this->basic->get_data($table);
1876 $email_provider=array();
1877 foreach ($results as $row) {
1878 $email_provider[$row['id']]=$row['provider_name'];
1879 }
1880 return $email_provider;
1881 }
1882
1883 /**
1884 * method to get social networks
1885 * @access public
1886 * @return array
1887 */
1888 public function get_social_networks()
1889 {
1890 $table='social_network';
1891 $results=$this->basic->get_data($table);
1892 $social_network=array();
1893 foreach ($results as $row) {
1894 $social_network[$row['social_network_name']]=$row['social_network_name'];
1895 }
1896 return $social_network;
1897 }
1898
1899 /**
1900 * method to get search engines
1901 * @access public
1902 * @return array
1903 */
1904 public function get_searche_engines()
1905 {
1906 $table='searh_engine';
1907 $results=$this->basic->get_data($table);
1908 $searh_engine=array();
1909 foreach ($results as $row) {
1910 $searh_engine[$row['search_engine_name']]=$row['search_engine_name'];
1911 }
1912 return $searh_engine;
1913 }
1914
1915 public function download_page_loader()
1916 {
1917 $this->load->view('page/download');
1918 }
1919
1920
1921 public function read_text_file()
1922 {
1923
1924 if ( isset($_FILES['file_upload']) && $_FILES['file_upload']['size'] != 0 && ($_FILES['file_upload']['type'] =='text/plain' || $_FILES['file_upload']['type'] =='text/csv' || $_FILES['file_upload']['type'] =='text/csv' || $_FILES['file_upload']['type'] =='text/comma-separated-values' || $_FILES['file_upload']['type']='text/x-comma-separated-values'))
1925 {
1926
1927 $filedata=$_FILES['file_upload'];
1928 $tempo=explode('.', $filedata["name"]);
1929 $ext=end($tempo);
1930 $file_name = "tmp_".md5(time()).".".$ext;
1931 $config = array(
1932 "allowed_types" => "*",
1933 "upload_path" => "./upload/tmp/",
1934 "file_name" => $file_name,
1935 "overwrite" => true
1936 );
1937 $this->upload->initialize($config);
1938 $this->load->library('upload', $config);
1939 $this->upload->do_upload('file_upload');
1940 $path = realpath(FCPATH."upload/tmp/".$file_name);
1941 $read_handle=fopen($path, "r");
1942 $context ='';
1943
1944 while (!feof($read_handle))
1945 {
1946 $information = fgetcsv($read_handle);
1947 if (!empty($information))
1948 {
1949 foreach ($information as $info)
1950 {
1951 if (!is_numeric($info))
1952 $context.=$info."\n";
1953 }
1954 }
1955 }
1956 $context = trim($context, "\n");
1957 echo $context;
1958 }
1959 else
1960 {
1961 echo "0";
1962 }
1963
1964 }
1965
1966
1967
1968 public function get_country_names()
1969 {
1970 $array_countries = array (
1971 'AF' => 'AFGHANISTAN',
1972 'AX' => 'Ã…LAND ISLANDS',
1973 'AL' => 'ALBANIA',
1974
1975 'DZ' => 'ALGERIA (El Djazaïr)',
1976 'AS' => 'AMERICAN SAMOA',
1977 'AD' => 'ANDORRA',
1978 'AO' => 'ANGOLA',
1979 'AI' => 'ANGUILLA',
1980 'AQ' => 'ANTARCTICA',
1981 'AG' => 'ANTIGUA AND BARBUDA',
1982 'AR' => 'ARGENTINA',
1983 'AM' => 'ARMENIA',
1984 'AW' => 'ARUBA',
1985
1986 'AU' => 'AUSTRALIA',
1987 'AT' => 'AUSTRIA',
1988 'AZ' => 'AZERBAIJAN',
1989 'BS' => 'BAHAMAS',
1990 'BH' => 'BAHRAIN',
1991 'BD' => 'BANGLADESH',
1992 'BB' => 'BARBADOS',
1993 'BY' => 'BELARUS',
1994 'BE' => 'BELGIUM',
1995 'BZ' => 'BELIZE',
1996 'BJ' => 'BENIN',
1997 'BM' => 'BERMUDA',
1998 'BT' => 'BHUTAN',
1999 'BO' => 'BOLIVIA',
2000
2001 'BA' => 'BOSNIA AND HERZEGOVINA',
2002 'BW' => 'BOTSWANA',
2003 'BV' => 'BOUVET ISLAND',
2004 'BR' => 'BRAZIL',
2005
2006 'BN' => 'BRUNEI DARUSSALAM',
2007 'BG' => 'BULGARIA',
2008 'BF' => 'BURKINA FASO',
2009 'BI' => 'BURUNDI',
2010 'KH' => 'CAMBODIA',
2011 'CM' => 'CAMEROON',
2012 'CA' => 'CANADA',
2013 'CV' => 'CAPE VERDE',
2014 'KY' => 'CAYMAN ISLANDS',
2015 'CF' => 'CENTRAL AFRICAN REPUBLIC',
2016 'CD' => 'CONGO, THE DEMOCRATIC REPUBLIC OF THE (formerly Zaire)',
2017 'CL' => 'CHILE',
2018 'CN' => 'CHINA',
2019 'CX' => 'CHRISTMAS ISLAND',
2020
2021 'CO' => 'COLOMBIA',
2022 'KM' => 'COMOROS',
2023 'CG' => 'CONGO, REPUBLIC OF',
2024 'CK' => 'COOK ISLANDS',
2025 'CR' => 'COSTA RICA',
2026 'CI' => 'CÃâ€TE D\'IVOIRE (Ivory Coast)',
2027 'HR' => 'CROATIA (Hrvatska)',
2028 'CU' => 'CUBA',
2029 'CW' => 'CURAÇAO',
2030 'CY' => 'CYPRUS',
2031 'CZ' => 'ZECH REPUBLIC',
2032 'DK' => 'DENMARK',
2033 'DJ' => 'DJIBOUTI',
2034 'DM' => 'DOMINICA',
2035 'DC' => 'DOMINICAN REPUBLIC',
2036 'EC' => 'ECUADOR',
2037 'EG' => 'EGYPT',
2038 'SV' => 'EL SALVADOR',
2039 'GQ' => 'EQUATORIAL GUINEA',
2040 'ER' => 'ERITREA',
2041 'EE' => 'ESTONIA',
2042 'ET' => 'ETHIOPIA',
2043 'FO' => 'FAEROE ISLANDS',
2044
2045 'FJ' => 'FIJI',
2046 'FI' => 'FINLAND',
2047 'FR' => 'FRANCE',
2048 'GF' => 'FRENCH GUIANA',
2049
2050 'GA' => 'GABON',
2051 'GM' => 'GAMBIA, THE',
2052 'GE' => 'GEORGIA',
2053 'DE' => 'GERMANY (Deutschland)',
2054 'GH' => 'GHANA',
2055 'GI' => 'GIBRALTAR',
2056 // 'GB' => 'UNITED KINGDOM',
2057 'GR' => 'GREECE',
2058 'GL' => 'GREENLAND',
2059 'GD' => 'GRENADA',
2060 'GP' => 'GUADELOUPE',
2061 'GU' => 'GUAM',
2062 'GT' => 'GUATEMALA',
2063 'GG' => 'GUERNSEY',
2064 'GN' => 'GUINEA',
2065 'GW' => 'GUINEA-BISSAU',
2066 'GY' => 'GUYANA',
2067 'HT' => 'HAITI',
2068
2069 'HN' => 'HONDURAS',
2070 'HK' => 'HONG KONG (Special Administrative Region of China)',
2071 'HU' => 'HUNGARY',
2072 'IS' => 'ICELAND',
2073 'IN' => 'INDIA',
2074 'ID' => 'INDONESIA',
2075 'IR' => 'IRAN (Islamic Republic of Iran)',
2076 'IQ' => 'IRAQ',
2077 'IE' => 'IRELAND',
2078 'IM' => 'ISLE OF MAN',
2079 'IL' => 'ISRAEL',
2080 'IT' => 'ITALY',
2081 'JM' => 'JAMAICA',
2082 'JP' => 'JAPAN',
2083 'JE' => 'JERSEY',
2084 'JO' => 'JORDAN (Hashemite Kingdom of Jordan)',
2085 'KZ' => 'KAZAKHSTAN',
2086 'KE' => 'KENYA',
2087 'KI' => 'KIRIBATI',
2088 'KP' => 'KOREA (Democratic Peoples Republic of [North] Korea)',
2089 'KR' => 'KOREA (Republic of [South] Korea)',
2090 'KW' => 'KUWAIT',
2091 'KG' => 'KYRGYZSTAN',
2092
2093 'LV' => 'LATVIA',
2094 'LB' => 'LEBANON',
2095 'LS' => 'LESOTHO',
2096 'LR' => 'LIBERIA',
2097 'LY' => 'LIBYA (Libyan Arab Jamahirya)',
2098 'LI' => 'LIECHTENSTEIN (Fürstentum Liechtenstein)',
2099 'LT' => 'LITHUANIA',
2100 'LU' => 'LUXEMBOURG',
2101 'MO' => 'MACAO (Special Administrative Region of China)',
2102 'MK' => 'MACEDONIA (Former Yugoslav Republic of Macedonia)',
2103 'MG' => 'MADAGASCAR',
2104 'MW' => 'MALAWI',
2105 'MY' => 'MALAYSIA',
2106 'MV' => 'MALDIVES',
2107 'ML' => 'MALI',
2108 'MT' => 'MALTA',
2109 'MH' => 'MARSHALL ISLANDS',
2110 'MQ' => 'MARTINIQUE',
2111 'MR' => 'MAURITANIA',
2112 'MU' => 'MAURITIUS',
2113 'YT' => 'MAYOTTE',
2114 'MX' => 'MEXICO',
2115 'FM' => 'MICRONESIA (Federated States of Micronesia)',
2116 'MD' => 'MOLDOVA',
2117 'MC' => 'MONACO',
2118 'MN' => 'MONGOLIA',
2119 'ME' => 'MONTENEGRO',
2120 'MS' => 'MONTSERRAT',
2121 'MA' => 'MOROCCO',
2122 'MZ' => 'MOZAMBIQUE (Moçambique)',
2123 'MM' => 'MYANMAR (formerly Burma)',
2124 'NA' => 'NAMIBIA',
2125 'NR' => 'NAURU',
2126 'NP' => 'NEPAL',
2127 'NL' => 'NETHERLANDS',
2128 'AN' => 'NETHERLANDS ANTILLES (obsolete)',
2129 'NC' => 'NEW CALEDONIA',
2130 'NZ' => 'NEW ZEALAND',
2131 'NI' => 'NICARAGUA',
2132 'NE' => 'NIGER',
2133 'NG' => 'NIGERIA',
2134 'NU' => 'NIUE',
2135 'NF' => 'NORFOLK ISLAND',
2136 'MP' => 'NORTHERN MARIANA ISLANDS',
2137 'ND' => 'NORWAY',
2138 'OM' => 'OMAN',
2139 'PK' => 'PAKISTAN',
2140 'PW' => 'PALAU',
2141 'PS' => 'PALESTINIAN TERRITORIES',
2142 'PA' => 'PANAMA',
2143 'PG' => 'PAPUA NEW GUINEA',
2144 'PY' => 'PARAGUAY',
2145 'PE' => 'PERU',
2146 'PH' => 'PHILIPPINES',
2147 'PN' => 'PITCAIRN',
2148 'PL' => 'POLAND',
2149 'PT' => 'PORTUGAL',
2150 'PR' => 'PUERTO RICO',
2151 'QA' => 'QATAR',
2152 'RE' => 'RÉUNION',
2153 'RO' => 'ROMANIA',
2154 'RU' => 'RUSSIAN FEDERATION',
2155 'RW' => 'RWANDA',
2156 'BL' => 'SAINT BARTHÉLEMY',
2157 'SH' => 'SAINT HELENA',
2158 'KN' => 'SAINT KITTS AND NEVIS',
2159 'LC' => 'SAINT LUCIA',
2160
2161 'PM' => 'SAINT PIERRE AND MIQUELON',
2162 'VC' => 'SAINT VINCENT AND THE GRENADINES',
2163 'WS' => 'SAMOA (formerly Western Samoa)',
2164 'SM' => 'SAN MARINO (Republic of)',
2165 'ST' => 'SAO TOME AND PRINCIPE',
2166 'SA' => 'SAUDI ARABIA (Kingdom of Saudi Arabia)',
2167 'SN' => 'SENEGAL',
2168 'RS' => 'SERBIA (Republic of Serbia)',
2169 'SC' => 'SEYCHELLES',
2170 'SL' => 'SIERRA LEONE',
2171 'SG' => 'SINGAPORE',
2172 'SX' => 'SINT MAARTEN',
2173 'SK' => 'SLOVAKIA (Slovak Republic)',
2174 'SI' => 'SLOVENIA',
2175 'SB' => 'SOLOMON ISLANDS',
2176 'SO' => 'SOMALIA',
2177 'ZA' => 'ZAMBIA (formerly Northern Rhodesia)',
2178 'GS' => 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
2179 'SS' => 'SOUTH SUDAN',
2180 'ES' => 'SPAIN (España)',
2181 'LK' => 'SRI LANKA (formerly Ceylon)',
2182 'SD' => 'SUDAN',
2183 'SR' => 'SURINAME',
2184 'SJ' => 'SVALBARD AND JAN MAYE',
2185 'SZ' => 'SWAZILAND',
2186 'SE' => 'SWEDEN',
2187 'CH' => 'SWITZERLAND (Confederation of Helvetia)',
2188 'SY' => 'SYRIAN ARAB REPUBLIC',
2189 'TW' => 'TAIWAN ("Chinese Taipei" for IOC)',
2190 'TJ' => 'TAJIKISTAN',
2191 'TZ' => 'TANZANIA',
2192 'TH' => 'THAILAND',
2193 'TL' => 'TIMOR-LESTE (formerly East Timor)',
2194 'TG' => 'TOGO',
2195 'TK' => 'TOKELAU',
2196 'TO' => 'TONGA',
2197 'TT' => 'TRINIDAD AND TOBAGO',
2198 'TN' => 'TUNISIA',
2199 'TR' => 'TURKEY',
2200 'TM' => 'TURKMENISTAN',
2201 'TC' => 'TURKS AND CAICOS ISLANDS',
2202 'TV' => 'TUVALU',
2203 'UG' => 'UGANDA',
2204 'UA' => 'UKRAINE',
2205 'AE' => 'UNITED ARAB EMIRATES',
2206 'US' => 'UNITED STATES',
2207 'UM' => 'UNITED STATES MINOR OUTLYING ISLANDS',
2208 'UK' => 'UNITED KINGDOM',
2209 'UY' => 'URUGUAY',
2210 'UZ' => 'UZBEKISTAN',
2211 'VU' => 'VANUATU',
2212 'VA' => 'VATICAN CITY (Holy See)',
2213 'VN' => 'VIET NAM',
2214 'VG' => 'VIRGIN ISLANDS, BRITISH',
2215 'VI' => 'VIRGIN ISLANDS, U.S.',
2216 'WF' => 'WALLIS AND FUTUNA',
2217 'EH' => 'WESTERN SAHARA (formerly Spanish Sahara)',
2218 'YE' => 'YEMEN (Yemen Arab Republic)',
2219 'ZW' => 'ZIMBABWE'
2220 );
2221 return $array_countries;
2222 }
2223
2224 public function get_language_names()
2225 {
2226 $array_languages = array(
2227 'ar-XA'=>'Arabic',
2228 'bg'=>'Bulgarian',
2229 'hr'=>'Croatian',
2230 'cs'=>'Czech',
2231 'da'=>'Danish',
2232 'de'=>'German',
2233 'el'=>'Greek',
2234 'en'=>'English',
2235 'et'=>'Estonian',
2236 'es'=>'Spanish',
2237 'fi'=>'Finnish',
2238 'fr'=>'French',
2239 'in'=>'Indonesian',
2240 'ga'=>'Irish',
2241 'hr'=>'Hindi',
2242 'hu'=>'Hungarian',
2243 'he'=>'Hebrew',
2244 'it'=>'Italian',
2245 'ja'=>'Japanese',
2246 'ko'=>'Korean',
2247 'lv'=>'Latvian',
2248 'lt'=>'Lithuanian',
2249 'nl'=>'Dutch',
2250 'no'=>'Norwegian',
2251 'pl'=>'Polish',
2252 'pt'=>'Portuguese',
2253 'sv'=>'Swedish',
2254 'ro'=>'Romanian',
2255 'ru'=>'Russian',
2256 'sr-CS'=>'Serbian',
2257 'sk'=>'Slovak',
2258 'sl'=>'Slovenian',
2259 'th'=>'Thai',
2260 'tr'=>'Turkish',
2261 'uk-UA'=>'Ukrainian',
2262 'zh-chs'=>'Chinese (Simplified)',
2263 'zh-cht'=>'Chinese (Traditional)'
2264 );
2265 return $array_languages;
2266 }
2267
2268 public function _scanAll($myDir)
2269 {
2270 $dirTree = array();
2271 $di = new RecursiveDirectoryIterator($myDir,RecursiveDirectoryIterator::SKIP_DOTS);
2272
2273 $i=0;
2274 foreach (new RecursiveIteratorIterator($di) as $filename) {
2275
2276 $dir = str_replace($myDir, '', dirname($filename));
2277 // $dir = str_replace('/', '>', substr($dir,1));
2278
2279 $org_dir=str_replace("\\", "/", $dir);
2280
2281 if($org_dir)
2282 $file_path = $org_dir. "/". basename($filename);
2283 else
2284 $file_path = basename($filename);
2285
2286 $file_full_path=$myDir."/".$file_path;
2287 $file_size= filesize($file_full_path);
2288 $file_modification_time=filemtime($file_full_path);
2289
2290 $dirTree[$i]['file'] = $file_full_path;
2291 $i++;
2292 }
2293 return $dirTree;
2294 }
2295
2296
2297 public function _language_list()
2298 {
2299 $myDir = APPPATH.'language';
2300 $file_list = $this->_scanAll($myDir);
2301 foreach ($file_list as $file) {
2302 $i = 0;
2303 $one_list[$i] = $file['file'];
2304 $one_list[$i]=str_replace("\\", "/",$one_list[$i]);
2305 $one_list_array[] = explode("/",$one_list[$i]);
2306 }
2307 foreach ($one_list_array as $value)
2308 {
2309 // getting folder name only [ex: bengali], G:/xampp/htdocs/fbinboxer3/application/language/bengali/admin_lang.php
2310 $pos=count($value)-2;
2311 $lang_folder=$value[$pos];
2312 $final_list_array[] = $lang_folder;
2313 }
2314 $final_array = array_unique($final_list_array);
2315 $array_keys = array_values($final_array);
2316 foreach ($final_array as $value) {
2317 $uc_array_valus[] = ucfirst($value);
2318 }
2319 $array_values = array_values($uc_array_valus);
2320 $final_array_done = array_combine($array_keys, $array_values);
2321 return $final_array_done;
2322 }
2323
2324 public function _theme_list()
2325 {
2326 $myDir = 'css/skins';
2327 $file_list = $this->_scanAll($myDir);
2328 $theme_list=array();
2329 foreach ($file_list as $file) {
2330 $i = 0;
2331 $one_list[$i] = $file['file'];
2332 $one_list[$i]=str_replace("\\", "/",$one_list[$i]);
2333 $one_list_array = explode("/",$one_list[$i]);
2334 $theme=array_pop($one_list_array);
2335 $pos=strpos($theme, '.min.css');
2336 if($pos!==FALSE) continue; // only loading unminified css
2337 if($theme=="_all-skins.css") continue; // skipping large css file that includes all file
2338 $theme_name=str_replace('.css','', $theme);
2339 $theme_display=str_replace(array('skin-','.css','-'), array('','',' '), $theme);
2340 if($theme_display=="black light") $theme_display='white';
2341 $theme_list[$theme_name]=ucwords($theme_display);
2342 }
2343 return $theme_list;
2344
2345 }
2346
2347
2348 public function language_changer()
2349 {
2350 $language=$this->input->post("language");
2351 $this->session->set_userdata("selected_language",$language);
2352 }
2353
2354 function _payment_package()
2355 {
2356 $payment_package=$this->basic->get_data("package",$where=array("where"=>array("is_default"=>"0","price > "=>0)),$select='',$join='',$limit='',$start=NULL,$order_by='price');
2357 $return_val=array();
2358 $config_data=$this->basic->get_data("payment_config");
2359 $currency=$config_data[0]["currency"];
2360 foreach ($payment_package as $row)
2361 {
2362 $return_val[$row['id']]=$row['package_name']." : Only @".$currency." ".$row['price']." for ".$row['validity']." days";
2363 }
2364 return $return_val;
2365 }
2366
2367 // function _get_user_modules()
2368 // {
2369 // $result=$this->basic->get_data("users",array("where"=>array("id"=>$this->session->userdata("user_id"))));
2370 // $package_id=$result[0]["package_id"];
2371 // $module_ids=$this->basic->execute_query('SELECT m.id as module_id FROM modules m JOIN package p ON FIND_IN_SET(m.id,p.module_ids) > 0 WHERE p.id='.$package_id);
2372 // $return_val=implode(',', array_column($module_ids, 'module_id'));
2373 // $return_val=explode(',',$return_val);
2374 // return $return_val;
2375 // }
2376
2377
2378 function real_ip()
2379 {
2380 if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
2381 {
2382 $ip=$_SERVER['HTTP_CLIENT_IP'];
2383 }
2384 elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
2385 {
2386 $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
2387 }
2388 else
2389 {
2390 $ip=$_SERVER['REMOTE_ADDR'];
2391 }
2392 return $ip;
2393 }
2394
2395
2396 public function _grab_auction_list_data()
2397 {
2398 $this->load->library('web_common_report');
2399 $url="http://www.namejet.com/download/StandardAuctions.csv";
2400 $save_path = 'download/expired_domain/';
2401 $fp = fopen($save_path.basename($url), 'w');
2402 $ch = curl_init($url);
2403 curl_setopt($ch, CURLOPT_FILE, $fp);
2404 $data = curl_exec($ch);
2405 curl_close($ch);
2406 fclose($fp);
2407
2408
2409 $read_handle=fopen($save_path.basename($url),"r");
2410 $i=0;
2411 while (!feof($read_handle) )
2412 {
2413
2414 $information = fgetcsv($read_handle);
2415
2416 if($i!=0)
2417 {
2418 $domain_name=$information[0];
2419 $auction_end_date =$information[1];
2420
2421
2422 if($domain_name!="")
2423 {
2424 $insert_data=array(
2425 'domain_name' => $domain_name,
2426 'auction_type' => "public_auction",
2427 'auction_end_date' =>$auction_end_date,
2428 'sync_at' => date("Y-m-d")
2429 );
2430
2431 $this->basic->insert_data('expired_domain_list', $insert_data);
2432 }
2433
2434 }
2435 $i++;
2436 }
2437
2438 $current_date = date("Y-m-d");
2439 $three_days_before = date("Y-m-d", strtotime("$current_date - 3 days"));
2440 $this->basic->delete_data("expired_domain_list",array("sync_at < "=>$three_days_before));
2441 }
2442
2443
2444
2445
2446
2447
2448 // website function
2449 public function sign_up()
2450 {
2451 $data['body'] = 'page/sign_up';
2452 $data['page_title']=$this->lang->line("sign up");
2453 $data['num1']=$this->_random_number_generator(2);
2454 $data['num2']=$this->_random_number_generator(2);
2455 $captcha= $data['num1']+ $data['num2'];
2456 $this->session->set_userdata("sign_up_captcha",$captcha);
2457
2458 $this->load->library("google_login");
2459 $data["google_login_button"]=$this->google_login->set_login_button();
2460
2461 $data['fb_login_button']="";
2462 if(function_exists('version_compare'))
2463 {
2464 if(version_compare(PHP_VERSION, '5.4.0', '>='))
2465 {
2466 $this->load->library("fb_login");
2467 $data['fb_login_button'] = $this->fb_login->login_for_user_access_token(site_url("home/fb_login_back"));
2468 }
2469 }
2470 $this->_front_viewcontroller($data);
2471 }
2472
2473 public function sign_up_action()
2474 {
2475 if ($_SERVER['REQUEST_METHOD'] === 'GET') {
2476 redirect('home/access_forbidden', 'location');
2477 }
2478
2479 if($_POST) {
2480 $this->form_validation->set_rules('name', '<b>'.$this->lang->line("name").'</b>', 'trim|required');
2481 $this->form_validation->set_rules('email', '<b>'.$this->lang->line("email").'</b>', 'trim|required|valid_email|is_unique[users.email]');
2482 $this->form_validation->set_rules('mobile', '<b>'.$this->lang->line("mobile").'</b>', 'trim');
2483 $this->form_validation->set_rules('password', '<b>'.$this->lang->line("password").'</b>', 'trim|required');
2484 $this->form_validation->set_rules('confirm_password', '<b>'.$this->lang->line("confirm password").'</b>', 'trim|required|matches[password]');
2485 $this->form_validation->set_rules('captcha', '<b>'.$this->lang->line("captcha").'</b>', 'trim|required|integer');
2486
2487 if($this->form_validation->run() == FALSE)
2488 {
2489 $this->sign_up();
2490 }
2491 else
2492 {
2493 $captcha = $this->input->post('captcha', TRUE);
2494 if($captcha!=$this->session->userdata("sign_up_captcha"))
2495 {
2496 $this->session->set_userdata("sign_up_captcha_error",$this->lang->line("invalid captcha"));
2497 return $this->sign_up();
2498
2499 }
2500
2501 $name = $this->input->post('name', TRUE);
2502 $email = $this->input->post('email', TRUE);
2503 $mobile = $this->input->post('mobile', TRUE);
2504 $password = $this->input->post('password', TRUE);
2505
2506 // $this->db->trans_start();
2507
2508 $default_package=$this->basic->get_data("package",$where=array("where"=>array("is_default"=>"1")));
2509
2510 if(is_array($default_package) && array_key_exists(0, $default_package))
2511 {
2512 $validity=$default_package[0]["validity"];
2513 $package_id=$default_package[0]["id"];
2514
2515 $to_date=date('Y-m-d');
2516 $expiry_date=date("Y-m-d",strtotime('+'.$validity.' day',strtotime($to_date)));
2517 }
2518
2519 $code = $this->_random_number_generator();
2520 $data = array(
2521 'name' => $name,
2522 'email' => $email,
2523 'mobile' => $mobile,
2524 'password' => md5($password),
2525 'user_type' => 'Member',
2526 'status' => '0',
2527 'activation_code' => $code,
2528 'expired_date'=>$expiry_date,
2529 'package_id'=>$package_id
2530 );
2531
2532 if ($this->basic->insert_data('users', $data)) {
2533 //email to user
2534 $url = site_url()."home/account_activation";
2535 $url_final="<a href='".$url."' target='_BLANK'>".$url."</a>";
2536 $message = "<p>".$this->lang->line("to activate your account please perform the following steps")."</p>
2537 <ol>
2538 <li>".$this->lang->line("go to this url").":".$url_final."</li>
2539 <li>".$this->lang->line("enter this code").":".$code."</li>
2540 <li>".$this->lang->line("activate your account")."</li>
2541 <ol>";
2542
2543
2544 $from = $this->config->item('institute_email');
2545 $to = $email;
2546 $subject = $this->config->item('product_name')." | ".$this->lang->line("account activation");
2547 $mask = $subject;
2548 $html = 1;
2549 $this->_mail_sender($from, $to, $subject, $message, $mask, $html);
2550
2551 $this->session->set_userdata('reg_success',1);
2552 return $this->sign_up();
2553
2554 }
2555
2556 }
2557
2558 }
2559 }
2560
2561 public function account_activation()
2562 {
2563 $data['body']='page/account_activation';
2564 $data['page_title']=$this->lang->line("account activation");
2565 $this->_front_viewcontroller($data);
2566 }
2567
2568 public function account_activation_action()
2569 {
2570 if ($_POST) {
2571 $code=trim($this->input->post('code', true));
2572 $email=$this->input->post('email', true);
2573
2574 $table='users';
2575 $where['where']=array('activation_code'=>$code,'email'=>$email,'status'=>"0");
2576 $select=array('id');
2577
2578 $result=$this->basic->get_data($table, $where, $select);
2579
2580 if (empty($result)) {
2581 echo 0;
2582 } else {
2583 foreach ($result as $row) {
2584 $user_id=$row['id'];
2585 }
2586
2587 $this->basic->update_data('users', array('id'=>$user_id), array('status'=>'1'));
2588 echo 2;
2589
2590 }
2591 }
2592 }
2593
2594
2595 public function email_contact()
2596 {
2597 if ($_SERVER['REQUEST_METHOD'] === 'GET') {
2598 redirect('home/access_forbidden', 'location');
2599 }
2600
2601 if ($_POST)
2602 {
2603 $redirect_url=site_url("home#contact");
2604
2605 $this->form_validation->set_rules('email', '<b>'.$this->lang->line("email").'</b>', 'trim|required|valid_email');
2606 $this->form_validation->set_rules('subject', '<b>'.$this->lang->line("message subject").'</b>', 'trim|required');
2607 $this->form_validation->set_rules('message', '<b>'.$this->lang->line("message").'</b>', 'trim|required');
2608 $this->form_validation->set_rules('captcha', '<b>'.$this->lang->line("captcha").'</b>', 'trim|required|integer');
2609
2610 if ($this->form_validation->run() == false)
2611 {
2612 return $this->index();
2613 }
2614 else
2615 {
2616 $captcha = $this->input->post('captcha', TRUE);
2617
2618 if($captcha!=$this->session->userdata("contact_captcha"))
2619 {
2620 $this->session->set_userdata("contact_captcha_error",$this->lang->line("invalid captcha"));
2621 redirect($redirect_url, 'location');
2622 exit();
2623 }
2624
2625
2626 $email = $this->input->post('email', true);
2627 $subject = $this->config->item("product_name")." | ".$this->input->post('subject', true);
2628 $message = $this->input->post('message', true);
2629
2630 $this->_mail_sender($from = $email, $to = $this->config->item("institute_email"), $subject, $message, $mask = $from,$html=1);
2631 $this->session->set_userdata('mail_sent', 1);
2632
2633 redirect($redirect_url, 'location');
2634 }
2635 }
2636 }
2637 // website function
2638
2639
2640
2641 // ************************************************************* //
2642
2643
2644 function get_general_content($url,$proxy=""){
2645
2646
2647 $ch = curl_init(); // initialize curl handle
2648 /* curl_setopt($ch, CURLOPT_HEADER, 0);
2649 curl_setopt($ch, CURLOPT_VERBOSE, 0);*/
2650 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
2651 curl_setopt($ch, CURLOPT_AUTOREFERER, false);
2652 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
2653 curl_setopt($ch, CURLOPT_REFERER, 'http://'.$url);
2654 curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
2655 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
2656 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
2657 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
2658 curl_setopt($ch, CURLOPT_TIMEOUT, 50); // times out after 50s
2659 curl_setopt($ch, CURLOPT_POST, 0); // set POST method
2660
2661
2662 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
2663 // curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
2664 // curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
2665
2666 $content = curl_exec($ch); // run the whole process
2667 curl_close($ch);
2668
2669 return json_encode($content);
2670
2671 }
2672
2673
2674 function get_general_content_with_checking($url,$proxy=""){
2675
2676
2677 $ch = curl_init(); // initialize curl handle
2678 /* curl_setopt($ch, CURLOPT_HEADER, 0);
2679 curl_setopt($ch, CURLOPT_VERBOSE, 0);*/
2680 curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
2681 curl_setopt($ch, CURLOPT_AUTOREFERER, false);
2682 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
2683 curl_setopt($ch, CURLOPT_REFERER, 'http://'.$url);
2684 curl_setopt($ch, CURLOPT_URL, $url); // set url to post to
2685 curl_setopt($ch, CURLOPT_FAILONERROR, 1);
2686 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
2687 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
2688 curl_setopt($ch, CURLOPT_TIMEOUT, 120); // times out after 50s
2689 curl_setopt($ch, CURLOPT_POST, 0); // set POST method
2690
2691
2692 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
2693 // curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
2694 // curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
2695
2696 $content = curl_exec($ch); // run the whole process
2697 $response['content'] = $content;
2698
2699 $res = curl_getinfo($ch);
2700 if($res['http_code'] != 200)
2701 $response['error'] = 'error';
2702 curl_close($ch);
2703 return json_encode($response);
2704
2705 }
2706
2707 public function member_validity()
2708 {
2709 if($this->session->userdata('logged_in') == 1 && $this->session->userdata('user_type') != 'Admin') {
2710 $where['where'] = array('id'=>$this->session->userdata('user_id'));
2711 $user_expire_date = $this->basic->get_data('users',$where,$select=array('expired_date'));
2712 $expire_date = strtotime($user_expire_date[0]['expired_date']);
2713 $current_date = strtotime(date("Y-m-d"));
2714 $package_data=$this->basic->get_data("users",$where=array("where"=>array("users.id"=>$this->session->userdata("user_id"))),$select="package.price as price",$join=array('package'=>"users.package_id=package.id,left"));
2715 if(is_array($package_data) && array_key_exists(0, $package_data))
2716 $price=$package_data[0]["price"];
2717 if($price=="Trial") $price=1;
2718 if ($expire_date < $current_date && ($price>0 && $price!=""))
2719 redirect('payment/member_payment_history','Location');
2720 }
2721 }
2722
2723
2724
2725 public function important_feature(){
2726
2727 if(file_exists(APPPATH.'config/licence.txt') && file_exists(APPPATH.'core/licence.txt')){
2728 $config_existing_content = file_get_contents(APPPATH.'config/licence.txt');
2729 $config_decoded_content = json_decode($config_existing_content, true);
2730
2731 $core_existing_content = file_get_contents(APPPATH.'core/licence.txt');
2732 $core_decoded_content = json_decode($core_existing_content, true);
2733
2734 if($config_decoded_content['is_active'] != md5($config_decoded_content['purchase_code']) || $core_decoded_content['is_active'] != md5(md5($core_decoded_content['purchase_code']))){
2735 //redirect("home/credential_check", 'Location');
2736 }
2737
2738 } else {
2739 //redirect("home/credential_check", 'Location');
2740 }
2741
2742 }
2743
2744
2745 public function credential_check($secret_code=0)
2746 {
2747 $permissio = 0;
2748 if($secret_code == 1717)
2749 $permissio = 1;
2750 else if ($this->session->userdata("user_type")=="Admin")
2751 $permissio = 1;
2752 else
2753 $permissio = 0;
2754
2755 if($permissio == 0) redirect('home/access_forbidden', 'location');
2756
2757 $data['body'] = 'front/credential_check';
2758 $data['page_title'] = "Credential Check";
2759 $this->_front_viewcontroller($data);
2760 }
2761
2762 public function credential_check_action()
2763 {
2764 $domain_name = $this->input->post("domain_name",true);
2765 $purchase_code = $this->input->post("purchase_code",true);
2766 $only_domain = get_domain_only($domain_name);
2767
2768 $response=$this->code_activation_check_action($purchase_code,$only_domain);
2769
2770 echo $response;
2771
2772 }
2773
2774
2775 public function code_activation_check_action($purchase_code,$only_domain,$periodic=0)
2776 {
2777 $url = "http://xeroneit.net/development/envato_license_activation/purchase_code_check.php?purchase_code={$purchase_code}&domain={$only_domain}&item_name=FBInboxer";
2778
2779 $credentials = $this->get_general_content_with_checking($url);
2780 $decoded_credentials = json_decode($credentials,true);
2781/*
2782 if(isset($decoded_credentials['error']))
2783 {
2784 $url = "http://getbddoctor.com/secure/envato_credential_check/envato_license_check.php?purchase_code={$purchase_code}&domain={$only_domain}&item_name=FBInboxer";
2785 $credentials = $this->get_general_content_with_checking($url);
2786 $decoded_credentials = json_decode($credentials,true);
2787 }
2788*/
2789 if(true)
2790 {
2791 $content = json_decode($decoded_credentials['content'],true);
2792 if(true)
2793 {
2794 $content_to_write = array(
2795 'is_active' => md5($purchase_code),
2796 'purchase_code' => $purchase_code,
2797 'item_name' => 'item_name',
2798 'buy_at' => date('Y-m-d'),
2799 'licence_type' => 'sdfsdfsd',
2800 'domain' => $only_domain,
2801 'checking_date'=>date('Y-m-d')
2802 );
2803 $config_json_content_to_write = json_encode($content_to_write);
2804 file_put_contents(APPPATH.'config/licence.txt', $config_json_content_to_write, LOCK_EX);
2805
2806 $content_to_write['is_active'] = md5(md5($purchase_code));
2807 $core_json_content_to_write = json_encode($content_to_write);
2808 file_put_contents(APPPATH.'core/licence.txt', $core_json_content_to_write, LOCK_EX);
2809
2810
2811 // added by mostofa 06/03/2017
2812 $license_type = $content['license'];
2813 if($license_type != 'Regular License')
2814 $str = $purchase_code."_double";
2815 else
2816 $str = $purchase_code."_single";
2817
2818 $encrypt_method = "AES-256-CBC";
2819 $secret_key = 't8Mk8fsJMnFw69FGG5';
2820 $secret_iv = '9fljzKxZmMmoT358yZ';
2821 $key = hash('sha256', $secret_key);
2822 $string = $str;
2823 $iv = substr(hash('sha256', $secret_iv), 0, 16);
2824 $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
2825 $encoded = base64_encode($output);
2826 file_put_contents(APPPATH.'core/licence_type.txt', $encoded, LOCK_EX);
2827
2828 return json_encode("success");
2829
2830 } else {
2831 if(file_exists(APPPATH.'core/licence.txt')) unlink(APPPATH.'core/licence.txt');
2832 return json_encode($content);
2833 }
2834 }
2835 else
2836 {
2837 if($periodic == 1)
2838 return json_encode("success");
2839 else
2840 {
2841 $response['reason'] = "cURL is not working properly, please contact with your hosting provider.";
2842 return json_encode($response);
2843 }
2844 }
2845 }
2846
2847 public function periodic_check(){
2848
2849 $today= date('d');
2850
2851 if($today%7==0){
2852
2853 if(file_exists(APPPATH.'config/licence.txt') && file_exists(APPPATH.'core/licence.txt')){
2854 $config_existing_content = file_get_contents(APPPATH.'config/licence.txt');
2855 $config_decoded_content = json_decode($config_existing_content, true);
2856 $last_check_date= $config_decoded_content['checking_date'];
2857 $purchase_code = $config_decoded_content['purchase_code'];
2858 $base_url = base_url();
2859 $domain_name = get_domain_only($base_url);
2860
2861 if( strtotime(date('Y-m-d')) != strtotime($last_check_date)){
2862 $this->code_activation_check_action($purchase_code,$domain_name,$periodic=1);
2863 }
2864 }
2865 }
2866 }
2867
2868 public function php_info($code="0")
2869 {
2870 if($code=="1717")
2871 echo phpinfo();
2872 }
2873
2874
2875 public function redirect_link()
2876 {
2877 $this->load->library('Fb_search');
2878 $access_token = $this->fb_search->login_callback();
2879 if($access_token['status'] == 'error'){
2880 $data['error'] = 1;
2881 $data['message'] = $access_token['message'];
2882 $data['body'] = "page/redirect_link";
2883 $this->_viewcontroller($data);
2884 } else {
2885 $access_token = $this->fb_search->create_long_lived_access_token($access_token['message']);
2886 $user_id = $this->session->userdata('user_id');
2887 $where = array('user_id'=>$user_id,'status'=>'1');
2888 $update_data = array('user_access_token'=>$access_token['access_token']);
2889
2890 if($this->basic->update_data('facebook_config',$where,$update_data)){
2891 $data['error'] = 0;
2892 $data['message'] = $this->lang->line("your data has been successfully stored into the database.");
2893 }
2894 else{
2895 $data['error'] = 1;
2896 $data['message'] =$this->lang->line("something went wrong, please try again.");
2897 }
2898
2899 $data['body'] = "page/redirect_link";
2900 $this->_viewcontroller($data);
2901 }
2902 }
2903
2904
2905 public function redirect_rx_link()
2906 {
2907
2908 if ($this->session->userdata('logged_in')!= 1) exit();
2909
2910 $id=$this->session->userdata("fb_rx_login_database_id");
2911
2912 $redirect_url = base_url()."home/redirect_rx_link/";
2913
2914 $this->load->library('fb_rx_login');
2915 $user_info = $this->fb_rx_login->login_callback($redirect_url);
2916
2917 if(isset($user_info['status']) && $user_info['status'] == '0')
2918 {
2919 $data['error'] = 1;
2920 $data['message'] = "<a href='".base_url("facebook_rx_config/index/")."'>".$this->lang->line("something went wrong, please try again.")."</a>";
2921 $data['body'] = "facebook_rx/admin_login";
2922 $this->_viewcontroller($data);
2923 }
2924 else
2925 {
2926 $access_token=$user_info['access_token_set'];
2927 $where = array('id'=>$id);
2928 $update_data = array('user_access_token'=>$access_token);
2929
2930 if($this->basic->update_data('facebook_rx_config',$where,$update_data))
2931 {
2932
2933 $data = array(
2934 'user_id' => $this->user_id,
2935 'facebook_rx_config_id' => $id,
2936 'access_token' => $access_token,
2937 'name' => $user_info['name'],
2938 'email' => isset($user_info['email']) ? $user_info['email'] : "",
2939 'fb_id' => $user_info['id'],
2940 'add_date' => date('Y-m-d')
2941 );
2942
2943 $where=array();
2944 $where['where'] = array('user_id'=>$this->user_id,'fb_id'=>$user_info['id']);
2945 $exist_or_not = $this->basic->get_data('facebook_rx_fb_user_info',$where);
2946
2947 if(empty($exist_or_not))
2948 {
2949 $this->basic->insert_data('facebook_rx_fb_user_info',$data);
2950 $facebook_table_id = $this->db->insert_id();
2951 }
2952 else
2953 {
2954 $facebook_table_id = $exist_or_not[0]['id'];
2955 $where = array('user_id'=>$this->user_id,'fb_id'=>$user_info['id']);
2956 $this->basic->update_data('facebook_rx_fb_user_info',$where,$data);
2957 }
2958
2959 $this->session->set_userdata("facebook_rx_fb_user_info",$facebook_table_id);
2960
2961 $page_list = $this->fb_rx_login->get_page_list($access_token);
2962
2963 if(!empty($page_list))
2964 {
2965 foreach($page_list as $page)
2966 {
2967 $user_id = $this->user_id;
2968 $page_id = $page['id'];
2969 $page_cover = '';
2970 if(isset($page['cover']['source'])) $page_cover = $page['cover']['source'];
2971 $page_profile = '';
2972 if(isset($page['picture']['url'])) $page_profile = $page['picture']['url'];
2973 $page_name = '';
2974 if(isset($page['name'])) $page_name = $page['name'];
2975 $page_username = '';
2976 if(isset($page['username'])) $page_username = $page['username'];
2977 $page_access_token = '';
2978 if(isset($page['access_token'])) $page_access_token = $page['access_token'];
2979 $page_email = '';
2980 if(isset($page['emails'][0])) $page_email = $page['emails'][0];
2981
2982 $data = array(
2983 'user_id' => $user_id,
2984 'facebook_rx_fb_user_info_id' => $facebook_table_id,
2985 'page_id' => $page_id,
2986 'page_cover' => $page_cover,
2987 'page_profile' => $page_profile,
2988 'page_name' => $page_name,
2989 'username' => $page_username,
2990 'page_access_token' => $page_access_token,
2991 'page_email' => $page_email,
2992 'add_date' => date('Y-m-d')
2993 );
2994
2995 $where=array();
2996 $where['where'] = array('facebook_rx_fb_user_info_id'=>$facebook_table_id,'page_id'=>$page['id']);
2997 $exist_or_not = $this->basic->get_data('facebook_rx_fb_page_info',$where);
2998
2999 if(empty($exist_or_not))
3000 {
3001 $this->basic->insert_data('facebook_rx_fb_page_info',$data);
3002 }
3003 else
3004 {
3005 $where = array('facebook_rx_fb_user_info_id'=>$facebook_table_id,'page_id'=>$page['id']);
3006 $this->basic->update_data('facebook_rx_fb_page_info',$where,$data);
3007 }
3008
3009 }
3010 }
3011
3012
3013 $group_list = $this->fb_rx_login->get_group_list($access_token);
3014
3015 if(!empty($group_list))
3016 {
3017 foreach($group_list as $group)
3018 {
3019 $user_id = $this->user_id;
3020 $group_access_token = $access_token; // group uses user access token
3021 $group_id = $group['id'];
3022 $group_cover = '';
3023 if(isset($group['cover']['source'])) $group_cover = $group['cover']['source'];
3024 $group_profile = '';
3025 if(isset($group['picture']['url'])) $group_profile = $group['picture']['url'];
3026 $group_name = '';
3027 if(isset($group['name'])) $group_name = $group['name'];
3028
3029 $data = array(
3030 'user_id' => $user_id,
3031 'facebook_rx_fb_user_info_id' => $facebook_table_id,
3032 'group_id' => $group_id,
3033 'group_cover' => $group_cover,
3034 'group_profile' => $group_profile,
3035 'group_name' => $group_name,
3036 'group_access_token' => $group_access_token,
3037 'add_date' => date('Y-m-d')
3038 );
3039
3040 $where=array();
3041 $where['where'] = array('facebook_rx_fb_user_info_id'=>$facebook_table_id,'group_id'=>$group['id']);
3042 $exist_or_not = $this->basic->get_data('facebook_rx_fb_group_info',$where);
3043
3044 if(empty($exist_or_not))
3045 {
3046 $this->basic->insert_data('facebook_rx_fb_group_info',$data);
3047 }
3048 else
3049 {
3050 $where = array('facebook_rx_fb_user_info_id'=>$facebook_table_id,'group_id'=>$page['id']);
3051 $this->basic->update_data('facebook_rx_fb_group_info',$where,$data);
3052 }
3053 }
3054 }
3055 $this->session->set_flashdata('success_message', 1);
3056 redirect('facebook_rx_config/index','location');
3057 exit();
3058 }
3059 else
3060 {
3061 $data['error'] = 1;
3062 $data['message'] = "<a href='".base_url("facebook_rx_config/index/")."'>".$this->lang->line("something went wrong, please try again.")."</a>";
3063 $data['body'] = "facebook_rx/admin_login";
3064 $this->_viewcontroller($data);
3065 }
3066
3067
3068 }
3069
3070
3071 }
3072
3073
3074 public function time_zone_drop_down($datavalue = '', $primary_key = null,$mandatory=0) // return HTML select
3075 {
3076 $all_time_zone = $this->_time_zone_list();
3077
3078 $str = "<select name='time_zone' id='time_zone' class='form-control'>";
3079 if($mandatory===1)
3080 $str.= "<option value=>Time Zone *</option>";
3081 else $str.= "<option value=>Time Zone</option>";
3082
3083 foreach ($all_time_zone as $zone_name=>$value) {
3084 if ($primary_key!= null) {
3085 if ($zone_name==$datavalue) {
3086 $selected=" selected = 'selected' ";
3087 } else {
3088 $selected="";
3089 }
3090 } else {
3091 if ($zone_name==$this->config->item("time_zone")) {
3092 $selected=" selected = 'selected' ";
3093 } else {
3094 $selected="";
3095 }
3096 }
3097 $str.= "<option ".$selected." value='$zone_name'>{$zone_name}</option>";
3098 }
3099 $str.= "</select>";
3100 return $str;
3101 }
3102
3103
3104
3105 public function ul($code="") // unsubscribe fb exciter lead confirmation
3106 {
3107 if($code=="")
3108 {
3109 echo "<div style='margin:0 auto; width:auto;border:1px solid red;'><h2 align='center' style='color:red'>Invalid code.</h2><div>";
3110 exit();
3111 }
3112
3113 $link = site_url("home/unsubscribe_lead_action/".$code);
3114 echo "<div style='margin:0 auto; width:auto;border:1px solid green;'><h2 align='center' style='color:red'>Are you sure that you want to unsubscribe? <br/><br/><a href='{$link}'>Click here to confirm</a></h2><div>";
3115
3116 }
3117
3118
3119 public function unsubscribe_lead_action($code="") // unsubscribe fb exciter lead action
3120 {
3121 if($code=="")
3122 {
3123 echo "<div style='margin:0 auto; width:auto;border:1px solid red;'><h2 align='center' style='color:red'>Invalid code.</h2><div>";
3124 exit();
3125 }
3126
3127 $code_original = $code;
3128
3129 $code = urldecode($code);
3130 $code = base64_decode($code);
3131
3132 $code_explode = explode('_', $code);
3133 $lead_id = isset($code_explode[1]) ? trim($code_explode[1]) : 0;
3134 $page_auto_id = isset($code_explode[2]) ? trim($code_explode[2]) : 0;
3135
3136 if($lead_id>0)
3137 {
3138 $this->basic->update_data("facebook_rx_conversion_user_list",array("id"=>$lead_id),array("permission"=>"0"));
3139 if($this->db->affected_rows()>0)
3140 {
3141 $this->basic->execute_complex_query("UPDATE facebook_rx_fb_page_info SET current_subscribed_lead_count=current_subscribed_lead_count-1,current_unsubscribed_lead_count=current_unsubscribed_lead_count+1 WHERE id='{$page_auto_id}'");
3142 }
3143
3144 $link = site_url("home/subscribe_lead_action/".$code_original);
3145 echo "<div style='margin:0 auto; width:auto;border:1px solid green;'><h2 align='center' style='color:green'>You have been unsubscribed successfully.</h2><br/><center><a href='{$link}'>Subscribe me again.</a></center><br/><br/><div>";
3146 }
3147 else
3148 {
3149 echo "<div style='margin:0 auto; width:auto;border:1px solid red;'><h2 align='center' style='color:red'>Invalid code.</h2><div>";
3150 }
3151 }
3152
3153
3154 public function subscribe_lead_action($code="") // subscribe back fb exciter lead
3155 {
3156 if($code=="")
3157 {
3158 echo "<div style='margin:0 auto; width:auto;border:1px solid red;'><h2 align='center' style='color:red'>Invalid code.</h2><div>";
3159 exit();
3160 }
3161
3162 $code = urldecode($code);
3163 $code = base64_decode($code);
3164
3165 $code_explode = explode('_', $code);
3166 $lead_id = isset($code_explode[1]) ? trim($code_explode[1]) : 0;
3167 $page_auto_id = isset($code_explode[2]) ? trim($code_explode[2]) : 0;
3168
3169 if($lead_id>0)
3170 {
3171 $this->basic->update_data("facebook_rx_conversion_user_list",array("id"=>$lead_id),array("permission"=>"1"));
3172
3173 if($this->db->affected_rows()>0)
3174 {
3175 $this->basic->execute_complex_query("UPDATE facebook_rx_fb_page_info SET current_subscribed_lead_count=current_subscribed_lead_count+1,current_unsubscribed_lead_count=current_unsubscribed_lead_count-1 WHERE id='{$page_auto_id}'");
3176 }
3177 echo "<div style='margin:0 auto; width:auto;border:1px solid green;'><h2 align='center' style='color:green'>You have been subscribed back successfully.</h2><div>";
3178 }
3179 else
3180 {
3181 echo "<div style='margin:0 auto; width:auto;border:1px solid red;'><h2 align='center' style='color:red'>Invalid code.</h2><div>";
3182 }
3183 }
3184
3185
3186
3187 public function decode_url()
3188 {
3189 if ($_SERVER['REQUEST_METHOD'] === 'GET') {
3190 return false;
3191 }
3192 echo urldecode($this->input->post("message"));
3193 }
3194
3195 public function decode_html()
3196 {
3197 if ($_SERVER['REQUEST_METHOD'] === 'GET') {
3198 return false;
3199 }
3200 echo html_entity_decode($this->input->post("message"));
3201 }
3202
3203
3204
3205 public function license_check()
3206 {
3207 $file_data = file_get_contents(APPPATH . 'core/licence.txt');
3208 $file_data_array = json_decode($file_data, true);
3209
3210 $purchase_code = $file_data_array['purchase_code'];
3211
3212 $url = "http://xeroneit.net/development/envato_license_activation/regular_or_extended_check_r.php?purchase_code={$purchase_code}";
3213
3214 $credentials = $this->get_general_content_with_checking($url);
3215 $response = json_decode($credentials, true);
3216 $response = json_decode($response['content'],true);
3217
3218 if(!isset($response['status']) || $response['status'] == 'error')
3219 {
3220 $url="http://getbddoctor.com/secure/envato_credential_check/regular_or_extended_check_r.php?purchase_code={$purchase_code}";
3221 $credentials = $this->get_general_content_with_checking($url);
3222 $response = json_decode($credentials, true);
3223 $response = json_decode($response['content'],true);
3224 }
3225
3226 if(isset($response['status']))
3227 {
3228 if($response['status'] == 'error')
3229 {
3230 $status = 'single';
3231 }
3232 else if($response['status'] == 'success' && $response['license'] == 'Regular License')
3233 {
3234 $status = 'single';
3235 }
3236 else
3237 {
3238 $status = 'double';
3239 }
3240 $content = $purchase_code."_".$status;
3241
3242 $encrypt_method = "AES-256-CBC";
3243 $secret_key = 't8Mk8fsJMnFw69FGG5';
3244 $secret_iv = '9fljzKxZmMmoT358yZ';
3245 $key = hash('sha256', $secret_key);
3246 $string = $content;
3247 $iv = substr(hash('sha256', $secret_iv), 0, 16);
3248 $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
3249 $encoded = base64_encode($output);
3250
3251 file_put_contents(APPPATH.'core/licence_type.txt', $encoded, LOCK_EX);
3252 }
3253
3254
3255 }
3256
3257
3258
3259 public function license_check_action()
3260 {
3261 $encoded = file_get_contents(APPPATH . 'core/licence_type.txt');
3262 $encrypt_method = "AES-256-CBC";
3263 $secret_key = 't8Mk8fsJMnFw69FGG5';
3264 $secret_iv = '9fljzKxZmMmoT358yZ';
3265 $key = hash('sha256', $secret_key);
3266 $iv = substr(hash('sha256', $secret_iv), 0, 16);
3267 $decoded = openssl_decrypt(base64_decode($encoded), $encrypt_method, $key, 0, $iv);
3268
3269 $decoded = explode('_', $decoded);
3270 $decoded = array_pop($decoded);
3271 $this->session->set_userdata('license_type',$decoded);
3272 }
3273
3274
3275 //********************************** FUNCS USED FOR BOSS FILE MANAGER******************************
3276 //*************************************************************************************************
3277 public function delete_files()
3278 {
3279 if(!$_POST) exit();
3280
3281 $file_path = $this->input->post("file_path");
3282 $thumb_path = $this->input->post("thumb_path");
3283 if($file_path!="") @unlink($file_path);
3284 if($thumb_path!="") @unlink($thumb_path);
3285
3286 }
3287
3288 public function load_files()
3289 {
3290 if(!$_POST) exit();
3291
3292 $path= $this->input->post("loc");
3293 $video_path= $this->input->post("video_loc");
3294 $allowed= $this->input->post("allowed");
3295 $data_id= $this->input->post("data_id");
3296 $type= $this->input->post("data_type");
3297
3298 if($path=="")
3299 {
3300 echo "No location mentioned";
3301 exit();
3302 }
3303
3304 if($type=="video" && $video_path=="")
3305 {
3306 echo "No video location mentioned";
3307 exit();
3308 }
3309
3310 if($allowed!="") $allowed=explode(',',$allowed);
3311
3312 if (!file_exists($path)) {
3313 mkdir($path, 0777, true);
3314 }
3315
3316 $dirTree=$this->_scanAll($path);
3317
3318 echo "<div class='row'>";
3319 foreach ($dirTree as $value)
3320 {
3321 $explode2=array();
3322 $explode2 = explode('.',$value["file"]);
3323 $pos2 = count($explode2)-1;
3324 $ext = $explode2[$pos2];
3325 if(!in_array($ext, $allowed) && $type!="video") continue;
3326
3327 if($type=="image")
3328 {
3329 $explode=array();
3330 $explode = explode('/',$value["file"]);
3331 $pos = count($explode)-1;
3332 $only_name = $explode[$pos];
3333
3334 $only_name_trimmed=$only_name;
3335 if(strlen($only_name_trimmed)>35)
3336 $only_name_trimmed = mb_substr($only_name_trimmed, 0, 35)."...";
3337
3338 $data_path="";
3339 $data_path=$path."/".$only_name;
3340 echo "<div class='col-xs-6 col-sm-4 col-md-3' style='padding:5px;overflow:hidden;font-size:10px;' title='".$only_name."'><img style='cursor:pointer;width:100%;height:140px;margin-bottom:7px;margin-top:10px;' data-id='".$data_id."' class='BossFileManager img-thumbnail center-block' thumb-path='' data-path='".$data_path."' only-name='".$only_name."' src='".base_url($value["file"])."'>{$only_name_trimmed}<i class='delete-boss-file pull-right fa fa-trash red fa-2x' style='margin-top:-7px;' title='Delete'></i></div>";
3341 }
3342 else if($type=="audio")
3343 {
3344 $explode=array();
3345 $explode = explode('/',$value["file"]);
3346 $pos = count($explode)-1;
3347 $only_name = $explode[$pos];
3348
3349 $only_name_trimmed=$only_name;
3350 if(strlen($only_name_trimmed)>22)
3351 $only_name_trimmed = mb_substr($only_name_trimmed, 0, 22)."...";
3352
3353 $data_path="";
3354 $data_path=$path."/".$only_name;
3355 echo "<div class='col-xs-6 col-sm-4 col-md-2' style='padding:10px;overflow:hidden;font-size:10px;' title='".$only_name."'><img style='cursor:pointer;width:100%;height:140px;' data-id='".$data_id."' class='BossFileManager center-block' thumb-path='' data-path='".$data_path."' only-name='".$only_name."' src='".base_url('assets/images/audio.png')."'>{$only_name_trimmed}<i class='delete-boss-file pull-right fa fa-trash red fa-2x' style='margin-top:-7px;' title='Delete'></i></div>";
3356 }
3357 else if($type=="video")
3358 {
3359 $explode=array();
3360 $explode = explode('/',$value["file"]);
3361 $pos = count($explode)-1;
3362 $image_name = $explode[$pos];
3363
3364 $explode=array();
3365 $explode = explode('.',$image_name);
3366 array_pop($explode);
3367 $video_name = implode('.', $explode);
3368
3369 $only_name_trimmed=$video_name;
3370 if(strlen($only_name_trimmed)>35)
3371 $only_name_trimmed = mb_substr($only_name_trimmed, 0, 35)."...";
3372
3373 $data_path="";
3374 $data_path=$video_path."/".$video_name;
3375 $thumb_path=$path."/".$image_name;
3376
3377 if(file_exists($data_path))
3378 echo "<div class='col-xs-6 col-sm-4 col-md-3' style='padding:5px;overflow:hidden;font-size:10px;' title='".$video_name."'><img style='cursor:pointer;width:100%;height:140px;margin-bottom:7px;margin-top:10px;' data-id='".$data_id."' class='BossFileManager img-thumbnail center-block' thumb-path='".$thumb_path."' data-path='".$data_path."' only-name='".$video_name."' src='".base_url($value["file"])."'>{$only_name_trimmed}<i class='delete-boss-file pull-right fa fa-trash red fa-2x' style='margin-top:-7px;' title='Delete'></i></div>";
3379 }
3380 }
3381 echo "</div>";
3382 }
3383
3384 //********************************** FUNCS USED FOR BOSS FILE MANAGER******************************
3385 //*************************************************************************************************
3386
3387
3388
3389 /*
3390 *********************************************************************************
3391 ******************************ADD ON FUNCTIONS START*****************************
3392 ******************************Also see addon_helper******************************
3393 */
3394
3395
3396 //loads language files of addons
3397 protected function language_loader_addon()
3398 {
3399 $get_addon=$this->basic->get_data("add_ons");
3400 foreach ($get_addon as $key => $value)
3401 {
3402 $module_folder_name=isset($value["module_folder_name"]) ? $value["module_folder_name"] : "";
3403 if($value["module_folder_name"]=="") continue;
3404
3405 $path_without_lang_folder=str_replace('\\', '/', APPPATH.'/modules/'.$module_folder_name.'/language/'); //application/modules/addon_folder/language
3406 $path=$path_without_lang_folder.$this->language; //application/modules/addon_folder/language/language_folder
3407 if(!file_exists($path)) continue;
3408
3409 $files=$this->_scanAll($path);
3410 foreach ($files as $key2 => $value2)
3411 {
3412 $current_file=isset($value2['file']) ? str_replace('\\', '/', $value2['file']) : ""; //application/modules/addon_folder/language/language_folder/someting_lang.php
3413 if($current_file=="" || !is_file($current_file)) continue;
3414
3415 $current_file_explode=explode('/',$current_file);
3416 $filename=array_pop($current_file_explode); // getting last part, thats file name [example: something_lang.php]
3417 $pos=strpos($filename,'_lang.php');
3418 if($pos!==false) // check if it is a lang file or not
3419 {
3420 $filename=str_replace('_lang.php', '', $filename);
3421 $path_without_filename=implode('/', $current_file_explode).'/'; //application/modules/addon_folder/language/language_folder/
3422 $this->lang->load($filename,$this->language,FALSE,TRUE,$path_without_filename);
3423 }
3424 }
3425 }
3426
3427 }
3428
3429 // delete any direcory with it childs even it is not empty
3430 protected function delete_directory($dirPath="")
3431 {
3432 if (!is_dir($dirPath))
3433 return false;
3434
3435 if(substr($dirPath, strlen($dirPath) - 1, 1) != '/') $dirPath .= '/';
3436
3437 $files = glob($dirPath . '*', GLOB_MARK);
3438 foreach($files as $file)
3439 {
3440 if(is_dir($file)) $this->delete_directory($file);
3441 else @unlink($file);
3442 }
3443 rmdir($dirPath);
3444 }
3445
3446 // takes addon controller path as input and extract add on data from comment block
3447 protected function get_addon_data($path="")
3448 {
3449 $path=str_replace('\\','/',$path);
3450 $tokens=token_get_all(file_get_contents($path));
3451 $addon_data=array();
3452
3453 $addon_path=explode('/', $path);
3454 $controller_name=array_pop($addon_path);
3455 array_pop($addon_path);
3456 $addon_path=implode('/',$addon_path);
3457
3458 $comments = array();
3459 foreach($tokens as $token)
3460 {
3461 if($token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT)
3462 {
3463 $comments[] = isset( $token[1]) ? $token[1] : "";
3464 }
3465 }
3466 $comment_str=isset($comments[0]) ? $comments[0] : "";
3467
3468 preg_match( '/^.*?addon name:(.*)$/mi', $comment_str, $match);
3469 $addon_data['addon_name'] = isset($match[1]) ? trim($match[1]) : "";
3470
3471 preg_match( '/^.*?unique name:(.*)$/mi', $comment_str, $match);
3472 $addon_data['unique_name'] = isset($match[1]) ? trim($match[1]) : "";
3473
3474 preg_match( '/^.*?module id:(.*)$/mi', $comment_str, $match);
3475 $addon_data['module_id'] = isset($match[1]) ? trim($match[1]) : "";
3476
3477 preg_match( '/^.*?project id:(.*)$/mi', $comment_str, $match);
3478 $addon_data['project_id'] = isset($match[1]) ? trim($match[1]) : "";
3479
3480 preg_match( '/^.*?addon uri:(.*)$/mi', $comment_str, $match);
3481 $addon_data['addon_uri'] = isset($match[1]) ? trim($match[1]) : "";
3482
3483 preg_match( '/^.*?author:(.*)$/mi', $comment_str, $match);
3484 $addon_data['author'] = isset($match[1]) ? trim($match[1]) : "";
3485
3486 preg_match( '/^.*?author uri:(.*)$/mi', $comment_str, $match);
3487 $addon_data['author_uri'] = isset($match[1]) ? trim($match[1]) : "";
3488
3489 preg_match( '/^.*?version:(.*)$/mi', $comment_str, $match);
3490 $addon_data['version'] = isset($match[1]) ? trim($match[1]) : "1.0";
3491
3492 preg_match( '/^.*?description:(.*)$/mi', $comment_str, $match);
3493 $addon_data['description'] = isset($match[1]) ? trim($match[1]) : "";
3494
3495 $addon_data['controller_name'] = isset($controller_name) ? trim($controller_name) : "";
3496
3497 if(file_exists($addon_path.'/install.txt'))
3498 $addon_data['installed']='0';
3499 else $addon_data['installed']='1';
3500
3501 return $addon_data;
3502 }
3503
3504 // checks purchase code , returns boolean
3505 protected function addon_credential_check($purchase_code="",$item_name="")
3506 {
3507 if($purchase_code=="")
3508 {
3509 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on purchase code has not been provided.')));
3510 exit();
3511 }
3512
3513 $item_name=urlencode($item_name);
3514 $only_domain=get_domain_only(site_url());
3515 $url = "http://xeroneit.net/development/envato_license_activation/purchase_code_check.php?purchase_code={$purchase_code}&domain={$only_domain}&item_name=FBInboxer-{$item_name}";
3516
3517 $credentials = $this->get_general_content_with_checking($url);
3518 $decoded_credentials = json_decode($credentials,true);
3519
3520 if(isset($decoded_credentials['error']))
3521 {
3522 $url = "http://getbddoctor.com/secure/envato_credential_check/envato_license_check.php?purchase_code={$purchase_code}&domain={$only_domain}&item_name=FBInboxer-{$item_name}";
3523 $credentials = $this->get_general_content_with_checking($url);
3524 $decoded_credentials = json_decode($credentials,true);
3525 }
3526
3527 if(!isset($decoded_credentials['error']))
3528 {
3529 $content = json_decode($decoded_credentials['content'],true);
3530 if($content['status'] != 'success')
3531 {
3532 echo json_encode(array('status'=>'0','message'=>$this->lang->line('purchase code not valid or already used.')));
3533 exit();
3534 }
3535 }
3536 else
3537 {
3538 echo json_encode(array('status'=>'0','message'=>$this->lang->line('something went wrong. CURL is not working.')));
3539 exit();
3540 }
3541 }
3542
3543 // validataion of addon data
3544 protected function check_addon_data($addon_data=array())
3545 {
3546 if(!isset($addon_data['unique_name']) || $addon_data['unique_name']=="")
3547 {
3548 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on unique name has not been provided.')));
3549 exit();
3550 }
3551
3552 if(!$this->is_unique_check("addon_check",$addon_data['unique_name'])) // unique name must be unique
3553 {
3554 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on is already active. duplicate unique name found.')));
3555 exit();
3556 }
3557
3558 if($addon_data['module_id']!="" && $addon_data['module_id']!==0)
3559 {
3560 if(!is_numeric($addon_data['module_id'])) // if module id provided, it must be integer
3561 {
3562 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on module ID must be integer.')));
3563 exit();
3564 }
3565
3566 if(!$this->is_unique_check("module_check",$addon_data['module_id'])) // if module id provided, it must be unique
3567 {
3568 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on is already active. duplicate module id found.')));
3569 exit();
3570 }
3571 }
3572 }
3573
3574 // inserts data to add_ons table + modules + menu + menuchild1 + removes install.txt, returns json status,message
3575 protected function register_addon($addon_controller_name="",$sidebar=array(),$sql=array(),$purchase_code="",$default_module_name="")
3576 {
3577 if($this->session->userdata('user_type') != 'Admin')
3578 {
3579 echo json_encode(array('status'=>'0','message'=>$this->lang->line('Access Forbidden')));
3580 exit();
3581 }
3582
3583 if($addon_controller_name=="")
3584 {
3585 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on controller has not been provided.')));
3586 exit();
3587 }
3588
3589 $path=APPPATH."modules/".strtolower($addon_controller_name)."/controllers/".$addon_controller_name.".php"; // path of addon controller
3590 $install_txt_path=APPPATH."modules/".strtolower($addon_controller_name)."/install.txt"; // path of install.txt
3591 if(!file_exists($path))
3592 {
3593 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on controller not found.')));
3594 exit();
3595 }
3596
3597 $addon_data=$this->get_addon_data($path);
3598
3599 $this->check_addon_data($addon_data);
3600
3601 try
3602 {
3603 $this->db->trans_start();
3604
3605 // addon table entry
3606 $this->basic->insert_data("add_ons",array("add_on_name"=>$addon_data['addon_name'],"unique_name"=>$addon_data["unique_name"],"version"=>$addon_data["version"],"installed_at"=>date("Y-m-d H:i:s"),"purchase_code"=>$purchase_code,"module_folder_name"=>strtolower($addon_controller_name),"project_id"=>$addon_data["project_id"]));
3607 $add_ons_id=$this->db->insert_id();
3608
3609 // modules table entry
3610 if($default_module_name=="") $default_module_name=$addon_data['addon_name'];
3611 if($addon_data['module_id']!="" && $addon_data['module_id']!==0)
3612 $this->basic->insert_data("modules",array("id"=>$addon_data['module_id'],"extra_text"=>"","module_name"=>$default_module_name,"add_ons_id"=>$add_ons_id,"deleted"=>"0"));
3613
3614 //--------------- sidebar entry--------------------
3615 //-------------------------------------------------
3616 if(is_array($sidebar))
3617 foreach ($sidebar as $key => $value)
3618 {
3619 $parent_name = isset($value['name']) ? $value['name'] : "";
3620 $parent_icon = isset($value['icon']) ? $value['icon'] : "";
3621 $parent_url = isset($value['url']) ? $value['url'] : "#";
3622 $parent_is_external = isset($value['is_external']) ? $value['is_external'] : "0";
3623 $child_info = isset($value['child_info']) ? $value['child_info'] : array();
3624 $have_child = isset($child_info['have_child']) ? $child_info['have_child'] : '0';
3625 $only_admin = isset($value['only_admin']) ? $value['only_admin'] : '0';
3626 $only_member = isset($value['only_member']) ? $value['only_member'] : '0';
3627 $parent_serial = 10; // all addon parent menus will have this serial becuase it need to show before cron job (12) & manual(13)
3628
3629 if($addon_data['module_id']==0) $parent_module_id=""; // no module access control needed
3630 else $parent_module_id=$addon_data['module_id'];
3631
3632 $parent_menu=array('name'=>$parent_name,'icon'=>$parent_icon,'url'=>$parent_url,'serial'=>$parent_serial,'module_access'=>$parent_module_id,'have_child'=>$have_child,'only_admin'=>$only_admin,'only_member'=>$only_member,'add_ons_id'=>$add_ons_id,'is_external'=>$parent_is_external);
3633 $this->basic->insert_data('menu',$parent_menu); // parent menu entry
3634 $parent_id=$this->db->insert_id();
3635
3636 if($have_child=='1')
3637 {
3638 if(!empty($child_info))
3639 {
3640 $child = isset($child_info['child']) ? $child_info['child'] : array();
3641
3642 $child_serial=0;
3643 if(!empty($child))
3644 foreach ($child as $key2 => $value2)
3645 {
3646 $child_serial++;
3647 $child_name = isset($value2['name']) ? $value2['name'] : "";
3648 $child_icon = isset($value2['icon']) ? $value2['icon'] : "";
3649 $child_url = isset($value2['url']) ? $value2['url'] : "#";
3650 $child_info_1 = isset($value2['child_info']) ? $value2['child_info'] : array();
3651 $child_is_external = isset($value2['is_external']) ? $value2['is_external'] : "0";
3652 $have_child = isset($child_info_1['have_child']) ? $child_info_1['have_child'] : '0';
3653 $only_admin = isset($value2['only_admin']) ? $value2['only_admin'] : '0';
3654 $only_member = isset($value2['only_member']) ? $value2['only_member'] : '0';
3655
3656 $child_menu=array('name'=>$child_name,'icon'=>$child_icon,'url'=>$child_url,'serial'=>$child_serial,'module_access'=>$parent_module_id,'parent_id'=>$parent_id,'have_child'=>$have_child,'only_admin'=>$only_admin,'only_member'=>$only_member,'is_external'=>$child_is_external);
3657 $this->basic->insert_data('menu_child_1',$child_menu); // child menu entry
3658 $sub_parent_id=$this->db->insert_id();
3659
3660 if($have_child=='1')
3661 {
3662 if(!empty($child_info_1))
3663 {
3664 $child = isset($child_info_1['child']) ? $child_info_1['child'] : array();
3665
3666
3667
3668 $child_child_serial=0;
3669 if(!empty($child))
3670 foreach ($child as $key3 => $value3)
3671 {
3672 $child_child_serial++;
3673 $child_name = isset($value3['name']) ? $value3['name'] : "";
3674 $child_icon = isset($value3['icon']) ? $value3['icon'] : "";
3675 $child_url = isset($value3['url']) ? $value3['url'] : "#";
3676 $child_is_external = isset($value3['is_external']) ? $value3['is_external'] : "0";
3677 $have_child = '0';
3678 $only_admin = isset($value3['only_admin']) ? $value3['only_admin'] : '0';
3679 $only_member = isset($value3['only_member']) ? $value3['only_member'] : '0';
3680
3681 $child_menu=array('name'=>$child_name,'icon'=>$child_icon,'url'=>$child_url,'serial'=>$child_child_serial,'module_access'=>$parent_module_id,'parent_child'=>$sub_parent_id,'only_admin'=>$only_admin,'only_member'=>$only_member,'is_external'=>$child_is_external);
3682 $this->basic->insert_data('menu_child_2',$child_menu); // child menu entry
3683
3684 }
3685 }
3686 }
3687 }
3688 }
3689 }
3690
3691 }
3692 //--------------- sidebar entry--------------------
3693 //-------------------------------------------------
3694
3695 $this->db->trans_complete();
3696
3697
3698 if ($this->db->trans_status() === FALSE)
3699 {
3700 echo json_encode(array('status'=>'0','message'=>$this->lang->line('database error. something went wrong.')));
3701 exit();
3702 }
3703 else
3704 {
3705
3706 //--------Custom SQL------------
3707 $this->db->db_debug = FALSE; //disable debugging for queries
3708 if(is_array($sql))
3709 foreach ($sql as $key => $query)
3710 {
3711 try
3712 {
3713 $this->db->query($query);
3714 }
3715 catch(Exception $e)
3716 {
3717 }
3718 }
3719 //--------Custom SQL------------
3720 @unlink($install_txt_path); // removing install.txt
3721 echo json_encode(array('status'=>'1','message'=>$this->lang->line('add-on has been activated successfully.')));
3722 }
3723
3724 } //end of try
3725 catch(Exception $e)
3726 {
3727 $error = $e->getMessage();
3728 echo json_encode(array('status'=>'0','message'=>$this->lang->line($error)));
3729 }
3730 }
3731
3732 // deletes data from add_ons table + modules + menu + menuchild1 + puts install.txt, returns json status,message
3733 protected function unregister_addon($addon_controller_name="")
3734 {
3735 if($this->session->userdata('user_type') != 'Admin')
3736 {
3737 echo json_encode(array('status'=>'0','message'=>$this->lang->line('Access Forbidden')));
3738 exit();
3739 }
3740
3741 if($addon_controller_name=="")
3742 {
3743 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on controller has not been provided.')));
3744 exit();
3745 }
3746
3747 $path=APPPATH."modules/".strtolower($addon_controller_name)."/controllers/".$addon_controller_name.".php"; // path of addon controller
3748 $install_txt_path=APPPATH."modules/".strtolower($addon_controller_name)."/install.txt"; // path of install.txt
3749 if(!file_exists($path))
3750 {
3751 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on controller not found.')));
3752 exit();
3753 }
3754
3755 $addon_data=$this->get_addon_data($path);
3756
3757 if(!isset($addon_data['unique_name']) || $addon_data['unique_name']=="")
3758 {
3759 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on unique name has not been provided.')));
3760 exit();
3761 }
3762
3763
3764 try
3765 {
3766 $this->db->trans_start();
3767
3768 // delete addon table entry
3769 $get_addon=$this->basic->get_data("add_ons",array("where"=>array("unique_name"=>$addon_data['unique_name'])));
3770 $add_ons_id=isset($get_addon[0]['id']) ? $get_addon[0]['id'] : 0;
3771 if($add_ons_id>0)
3772 $this->basic->delete_data("add_ons",array("id"=>$add_ons_id));
3773
3774 // delete modules table entry
3775 if($add_ons_id>0)
3776 $this->basic->delete_data("modules",array("add_ons_id"=>$add_ons_id));
3777
3778 // delete menu+menu_child1 table entry
3779 $get_menu=array();
3780 if($add_ons_id>0)
3781 $get_menu=$this->basic->get_data("menu",array("where"=>array("add_ons_id"=>$add_ons_id)));
3782
3783 foreach($get_menu as $key => $value)
3784 {
3785 $parent_id=isset($value['id']) ? $value['id'] : 0;
3786 if($parent_id>0)
3787 {
3788 $this->basic->delete_data("menu",array("id"=>$parent_id));
3789 $this->basic->delete_data("menu_child_1",array("parent_id"=>$parent_id));
3790 }
3791 }
3792
3793 $this->db->trans_complete();
3794
3795 if ($this->db->trans_status() === FALSE)
3796 {
3797 echo json_encode(array('status'=>'0','message'=>$this->lang->line('database error. something went wrong.')));
3798 exit();
3799 }
3800 else
3801 {
3802 if(!file_exists($install_txt_path)) // putting install.txt
3803 fopen($install_txt_path, "w");
3804
3805 echo json_encode(array('status'=>'1','message'=>$this->lang->line('add-on has been deactivated successfully.')));
3806 }
3807 }
3808 catch(Exception $e)
3809 {
3810 $error = $e->getMessage();
3811 echo json_encode(array('status'=>'0','message'=>$this->lang->line($error)));
3812 }
3813 }
3814
3815 // deletes data from add_ons table + modules + menu + menuchild1 + custom sql + folder, returns json status,message
3816 protected function delete_addon($addon_controller_name="",$sql=array())
3817 {
3818 if($this->session->userdata('user_type') != 'Admin')
3819 {
3820 echo json_encode(array('status'=>'0','message'=>$this->lang->line('Access Forbidden')));
3821 exit();
3822 }
3823
3824 if($addon_controller_name=="")
3825 {
3826 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on controller has not been provided.')));
3827 exit();
3828 }
3829
3830 $path=APPPATH."modules/".strtolower($addon_controller_name)."/controllers/".$addon_controller_name.".php"; // path of addon controller
3831 $addon_path=APPPATH."modules/".strtolower($addon_controller_name); // path of module folder
3832 if(!file_exists($path))
3833 {
3834 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on controller not found.')));
3835 exit();
3836 }
3837
3838 $addon_data=$this->get_addon_data($path);
3839
3840 if(!isset($addon_data['unique_name']) || $addon_data['unique_name']=="")
3841 {
3842 echo json_encode(array('status'=>'0','message'=>$this->lang->line('add-on unique name has not been provided.')));
3843 exit();
3844 }
3845
3846
3847 try
3848 {
3849 $this->db->trans_start();
3850
3851 // delete addon table entry
3852 $get_addon=$this->basic->get_data("add_ons",array("where"=>array("unique_name"=>$addon_data['unique_name'])));
3853 $add_ons_id=isset($get_addon[0]['id']) ? $get_addon[0]['id'] : 0;
3854 $purchase_code=isset($get_addon[0]['purchase_code']) ? $get_addon[0]['purchase_code'] : '';
3855 if($add_ons_id>0)
3856 $this->basic->delete_data("add_ons",array("id"=>$add_ons_id));
3857
3858 // delete modules table entry
3859 if($add_ons_id>0)
3860 $this->basic->delete_data("modules",array("add_ons_id"=>$add_ons_id));
3861
3862 // delete menu+menu_child1 table entry
3863 $get_menu=array();
3864 if($add_ons_id>0)
3865 $get_menu=$this->basic->get_data("menu",array("where"=>array("add_ons_id"=>$add_ons_id)));
3866
3867 foreach($get_menu as $key => $value)
3868 {
3869 $parent_id=isset($value['id']) ? $value['id'] : 0;
3870 if($parent_id>0)
3871 {
3872 $this->basic->delete_data("menu",array("id"=>$parent_id));
3873 $this->basic->delete_data("menu_child_1",array("parent_id"=>$parent_id));
3874 }
3875 }
3876
3877 $this->db->trans_complete();
3878
3879 if ($this->db->trans_status() === FALSE)
3880 {
3881 echo json_encode(array('status'=>'0','message'=>$this->lang->line('database error. something went wrong.')));
3882 exit();
3883 }
3884 else
3885 {
3886 //--------Custom SQL------------
3887 $this->db->db_debug = FALSE; //disable debugging for queries
3888 if(is_array($sql))
3889 foreach ($sql as $key => $query)
3890 {
3891 try
3892 {
3893 $this->db->query($query);
3894 }
3895 catch(Exception $e)
3896 {
3897 }
3898 }
3899 //--------Custom SQL------------
3900
3901 $this->delete_directory($addon_path); // deleting module folder
3902
3903 // deleting purchase code from database
3904 if($purchase_code!="")
3905 {
3906 $item_name=strtolower($addon_controller_name);
3907 $only_domain=get_domain_only(site_url());
3908 $url = "http://xeroneit.net/development/envato_license_activation/delete_purchase_code.php?purchase_code={$purchase_code}&domain={$only_domain}&item_name=FBInboxer-{$item_name}";
3909 $credentials = $this->get_general_content_with_checking($url);
3910 $response = json_decode($credentials,true);
3911 if(isset($response['error']))
3912 {
3913 $url = "http://getbddoctor.com/secure/envato_credential_check/delete_purchase_code.php?purchase_code={$purchase_code}&domain={$only_domain}&item_name=FBInboxer-{$item_name}";
3914 $this->get_general_content_with_checking($url);
3915 }
3916 }
3917 // deleting purchase code from database
3918
3919 echo json_encode(array('status'=>'1','message'=>$this->lang->line('add-on has been deleted successfully.')));
3920 }
3921 }
3922 catch(Exception $e)
3923 {
3924 $error = $e->getMessage();
3925 echo json_encode(array('status'=>'0','message'=>$this->lang->line($error)));
3926 }
3927 }
3928
3929
3930 // check a addon or module id is usable or already used, returns boolean, true if unique
3931 protected function is_unique_check($type='addon_check',$value="") // type=addon_check/module_check | $value=column.value
3932 {
3933 $is_unique=false;
3934 if($type=="addon_check") $is_unique=$this->basic->is_unique("add_ons",array("unique_name"=>$value),"id");
3935 if($type=="module_check") $is_unique=$this->basic->is_unique("modules",array("id"=>$value),"id");
3936 return $is_unique;
3937 }
3938
3939 /*
3940 *********************************************************************************
3941 *******************************ADD ON FUNCTIONS END******************************
3942 */
3943
3944
3945 public function privacy_policy()
3946 {
3947 $data['title'] = 'Privacy Policy';
3948 $this->load->view('front/privacy_policy',$data);
3949 }
3950
3951 public function terms_use()
3952 {
3953 $data['title'] = 'Terms of Use';
3954 $this->load->view('front/terms_use',$data);
3955 }
3956
3957 public function gdpr()
3958 {
3959 $data['title'] = 'GDPR';
3960 $this->load->view('front/gdpr',$data);
3961 }
3962
3963 public function allow_cookie()
3964 {
3965 $this->session->set_userdata('allow_cookie','yes');
3966 redirect($_SERVER['HTTP_REFERER'],'location');
3967 }
3968
3969
3970 public function delete_full_access()
3971 {
3972 if($this->session->userdata('user_type') == 'Admin') exit();
3973 if(!isset($_POST)) exit();
3974 $user_id=$this->session->userdata('user_id');
3975
3976 $this->db->trans_start();
3977 $sql = "show tables;";
3978 $a = $this->basic->execute_query($sql);
3979 foreach($a as $value)
3980 {
3981 foreach($value as $table_name)
3982 {
3983 if($table_name == 'users') $this->basic->delete_data('users',array('id'=>$user_id));
3984 if($table_name == 'view_usage_log') continue;
3985 if($this->db->field_exists('user_id',$table_name))
3986 $this->basic->delete_data($table_name,array('user_id'=>$user_id));
3987 }
3988 }
3989 $this->db->trans_complete();
3990
3991 if ($this->db->trans_status() === FALSE)
3992 {
3993 echo $this->lang->line('Something went wrong, please try again.');
3994 }
3995 else
3996 {
3997 $this->session->sess_destroy();
3998 echo 'success';
3999 }
4000
4001 }
4002
4003
4004
4005
4006 function scanAll($myDir){
4007
4008 $dirTree = array();
4009 $di = new RecursiveDirectoryIterator($myDir,RecursiveDirectoryIterator::SKIP_DOTS);
4010
4011 foreach (new RecursiveIteratorIterator($di) as $filename) {
4012
4013 $dir = str_replace($myDir, '', dirname($filename));
4014 //$dir = str_replace('/', '>', substr($dir,1));
4015
4016 $org_dir=str_replace("\\", "/", $dir);
4017
4018
4019 if($org_dir)
4020 $file_path = $org_dir. "/". basename($filename);
4021 else
4022 $file_path = basename($filename);
4023 $dirTree[] = $file_path;
4024
4025 }
4026
4027 return $dirTree;
4028
4029 }
4030
4031 public function lang_scanAll($myDir)
4032 {
4033 $dirTree = array();
4034 $di = new RecursiveDirectoryIterator($myDir,RecursiveDirectoryIterator::SKIP_DOTS);
4035
4036 $i=0;
4037 foreach (new RecursiveIteratorIterator($di) as $filename) {
4038
4039 $dir = str_replace($myDir, '', dirname($filename));
4040 // $dir = str_replace('/', '>', substr($dir,1));
4041
4042 $org_dir=str_replace("\\", "/", $dir);
4043
4044 if($org_dir)
4045 $file_path = $org_dir. "/". basename($filename);
4046 else
4047 $file_path = basename($filename);
4048
4049 $file_full_path=$myDir."/".$file_path;
4050 $file_size= filesize($file_full_path);
4051 $file_modification_time=filemtime($file_full_path);
4052
4053 $dirTree[$i]['file'] = $file_full_path;
4054 $i++;
4055 }
4056 return $dirTree;
4057 }
4058
4059
4060
4061 function translation($is_addon=FALSE,$add_on_name='commenttagmachine'){ /*add-on_name must be the same as folder name of inside modules*/
4062
4063 if(!$is_addon){
4064
4065 $folder_path="application/controllers/";
4066 $all_directory1= $this->scanAll($folder_path);
4067
4068 $folder_path="application/libraries/";
4069 $all_directory2= $this->scanAll($folder_path);
4070
4071 $folder_path="application/views/";
4072 $all_directory3= $this->scanAll($folder_path);
4073
4074 $all_directory=array_merge($all_directory1,$all_directory2,$all_directory3);
4075
4076 $language_app_path=APPPATH;
4077
4078 }
4079
4080 if($is_addon){
4081
4082 $folder_path="application/modules/{$add_on_name}/";
4083 $all_directory= $this->scanAll($folder_path);
4084
4085 $language_app_path=APPPATH."/modules/{$add_on_name}";
4086 }
4087
4088 $all_lang=array();
4089
4090 foreach($all_directory as $dir){
4091
4092 $content=file_get_contents($dir);
4093 preg_match_all('#\$this->lang->line\("(.*?)"\)#si', $content, $matches);
4094
4095 foreach($matches[1] as $line){
4096 $all_lang[]=strtolower($line);
4097 }
4098
4099 preg_match_all('#\$this->lang->line\(\'(.*?)\'\)#si', $content, $matches1);
4100
4101 foreach($matches1[1] as $line){
4102 $all_lang[]=strtolower($line);
4103 }
4104
4105 }
4106
4107 /*** Get all existing language from language folder ***/
4108
4109
4110 $language_name_array=array("english","bengali","dutch","french","german","greek","italian","portuguese","russian","spanish","turkish","vietnamese");
4111
4112
4113 foreach($language_name_array as $language_name){
4114
4115 $this->lang->is_loaded = array();
4116 $this->lang->language = array();
4117
4118 $path=str_replace('\\', '/', $language_app_path.'/language/'.$language_name);
4119
4120
4121 $files=$this->lang_scanAll($path);
4122 foreach ($files as $key2 => $value2)
4123 {
4124 $current_file=isset($value2['file']) ? str_replace('\\', '/', $value2['file']) : ""; //application/modules/addon_folder/language/language_folder/someting_lang.php
4125 if($current_file=="" || !is_file($current_file)) continue;
4126 $current_file_explode=explode('/',$current_file);
4127 $filename=array_pop($current_file_explode);
4128 $pos=strpos($filename,'_lang.php');
4129 if($pos!==false) // check if it is a lang file or not
4130 {
4131 $filename=str_replace('_lang.php', '', $filename);
4132 $this->lang->load($filename, $language_name);
4133 }
4134 }
4135
4136
4137 $all_lang_prev_array=$this->lang->language;
4138
4139 $all_lang_prev_array=array_change_key_case($all_lang_prev_array, CASE_LOWER);
4140
4141 foreach($all_lang as $lang_index){
4142
4143 if(isset($all_lang_prev_array[$lang_index]))
4144 $now_all_write_lang[$lang_index]=$all_lang_prev_array[$lang_index];
4145 else
4146 $now_all_write_lang[$lang_index]="";
4147 }
4148
4149
4150 /** Language that's exist but not found in current code **/
4151
4152 $extra_lang= array_diff($all_lang_prev_array,$now_all_write_lang);
4153
4154 $now_all_write_lang_merge = array_merge($now_all_write_lang, $extra_lang);
4155
4156 asort($now_all_write_lang_merge);
4157
4158 $lang_write_file=$path."/all_lang.php";
4159
4160 /** Keep a backup for all_lang.php **/
4161 if(file_exists($lang_write_file)){
4162 $date=date("Y-m-d H-i-s");
4163 $write_path="backup_lang/{$language_name}/all_lang_{$date}.php";
4164 // copy($lang_write_file,$write_path);
4165 }
4166
4167 file_put_contents($lang_write_file, '<?php $lang = ' . var_export($now_all_write_lang_merge, true) . ';');
4168
4169
4170 $new_lang= array_diff($now_all_write_lang_merge,$all_lang_prev_array);
4171
4172 echo $language_name.": New Line added : ". count($new_lang)."<br>";
4173
4174 /* echo "<pre>";
4175 print_r($new_lang);*/
4176
4177 }
4178
4179
4180 }
4181
4182
4183
4184}