Beispiel #1
0
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 */
// common definitions and initial processing
include_once '../shared/global.php';
include_once 'servers.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
    $id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
    $id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Servers::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
}
// associates can do what they want
if (Surfer::is_associate()) {
    $permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
    $permitted = FALSE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
    $permitted = TRUE;
} elseif ($item['active'] == 'Y') {
    $permitted = TRUE;
} else {
Beispiel #2
0
 *
 * The response is a list of matching articles encoded with RSS.
 * Only public items are searched.
 *
 * @author Bernard Paques
 * @author GnapZ
 * @reference
 * @license http://www.gnu.org/copyleft/lesser.txt GNU Lesser General Public License
 *
 * @see search.php
 * @see services/rss_codec.php
 */
include_once '../shared/global.php';
// stop banned hosts
include_once $context['path_to_root'] . 'servers/servers.php';
if (isset($_SERVER['REMOTE_HOST']) && ($server = Servers::get($_SERVER['REMOTE_HOST']) && $server['process_search'] != 'Y')) {
    exit('Access denied');
}
// look for words
$search = '';
if (isset($_REQUEST['search'])) {
    $search = $_REQUEST['search'];
} elseif (isset($context['arguments'][0])) {
    $search = $context['arguments'][0];
}
$search = strip_tags($search);
// search type
$type = '';
if (isset($_REQUEST['type'])) {
    $type = $_REQUEST['type'];
}
Beispiel #3
0
    $fields['submit_ping'] = 'Y';
    $fields['ping_url'] = 'http://api.my.yahoo.com/RPC2';
    $fields['submit_search'] = 'N';
    $fields['search_url'] = '';
    $fields['submit_monitor'] = 'N';
    $fields['monitor_url'] = '';
    if ($error = Servers::post($fields)) {
        $text .= $error;
    } else {
        $text .= sprintf(i18n::s('A record has been created for server %s'), $fields['host_name']) . BR . "\n";
    }
}
// 'www.yacs.fr' server
$fields = array();
$fields['host_name'] = i18n::s('www.yacs.fr');
if (Servers::get($fields['host_name'])) {
    $text .= sprintf(i18n::s('An entry already exists for server %s'), $fields['host_name']) . BR . "\n";
} else {
    $fields['title'] = 'yacs';
    $fields['description'] = i18n::c('The origin server for the YACS system');
    $fields['main_url'] = 'http://www.yacs.fr/';
    $fields['submit_feed'] = 'Y';
    $fields['feed_url'] = 'http://www.yacs.fr/feeds/rss.php';
    $fields['submit_ping'] = 'Y';
    $fields['ping_url'] = 'http://www.yacs.fr/services/ping.php';
    $fields['submit_search'] = 'N';
    $fields['search_url'] = 'http://www.yacs.fr/services/search.php';
    $fields['submit_monitor'] = 'N';
    $fields['monitor_url'] = 'http://www.yacs.fr/services/ping.php';
    if ($error = Servers::post($fields)) {
        $text .= $error;
Beispiel #4
0
             $fields['link_url'] = $source;
             if (!($fields['id'] = Links::post($fields))) {
                 $response = 0;
             } else {
                 $response = 'Thanks for the ping';
                 Links::clear($fields);
             }
         }
     }
     break;
     // ping an external reference to some page on this site
 // ping an external reference to some page on this site
 case 'weblogUpdates.ping':
     list($label, $url) = $parameters['params'];
     // caller has been banned
     if ($_SERVER['REMOTE_HOST'] && ($server = Servers::get($_SERVER['REMOTE_HOST']) && $server['process_ping'] != 'Y')) {
         $response = array('flerror' => 49, 'message' => 'Access denied');
     } elseif (preg_match('/\\b(127\\.0\\.0\\.1|localhost)\\b/', $url)) {
         $response = array('flerror' => 1, 'message' => 'We don\'t accept local references ' . $url);
     } elseif (($content = http::proceed($url)) === FALSE && ($content = http::proceed($url . '/')) === FALSE) {
         $response = array('flerror' => 1, 'message' => 'Cannot read source address ' . $url);
     } else {
         $response = Servers::ping(strip_tags($label), $url);
         if ($response) {
             Logger::remember('services/ping.php: failing ping', $response, 'debug');
             $response = array('flerror' => 1, 'message' => $response);
         } else {
             $response = array('flerror' => 0, 'message' => 'Thanks for the ping');
         }
     }
     break;
Beispiel #5
0
<?php

