Exemple #1
0
     // the list of newest pages
     $values['items'] = (array) Articles::list_for_author_by('publication', $item['id'], 0, 50, 'feed');
     // make a text
     include_once '../services/codec.php';
     include_once '../services/rss_codec.php';
     $result = rss_Codec::encode($values);
     $status = @$result[0];
     $text = @$result[1];
     // save in cache for the next request
     Cache::put($cache_id, $text, 'articles');
 }
 //
 // transfer to the user agent
 //
 // handle the output correctly
 render_raw('text/xml; charset=' . $context['charset']);
 // suggest a name on download
 if (!headers_sent()) {
     $file_name = utf8::to_ascii($context['site_name'] . '.section.' . $item['id'] . '.rss.xml');
     Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
 // strong validator
 $etag = '"' . md5($text) . '"';
 // manage web cache
 if (http::validate(NULL, $etag)) {
     return;
 }
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
Exemple #2
0
    // look for some notification
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
    // change session data to extend life of related file
    if (!isset($_SESSION['heartbit'])) {
        $_SESSION['heartbit'] = 0;
    }
    $_SESSION['heartbit']++;
    // refresh the watchdog
    $_SESSION['watchdog'] = time();
    // update surfer presence
    $query = "UPDATE " . SQL::table_name('users') . " SET click_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'" . " WHERE (id = " . SQL::escape(Surfer::get_id()) . ")";
    SQL::query($query, FALSE, $context['users_connection']);
    // assign article for more time
    if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit' && isset($_REQUEST['reference']) && !strncmp($_REQUEST['reference'], 'article:', 8)) {
        // refresh record of this article
        $query = "UPDATE " . SQL::table_name('articles') . " SET " . " assign_date = '" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'" . " WHERE (id = " . SQL::escape(substr($_REQUEST['reference'], 8)) . ") AND (assign_id = " . SQL::escape(Surfer::get_id()) . ")";
        SQL::query($query);
    }
    // look for one notification -- script will be be killed if none is available
    $response = Notifications::pull();
    // encode result in JSON
    $output = json_encode($response);
    // allow for data compression
    render_raw('application/json; charset=' . $context['charset']);
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
        echo $output;
    }
    // the post-processing hook, then exit
    finalize_page(TRUE);
}
Exemple #3
0
     // send the response to the caller
     if (!headers_sent()) {
         Safe::header('Content-Description: Reference file from YACS environment');
     }
     // suggest a download
     if (!headers_sent()) {
         $file_name = utf8::to_ascii(basename($script[0]));
         Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
     }
     // several scripts at one
 } else {
     // multi-part separator on the first line
     $text = $separator . $text;
     // compress the page if possible, but no transcoding -- the bare handler
     $context['charset'] = 'ASCII';
     render_raw('text/html');
     // send the response to the caller
     if (!headers_sent()) {
         Safe::header('Content-Description: Reference files from YACS environment');
     }
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
 // strong validator
 $etag = '"' . md5($text) . '"';
 // manage web cache
 if (http::validate(NULL, $etag)) {
     return;
 }
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
 */
//Content Rendering API
//Version 0.07
//Notes: You shouldn't be touching this file directly.  You should be calling through the render/index.php handler and passing the version 007
include(COMMON_DIR.'user.php');     //Class to represent a site user
include(COMMON_DIR.'feed.php');     //Class to represent a content feed
include(COMMON_DIR.'content.php');  //Class to represent content items in the system


if($_REQUEST['select'] == 'system'){
    system_info();
} else {
    $criteria = validation($_REQUEST);
    $contents = content_selection($criteria);
    if($criteria['format'] == 'raw'){
        render_raw($contents, $criteria);
    }elseif($criteria['format'] == 'html'){
        render_html($contents, $criteria);
    }elseif($criteria['format'] == 'rss'){
        render_rss($contents, $criteria);
    }elseif($criteria['format'] == 'json'){
        render_json($contents, $criteria);
    }
}

//Grab and check user values
function validation($request){
    //Default Values
    $criteria['select'] = 'feed';
    $criteria['format'] = 'rss';
    $criteria['orderby'] = 'id';
Exemple #5
0
// the section
// $context['text'] .= '<p>'.i18n::s('Section').BR
// 	.'<select name="anchor">'.Sections::get_options().'</select>'
// 	.'</p>'."\n";
// the title
$context['text'] .= '<p>' . i18n::s('Title') . BR . '<textarea name="title" id="title" rows="2" cols="20" accesskey="t"></textarea>' . '</p>' . "\n";
// the introduction
$context['text'] .= '<p>' . i18n::s('Introduction') . BR . '<textarea name="introduction" rows="3" cols="20" accesskey="i"></textarea>' . '</p>' . "\n";
// the description label
$context['text'] .= '<p>' . i18n::s('Page content') . BR . '<textarea name="text" rows="10" cols="20" accesskey="c"></textarea>' . '</p>' . "\n";
// the submit and reset buttons
$context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's', NULL, 'no_spin_on_click') . '</p>' . "\n";
// end of the form
$context['text'] .= '</form>';
// handle the output correctly
render_raw();
// if it was a HEAD request, stop here
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'HEAD') {
    return;
}
// add language information, if known
if (isset($context['page_language'])) {
    $language = ' xml:lang="' . $context['page_language'] . '" ';
} else {
    $language = '';
}
// do our own rendering
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">' . "\n" . '<html ' . $language . ' xmlns="http://www.w3.org/1999/xhtml">' . "\n" . '<head>' . "\n";
// the title
if (isset($context['page_title'])) {
    echo '<title>' . ucfirst(strip_tags($context['page_title'])) . '</title>';
Exemple #6
0
     $text .= Skin::build_block($context['page_title'], 'page_title');
 }
 // display error messages, if any
 $text .= Skin::build_error_block();
 // render and display the content, if any
 $text .= $context['text'] . "\n";
 $text .= '</body></html>' . "\n";
 // MS-WORD won't import pictures
 $text = preg_replace('/<img (.*?)\\/>/i', '', $text);
 // strip relative links
 $text = preg_replace('/<a (.*?)>(.*?)<\\/a>/is', '\\2', $text);
 //
 // transfer to the user agent
 //
 // handle the output correctly
 render_raw('application/msword; charset=' . $context['charset']);
 // suggest a download
 if (!headers_sent()) {
     $file_name = utf8::to_ascii(Skin::strip($context['page_title']) . '.doc');
     Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
 }
 // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
 http::expire(1800);
 // strong validator
 $etag = '"' . md5($text) . '"';
 // manage web cache
 if (http::validate(NULL, $etag)) {
     return;
 }
 // actual transmission except on a HEAD request
 if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
