function timeOffset($timestamp) { if (function_exists('serendipity_serverOffsetHour')) { return serendipity_serverOffsetHour($timestamp, true); } return $timestamp; }
/** * @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); } }
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; }
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>'; }
/** * 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; }
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"; }
/** * Shows the entry panel overview * * Shows a list of existing entries, with pagination and cookie-remember settings. * * @access public * @return null */ function serendipity_drawList() { global $serendipity, $sort_order, $per_page; $filter_import = array('author', 'category', 'isdraft'); $sort_import = array('perPage', 'ordermode', 'order'); foreach ($filter_import as $f_import) { serendipity_restoreVar($serendipity['COOKIE']['entrylist_filter_' . $f_import], $serendipity['GET']['filter'][$f_import]); serendipity_JSsetCookie('entrylist_filter_' . $f_import, $serendipity['GET']['filter'][$f_import]); } foreach ($sort_import as $s_import) { serendipity_restoreVar($serendipity['COOKIE']['entrylist_sort_' . $s_import], $serendipity['GET']['sort'][$s_import]); serendipity_JSsetCookie('entrylist_sort_' . $s_import, $serendipity['GET']['sort'][$s_import]); } $perPage = !empty($serendipity['GET']['sort']['perPage']) ? $serendipity['GET']['sort']['perPage'] : $per_page[0]; $page = (int) $serendipity['GET']['page']; $offSet = $perPage * $page; if (empty($serendipity['GET']['sort']['ordermode']) || $serendipity['GET']['sort']['ordermode'] != 'ASC') { $serendipity['GET']['sort']['ordermode'] = 'DESC'; } if (!empty($serendipity['GET']['sort']['order']) && !empty($sort_order[$serendipity['GET']['sort']['order']])) { $orderby = serendipity_db_escape_string($serendipity['GET']['sort']['order'] . ' ' . $serendipity['GET']['sort']['ordermode']); } else { $orderby = 'timestamp ' . serendipity_db_escape_string($serendipity['GET']['sort']['ordermode']); } $filter = array(); if (!empty($serendipity['GET']['filter']['author'])) { $filter[] = "e.authorid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['author']) . "'"; } if (!empty($serendipity['GET']['filter']['category'])) { $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter']['category']) . "'"; } if (!empty($serendipity['GET']['filter']['isdraft'])) { if ($serendipity['GET']['filter']['isdraft'] == 'draft') { $filter[] = "e.isdraft = 'true'"; } elseif ($serendipity['GET']['filter']['isdraft'] == 'publish') { $filter[] = "e.isdraft = 'false'"; } } if (!empty($serendipity['GET']['filter']['body'])) { if ($serendipity['dbType'] == 'mysql') { $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($serendipity['GET']['filter']['body']) . "')"; $full = true; } } $filter_sql = implode(' AND ', $filter); // Fetch the entries $entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage + 1), true, false, $orderby, $filter_sql); ?> <div class="serendipity_admin_list"> <form action="?" method="get"> <input type="hidden" name="serendipity[action]" value="admin" /> <input type="hidden" name="serendipity[adminModule]" value="entries" /> <input type="hidden" name="serendipity[adminAction]" value="editSelect" /> <table width="100%" class="serendipity_admin_filters"> <tr> <td class="serendipity_admin_filters_headline" colspan="6"><strong><?php echo FILTERS; ?> </strong> - <?php echo FIND_ENTRIES; ?> </td> </tr> <tr> <td valign="top" width="80"><?php echo AUTHOR; ?> </td> <td valign="top"> <select name="serendipity[filter][author]"> <option value="">--</option> <?php $users = serendipity_fetchUsers('', null, true); if (is_array($users)) { foreach ($users as $user) { if (isset($user['artcount']) && $user['artcount'] < 1) { continue; } echo '<option value="' . $user['authorid'] . '" ' . (isset($serendipity['GET']['filter']['author']) && $serendipity['GET']['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n"; } } ?> </select> <select name="serendipity[filter][isdraft]"> <option value="all"><?php echo COMMENTS_FILTER_ALL; ?> </option> <option value="draft" <?php echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'draft' ? 'selected="selected"' : ''; ?> ><?php echo DRAFT; ?> </option> <option value="publish" <?php echo isset($serendipity['GET']['filter']['isdraft']) && $serendipity['GET']['filter']['isdraft'] == 'publish' ? 'selected="selected"' : ''; ?> ><?php echo PUBLISH; ?> </option> </select> </td> <td valign="top" width="80"><?php echo CATEGORY; ?> </td> <td valign="top"> <select name="serendipity[filter][category]"> <option value="">--</option> <?php $categories = serendipity_fetchCategories(); $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); foreach ($categories as $cat) { echo '<option value="' . $cat['categoryid'] . '"' . ($serendipity['GET']['filter']['category'] == $cat['categoryid'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . htmlspecialchars($cat['category_name']) . '</option>' . "\n"; } ?> </select> </td> <td valign="top" width="80"><?php echo CONTENT; ?> </td> <td valign="top"><input class="input_textbox" size="10" type="text" name="serendipity[filter][body]" value="<?php echo isset($serendipity['GET']['filter']['body']) ? htmlspecialchars($serendipity['GET']['filter']['body']) : ''; ?> " /></td> </tr> <tr> <td class="serendipity_admin_filters_headline" colspan="6"><strong><?php echo SORT_ORDER; ?> </strong></td> </tr> <tr> <td> <?php echo SORT_BY; ?> </td> <td> <select name="serendipity[sort][order]"> <?php foreach ($sort_order as $so_key => $so_val) { echo '<option value="' . $so_key . '" ' . (isset($serendipity['GET']['sort']['order']) && $serendipity['GET']['sort']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>' . "\n"; } ?> </select> </td> <td><?php echo SORT_ORDER; ?> </td> <td> <select name="serendipity[sort][ordermode]"> <option value="DESC" <?php echo isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'DESC' ? 'selected="selected"' : ''; ?> ><?php echo SORT_ORDER_DESC; ?> </option> <option value="ASC" <?php echo isset($serendipity['GET']['sort']['ordermode']) && $serendipity['GET']['sort']['ordermode'] == 'ASC' ? 'selected="selected"' : ''; ?> ><?php echo SORT_ORDER_ASC; ?> </option> </select> </td> <td><?php echo ENTRIES_PER_PAGE; ?> </td> <td> <select name="serendipity[sort][perPage]"> <?php foreach ($per_page as $per_page_nr) { echo '<option value="' . $per_page_nr . '" ' . (isset($serendipity['GET']['sort']['perPage']) && $serendipity['GET']['sort']['perPage'] == $per_page_nr ? 'selected="selected"' : '') . '>' . $per_page_nr . '</option>' . "\n"; } ?> </select> </td> </tr> <tr> <td align="right" colspan="6"><input type="submit" name="go" value="<?php echo GO; ?> " class="serendipityPrettyButton input_button" /></td> </tr> </table> </form> <table class="serendipity_admin_list" cellpadding="5" width="100%"> <?php if (is_array($entries)) { $count = count($entries); $qString = '?serendipity[adminModule]=entries&serendipity[adminAction]=editSelect'; foreach ((array) $serendipity['GET']['sort'] as $k => $v) { $qString .= '&serendipity[sort][' . $k . ']=' . $v; } foreach ((array) $serendipity['GET']['filter'] as $k => $v) { $qString .= '&serendipity[filter][' . $k . ']=' . $v; } $linkPrevious = $qString . '&serendipity[page]=' . ($page - 1); $linkNext = $qString . '&serendipity[page]=' . ($page + 1); ?> <tr> <td> <?php if ($offSet > 0) { ?> <a href="<?php echo $linkPrevious; ?> " class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png'); ?> " /><?php echo PREVIOUS; ?> </a> <?php } ?> </td> <td align="right"> <?php if ($count > $perPage) { ?> <a href="<?php echo $linkNext; ?> " class="serendipityIconLinkRight"><?php echo NEXT; ?> <img src="<?php echo serendipity_getTemplateFile('admin/img/next.png'); ?> " /></a> <?php } ?> </td> </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']; ?> "><?php echo serendipity_truncateString(htmlspecialchars($entry['title']), 50); ?> </a></strong> </td> <td align="right"> <?php echo serendipity_formatTime(DATE_FORMAT_SHORT, $entry['timestamp']) . ' ' . $lm; ?> </td> </tr> <tr> <td> <?php echo POSTED_BY . ' ' . htmlspecialchars($entry['author']); if (count($entry['categories'])) { echo ' ' . IN . ' '; $cats = array(); foreach ($entry['categories'] as $cat) { $caturl = serendipity_categoryURL($cat); $cats[] = '<a href="' . $caturl . '">' . htmlspecialchars($cat['category_name']) . '</a>'; } echo implode(', ', $cats); } $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $entry['preview_link'] = '?serendipity[noBanner]=true&serendipity[noSidebar]=true&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=preview&serendipity[id]=' . $entry['id']; ?> </td> <td align="right"> <?php if (serendipity_db_bool($entry['isdraft']) || !$serendipity['showFutureEntries'] && $entry['timestamp'] >= serendipity_serverOffsetHour()) { ?> <a target="_blank" href="<?php echo $entry['preview_link']; ?> " title="<?php echo PREVIEW . ' #' . $entry['id']; ?> " class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?> " alt="<?php echo PREVIEW; ?> " /><?php echo PREVIEW; ?> </a> <?php } else { ?> <a target="_blank" href="<?php echo $entry['link']; ?> " title="<?php echo VIEW . ' #' . $entry['id']; ?> " class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/zoom.png'); ?> " alt="<?php echo VIEW; ?> " /><?php echo VIEW; ?> </a> <?php } ?> <a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=<?php echo $entry['id']; ?> " title="<?php echo EDIT . ' #' . $entry['id']; ?> " class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png'); ?> " alt="<?php echo EDIT; ?> " /><?php echo EDIT; ?> </a> <a href="?<?php echo serendipity_setFormToken('url'); ?> &serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=delete&serendipity[id]=<?php echo $entry['id']; ?> " title="<?php echo DELETE . ' #' . $entry['id']; ?> " class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png'); ?> " alt="<?php echo DELETE; ?> " /><?php echo DELETE; ?> </a> <input class="input_checkbox" type="checkbox" name="serendipity[multiDelete][]" value="<?php echo $entry['id']; ?> " /> </td> </tr> </table> </div> <?php } // end entries output ?> <table class="serendipity_admin_list" cellpadding="5" width="100%"> <tr> <td> <?php if ($offSet > 0) { ?> <a href="<?php echo $linkPrevious; ?> " class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/previous.png'); ?> " /><?php echo PREVIOUS; ?> </a> <?php } ?> </td> <td align="right"> <?php if ($count > $perPage) { ?> <a href="<?php echo $linkNext; ?> " class="serendipityIconLinkRight"><?php echo NEXT; ?> <img src="<?php echo serendipity_getTemplateFile('admin/img/next.png'); ?> " /></a> <?php } ?> </td> </tr> </table> <table class="serendipity_admin_list" cellpadding="0" width="100%"> <tr> <td align="right"> <input type="button" name="toggle" value="<?php echo INVERT_SELECTIONS; ?> " onclick="invertSelection()" class="serendipityPrettyButton input_button" /> <input type="submit" name="toggle" value="<?php echo DELETE_SELECTED_ENTRIES; ?> " class="serendipityPrettyButton input_button" /> </td> </tr> </table> </form> <div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($rows + 1) % 2 ? 'even' : 'uneven'; ?> "> <table width="100%" cellspacing="0" cellpadding="3"> <tr> <td> <form action="?" method="get"> <input type="hidden" name="serendipity[action]" value="admin" /> <input type="hidden" name="serendipity[adminModule]" value="entries" /> <input type="hidden" name="serendipity[adminAction]" value="editSelect" /> <?php echo EDIT_ENTRY; ?> : #<input class="input_textbox" type="text" size="3" name="serendipity[id]" /> <input type="submit" name="serendipity[editSubmit]" value="<?php echo GO; ?> " class="serendipityPrettyButton input_button" /> </form> </td> </tr> </table> </div> <?php } else { // We've got nothing ?> <tr> <td align="center" class="serendipityAdminMsgNote"> <img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_note.png'); ?> " alt="" /> <?php echo NO_ENTRIES_TO_PRINT; ?> </td> </tr> </table> <?php } ?> </div> <?php }
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; } }
/** * 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; $hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />'; $hidden .= ' ' . serendipity_setFormToken(); if (is_object($serendipity['smarty']) || !$_SESSION['no_smarty'] && serendipity_smarty_init()) { $use_smarty = true; } else { $use_smarty = false; } if (is_object($serendipity['smarty'])) { 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; } if (preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { $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['hidden'] = $hidden; $template_vars['errMsg'] = $errMsg; $template_vars['entry'] =& $entry; $template_vars['targetURL'] = $targetURL; $template_vars['cat_count'] = count($cats) + 1; $template_vars['cat_state'] = $categoryselector_expanded ? 'on' : 'off'; $template_vars['wysiwyg'] = $serendipity['wysiwyg']; $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; $template_vars['wysiwyg_blocks'] = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); $template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'); $serendipity['smarty']->registerPlugin('modifier', 'emit_htmlarea_code', 'serendipity_emit_htmlarea_code'); $serendipity['smarty']->assign('admin_view', 'entryform'); serendipity_plugin_api::hook_event('backend_entryform_smarty', $template_vars); $serendipity['smarty']->assignByRef('entry_vars', $template_vars); $serendipity['smarty']->display($template_vars['entry_template']); return true; } /* HTML CODE BELOW IS FOR FALLBACK PORTABILITY ONLY - MODIFY CODE IN TEMPLATE ADMIN/ENTRIES.TPL INSTEAD! */ if (!empty($errMsg)) { ?> <div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="<?php echo serendipity_getTemplateFile('admin/img/admin_msg_error.png'); ?> " alt="" /><?php echo $errMsg; ?> </div> <?php } ?> <form <?php echo $entry['entry_form']; ?> action="<?php echo $targetURL; ?> " method="post" id="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px"> <?php echo $hidden; ?> <table class="serendipityEntryEdit" border="0" width="100%"> <tr> <td> <b><?php echo TITLE; ?> :</b> </td> <td colspan="2"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td><input class="input_textbox" type="text" id="entryTitle" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?> " size="60" /></td> <td align="right"> <select name="serendipity[isdraft]"> <?php if ($_SESSION['serendipityRightPublish']) { ?> <option value="false" <?php echo $draftP; ?> ><?php echo PUBLISH; ?> </option><?php } ?> <option value="true" <?php echo $draftD; ?> ><?php echo DRAFT; ?> </option> </select> </td> </tr> </table> </td> </tr> <tr> <?php if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) { ?> <td> <b><?php echo DATE; ?> :</b> </td> <td> <input type="hidden" name="serendipity[chk_timestamp]" value="<?php echo serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); ?> " /> <input class="input_textbox" type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time())); ?> " /> <a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(time())); ?> '; return false;" title="<?php echo RESET_DATE_DESC; ?> "><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?> " border="0" style="vertical-align: text-top;" alt="<?php echo RESET_DATE; ?> " /></a> </td> <td align="right"> <?php } else { ?> <td align="right" colspan="3"> <?php } ?> <a style="border:0; text-decoration: none" href="#" onclick="showItem('categoryselector'); return false" title="<?php echo TOGGLE_OPTION; ?> "><img src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " id="option_categoryselector" style="border: 20px" alt="" border="0" /></a> <b><?php echo CATEGORY; ?> :</b> <?php echo $cat_list; ?> <script type="text/javascript" language="JavaScript"> function toggle_extended(setCookie) { var textarea = document.getElementById('serendipity[extended]'); var button = document.getElementById('option_extended'); var tools = document.getElementById('tools_extended'); if ( textarea.style.display == 'none' ) { textarea.style.display = ''; tools.style.display = ''; button.src = '<?php echo serendipity_getTemplateFile('img/minus.png'); ?> '; if (setCookie == true) { document.cookie = 'serendipity[toggle_extended]=true;'; } } else { textarea.style.display = 'none'; tools.style.display = 'none'; button.src = '<?php echo serendipity_getTemplateFile('img/plus.png'); ?> '; if (setCookie == true) { document.cookie = 'serendipity[toggle_extended]=;'; } } } var selector_toggle = new Array(); var selector_store = new Array(); var selector_restore = new Array(); function showItem(id) { var selected = 0; if (typeof(id) == 'undefined' || typeof(id) == 'object') { id = 'categoryselector'; } if (document.getElementById) { el = document.getElementById(id); if (selector_toggle[id] && selector_toggle[id] == 'off') { selector_restore[id] = new Array(); selector_toggle[id] = 'on'; /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */ last = 0; for (i=0; i < el.options.length; i++) { if (el.options[i].selected == true) { selected++; last = i; selector_restore[id][last] = 'on'; } if (selected > 1) { /* If there is more than one selected, we reset all those to false This is because otherwise the label will say 'No Category', but the categories will still be selected */ for (j=0; j < el.options.length; j++) { /* Save selection in array to later restore them */ if (el.options[j].selected == true) { el.options[j].selected = false; selector_restore[id][j] = 'on'; last = j; } else { selector_restore[id][j] = false; } } break; } } el.selectedIndex = null; if (last > 0) { el.selectedIndex = last; } el.size = 1; /* Show a normal dropdown */ if (el.multiple) { el.multiple = false; } document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png'); ?> '; } else { selector_store[id] = el.size; if (selector_store[id] == 0) { selector_store[id] = 5; } last = 0; if (el.selectedIndex > 0) { if (!selector_restore[id]) { selector_restore[id] = new Array(); } for (j=0; j < el.options.length; j++) { /* Save selection in array to later restore them */ if (el.options[j].selected == true) { selector_restore[id][j] = 'on'; last = j; } } } el.selectedIndex = -1; el.size = <?php echo count($cats) + 1; ?> ; selector_toggle[id] = 'off'; /* Show multiple items */ el.multiple = true; /* Restore previously selected items? */ last = 0; for (i = 0; i < el.options.length; i++) { if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') { val = el.options[i].value; if (el.options[i].selected != true) { el.options[i].selected = true; last = i; // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this: // alert('it doesnt matter what, just the alert is important'); } } } document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/minus.png'); ?> '; } } } function checkSave() { <?php $void = null; serendipity_plugin_api::hook_event('backend_entry_checkSave', $void); ?> return true; } selector_toggle['categoryselector'] = '<?php echo $categoryselector_expanded ? 'on' : 'off'; ?> '; addLoadEvent(showItem); </script> </td> </tr> <tr> <?php if (!$serendipity['wysiwyg']) { ?> <td colspan="2"><b><?php echo ENTRY_BODY; ?> </b></td> <td align="right"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (!$serendipity['wysiwyg'] && preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<em>\',\'</em>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<strong>\',\'</strong>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<u>\',\'</u>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<blockquote>\',\'</blockquote>\')" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " style="" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />'); document.write('<input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />'); </script> <?php /* Do the "old" non-WYSIWYG editor */ } elseif (!$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> document.write('<input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'b\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'u\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'i\')">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no\');">'); document.write('<input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">'); </script> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); } else { ?> <td colspan="2"><b><?php echo ENTRY_BODY; ?> </b></td> <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?> <?php } ?> </td> </tr> <tr> <td colspan="3"> <textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?> </textarea> </td> </tr> <tr> <td colspan="3"> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td align="left" width="70%"> <input class="input_checkbox" id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" <?php echo $allow_comments; ?> /><label for="checkbox_allow_comments"><?php echo COMMENTS_ENABLE; ?> </label><br /> <input class="input_checkbox" id="checkbox_moderate_comments" type="checkbox" name="serendipity[moderate_comments]" value="true" <?php echo $moderate_comments; ?> /><label for="checkbox_moderate_comments"><?php echo COMMENTS_MODERATE; ?> </label> </td> <td align="right" rowspan="2" valign="middle" width="30%"> <input accesskey="p" type="submit" value="- <?php echo PREVIEW; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" /><br /> <input accesskey="s" type="submit" onclick="return checkSave();" value="- <?php echo SAVE; ?> -" class="serendipityPrettyButton input_button" style="width: 150px" /> </td> </tr> </table> <br /> </td> </tr> <tr> <td colspan="2"> <?php if (!$serendipity['wysiwyg']) { ?> <a style="border:0; text-decoration: none" href="#" onclick="toggle_extended(true); return false;" title="<?php echo TOGGLE_OPTION; ?> "><img src="<?php echo serendipity_getTemplateFile('img/plus.png'); ?> " id="option_extended" alt="+/-" border="0" /></a> <?php } ?> <b><?php echo EXTENDED_BODY; ?> </b></td> <td align="right"> <?php if (!$serendipity['wysiwyg']) { ?> <div id="tools_extended" style="display: none"> <?php /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */ if (preg_match($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT'])) { ?> <input type="button" class="serendipityPrettyButton input_button" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<em>','</em>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<strong>','</strong>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<u>','</u>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insQ" value="<?php echo QUOTE; ?> " accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<blockquote>','</blockquote>')" /> <input type="button" class="serendipityPrettyButton input_button" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[extended]'])" /> <input type="button" class="serendipityPrettyButton input_button" name="insImage" value="<?php echo MEDIA; ?> " onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" /> <input type="button" class="serendipityPrettyButton input_button" name="insURL" value="URL" accesskey="l" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[extended]'])" /> <?php /* Do the "old" non-WYSIWYG editor */ } else { ?> <input type="button" class="serendipityPrettyButton input_button" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'b')"> <input type="button" class="serendipityPrettyButton input_button" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'u')"> <input type="button" class="serendipityPrettyButton input_button" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'i')"> <input type="button" class="serendipityPrettyButton input_button" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[extended]'])"> <input type="button" class="serendipityPrettyButton input_button" value="<?php echo MEDIA; ?> " onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no');"> <input type="button" class="serendipityPrettyButton input_button" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[extended]'])"> <?php } serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); ?> </div> <?php } else { serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry); } ?> </td> </tr> <tr> <td colspan="3"> <textarea style="width: 100%;" name="serendipity[extended]" id="serendipity[extended]" cols="80" rows="20"><?php echo isset($entry['extended']) ? htmlspecialchars($entry['extended']) : ''; ?> </textarea> <?php if (!$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> toggle_extended(); </script> <?php } ?> </td> </tr> <tr> <td colspan="3"> <br /> <fieldset> <legend><b><?php echo ADVANCED_OPTIONS; ?> </b></legend> <?php serendipity_plugin_api::hook_event('backend_display', $entry); ?> </fieldset> </td> </tr> </table> </form> <?php if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) { ?> <script type="text/javascript" language="JavaScript"> toggle_extended(); </script> <?php } if ($serendipity['wysiwyg']) { $fields = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); foreach ($fields as $f_jsname => $f_item) { serendipity_emit_htmlarea_code($f_item, $f_jsname); } serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $fields); } echo ' <script type="text/javascript" language="JavaScript" src="serendipity_define.js.php"></script>'; echo ' <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>'; }
/** * 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); }
/** * 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; }
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; }
/** * 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; $template_vars['entry'] =& $entry; $template_vars['targetURL'] = $targetURL; $template_vars['cat_count'] = count($cats) + 1; $template_vars['wysiwyg'] = $serendipity['wysiwyg']; $template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish']; $template_vars['wysiwyg_blocks'] = array('body' => 'serendipity[body]', 'extended' => 'serendipity[extended]'); $template_vars['entry_template'] = serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'); if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $serendipity['smarty']->registerPlugin('modifier', 'emit_htmlarea_code', 'serendipity_emit_htmlarea_code'); $serendipity['smarty']->assign('admin_view', 'entryform'); serendipity_plugin_api::hook_event('backend_entryform_smarty', $template_vars); $serendipity['smarty']->assignByRef('entry_vars', $template_vars); return serendipity_smarty_show('admin/entries.tpl'); }
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']); } } } }
/** * 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'] = '*****@*****.**'; // 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': $entry_hook = 'frontend_display:rss-1.0:per_entry'; break; case '2.0': $entry_hook = 'frontend_display:rss-2.0:per_entry'; break; case 'atom0.3': $entry_hook = 'frontend_display:atom-0.3:per_entry'; break; case 'atom1.0': $entry_hook = 'frontend_display:atom-1.0:per_entry'; break; } serendipity_plugin_api::hook_event($entry_hook, $entry); $entry['per_entry_display_dat'] = $entry['display_dat']; } } }
function generate_content(&$title) { global $serendipity; $title = $this->title; // Usage of serendipity_serverOffsetHour is as follow: // * Whenever a date to display needs to be set, apply the timezone offset // * Whenever we USE the date anywhere in the database, subtract the timezone offset // * Whenever we DISPLAY the date, we do not apply additional timezone addition to it. if (!isset($serendipity['GET']['calendarZoom'])) { if (!isset($serendipity['range'])) { $serendipity['GET']['calendarZoom'] = serendipity_serverOffsetHour(time()); } else { $serendipity['GET']['calendarZoom'] = serendipity_serverOffsetHour($serendipity['range'][0]); } } $month = date('m', serendipity_serverOffsetHour($serendipity['GET']['calendarZoom'], true)); $year = date('Y', serendipity_serverOffsetHour($serendipity['GET']['calendarZoom'], true)); $bow = (int) $this->get_config('beginningOfWeek', 1); // Check for faulty input, is so - run the default if ($bow > 6) { $bow = 1; } // Catch faulty month $month = (int) $month; if ($month < 1) { $month = 1; } switch ($serendipity['calendar']) { default: case 'gregorian': // How many days does the month have? $ts = strtotime($year . '-' . sprintf('%02d', $month) . '-01'); $now = serendipity_serverOffsetHour(time()); $nrOfDays = date('t', $ts); $firstDayWeekDay = date('w', $ts); $firstts = $ts; $endts = mktime(0, 0, 0, $month + 1, 1, $year); break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; list(, $jy, $jm, $jd) = $serendipity['uriArguments']; if (isset($jd) && $jd) { list($gy, $gm, $gd) = p2g($jy, $jm, $jd); } elseif (isset($jm) && $jm) { list($gy, $gm, $gd) = p2g($jy, $jm, 1); } else { $gy = $year; $gm = $month; $gd = (int) date('d'); } list($year, $month, $day) = g2p($gy, $gm, $gd); // How many days does the month have? $ts = strtotime($gy . '-' . sprintf('%02d', $gm) . '-' . sprintf('%02d', $gd)); $now = serendipity_serverOffsetHour(time()); $nrOfDays = persian_strftime_utf('%m', $ts); $j_days_in_month = array(0, 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29); if ($year % 4 == 3 && $nrOfDays == 12) { $nrOfDays = $j_days_in_month[(int) $nrOfDays] + 1; } else { $nrOfDays = $j_days_in_month[(int) $nrOfDays]; } // Calculate first timestamp of the month list($firstgy, $firstgm, $firstgd) = p2g($year, $month, 1); $firstts = mktime(0, 0, 0, $firstgm, $firstgd, $firstgy); // Calculate first persian day, week day name $firstDayWeekDay = date('w', $firstts); // Calculate end timestamp of the month list($end_year, $end_month, $end_day) = p2g($year, $month + 1, 1); $endts = mktime(0, 0, 0, $end_month, $end_day, $end_year); break; } // end switch // Calculate the first day of the week, based on the beginning of the week ($bow) if ($bow > $firstDayWeekDay) { $firstDayWeekDay = $firstDayWeekDay + 7 - $bow; } elseif ($bow < $firstDayWeekDay) { $firstDayWeekDay = $firstDayWeekDay - $bow; } else { $firstDayWeekDay = 0; } // Calculate the number of next/previous month if ($month > 1) { $previousMonth = $month - 1; $previousYear = $year; } else { $previousMonth = 12; $previousYear = $year - 1; } if ($month < 12) { $nextMonth = $month + 1; $nextYear = $year; } else { $nextMonth = 1; $nextYear = $year + 1; } // Get first and last entry $minmax = serendipity_db_query("SELECT MAX(timestamp) AS max, MIN(timestamp) AS min FROM {$serendipity['dbPrefix']}entries"); if (!is_array($minmax) || !is_array($minmax[0]) || $minmax[0]['min'] < 1 || $minmax[0]['max'] < 1) { // If no entry is available yet, allow scrolling a year back and forth $minmax = array('0' => array('min' => mktime(0, 0, 0, 1, 1, date('Y', $now) - 1), 'max' => mktime(0, 0, 0, 1, 1, date('Y', $now) + 1))); } // Find out about diary entries $add_query = ''; $base_query = ''; $cond = array(); $cond['and'] = "WHERE e.timestamp >= " . serendipity_serverOffsetHour($firstts, true) . "\n AND e.timestamp <= " . serendipity_serverOffsetHour($endts, true) . "\n " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND e.timestamp <= " . serendipity_db_time() : '') . "\n AND e.isdraft = 'false'"; serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('noCache' => false, 'noSticky' => false, 'source' => 'calendar')); // Event Calendar $cat = $this->get_config('category', 'all'); if ($cat != 'all') { $catid = (int) $cat; } elseif (isset($serendipity['GET']['category'])) { $catid = (int) $serendipity['GET']['category']; } else { $catid = false; } if ($catid) { $base_query = 'C' . $catid; $add_query = '/' . $base_query; $querystring = "SELECT timestamp\n FROM {$serendipity['dbPrefix']}category c,\n {$serendipity['dbPrefix']}entrycat ec,\n {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n {$cond['and']}\n AND e.id = ec.entryid\n AND c.categoryid = ec.categoryid\n AND (" . serendipity_getMultiCategoriesSQL($catid) . ")"; } if (!isset($querystring)) { $querystring = "SELECT id, timestamp\n FROM {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n {$cond['and']}"; } $rows = serendipity_db_query($querystring); switch ($serendipity['calendar']) { default: case 'gregorian': $activeDays = array(); if (is_array($rows)) { foreach ($rows as $row) { $row['timestamp'] = serendipity_serverOffsetHour($row['timestamp']); $activeDays[date('j', $row['timestamp'])] = $row['timestamp']; } } $today_day = date('j', $now); $today_month = date('m', $now); $today_year = date('Y', $now); break; case 'persian-utf8': $activeDays = array(); if (is_array($rows)) { foreach ($rows as $row) { $row['timestamp'] = serendipity_serverOffsetHour($row['timestamp']); $activeDays[(int) persian_date_utf('j', $row['timestamp'])] = $row['timestamp']; } } $today_day = persian_date_utf('j', $now); $today_month = persian_date_utf('m', $now); $today_year = persian_date_utf('Y', $now); break; } // end switch $externalevents = array(); if (serendipity_db_bool($this->get_config('enableExtEvents', false))) { serendipity_plugin_api::hook_event('frontend_calendar', $externalevents, array('Month' => $month, 'Year' => $year, 'TS' => $ts, 'EndTS' => $endts)); } // Print the calendar $currDay = 1; $nrOfRows = ceil(($nrOfDays + $firstDayWeekDay) / 7); for ($x = 0; $x < 6; $x++) { // Break out if we are out of days if ($currDay > $nrOfDays) { break; } // Prepare row for ($y = 0; $y < 7; $y++) { $cellProps = array(); $printDay = ''; $link = ''; if ($x == 0) { $cellProps['FirstRow'] = 1; } if ($y == 0) { $cellProps['FirstInRow'] = 1; } if ($y == 6) { $cellProps['LastInRow'] = 1; } if ($x == $nrOfRows - 1) { $cellProps['LastRow'] = 1; } // If it's not a blank day, we print the day if (($x > 0 || $y >= $firstDayWeekDay) && $currDay <= $nrOfDays) { $printDay = $currDay; if ($today_day == $currDay && $today_month == $month && $today_year == $year) { $cellProps['Today'] = 1; } if (isset($externalevents[$currDay])) { if (isset($externalevents[$currDay]['Class'])) { $cellProps[$externalevents[$currDay]['Class']] = 1; } if (isset($externalevents[$currDay]['Title'])) { $cellProps['Title'] = htmlspecialchars($externalevents[$currDay]['Title']); } if (isset($externalevents[$currDay]['Extended'])) { foreach ($externalevents[$currDay]['Extended'] as $ext_key => $ext_val) { $cellProps[$ext_key] = $ext_val; } } } if (isset($activeDays[$currDay]) && $activeDays[$currDay] > 1) { $cellProps['Active'] = 1; $cellProps['Link'] = serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', $year, $month, $currDay) . $add_query); } $currDay++; } $smartyRows[$x]['days'][] = array('name' => $printDay, 'properties' => $cellProps, 'classes' => implode(' ', array_keys($cellProps))); } // end for } // end for $serendipity['smarty']->assignByRef('plugin_calendar_weeks', $smartyRows); $dow = array(); for ($i = 1; $i <= 7; $i++) { $dow[] = array('date' => mktime(0, 0, 0, 3, $bow + $i - 1, 2004)); } $serendipity['smarty']->assignByRef('plugin_calendar_dow', $dow); $plugin_calendar_data = array('month_date' => $ts, 'uri_previous' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $previousYear, $previousMonth) . $add_query), 'uri_month' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $year, $month) . $add_query), 'uri_next' => serendipity_archiveDateUrl(sprintf('%04d/%02d', $nextYear, $nextMonth) . $add_query), 'minScroll' => $minmax[0]['min'], 'maxScroll' => $minmax[0]['max']); $serendipity['smarty']->assignByRef('plugin_calendar_head', $plugin_calendar_data); echo serendipity_smarty_fetch('CALENDAR', 'plugin_calendar.tpl'); }
/** * Parse/Convert properties * * @param array Holds the property key array * @param array Holds the keyword key array * @param int Holds the media metadata * @param int Holds the media properties * @param int How many keyword checkboxes to display next to each other? * @param boolean Can existing data be modified? * @return boolean * */ function serendipity_parseMediaProperties(&$dprops, &$keywords, &$media, &$props, $keywordsPerBlock, $is_edit) { global $serendipity; if (!is_array($dprops)) { $dprops = explode(';', $serendipity['mediaProperties']); } if (!is_array($keywords)) { $keywords = explode(';', $serendipity['mediaKeywords']); } $media['references'] = serendipity_db_query("SELECT link, name\n FROM {$serendipity['dbPrefix']}references\n WHERE entry_id = " . $media['id'] . "\n AND type = 'media'\n ORDER BY name DESC\n LIMIT 15", false, 'assoc'); if (!is_array($media['references'])) { $media['references'] = false; } foreach ($dprops as $prop) { $type = 'input'; $parts = explode(':', trim($prop)); if (in_array('MULTI', $parts)) { $type = 'textarea'; } if (preg_match('@(AUDIO|VIDEO|DOCUMENT|IMAGE|ARCHIVE|BINARY)@i', $prop)) { $show_item = false; if ($media['mediatype'] == 'video' && in_array('VIDEO', $parts)) { $show_item = true; } if ($media['mediatype'] == 'audio' && in_array('AUDIO', $parts)) { $show_item = true; } if ($media['mediatype'] == 'image' && in_array('IMAGE', $parts)) { $show_item = true; } if ($media['mediatype'] == 'document' && in_array('DOCUMENT', $parts)) { $show_item = true; } if ($media['mediatype'] == 'archive' && in_array('ARCHIVE', $parts)) { $show_item = true; } if ($media['mediatype'] == 'binary' && in_array('BINARY', $parts)) { $show_item = true; } if (!$show_item) { continue; } } if (!$is_edit) { $type = 'readonly'; } $val = serendipity_mediaTypeCast($parts[0], $props['base_property'][$parts[0]], true); $propkey = serendipity_specialchars($parts[0]) . $idx; $media['base_property'][$propkey] = array('label' => serendipity_specialchars(defined('MEDIA_PROPERTY_' . strtoupper($parts[0])) ? constant('MEDIA_PROPERTY_' . strtoupper($parts[0])) : $parts[0]), 'type' => $type, 'val' => $val, 'title' => serendipity_specialchars($parts[0])); if (!is_array($GLOBALS['IPTC'])) { // Your templates config.inc.php or any of the language files can declare this variable, // if you want to use other default settings for this. No interface ability to declare this // yet, sorry. $GLOBALS['IPTC'] = array('DATE' => array('DateCreated'), 'RUN_LENGTH' => array('RunLength'), 'DPI' => array('XResolution'), 'COPYRIGHT' => array('Creator'), 'TITLE' => array('Title', 'ObjectName'), 'COMMENT1' => array('Description'), 'ALT' => array('Title', 'ObjectName'), 'COMMENT2' => array('Keywords', 'PhotoLocation')); } $default_iptc_val = null; if (empty($val)) { switch ($parts[0]) { case 'DATE': $default_iptc_val = serendipity_serverOffsetHour(); case 'RUN_LENGTH': if (!isset($default_iptc_val)) { $default_iptc_val = '00:00:00.00'; } case 'DPI': if (!isset($default_iptc_val)) { $default_iptc_val = '72'; } case 'COPYRIGHT': if (!isset($default_iptc_val)) { $default_iptc_val = $serendipity['serendipityUser']; } case 'TITLE': if (!isset($default_iptc_val)) { $default_iptc_val = $media['realname']; } case 'ALT': if (!isset($default_iptc_val)) { $default_iptc_val = ''; } case 'COMMENT1': if (!isset($default_iptc_val)) { $default_iptc_val = ''; } case 'COMMENT2': if (!isset($default_iptc_val)) { $default_iptc_val = ''; } $media['base_property'][$propkey]['val'] = serendipity_pickKey($media['metadata'], 'Keywords', ''); $new_iptc_val = false; foreach ($GLOBALS['IPTC'][$parts[0]] as $iptc_key) { if (empty($new_iptc_val)) { $new_iptc_val = serendipity_pickKey($media['metadata'], $iptc_key, ''); } } if (empty($new_iptc_val)) { $new_iptc_val = $default_iptc_val; } if ($parts[0] == 'DATE') { $media['base_property'][$propkey]['val'] = serendipity_strftime(DATE_FORMAT_SHORT, $new_iptc_val); } else { $media['base_property'][$propkey]['val'] = $new_iptc_val; } break; default: serendipity_plugin_api::hook_event('media_showproperties', $media, $propkey); break; } } } if ($keywordsPerBlock > 0) { $rows = ceil(count($keywords) / $keywordsPerBlock); for ($i = 0; $i < $rows; $i++) { for ($j = 0; $j < $keywordsPerBlock; $j++) { $kidx = $i * $keywordsPerBlock + $j; if (isset($keywords[$kidx])) { $media['base_keywords'][$i][$j] = array('name' => serendipity_specialchars($keywords[$kidx]), 'selected' => isset($props['base_keyword'][$keywords[$kidx]]) ? true : false); } else { $media['base_keywords'][$i][$j] = array(); } } } } }
} $file_version = preg_replace('@[^0-9a-z\\.-_]@i', '', $version); $metadata['template_file'] = serendipity_getTemplateFile('feed_' . $file_version . '.tpl', 'serendipityPath'); serendipity_smarty_init(); serendipity_plugin_api::hook_event('frontend_rss', $metadata); if (!$metadata['template_file'] || $metadata['template_file'] == 'feed_' . $file_version . '.tpl') { die("Invalid RSS version specified or RSS-template file not found\n"); } $self_url = 'http://' . $_SERVER['HTTP_HOST'] . htmlspecialchars($_SERVER['REQUEST_URI']); if (!is_array($entries)) { $entries = array(); } if ($entries[0]['last_modified']) { $gm_modified = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour($entries[0]['last_modified'])); } else { $gm_modified = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour()); } serendipity_printEntries_rss($entries, $version, $comments, $metadata['fullFeed'], $metadata['showMail']); $namespace_hook = 'frontend_display:unknown:namespace'; $once_display_dat = ''; switch ($version) { case 'opml1.0': $namespace_hook = 'frontend_display:opml-1.0:namespace'; break; case '0.91': $namespace_hook = 'frontend_display:rss-0.91:namespace'; break; case '1.0': $namespace_hook = 'frontend_display:rss-1.0:namespace'; serendipity_plugin_api::hook_event('frontend_display:rss-1.0:once', $entries); $once_display_dat = $entries['display_dat'];
function showElementFuture() { $lim = $this->get_config('limit_future'); if ($lim < 1) { return; } echo '<div class="dashboard dashboard_future">'; echo '<h3>' . PLUGIN_DASHBOARD_FUTURE . '</h3>'; $this->showElementEntrylist(array("e.isdraft != 'true' AND e.timestamp >= " . serendipity_serverOffsetHour()), $lim); echo '</div>'; }
// is done in tpl per $totalPages $smartentries = array(); foreach ($entries as $ey) { $entry_cats = array(); if (count($ey['categories'])) { foreach ($ey['categories'] as $cat) { $cat['link'] = serendipity_categoryURL($cat); $entry_cats[] = $cat; } } $smartentries[] = array('id' => $ey['id'], 'title' => serendipity_specialchars($ey['title']), 'timestamp' => (int) $ey['timestamp'], 'last_modified' => (int) $ey['last_modified'], 'isdraft' => serendipity_db_bool($ey['isdraft']), 'ep_is_sticky' => serendipity_db_bool($ey['properties']['ep_is_sticky']) ? true : false, 'pubdate' => date("c", (int) $ey['timestamp']), 'author' => serendipity_specialchars($ey['author']), 'cats' => $entry_cats, 'preview' => serendipity_db_bool($ey['isdraft']) || !$serendipity['showFutureEntries'] && $ey['timestamp'] >= serendipity_serverOffsetHour() ? true : false, 'archive_link' => serendipity_archiveURL($ey['id'], $ey['title'], 'serendipityHTTPPath', true, array('timestamp' => $ey['timestamp'])), 'preview_link' => '?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=preview&' . serendipity_setFormToken('url') . '&serendipity[id]=' . $ey['id']); } $data['entries'] = $smartentries; $data['urltoken'] = serendipity_setFormToken('url'); $data['formtoken'] = serendipity_setFormToken(); $data['serverOffsetHour'] = serendipity_serverOffsetHour(); $data['showFutureEntries'] = $serendipity['showFutureEntries']; $data['filter_import'] = $filter_import; $data['sort_import'] = $sort_import; } else { $data['no_entries'] = true; } // if entries end break; case 'delete': if (!serendipity_checkFormToken()) { break; } $newLoc = '?' . serendipity_setFormToken('url') . '&serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=doDelete&serendipity[id]=' . (int) $serendipity['GET']['id']; $entry = serendipity_fetchEntry('id', $serendipity['GET']['id'], 1, 1); $data['switched_output'] = true;
$comment['fullBody'] = $comment['body']; $comment['summary'] = serendipity_mb('substr', $comment['body'], 0, 100); if (strlen($comment['fullBody']) > strlen($comment['summary'])) { $comment['excerpt'] = true; // When summary is not the full body, strip HTML tags from summary, as it might break and leave unclosed HTML. $comment['fullBody'] = nl2br(serendipity_specialchars($comment['fullBody'])); $comment['summary'] = nl2br(strip_tags($comment['summary'])); } } } $data['comments'] = $comments; $entries = serendipity_fetchEntries(false, false, (int) $serendipity['dashboardLimit'], true, false, 'timestamp DESC', 'e.timestamp >= ' . serendipity_serverOffsetHour()); $entriesAmount = count($entries); if ($entriesAmount < (int) $serendipity['dashboardDraftLimit']) { // there is still space for drafts $drafts = serendipity_fetchEntries(false, false, (int) $serendipity['dashboardDraftLimit'] - $entriesAmount, true, false, 'timestamp DESC', "isdraft = 'true' AND e.timestamp <= " . serendipity_serverOffsetHour()); if (is_array($entries) && is_array($drafts)) { $entries = array_merge($entries, $drafts); } else { if (is_array($drafts)) { // $entries is not an array, thus empty $entries = $drafts; } } } $data['entries'] = $entries; $data['urltoken'] = serendipity_setFormToken('url'); $data['token'] = serendipity_setFormToken(); $data['no_create'] = $serendipity['no_create']; echo serendipity_smarty_show('admin/overview.inc.tpl', $data); /* vim: set sts=4 ts=4 expandtab : */
function cacheHeaders($lm = null) { global $serendipity; if ($lm === null || empty($lm)) { $last_modified_ts = serendipity_serverOffsetHour(); } else { $last_modified_ts = serendipity_serverOffsetHour($lm, true); } $modified_since = !empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? gmdate('D, d M Y H:i:s \\G\\M\\T', serendipity_serverOffsetHour(strtotime(stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE'])), true)) : false; $none_match = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) : false; $last_modified = gmdate('D, d M Y H:i:s \\G\\M\\T', $last_modified_ts); $etag = '"' . $last_modified . '"'; serendipity_header('Last-Modified: ' . $last_modified); serendipity_header('ETag: ' . $etag); if ($none_match == $last_modified && $modified_since == $last_modified || !$none_match && $modified_since == $last_modified || !$modified_since && $none_match == $last_modified) { header('HTTP/1.0 304 Not Modified'); header('Status: 304 Not Modified'); return true; } return false; }
/** * Shows the HTML form to add/edit properties of uploaded media items * * @param array Associative array holding an array('image_id', 'target', 'created_thumbnail') that points to the uploaded media * @param int How many keyword checkboxes to display next to each other? * @param boolean Can existing data be modified? * @return boolean * */ function serendipity_showPropertyForm(&$new_media, $keywordsPerBlock = 3, $is_edit = true) { global $serendipity; if (!is_array($new_media) || count($new_media) < 1) { return true; } $mirror = array(); serendipity_checkPropertyAccess($new_media, $mirror, 'read'); $editform_hidden = ''; if (isset($GLOBALS['image_selector_addvars']) && is_array($GLOBALS['image_selector_addvars'])) { // These variables may come from serendipity_admin_image_selector.php to show embedded upload form foreach ($GLOBALS['image_selector_addvars'] as $imgsel_key => $imgsel_val) { $editform_hidden .= ' <input type="hidden" name="serendipity[' . htmlspecialchars($imgsel_key) . ']" value="' . htmlspecialchars($imgsel_val) . '" />' . "\n"; } } $dprops = explode(';', $serendipity['mediaProperties']); $keywords = explode(';', $serendipity['mediaKeywords']); $now = serendipity_serverOffsetHour(); $show = array(); foreach ($new_media as $idx => $media) { $props =& serendipity_fetchMediaProperties($media['image_id']); $show[$idx] =& $media['internal']; $show[$idx]['image_id'] = $media['image_id']; serendipity_prepareMedia($show[$idx]); if (!is_array($props['base_metadata'])) { $show[$idx]['metadata'] =& serendipity_getMetaData($show[$idx]['realfile'], $show[$idx]['header']); } else { $show[$idx]['metadata'] = $props['base_metadata']; serendipity_plugin_api::hook_event('media_getproperties_cached', $show[$idx]['metadata'], $show[$idx]['realfile']); } serendipity_parseMediaProperties($dprops, $keywords, $show[$idx], $props, $keywordsPerBlock, $is_edit); } $smarty_vars = array('is_edit' => $is_edit, 'editform_hidden' => $editform_hidden, 'keywordsPerBlock' => $keywordsPerBlock, 'keywords' => $keywords, 'dprops' => $dprops); return serendipity_showMedia($show, $mirror, $url, false, 1, false, $smarty_vars); }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); $this->debug = serendipity_db_bool($this->get_config('debug')); if (isset($hooks[$event])) { switch ($event) { case 'backend_sidebar_entries': if ($serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF) { if ($serendipity['version'][0] == '1') { ?> <li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=aggregator"><?php echo PLUGIN_AGGREGATOR_TITLE; ?> </a></li> <?php } else { ?> <li><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=aggregator"><?php echo PLUGIN_AGGREGATOR_TITLE; ?> </a></li> <?php } } break; case 'backend_sidebar_entries_event_display_aggregator': $this->showFeeds(); break; case 'cronjob': if ($this->get_config('cronjob') == $eventData) { serendipity_event_cronjob::log('Aggregator', 'plugin'); $this->fetchFeeds(); # Fetch first, expire later (some feeds offer old stuff) $this->expireFeeds(); } return true; break; case 'aggregator_feedlist': $this->parseShowFeed($eventData); return true; break; case 'external_plugin': if ($eventData == 'opmlfeeds.xml') { header('Content-Type: text/xml; charset=utf-8'); echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n"; $modified = gmdate('D, d M Y H:i:s \\G\\M\\T', serendipity_serverOffsetHour(time(), true)); print <<<EOF <opml version="1.0"> <head> <title>{$serendipity['blogTitle']}</title> <dateModified>{$modified}</dateModified> <ownerName>Serendipity - http://www.s9y.org/</ownerName> </head> <body> EOF; $feeds = serendipity_db_Query("\n SELECT c.categoryid,\n f.feedname,\n f.feedurl,\n f.htmlurl\n FROM {$serendipity['dbPrefix']}category AS c\n LEFT JOIN {$serendipity['dbPrefix']}aggregator_feedcat AS fc\n ON fc.categoryid = c.categoryid\n LEFT JOIN {$serendipity['dbPrefix']}aggregator_feeds AS f\n ON fc.feedid = f.feedid", false, 'assoc'); $xml = array(); if (is_array($feeds)) { foreach ($feeds as $feed) { $xml[$feed['categoryid']][] = $feed; } } if (is_array($cats = serendipity_fetchCategories())) { $cats = $this->showRecursive($cats, $xml, 'categoryid', 'parentid', VIEWMODE_THREADED); } print "</body>\n</opml>"; return; } if ($eventData != 'aggregator') { return; } $this->fetchFeeds(); # Fetch first, expire later (some feeds offer old stuff) $this->expireFeeds(); break; } } return true; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); $links = array(); $article_show = false; if (isset($hooks[$event])) { switch ($event) { case 'frontend_display': if (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) { $article_show = true; $year = date('Y', serendipity_serverOffsetHour($eventData['timestamp'])); $month = date('m', serendipity_serverOffsetHour($eventData['timestamp'])); } else { break; } case 'entries_footer': if (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) { $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/articlepdf_' . $serendipity['GET']['id'] . '">' . PLUGIN_EVENT_BLOGPDF_VIEW_ENTRY . '</a>'; } if (isset($serendipity['GET']['category'])) { $cid = explode('_', $serendipity['GET']['category']); if (is_numeric($cid[0])) { $cat = serendipity_fetchCategoryInfo($cid[0]); $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/categorypdf_' . $cid[0] . '">' . sprintf(PLUGIN_EVENT_BLOGPDF_VIEW_CATEGORY, $cat['category_name']) . '</a>'; } } if (empty($year) && empty($month) && isset($serendipity['GET']['range']) && is_numeric($serendipity['GET']['range'])) { $year = substr($serendipity['GET']['range'], 0, 4); $month = substr($serendipity['GET']['range'], 4, 2); } if (empty($year)) { $year = date('Y', serendipity_serverOffsetHour()); } if (empty($month)) { $month = date('m', serendipity_serverOffsetHour()); } $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/monthpdf_' . $year . $month . '">' . PLUGIN_EVENT_BLOGPDF_VIEW_MONTH . '</a>'; $links[] = '<a href="' . $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/blogpdf">' . PLUGIN_EVENT_BLOGPDF_VIEW_FULL . '</a>'; if ($article_show) { $eventData['add_footer'] .= '<div class="serendipity_blogpdf">' . PLUGIN_EVENT_BLOGPDF_VIEW . implode(' | ', $links) . '</div>'; } else { echo '<div class="serendipity_blogpdf">' . PLUGIN_EVENT_BLOGPDF_VIEW . implode(' | ', $links) . '</div>'; } return true; break; case 'external_plugin': if (serendipity_db_bool($this->get_config('html2pdf'))) { include_once dirname(__FILE__) . '/html2fpdf.php'; } elseif (serendipity_db_bool($this->get_config('updf'))) { include_once dirname(__FILE__) . '/serendipity_blogupdf.inc.php'; } else { include_once dirname(__FILE__) . '/serendipity_blogpdf.inc.php'; } $cachetime = 60 * 60 * 24; // one day $parts = explode('_', $eventData); if (!empty($parts[1])) { $param = (int) $parts[1]; } else { $param = null; } $methods = array('blogpdf', 'articlepdf', 'monthpdf', 'categorypdf'); if (!in_array($parts[0], $methods)) { return; } if (serendipity_db_bool($this->get_config('html2pdf'))) { $this->pdf = new HTML2FPDF(); } else { $this->pdf = new PDF(); } $this->pdf->AliasNbPages(); switch ($parts[0]) { case 'blogpdf': $feedcache = $serendipity['serendipityPath'] . 'archives/blog.pdf'; $entries = serendipity_fetchEntries(); $this->process($feedcache, $entries); break; case 'articlepdf': $feedcache = $serendipity['serendipityPath'] . 'archives/article' . $param . '.pdf'; $this->single = true; $entry = serendipity_fetchEntry('id', $param); $this->process($feedcache, $entry); break; case 'monthpdf': $feedcache = $serendipity['serendipityPath'] . 'archives/month' . $param . '.pdf'; $entries = serendipity_fetchEntries($param); $this->process($feedcache, $entries); break; case 'categorypdf': $feedcache = $serendipity['serendipityPath'] . 'archives/category' . $param . '.pdf'; $serendipity['GET']['category'] = $param . '_category'; $entries = serendipity_fetchEntries(); $this->process($feedcache, $entries); break; } $this->pdf->Output(); return true; break; default: return false; break; } } else { return false; } }
?> " style="display:inline;"><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?> " style="border:none;vertical-align:text-top" alt="<?php echo RESET_DATE; ?> " /></a> <br style="clear:both"/> <label for="hCalendar_enddate">End date</label> <input type="text" id="hCalendar_enddate" name="serendipity[properties][hCalendar_enddate]" value="<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(isset($eventData['properties']['mf_hCalendar_enddate']) && $eventData['properties']['mf_hCalendar_enddate'] > 0 ? $eventData['properties']['mf_hCalendar_enddate'] : time())); ?> " style="width:auto;" /> <a href="#" onclick="document.getElementById('hCalendar_enddate').value = '<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(time())); ?> '; return false;" title="<?php echo RESET_DATE_DESC; ?> " style="display:inline;"><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png'); ?> " style="border:none;vertical-align:text-top" alt="<?php echo RESET_DATE; ?> " /></a> <br style="clear:left"/> <br/> </div> <br/><input type="hidden" id="hCalendar_timezone" name="serendipity[properties][hCalendar_timezone]" value="<?php