Example #1
0
function rmagic_init(&$a)
{
    if (local_channel()) {
        goaway(z_root());
    }
    $me = get_my_address();
    if ($me) {
        $r = q("select hubloc_url from hubloc where hubloc_addr = '%s' limit 1", dbesc($me));
        if ($r) {
            if ($r[0]['hubloc_url'] === z_root()) {
                goaway(z_root() . '/login');
            }
            $dest = z_root() . '/' . str_replace('zid=', 'zid_=', get_app()->query_string);
            goaway($r[0]['hubloc_url'] . '/magic' . '?f=&dest=' . $dest);
        }
    }
}
Example #2
0
/**
 * @brief Adds a zid parameter to a url.
 *
 * @param string $s
 *   The url to accept the zid
 * @param boolean $address
 *   $address to use instead of session environment
 * @return string
 *
 * @hooks 'zid'
 *      string url - url to accept zid
 *      string zid - urlencoded zid
 *      string result - the return string we calculated, change it if you want to return something else
 */
function zid($s, $address = '')
{
    if (!strlen($s) || strpos($s, 'zid=')) {
        return $s;
    }
    $has_params = strpos($s, '?') ? true : false;
    $num_slashes = substr_count($s, '/');
    if (!$has_params) {
        $has_params = strpos($s, '&') ? true : false;
    }
    $achar = strpos($s, '?') ? '&' : '?';
    $mine = get_my_url();
    $myaddr = $address ? $address : get_my_address();
    /** @FIXME checking against our own channel url is no longer reliable. We may have a lot
     * of urls attached to out channel. Should probably match against our site, since we
     * will not need to remote authenticate on our own site anyway.
     */
    if ($mine && $myaddr && !link_compare($mine, $s)) {
        $zurl = $s . ($num_slashes >= 3 ? '' : '/') . $achar . 'zid=' . urlencode($myaddr);
    } else {
        $zurl = $s;
    }
    $arr = array('url' => $s, 'zid' => urlencode($myaddr), 'result' => $zurl);
    call_hooks('zid', $arr);
    return $arr['result'];
}
Example #3
0
 function build_pagehead()
 {
     $user_scalable = local_channel() ? get_pconfig(local_channel(), 'system', 'user_scalable') : 1;
     if ($user_scalable === false) {
         $user_scalable = 1;
     }
     $interval = local_channel() ? get_pconfig(local_channel(), 'system', 'update_interval') : 80000;
     if ($interval < 10000) {
         $interval = 80000;
     }
     if (!x($this->page, 'title')) {
         $this->page['title'] = $this->config['system']['sitename'];
     }
     /* put the head template at the beginning of page['htmlhead']
      * since the code added by the modules frequently depends on it
      * being first
      */
     $tpl = get_markup_template('head.tpl');
     $this->page['htmlhead'] = replace_macros($tpl, array('$user_scalable' => $user_scalable, '$baseurl' => $this->get_baseurl(), '$local_channel' => local_channel(), '$generator' => PLATFORM_NAME . ' ' . RED_VERSION, '$update_interval' => $interval, '$icon' => head_get_icon(), '$head_css' => head_get_css(), '$head_js' => head_get_js(), '$js_strings' => js_strings(), '$zid' => get_my_address(), '$channel_id' => $this->profile['uid'])) . $this->page['htmlhead'];
     // always put main.js at the end
     $this->page['htmlhead'] .= head_get_main_js();
 }
Example #4
0
 public static function build_pagehead()
 {
     $user_scalable = local_channel() ? get_pconfig(local_channel(), 'system', 'user_scalable') : 1;
     if ($user_scalable === false) {
         $user_scalable = 1;
     }
     $preload_images = local_channel() ? get_pconfig(local_channel(), 'system', 'preload_images') : 0;
     if ($preload_images === false) {
         $preload_images = 0;
     }
     $interval = local_channel() ? get_pconfig(local_channel(), 'system', 'update_interval') : 80000;
     if ($interval < 10000) {
         $interval = 80000;
     }
     if (!x(self::$page, 'title')) {
         self::$page['title'] = self::$config['system']['sitename'];
     }
     if (!self::$meta->get_field('og:title')) {
         self::$meta->set('og:title', self::$page['title']);
     }
     self::$meta->set('generator', Zotlabs\Lib\System::get_platform_name());
     /* put the head template at the beginning of page['htmlhead']
      * since the code added by the modules frequently depends on it
      * being first
      */
     $tpl = get_markup_template('head.tpl');
     self::$page['htmlhead'] = replace_macros($tpl, array('$preload_images' => $preload_images, '$user_scalable' => $user_scalable, '$query' => urlencode(self::$query_string), '$baseurl' => self::get_baseurl(), '$local_channel' => local_channel(), '$metas' => self::$meta->get(), '$update_interval' => $interval, 'osearch' => sprintf(t('Search %1$s (%2$s)', 'opensearch'), Zotlabs\Lib\System::get_site_name(), t('$Projectname', 'opensearch')), '$icon' => head_get_icon(), '$head_css' => head_get_css(), '$head_js' => head_get_js(), '$js_strings' => js_strings(), '$zid' => get_my_address(), '$channel_id' => self::$profile['uid'])) . self::$page['htmlhead'];
     // always put main.js at the end
     self::$page['htmlhead'] .= head_get_main_js();
 }