public static function parseURI($uri, $validate = false, $default = null) { // Return the URI if it's an URI instance already if ($uri instanceof URI) { return $uri; } // Parse the URI, and make sure it's valid $parsed = parse_url($uri); if ($parsed === false) { return $default; } // Parse the user info $userInfo = null; if (isset($parsed['user']) || isset($parsed['pass'])) { $userInfo = new URIUserInfo(@$parsed['user'], @$parsed['pass']); } // Parse the URI $uri = new URI(@$parsed['scheme'], @$parsed['host'], @$parsed['port'], $userInfo, @$parsed['path'], @$parsed['query'], @$parsed['fragment']); // Make sure the URI is valid if ($validate) { if (!$uri->isValid()) { return $default; } } // Return the parsed URI return $uri; }
/** * Show invite only page if enabled */ public function login() { $uri = new URI(); // Redirect to invite page if not logged or signing in if (!in_array($uri->string(), array('invite', 'sign/in')) && strpos($uri->string(), 'sign/up') !== 0 && !Visitor::instance()->logged_in()) { // Stop execution if ajax, ie. expired session and trying to do ajax call if (request::is_ajax()) { exit; } url::redirect('invite'); } }
/** * Инлексная страница */ public function action_index() { // Если была отправлена форма фильтрации или сортировка if (\Input::method() == 'POST') { $category_id = (int) \Input::post('category_id'); if ($category_id > 0) { \Session::set('filter_articles_category_id', $category_id); } else { \Session::set('filter_articles_category_id', null); } $title = trim(\Input::post('title')); \Session::set('filter_articles_title', $title); // Сортировка \Session::set('admin_articles_order_by', \Input::post('order_by', 'id')); \Session::set('admin_articles_order_method', \Input::post('order_method', 'desc')); } // Запрос на извлечение кол-ва статей $count = \Model_Article::get_articles_count(\Session::get('filter_articles_title'), \Session::get('filter_articles_category_id')); // Пагинация $config = array('pagination_url' => \URI::create('admin/articles/index'), 'total_items' => $count, 'per_page' => 15, 'uri_segment' => 4); $pagination = \Pagination::forge('articles_pagination', $config); $data['pagination'] = $pagination->render(); // Передаём в представление данные пагинации (для нумерации статей) $data['current_page'] = is_null($pagination->current_page) ? 1 : $pagination->current_page; $data['per_page'] = $pagination->per_page; // Получение статей $data['articles'] = \Model_Article::get_articles(\Session::get('filter_articles_title'), \Session::get('filter_articles_category_id'), $pagination->per_page, $pagination->offset, \Session::get('admin_articles_order_by', 'id'), \Session::get('admin_articles_order_method', 'desc')); // Категории статей $data['categories'] = \Model_Category::get_categories_for_select(); $this->template->title = "Статьи"; $this->template->content = \View::forge('articles/index', $data, false); }
public function __construct() { parent::__construct(); $this->breadcrumb->add('Bewertungen', URI::build('airlines/admin/evals')); $this->breadcrumb->add('Kategorien', URI::build('airlines/admin/categories')); $this->breadcrumb->add('Felder', URI::build('airlines/admin/cfields')); }
/** * Hook to prepare the database connection. Performs 2 tasks. * 1) Initialises the search path, unless configured not to do this (e.g. if this is set at db level). * 2) If this is a report request, sets the connection to read only. */ public static function prepare_connection() { $uri = URI::instance(); // we havent to proceed futher if a setup call was made if ($uri->segment(1) == 'setup_check') { return; } // continue to init the system // // add schema to the search path // $_schema = Kohana::config('database.default.schema'); $query = ''; if (!empty($_schema) && kohana::config('indicia.apply_schema') !== false) { $query = "SET search_path TO {$_schema}, public, pg_catalog;\n"; } // Force a read only connection for reporting. if ($uri->segment(1) == 'services' && $uri->segment(2) == 'report') { $query .= "SET default_transaction_read_only TO true;\n"; } if (!empty($query)) { $db = Database::instance(); $db->query($query); } }
static function cache_file($f) { $css_file = Misc::key('css', $f) . '.css'; $cache_file = Cache::cache_filename($css_file); $cache_path = ROOT_PATH . PUBLIC_BASE . $cache_file; $version = (int) Config::get('page.css_version'); if (Config::get('debug.css_check_cache')) { if (file_exists($cache_path)) { $files = array_unique(explode(' ', $f)); $mtime = 0; foreach ($files as $file) { $file = trim($file); list($category, $file) = explode(':', $file, 2); if (!$file) { $file = $category; $category = NULL; } if (!$file) { continue; } $path = Core::file_exists(PRIVATE_BASE . 'css/' . $file . '.css', $category); if ($path) { $mtime = max($mtime, filemtime($path)); } } if ($mtime <= filemtime($cache_path)) { return $cache_file . '?v=' . $version; } } } elseif (file_exists($cache_path)) { return $cache_file . '?v=' . $version; } return URI::url('css', array('f' => $f, 'v' => $version)); }
public static function getInstance() { if (is_null(self::$_instance) || isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
public function __toString() { /** * poa = product options atributes */ // echo Kohana::debug(@$_POST); $opa = new fpp_product_has_attributes_product_Model(); $orm = $opa->db2cls(); $uri = URI::Instance(); $id = (int) $uri->segment("edit"); if (request::method() == 'post' and is_array(@$_POST['opt'])) { $orm->delete(array('product_id_product' => $id)); foreach ($_POST['opt'] as $key => $value) { $orm = $opa->db2cls(); $data['product_id_product'] = $id; // $data['ap_id_attributes_product'] = @$_POST['atr'][$key]; $data['prefix'] = @$_POST['prefix'][$key]; $data['vap_id_values_atributtes_product'] = @$_POST['opt'][$key]; $data['value'] = @$_POST['val'][$key]; $data['extra'] = @$_POST['extra'][$key]; $orm->set_fields($data); $orm->save(); } } $results = $this->GetAttr($id); // fetch_where(array('product_id_product'=> ) ); $atr_p = new fpp_attributes_product_Model(); $orm_atrp = $atr_p->db2cls(); $attributes = form::dropdown("poa_id", $orm_atrp->select_list('id_attributes_product', 'name_attributes_product')); $string = View::factory("extras/ajaxattributes")->set("attributes", $attributes)->set("results", $results)->render(); return $string; }
function get_list($gid) { $data = array('action' => 'list', 'name' => $this->name, 'role' => User::instance()->get_role()); Event::run('steamcore.aclcheck', $data); // which model are we using? one passed through or the default? $model = steamcore::get_controls_model($this->gallery); $controller = URI::segment(1); $tdata = array(); $page = Input::instance()->get('page', 0); $num = 18; $offset = 0; $limit = 18; if ($page) { $offset = $num * $page - $num; } $where = array(); if (isset($gid) and is_numeric($gid)) { $where = array('galleries_id' => $gid); } // query the model $data['query'] = $model->where($where)->limit($limit, $offset)->find_all(); $data['controller'] = $controller; $total = $model->count_last_query(); $data['pagination'] = ''; if ($total > $num) { $data['pagination'] = Pagination::factory(array('style' => 'digg', 'items_per_page' => $num, 'query_string' => 'page', 'total_items' => $total)); } // merge any passed data and the data returned from the model $tdata = array_merge($tdata, $data); // return the result return $tdata; }
private function sendEmail($xml) { try { $emailConf = Config::get('email'); $mail = new PHPMailer(); $mail->isSMTP(); $mail->CharSet = $emailConf['charset']; $mail->Host = $emailConf['host']; $mail->SMTPAuth = $emailConf['auth']; $mail->Username = $emailConf['username']; $mail->Password = $emailConf['password']; $mail->Port = $emailConf['port']; $mail->From = $emailConf['from']; $mail->FromName = $emailConf['from_name']; $mail->Subject = 'Falha na integração'; $mail->Body = "Ocorreu erro na integração de dados com Vtex." . "\r\n" . "\r\n"; $mail->Body .= "Ambiente: " . (Config::get('development') === true ? 'Desenvolvimento' : 'Produção') . "\r\n" . "\r\n"; $mail->Body .= "URL Segments: " . json_encode(URI::get_segments()) . "\r\n" . "\r\n"; $mail->Body .= "POST: " . print_r($_POST, true) . "\r\n" . "\r\n"; $mail->Body .= "Response Header: " . self::$responseHeader . "\r\n" . "\r\n"; $mail->Body .= 'Saída do script: ' . $xml; $mail->addAddress($emailConf['address']); $mail->isHTML(false); $mail->send(); return true; } catch (Exception $e) { return false; } }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $category = Util::getMediaWikiNamespace($this->language, MW_CATEGORY_NAMESPACE); if (preg_match_all("/" . $category . ":(.*)/", $pageID, $match)) { $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_PREFLABEL, false), RDFtriple::Literal($this->decode_title($pageTitle), NULL, $this->language)); $result->addTriple($this->getPageURI(), RDFtriple::URI(RDF_TYPE, false), RDFtriple::URI(SKOS_CONCEPT, false)); if (preg_match_all("/\\[\\[" . $category . ":(.*)\\]\\]/", $pageSource, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // split on | sign if (strpos($match[1], '|') === false) { $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($match[1]); } else { $split = explode('|', $match[1]); $object = Util::getDBpediaCategoryPrefix($this->language) . URI::wikipediaEncode($split[0]); } try { $object = RDFtriple::URI($object); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; continue; } $result->addTriple($this->getPageURI(), RDFtriple::URI(SKOS_BROADER, false), $object); } } } return $result; }
/** * Loads URI, and Input into this controller. * * @return void */ public function __construct() { if (Kohana::$instance == NULL) { // Set the instance to the first controller loaded Kohana::$instance = $this; } // URI should always be available $this->uri = URI::instance(); // Input should always be available $this->input = Input::instance(); $this->db = new Database(); $this->user_model = ORM::factory('user'); $this->supplier_model = ORM::factory('supplier'); $this->category_model = ORM::factory('category'); $this->item_model = ORM::factory('item'); $this->item_stock_model = ORM::factory('item_stock'); $this->district_model = ORM::factory('district'); $this->office_model = ORM::factory('office'); $this->budget_model = ORM::factory('office_budget'); $this->purchase_model = ORM::factory('purchase'); $this->request_model = ORM::factory('request'); $this->transaction_model = ORM::factory('transaction'); $this->setting_model = ORM::factory('setting'); $this->log_model = ORM::factory('log'); $this->email_model = ORM::factory('email'); }
public function post_pricing_view() { $price = QuotationPriceAdjustments::find(URI::Segment(4)); $update_layout = array('friendly_name' => trim(Input::get('friendly_name')), 'note' => trim(Input::get('note'))); $price->update($price->id, $update_layout); return Redirect::to('/user/quotations/pricing_view/' . $price->id)->with('success', 'Update successfull'); }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, $this->getExtractorID()); $image_ar = $this->extract_image_url($pageSource); $image = ucfirst($image_ar[0]); $width = $image_ar[1]; if ($image == null) { return $result; } $ImageURL = $this->make_image_url($image, false, true); $ImageURLSmall = $this->make_image_url($image, $width); $image = str_replace(" ", "_", trim($image)); if (!URI::validate($ImageURL) || !URI::validate($ImageURLSmall)) { return $result; } // Add fullsize image $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(FOAF_DEPICTION), RDFtriple::URI($ImageURL)); // Add depiction has thumbnail $result->addTriple(RDFtriple::URI($ImageURL), RDFtriple::URI(FOAF_THUMBNAIL), RDFtriple::URI($ImageURLSmall)); // Add object has thumbnail $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI(DBO_THUMBNAIL), RDFtriple::URI($ImageURLSmall)); // add triples linking back to the Wikipedia image description $image = urlencode($image); $wikipediaImageDescription = 'http://' . $this->language . '.wikipedia.org/wiki/Image:' . $image; $result->addTriple(RDFtriple::URI($ImageURLSmall), RDFtriple::URI(DC_RIGHTS), RDFtriple::URI($wikipediaImageDescription)); $result->addTriple(RDFtriple::URI($ImageURL), RDFtriple::URI(DC_RIGHTS), RDFtriple::URI($wikipediaImageDescription)); return $result; }
public function main() { $page = Request::get(0, VAR_URI); if (preg_match('/^(\\d+)-/', $page, $matches) > 0 && !empty($matches[1])) { $airlineData = new CustomData($this->airlinePage->getPosition()); if ($airlineData->load($matches[1])) { $uri = AirlineTools::buildUri($airlineData->getId(), $airlineData->getData('name'), true); $this->flightPage->setBaseUri($uri); $this->breadcrumb->add($airlineData->getData('name'), URI::build($uri)); $flight = Request::get(1, VAR_INT); if (is_id($flight)) { $this->flight($flight); } else { $this->airline($matches[1]); } } else { $this->header(); $this->notFoundError(); $this->footer(); } } else { $this->header(); $this->airlinePage->overview('/Airlines/categories'); $this->footer(); } }
public static function load($group, $save = true) { $paths = array(); $paths[] = J_PATH . "config" . DS . $group . EXT; $paths[] = J_PATH . "config" . DS . strtolower(Request::env()) . DS . $group . EXT; if (URI::isManager()) { $paths[] = J_MANAGERPATH . DS . "config" . DS . $group . EXT; $paths[] = J_MANAGERPATH . DS . "config" . DS . strtolower(Request::env()) . DS . $group . EXT; } else { $paths[] = J_APPPATH . "config" . DS . $group . EXT; $paths[] = J_APPPATH . "config" . DS . strtolower(Request::env()) . DS . $group . EXT; } $items = array(); foreach ($paths as $path) { if (file_exists($path)) { $result = (require $path); if (is_array($result)) { $items = array_merge($items, $result); } } } if (count($items) > 0) { if ($save) { static::$items[$group] = $items; } return $items; } }
public function renderContent($template = 'content', $return = false) { switch (URI::getURI()) { case '': $template = 'content'; break; case 'messages': $template = 'messages'; break; case 'friends': $template = 'friends'; break; case 'groups': $template = 'groups'; break; case 'settings': $template = 'settings'; break; case '?logout': $template = 'register'; break; default: $template = 'page404'; } if ($return) { return $this->render($template, true); } else { echo $this->render($template, true); } }
public function redirect() { $uri = URI::instance()->string(); $routed_uri = false; $bounces = Kohana::config('redirect_301'); if (is_null(Router::$controller) and is_array($bounces)) { foreach ($bounces as $key => $val) { // Trim slashes $key = trim($key, '/'); $val = trim($val, '/'); if (preg_match('#^' . $key . '$#u', $uri)) { if (strpos($val, '$') !== FALSE) { // Use regex routing $routed_uri = preg_replace('#^' . $key . '$#u', $val, $uri); } else { // Standard routing $routed_uri = $val; } // A valid route has been found break; } } } if ($routed_uri !== false) { url::redirect($routed_uri, '301'); } }
public function get_requestDetailinfo() { $data['claimID'] = $claimID = URI::segment(5); $data['app'] = $claimApp = Claims_App::appInfo($claimID); $data['detailList'] = Claims_App::listDetailsHistory($claimID); return View::make('claims.request.inforequestdetails', $data); }
public function __construct() { $this->filter('before', array('admin')); $this->filter('before', array('valid_page'))->except(array('index', 'create')); if (is_numeric(URI::Segment(4))) { $this->page_id = URI::Segment(4); } }
private function parse($page) { // URI conversion, example: [@uri:/cms/contact] $page = preg_replace_callback('~\\[@uri:([^]]+)\\]~i', function ($m) { return URI::build($m[1]); }, $page); return $page; }
public function extractPage($pageID, $pageTitle, $pageSource) { $result = new ExtractionResult($pageID, $this->language, self::extractorID); if ($this->language == "en") { $result->addTriple(RDFtriple::page($pageID), RDFtriple::URI("http://xmlns.com/foaf/0.1/page"), RDFtriple::URI("http://wikicompany.org/wiki/" . URI::wikipediaEncode($pageTitle))); } return $result; }
protected function makeResponse($response, $internal = true) { if ($this->isServer and ($response === false or $response === E_UNAUTH) and !$this->user(false)) { return Redirect::to(route('vanemart::login') . '?back=' . urlencode(\URI::full()))->with('passthru', 1); } else { return parent::makeResponse($response, $internal); } }
public function container() { $id = URI::instance()->segment(3, false); $p = ORM::factory('plugin_instance', $id); if ($p->loaded) { echo PluginManager::instance()->get_plugin($p)->render(); } }
public static function jsonToData($object) { $isJson = Uteis::isJson($object); if ($isJson === false) { Handler::error('Falha na integração: Formato json inválido ' . json_encode(URI::get_segments())); } return json_decode($object); }
/** * If not in the setup pages, but the indicia config file is missing, go to system setup. */ public static function _setup_check() { $uri = URI::instance(); $isOk = $uri->segment(1) == 'setup' || $uri->segment(1) == 'setup_check' || kohana::config('indicia.private_key', false, false) !== null; if (!$isOk) { url::redirect('setup_check'); } }
function error_404() { if (Kohana::$instance == NULL) { Kohana::$instance = new Errors_Controller(); } Kohana::log('error', 'Error 404 (steam.core.hooks): ' . URI::instance()->string()); Kohana::show_404(null, 'common/error_404'); }
/** * @throws SystemException */ public function __construct() { $this->uri = URI::create(); $path = $this->uri->getPath(); if (strpos($path, E()->getSiteManager()->getCurrentSite()->root) !== false) { $path = array_values(array_diff(explode('/', substr($path, strlen(E()->getSiteManager()->getCurrentSite()->root))), array(''))); } else { $path = array(); } try { $language = E()->getLanguage(); $this->lang = isset($path[0]) && $language->isValidLangAbbr($path[0]) ? array_shift($path) : ''; } catch (SystemException $e) { $this->lang = ''; } $this->path = $path; }
/** * Returns the root URL of the project. If addManager = false, don't append 'manager/' if we are calling this function from a manager route. * @param boolean $addManager * @return string */ public static function root($addManager = true) { $root = Request::rootURL(); if ($addManager && URI::isManager()) { $root .= "manager/"; } return $root; }
private static function _init() { self::$objs['benchmark'] = new benchmark(); self::$objs['config'] = new Config(); self::$objs['lang'] = new Lang(); self::$objs['uri'] = URI::getInstance(); self::$objs['view'] = new View(); }