本文整理汇总了PHP中Surfer::get_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Surfer::get_name方法的具体用法?PHP Surfer::get_name怎么用?PHP Surfer::get_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surfer
的用法示例。
在下文中一共展示了Surfer::get_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stamp
/**
* stamp an article
*
* This function is used to change various dates for one article.
*
* [*] If a publication date is provided, it is saved along the article.
* An optional expiry date will be saved as well.
*
* [*] If only an expiry date is provided, it is saved along the article.
*
* [*] If no date is provided, the review field is updated to the current date and time.
*
* Dates are supposed to be in UTC time zone.
*
* The name of the surfer is registered as the official publisher.
* As an alternative, publisher attributes ('name', 'id' and 'address') can be provided
* in parameters.
*
* @param int the id of the item to publish
* @param string the target publication date, if any
* @param string the target expiration date, if any
* @param array attributes of the publisher, if any
* @return string either a null string, or some text describing an error to be inserted into the html response
*
* @see articles/publish.php
* @see sections/manage.php
**/
public static function stamp($id, $publication = NULL, $expiry = NULL, $publisher = NULL)
{
global $context;
// id cannot be empty
if (!$id || !is_numeric($id)) {
return i18n::s('No item has the provided id.');
}
// server offset
$server_offset = 0;
if (isset($context['gmt_offset'])) {
$server_offset = intval($context['gmt_offset']);
}
// surfer offset
$surfer_offset = Surfer::get_gmt_offset();
// no publication time is provided
if (!isset($publication) || !$publication) {
$publication_stamp = 0;
} elseif (preg_match('/GMT$/', $publication) && strlen($publication) == 19) {
// YYMMDD-HH:MM:SS GMT -> HH, MM, SS, MM, DD, YY
$publication_stamp = gmmktime(intval(substr($publication, 7, 2)), intval(substr($publication, 10, 2)), intval(substr($publication, 13, 2)), intval(substr($publication, 2, 2)), intval(substr($publication, 4, 2)), intval(substr($publication, 0, 2)));
// time()-like stamp
} elseif (intval($publication) > 1000000000) {
// adjust to UTC time zone
$publication_stamp = intval($publication) + $context['gmt_offset'] * 3600;
// YYYY-MM-DD HH:MM:SS, or a string that can be readed
} elseif (($publication_stamp = SQL::strtotime($publication)) != -1) {
} else {
return sprintf(i18n::s('"%s" is not a valid date'), $publication);
}
// no expiry date
if (!isset($expiry) || !$expiry) {
$expiry_stamp = 0;
} elseif (preg_match('/GMT$/', $expiry) && strlen($expiry) == 19) {
// YYMMDD-HH:MM:SS GMT -> HH, MM, SS, MM, DD, YY
$expiry_stamp = gmmktime(substr($expiry, 7, 2), substr($expiry, 10, 2), substr($expiry, 13, 2), substr($expiry, 2, 2), substr($expiry, 4, 2), substr($expiry, 0, 2));
// time()-like stamp
} elseif (intval($expiry) > 1000000000) {
// adjust to server time zone
$expiry_stamp = intval($expiry) + $context['gmt_offset'] * 3600;
// YYYY-MM-DD HH:MM:SS, or a string that can be readed
} elseif (($expiry_stamp = SQL::strtotime($expiry)) != -1) {
} else {
return sprintf(i18n::s('"%s" is not a valid date'), $expiry);
}
// review date
$review_stamp = 0;
if (!$publication_stamp && !$expiry_stamp) {
$review_stamp = time();
}
// shape the query
$query = array();
if ($publication_stamp > 0) {
$query[] = "publish_name='" . SQL::escape(isset($publisher['name']) ? $publisher['name'] : Surfer::get_name()) . "'," . "publish_id=" . SQL::escape(isset($publisher['id']) ? $publisher['id'] : Surfer::get_id()) . "," . "publish_address='" . SQL::escape(isset($publisher['address']) ? $publisher['address'] : Surfer::get_email_address()) . "'," . "publish_date='" . gmstrftime('%Y-%m-%d %H:%M:%S', $publication_stamp) . "'," . "edit_name='" . SQL::escape(isset($publisher['name']) ? $publisher['name'] : Surfer::get_name()) . "'," . "edit_id=" . SQL::escape(isset($publisher['id']) ? $publisher['id'] : Surfer::get_id()) . "," . "edit_address='" . SQL::escape(isset($publisher['address']) ? $publisher['address'] : Surfer::get_email_address()) . "'," . "edit_action='article:publish'," . "edit_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'";
}
if ($expiry_stamp > 0) {
$query[] = "expiry_date='" . gmstrftime('%Y-%m-%d %H:%M:%S', $expiry_stamp) . "'";
}
if ($review_stamp > 0) {
$query[] = "review_date='" . gmstrftime('%Y-%m-%d %H:%M:%S', $review_stamp) . "'";
}
// update an existing record
$query = "UPDATE " . SQL::table_name('articles') . " SET " . implode(',', $query) . " WHERE id = " . SQL::escape($id);
if (SQL::query($query) === FALSE) {
return NULL;
}
// remember the publication in weekly and monthly categories
if ($publication_stamp > 0) {
Categories::remember('article:' . $id, gmstrftime('%Y-%m-%d %H:%M:%S', $publication_stamp));
}
// end of job
return NULL;
}
示例2: touch
//.........这里部分代码省略.........
}
}
// refresh stamp only if image update occurs within 6 hours after last edition
if (SQL::strtotime($this->item['edit_date']) + 6 * 60 * 60 < time()) {
$silently = TRUE;
}
// suppress a reference to an image that has been deleted
} elseif ($action == 'image:delete') {
// suppress reference in main description field
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'";
// suppress references as icon and thumbnail as well
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
if ($this->item['icon_url'] == $url) {
$query[] = "icon_url = ''";
}
if ($this->item['thumbnail_url'] == $url) {
$query[] = "thumbnail_url = ''";
}
}
if ($url = Images::get_thumbnail_href($image)) {
if ($this->item['icon_url'] == $url) {
$query[] = "icon_url = ''";
}
if ($this->item['thumbnail_url'] == $url) {
$query[] = "thumbnail_url = ''";
}
}
}
// set an existing image as the category icon
} elseif ($action == 'image:set_as_icon') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
$query[] = "icon_url = '" . SQL::escape($url) . "'";
}
// also use it as thumnail if none has been defined yet
if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// set an existing image as the category thumbnail
} elseif ($action == 'image:set_as_thumbnail') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_thumbnail_href($image)) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// append a new image, and set it as the article thumbnail
} elseif ($action == 'image:set_as_both') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
}
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_thumbnail_href($image)) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
} elseif ($origin) {
$query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
}
// do not remember minor changes
$silently = TRUE;
// add a reference to a new table in the category description
} elseif ($action == 'table:create') {
if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [table=' . $origin . ']') . "'";
}
// suppress a reference to a table that has been deleted
} elseif ($action == 'table:delete') {
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'table', $origin)) . "'";
}
// stamp the update
if (!$silently) {
$query[] = "edit_name='" . Surfer::get_name() . "'," . "edit_id=" . Surfer::get_id() . "," . "edit_address='" . Surfer::get_email_address() . "'," . "edit_action='{$action}'," . "edit_date='" . strftime('%Y-%m-%d %H:%M:%S') . "'";
}
// ensure we have a valid update query
if (!@count($query)) {
return;
}
// update the anchor category
$query = "UPDATE " . SQL::table_name('categories') . " SET " . implode(', ', $query) . " WHERE id = " . SQL::escape($this->item['id']);
if (SQL::query($query) === FALSE) {
return;
}
// always clear the cache, even on no update
Categories::clear($this->item);
// get the parent
if (!$this->anchor) {
$this->anchor = Anchors::get($this->item['anchor']);
}
// propagate the touch upwards silently -- we only want to purge the cache
if (is_object($this->anchor)) {
$this->anchor->touch('category:update', $this->item['id'], TRUE);
}
}
示例3: array
$anchor = 'section:' . $fields['id'];
}
}
// archive the letter
$context['text'] .= i18n::s('Archiving the new letter') . BR . "\n";
// save the letter as a published article, but don't use special categories
$fields = array();
$fields['anchor'] = $anchor;
$fields['title'] = $_REQUEST['letter_title'];
$label = $_REQUEST['letter_recipients'];
if ($_REQUEST['letter_recipients'] == 'custom' && isset($_REQUEST['mail_to'])) {
$label = $_REQUEST['mail_to'];
}
$fields['introduction'] = sprintf(i18n::c('Sent %s to "%s"'), Skin::build_date(time(), 'full', $context['preferred_language']), $label);
$fields['description'] = $_REQUEST['letter_body'];
$fields['publish_name'] = Surfer::get_name();
$fields['publish_id'] = Surfer::get_id();
$fields['publish_address'] = Surfer::get_email_address();
$fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
$fields['id'] = Articles::post($fields);
// from: from configuration files
if (isset($context['letter_reply_to']) && $context['letter_reply_to']) {
$from = $context['letter_reply_to'];
} elseif (isset($context['mail_from']) && $context['mail_from']) {
$from = $context['mail_from'];
} else {
$from = $context['site_name'];
}
// to: build the list of recipients
$recipients = array();
switch ($_REQUEST['letter_recipients']) {
示例4: elseif
}
// ensure we have a valid layout for articles
if (!isset($_REQUEST['root_articles_layout']) || !$_REQUEST['root_articles_layout'] || !preg_match('/(alistapart|compact|custom|daily|decorated|digg|hardboiled|newspaper|no_articles|slashdot)/', $_REQUEST['root_articles_layout'])) {
$_REQUEST['root_articles_layout'] = 'daily';
} elseif ($_REQUEST['root_articles_layout'] == 'custom') {
if (isset($_REQUEST['home_custom_layout']) && $_REQUEST['home_custom_layout']) {
$_REQUEST['root_articles_layout'] = basename(strip_tags($_REQUEST['home_custom_layout']));
} else {
$_REQUEST['root_articles_layout'] = 'daily';
}
}
// backup the old version
Safe::unlink($context['path_to_root'] . 'parameters/root.include.php.bak');
Safe::rename($context['path_to_root'] . 'parameters/root.include.php', $context['path_to_root'] . 'parameters/root.include.php.bak');
// build the new configuration file
$content = '<?php' . "\n" . '// This file has been created by the configuration script configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . 'global $context;' . "\n" . '$context[\'root_articles_layout\']=\'' . addcslashes($_REQUEST['root_articles_layout'], "\\'") . "';\n";
if (isset($_REQUEST['root_articles_count_at_home']) && intval($_REQUEST['root_articles_count_at_home'])) {
$content .= '$context[\'root_articles_count_at_home\']=\'' . intval($_REQUEST['root_articles_count_at_home']) . "';\n";
}
if (isset($_REQUEST['root_cover_at_home'])) {
$content .= '$context[\'root_cover_at_home\']=\'' . addcslashes($_REQUEST['root_cover_at_home'], "\\'") . "';\n";
}
if (isset($_REQUEST['root_flash_at_home'])) {
$content .= '$context[\'root_flash_at_home\']=\'' . addcslashes($_REQUEST['root_flash_at_home'], "\\'") . "';\n";
}
if (isset($_REQUEST['root_gadget_boxes_at_home'])) {
$content .= '$context[\'root_gadget_boxes_at_home\']=\'' . addcslashes($_REQUEST['root_gadget_boxes_at_home'], "\\'") . "';\n";
}
if (isset($_REQUEST['root_featured_layout'])) {
$content .= '$context[\'root_featured_layout\']=\'' . addcslashes($_REQUEST['root_featured_layout'], "\\'") . "';\n";
}
示例5: die
* @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 'notifications.php';
// ensure browser always look for fresh data
http::expire(0);
// surfer has to be logged --provide a short response
if (!Surfer::get_id()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
// a new notification has been submitted
} elseif (isset($_REQUEST['recipient']) && isset($_REQUEST['type'])) {
// record the notification
$fields = array();
$fields['nick_name'] = Surfer::get_name();
$fields['recipient'] = $_REQUEST['recipient'];
$fields['type'] = $_REQUEST['type'];
if (isset($_REQUEST['address'])) {
$fields['address'] = encode_link($_REQUEST['address']);
}
if (isset($_REQUEST['message'])) {
$fields['message'] = strip_tags($_REQUEST['message']);
}
// vaidate notification attributes
switch ($fields['type']) {
case 'browse':
if (!isset($_REQUEST['address'])) {
Safe::header('Status: 400 Bad Request', TRUE, 400);
die(i18n::s('Request is invalid.'));
}
示例6: sprintf
$label = i18n::s('Message title');
if (is_object($overlay)) {
$title = $overlay->get_live_title($item);
} else {
$title = $item['title'];
}
$title = sprintf(i18n::c('Invitation: %s'), $title);
$input = '<input type="text" name="subject" size="50" maxlength="255" value="' . encode_field($title) . '" />';
$fields[] = array($label, $input);
// default message content
$content = '';
if (is_callable(array($overlay, 'get_invite_default_message'))) {
$content = $overlay->get_invite_default_message();
}
if (!$content) {
$content = '<p>' . i18n::c('I would like to invite you to the following page.') . '</p>' . '<p><a href="' . Sections::get_permalink($item) . '">' . $item['title'] . '</a></p>' . '<p>' . i18n::c('Please let me thank you for your involvement.') . '</p>' . '<p>' . Surfer::get_name() . '</p>';
}
// the message
$label = i18n::s('Message content');
$input = Surfer::get_editor('message', $content);
$fields[] = array($label, $input);
// build the form
$context['text'] .= Skin::build_form($fields);
//
// bottom commands
//
$menu = array();
// the submit button
$menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
// cancel button
if (isset($item['id'])) {
示例7: sprintf
}
// display the form
if ($with_form) {
// by default it will be a group space
if (!isset($item['articles_layout'])) {
$item['articles_layout'] = 'group';
}
// default title
if (!isset($item['title'])) {
// first section
if (!isset($existing_sections) || !$existing_sections) {
$item['title'] = sprintf(i18n::s('The personal space of %s'), Surfer::get_name());
} elseif ($existing_sections == 1) {
$item['title'] = sprintf(i18n::s('Another personal space of %s'), Surfer::get_name());
} else {
$item['title'] = sprintf(i18n::s('Another personal space of %s (%d)'), Surfer::get_name(), $existing_sections + 1);
}
}
// the form to edit a section
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>';
// layout for related articles
$label = i18n::s('Purpose');
$input = i18n::s('What are you aiming to create?');
$input .= BR . '<input type="radio" name="space_type" value="group" checked="checked"';
$input .= EOT . i18n::s('A group, for people interested in some topic');
$input .= BR . '<input type="radio" name="space_type" value="blog"';
$input .= EOT . i18n::s('A blog, to express your thoughts and to lead the pack');
$input .= BR . '<input type="radio" name="space_type" value="project"';
$input .= EOT . i18n::s('A project, to support teamwork');
$fields[] = array($label, $input);
// the title
示例8: touch
//.........这里部分代码省略.........
// suppress reference in main description field
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'";
// suppress references as icon and thumbnail as well
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
if ($this->item['icon_url'] == $url) {
$query[] = "icon_url = ''";
}
if ($this->item['thumbnail_url'] == $url) {
$query[] = "thumbnail_url = ''";
}
}
if ($url = Images::get_thumbnail_href($image)) {
if ($this->item['icon_url'] == $url) {
$query[] = "icon_url = ''";
}
if ($this->item['thumbnail_url'] == $url) {
$query[] = "thumbnail_url = ''";
}
}
}
// set an existing image as the section icon
} elseif ($action == 'image:set_as_icon') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
$query[] = "icon_url = '" . SQL::escape($url) . "'";
}
// also use it as thumnail if none has been defined yet
if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
} elseif ($origin) {
$query[] = "icon_url = '" . SQL::escape($origin) . "'";
}
$silently = TRUE;
// set an existing image as the section thumbnail
} elseif ($action == 'image:set_as_thumbnail') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
// use the thumbnail for large files, or the image itself for smaller files
if ($image['image_size'] > $context['thumbnail_threshold']) {
$url = Images::get_thumbnail_href($image);
} else {
$url = Images::get_icon_href($image);
}
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
} elseif ($origin) {
$query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
}
$silently = TRUE;
// append a new image, and set it as the article thumbnail
} elseif ($action == 'image:set_as_both') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
}
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
// use the thumbnail for large files, or the image itself for smaller files
if ($image['image_size'] > $context['thumbnail_threshold']) {
$url = Images::get_thumbnail_href($image);
} else {
$url = Images::get_icon_href($image);
}
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
} elseif ($origin) {
$query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
}
// do not remember minor changes
$silently = TRUE;
// add a reference to a new table in the section description
} elseif ($action == 'table:create') {
if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [table=' . $origin . ']') . "'";
}
// suppress a reference to a table that has been deleted
} elseif ($action == 'table:delete') {
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'table', $origin)) . "'";
}
// stamp the update
if (!$silently) {
$query[] = "edit_name='" . SQL::escape(Surfer::get_name()) . "'," . "edit_id=" . SQL::escape(Surfer::get_id()) . "," . "edit_address='" . SQL::escape(Surfer::get_email_address()) . "'," . "edit_action='{$action}'," . "edit_date='" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'";
}
// update the database
if (@count($query)) {
$query = "UPDATE " . SQL::table_name('sections') . " SET " . implode(', ', $query) . " WHERE id = " . SQL::escape($this->item['id']);
SQL::query($query);
}
// always clear the cache, even on no update
Sections::clear($this->item);
// get the parent
if (!$this->anchor) {
$this->anchor = Anchors::get($this->item['anchor']);
}
// propagate the touch upwards silently -- we only want to purge the cache
if (is_object($this->anchor)) {
$this->anchor->touch('section:touch', $this->item['id'], TRUE);
}
}
示例9: sprintf
if (!strncmp($track, 'user:', 5)) {
// notify a person that is followed
if (($user = Users::get(str_replace('user:', '', $track))) && isset($user['email']) && $user['email'] && $user['without_alerts'] != 'Y') {
// contact target user by e-mail
$subject = sprintf(i18n::c('%s is following you'), strip_tags(Surfer::get_name()));
// headline
$headline = sprintf(i18n::c('%s is following you'), Surfer::get_link());
// information
$message = '<p>' . sprintf(i18n::c('%s will receive notifications when you will update your followers at %s'), Surfer::get_name(), $context['site_name']) . '</p>';
// assemble main content of this message
$message = Skin::build_mail_content($headline, $message);
// a set of links
$menu = array();
// call for action
$link = Surfer::get_permalink();
$menu[] = Skin::build_mail_button($link, ucfirst(strip_tags(Surfer::get_name())), TRUE);
// finalize links
$message .= Skin::build_mail_menu($menu);
// enable threading
$headers = Mailer::set_thread('user:' . $item['id']);
// sent by the server
Mailer::notify(NULL, $user['email'], $subject, $message, $headers);
}
// feed-back to poster
$context['text'] .= '<p>' . sprintf(i18n::s('You have been connected to %s.'), Skin::build_link($anchor->get_url(), $anchor->get_title())) . "</p>\n";
$menu[] = Skin::build_link(Users::get_url($track, 'track'), i18n::s('I have changed my mind'), 'span');
// we are tracking a page
} else {
// reference the anchor page
if (is_object($anchor) && $anchor->is_viewable()) {
$context['text'] .= '<p>' . Skin::build_link($anchor->get_url(), $anchor->get_title()) . "</p>\n";
示例10: elseif
// end of the installation
} elseif (!file_exists('parameters/switch.on') && !file_exists('parameters/switch.off')) {
// create the switch
$content = '---------------------------------------------' . "\n" . 'YACS will process requests if this file is named switch.on,' . "\n" . 'and will redirect everything to control/closed.php if its name is changed to switch.off.' . "\n" . "\n" . 'Associates can use the script control/switch.php to stop and restart remotely.' . "\n" . '---------------------------------------------' . "\n";
if (!Safe::file_put_contents('parameters/switch.on', $content)) {
// not enough rights to write the file
Logger::error(i18n::s('ERROR: YACS cannot create the file parameters/switch.on to activate the server.'));
// allow for a manual update
$context['text'] .= '<p style="text-decoration: blink;">' . sprintf(i18n::s('To actually switch on the server, please copy and paste following lines by yourself in file %s.'), 'parameters/switch.on') . "</p>\n";
// content of the switch file
$context['text'] .= '<pre>' . $content . "</pre>\n";
}
// if there is no index at the upper level
if (!file_exists($context['path_to_root'] . '../index.php') && ($content = Safe::file_get_contents($context['path_to_root'] . 'index.php'))) {
// silently attempt to duplicate our index
Safe::file_put_contents('../index.php', $content);
// remember this for the next incremental update
$content = '<?php' . "\n" . '// This file has been created by the setup script setup.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . '$context[\'home_at_root\']=\'Y\';' . "\n" . '$context[\'reference_server\']=\'' . addcslashes(i18n::s('www.yacs.fr'), "\\'") . "';\n" . '?>' . "\n";
Safe::file_put_contents('parameters/scripts.include.php', $content);
}
// the splash message
$context['text'] .= sprintf(i18n::s("<p>You have passed through the several installation steps.</p>\nWhat do you want to do now?<ul>\n<li>Select %s for your site.</li>\n<li>Populate your site with the %s.</li>\n<li>Manage everything from the %s.</li>\n<li>Check the %s of this site.</li>\n<li>Review %s.</li>\n<li>%s.</li>\n<li>Look at the %s.</li>\n<li>Visit %s to learn more.</li>\n</ul>\n<p>Thank you for having selected to use YACS for your web site.</p>\n"), Skin::build_link('skins/', i18n::s('another skin')), Skin::build_link('help/populate.php', i18n::s('Content Assistant')), Skin::build_link('control/', i18n::s('Control Panel')), Skin::build_link($context['url_to_root'], i18n::s('front page')), Skin::build_link('users/view.php', i18n::s('your profile')), Skin::build_link('articles/edit.php', i18n::s('Add a page')), Skin::build_link('help/', i18n::s('Help index')), Skin::build_link(i18n::s('http://www.yacs.fr/'), i18n::s('www.yacs.fr'), 'external')) . "\n";
// no need for installation
} else {
// the splash message
$context['text'] .= i18n::s('<p>Since basic configuration files exist on your server, it is likely that the installation has been achieved successfully. Click on the link below to modify the running parameters of your server.</p>') . "\n";
// to the control panel
$context['text'] .= '<p><a href="control/">' . i18n::s('Control Panel') . "</a></p>\n";
}
// render the skin
render_skin();
示例11: get_permalink
/**
* get profile address for this surfer, if known
*
* @return string web link to the target user profile, or NULL
*/
public static function get_permalink()
{
global $context;
if (Surfer::get_id() && is_callable(array('Users', 'get_url'))) {
return $context['url_to_home'] . $context['url_to_root'] . Users::get_url(Surfer::get_id(), 'view', Surfer::get_name());
}
return NULL;
}
示例12: stop_meeting
/**
* stop a meeting
*
*/
function stop_meeting()
{
global $context;
// move to the 'closed' status
$fields = array('status' => 'stopped');
$this->set_values($fields);
// track the end of the meeting
include_once $context['path_to_root'] . 'comments/comments.php';
if (is_callable(array($this->anchor, 'get_reference')) && !$this->anchor->has_option('no_comments')) {
$fields = array();
$fields['anchor'] = $this->anchor->get_reference();
$fields['description'] = sprintf(i18n::s('%s has stopped the meeting'), Surfer::get_name());
$fields['type'] = 'notification';
Comments::post($fields);
}
}
示例13: has_virus
/**
* scan a file for viruses
*
* This function connects to ClamAV daemon, if possible, to scan the referred file.
*
* @param string absolute path of the file to scan
* @return string 'Y' if the file has been infected, '?' if clamav is not available, or 'N' if no virus has been found
*/
public static function has_virus($file)
{
global $context;
// file scanning must be configured
if (!isset($context['clamav_check']) || $context['clamav_check'] === 'N') {
return 'N';
}
// we can't connect to clamav daemon
$server = 'localhost';
if (!($handle = Safe::fsockopen($server, 3310, $errno, $errstr, 1))) {
if ($context['with_debug'] == 'Y') {
Logger::remember('files/files.php: Unable to connect to CLAMAV daemon', '', 'debug');
}
return '?';
}
// ensure enough execution time
Safe::set_time_limit(30);
// scan uploaded file
$request = 'SCAN ' . $file;
fputs($handle, $request . CRLF);
if ($context['with_debug'] == 'Y') {
Logger::remember('files/files.php: CLAMAV ->', $request, 'debug');
}
// expecting an OK
if (($reply = fgets($handle)) === FALSE) {
Logger::remember('files/files.php: No reply to SCAN command at ' . $server);
fclose($handle);
return '?';
}
if ($context['with_debug'] == 'Y') {
Logger::remember('files/files.php: CLAMAV <-', $reply, 'debug');
}
// file has been infected!
if (!stripos($reply, ': ok')) {
Logger::remember('files/files.php: Infected upload by ' . Surfer::get_name());
fclose($handle);
return 'Y';
}
// everything is ok
fclose($handle);
return 'N';
}
示例14: elseif
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// maybe this article cannot be modified anymore
} elseif (isset($item['locked']) && $item['locked'] == 'Y' && !Surfer::is_empowered()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('This page has been locked.'));
// do the job
} else {
// attributes to change
$fields = array();
$fields['id'] = $item['id'];
$fields['anchor'] = $destination->get_reference();
// do the change
if (Articles::put_attributes($fields)) {
// only when comments are allowed
if (!Articles::has_option('no_comments', $anchor, $item)) {
// add a comment to make the move explicit
include_once $context['path_to_root'] . 'comments/comments.php';
$fields = array();
$fields['anchor'] = 'article:' . $item['id'];
$fields['description'] = sprintf(i18n::s('Moved by %s from %s to %s'), Surfer::get_name(), $anchor->get_title(), $destination->get_title());
Comments::post($fields);
}
// update previous container
Cache::clear($anchor->get_reference());
// switch to the updated page
Safe::redirect(Articles::get_permalink($item));
}
}
// render the skin
render_skin();
示例15: footer
/**
* echo the standard footer
*
* Note that this one does not echo $context['page_footer'], and you have
* to do it yourself.
*
* @param string footer prefix, if any
* @param string footer suffix, if any
*/
public static function footer($prefix = '', $suffix = '')
{
global $context;
// the last paragraph
echo '<p>';
// add footer prefix
echo $prefix;
$details = array();
// execution time and surfer name, for logged user only (not for indexing robots!)
if (is_callable(array('Surfer', 'get_name')) && is_callable(array('i18n', 's'))) {
$execution_time = round(get_micro_time() - $context['start_time'], 2);
$details[] = sprintf(i18n::s('page prepared in %.2f seconds for %s'), $execution_time, ucwords(Surfer::get_name()));
}
// site copyright
if (isset($context['site_copyright']) && $context['site_copyright']) {
$details[] = '© ' . $context['site_copyright'] . "\n";
}
// a command to authenticate
if (is_callable(array('Surfer', 'is_logged')) && !Surfer::is_logged() && is_callable(array('i18n', 's'))) {
$details[] = Skin::build_link('users/login.php', i18n::s('login'), 'basic');
}
// about this site
if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) {
$details[] = Skin::build_link(Articles::get_url('about'), i18n::s('about this site'), 'basic');
}
// privacy statement
if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) {
$details[] = Skin::build_link(Articles::get_url('privacy'), i18n::s('privacy statement'), 'basic');
}
// a reference to YACS
if (is_callable(array('i18n', 's')) && $context['host_name'] != 'www.yacs.fr') {
$details[] = sprintf(i18n::s('powered by %s'), Skin::build_link(i18n::s('http://www.yacs.fr/'), 'Yacs', 'external'));
}
// all our feeds
if (is_callable(array('i18n', 's'))) {
$details[] = Skin::build_link('feeds/', i18n::s('information channels'), 'basic');
}
echo join(' - ', $details);
// add footer suffix
echo $suffix;
// end of the last paragraph
echo '</p>' . "\n";
}