/** * Constructor * * @access public * @return void **/ public function __construct() { $this->_ci =& get_instance(); // -------------------------------------------------------------------------- // Default vars $this->_access_token = ''; $this->api_endpoint = 'https://api.linkedin.com/'; // -------------------------------------------------------------------------- // Fetch our config variables $this->_ci->config->load('linkedin'); $this->_settings = $this->_ci->config->item('linkedin'); // Fetch our config variables $this->_settings = array(); $this->_settings['api_key'] = app_setting('social_signin_li_app_key'); $this->_settings['api_secret'] = app_setting('social_signin_li_app_secret'); if ($this->_settings['api_secret']) { $this->_settings['api_secret'] = $this->_ci->encrypt->decode($this->_settings['api_secret'], APP_PRIVATE_KEY); } // Sanity check if (!$this->_settings['api_key'] || !$this->_settings['api_secret']) { if (ENVIRONMENT === 'production') { show_fatal_error('LinkedIn has not been configured correctly', 'The LinkedIn App ID and secret must be specified in Admin under Site Settings.'); } else { show_error('The LinkedIn App ID and secret must be specified in Admin under Site Settings.'); } } }
/** * Constructor * * @access public * @return void **/ public function __construct() { $this->_ci = get_instance(); // -------------------------------------------------------------------------- // Fetch our config variables $this->_settings = array(); $this->_settings['appId'] = app_setting('social_signin_fb_app_id'); $this->_settings['secret'] = app_setting('social_signin_fb_app_secret'); $this->_settings['scope'] = app_setting('social_signin_fb_app_scope'); if (!is_array($this->_settings['scope'])) { $this->_settings['scope'] = (array) $this->_settings['scope']; } if ($this->_settings['secret']) { $this->_settings['secret'] = $this->_ci->encrypt->decode($this->_settings['secret'], APP_PRIVATE_KEY); } // Add the email scope array_unshift($this->_settings['scope'], 'email'); $this->_settings['scope'] = array_filter($this->_settings['scope']); $this->_settings['scope'] = array_unique($this->_settings['scope']); // Sanity check if (!$this->_settings['appId'] || !$this->_settings['secret']) { if (ENVIRONMENT === 'production') { show_fatal_error('Facebook has not been configured correctly', 'The Facebook App ID and secret must be specified in Admin under Site Settings.'); } else { show_error('The Facebook App ID and secret must be specified in Admin under Site Settings.'); } } // -------------------------------------------------------------------------- // Fire up and initialize the SDK $this->_facebook = new Facebook($this->_settings); }
public function get_default_group() { $_data['where'] = array(); $_data['where'][] = array('column' => 'is_default', 'value' => TRUE); $_group = $this->get_all(NULL, NULL, $_data); if (!$_group) { show_fatal_error('No Default Group Set', 'A default user group must be set.'); } $this->_default_group = $_group[0]; return $this->_default_group; }
public function __construct() { parent::__construct(); // -------------------------------------------------------------------------- // Check this module is enabled in settings if (!module_is_enabled('shop')) { // Cancel execution, module isn't enabled show_404(); } // -------------------------------------------------------------------------- // Load language file $this->lang->load('shop'); // -------------------------------------------------------------------------- // Load the models $this->load->model('shop/shop_model'); $this->load->model('shop/shop_basket_model'); $this->load->model('shop/shop_brand_model'); $this->load->model('shop/shop_category_model'); $this->load->model('shop/shop_collection_model'); $this->load->model('shop/shop_currency_model'); $this->load->model('shop/shop_order_model'); $this->load->model('shop/shop_product_model'); $this->load->model('shop/shop_product_type_model'); $this->load->model('shop/shop_range_model'); $this->load->model('shop/shop_shipping_model'); $this->load->model('shop/shop_sale_model'); $this->load->model('shop/shop_tag_model'); $this->load->model('shop/shop_voucher_model'); $this->load->model('shop/shop_skin_model'); // -------------------------------------------------------------------------- // Load up the shop's skin $_skin = app_setting('skin', 'shop') ? app_setting('skin', 'shop') : 'getting-started'; $this->_skin = $this->shop_skin_model->get($_skin); if (!$this->_skin) { show_fatal_error('Failed to load shop skin "' . $_skin . '"', 'Shop skin "' . $_skin . '" failed to load at ' . APP_NAME . ', the following reason was given: ' . $this->shop_skin_model->last_error()); } // -------------------------------------------------------------------------- // Pass to $this->data, for the views $this->data['skin'] = $this->_skin; // -------------------------------------------------------------------------- // Shop's name $this->_shop_name = app_setting('name', 'shop') ? app_setting('name', 'shop') : 'Shop'; }
public function __construct() { parent::__construct(); // -------------------------------------------------------------------------- // Check this module is enabled in settings if (!module_is_enabled('blog')) { // Cancel execution, module isn't enabled show_404(); } // -------------------------------------------------------------------------- // Load language file $this->lang->load('blog/blog'); // -------------------------------------------------------------------------- // Load the models $this->load->model('blog/blog_model'); $this->load->model('blog/blog_post_model'); $this->load->model('blog/blog_widget_model'); $this->load->model('blog/blog_skin_model'); // -------------------------------------------------------------------------- if (app_setting('categories_enabled', 'blog')) { $this->load->model('blog/blog_category_model'); } if (app_setting('tags_enabled', 'blog')) { $this->load->model('blog/blog_tag_model'); } // -------------------------------------------------------------------------- // Load up the blog's skin $_skin = app_setting('skin', 'blog') ? app_setting('skin', 'blog') : 'getting-started'; $this->_skin = $this->blog_skin_model->get($_skin); if (!$this->_skin) { show_fatal_error('Failed to load blog skin "' . $_skin . '"', 'Blog skin "' . $_skin . '" failed to load at ' . APP_NAME . ', the following reason was given: ' . $this->blog_skin_model->last_error()); } // -------------------------------------------------------------------------- // Pass to $this->data, for the views $this->data['skin'] = $this->_skin; // -------------------------------------------------------------------------- // Blog name $this->_blog_name = app_setting('name', 'blog') ? app_setting('name', 'blog') : 'Blog'; }
/** * Constructor * * @access public * @return void **/ public function __construct() { $this->_ci =& get_instance(); // -------------------------------------------------------------------------- // Fetch our config variables $this->_settings = array(); $this->_settings['consumer_key'] = app_setting('social_signin_fb_app_id'); $this->_settings['consumer_secret'] = app_setting('social_signin_fb_app_secret'); if ($this->_settings['consumer_secret']) { $this->_settings['consumer_secret'] = $this->_ci->encrypt->decode($this->_settings['consumer_secret'], APP_PRIVATE_KEY); } // Sanity check if (!$this->_settings['consumer_key'] || !$this->_settings['consumer_secret']) { if (ENVIRONMENT === 'production') { show_fatal_error('Twitter has not been configured correctly', 'The Twitter App ID and secret must be specified in Admin under Site Settings.'); } else { show_error('The Twitter App ID and secret must be specified in Admin under Site Settings.'); } } // -------------------------------------------------------------------------- // Fire up and initialize the SDK Codebird\Codebird::setConsumerKey($this->_settings['consumer_key'], $this->_settings['consumer_secret']); $this->_twitter = new Codebird\Codebird(); }
public function _remap() { if ($this->config->item('auth_two_factor_enable')) { $_return_to = $this->input->get('return_to', TRUE); $_remember = $this->input->get('remember', TRUE); $_user_id = $this->uri->segment(3); $_user = $this->user_model->get_by_id($_user_id); if (!$_user) { $this->session->set_flashdata('error', lang('auth_twofactor_token_unverified')); if ($_return_to) { redirect('auth/login?return_to=' . $_return_to); return; } else { redirect('auth/login'); return; } } $_salt = $this->uri->segment(4); $_token = $this->uri->segment(5); $_ip = $this->input->ip_address(); $_login_method = $this->uri->segment(6) ? $this->uri->segment(6) : 'native'; // Safety first switch ($_login_method) { case 'facebook': case 'twitter': case 'linkedin': case 'native': // All good, homies. break; default: $_login_method = 'native'; break; } if ($this->auth_model->verify_two_factor_token($_user->id, $_salt, $_token, $_ip)) { // Token is valid, generate a new one for the next request $this->data['token'] = $this->auth_model->generate_two_factor_token($_user->id); // Set data for the views $this->data['user_id'] = $_user->id; $this->data['login_method'] = $_login_method; $this->data['return_to'] = $_return_to; $this->data['remember'] = $_remember; if ($this->input->post('answer')) { // Validate the answer, if correct then log user in and forward, if not // then generate a new token and show errors $this->data['question'] = $this->user_model->get_security_question($_user->id); $_valid = $this->user_model->validate_security_answer($this->data['question']->id, $_user->id, $this->input->post('answer')); if ($_valid) { // Set login data for this user $this->user_model->set_login_data($_user->id); // If we're remembering this user set a cookie if ($_remember) { $this->user_model->set_remember_cookie($_user->id, $_user->password, $_user->email); } // Update their last login and increment their login count $this->user_model->update_last_login($_user->id); // -------------------------------------------------------------------------- // Generate an event for this log in create_event('did_log_in', $_user->id, 0, NULL, array('method' => $_login_method)); // -------------------------------------------------------------------------- // Say hello if ($_user->last_login) { $this->load->helper('date'); $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($_user->last_login)) : user_datetime($_user->last_login); if ($this->config->item('auth_show_last_ip_on_login')) { $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($_user->first_name, $_last_login, $_user->last_ip))); } else { $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($_user->first_name, $_last_login))); } } else { $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($_user->first_name))); } // -------------------------------------------------------------------------- // Delete the token we generated, its no needed, eh! $this->auth_model->delete_two_factor_token($this->data['token']['id']); // -------------------------------------------------------------------------- $_redirect = $_return_to != site_url() ? $_return_to : $_user->group_homepage; redirect($_redirect); return; } else { $this->data['error'] = lang('auth_twofactor_answer_incorrect'); // Ask away cap'n! $this->data['page']->title = lang('auth_twofactor_answer_title'); $this->load->view('structure/header', $this->data); $this->load->view('auth/security_question/ask', $this->data); $this->load->view('structure/footer', $this->data); } } else { // Determine whether the user has any security questions set $this->data['question'] = $this->user_model->get_security_question($_user->id); if ($this->data['question']) { // Ask away cap'n! $this->data['page']->title = 'Security Question'; $this->load->view('structure/header', $this->data); $this->load->view('auth/security_question/ask', $this->data); $this->load->view('structure/footer', $this->data); } else { // Auth config stuffz $this->data['questions'] = $this->config->item('auth_two_factor_questions'); $this->data['num_questions'] = count($this->data['questions']) < $this->config->item('auth_two_factor_num_questions') ? count($this->data['questions']) : $this->config->item('auth_two_factor_num_questions'); $this->data['num_custom_questions'] = $this->config->item('auth_two_factor_num_custom_question'); if ($this->data['num_questions'] + $this->data['num_custom_questions'] <= 0) { show_fatal_error('Two-factor auth is enabled, but no questions available', 'A user tried to set security questions but there are no questions available for them to choose. Please ensure auth.php is configured correctly.'); } if ($this->input->post()) { $this->load->library('form_validation'); for ($i = 0; $i < $this->data['num_questions']; $i++) { $this->form_validation->set_rules('question[' . $i . '][question]', '', 'xss_clean|required|is_natural_no_zero'); $this->form_validation->set_rules('question[' . $i . '][answer]', '', 'xss_clean|trim|required'); } for ($i = 0; $i < $this->data['num_custom_questions']; $i++) { $this->form_validation->set_rules('custom_question[' . $i . '][question]', '', 'xss_clean|trim|required'); $this->form_validation->set_rules('custom_question[' . $i . '][answer]', '', 'xss_clean|trim|required'); } $this->form_validation->set_message('required', lang('fv_required')); $this->form_validation->set_message('is_natural_no_zero', lang('fv_required')); if ($this->form_validation->run()) { // Make sure that we have different questions $_question_index = array(); $_question = (array) $this->input->post('question'); $_error = FALSE; foreach ($_question as $q) { if (array_search($q['question'], $_question_index) === FALSE) { $_question_index[] = $q['question']; } else { $_error = TRUE; break; } } $_question_index = array(); $_question = (array) $this->input->post('custom_question'); foreach ($_question as $q) { if (array_search($q['question'], $_question_index) === FALSE) { $_question_index[] = $q['question']; } else { $_error = TRUE; break; } } if (!$_error) { // Good arrows. Save questions $_data = array(); if ($this->input->post('question')) { foreach ($this->input->post('question') as $q) { $_temp = new stdClass(); $_temp->question = isset($this->data['questions'][$q['question'] - 1]) ? $this->data['questions'][$q['question'] - 1] : NULL; $_temp->answer = $q['answer']; $_data[] = $_temp; } } if ($this->input->post('custom_question')) { foreach ((array) $this->input->post('custom_question') as $q) { $_temp = new stdClass(); $_temp->question = trim($q['question']); $_temp->answer = $q['answer']; $_data[] = $_temp; } } if ($this->user_model->set_security_questions($_user->id, $_data)) { // Set login data for this user $this->user_model->set_login_data($_user->id); // If we're remembering this user set a cookie if ($_remember) { $this->user_model->set_remember_cookie($_user->id, $_user->password, $_user->email); } // Update their last login and increment their login count $this->user_model->update_last_login($_user->id); // -------------------------------------------------------------------------- // Generate an event for this log in create_event('did_log_in', $_user->id, 0, NULL, array('method' => $_login_method)); // -------------------------------------------------------------------------- // Say hello if ($_user->last_login) { $this->load->helper('date'); $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($_user->last_login)) : user_datetime($_user->last_login); if ($this->config->item('auth_show_last_ip_on_login')) { $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($_user->first_name, $_last_login, $_user->last_ip))); } else { $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($_user->first_name, $_last_login))); } } else { $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($_user->first_name))); } // -------------------------------------------------------------------------- // Delete the token we generated, its no needed, eh! $this->auth_model->delete_two_factor_token($this->data['token']['id']); // -------------------------------------------------------------------------- $_redirect = $_return_to != site_url() ? $_return_to : $_user->group_homepage; redirect($_redirect); return; } else { $this->data['error'] = lang('auth_twofactor_question_set_fail') . ' ' . $this->user_model->last_error(); } } else { $this->data['error'] = lang('auth_twofactor_question_unique'); } } else { $this->data['error'] = lang('fv_there_were_errors'); } } // No questions, request they set them $this->data['page']->title = lang('auth_twofactor_question_set_title'); $this->load->view('structure/header', $this->data); $this->load->view('auth/security_question/set', $this->data); $this->load->view('structure/footer', $this->data); } } } else { $this->session->set_flashdata('error', lang('auth_twofactor_token_unverified')); $_query = array(); $_query['return_to'] = $_return_to; $_query['remember'] = $_remember; $_query = array_filter($_query); if ($_query) { $_query = '?' . http_build_query($_query); } else { $_query = ''; } redirect('auth/login' . $_query); } } else { show_404(); } }
protected function _instantiate_languages() { // Define default language $_default = $this->language_model->get_default(); if (empty($_default)) { show_fatal_error('No default language has been set, or it\'s been set incorrectly.'); } define('APP_DEFAULT_LANG_CODE', $_default->code); define('APP_DEFAULT_LANG_LABEL', $_default->label); // -------------------------------------------------------------------------- // Set any global preferences for this user, e.g languages, fall back to // the app's default language (defined in config.php). $_user_lang = active_user('language'); if (!empty($_user_lang)) { define('RENDER_LANG_CODE', $_user_lang); } else { define('RENDER_LANG_CODE', APP_DEFAULT_LANG_CODE); } // Set the language config item which codeigniter will use. $this->config->set_item('language', RENDER_LANG_CODE); // Load the Nails. generic lang file $this->lang->load('nails'); }
/** * Update a user's access token and log them in to the app * * @access public * @param object $access_token The user's access token * @return void **/ protected function _login_user($access_token, $user) { // Load the auth lang file $this->lang->load('auth', 'english'); // -------------------------------------------------------------------------- // Check if the user is suspended. if ($user->is_suspended) { $this->session->set_flashdata('error', lang('auth_login_fail_suspended')); $this->_redirect($this->_return_to_fail); return; } // -------------------------------------------------------------------------- // Update token $_data['li_token'] = $access_token->access_token; $this->user_model->update($user->id, $_data); // -------------------------------------------------------------------------- // Two factor auth enabled? if ($this->config->item('auth_two_factor_enable')) { // Generate a token $this->load->model('auth_model'); $_token = $this->auth_model->generate_two_factor_token($user->id); if (!$_token) { show_fatal_error('Failed to generate two-factor auth token', 'A user tried to login with LinkedIn and the system failed to generate a two-factor auth token.'); } $_query = array(); $_query['return_to'] = $this->_return_to; $_query = array_filter($_query); if ($_query) { $_query = '?' . http_build_query($_query); } else { $_query = ''; } redirect('auth/security_questions/' . $user->id . '/' . $_token['salt'] . '/' . $_token['token'] . '/linkedin' . $_query); } else { // Set login details $this->user_model->set_login_data($user->id); // -------------------------------------------------------------------------- // Set welcome message if ($user->last_login) { $this->load->helper('date'); $_last_login = $this->config->item('auth_show_nicetime_on_login') ? nice_time(strtotime($user->last_login)) : user_datetime($user->last_login); if ($this->config->item('auth_show_last_ip_on_login')) { $this->session->set_flashdata('message', lang('auth_login_ok_welcome_with_ip', array($user->first_name, $_last_login, $user->last_ip))); } else { $this->session->set_flashdata('message', lang('auth_login_ok_welcome', array($user->first_name, $_last_login))); } } else { $this->session->set_flashdata('message', lang('auth_login_ok_welcome_notime', array($user->first_name))); } // -------------------------------------------------------------------------- // Update the last login $this->user_model->update_last_login($user->id); // -------------------------------------------------------------------------- // Create an event for this event create_event('did_log_in', $user->id, 0, NULL, array('method' => 'linkedin')); // -------------------------------------------------------------------------- // Delete register token delete_cookie('liRegisterToken'); // -------------------------------------------------------------------------- // If no return to value is defined, default to the group homepage if (!$this->_return_to) { $this->_return_to = $user->group_homepage; } } // -------------------------------------------------------------------------- // Redirect $this->_redirect($this->_return_to); return; }
function go() { //Объявляем глобальные переменные global $version_files; global $virtual_files; global $eol; global $store; //Задаем пути к директориям и сразу же проверяем $dir = correct_path("C:\\Temp"); $store = correct_path("C:\\Store"); if (!file_exists($dir)) { echo "Ошибка.{$eol}Директория-источник {$dir} не существует.{$eol}Подробнее смотрите файл " . __FILE__ . " строка " . __LINE__ . $eol . "Скрипт принудительно завершает работу."; exit; } if (!file_exists($store)) { echo "Ошибка.{$eol}Директория-хранилище {$store} не существует.{$eol}Подробнее смотрите файл " . __FILE__ . " строка " . __LINE__ . $eol . "Скрипт принудительно завершает работу."; exit; } /*Анализируем файл с информацией о копиях в хранилище*/ //1. Номер последней копии $main_info_file = $store . "store.info"; if (file_exists($main_info_file)) { if ($fp = fopen($main_info_file, 'r')) { $previous_copy_id = fgets($fp) + 0; fclose($fp); if (is_int($previous_copy_id)) { get_virtual_dir($previous_copy_id); $previous_version_files = $virtual_files; $previous_info_file = correct_path($store . "store." . $previous_copy_id) . "store." . $previous_copy_id . ".info"; if ($fp = fopen($previous_info_file, 'r')) { $current_copy_id = $previous_copy_id + 1; $lines = file($previous_info_file); foreach ($lines as $line_numFOR => $lineFOR) { $explodeFOR = explode("\t", $lineFOR); //show($explodeFOR); //$previous_version_files[tmlspecialchars($line) . "<br />\n"; } //show($previous_version_files); fclose($fp); } else { show_fatal_error("Невозможно открыть файл {$previous_info_file}", __FILE__, __LINE__); } } else { show_fatal_error("Главный информационный файл хранилища {$main_info_file} существует." . $eol . "Но первая строка данного файла не содержит целое число.", __FILE__, __LINE__); } } else { show_fatal_error("Не удается открыть главный информационный файл хранилища {$main_info_file}", __FILE__, __LINE__); } } else { $previous_version_files = array(); $current_copy_id = 0; } /*Получаем массив version_files*/ get_files_array($dir, $dir); //show($version_files); //show($virtual_files); /*Записываем информацию об измененных файлах*/ $current_store_dir = correct_path($store . "store." . $current_copy_id); $current_info_file = $current_store_dir . "store." . $current_copy_id . ".info"; $copy_info = get_changes($version_files, $previous_version_files, PHP_EOL); //Записываем информацию о текущей копии в главный информационный файл хранилища file_easy_write($main_info_file, $current_copy_id); if (!file_exists($current_store_dir)) { mkdir($current_store_dir); } file_easy_write($current_info_file, $copy_info); show_message("Создана версия №" . $current_copy_id); }