Example #1
0
File: view.php Project: rair/yacs
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Servers::get_url($item['id'])));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Servers::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the server profile
} else {
    $text = '';
    // initialize the rendering engine
    Codes::initialize(Servers::get_url($item['id']));
    // the nick name
    if ($item['host_name'] && Surfer::is_associate()) {
        $details[] = '"' . $item['host_name'] . '"';
    }
    // information on last update
    if ($item['edit_name']) {
        $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
    }
    // restricted to logged members
    if ($item['active'] == 'R') {
        $details[] = RESTRICTED_FLAG . i18n::s('Community - Access is granted to any identified surfer') . BR . "\n";
    } elseif ($item['active'] == 'N') {
        $details[] = PRIVATE_FLAG . i18n::s('Private - Access is restricted to selected persons') . BR . "\n";
    }
    // all details
Example #2
0
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!Articles::allow_access($item, $anchor)) {
    // give anonymous surfers a chance for HTTP authentication
    if (!Surfer::is_logged()) {
        Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"');
        Safe::header('Status: 401 Unauthorized', TRUE, 401);
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // describe the article
} else {
    // initialize the rendering engine
    Codes::initialize(Articles::get_permalink($item));
    // compute the url for this article
    $permanent_link = Articles::get_permalink($item);
    // the trackback link
    $trackback_link = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=article:' . $item['id'];
    // get a description -- render codes
    if (isset($item['introduction']) && $item['introduction']) {
        $description = Codes::beautify($item['introduction'], $item['options']);
    } else {
        $description = Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
    }
    // prepare the response
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" . '		   xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . '		   xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . '	<rdf:Description' . "\n" . '		trackback:ping="' . $trackback_link . '"' . "\n" . '		dc:identifier="' . $permanent_link . '"' . "\n" . '		rdf:about="' . $permanent_link . '">' . "\n" . '		<dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . '		<dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . '		<dc:creator>' . $item['create_name'] . '</dc:creator>' . "\n" . '		<dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . '		<dc:format>text/html</dc:format>' . "\n";
    if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
        $text .= '		<dc:language>' . $item['language'] . '</dc:language>' . "\n";
    }
Example #3
0
File: view.php Project: rair/yacs
// the title of the page
if ($item['geo_place_name']) {
    $context['page_title'] = $item['geo_place_name'];
}
// not found -- help web crawlers
if (!isset($item['id'])) {
    include '../error.php';
    // re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Locations::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the location full size
} else {
    // initialize the rendering engine
    Codes::initialize(Locations::get_url($item['id']));
    // insert anchor prefix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_prefix();
    }
    // geo position
    if ($item['geo_position']) {
        // a place holder for the dynamic map
        $context['text'] .= '<p>' . sprintf(i18n::s('Geographical coordinates: %s'), $item['geo_position']) . "</p>\n" . '<div id="map" style="border: 1px solid #979797; background-color: #e5e3df; width: 500px; height: 300px; margin-right: auto; margin-top: 2em; margin-bottom: 2em">' . "\n" . '	<div style="padding: 1em; color: gray">' . i18n::s('Loading...') . '</div>' . "\n" . '</div>' . "\n";
        // ensure we have split coordinates
        if (!$item['latitude'] || !$item['longitude']) {
            list($item['latitude'], $item['longitude']) = preg_split('/[\\s,;]+/', $item['geo_position']);
        }
        // link to anchor page
        $description = '';
        if ($anchor = Anchors::get($item['anchor'])) {
 /**
  * layout the newest articles
  *
  * caution: this function also updates page title directly, and this makes its call non-cacheable
  *
  * @param array the article
  * @return string the rendered text
  **/
 function layout_newest($item)
 {
     global $context;
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // the url to view this item
     $url = Articles::get_permalink($item);
     // reset the rendering engine between items
     Codes::initialize($url);
     // build a title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // title prefix & suffix
     $text = $prefix = $suffix = '';
     // flag articles updated recently
     if ($context['site_revisit_after'] < 1) {
         $context['site_revisit_after'] = 2;
     }
     $context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
     // link to permalink
     if (Surfer::is_empowered()) {
         $title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
     }
     // signal articles to be published
     if ($item['publish_date'] <= NULL_DATE) {
         $prefix .= DRAFT_FLAG;
     } else {
         if ($item['publish_date'] > NULL_DATE && $item['publish_date'] > $context['now']) {
             $prefix .= DRAFT_FLAG;
         }
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG . ' ';
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG . ' ';
     }
     // signal locked articles
     if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
         $suffix .= LOCKED_FLAG;
     }
     // flag expired article
     if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $suffix .= EXPIRED_FLAG;
     }
     // update page title directly
     $text .= Skin::build_block($prefix . $title . $suffix, 'title');
     // if this article has a specific icon, use it
     if ($item['icon_url']) {
         $icon = $item['icon_url'];
     } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
         $icon = $anchor->get_icon_url();
     }
     // if we have a valid image
     if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
         // fix relative path
         if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
             $icon = $context['url_to_root'] . $icon;
         }
         // flush the image on the right
         $text .= '<img src="' . $icon . '" class="right_image" alt="" />';
     }
     // article rating, if the anchor allows for it
     if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
         // report on current rating
         $label = '';
         if ($item['rating_count']) {
             $label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
         }
         $label .= i18n::s('Rate this page');
         // allow for rating
         $text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } else {
         $text .= Skin::build_block($item['introduction'], 'introduction');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('view', $item);
     }
     // the beautified description, which is the actual page body
     if ($item['description']) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $text .= Skin::build_block($label, 'title');
         }
         $text .= Skin::build_block($item['description'], 'description', '', $item['options']);
     }
     //
     // list related files
     //
     // if this surfer is an editor of this article, show hidden files as well
     if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
         Surfer::empower();
     }
     // build a complete box
     $box['bar'] = array();
     $box['text'] = '';
     // count the number of files in this article
     if ($count = Files::count_for_anchor('article:' . $item['id'])) {
         if ($count > 20) {
             $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
         }
         // list files by date (default) or by title (option files_by_title)
         if (Articles::has_option('files_by', $anchor, $item) == 'title') {
             $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         } else {
             $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         }
         if (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         }
         // navigation commands for files
         $prefix = Articles::get_url($item['id'], 'navigate', 'files');
         $box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0);
         // the command to post a new file, if allowed
         if (Files::allow_creation($item, $anchor, 'article')) {
             $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             $box['bar'] += array($link => i18n::s('Add a file'));
         }
         if (is_array($box['bar'])) {
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
     }
     // actually render the html for this box
     if ($box['text']) {
         $text .= Skin::build_box(i18n::s('Files'), $box['text'], 'header1', 'files');
     }
     //
     // bottom page menu
     //
     // discuss this page, if the index page can be commented, and comments are accepted at the article level
     if (Comments::allow_creation($item, $anchor)) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Post a comment'), 'span');
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
     }
     // new links are accepted at the index page and at the article level
     if (Links::allow_trackback()) {
         $this->menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
     }
     // new files are accepted at the index page and at the article level
     if (is_object($anchor) && $anchor->has_option('with_files') && !($anchor->has_option('no_files') || preg_match('/\\bno_files\\b/i', $item['options']))) {
         // add a file
         if (Files::allow_creation($item, $anchor, 'article')) {
             if ($context['with_friendly_urls'] == 'Y') {
                 $link = 'files/edit.php/article/' . $item['id'];
             } else {
                 $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             }
             $this->menu[] = Skin::build_link($link, i18n::s('Add a file'), 'span');
         }
     }
     // modify this page
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('Edit'), 'span');
     }
     // view permalink
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('trailer', $item);
     }
     // add trailer information from this item, if any
     if (isset($item['trailer']) && trim($item['trailer'])) {
         $text .= Codes::beautify($item['trailer']);
     }
     // returned the formatted content
     return $text;
 }
