Beispiel #1
0
/**
 * Output Javascript into the header of the page
 *
 * This should be the first asset loaded to reduce loading time.
 */
function head_js()
{
    if (is_user_logged_in() || is_main_domain()) {
        return;
    }
    $args = array('host' => $_SERVER['HTTP_HOST'], 'back' => set_url_scheme('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), 'site' => get_current_blog_id());
    $args['nonce'] = create_shared_nonce('mercator-sso|' . $args['site'] . '|' . $args['host'] . '|' . $args['back']);
    $script_url = get_action_url(ACTION_JS, $args);
    ?>
	<script src="<?php 
    echo esc_url($script_url);
    ?>
"></script>
	<script type="text/javascript">
		/* <![CDATA[ */
			if ( 'function' === typeof MercatorSSO ) {
				document.cookie = "<?php 
    echo esc_js(TEST_COOKIE);
    ?>
=WP Cookie check; path=/";
				if ( document.cookie.match( /(;|^)\s*<?php 
    echo esc_js(TEST_COOKIE);
    ?>
\=/ ) ) {
					MercatorSSO();
				}
			}
		/* ]]> */
	</script>
<?php 
}
Beispiel #2
0
 } elseif (isset($page['first_item']) and $row['id'] == $page['first_item']) {
     $i = 'first';
 } elseif (isset($page['last_item']) and $row['id'] == $page['last_item']) {
     $i = 'last';
 } else {
     $i = 'current';
 }
 $row['src_image'] = new SrcImage($row);
 $row['derivatives'] = DerivativeImage::get_all($row['src_image']);
 if ($i == 'current') {
     $row['element_path'] = get_element_path($row);
     if ($row['src_image']->is_original()) {
         // we have a photo
         if ($user['enabled_high'] == 'true') {
             $row['element_url'] = $row['src_image']->get_url();
             $row['download_url'] = get_action_url($row['id'], 'e', true);
         }
     } else {
         // not a pic - need download link
         $row['download_url'] = $row['element_url'] = get_element_url($row);
     }
 }
 $row['url'] = duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start'));
 $picture[$i] = $row;
 $picture[$i]['TITLE'] = render_element_name($row);
 $picture[$i]['TITLE_ESC'] = str_replace('"', '&quot;', $picture[$i]['TITLE']);
 if ('previous' == $i and $page['previous_item'] == $page['first_item']) {
     $picture['first'] = $picture[$i];
 }
 if ('next' == $i and $page['next_item'] == $page['last_item']) {
     $picture['last'] = $picture[$i];
/**
 * Event handler to protect element urls.
 *
 * @param string $url
 * @param array $infos id, path
 * @return string
 */
function get_element_url_protection_handler($url, $infos)
{
    global $conf;
    if ('images' == $conf['original_url_protection']) {
        // protect only images and not other file types (for example large movies that we don't want to send through our file proxy)
        $ext = get_extension($infos['path']);
        if (!in_array($ext, $conf['picture_ext'])) {
            return $url;
        }
    }
    return get_action_url($infos['id'], 'e', false);
}
Beispiel #4
0
function get_login_url($path)
{
    return get_action_url($path, 'login');
}