$servers = Servers::get(10);
?>

<div id="page-title">
    <h1>Рейтинг серверов Minecraft <g:plusone></g:plusone></h1>
</div>

<div class="server-list">
    <?php 
foreach ($servers as $server) {
    require 'partials/server.php';
}
?>
</div>
Beispiel #6
0
 /**
  * render a link to an object
  *
  * Following types are supported:
  * - article - link to an article page
  * - category - link to a category page
  * - comment - link to a comment page
  * - download - link to a download page
  * - file - link to a file page
  * - flash - display a file as a native flash object, or play a flash video
  * - go
  * - image - display an in-line image
  * - next - link to an article page
  * - previous - link to an article page
  * - section - link to a section page
  * - server - link to a server page
  * - user - link to a user page
  *
  * @param string the type
  * @param string the id, with possible options or variant
  * @return string the rendered text
  **/
 public static function render_object($type, $id)
 {
     global $context;
     $id = Codes::fix_tags($id);
     // depending on type
     switch ($type) {
         // link to an article
         case 'article':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[article=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // insert article description
         // insert article description
         case 'article.description':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[article.description=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'article');
                 // the introduction text, if any
                 $output .= BR . Codes::beautify($item['introduction']);
                 // load overlay, if any
                 if (isset($item['overlay']) && $item['overlay']) {
                     $overlay = Overlay::load($item, 'article:' . $item['id']);
                     // get text related to the overlay, if any
                     if (is_object($overlay)) {
                         $output .= $overlay->get_text('view', $item);
                     }
                 }
                 // the description, which is the actual page body
                 $output .= '<div>' . Codes::beautify($item['description']) . '</div>';
             }
             return $output;
             // link to a category
         // link to a category
         case 'category':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Categories::get($id))) {
                 $output = '[category=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Categories::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // insert category description
         // insert category description
         case 'category.description':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Categories::get($id))) {
                 $output = '[category.description=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Categories::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'category');
                 // the introduction text, if any
                 $output .= BR . Codes::beautify($item['introduction']);
                 // load overlay, if any
                 if (isset($item['overlay']) && $item['overlay']) {
                     $overlay = Overlay::load($item, 'category:' . $item['id']);
                     // get text related to the overlay, if any
                     if (is_object($overlay)) {
                         $output .= $overlay->get_text('view', $item);
                     }
                 }
                 // the description, which is the actual page body
                 $output .= '<div>' . Codes::beautify($item['description']) . '</div>';
             }
             return $output;
             // link to a comment
         // link to a comment
         case 'comment':
             include_once $context['path_to_root'] . 'comments/comments.php';
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Comments::get($id))) {
                 $output = '[comment=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                 } else {
                     $text = i18n::s('View this comment');
                 }
                 // make a link to the target page
                 $url = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id']);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'basic');
             }
             return $output;
             // link to a download
         // link to a download
         case 'download':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Files::get($id))) {
                 // file does not exist anymore
                 if (isset($attributes[1]) && $attributes[1]) {
                     $output = $attributes[1] . '<p class="details">' . i18n::s('[this file has been deleted]') . '</p>';
                 } else {
                     $output = '[download=' . $id . ']';
                 }
             } else {
                 // label for this file
                 $prefix = $text = $suffix = '';
                 // signal restricted and private files
                 if ($item['active'] == 'N') {
                     $prefix .= PRIVATE_FLAG;
                 } elseif ($item['active'] == 'R') {
                     $prefix .= RESTRICTED_FLAG;
                 }
                 // ensure we have a label for this link
                 if (isset($attributes[1]) && $attributes[1]) {
                     $text .= $attributes[1];
                     // this may describe a previous file, which has been replaced
                     if ($item['edit_action'] != 'file:create' && $attributes[1] != $item['file_name']) {
                         $text .= ' <p class="details">' . i18n::s('[this file has been replaced]') . '</p>';
                         $output = $prefix . $text . $suffix;
                         return $output;
                     }
                 } else {
                     $text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
                 }
                 // flag files uploaded recently
                 if ($item['create_date'] >= $context['fresh']) {
                     $suffix .= NEW_FLAG;
                 } elseif ($item['edit_date'] >= $context['fresh']) {
                     $suffix .= UPDATED_FLAG;
                 }
                 // always download the file
                 $url = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
                 // return a complete anchor
                 $output = $prefix . Skin::build_link($url, $text, 'file') . $suffix;
             }
             return $output;
             // link to a file
         // link to a file
         case 'file':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database --ensure we get a fresh copy of the record, not a cached one
             if (!($item = Files::get($id, TRUE))) {
                 // file does not exist anymore
                 if (isset($attributes[1]) && $attributes[1]) {
                     $output = $attributes[1] . '<p class="details">' . i18n::s('[this file has been deleted]') . '</p>';
                 } else {
                     $output = '[file=' . $id . ']';
                 }
             } else {
                 // maybe we want to illustrate this file
                 if ($item['edit_action'] != 'file:create' && isset($attributes[1]) && $attributes[1] || !($output = Files::interact($item))) {
                     // label for this file
                     $output = $prefix = $text = $suffix = '';
                     // signal restricted and private files
                     if ($item['active'] == 'N') {
                         $prefix .= PRIVATE_FLAG;
                     } elseif ($item['active'] == 'R') {
                         $prefix .= RESTRICTED_FLAG;
                     }
                     // ensure we have a label for this link
                     if (isset($attributes[1]) && $attributes[1]) {
                         $text .= $attributes[1];
                         // this may describe a previous file, which has been replaced
                         if ($item['edit_action'] != 'file:create' && $attributes[1] != $item['file_name']) {
                             $text .= '<p class="details">' . i18n::s('[this file has been replaced]') . '</p>';
                             $output = $prefix . $text . $suffix;
                             return $output;
                         }
                     } else {
                         $text .= Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
                     }
                     // flag files uploaded recently
                     if ($item['create_date'] >= $context['fresh']) {
                         $suffix .= NEW_FLAG;
                     } elseif ($item['edit_date'] >= $context['fresh']) {
                         $suffix .= UPDATED_FLAG;
                     }
                     // make a link to the target page
                     $url = Files::get_download_url($item);
                     // return a complete anchor
                     $output .= $prefix . Skin::build_link($url, $text, 'basic') . $suffix;
                 }
             }
             return $output;
             // invoke the selector
         // invoke the selector
         case 'go':
             // extract the label, if any
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $name = $attributes[0];
             // ensure we have a label for this link
             if (isset($attributes[1])) {
                 $text = $attributes[1];
             } else {
                 $text = $name;
             }
             // return a complete anchor
             $output = Skin::build_link($context['url_to_home'] . $context['url_to_root'] . normalize_shortcut($name), $text, 'basic');
             return $output;
             // embed an image
         // embed an image
         case 'image':
             include_once $context['path_to_root'] . 'images/images.php';
             // get the variant, if any
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             if (isset($attributes[1])) {
                 $variant = $attributes[1];
             } else {
                 $variant = 'inline';
             }
             // get the image record
             if (!($image = Images::get($id))) {
                 $output = '[image=' . $id . ']';
                 return $output;
             }
             // a title for the image --do not force a title
             if (isset($image['title'])) {
                 $title = $image['title'];
             } else {
                 $title = '';
             }
             // provide thumbnail if not defined, or forced, or for large images
             if (!$image['use_thumbnail'] || $image['use_thumbnail'] == 'A' || $image['use_thumbnail'] == 'Y' && $image['image_size'] > $context['thumbnail_threshold']) {
                 // not inline anymore, but thumbnail --preserve other variants
                 if ($variant == 'inline') {
                     $variant = 'thumbnail';
                 }
                 // where to fetch the image file
                 $href = Images::get_thumbnail_href($image);
                 // to drive to plain image
                 $link = Images::get_icon_href($image);
                 // add an url, if any
             } elseif ($image['link_url']) {
                 // flag large images
                 if ($image['image_size'] > $context['thumbnail_threshold']) {
                     $variant = rtrim('large ' . $variant);
                 }
                 // where to fetch the image file
                 $href = Images::get_icon_href($image);
                 // transform local references, if any
                 include_once $context['path_to_root'] . '/links/links.php';
                 $attributes = Links::transform_reference($image['link_url']);
                 if ($attributes[0]) {
                     $link = $context['url_to_root'] . $attributes[0];
                 } else {
                     $link = $image['link_url'];
                 }
                 // get the <img ... /> element
             } else {
                 // do not append poor titles to inline images
                 if ($variant == 'inline') {
                     $title = '';
                 }
                 // flag large images
                 if ($image['image_size'] > $context['thumbnail_threshold']) {
                     $variant = rtrim('large ' . $variant);
                 }
                 // where to fetch the image file
                 $href = Images::get_icon_href($image);
                 // no link
                 $link = '';
             }
             // use the skin
             if (Images::allow_modification($image['anchor'], $id)) {
                 // build editable image
                 $output =& Skin::build_image($variant, $href, $title, $link, $id);
             } else {
                 $output =& Skin::build_image($variant, $href, $title, $link);
             }
             return $output;
             // embed a stack of images
         // embed a stack of images
         case 'images':
             include_once $context['path_to_root'] . 'images/images.php';
             // get the list of ids
             $ids = preg_split("/\\s*,\\s*/", $id);
             if (!count($ids)) {
                 $output = '[images=id1, id2, ...]';
                 return $output;
             }
             // build the list of images
             $items = array();
             foreach ($ids as $id) {
                 // get the image record
                 if ($image = Images::get($id)) {
                     // a title for the image --do not force a title
                     if (isset($image['title'])) {
                         $title = $image['title'];
                     } else {
                         $title = '';
                     }
                     // provide thumbnail if not defined, or forced, or for large images
                     $variant = 'inline';
                     if (!$image['use_thumbnail'] || $image['use_thumbnail'] == 'A' || $image['use_thumbnail'] == 'Y' && $image['image_size'] > $context['thumbnail_threshold']) {
                         // not inline anymore, but thumbnail
                         $variant = 'thumbnail';
                         // where to fetch the image file
                         $href = Images::get_thumbnail_href($image);
                         // to drive to plain image
                         $link = $context['url_to_root'] . Images::get_url($id);
                         // add an url, if any
                     } elseif ($image['link_url']) {
                         // flag large images
                         if ($image['image_size'] > $context['thumbnail_threshold']) {
                             $variant = rtrim('large ' . $variant);
                         }
                         // where to fetch the image file
                         $href = Images::get_icon_href($image);
                         // transform local references, if any
                         include_once $context['path_to_root'] . '/links/links.php';
                         $attributes = Links::transform_reference($image['link_url']);
                         if ($attributes[0]) {
                             $link = $context['url_to_root'] . $attributes[0];
                         } else {
                             $link = $image['link_url'];
                         }
                         // get the <img ... /> element
                     } else {
                         // flag large images
                         if ($image['image_size'] > $context['thumbnail_threshold']) {
                             $variant = rtrim('large ' . $variant);
                         }
                         // where to fetch the image file
                         $href = Images::get_icon_href($image);
                         // no link
                         $link = '';
                     }
                     // use the skin
                     $label =& Skin::build_image($variant, $href, $title, $link);
                     // add item to the stack
                     $items[] = $label;
                 }
             }
             // format the list
             $output = '';
             if (count($items)) {
                 // stack items
                 $output = Skin::finalize_list($items, 'stack');
                 // rotate items
                 $output = Skin::rotate($output);
             }
             // done
             return $output;
             // link to the next article
         // link to the next article
         case 'next':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[next=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'next');
             }
             return $output;
             // link to the previous article
         // link to the previous article
         case 'previous':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Articles::get($id))) {
                 $output = '[previous=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Articles::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, 'previous');
             }
             return $output;
             // link to a section
         // link to a section
         case 'section':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Sections::get($id))) {
                 $output = '[section=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = Sections::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // link to a server
         // link to a server
         case 'server':
             include_once $context['path_to_root'] . 'servers/servers.php';
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Servers::get($id))) {
                 $output = '[server=' . $id . ']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } else {
                     $text = Skin::strip($item['title']);
                 }
                 // make a link to the target page
                 $url = $context['url_to_home'] . $context['url_to_root'] . Servers::get_url($id);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // link to a user
         // link to a user
         case 'user':
             // maybe an alternate title has been provided
             $attributes = preg_split("/\\s*,\\s*/", $id, 2);
             $id = $attributes[0];
             // load the record from the database
             if (!($item = Users::get($id))) {
                 $output = '[user='******']';
             } else {
                 // ensure we have a label for this link
                 if (isset($attributes[1])) {
                     $text = $attributes[1];
                     $type = 'basic';
                 } elseif (isset($item['full_name']) && $item['full_name']) {
                     $text = ucfirst($item['full_name']);
                 } else {
                     $text = ucfirst($item['nick_name']);
                 }
                 // make a link to the target page
                 $url = Users::get_permalink($item);
                 // return a complete anchor
                 $output =& Skin::build_link($url, $text, $type);
             }
             return $output;
             // invalid type
         // invalid type
         default:
             $output = '[' . $type . ']';
             return $output;
     }
 }