Exemple #7
0
}
$text .= '	<homePageLink>' . $context['url_to_home'] . $context['url_to_root'] . $link . '</homePageLink>' . "\n";
// restrict the scope of the API
$scope = '';
if ($id) {
    $scope = '?id=' . urlencode($id);
}
// available blogging api
$text .= '	<apis>' . "\n" . '		<api name="MovableType" preferred="true" apiLink="' . $context['url_to_home'] . $context['url_to_root'] . 'services/blog.php' . $scope . '" blogID="' . encode_field($id) . '" />' . "\n" . '		<api name="MetaWeblog" preferred="false" apiLink="' . $context['url_to_home'] . $context['url_to_root'] . 'services/blog.php' . $scope . '" blogID="' . encode_field($id) . '" />' . "\n" . '		<api name="Blogger" preferred="false" apiLink="' . $context['url_to_home'] . $context['url_to_root'] . 'services/blog.php' . $scope . '" blogID="' . encode_field($id) . '" />' . "\n" . '	</apis>' . "\n";
// the postamble
$text .= '</service>' . "\n" . '</rsd>' . "\n";
//
// transfer to the user agent
//
// handle the output correctly
render_raw('application/rsd+xml; charset=' . $context['charset']);
// suggest a name on download
if (!headers_sent()) {
    $file_name = utf8::to_ascii($context['site_name'] . '.rsd.xml');
    Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
}
// enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
http::expire(1800);
// strong validator
$etag = '"' . md5($text) . '"';
// manage web cache
if (http::validate(NULL, $etag)) {
    return;
}
// actual transmission except on a HEAD request
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
Exemple #8
0
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_raw')));
    }
    // 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 table in CSV
} else {
    // force the character set
    $context['charset'] = 'iso-8859-15';
    // render actual table content
    $text = strip_tags(Tables::build($item['id'], 'raw'));
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/csv; charset=' . $context['charset']);
    // suggest a download
    if (!headers_sent()) {
        $file_name = utf8::to_ascii(Skin::strip($item['title']) . '.csv');
        Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
    http::expire(1800);
    // strong validator
    $etag = '"' . md5($text) . '"';
    // manage web cache
    if (http::validate(NULL, $etag)) {
        return;
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
Exemple #9
0
 /**
  * render comment as json format
  * 
  * @param int $id of the comment
  * @param object $anchor of the comment
  */
 public static function render_json($id, $anchor)
 {
     // we'll return json
     $output = '';
     // get layout and render last comment
     $layout = Comments::get_layout($anchor);
     $layout->set_variant('no_wrap');
     $rendering = Comments::list_by_date_for_anchor($anchor, 0, 1, $layout, true);
     $output = json_encode(array('entity' => 'comment', 'id' => $id, 'anchor' => $anchor->get_reference(), 'html' => $rendering));
     // allow for data compression
     render_raw('application/json');
     echo $output;
     // the post-processing hook, then exit
     finalize_page(TRUE);
 }
Exemple #10
0
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_csv')));
    }
    // 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 table in CSV
} else {
    // force the character set
    $context['charset'] = 'iso-8859-15';
    // render actual table content
    $text = strip_tags(Tables::build($item['id'], 'csv'));
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('application/vnd.ms-excel; charset=' . $context['charset']);
    // suggest a download
    if (!headers_sent()) {
        $file_name = utf8::to_ascii(Skin::strip($item['title']) . '.csv');
        Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 30-minute caching (30*60 = 1800), even through https, to help IE6 on download
    http::expire(1800);
    // strong validator
    $etag = '"' . md5($text) . '"';
    // manage web cache
    if (http::validate(NULL, $etag)) {
        return;
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
Exemple #11
0
        $layout = 'tree_manager';
        if (isset($_REQUEST['variant'])) {
            $layout .= ' ' . $_REQUEST['variant'];
        }
        $childs = $anchor->get_childs($anchor->get_type(), 0, 200, $layout);
        // prepare json reply
        if (isset($childs[$anchor->get_type()])) {
            $output['success'] = true;
            $output['content'] = $childs[$anchor->get_type()];
            $output['title'] = $anchor->get_title();
            $output['crumbs_separator'] = CRUMBS_SEPARATOR;
            $output['crumbs_suffix'] = CRUMBS_SUFFIX;
            $output['userlevel'] = $powered ? 'powered' : '';
            $output['root_ref'] = $anchor->get_reference();
        } else {
            $output['success'] = false;
        }
        break;
    default:
        // unknown action
        die_on_invalid();
}
// output is JSON formated
render_raw('application/json');
$output = json_encode($output);
// actual transmission
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
    echo $output;
}
// the post-processing hook, then exit
finalize_page(TRUE);
Exemple #12
0
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Tables::get_url($item['id'], 'fetch_as_json')));
    }
    // 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 table in CSV
} else {
    // force the character set
    $context['charset'] = 'iso-8859-15';
    // render actual table content
    $text = Tables::build($id, 'json');
    //
    // transfer to the user agent
    //
    // handle the output correctly
    render_raw('text/json; charset=' . $context['charset']);
    // suggest a download
    if (!headers_sent()) {
        $file_name = utf8::to_ascii(Skin::strip($item['title']) . '.json');
        Safe::header('Content-Disposition: attachment; filename="' . str_replace('"', '', $file_name) . '"');
    }
    // enable 3-minute caching (3*60 = 180), even through https, to help IE6 on download
    http::expire(180);
    // strong validator
    $etag = '"' . md5($text) . '"';
    // manage web cache
    if (http::validate(NULL, $etag)) {
        return;
    }
    // actual transmission except on a HEAD request
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {