public function unserialize($config)
 {
     if (!is_array($config)) {
         return false;
     }
     $urls = new Urls();
     foreach ($config['URL'] as $key => $val) {
         $urls->addUrl($key, $val, $config['DIRECTORY'][$key]);
     }
     return $urls;
 }
 public function unserialize($xml)
 {
     $urls_xml = simplexml_load_string($xml);
     $urls = new Urls($urls);
     foreach ($urls_xml->{'url'} as $url_elem_xml) {
         $url_key = (string) $url_elem_xml['key'];
         $url_val = (string) $url_elem_xml->value;
         $url_directory = (string) $url_elem_xml->directory;
         $urls->addUrl($url_key, $url_val, $url_directory);
     }
     return $urls;
 }
 public function getHome()
 {
     Session::put('old_RequestSegment2', '');
     //is root?
     //if (Request::is('/') && Locale::countEnable() > 1) return Redirect::to('/' . App::getLocale(), 301);
     //is OnePage?
     if (Config::get('core::display.onepage')) {
         $data = array();
         $data['onepage'] = OnePage::first();
         return View::make('theme::public.onepage', $data);
     } else {
         //Find good page
         $urls = Urls::getRoutes();
         foreach ($urls as $url) {
             if ($url['url'] == '/' && $url['locale_id'] == App::getLocale()) {
                 $structure = Structure::where('i18n_url', $url['i18n_id'])->first();
                 if (!empty($structure)) {
                     if ($structure->structurable_type != 'OnePage') {
                         $page = $structure->structurable;
                         return View::make('pager::public.pages.page', compact('page'));
                     }
                 }
             }
         }
         return App::abort(404);
     }
 }
Exemple #4
0
 /**
  * Find AND Add
  * @param type $url
  * @return boolean|\Urls
  */
 public static function FAA($url)
 {
     $url = trim(htmlspecialchars_decode($url));
     if (!$url) {
         return false;
     }
     if (substr($url, -1) == '/') {
         $url = substr($url, 0, -1);
     }
     $hash = md5($url);
     $info = Urls::model()->find('hash=:hash', array(':hash' => $hash));
     if ($info) {
         return $info;
     }
     $code = '';
     $len = zmf::config('shortUrlsLen');
     $len = intval($len);
     if (!$len) {
         $len = 4;
     }
     for ($i = 0; $i < 10; $i++) {
         $code = tools::randMykeys($len);
         $codeInfo = Urls::model()->find('code=:code', array(':code' => $code));
         if (!$codeInfo) {
             break;
         }
     }
     if (!$code) {
         return false;
     }
     $attr = array('code' => $code, 'url' => $url, 'hash' => $hash);
     $model = new Urls();
     $model->attributes = $attr;
     if ($model->save()) {
         return $model;
     } else {
         return false;
     }
 }
<?php

require_once '__init__.php';
Rhaco::import('generic.Urls');
Rhaco::import('model.Todo');
Rhaco::import('model.Category');
$db = new DbUtil(Category::connection());
$patterns = array('^$' => array('class' => 'generic.Views', 'method' => 'read', 'args' => array(new Todo(), new C(Q::eq(Todo::columnClose(), false), Q::fact())), 'template' => 'list.html'), '^detail/(\\d+)$' => array('method' => 'detail', 'args' => array(new Todo(), new C(Q::fact()))), '^create$' => array('method' => 'create', 'args' => array(new Todo(), Rhaco::url())), '^update/(\\d+)$' => array('method' => 'update', 'args' => array(new Todo(), null, Rhaco::url())), '^delete/(\\d+)$' => array('method' => 'delete', 'args' => array(new Todo(), null, Rhaco::url())), '^cat/(\\d+)$' => array('method' => 'detail', 'args' => array(new Category(), new C(Q::depend()))));
$parser = Urls::parser($patterns, $db);
$parser->setVariable('categories', $db->select(new Category()));
$parser->write();
Exemple #6
0
 /**
  * Builds an standard Sifo url.
  *
  * @param string $hostname The hostname of the url to be built. Must be a key in the url.config.
  * @param string $controller The controller part of the url as defined in the router. Must be a key in the url.config.
  * @param array $actions An array of parameters that will be available in the $params['path_parts'] array.
  * @param array $params Url parameters that will be available in the $params['params'] array.
  * @return string A sifo url.
  */
 public static function buildUrl($hostname, $controller, array $actions = array(), array $params = array())
 {
     $url = Urls::getUrl($hostname) . '/';
     $callback = function ($a) {
         return urlencode($a);
     };
     $actions = array_map($callback, $actions);
     array_unshift($actions, Urls::getUrl($controller));
     $url .= implode(self::$url_definition['context_separator'], $actions);
     if (array() !== $params) {
         $url .= self::$url_definition['params_separator'];
     }
     $url .= implode(self::$url_definition['params_separator'], $params);
     return $url;
 }
