/** * Logs one user on the admin panel * */ function login() { $default_admin_lang = Settings::get_default_admin_lang(); $uri_lang = Settings::get_uri_lang(); // If the user is already logged and if he is in the correct minimum group, go to Admin if ($this->connect->logged_in() && $this->connect->is('editors', true)) { redirect(base_url() . $uri_lang . '/' . config_item('admin_url')); } if (!empty($_POST)) { unset($_POST['submit']); if ($this->_try_validate_login()) { // Syntax talks from itself, isn't it? :) // The login method will check for a 'remember_me' value // If found it will remember the user until he log out. // Remember time is specified time in the access config file (default is 7 days) try { $this->connect->login($_POST); redirect(base_url() . $uri_lang . '/' . config_item('admin_url')); } catch (Exception $e) { $this->login_errors = $e->getMessage(); } } else { $this->login_errors = lang('ionize_login_error'); } } else { if (!in_array($uri_lang, Settings::get('displayed_admin_languages')) or $uri_lang == config_item('admin_uri')) { redirect(base_url() . $default_admin_lang . '/' . config_item('admin_url') . '/user/login'); } } $this->output('access/login'); }
function __construct() { $auth = Settings::get('auth'); if (isset($auth[$this->name])) { $this->settings = $auth[$this->name]; } }
public static function get_current_usage() { /* Permission check. */ if (Permission::has('operator_parking_usage')) { /* Select query. */ $select = Database::query("SELECT rc.type_card FROM parking AS p INNER JOIN rfid_card AS rc ON rc.id = p.rfid_id WHERE start_date IS NOT NULL AND end_date IS NULL"); /* Controleren of query is gelukt. */ if ($select) { /* Return array. */ $return = array(); /* Vul het aantal in. */ $return['aantal'] = array('totaal' => $select->num_rows, 'ad-hoc' => 0, 'subscription' => 0, 'guest' => 0); /* Loop elk item bij langs. */ while ($obj = $select->fetch_object()) { /* Tel de huidige kaart in de array op. */ $return['aantal'][strtolower($obj->type_card)]++; } /* Bereken procenten. */ $procent = $return['aantal']['totaal'] / Settings::get('citypark_parking_space') * 100; /* Vul procenten in. */ $return['procent'] = round($procent); /* Return de array als object. */ return (object) $return; } else { /* Foutmelding. */ throw new Exception('Er ging wat fout bij het berekenen van het parkeer verbruik.'); } } else { /* Geen rechten. */ throw new Exception('U heeft geen rechten om het parkeer verbruik te mogen zien.'); } }
private function watermark($data = array()) { $this->load->library('files/files'); $mark_text = isset($data['text']) ? $data['text'] : Settings::get('site_name'); $font_color = isset($data['font_color']) ? $data['font_color'] : 'ffffff'; $opacity = isset($data['opacity']) ? (int) $data['opacity'] : 100; $font_size = isset($data['font_size']) ? (int) $data['font_size'] : 12; $files = $data['files']; $font_path = './' . SHARED_ADDONPATH . 'modules/watermark/fonts/Gabrielle.ttf'; if (is_array($files) && count($files) > 0) { foreach ($files as $file) { $filedata = Files::get_file($file); if ($filedata['status'] === TRUE) { $dirpath = FCPATH . '/uploads/default/files/'; $source = $dirpath . $filedata['data']->filename; $imageLayer = ImageWorkshop::initFromPath($source); //var_dump($imageLayer);exit; $textLayer = ImageWorkshop::initTextLayer($mark_text, $font_path, $font_size, $font_color, $data['rotation']); $textLayer->opacity($opacity); $imageLayer->addLayerOnTop($textLayer, 12, 12, $data['position']); $image = $imageLayer->getResult(); $imageLayer->save($dirpath, $filedata['data']->filename, false, null, 100); $wm_data = array('file_id' => $filedata['data']->id, 'folder_id' => $filedata['data']->folder_id); $this->watermark_m->insert($wm_data); } } $this->session->set_flashdata('success', lang('watermark:submit_success')); redirect('admin/watermark'); } else { $this->session->set_flashdata('error', lang('watermark:no_files_remaining')); redirect('admin/watermark'); } }
/** * List all FAQs using Streams CP Driver * * @access public * @return void */ public function index() { $extra['title'] = lang('faq:faqs'); $extra['sorting'] = true; $extra['buttons'] = array(array('label' => lang('global:edit'), 'url' => 'admin/faq/edit/-entry_id-'), array('label' => lang('global:delete'), 'url' => 'admin/faq/delete/-entry_id-', 'confirm' => true)); $this->streams->cp->entries_table('faqs', 'faq', Settings::get('records_per_page'), 'admin/faq/index', true, $extra); }
function init() { $this->_helper->Init->init(); if (!$this->user->isLogged()) { Functions::redirect('//' . Settings::get('root_domain') . '/login/'); } }
/** * Saves one Page * * @param array Page data table * @param array Page Lang depending data table * * @return string The inserted / updated page ID * */ function save($data, $lang_data) { // Dates $data['publish_on'] = $data['publish_on'] ? getMysqlDatetime($data['publish_on'], Settings::get('date_format')) : '0000-00-00'; $data['publish_off'] = $data['publish_off'] ? getMysqlDatetime($data['publish_off'], Settings::get('date_format')) : '0000-00-00'; $data['logical_date'] = $data['logical_date'] ? getMysqlDatetime($data['logical_date'], Settings::get('date_format')) : '0000-00-00'; // Creation date if (!$data['id_page'] or $data['id_page'] == '') { $data['created'] = date('Y-m-d H:i:s'); } else { $data['updated'] = date('Y-m-d H:i:s'); } // Be sure URLs are unique $this->set_unique_urls($lang_data, $data['id_page']); // Clean metas data foreach ($lang_data as $lang => $row) { foreach ($row as $key => $value) { if ($key == 'meta_description') { $lang_data[$lang][$key] = preg_replace('[\\"]', '', $value); } if ($key == 'meta_keywords') { $lang_data[$lang][$key] = preg_replace('/[\\"\\.;]/i ', '', $value); } } } // Base model save method call return parent::save($data, $lang_data); }
function __construct($user) { $this->settings = Settings::get($this->user['database'])->toArray(); $this->shipment = new ShipOnline($this->settings['shiponline']['user'], $this->settings['shiponline']['password'], $this->settings['shiponline']['token']); $this->carrier = 'UPS'; // fix me }
/** * @since 2.3 * * @return PropertyTableInfoFetcher */ public function newPropertyTableInfoFetcher() { $propertyTableInfoFetcher = new PropertyTableInfoFetcher(); $propertyTableInfoFetcher->setCustomFixedPropertyList($this->settings->get('smwgFixedProperties')); $propertyTableInfoFetcher->setCustomSpecialPropertyList($this->settings->get('smwgPageSpecialProperties')); return $propertyTableInfoFetcher; }
public function get_ionize_notifications() { if ($this->notification_model->should_refresh()) { $this->load->library('curl'); $this->curl->option(CURLOPT_USERAGENT, $this->input->user_agent()); $this->curl->option(CURLOPT_RETURNTRANSFER, TRUE); $h = $this->input->request_headers(); $h = array_change_key_case($h); $headers = array('X-source: ionize', 'X-version: ' . Settings::get('ionize_version'), 'X-host: ' . (isset($h['host']) ? $h['host'] : '')); if (!empty($h['accept-language'])) { $headers[] = 'accept-language:' . $h['accept-language']; } $this->curl->option(CURLOPT_HTTPHEADER, $headers); $result = $this->curl->simple_get('http://ionizecms.com/ionize_notification'); $result = json_decode($result, TRUE); $this->notification_model->set_refreshed(); if (!empty($result)) { if (!empty($result['version'])) { $this->notification_model->set_last_version($result['version']); } if (!empty($result['notifications'])) { $this->notification_model->update_ionize_notifications($result['notifications']); } $this->xhr_output($result); } else { $this->xhr_output(array()); } } else { $result = $this->notification_model->get_networked_ionize_notifications(); $this->xhr_output($result); } }
public static function getSiteName() { if ($name = Settings::get('site', 'name')) { return $name; } return Yii::app()->name; }
public function __construct() { parent::__construct(); $this->_table = 'choices'; $this->primary_key = 'id'; $this->site_lang = Settings::get('site_lang'); }
/** * Logs one user on the admin panel * */ function login() { $default_admin_lang = Settings::get_default_admin_lang(); $uri_lang = Settings::get_uri_lang(); // If the user is already logged and if he is in the correct minimum group, go to Admin if ($this->connect->logged_in() && $this->connect->is('editors', true)) { redirect(base_url() . $uri_lang . '/' . config_item('admin_url')); } if (!empty($_POST)) { unset($_POST['submit']); if ($this->_try_validate_login()) { // User can log with email OR username if (strpos($_POST['username'], '@') !== FALSE) { $email = $_POST['username']; unset($_POST['username']); $_POST['email'] = $email; } try { $this->connect->login($_POST); redirect(base_url() . $uri_lang . '/' . config_item('admin_url')); } catch (Exception $e) { $this->login_errors = $e->getMessage(); } } else { $this->login_errors = lang('ionize_login_error'); } } else { if (!in_array($uri_lang, Settings::get('displayed_admin_languages')) or $uri_lang != $default_admin_lang) { redirect(base_url() . $default_admin_lang . '/' . config_item('admin_url') . '/user/login'); } } $this->output('access/login'); }
public function get($id_media) { // Pictures data from database $picture = $id_media ? $this->media_model->get($id_media) : FALSE; $options = $this->uri->uri_to_assoc(); unset($options['get']); if (empty($options['size'])) { $options['size'] = 120; } // Path to the picture if ($picture && file_exists($picture_path = DOCPATH . $picture['path'])) { $thumb_path = DOCPATH . Settings::get('files_path') . str_replace(Settings::get('files_path') . '/', '/.thumbs/', $picture['base_path']); $thumb_file_path = $this->medias->get_thumb_file_path($picture, $options); $refresh = !empty($options['refresh']) ? TRUE : FALSE; // If no thumb, try to create it if (!file_exists($thumb_file_path) or $refresh === TRUE) { try { $thumb_file_path = $this->medias->create_thumb(DOCPATH . $picture['path'], $thumb_file_path, $options); } catch (Exception $e) { // $return_thumb_path = FCPATH.'themes/'.Settings::get('theme_admin').'/styles/'.Settings::get('backend_ui_style').'/images/icon_48_no_folder_rights.png'; } } $mime = get_mime_by_extension($thumb_file_path); $content = read_file($thumb_file_path); $this->push_thumb($content, $mime, 0); } else { $mime = 'image/png'; $content = read_file(FCPATH . 'themes/' . Settings::get('theme_admin') . '/styles/' . Settings::get('backend_ui_style') . '/images/icon_48_no_source_picture.png'); $this->push_thumb($content, $mime, 0); } }
/** * Check that the API is enabled */ public function early_checks() { if (!Settings::get('api_enabled')) { $this->response(array('status' => false, 'error' => 'This API is currently disabled.'), 505); exit; } }
/** * Constructor method * * @return void */ public function __construct($config = array()) { parent::__construct($config); //set mail protocol $config['protocol'] = Settings::get('mail_protocol'); //set a few config items (duh) $config['mailtype'] = "html"; $config['charset'] = "utf-8"; $config['crlf'] = Settings::get('mail_line_endings') ? "\r\n" : PHP_EOL; $config['newline'] = Settings::get('mail_line_endings') ? "\r\n" : PHP_EOL; //sendmail options if (Settings::get('mail_protocol') == 'sendmail') { if (Settings::get('mail_sendmail_path') == '') { //set a default $config['mailpath'] = '/usr/sbin/sendmail'; } else { $config['mailpath'] = Settings::get('mail_sendmail_path'); } } //smtp options if (Settings::get('mail_protocol') == 'smtp') { $config['smtp_host'] = Settings::get('mail_smtp_host'); $config['smtp_user'] = Settings::get('mail_smtp_user'); $config['smtp_pass'] = Settings::get('mail_smtp_pass'); $config['smtp_port'] = Settings::get('mail_smtp_port'); } $this->initialize($config); }
private function view($username = null) { switch (Settings::get('profile_visibility')) { case 'public': // if it's public then we don't care about anything break; case 'owner': // they have to be logged in so we know if they're the owner $this->current_user or redirect('users/login/users/view/' . $username); // do we have a match? $this->current_user->username !== $udsername and redirect('404'); break; case 'hidden': // if it's hidden then nobody gets it redirect('404'); break; case 'member': // anybody can see it if they're logged in $this->current_user or redirect('users/login/users/view/' . $username); break; } // Don't make a 2nd db call if the user profile is the same as the logged in user if ($this->current_user && $username === $this->current_user->username) { $user = $this->current_user; } else { $user = $this->ion_auth->get_user($username); } // No user? Show a 404 error $user or show_404(); return; }
public function showMain() { $page = $this->node; $tree = Collector::get('root'); $subTree = Tree::getSubTree($tree, $page); $blocks = null; if ($subTree) { $blocks = $subTree->children; } foreach ($blocks as $index => $block) { $blocks[$block->slug] = $block; unset($blocks[$index]); } $allRates = Cache::tags('rates')->rememberForever('rates_' . App::getLocale(), function () { return Rates::orderPriority()->get(); }); $rates = array(); foreach ($allRates as $i => $rate) { if ($rate['type'] == 1) { $rates['departments'][] = $rate; } else { $rates['cards'][$rate['name_card']][] = $rate; } } $calculatorCredit = new CashCalculator(); // fixme: //$calculatorCredit->setMonthlyIncome(Settings::get('monthly_income_default', 0)); $calculatorCredit->setCreditAmount(Settings::get('credit_amount_default', 100000)); $calculatorCredit->setTerm(Settings::get('term_default', 3)); $calculationsCredit = $calculatorCredit->calculate(); return View::make('index', compact('page', 'blocks', 'rates', 'calculationsCredit')); }
public function actionUpdate($id) { $page = $this->loadModel($id); if (isset($_POST['Page'])) { if (Settings::get('SEO', 'slugs_enabled')) { if (isset($page->slug)) { if (isset($page->slug->slug) && $_POST['Page']['slug'] != $page->slug->slug) { if ($_POST['Page']['slug'] == '') { $page->slug->delete(); $page->slug = NULL; } else { $page->slug->change($_POST['Page']['slug']); } } } else { $page->slug = Slug::create($_POST['Page']['slug'], array('view', 'id' => $id)); $page->save(); } } try { if ($page->save()) { $this->redirect(array('view', 'id' => $page->id)); } } catch (Exception $e) { $page->addError('', $e->getMessage()); } } $this->render('update', array('page' => $page)); }
public function __construct() { $supported_lang = Settings::get('supported_languages'); $cufon_enabled = $supported_lang[CURRENT_LANGUAGE]['direction'] !== 'rtl'; $cufon_font = 'qk.font.js'; // Translators, only if the default font is incompatible with the chars of your // language generate a new font (link: <http://cufon.shoqolate.com/generate/>) and add // your case in switch bellow. Important: use a licensed font and harmonic with design switch (CURRENT_LANGUAGE) { case 'zh': $cufon_enabled = FALSE; break; case 'ar': $cufon_enabled = FALSE; break; case 'he': $cufon_enabled = TRUE; case 'ru': $cufon_font = 'times.font.js'; break; } Settings::set('theme_default', compact('cufon_enabled', 'cufon_font')); }
public function parseUrl($request) { if ($this->getUrlFormat() === self::PATH_FORMAT) { $rawPathInfo = $request->getPathInfo(); if (Settings::get('SEO', 'slugs_enabled') && ($p = Slug::getPath($rawPathInfo))) { $rawPathInfo = trim($p, '/'); Yii::app()->punish = 0; } $pathInfo = $this->removeUrlSuffix($rawPathInfo, $this->urlSuffix); foreach ($this->_rules as $i => $rule) { if (is_array($rule)) { $this->_rules[$i] = $rule = Yii::createComponent($rule); } if (($r = $rule->parseUrl($this, $request, $pathInfo, $rawPathInfo)) !== false) { return isset($_GET[$this->routeVar]) ? $_GET[$this->routeVar] : $r; } } if ($this->useStrictParsing) { throw new AweException(404, Yii::t('yii', 'Unable to resolve the request "{route}".', array('{route}' => $pathInfo))); } else { return $pathInfo; } } else { if (isset($_GET[$this->routeVar])) { return $_GET[$this->routeVar]; } else { if (isset($_POST[$this->routeVar])) { return $_POST[$this->routeVar]; } else { return ''; } } } }
function LoadGroups() { global $usergroups, $loguserid, $loguser, $loguserGroup, $loguserPermset; global $guestPerms, $guestGroup, $guestPermset; $guestGroup = $usergroups[Settings::get('defaultGroup')]; $res = Query("SELECT *, 1 ord FROM {permissions} WHERE applyto=0 AND id={0} AND perm IN ({1c})", $guestGroup['id'], $guestPerms); $guestPermset = LoadPermset($res); if (!$loguserid) { $loguserGroup = $guestGroup; $loguserPermset = $guestPermset; $loguser['banned'] = false; $loguser['root'] = false; return; } $secgroups = array(); $loguserGroup = $usergroups[$loguser['primarygroup']]; $res = Query("SELECT groupid FROM {secondarygroups} WHERE userid={0}", $loguserid); while ($sg = Fetch($res)) { $secgroups[] = $sg['groupid']; } $res = Query("\tSELECT *, 1 ord FROM {permissions} WHERE applyto=0 AND id={0}\n\t\t\t\t\tUNION SELECT *, 2 ord FROM {permissions} WHERE applyto=0 AND id IN ({1c})\n\t\t\t\t\tUNION SELECT *, 3 ord FROM {permissions} WHERE applyto=1 AND id={2}\n\t\t\t\t\tORDER BY ord", $loguserGroup['id'], $secgroups, $loguserid); $loguserPermset = LoadPermset($res); $maxrank = FetchResult("SELECT MAX(rank) FROM {usergroups}"); $loguser['banned'] = $loguserGroup['id'] == Settings::get('bannedGroup'); $loguser['root'] = $loguserGroup['id'] == Settings::get('rootGroup'); }
public static function login(array $arguments) { $db = self::_initDB(); unset($_SESSION['user']); $q = "SELECT `id`, `username`, `name`, `groups`, `settings` FROM `users` WHERE `username` = ? AND `password` = ? LIMIT 1;"; $a = array($arguments['username'], $arguments['password']); $response = false; if ($stmt = $db->prepare($q)) { $stmt->setFetchMode(PDO::FETCH_ASSOC); if ($stmt->execute($a)) { if ($row = $stmt->fetch()) { $response = array("userData" => array("id" => (int) $row['id'], "username" => $row['username'], "name" => $row['name'], "groups" => (array) json_decode($row['groups'])), "userSettings" => (array) json_decode($row['settings'])); if (!$response['userData']['groups']) { $response['userData']['groups'] = array(); } if (!$response['userSettings']) { $response['userSettings'] = null; } } else { throw new Exception("Invalid login credentials"); } } } if ($response) { $settings = Settings::get(); $user = APIUser::login($response["userData"]); $homedir = sprintf("%s/%s", $settings['vfs']['homes'], $user->getUsername()); if (!file_exists($homedir)) { @mkdir($homedir); @mkdir("{$homedir}/.packages"); } } return array(false, $response); }
public function index() { $per_page = Settings::get('records_per_page'); $offset = $this->uri->segment(3) ? $this->uri->segment(3) : 0; $this->db->where('status', 1); $num_rows = $this->db->get('videos')->num_rows(); $this->db->order_by('created_on', 'DESC'); $this->db->limit($per_page, $offset); $query = $this->db->get('videos'); $this->load->library('pagination'); $config['base_url'] = site_url('videos/page'); $config['total_rows'] = $num_rows; $config['per_page'] = $per_page; $config['uri_segment'] = 3; $config['num_links'] = 3; $config['full_tag_open'] = '<ul>'; $config['full_tag_close'] = '</ul>'; $config['cur_tag_open'] = '<li class="active"><span>'; $config['cur_tag_close'] = '</span></li>'; $config['first_tag_open'] = '<li>'; $config['first_tag_close'] = '</li>'; $config['last_tag_open'] = '<li>'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next ›'; $config['next_tag_open'] = '<li>'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '‹ Prev'; $config['prev_tag_open'] = '<li>'; $config['prev_tag_close'] = '</li>'; $config['num_tag_open'] = '<li>'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); foreach ($query->result() as $row) { $row->created_on = indonesian_date($row->created_on); $url = 'http://gdata.youtube.com/feeds/api/videos/' . trim($row->video_id) . '?v=2&alt=json'; $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); /* Get the HTML or whatever is linked in $url. */ $response = curl_exec($handle); /* Check for 404 (file not found). */ $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); if ($httpCode == 200) { $json_output = @file_get_contents($url); $json_data = json_decode($json_output, TRUE); $title = $json_data['entry']['title']['$t']; $thumb = 'http://img.youtube.com/vi/' . $row->video_id . '/2.jpg'; } else { $title = $row->title; $thumb = $this->image_m->resize(UPLOAD_PATH . 'no_image.jpg', 154, 110, 'crop'); } curl_close($handle); $row->title = $title; $row->url = site_url('videos/view/' . $this->core->encode($row->id)); $row->thumb = $thumb; } $data['data'] = $query->result(); $data['pagination'] = $this->pagination->create_links(); $this->template->title($this->module_details['name'])->set('videos', $data)->build('index', array('page' => array('title' => 'Video'))); }
public function __toString() { $out = "Record Factory: {\n"; $out .= "\tRecord Size: " . $this->settings->get("recordSize") . "\n"; $out .= "\tCompression: " . $this->settings->get("compression") . "\n"; $out .= "}"; return $out; }
/** * Pulls link arrays from settings * @return array */ public static function pullSavedLinks() { $link_array = \Settings::get('contact', 'social'); if (!empty($link_array)) { return unserialize($link_array); } return $link_array; }
public function __construct(array $attributes = array()) { parent::__construct($attributes); $this->type = 'sb_inet_equiring'; $this->setEmailFrom(Settings::get('email_from', '*****@*****.**')); $this->setEmailFromTitle(Settings::get('email_from_title', 'Альфа-банк')); $this->prepareEmails(Settings::get('email_apply_forms', '*****@*****.**')); }
public function __toString() { $out = "Record Factory: {\n"; $out .= "\tRecord Size: " . $this->settings->get('recordSize') . "\n"; $out .= "\tCompression: " . $this->settings->get('compression') . "\n"; $out .= '}'; return $out; }
public function should_refresh() { $last_refresh = Settings::get('last_notification_refresh'); if (empty($last_refresh) or dateDiff($last_refresh, NULL, 'day') > 0) { return TRUE; } return FALSE; }
function __construct($query) { $app = App::getInstance(); $this->db = $app['db']; $this->safesql = $app['safesql']; $this->pageSize = Settings::get('articles_per_search_page'); $this->query = $query; }