本文整理汇总了PHP中serendipity_serverOffsetHour函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_serverOffsetHour函数的具体用法?PHP serendipity_serverOffsetHour怎么用?PHP serendipity_serverOffsetHour使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_serverOffsetHour函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: timeOffset
function timeOffset($timestamp)
{
if (function_exists('serendipity_serverOffsetHour')) {
return serendipity_serverOffsetHour($timestamp, true);
}
return $timestamp;
}
示例2: test_serendipity_serverOffsetHourWithTimestampNull
/**
* @test
* @dataProvider serverOffsetHourWithTimestampNullDataProvider
*/
public function test_serendipity_serverOffsetHourWithTimestampNull($serverOffsetHours, $negative)
{
global $serendipity;
$now = time();
$serendipity['serverOffsetHours'] = $serverOffsetHours;
$result = serendipity_serverOffsetHour(null, $negative);
if ($serverOffsetHours > 0) {
if ($negative) {
$this->assertGreaterThanOrEqual($now - $serverOffsetHours * 3600, $result);
} else {
$this->assertGreaterThan($now - $serverOffsetHours * 3600, $result);
}
} else {
$this->assertGreaterThanOrEqual($now, $result);
}
}
示例3: showPaging
function showPaging($id = false)
{
global $serendipity;
if (!$id) {
return false;
}
$links = array();
$cond = array();
$cond['and'] = " AND e.isdraft = 'false' AND e.timestamp <= " . serendipity_serverOffsetHour(time(), true);
serendipity_plugin_api::hook_event('frontend_fetchentry', $cond);
$querystring = "SELECT\n e.id, e.title, e.timestamp\n FROM\n {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n WHERE\n e.id [COMP] " . (int) $id . "\n {$cond['and']}\n ORDER BY e.id [ORDER]\n LIMIT 1";
$prevID = serendipity_db_query(str_replace(array('[COMP]', '[ORDER]'), array('<', 'DESC'), $querystring));
$nextID = serendipity_db_query(str_replace(array('[COMP]', '[ORDER]'), array('>', 'ASC'), $querystring));
if ($link = $this->makeLink($prevID)) {
$links['prev'] = $link;
}
if ($link = $this->makeLink($nextID)) {
$links['next'] = $link;
}
return $links;
}
示例4: generate_content
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', $this->title);
$intro = $this->get_config('intro');
$outro = $this->get_config('outro');
$maxlength = $this->get_config('maxlength');
$max_entries = $this->get_config('max_entries');
$min_age = $this->get_config('min_age');
$max_age = $this->get_config('max_age');
$specialage = $this->get_config('specialage');
$displaydate = $this->get_config('displaydate', 'true');
$dateformat = $this->get_config('dateformat');
$full = serendipity_db_bool($this->get_config('full'));
$displayauthor = serendipity_db_bool($this->get_config('displayauthor', false));
if (!is_numeric($min_age) || $min_age < 0 || $specialage == 'year') {
$min_age = 365 + date('L', serendipity_serverOffsetHour());
}
if (!is_numeric($max_age) || $max_age < 1 || $specialage == 'year') {
$max_age = 365 + date('L', serendipity_serverOffsetHour());
}
if (!is_numeric($max_entries) || $max_entries < 1) {
$max_entries = 5;
}
if (!is_numeric($maxlength) || $maxlength < 0) {
$maxlength = 30;
}
if (strlen($dateformat) < 1) {
$dateformat = '%a, %d.%m.%Y %H:%M';
}
$oldLim = $serendipity['fetchLimit'];
$nowts = serendipity_serverOffsetHour();
$maxts = mktime(23, 59, 59, date('m', $nowts), date('d', $nowts), date('Y', $nowts));
$mints = mktime(0, 0, 0, date('m', $nowts), date('d', $nowts), date('Y', $nowts));
$e = serendipity_fetchEntries(array($mints - $max_age * 86400, $maxts - $min_age * 86400), $full, $max_entries);
$serendipity['fetchLimit'] = $oldLim;
echo empty($intro) ? '' : '<div class="serendipity_history_intro">' . $intro . '</div>' . "\n";
if (!is_array($e)) {
return false;
}
if (($e_c = count($e)) == 0) {
return false;
}
for ($x = 0; $x < $e_c; $x++) {
$url = serendipity_archiveURL($e[$x]['id'], $e[$x]['title'], 'serendipityHTTPPath', true, array('timestamp' => $e[$x]['timestamp']));
$date = $displaydate == '0' ? '' : serendipity_strftime($dateformat, $e[$x]['timestamp']);
$author = $displayauthor ? $e[$x]['author'] . ': ' : '';
echo '<div class="serendipity_history_info">';
if ($displayauthor) {
echo '<span class="serendipity_history_author">' . $author . ' </span>';
}
if ($displaydate) {
echo '<span class="serendipity_history_date">' . $date . ' </span>';
}
$t = $maxlength == 0 || strlen($e[$x]['title']) <= $maxlength ? $e[$x]['title'] : trim(serendipity_mb('substr', $e[$x]['title'], 0, $maxlength - 3)) . ' [...]';
echo '<a href="' . $url . '" title="' . str_replace("'", "`", serendipity_specialchars($e[$x]['title'])) . '">"' . serendipity_specialchars($t) . '"</a></div>';
if ($full) {
echo '<div class="serendipity_history_body">' . strip_tags($e[$x]['body']) . '</div>';
}
}
echo empty($outro) ? '' : '<div class="serendipity_history_outro">' . $outro . '</div>';
}
示例5: serendipity_strftime
/**
* Format a timestamp
*
* This function can convert an input timestamp into specific PHP strftime() outputs, including applying necessary timezone calculations.
*
* @access public
* @param string Output format for the timestamp
* @param int Timestamp to use for displaying
* @param boolean Indicates, if timezone calculations shall be used.
* @param boolean Whether to use strftime or simply date
* @return string The formatted timestamp
*/
function serendipity_strftime($format, $timestamp = null, $useOffset = true, $useDate = false)
{
global $serendipity;
static $is_win_utf = null;
if ($is_win_utf === null) {
// Windows does not have UTF-8 locales.
$is_win_utf = LANG_CHARSET == 'UTF-8' && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false;
}
if ($useDate) {
$out = date($format, $timestamp);
} else {
switch ($serendipity['calendar']) {
default:
case 'gregorian':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
$out = strftime($format, $timestamp);
break;
case 'persian-utf8':
if ($timestamp == null) {
$timestamp = serendipity_serverOffsetHour();
} elseif ($useOffset) {
$timestamp = serendipity_serverOffsetHour($timestamp);
}
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
$out = persian_strftime_utf($format, $timestamp);
break;
}
}
if ($is_win_utf && (empty($serendipity['calendar']) || $serendipity['calendar'] == 'gregorian')) {
$out = utf8_encode($out);
}
return $out;
}
示例6: lj_update
function lj_update($eventData, $delete = '')
{
global $serendipity;
$this->check_lj_entries();
$rec_exists = false;
$itemid = 0;
$rec = serendipity_db_query("SELECT itemid FROM {$serendipity['dbPrefix']}lj_entries where entry_id=" . (int) $eventData['id'], true);
if (is_array($rec)) {
$itemid = $rec['itemid'];
$rec_exests = true;
}
if ($delete == 'delete' && $itemid == 0) {
return;
}
echo "Update LiveJournal...<br />\n";
if ($delete == 'delete') {
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}lj_entries where entry_id=" . (int) $eventData['id']);
} else {
if ($rec_exists) {
serendipity_db_update('lj_entries', array('entry_id' => round($eventData['id'])), array('itemid' => $itemid, 'current_mood' => $serendipity['POST']['ljmood'], 'current_music' => $serendipity['POST']['ljmusic'], 'picture_keyword' => $serendipity['POST']['ljuserpic'], 'security' => $serendipity['POST']['ljsecurity'], 'opt_nocomments' => $serendipity['POST']['ljcomment']));
} else {
serendipity_db_insert('lj_entries', array('entry_id' => (int) $eventData['id'], 'itemid' => $itemid, 'current_mood' => $serendipity['POST']['ljmood'], 'current_music' => $serendipity['POST']['ljmusic'], 'picture_keyword' => $serendipity['POST']['ljuserpic'], 'security' => $serendipity['POST']['ljsecurity'], 'opt_nocomments' => $serendipity['POST']['ljcomment']));
}
}
$event = $eventData['body'];
if ($eventData['extended']) {
$event .= "<br /><br /><lj-cut text='" . $this->get_config('ljcuttext') . "'>\n" . $eventData['extended'] . "</lj-cut>";
}
if ($serendipity['POST']['ljcomment'] == 1) {
$commentlink = serendipity_archiveURL($eventData['id'], $eventData['title'], 'baseURL', true, array('timestamp' => $eventData['timestamp']));
$event .= "<br /><a style=\"text-align: right\" href=\"{$commentlink}#comments\">" . PLUGIN_LJUPDATE_READCOMMENTS . "</a>";
} else {
$serendipity['POST']['ljcomment'] = 0;
}
if (empty($serendipity['POST']['ljsecurity'])) {
$serendipity['POST']['ljsecurity'] = 'public';
}
//Make LJ Entries not doublespaced
$event = str_replace("\n", "", $event);
//Replace relative with absolute URLs
$event = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\\1=\\2' . $serendipity['baseURL'] . '\\4\\2\\6>', $event);
$t = serendipity_serverOffsetHour($eventData['timestamp']);
$params['username'] = new XML_RPC_Value($this->get_config('ljusername'), 'string');
$params['hpassword'] = new XML_RPC_Value(md5($this->get_config('ljpass')), 'string');
if ($itemid != 0) {
$params['itemid'] = new XML_RPC_Value($itemid, 'string');
}
if ($delete == 'delete') {
$params['event'] = new XML_RPC_Value('', 'string');
$params['subject'] = new XML_RPC_Value('', 'string');
$params['year'] = new XML_RPC_Value('', 'string');
$params['mon'] = new XML_RPC_Value('', 'string');
$params['day'] = new XML_RPC_Value('', 'string');
$params['hour'] = new XML_RPC_Value('', 'string');
$params['min'] = new XML_RPC_Value('', 'string');
} else {
$params['event'] = new XML_RPC_Value($event, 'string');
$params['subject'] = new XML_RPC_Value($eventData['title'], 'string');
$params['year'] = new XML_RPC_Value(date('Y', $t), 'string');
$params['mon'] = new XML_RPC_Value(date('m', $t), 'string');
$params['day'] = new XML_RPC_Value(date('d', $t), 'string');
$params['hour'] = new XML_RPC_Value(date('H', $t), 'string');
$params['min'] = new XML_RPC_Value(date('i', $t), 'string');
$params['security'] = new XML_RPC_Value($serendipity['POST']['ljsecurity'], 'string');
if ($serendipity['POST']['ljsecurity'] == 'usemask') {
$params['allowmask'] = new XML_RPC_Value(1, 'string');
}
$props['current_mood'] = new XML_RPC_Value($serendipity['POST']['ljmood'], 'string');
$props['current_music'] = new XML_RPC_Value($serendipity['POST']['ljmusic'], 'string');
$props['picture_keyword'] = new XML_RPC_Value($serendipity['POST']['ljuserpic'], 'string');
$props['opt_nocomments'] = new XML_RPC_Value($serendipity['POST']['ljcomment'], 'string');
$params['props'] = new XML_RPC_Value($props, 'struct');
}
$client = new XML_RPC_Client('/interface/xmlrpc', $this->get_config('ljserver'));
$data = new XML_RPC_Value($params, 'struct');
if ($itemid == 0 && $delete != 'delete') {
$msg = new XML_RPC_Message('LJ.XMLRPC.postevent', array($data));
} else {
$msg = new XML_RPC_Message('LJ.XMLRPC.editevent', array($data));
}
$res = $client->send($msg, 10);
if ($res->faultCode() == 0) {
$v = $res->value()->getval();
$newitemid = (int) $v['itemid'];
} else {
echo htmlentities($res->faultString(), ENT_COMPAT, LANG_CHARSET) . '<br />';
$newitemid = 0;
}
if ($itemid != $newitemid && $newitemid != 0) {
serendipity_db_update('lj_entries', array('entry_id' => round($eventData['id'])), array('itemid' => $newitemid));
}
echo "Updating finished.<br />\n";
}
示例7: serendipity_drawList
//.........这里部分代码省略.........
</tr>
</table>
<script type="text/javascript">
function invertSelection() {
var f = document.formMultiDelete;
for (var i = 0; i < f.elements.length; i++) {
if (f.elements[i].type == 'checkbox') {
f.elements[i].checked = !(f.elements[i].checked);
}
}
}
</script>
<form action="?" method="post" name="formMultiDelete" id="formMultiDelete">
<?php
echo serendipity_setFormToken();
?>
<input type="hidden" name="serendipity[action]" value="admin" />
<input type="hidden" name="serendipity[adminModule]" value="entries" />
<input type="hidden" name="serendipity[adminAction]" value="multidelete" />
<?php
// Print the entries
$rows = 0;
foreach ($entries as $entry) {
$rows++;
if ($rows > $perPage) {
continue;
}
// Find out if the entry has been modified later than 30 minutes after creation
if ($entry['timestamp'] <= $entry['last_modified'] - 60 * 30) {
$lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entry['last_modified']) . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a>';
} else {
$lm = '';
}
if (!$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) {
$entry_pre = '<a href="#" title="' . ENTRY_PUBLISHED_FUTURE . '" onclick="alert(this.title)"><img src="' . serendipity_getTemplateFile('admin/img/clock_future.png') . '" alt="*" style="border: 0px none ; vertical-align: bottom;" /></a> ';
} else {
$entry_pre = '';
}
if (serendipity_db_bool($entry['properties']['ep_is_sticky'])) {
$entry_pre .= ' ' . STICKY_POSTINGS . ': ';
}
if (serendipity_db_bool($entry['isdraft'])) {
$entry_pre .= ' ' . DRAFT . ': ';
}
?>
<!-- <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php
echo $rows % 2 ? 'even' : 'uneven';
?>
"> -->
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php
echo $rows % 2 ? 'even' : 'uneven';
?>
">
<table width="100%" cellspacing="0" cellpadding="3">
<tr>
<td>
<strong><?php
echo $entry_pre;
?>
<a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=<?php
echo $entry['id'];
?>
" title="#<?php
echo $entry['id'];
?>
示例8: log
function log($logfile, $id, $switch, $reason, $comment)
{
global $serendipity;
$method = $this->get_config('logtype');
switch ($method) {
case 'file':
if (empty($logfile)) {
return;
}
if (strpos($logfile, '%') !== false) {
$logfile = strftime($logfile);
}
$fp = @fopen($logfile, 'a+');
if (!is_resource($fp)) {
return;
}
fwrite($fp, sprintf('[%s] - [%s: %s] - [#%s, Name "%s", E-Mail "%s", URL "%s", User-Agent "%s", IP %s] - [%s]' . "\n", date('Y-m-d H:i:s', serendipity_serverOffsetHour()), $switch, $reason, $id, str_replace("\n", ' ', $comment['name']), str_replace("\n", ' ', $comment['email']), str_replace("\n", ' ', $comment['url']), str_replace("\n", ' ', $_SERVER['HTTP_USER_AGENT']), $_SERVER['REMOTE_ADDR'], str_replace("\n", ' ', $comment['comment'])));
fclose($fp);
break;
case 'none':
return;
break;
case 'db':
default:
$q = sprintf("INSERT INTO {$serendipity['dbPrefix']}spamblocklog\n (timestamp, type, reason, entry_id, author, email, url, useragent, ip, referer, body)\n VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", serendipity_serverOffsetHour(), serendipity_db_escape_string($switch), serendipity_db_escape_string($reason), serendipity_db_escape_string($id), serendipity_db_escape_string($comment['name']), serendipity_db_escape_string($comment['email']), serendipity_db_escape_string($comment['url']), substr(serendipity_db_escape_string($_SERVER['HTTP_USER_AGENT']), 0, 255), serendipity_db_escape_string($_SERVER['REMOTE_ADDR']), substr(serendipity_db_escape_string(isset($_SESSION['HTTP_REFERER']) ? $_SESSION['HTTP_REFERER'] : $_SERVER['HTTP_REFERER']), 0, 255), serendipity_db_escape_string($comment['comment']));
serendipity_db_query($q);
break;
}
}
示例9: serendipity_printEntryForm
/**
* Prints the form for editing/creating new blog entries
*
* This is the core file where your edit form appears. The Heart Of Gold, so to say.
*
* @access public
* @param string The URL where the entry form is submitted to
* @param array An array of hidden input fields that should be passed on to the HTML FORM
* @param array The entry superarray with your entry's contents
* @param string Any error messages that might have occured on the last run
* @return null
*/
function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "")
{
global $serendipity;
$serendipity['EditorBrowsers'] = '@(IE|Mozilla|Opera)@i';
$draftD = '';
$draftP = '';
$categoryselector_expanded = false;
$template_vars = array();
serendipity_plugin_api::hook_event('backend_entryform', $entry);
if (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft']) || !isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') {
$draftD = ' selected="selected"';
$template_vars['draft_mode'] = 'draft';
} else {
$draftP = ' selected="selected"';
$template_vars['draft_mode'] = 'publish';
}
if (isset($entry['moderate_comments']) && serendipity_db_bool($entry['moderate_comments'])) {
$template_vars['moderate_comments'] = true;
$moderate_comments = ' checked="checked"';
} elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) {
// This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration.
$moderate_comments = ' checked="checked"';
$template_vars['moderate_comments'] = true;
} else {
$moderate_comments = '';
$template_vars['moderate_comments'] = false;
}
if (isset($entry['allow_comments']) && serendipity_db_bool($entry['allow_comments'])) {
$template_vars['allow_comments'] = true;
$allow_comments = ' checked="checked"';
} elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {
// This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration.
$template_vars['allow_comments'] = true;
$allow_comments = ' checked="checked"';
} else {
$template_vars['allow_comments'] = false;
$allow_comments = '';
}
// Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost.
if (is_array($entry['categories']) && !is_array($entry['categories'][0])) {
$categories = (array) $entry['categories'];
$entry['categories'] = array();
foreach ($categories as $catid) {
$entry['categories'][] = serendipity_fetchCategoryInfo($catid);
}
}
$n = "\n";
$cat_list = '<select id="categoryselector" name="serendipity[categories][]" style="vertical-align: middle;" multiple="multiple">' . $n;
$cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;
$selected = array();
if (is_array($entry['categories'])) {
if (count($entry['categories']) > 1) {
$categoryselector_expanded = true;
}
foreach ($entry['categories'] as $cat) {
$selected[] = $cat['categoryid'];
}
}
if (count($selected) > 1 || isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1) {
$categoryselector_expanded = true;
}
if (is_array($cats = serendipity_fetchCategories())) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ($cats as $cat) {
if (in_array($cat['categoryid'], $selected)) {
$cat['is_selected'] = true;
}
$cat['depth_pad'] = str_repeat(' ', $cat['depth']);
$template_vars['category_options'][] = $cat;
$cat_list .= '<option value="' . $cat['categoryid'] . '"' . ($cat['is_selected'] ? ' selected="selected"' : '') . '>' . $cat['depth_pad'] . $cat['category_name'] . '</option>' . "\n";
}
}
$cat_list .= '</select>' . $n;
if (!empty($serendipity['GET']['title'])) {
$entry['title'] = utf8_decode(urldecode($serendipity['GET']['title']));
}
if (!empty($serendipity['GET']['body'])) {
$entry['body'] = utf8_decode(urldecode($serendipity['GET']['body']));
}
if (!empty($serendipity['GET']['url'])) {
$entry['body'] .= "\n" . '<br /><a href="' . htmlspecialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>';
}
$hidden = '';
foreach ($hiddens as $key => $value) {
$hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $n;
}
$hidden .= ' <input type="hidden" id="entryid" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n;
$hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n;
//.........这里部分代码省略.........
示例10: serendipity_printArchives
/**
* Gather an archive listing of older entries and passes it to Smarty
*
* The archives are created according to the current timestamp and show the current year.
* $serendipity['GET']['category'] is honoured like in serendipity_fetchEntries()
* $serendipity['GET']['viewAuthor'] is honoured like in serendipity_fetchEntries()
*
* @access public
* @return null
*/
function serendipity_printArchives()
{
global $serendipity;
$f = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries ORDER BY timestamp ASC LIMIT 1");
switch ($serendipity['calendar']) {
case 'gregorian':
default:
$lastYear = date('Y', serendipity_serverOffsetHour($f[0][0]));
$lastMonth = date('m', serendipity_serverOffsetHour($f[0][0]));
$thisYear = date('Y', serendipity_serverOffsetHour());
$thisMonth = date('m', serendipity_serverOffsetHour());
break;
case 'persian-utf8':
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
$lastYear = persian_date_utf('Y', serendipity_serverOffsetHour($f[0][0]));
$lastMonth = persian_date_utf('m', serendipity_serverOffsetHour($f[0][0]));
$thisYear = persian_date_utf('Y', serendipity_serverOffsetHour());
$thisMonth = persian_date_utf('m', serendipity_serverOffsetHour());
break;
}
$max = 1;
if (isset($serendipity['GET']['category'])) {
$cat_sql = serendipity_getMultiCategoriesSQL($serendipity['GET']['category']);
$cat_get = '/C' . (int) $serendipity['GET']['category'];
} else {
$cat_sql = '';
$cat_get = '';
}
if (isset($serendipity['GET']['viewAuthor'])) {
$author_get = '/A' . (int) $serendipity['GET']['viewAuthor'];
} else {
$author_get = '';
}
if ($serendipity['dbType'] == 'postgres' || $serendipity['dbType'] == 'pdo-postgres') {
$distinct = 'DISTINCT e.id,';
} else {
$distinct = '';
}
$q = "SELECT {$distinct} e.timestamp\n FROM {$serendipity['dbPrefix']}entries e\n " . (!empty($cat_sql) ? "\n LEFT JOIN {$serendipity['dbPrefix']}entrycat ec\n ON e.id = ec.entryid\n LEFT JOIN {$serendipity['dbPrefix']}category c\n ON ec.categoryid = c.categoryid" : "") . "\n WHERE isdraft = 'false'" . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND timestamp <= " . serendipity_db_time() : '') . (!empty($cat_sql) ? ' AND ' . $cat_sql : '') . (!empty($serendipity['GET']['viewAuthor']) ? ' AND e.authorid = ' . (int) $serendipity['GET']['viewAuthor'] : '') . (!empty($cat_sql) ? " GROUP BY e.id, e.timestamp" : '');
$entries =& serendipity_db_query($q, false, 'assoc');
$group = array();
if (is_array($entries)) {
foreach ($entries as $entry) {
$group[date('Ym', $entry['timestamp'])]++;
}
}
$output = array();
for ($y = $thisYear; $y >= $lastYear; $y--) {
$output[$y]['year'] = $y;
for ($m = 12; $m >= 1; $m--) {
/* If the month we are checking are in the future, we drop it */
if ($m > $thisMonth && $y == $thisYear) {
continue;
}
/* If the month is lower than the lowest month containing entries, we're done */
if ($m < $lastMonth && $y <= $lastYear) {
break;
}
switch ($serendipity['calendar']) {
case 'gregorian':
default:
$s = serendipity_serverOffsetHour(mktime(0, 0, 0, $m, 1, $y), true);
$e = serendipity_serverOffsetHour(mktime(23, 59, 59, $m, date('t', $s), $y), true);
break;
case 'persian-utf8':
require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php';
$s = serendipity_serverOffsetHour(persian_mktime(0, 0, 0, $m, 1, $y), true);
$e = serendipity_serverOffsetHour(persian_mktime(23, 59, 59, $m, date('t', $s), $y), true);
break;
}
$entry_count = (int) $group[$y . (strlen($m) == 1 ? '0' : '') . $m];
/* A silly hack to get the maximum amount of entries per month */
if ($entry_count > $max) {
$max = $entry_count;
}
$data = array();
$data['entry_count'] = $entry_count;
$data['link'] = serendipity_archiveDateUrl($y . '/' . sprintf('%02s', $m) . $cat_get . $author_get);
$data['link_summary'] = serendipity_archiveDateUrl($y . '/' . sprintf('%02s', $m) . $cat_get . $author_get, true);
$data['date'] = $s;
$output[$y]['months'][] = $data;
}
}
$serendipity['smarty']->assign_by_ref('archives', $output);
$serendipity['smarty']->assign_by_ref('max_entries', $max);
serendipity_smarty_fetch('ARCHIVES', 'entries_archives.tpl', true);
}
示例11: serendipity_makePermalink
/**
* Format a permalink according to the configured format
*
* @access public
* @param string The URL format to use
* @param array The input data to format a permalink
* @param string The type of the permalink (entry|category|author)
* @return string The formatted permalink
*/
function serendipity_makePermalink($format, $data, $type = 'entry')
{
global $serendipity;
static $entryKeys = array('%id%', '%lowertitle%', '%title%', '%day%', '%month%', '%year%');
static $authorKeys = array('%id%', '%username%', '%realname%', '%email%');
static $categoryKeys = array('%id%', '%name%', '%parentname%', '%description%');
switch ($type) {
case 'entry':
if (!isset($data['entry']['timestamp']) && preg_match('@(%day%|%month%|%year%)@', $format)) {
// We need the timestamp to build the URI, but no timestamp has been submitted. Thus we need to fetch the data.
$ts = serendipity_db_query("SELECT timestamp FROM {$serendipity['dbPrefix']}entries WHERE id = " . (int) $data['id'], true);
if (is_array($ts)) {
$data['entry']['timestamp'] = $ts['timestamp'];
} else {
$data['entry']['timestamp'] = time();
}
}
$ts = serendipity_serverOffsetHour($data['entry']['timestamp']);
$ftitle = serendipity_makeFilename($data['title']);
$fltitle = strtolower($ftitle);
$replacements = array((int) $data['id'], $fltitle, $ftitle, date('d', $ts), date('m', $ts), date('Y', $ts));
return str_replace($entryKeys, $replacements, $format);
break;
case 'author':
$replacements = array((int) $data['authorid'], serendipity_makeFilename($data['username'], true), serendipity_makeFilename($data['realname'], true), serendipity_makeFilename($data['email'], true));
return str_replace($authorKeys, $replacements, $format);
break;
case 'category':
$parent_path = array();
// This is expensive. Only lookup if required.
if (strstr($format, '%parentname%')) {
$parents = serendipity_getCategoryRoot($data['categoryid']);
if (is_array($parents)) {
foreach ($parents as $parent) {
$parent_path[] = serendipity_makeFilename($parent['category_name'], true);
}
}
}
$replacements = array((int) $data['categoryid'], serendipity_makeFilename($data['category_name'], true), implode('/', $parent_path), serendipity_makeFilename($data['category_description'], true));
return str_replace($categoryKeys, $replacements, $format);
break;
}
return false;
}
示例12: generate_rss_fields
function generate_rss_fields(&$title, &$description, &$entries)
{
global $serendipity;
// Check for a logo to use for an RSS feed. Can either be set by configuring the
// syndication plugin OR by just placing a rss_banner.png file in the template directory.
// If both is not set, we will display our happy own branding. :-)
$bag = new serendipity_property_bag();
$this->introspect($bag);
$additional_fields = array();
if ($this->get_config('bannerURL') != '') {
$img = $this->get_config('bannerURL');
$w = $this->get_config('bannerWidth');
$h = $this->get_config('bannerHeight');
} elseif ($banner = serendipity_getTemplateFile('img/rss_banner.png', 'serendipityPath')) {
$img = serendipity_getTemplateFile('img/rss_banner.png', 'baseURL');
$i = getimagesize($banner);
$w = $i[0];
$h = $i[1];
} else {
$img = serendipity_getTemplateFile('img/s9y_banner_small.png', 'baseURL');
$w = 100;
$h = 21;
}
$additional_fields['image'] = <<<IMAGE
<image>
<url>{$img}</url>
<title>RSS: {$title} - {$description}</title>
<link>{$serendipity['baseURL']}</link>
<width>{$w}</width>
<height>{$h}</height>
</image>
IMAGE;
$additional_fields['image_atom1.0'] = <<<IMAGE
<icon>{$img}</icon>
IMAGE;
$additional_fields['image_rss1.0_channel'] = '<image rdf:resource="' . $img . '" />';
$additional_fields['image_rss1.0_rdf'] = <<<IMAGE
<image rdf:about="{$img}">
<url>{$img}</url>
<title>RSS: {$title} - {$description}</title>
<link>{$serendipity['baseURL']}</link>
<width>{$w}</width>
<height>{$h}</height>
</image>
IMAGE;
// Now, if set, stitch together any fields that have been configured in the syndication plugin.
// First, do some sanity checks
$additional_fields['channel'] = '';
foreach ($bag->get('configuration') as $bag_index => $bag_value) {
if (preg_match('|^field_(.*)$|', $bag_value, $match)) {
$bag_content = $this->get_config($bag_value);
switch ($match[1]) {
case 'pubDate':
if (serendipity_db_bool($bag_content)) {
$bag_content = gmdate('D, d M Y H:i:s \\G\\M\\T', serendipity_serverOffsetHour($entries[0]['last_modified']));
} else {
$bag_content = '';
}
break;
// Each new RSS-field which needs rewrite of its content should get its own case here.
// Each new RSS-field which needs rewrite of its content should get its own case here.
default:
break;
}
if ($bag_content != '') {
$additional_fields['channel'] .= '<' . $match[1] . '>' . $bag_content . '</' . $match[1] . '>' . "\n";
}
}
}
return $additional_fields;
}
示例13: serendipity_printEntryForm
/**
* Prints the form for editing/creating new blog entries
*
* This is the core file where your edit form appears. The Heart Of Gold, so to say.
*
* @access public
* @param string The URL where the entry form is submitted to
* @param array An array of hidden input fields that should be passed on to the HTML FORM
* @param array The entry superarray with your entry's contents
* @param string Any error messages that might have occured on the last run
* @return null
*/
function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "")
{
global $serendipity;
$draftD = '';
$draftP = '';
$categoryselector_expanded = false;
$template_vars = array();
serendipity_plugin_api::hook_event('backend_entryform', $entry);
if (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft']) || !isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') {
$draftD = ' selected="selected"';
$template_vars['draft_mode'] = 'draft';
} else {
$draftP = ' selected="selected"';
$template_vars['draft_mode'] = 'publish';
}
if (isset($entry['moderate_comments']) && serendipity_db_bool($entry['moderate_comments'])) {
$template_vars['moderate_comments'] = true;
$moderate_comments = ' checked="checked"';
} elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) {
// This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration.
$moderate_comments = ' checked="checked"';
$template_vars['moderate_comments'] = true;
} else {
$moderate_comments = '';
$template_vars['moderate_comments'] = false;
}
if (isset($entry['allow_comments']) && serendipity_db_bool($entry['allow_comments'])) {
$template_vars['allow_comments'] = true;
$allow_comments = ' checked="checked"';
} elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {
// This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration.
$template_vars['allow_comments'] = true;
$allow_comments = ' checked="checked"';
} else {
$template_vars['allow_comments'] = false;
$allow_comments = '';
}
// Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost.
if (is_array($entry['categories']) && !is_array($entry['categories'][0])) {
$categories = (array) $entry['categories'];
$entry['categories'] = array();
foreach ($categories as $catid) {
$entry['categories'][] = serendipity_fetchCategoryInfo($catid);
}
}
$selected = array();
if (is_array($entry['categories'])) {
if (count($entry['categories']) > 1) {
$categoryselector_expanded = true;
}
foreach ($entry['categories'] as $cat) {
$selected[] = $cat['categoryid'];
}
}
if (count($selected) > 1 || isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1) {
$categoryselector_expanded = true;
}
if (is_array($cats = serendipity_fetchCategories())) {
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ($cats as $cat) {
if (in_array($cat['categoryid'], $selected)) {
$cat['is_selected'] = true;
}
$cat['depth_pad'] = str_repeat(' ', $cat['depth']);
$template_vars['category_options'][] = $cat;
}
}
if (!empty($serendipity['GET']['title'])) {
$entry['title'] = utf8_decode(urldecode($serendipity['GET']['title']));
}
if (!empty($serendipity['GET']['body'])) {
$entry['body'] = utf8_decode(urldecode($serendipity['GET']['body']));
}
if (!empty($serendipity['GET']['url'])) {
$entry['body'] .= "\n" . '<a class="block_level" href="' . serendipity_specialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>';
}
$template_vars['formToken'] = serendipity_setFormToken();
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) {
$template_vars['allowDateManipulation'] = true;
}
if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) {
$template_vars['show_wysiwyg'] = true;
}
$template_vars['wysiwyg_advanced'] = true;
$template_vars['timestamp'] = serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time());
$template_vars['reset_timestamp'] = serendipity_serverOffsetHour(time());
$template_vars['hiddens'] = $hiddens;
$template_vars['errMsg'] = $errMsg;
//.........这里部分代码省略.........
示例14: generateDelayed
function generateDelayed()
{
global $serendipity;
$this->upgradeCheck();
$sql = "SELECT id, timestamp\n FROM\n {$serendipity['dbPrefix']}delayed_trackbacks";
$entries = serendipity_db_query($sql);
if (is_array($entries) && !empty($entries)) {
foreach ($entries as $entry) {
if ($entry['timestamp'] <= serendipity_serverOffsetHour()) {
include_once S9Y_INCLUDE_PATH . 'include/functions_trackbacks.inc.php';
$stored_entry = serendipity_fetchEntry('id', $entry['id'], 1, 1);
if (isset($_SESSION['serendipityRightPublish'])) {
$oldPublighRights = $_SESSION['serendipityRightPublish'];
} else {
$oldPublighRights = 'unset';
}
$_SESSION['serendipityRightPublish'] = true;
#remove unnatural entry-data which let the update fail
if (isset($stored_entry['loginname'])) {
unset($stored_entry['loginname']);
}
if (isset($stored_entry['email'])) {
unset($stored_entry['email']);
}
# Convert fetched categories to storable categories.
$current_cat = $stored_entry['categories'];
$stored_entry['categories'] = array();
foreach ($current_cat as $categoryidx => $category_data) {
$stored_entry['categories'][$category_data['categoryid']] = $category_data['categoryid'];
}
ob_start();
serendipity_updertEntry($stored_entry);
ob_end_clean();
if ($oldPublighRights == 'unset') {
unset($_SESSION['serendipityRightPublish']);
} else {
$_SESSION['serendipityRightPublish'] = $oldPublighRights;
}
#the trackbacks are now generated
$this->removeDelayed($entry['id']);
}
}
}
}
示例15: serendipity_printEntries_rss
/**
* Parses entries to display them for RSS/Atom feeds to be passed on to generic Smarty templates
*
* This function searches for existing RSS feed template customizations. As long as a template
* with the same name as the $version variable exists, it will be emitted.
*
* @access public
* @see serendipity_fetchEntries(), rss.php
* @param array A superarray of entries to output
* @param string The version/type of a RSS/Atom feed to display (atom1_0, rss2_0 etc)
* @param boolean If true, this is a comments feed. If false, it's an Entry feed.
* @param boolean Indicates if this feed is a fulltext feed (true) or only excercpt (false)
* @param boolean Indicates if E-Mail addresses should be shown (true) or hidden (false)
* @return
*/
function serendipity_printEntries_rss(&$entries, $version, $comments = false, $fullFeed = false, $showMail = true)
{
global $serendipity;
$options = array('version' => $version, 'comments' => $comments, 'fullFeed' => $fullFeed, 'showMail' => $showMail);
serendipity_plugin_api::hook_event('frontend_entries_rss', $entries, $options);
if (is_array($entries)) {
foreach ($entries as $key => $_entry) {
$entry =& $entries[$key];
if (isset($entry['entrytimestamp'])) {
$e_ts = $entry['entrytimestamp'];
} else {
$e_ts = $entry['timestamp'];
}
$entry['feed_id'] = isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id'];
// set feed guid only, if not already defined externaly
if (empty($entry['feed_guid'])) {
$entry['feed_guid'] = serendipity_rss_getguid($entry, $options['comments']);
}
$entry['feed_entryLink'] = serendipity_archiveURL($entry['feed_id'], $entry['title'], 'baseURL', true, array('timestamp' => $e_ts));
if ($options['comments'] == true) {
// Display username as part of the title for easier feed-readability
if ($entry['type'] == 'TRACKBACK' && !empty($entry['ctitle'])) {
$entry['author'] .= ' - ' . $entry['ctitle'];
}
$entry['title'] = (!empty($entry['author']) ? $entry['author'] : ANONYMOUS) . ': ' . $entry['title'];
// No HTML allowed here:
$entry['body'] = strip_tags($entry['body']);
}
// Embed a link to extended entry, if existing
if ($options['fullFeed']) {
$entry['body'] .= ' ' . $entry['extended'];
$ext = '';
} elseif ($entry['exflag']) {
$ext = '<br /><a href="' . $entry['feed_entryLink'] . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';
} else {
$ext = '';
}
$addData = array('from' => 'functions_entries:printEntries_rss', 'rss_options' => $options);
serendipity_plugin_api::hook_event('frontend_display', $entry, $addData);
// Do some relative -> absolute URI replacing magic. Replaces all HREF/SRC (<a>, <img>, ...) references to only the serendipitypath with the full baseURL URI
// garvin: Could impose some problems. Closely watch this one.
$entry['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\\1=\\2' . $serendipity['baseURL'] . '\\4\\2\\6>', $entry['body']);
// jbalcorn: clean up body for XML compliance as best we can.
$entry['body'] = xhtml_cleanup($entry['body']);
// extract author information
if (isset($entry['no_email']) && $entry['no_email'] || $options['showMail'] === FALSE) {
$entry['email'] = 'nospam@example.com';
// RSS Feeds need an E-Mail address!
} elseif (empty($entry['email'])) {
$query = "select email FROM {$serendipity['dbPrefix']}authors WHERE authorid = '" . serendipity_db_escape_string($entry['authorid']) . "'";
$results = serendipity_db_query($query);
$entry['email'] = $results[0]['email'];
}
if (!is_array($entry['categories'])) {
$entry['categories'] = array(0 => array('category_name' => $entry['category_name'], 'feed_category_name' => serendipity_utf8_encode(htmlspecialchars($entry['category_name'])), 'categoryURL' => serendipity_categoryURL($entry, 'baseURL')));
} else {
foreach ($entry['categories'] as $cid => $_cat) {
$cat =& $entry['categories'][$cid];
$cat['categoryURL'] = serendipity_categoryURL($cat, 'baseURL');
$cat['feed_category_name'] = serendipity_utf8_encode(htmlspecialchars($cat['category_name']));
}
}
// Prepare variables
// 1. UTF8 encoding + htmlspecialchars.
$entry['feed_title'] = serendipity_utf8_encode(htmlspecialchars($entry['title']));
$entry['feed_blogTitle'] = serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle']));
$entry['feed_title'] = serendipity_utf8_encode(htmlspecialchars($entry['title']));
$entry['feed_author'] = serendipity_utf8_encode(htmlspecialchars($entry['author']));
$entry['feed_email'] = serendipity_utf8_encode(htmlspecialchars($entry['email']));
// 2. gmdate
$entry['feed_timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour($entry['timestamp']));
$entry['feed_last_modified'] = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour($entry['last_modified']));
$entry['feed_timestamp_r'] = date('r', serendipity_serverOffsetHour($entry['timestamp']));
// 3. UTF8 encoding
$entry['feed_body'] = serendipity_utf8_encode($entry['body']);
$entry['feed_ext'] = serendipity_utf8_encode($ext);
$entry_hook = 'frontend_display:unknown:per-entry';
switch ($version) {
case 'opml1.0':
$entry_hook = 'frontend_display:opml-1.0:per_entry';
break;
case '0.91':
$entry_hook = 'frontend_display:rss-0.91:per_entry';
break;
case '1.0':
//.........这里部分代码省略.........