Exemple #7
0
 public static function textUrl($link)
 {
     if (self::checkImg($link)) {
         return $link;
     }
     if (self::checkUrlDomain($link)) {
         return $link;
     }
     $info = Urls::FAA($link);
     if ($info) {
         return "[texturl={$info['code']}]{$info['code']}[/texturl]";
     } else {
         return $link;
     }
 }
function getTopResults($queries, $todown, $msnkey, $culture_info)
{
    // create list of URLs
    $allURLs = new Urls();
    $i = 0;
    foreach ($queries as $query) {
        $query = mb_ereg_replace("/[^\\w\\d]/g", "", $query);
        $query = "'" . trim($query) . "'";
        $i++;
        try {
            $searchres = fetchBingResults($query, $todown, $msnkey, $culture_info);
        } catch (Exception $e) {
            print_error("exception in querying MSN!\n");
        }
        foreach ($searchres as $hit) {
            $ahit = new oneUrl();
            $ahit->mainUrl = $hit;
            $ahit->queryID = md5($hit);
            $ahit->msUrl = $hit;
            $ahit->counter = 1;
            $allURLs->addUrl($ahit);
        }
        // end parsing results
    }
    // end sending queries: we have top x results
    return $allURLs->getMax($todown);
}
Exemple #9
0
 /**
  * Get metadata. It uses the metadata key or path to return the metadata.
  *
  * @return array
  */
 public static function get()
 {
     $metadata_info = self::_getMetadataInformation();
     $metadata_raw = Config::getInstance()->getConfig('lang/metadata_' . Domains::getInstance()->getLanguage());
     $metadata = $metadata_raw['default'];
     if (isset($metadata_info['metadata_key'])) {
         $metadata = $metadata_raw[$metadata_info['metadata_key']];
     } else {
         $reversal_path = Router::getReversalRoute(Urls::getInstance(Bootstrap::$instance)->getPath());
         if ($reversal_path && isset($metadata_raw[$reversal_path])) {
             $metadata = $metadata_raw[$reversal_path];
         }
     }
     return self::_replaceVars($metadata, $metadata_info);
 }
 private function getContextlyBaseUrl($page_type)
 {
     $url_params = array('type' => $page_type, 'blog_url' => site_url(), 'blog_title' => get_bloginfo("name"), 'cms_settings_page' => $this->getWPPluginSettingsUrl());
     // Get MAJOR.MINOR version for the Control Panel.
     $version = ContextlyWpKit::getInstance()->version();
     $verison_parsed = ContextlyWpKit::parseVersion($version);
     if ($verison_parsed) {
         $url_params['kit_version'] = $verison_parsed[0] . '.' . $verison_parsed[1];
     }
     return Urls::getMainServerUrl() . 'cms-redirect/?' . http_build_query($url_params, NULL, '&');
 }