Example #5
0
File: view.php Project: rair/yacs
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Files::get_permalink($item)));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = Files::get_permalink($item)) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the page that describes the file
} else {
    // remember surfer visit
    Surfer::is_visiting(Files::get_permalink($item), Codes::beautify_title($item['title']), 'file:' . $item['id'], $item['active']);
    // initialize the rendering engine
    Codes::initialize(Files::get_permalink($item));
    // prevent search engines to present cache versions of this page
    if ($item['active'] != 'Y') {
        $context['page_header'] .= "\n" . '<meta name="robots" content="noarchive" />';
    }
    // add canonical link
    $context['page_header'] .= "\n" . '<link rel="canonical" href="' . Files::get_permalink($item) . '" />';
    // do not mention details to crawlers
    if (!Surfer::is_crawler()) {
        // all details
        $context['page_details'] .= '<p class="details">';
        $details = array();
        // information on upload
        if (Surfer::is_logged()) {
            $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
        } else {
Example #6
0
 /**
  * list articles as news
  *
  * @param resource the SQL result
  * @return array
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'articles/article.php';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset the rendering engine between items
         Codes::initialize($url);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // go to a new line
         $suffix .= BR;
         // get introduction from overlay
         if (is_object($overlay)) {
             $suffix .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
             // add a link to the main page
             $suffix .= BR . Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic', i18n::s('View the page'));
             // use introduction
         } elseif ($item['introduction']) {
             $suffix .= Codes::beautify_introduction($item['introduction']);
             // add a link to the main page
             $suffix .= BR . Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic', i18n::s('View the page'));
             // else use a teaser, if no overlay
         } elseif (!is_object($overlay)) {
             $article = new Article();
             $article->load_by_content($item);
             $suffix .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $suffix .= BR . Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($title) . '" />', 'basic');
         }
         // details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // actually insert details
         if ($details) {
             $suffix .= '<p class="details">' . ucfirst(trim(implode(', ', $details))) . '</p>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $title, $suffix, 'article', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #7
0
File: view.php Project: rair/yacs
if (is_object($anchor)) {
    $context['path_bar'] = $anchor->get_path_bar();
} else {
    $context['path_bar'] = array('dates/' => i18n::s('Dates'));
}
// the title of the page
if (is_object($anchor)) {
    $context['page_title'] = $anchor->get_title();
}
// not found -- help web crawlers
if (!isset($item['id'])) {
    include '../error.php';
    // display the date full size
} else {
    // initialize the rendering engine
    Codes::initialize(Dates::get_url($item['id']));
    // insert anchor prefix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_prefix();
    }
    // date
    if ($item['date_stamp']) {
        $context['text'] .= '<p>' . sprintf(i18n::s('%s: %s'), i18n::s('Target date'), Skin::build_date($item['date_stamp'], 'full')) . "</p>\n";
    }
    $details = array();
    // information on uploader
    if (Surfer::is_member() && $item['edit_name']) {
        $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
    }
    // page details
    if (is_array($details)) {
Example #8
0
File: view.php Project: rair/yacs
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Images::get_url($item['id'])));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the image full size
} else {
    // initialize the rendering engine
    Codes::initialize(Images::get_url($item['id']));
    // page main content
    //
    // insert anchor prefix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_prefix();
    }
    // retrieve slideshow links if we have an anchor
    if (is_object($anchor)) {
        // retrieve information from cache, if any
        $cache_id = 'images/view.php?id=' . $item['id'] . '#navigation';
        if ($data = Cache::get($cache_id)) {
            $data = Safe::unserialize($data);
        } else {
            $data = $anchor->get_neighbours('image', $item);
            // save in cache
Example #9
0
File: view.php Project: rair/yacs
} else {
    // behaviors can change page menu
    if (is_object($behaviors)) {
        $context['page_menu'] = $behaviors->add_commands('sections/view.php', 'section:' . $item['id'], $context['page_menu']);
    }
    // remember surfer visit
    Surfer::is_visiting(Sections::get_permalink($item), Codes::beautify_title($item['title']), 'section:' . $item['id'], $item['active']);
    // increment silently the hits counter if not robot, nor associate, nor owner, nor at follow-up page
    if (Surfer::is_crawler() || Surfer::is_associate()) {
    } elseif (isset($item['owner_id']) && Surfer::is($item['owner_id'])) {
    } elseif (!$zoom_type) {
        $item['hits'] = isset($item['hits']) ? $item['hits'] + 1 : 1;
        Sections::increment_hits($item['id']);
    }
    // initialize the rendering engine
    Codes::initialize($cur_section->get_permalink());
    // neighbours information
    $neighbours = NULL;
    if (Sections::has_option('with_neighbours', $anchor, $item) && is_object($anchor)) {
        $neighbours = $anchor->get_neighbours('section', $item);
    }
    //
    // set page image -- $context['page_image']
    //
    // the section or the anchor icon, if any
    if (isset($item['icon_url']) && $item['icon_url']) {
        $context['page_image'] = $item['icon_url'];
    } elseif (is_object($anchor)) {
        $context['page_image'] = $anchor->get_icon_url();
    }
    //
Example #10
0
File: view.php Project: rair/yacs
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // re-enforce the canonical link
} elseif (!$zoom_type && $context['self_url'] && ($canonical = Users::get_permalink($item)) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the user profile
} else {
    if ($whole_rendering) {
        // remember surfer visit
        Surfer::is_visiting(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name'], 'user:'******'id'], $item['active']);
        // initialize the rendering engine
        Codes::initialize(Users::get_permalink($item));
        //
        // meta-information -- $context['page_header'], etc.
        //
        // prevent search engines to present cache versions of this page
        if ($item['active'] != 'Y') {
            $context['page_header'] .= "\n" . '<meta name="robots" content="noarchive" />';
        }
        // add canonical link
        if (!$zoom_type) {
            $context['page_header'] .= "\n" . '<link rel="canonical" href="' . Users::get_permalink($item) . '" />';
        }
        // a meta link to a feeding page
        $context['page_header'] .= "\n" . '<link rel="alternate" href="' . $context['url_to_root'] . Users::get_url($item['id'], 'feed') . '" title="RSS" type="application/rss+xml" />';
        // a meta link to a description page (actually, rdf)
        $context['page_header'] .= "\n" . '<link rel="meta" href="' . $context['url_to_root'] . Users::get_url($item['id'], 'describe') . '" title="FOAF" type="application/rdf+xml" />';
Example #11
0
File: print.php Project: rair/yacs
    // not found
} elseif (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!Sections::allow_access($item, $anchor)) {
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Sections::get_url($item['id'], 'print')));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the section
} else {
    // initialize the rendering engine
    Codes::initialize(Sections::get_permalink($item));
    // the article or the anchor icon, if any
    if (isset($item['icon_url']) && $item['icon_url']) {
        $context['page_image'] = $item['icon_url'];
    } elseif (is_object($anchor)) {
        $context['page_image'] = $anchor->get_icon_url();
    }
    // provide details
    $details = array();
    // restricted to logged members
    if ($item['active'] == 'R') {
        $details[] = RESTRICTED_FLAG . i18n::s('Community - Access is granted to any identified surfer');
    } elseif ($item['active'] == 'N') {
        $details[] = PRIVATE_FLAG . i18n::s('Private - Access is restricted to selected persons');
    }
    // rank for this section
Example #12
0
File: view.php Project: rair/yacs
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the comment
} else {
    // insert anchor  icon
    if (is_object($anchor)) {
        $context['page_image'] = $anchor->get_icon_url();
    }
    // initialize the rendering engine
    Codes::initialize(Comments::get_url($item['id']));
    // neighbours information
    $neighbours = NULL;
    if (is_object($anchor)) {
        $neighbours = $anchor->get_neighbours('comment', $item);
    }
    //
    // page header
    //
    // a meta link to prefetch the next page
    if (isset($neighbours[2]) && $neighbours[2]) {
        $context['page_header'] .= "\n" . '<link rel="next" href="' . $context['url_to_root'] . $neighbours[2] . '" title="' . encode_field($neighbours[3]) . '" />';
    }
    //
    // main panel -- $context['text']
    //
Example #13
0
File: view.php Project: rair/yacs
    // anonymous users are invited to log in or to register
    if (!Surfer::is_logged()) {
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'])));
    }
    // permission denied to authenticated user
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // re-enforce the canonical link
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Tables::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the table
} else {
    // initialize the rendering engine
    Codes::initialize(Tables::get_url($item['id']));
    // insert anchor prefix
    if (is_object($anchor)) {
        $context['text'] .= $anchor->get_prefix();
    }
    // display the full text
    $context['text'] .= Skin::build_block($item['description'], 'description');
    // execute the query string to build the table
    if (isset($item['query']) && $item['query']) {
        $context['text'] .= Tables::build($item['id'], 'sortable');
    }
    // display the query string to associates and editors
    if (isset($item['query']) && $item['query'] && (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned())) {
        $context['text'] .= Skin::build_box(i18n::s('Query string'), Skin::build_block(encode_field($item['query']), 'code'), 'folded');
    }
    // add some details
Example #14
0
File: view.php Project: rair/yacs
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the category
} else {
    // remember surfer visit
    Surfer::is_visiting(Categories::get_permalink($item), Codes::beautify_title($item['title']), 'category:' . $item['id'], $item['active']);
    // increment silently the hits counter if not robot, nor associate, nor creator, nor at follow-up page
    if (Surfer::is_crawler() || Surfer::is_associate()) {
    } elseif (Surfer::get_id() && isset($item['create_id']) && Surfer::get_id() == $item['create_id']) {
    } elseif (!$zoom_type) {
        $item['hits'] = isset($item['hits']) ? $item['hits'] + 1 : 1;
        Categories::increment_hits($item['id']);
    }
    // initialize the rendering engine
    Codes::initialize(Categories::get_permalink($item));
    //
    // page image -- $context['page_image']
    //
    // the category or the anchor icon, if any
    if (isset($item['icon_url']) && $item['icon_url']) {
        $context['page_image'] = $item['icon_url'];
    } elseif (is_object($anchor)) {
        $context['page_image'] = $anchor->get_icon_url();
    }
    //
    // page meta information -- $context['page_header'], etc.
    //
    // prevent search engines to present cache versions of this page
    if ($item['active'] != 'Y') {
        $context['page_header'] .= "\n" . '<meta name="robots" content="noarchive" />';