本文整理汇总了PHP中SQL::strtotime方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::strtotime方法的具体用法?PHP SQL::strtotime怎么用?PHP SQL::strtotime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::strtotime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list images
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the anchor for this image
if ($item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// url to view the image
$url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the title as the label
if ($item['title']) {
$label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
} else {
$label = $item['image_name'];
}
// the section
$section = '';
if (is_object($anchor)) {
$section = ucfirst($anchor->get_title());
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = $item['create_address'] . ' (' . $item['create_name'] . ')';
if ($item['create_address'] != $item['edit_address']) {
if ($author) {
$author .= ', ';
}
$author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
}
// the description
$description = Codes::beautify($item['description']);
// cap the number of words
$description = Skin::cap($description, 300);
// fix image references
$description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
$introduction = $description;
// other rss fields
$extensions = array();
// url for enclosure
$type = Files::get_mime_type($item['image_name']);
$extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
// list all components for this item
$items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
}
// end of processing
SQL::free($result);
return $items;
}
示例2: layout
/**
* list dates
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// build the calendar
$text = 'BEGIN:VCALENDAR' . CRLF . 'VERSION:2.0' . CRLF . 'PRODID:YACS' . CRLF . 'METHOD:PUBLISH' . CRLF;
// organization, if any
if (isset($context['site_name']) && $context['site_name']) {
$text .= 'X-WR-CALNAME:' . $context['site_name'] . CRLF;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// one event at a time
$text .= 'BEGIN:VEVENT' . CRLF;
// the event spans limited time
if (isset($item['duration']) && $item['duration']) {
$text .= 'DTSTART:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp'])) . CRLF;
$text .= 'DTEND:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp']) + $item['duration'] * 60) . CRLF;
// a full-day event
} else {
$text .= 'DTSTART;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp'])) . CRLF;
$text .= 'DTEND;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp']) + 86400) . CRLF;
}
// url to view the date
$text .= 'URL:' . Articles::get_permalink($item) . CRLF;
// organization, if any
if (isset($item['introduction']) && $item['introduction']) {
$text .= 'DESCRIPTION:' . str_replace(array("\n", "\r"), ' ', strip_tags($item['introduction'])) . CRLF;
}
// build a valid title
if (isset($item['title']) && $item['title']) {
$text .= 'SUMMARY:' . Codes::beautify_title($item['title']) . CRLF;
}
// required by Outlook 2003
if (isset($item['id']) && $item['id']) {
$text .= 'UID:' . $item['id'] . CRLF;
}
// date of creation
if (isset($item['create_date']) && $item['create_date']) {
$text .= 'CREATED:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['create_date'])) . CRLF;
}
// date of last modification
if (isset($item['edit_date']) && $item['edit_date']) {
$text .= 'DTSTAMP:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF;
}
// next event
$text .= 'SEQUENCE:0' . CRLF . 'END:VEVENT' . CRLF;
}
// date of last update
$text .= 'END:VCALENDAR' . CRLF;
// end of processing
SQL::free($result);
return $text;
}
示例3: layout
/**
* list links
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @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
while ($item = SQL::fetch($result)) {
// get the anchor for this link
if ($item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// url is the link itself
$url = $item['link_url'];
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the title as the label
if ($item['title']) {
$label = $item['title'];
} else {
$label = $url;
}
// the section
$section = '';
if (is_object($anchor)) {
$section = ucfirst($anchor->get_title());
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = $item['edit_address'] . ' (' . $item['edit_name'] . ')';
// the description
$description = Codes::beautify($item['description']);
// cap the number of words
$description = Skin::cap($description, 300);
// fix image references
$description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
$introduction = $description;
// other rss fields
$extensions = array();
// list all components for this item
$items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
}
// end of processing
SQL::free($result);
return $items;
}
示例4: layout
/**
* list users
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// url to view the user profile
$url = Users::get_permalink($item);
// time of last update
$time = SQL::strtotime($item['edit_date']);
// item title
if ($item['full_name']) {
$label = ucfirst(Skin::strip($item['full_name'], 10));
} else {
$label = ucfirst(Skin::strip($item['nick_name'], 10));
}
// the section
$section = '';
// the author(s) is an e-mail address, according to rss 2.0 spec
$author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
// introduction
$introduction = Codes::beautify($item['introduction']);
// the description
$description = Codes::beautify($item['description']);
// cap the number of words
$description = Skin::cap($description, 300);
// fix image references
$description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
// other rss fields
$extensions = array();
// list all components for this item
$items[$url] = array($time, $label, $author, $section, $icon, $introduction, $description, $extensions);
}
// end of processing
SQL::free($result);
return $items;
}
示例5: touch
//.........这里部分代码省略.........
$query[] = "description = '" . SQL::escape($this->item['description'] . ' ' . $label) . "'";
}
// suppress references to a deleted file
} elseif ($action == 'file:delete' && $origin) {
// suppress reference in main description field
$text = Codes::delete_embedded($this->item['description'], 'download', $origin);
$text = Codes::delete_embedded($text, 'embed', $origin);
$text = Codes::delete_embedded($text, 'file', $origin);
// save changes
$query[] = "description = '" . SQL::escape($text) . "'";
// append a reference to a new image to the description
} elseif ($action == 'image:create' && $origin) {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$this->item['description'] .= ' [image=' . $origin . ']';
} else {
$this->item['description'] .= "\n\n" . '[image=' . $origin . ']';
}
$query[] = "description = '" . SQL::escape($this->item['description']) . "'";
}
}
// also use it as thumnail if none has been defined yet
if (!isset($this->item['thumbnail_url']) || !trim($this->item['thumbnail_url'])) {
include_once $context['path_to_root'] . 'images/images.php';
if (($image = Images::get($origin)) && ($url = Images::get_thumbnail_href($image))) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
// 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' && $origin) {
// 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 article icon
} elseif ($action == 'image:set_as_icon' && $origin) {
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) . "'";
示例6: touch
//.........这里部分代码省略.........
if ($label) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' ' . $label) . "'";
}
// suppress references to a deleted file
} elseif ($action == 'file:delete') {
// suppress reference in main description field
$text = Codes::delete_embedded($this->item['description'], 'download', $origin);
$text = Codes::delete_embedded($text, 'embed', $origin);
$text = Codes::delete_embedded($text, 'file', $origin);
// save changes
$query[] = "description = '" . SQL::escape($text) . "'";
// append a reference to a new image to the description
} elseif ($action == 'image:create') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
} else {
$query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
}
}
}
// also use it as thumnail if none has been defined yet
if (!isset($this->item['thumbnail_url']) || !trim($this->item['thumbnail_url'])) {
include_once $context['path_to_root'] . 'images/images.php';
if (($image = Images::get($origin)) && ($url = Images::get_thumbnail_href($image))) {
$query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
}
}
// 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 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) . "'";
示例7: while
/**
* wait for updates
*
* This script will wait for new updates before providing them to caller.
* Because of potential time-outs, you have to care of retries.
*
* @param string reference to thread (e.g., 'article:123')
* @param string timestamp of previous update
* @return array attributes including new comments and a timestamp
*
* @see articles/view_as_chat.php
* @see comments/thread.php
*/
public static function &pull($anchor, $stamp, $count = 100)
{
global $context;
$timer = 1;
// some implementations will kill network connections earlier anyway
Safe::set_time_limit(max(30, $timer));
// we return formatted text
$text = '';
// sanity check
if (!$anchor) {
return $text;
}
// the query to get time of last update
$query = "SELECT edit_date, edit_name FROM " . SQL::table_name('comments') . " AS comments " . " WHERE comments.anchor LIKE '" . SQL::escape($anchor) . "'" . " ORDER BY comments.edit_date DESC" . " LIMIT 1";
// we may timeout ourself, to be safe with network resources
while (!($stat = SQL::query_first($query)) || isset($stat['edit_date']) && $stat['edit_date'] <= $stamp) {
// kill the request to avoid repeated transmissions when nothing has changed
if (--$timer < 1) {
http::no_content();
die;
}
// preserve server resources
sleep(1);
}
// return an array of variables
$response = array();
$response['items'] =& Comments::list_by_thread_for_anchor($anchor, 0, $count, 'thread');
$response['name'] = strip_tags($stat['edit_name']);
$response['timestamp'] = SQL::strtotime($stat['edit_date']);
// return by reference
return $response;
}
示例8: sprintf
$details[] = EXPIRED_FLAG . ' ' . sprintf(i18n::s('Category has expired %s'), Skin::build_date($item['expiry_date']));
}
// display details, if any
if (count($details)) {
$context['page_details'] .= ucfirst(implode(BR, $details)) . BR;
}
// other details
$details = array();
// additional details for associates and editors
if (Surfer::is_associate() || is_object($anchor) && $anchor->is_assigned()) {
// the creator of this category
if ($item['create_date']) {
$details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date']));
}
// hide last edition if done by creator, and if less than 24 hours between creation and last edition
if ($item['create_date'] && $item['create_id'] == $item['edit_id'] && SQL::strtotime($item['create_date']) + 24 * 60 * 60 >= SQL::strtotime($item['edit_date'])) {
} else {
if ($item['edit_action']) {
$action = Anchors::get_action_label($item['edit_action']);
} else {
$action = i18n::s('edited');
}
$details[] = sprintf(i18n::s('%s by %s %s'), $action, Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// the number of hits
if ($item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// rank for this section
if (intval($item['rank']) != 10000 && Surfer::is_associate()) {
$details[] = '{' . $item['rank'] . '}';
示例9: layout
/**
* list articles
*
* @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
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'category:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// provide an absolute link
$url = Categories::get_permalink($item);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the section
$root = '';
if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$root = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
}
// the icon to use
$icon = '';
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) {
$icon = $anchor->get_bullet_url();
}
if ($icon) {
$icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = '';
if (isset($item['create_address'])) {
$author .= $item['create_address'];
}
if (isset($item['create_name']) && trim($item['create_name'])) {
$author .= ' (' . $item['create_name'] . ')';
}
if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) {
if ($author) {
$author .= ', ';
}
$author .= $item['edit_address'];
if (isset($item['edit_name']) && trim($item['edit_name'])) {
$author .= ' (' . $item['edit_name'] . ')';
}
}
// list all components for this item
$items[$url] = array($time, $title, $author, $root, $icon, '', '', '');
}
// end of processing
SQL::free($result);
return $items;
}
示例10: date
// phone number, if any
if (isset($agent['phone_number']) && $agent['phone_number']) {
$text .= 'TEL;PREF:' . $agent['phone_number'] . "\r\n";
}
// alternate number, if any
if (isset($agent['alternate_number']) && $agent['alternate_number']) {
$text .= 'TEL;MSG:' . $agent['alternate_number'] . "\r\n";
}
// web mail, if any
if (isset($agent['email']) && $agent['email']) {
$text .= 'EMAIL;PREF;INTERNET:' . $agent['email'] . "\r\n";
}
$text .= 'END:VCARD' . "\r\n";
}
// date of last update
$text .= 'REV:' . date('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF . 'END:VCARD' . CRLF;
//
// transfer to the user agent
//
// no encoding, no compression and no yacs handler...
if (!headers_sent()) {
Safe::header('Content-Type: text/x-vcard');
Safe::header('Content-Transfer-Encoding: binary');
Safe::header('Content-Length: ' . strlen($text));
}
// suggest a download
if (!headers_sent()) {
$file_name = utf8::to_ascii(Skin::strip($context['page_title']) . '.vcf');
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
示例11: tick_hook
/**
* process deferred messages
*
* Most often, the server has to stay below a given rate of messages,
* for example 50 messages per hour.
*
* Of course, any lively community will feature bursts of activity and of
* messages, therefore the need for a shaping mechanism.
*
* YACS implements a leaking bucket algorithm to take care of messages sent
* previously:
*
* 1. Initially, the bucket is empty.
*
* 2. New messages are queued in the database, to be processed asynchronously.
*
* 3. On background ticks, the bucket is decremented. If the bucket becomes
* empty, and if some messages have been queued, a couple of them are sent, and
* the bucket is incremented accordingly.
*
* Bucket content is managed as value 'bucket.content' saved in the database.
*
* The bucket size is given by parameter $context['mail_hourly_maximum'], set
* in the configuration panel for system parameters.
*
* This parameter has a default value of 50, meaning YACS will not send more
* than 50 messages per hour.
*
* Background processing is either added to regular page generation or delegated
* to an external sub-system (e.g., cron). In case of a large site, we recommend
* to use the second solution, even if this adds additional setup steps. Your
* choice will be recorded in the configuration panel for system parameters.
*
* @see control/configure.php
*
* The number of messages sent on each tick can go up to the bucket size if
* background processing is external. Else it is one fourth of bucket size, to
* minimize impact on watching surfer.
*
* @see cron.php
*/
public static function tick_hook()
{
global $context;
// email services have to be activated
if (!isset($context['with_email']) || $context['with_email'] != 'Y') {
return;
}
// useless if we don't have a valid database connection
if (!$context['connection']) {
return;
}
// remember start time
$start = get_micro_time();
// get bucket size --force it if set to 0
if (!isset($context['mail_hourly_maximum']) || $context['mail_hourly_maximum'] < 5) {
$context['mail_hourly_maximum'] = 50;
}
// get record related to last tick
include_once $context['path_to_root'] . 'shared/values.php';
$bucket = Values::get_record('mailer.bucket.content', 0);
$bucket['value'] = intval($bucket['value']);
// some content to leak
if ($bucket['value'] > 0) {
// date of last stamp
if (isset($bucket['edit_date'])) {
$stamp = SQL::strtotime($bucket['edit_date']);
} else {
$stamp = time() - 3600;
}
// leak is maximum after one hour
$leak = intval($context['mail_hourly_maximum'] * (time() - $stamp) / 3600);
// preserve previous value until actual leak
if ($leak < 1) {
return;
}
// actual leak
$bucket['value'] = max(0, $bucket['value'] - $leak);
}
// process some messages only when bucket is empty
$count = 0;
if ($bucket['value'] < 1) {
// reduced speed if on-line processing
if (isset($_SERVER['REMOTE_ADDR'])) {
$slice = intval($context['mail_hourly_maximum'] / 4);
} else {
$slice = intval($context['mail_hourly_maximum']);
}
// get some messages, if any
$query = "SELECT * FROM " . SQL::table_name('messages') . " ORDER BY edit_date LIMIT 0, " . $slice;
if ($result = SQL::query($query)) {
// process every message
while ($item = SQL::fetch($result)) {
Mailer::process($item['recipient'], $item['subject'], $item['message'], $item['headers']);
// purge the queue
$query = 'DELETE FROM ' . SQL::table_name('messages') . ' WHERE id = ' . $item['id'];
SQL::query($query);
// fill the bucket
$bucket['value'] += 1;
$count++;
//.........这里部分代码省略.........
示例12: touch
/**
* remember the last action for this user
*
* @param string the description of the last action
* @param string the id of the item related to this update
* @param boolean TRUE to not change the edit date of this anchor, default is FALSE
*
* @see shared/anchor.php
*/
function touch($action, $origin = NULL, $silently = FALSE)
{
global $context;
// don't go further on import
if (preg_match('/import$/i', $action)) {
return;
}
// no item bound
if (!isset($this->item['id'])) {
return;
}
// sanity check
if (!$origin) {
logger::remember('users/user.php: unexpected NULL origin at touch()');
return;
}
// components of the query
$query = array();
// append a reference to a new image to the description
if ($action == 'image:create') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
} else {
$query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
}
}
}
// 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['avatar_url'] == $url) {
$query[] = "avatar_url = ''";
}
}
if ($url = Images::get_thumbnail_href($image)) {
if ($this->item['avatar_url'] == $url) {
$query[] = "avatar_url = ''";
}
}
}
// set an existing image as the user avatar
} elseif ($action == 'image:set_as_avatar') {
include_once $context['path_to_root'] . 'images/images.php';
if ($image = Images::get($origin)) {
if ($url = Images::get_icon_href($image)) {
$query[] = "avatar_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// set an existing image as the user 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[] = "avatar_url = '" . SQL::escape($url) . "'";
}
}
$silently = TRUE;
// append a new image
} elseif ($action == 'image:set_as_both') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
}
// do not remember minor changes
$silently = TRUE;
// add a reference to a location in the article description
} elseif ($action == 'location:create') {
if (!Codes::check_embedded($this->item['description'], 'location', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [location=' . $origin . ']') . "'";
}
// suppress a reference to a location that has been deleted
} elseif ($action == 'location:delete') {
$query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'location', $origin)) . "'";
// add a reference to a new table in the user description
} elseif ($action == 'table:create') {
if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [table=' . $origin . ']') . "'";
//.........这里部分代码省略.........
示例13: elseif
} elseif (isset($_REQUEST['anchor'])) {
$link = 'articles/edit.php?anchor=' . $_REQUEST['anchor'];
} else {
$link = 'articles/edit.php';
}
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode($link));
}
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// an error occured
} elseif (count($context['error'])) {
$item = $_REQUEST;
$with_form = TRUE;
// page has been assigned to another person during the last 5 minutes
} elseif (isset($item['assign_id']) && $item['assign_id'] && !Surfer::is($item['assign_id']) && SQL::strtotime($item['assign_date']) + 5 * 60 >= time()) {
// permission denied to authenticated user
Safe::header('Status: 401 Unauthorized', TRUE, 401);
$context['text'] .= Skin::build_block(sprintf(i18n::s('This page is currently edited by %s. You have to wait for a new version to be released.'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id'])), 'caution');
// process uploaded data
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
// protect from hackers
if (isset($_REQUEST['edit_name'])) {
$_REQUEST['edit_name'] = preg_replace(FORBIDDEN_IN_NAMES, '_', $_REQUEST['edit_name']);
}
if (isset($_REQUEST['edit_address'])) {
$_REQUEST['edit_address'] = encode_link($_REQUEST['edit_address']);
}
// track anonymous surfers
Surfer::track($_REQUEST);
// set options
示例14: gmdate
$text .= ' <lastBuildDate>' . gmdate('D, d M Y H:i:s') . ' GMT</lastBuildDate>' . "\n" . ' <generator>yacs</generator>' . "\n" . ' <docs>http://blogs.law.harvard.edu/tech/rss</docs>' . "\n" . ' <ttl>5</ttl>' . "\n";
// list last events
$events = Logger::get_tail(50, 'all');
if (is_array($events)) {
// the actual list of events
foreach ($events as $event) {
list($stamp, $surfer, $script, $label, $description) = $event;
// formatting patterns
$search = array("|\r\n|", "|<br\\s*/>\n+|i", "|\n\n+[ \t]*-\\s+|i", "|\n[ \t]*-\\s+|i", "|\n\n+[ \t]*\\.\\s+|i", "|\n[ \t]*\\.\\s+|i", "|\n\n+[ \t]*\\*\\s+|i", "|\n[ \t]*\\*\\s+|i", "|\n\n+[ \t]*¤\\s+|i", "|\n[ \t]*¤\\s+|i", "|\n\n+[ \t]*\\•\\s+|i", "|\n[ \t]*\\•\\s+|i", "/\n[ \t]*(From|To|cc|bcc|Subject|Date):(\\s*)/i", "|\n[ \t]*>(\\s*)|i", "|\n[ \t]*\\|(\\s*)|i", "#([\n\t ])([a-z]+?)://([^, <>{}\n\r]+)#is", "#^([a-z]+?)://([^, <>{}\n\r]+)#is", "#([\n\t ])www\\.([a-z0-9\\-]+)\\.([a-z0-9\\-.\\~]+)((?:/[^,< \n\r]*)?)#is", "#([\n\t ])([a-z0-9\\-_.]+?)@([^,< \\.\n\r]+\\.[^,< \n\r]+)#is", "|\n\n|i");
$replace = array("\n", BR, BR . BR . "- ", BR . "- ", BR . BR . "- ", BR . "- ", BR . BR . "- ", BR . "- ", BR . BR . "- ", BR . "- ", BR . BR . "• ", BR . "• ", BR . "\$1:\$2", BR . ">\$1", BR . "|\$1", "\$1<a href=\"\$2://\$3\">\$2://\$3</a>", "<a href=\"\$1://\$2\">\$1://\$2</a>", "\$1<a href=\"http://www.\$2.\$3\$4\">http://www.\$2.\$3\$4</a>", "\$1<a href=\"mailto:\$2@\$3\">\$2@\$3</a>", BR . BR);
// build an extensive description field
$description = nl2br(preg_replace($search, $replace, $description)) . '<p>' . $script . (strlen($surfer) > 1 ? ' for ' . $surfer : '') . ' on ' . $stamp . "</p>";
// build a unique id
$id = md5($label . $description . $stamp . $script . $surfer);
// output one story
$text .= "\n" . ' <item>' . "\n" . ' <title>' . encode_field(strip_tags($label)) . "</title>\n" . ' <description><![CDATA[ ' . $description . " ]]></description>\n" . ' <pubDate>' . gmdate('D, d M Y H:i:s', SQL::strtotime($stamp)) . " GMT</pubDate>\n" . ' <link>' . $context['url_to_home'] . $context['url_to_root'] . 'agents/?subject=events&id=' . $id . "</link>\n" . ' <guid isPermaLink="false">' . $id . "</guid>\n" . ' <category>' . encode_field($script) . "</category>\n" . "\t</item>\n";
}
}
// the postamble
$text .= "\n\t</channel>\n" . '</rss>';
//
// 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 = $context['site_name'] . '.events.rss.xml';
$file_name =& utf8::to_ascii($file_name);
Safe::header('Content-Disposition: inline; filename="' . str_replace('"', '', $file_name) . '"');
}
示例15: array
/**
* get date of last modification
*
* @see services/check.php
*
* @return array the attribute 'timestamp' contains time of last update
*/
function &check()
{
$response = array();
// 'timestamp'
if (!isset($this->item['edit_date'])) {
$response['timestamp'] = '';
} else {
$response['timestamp'] = SQL::strtotime($this->item['edit_date']);
}
// 'name'
if (!isset($this->item['edit_name'])) {
$response['name'] = '';
} else {
$response['name'] = strip_tags($this->item['edit_name']);
}
return $response;
}