Exemple #11
0
 public function getUrl($relative_path, $params = null)
 {
     $url = Urls::getInstance($this->instance)->getUrl($relative_path);
     if (!$url && '' != $relative_path) {
         /*
          * The relative_path exists but the first getUrl try not found it.
          * We try with the path translations:
          */
         if (Router::getReversalRoute($relative_path)) {
             if (!($url = Urls::getInstance($this->instance)->getUrl(Router::getReversalRoute($relative_path)))) {
                 // Fixed the current_url in url like word1_word2 for url word1-word2
                 $url = Urls::getInstance($this->instance)->getUrl(Router::getReversalRoute(str_replace('-', '_', $relative_path)));
             }
         } else {
             $url = Urls::$base_url . '/' . $relative_path;
         }
     }
     if ($params) {
         $url .= $this->url_definition['params_separator'];
         if (is_array($params)) {
             $url .= implode($this->url_definition['params_separator'], $params);
         } else {
             $url .= $params;
         }
     }
     return $url;
 }
Exemple #12
0
<?php

ob_start();
include "set.php";
?>

<?php 
if (isset($_POST['submit'])) {
    if ($_POST['url'] != "") {
        $name = $_POST['url'];
        $newurl = Urls::make($name);
        if ($newurl->save()) {
            $short = base62($newurl->get_id());
            $newurl->set_shorturl($short);
            $newurl->save();
            $status = 1;
        } else {
            $status = 0;
        }
    }
}
?>

<?php 
include $dir_public . 'add.php';
?>

 public function getPluginCss($css_name)
 {
     if (CONTEXTLY_MODE == Urls::MODE_LIVE) {
         return Urls::getPluginCdnUrl($css_name, 'css');
     } else {
         return plugins_url('css/' . $css_name, __FILE__);
     }
 }
Exemple #14
0
<?php

ob_start();
include "set.php";
?>

<?php 
if (isset($_GET['short'])) {
    $ob = Urls::find_by_shorturl($_GET['short']);
    if (!empty($ob)) {
        Header("Location: " . $ob->url);
    } else {
        echo "Invalid Short URL";
    }
}
?>

<?php 
include $dir_public . 'index.php';
?>

Exemple #15
0
 /**
  * Dispatches an error after an exception.
  *
  * @param Exception $e
  *
  * @return output buffer
  */
 private static function _dispatchErrorController($e)
 {
     if (!isset($e->http_code)) {
         $e->http_code = 503;
         $e->http_code_msg = 'Exception!';
         $e->redirect = false;
     }
     header('HTTP/1.0 ' . $e->http_code . ' ' . $e->http_code_msg);
     // Execute ErrorCommonController when an exception is captured.
     $ctrl2 = self::invokeController('error/common');
     // Set params:
     $ctrl2->addParams(array('code' => $e->http_code, 'code_msg' => $e->http_code_msg, 'msg' => $e->getMessage(), 'trace' => $e->getTraceAsString()));
     // All the SEO_Exceptions with need of redirection have this attribute:
     if ($e->redirect) {
         // Path is passed via message:
         $path = trim($e->getMessage(), '/');
         $new_location = '';
         // Check if the URL for the redirection has already a protocol, like http:// , https://, ftp://, etc..
         if (false !== strpos($path, '://')) {
             // Absolute path passed:
             $new_location = $path;
         } else {
             // Relative path passed, use path as the key in url.config.php file:
             $new_location = Urls::getUrl($path);
         }
         if (empty($new_location) || false == $new_location) {
             trigger_error("Exception " . $e->http_code . " raised with an empty location " . $e->getTraceAsString());
             header('HTTP/1.0 500 Internal Server Error');
             exit;
         }
         if (!Domains::getInstance()->getDebugMode()) {
             header("Location: " . $new_location, true, $e->http_code);
         } else {
             $ctrl2->addParams(array('url_redirect' => $new_location));
             $ctrl2->dispatch();
             self::invokeController('debug/index')->dispatch();
             return;
         }
     }
     $result = $ctrl2->dispatch();
     // Load the debug in case you have enabled the has debug flag.
     if (Domains::getInstance()->getDebugMode()) {
         self::invokeController('debug/index')->dispatch();
     }
     return $result;
 }
Exemple #16
0
<?php

ob_start();
include "set.php";
?>

<?php 
$domains = Urls::find_all();
?>

<?php 
include $dir_public . 'show.php';
?>