function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $sort = $this->get_config('sort_order'); if ($sort == 'none') { $sort = ''; } else { $sort .= ' ' . $this->get_config('sort_method'); } $is_form = serendipity_db_bool($this->get_config('allow_select')); $is_count = serendipity_db_bool($this->get_config('showartcount')); $mincount = (int) $this->get_config('mincount'); $authors = serendipity_fetchUsers(null, 'hidden', $is_count); $html = ''; if ($is_form) { $html .= '<form action="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?frontpage" method="post">'; } $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif')); $image = $image == "'none'" || $image == 'none' ? '' : $image; $html .= '<ul class="plainList">' . "\n"; if (is_array($authors) && count($authors)) { foreach ($authors as $auth) { if ($is_count) { if ($auth['artcount'] < $mincount) { continue; } $entrycount = " ({$auth['artcount']})"; } else { $entrycount = ""; } $html .= '<li>'; if ($is_form) { $html .= '<input style="width: 15px" type="checkbox" name="serendipity[multiAuth][]" value="' . $auth['authorid'] . '" />'; } if (!empty($image)) { $html .= '<a class="serendipity_xml_icon" href="' . serendipity_feedAuthorURL($auth, 'serendipityHTTPPath') . '"><img src="' . $image . '" alt="XML" style="border: 0px" /></a> '; } $html .= '<a href="' . serendipity_authorURL($auth, 'serendipityHTTPPath') . '" title="' . serendipity_specialchars($auth['realname']) . '">' . serendipity_specialchars($auth['realname']) . $entrycount . '</a>'; $html .= '</li>' . "\n"; } } $html .= '</ul>' . "\n"; if ($is_form) { $html .= '<div><input type="submit" name="serendipity[isMultiAuth]" value="' . GO . '" /></div>'; } $html .= sprintf('<div><a href="%s" title="%s">%s</a></div>', $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'], ALL_AUTHORS, ALL_AUTHORS); if ($is_form) { $html .= '</form>'; } print $html; }
function getAuthors() { global $serendipity; $html = '<strong>' . PLUGIN_EVENT_XSSTRUST_AUTHORS . '</strong><br />'; $users = (array) serendipity_fetchUsers(); $valid =& $this->trusted_authors; $html .= '<select name="serendipity[plugin][trusted_authors][]" multiple="true">'; foreach ($users as $user) { $html .= '<option value="' . $user['authorid'] . '" ' . (isset($valid[$user['authorid']]) ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; } $html .= '</select>'; return $html; }
function displayUserList() { global $serendipity; $userlist = serendipity_fetchUsers(); $content = ""; foreach ($userlist as $user) { if (function_exists('serendipity_authorURL')) { $entryLink = serendipity_authorURL($user); } else { $entryLink = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $user['authorid'], 'title' => $user['realname']))); } $content .= sprintf("<a href=\"%s\" title=\"%s\">%s</a><br />\n", $entryLink, function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)); } return $content; }
function introspect_config_item($name, &$propbag) { global $serendipity; switch ($name) { case 'author': $propbag->add('type', 'select'); $propbag->add('name', AUTHOR); $propbag->add('description', PLUGIN_SUGGEST_AUTHOR); $propbag->add('default', ''); $users = serendipity_fetchUsers(); $vals = array(); foreach ($users as $user) { $vals[$user['authorid']] = $user['realname']; } $propbag->add('select_values', $vals); break; case 'permalink': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SUGGEST_PERMALINK); $propbag->add('description', PLUGIN_SUGGEST_PERMALINK_DESC); $propbag->add('default', $serendipity['rewrite'] != 'none' ? $serendipity['serendipityHTTPPath'] . 'pages/suggest.html' : $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/pages/suggest.html'); break; case 'pagetitle': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SUGGEST_PAGETITLE); $propbag->add('description', PLUGIN_SUGGEST_PAGETITLE_DESC); $propbag->add('default', 'suggest'); break; case 'email': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SUGGEST_EMAIL); $propbag->add('description', ''); $propbag->add('default', $serendipity['blogMail']); break; default: return false; } return true; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $sort = $this->get_config('sort_order'); if ($sort == 'none') { $sort = ''; } else { $sort .= ' ' . $this->get_config('sort_method'); } $is_count = serendipity_db_bool($this->get_config('showartcount', 'false')); $mincount = (int) $this->get_config('mincount'); $authors = serendipity_fetchUsers(null, 'hidden', $is_count); $html = ''; $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif')); $image = $image == "'none'" || $image == 'none' ? '' : $image; $html .= '<ul class="plainList">' . "\n"; if (is_array($authors) && count($authors)) { foreach ($authors as $auth) { if ($is_count) { if ($auth['artcount'] < $mincount) { continue; } $entrycount = " ({$auth['artcount']})"; } else { $entrycount = ""; } $html .= '<li>'; if (!empty($image)) { $html .= ' <a class="serendipity_xml_icon" href="' . serendipity_feedAuthorURL($auth, 'serendipityHTTPPath') . '"><img src="' . $image . '" alt="XML" style="border: 0px" /></a> '; } $html .= ' <a href="' . serendipity_authorURL($auth, 'serendipityHTTPPath') . '" title="' . serendipity_specialchars($auth['realname']) . '">' . serendipity_specialchars($auth['realname']) . $entrycount . '</a>'; $html .= '</li>' . "\n"; } } $html .= '</ul>' . "\n"; $html .= sprintf('<div><a href="%s" title="%s">%s</a></div>' . "\n", $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'], ALL_AUTHORS, ALL_AUTHORS); print $html; }
function displayBirthdayList() { global $serendipity; $userlist = serendipity_fetchUsers(); $birthdays = $this->getBirthdays(); foreach ($userlist as $user) { if (isset($birthdays[$user['authorid']])) { $res = $this->date_diff_days(time(), $birthdays[$user['authorid']]); $bdays[$res][] = array('name' => $user['realname'], 'date' => date("d.m.", $birthdays[$user['authorid']])); } } ksort($bdays); $max_running = (int) $this->get_config('number'); $running = 0; foreach ($bdays as $key => $bday) { if ($key > 0 && $max_running > 0 && $running > $max_running) { continue; } if ($key == 0) { echo '<strong>' . PLUGIN_USERPROFILES_BIRTHDAYTODAY . '</strong>'; } else { echo '<strong>' . sprintf(PLUGIN_USERPROFILES_BIRTHDAYIN, $key) . '</strong>'; } echo '<div>'; for ($i = 0, $ii = count($bday); $i < $ii; $i++) { if (strlen($content)) { $content .= '<br />'; } $content .= $bday[$i]['name'] . ' ' . $bday[$i]['date']; } echo $content; echo '</div>'; $content = ''; $running++; } }
function showUsersInterface() { global $serendipity; if (isset($_POST[submitusersedit])) { foreach ($_POST as $key => $val) { // Pick out the "userchoose-" values if (strpos($key, "userchoose-") !== FALSE) { $pbuserid = substr($key, 11); $this->set_config("phoneblogz_usermap_{$pbuserid}", $val); } } } $arr = getUsersForAccount($this->get_config('phoneblogz_accesscode'), $this->get_config('phoneblogz_password')); if (!empty($arr["error"])) { echo "ERROR: " . $arr["error"]; } else { echo "<center>"; echo '<h3 style="text-align:center;">' . PLUGIN_EVENT_PHONEBLOGZ_USERS_HEADING . '</h3>'; echo "<form name='users' method='post' action=''>"; echo "<table border='1'><tr><th>PhoneBlogz Name</th><th>PIN code</th><th>WordPress User</th></tr>"; $users = serendipity_fetchUsers(); $vals = array(); $vals['empty'] = MF_MYSELF; for ($i = 0; $i < count($arr); ++$i) { echo "<tr><td>" . $arr[$i]["name"] . "</td><td>" . $arr[$i]["pin"] . "</td>"; echo "<td><select name='userchoose-" . $arr[$i]["id"] . "'>"; echo "<option value='-1'>Please choose...</option>"; foreach ($users as $user) { $selected = $this->get_config("phoneblogz_usermap_" . $arr[$i]["id"]) == $user['authorid'] ? " SELECTED " : ""; echo "<option {$selected} value='" . $user['authorid'] . "'>" . $user['realname'] . " (" . $user['realname'] . ")</option>"; } echo "</select></td>"; echo "</tr>"; } echo "</table>"; echo "<br/>"; echo "<input class='serendipityPrettyButton input_button' type='submit' name='submitusersedit' value='Update Users' />"; echo "</form>"; echo "</center>"; } }
function serveAuthorPage($matches) { global $serendipity; $serendipity['view'] = 'authors'; $serendipity['GET']['viewAuthor'] = $matches[1]; $serendipity['GET']['action'] = 'read'; locateHiddenVariables($serendipity['uriArguments']); $matches[1] = serendipity_searchPermalink($serendipity['permalinkAuthorStructure'], implode('/', $serendipity['uriArguments']), $matches[1], 'author'); $serendipity['GET']['viewAuthor'] = $matches[1]; $serendipity['GET']['action'] = 'read'; $uInfo = serendipity_fetchUsers($serendipity['GET']['viewAuthor']); if (!is_array($uInfo)) { $serendipity['view'] = '404'; $serendipity['viewtype'] = '404_3'; header('HTTP/1.0 404 Not found'); header('Status: 404 Not found'); } else { $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['realname']); $serendipity['head_subtitle'] = $serendipity['blogTitle']; } include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; }
/** * Show the list of plugins * * Shows a HTML list of all installed plugins, complete with config/delete/sort order options * * @access public * @param boolean Indicates if event plugins (TRUE) or sidebar plugins (FALSE) shall be shown * @return null */ function show_plugins($event_only = false, $sidebars = null) { global $serendipity; $sql_filter = ''; if (is_array($sidebars)) { foreach ($sidebars as $sidebar) { $up = strtoupper($sidebar); if ($sidebar == 'hide') { $opts[$sidebar] = HIDDEN; } elseif (defined('SIDEBAR_' . $up)) { $opts[$sidebar] = constant('SIDEBAR_' . $up); } elseif (defined($up)) { $opts[$sidebar] = constant($up); } else { $opts[$sidebar] = $up; } $sql_filter .= "AND placement != '" . serendipity_db_escape_string($sidebar) . "' "; } } if (!$event_only) { $sql = "SELECT * from {$serendipity['dbPrefix']}plugins\n WHERE placement != 'event'\n AND placement != 'eventh'\n " . $sql_filter; $invisible_plugins = serendipity_db_query($sql); if (is_array($invisible_plugins)) { $sidebars[] = 'NONE'; $opts['NONE'] = NONE; } } $opts['event'] = PLUGIN_ACTIVE; $opts['eventh'] = PLUGIN_INACTIVE; $data['event_only'] = $event_only; if (!$event_only) { $data['is_first'] = true; } $data['serendipity_setFormToken'] = serendipity_setFormToken(); $data['serendipity_setFormTokenUrl'] = serendipity_setFormToken('url'); /* Block display the plugins per placement location. */ if ($event_only) { $plugin_placements = array('event', 'eventh'); } else { $plugin_placements = $sidebars; } $data['plugin_placements'] = $plugin_placements; static $users = array(); if (empty($users)) { $users = serendipity_fetchUsers('', 'hidden'); } $data['users'] = $users; $i = 0; foreach ($plugin_placements as $plugin_placement) { if (!$event_only && $plugin_placement == 'NONE') { $is_invisible = true; } else { $is_invisible = false; } $data['placement'][$plugin_placement]['ptitle'] = $ptitle = $opts[$plugin_placement]; $data['placement'][$plugin_placement]['pid'] = $pid = $plugin_placement; if ($is_invisible) { $plugins = $invisible_plugins; } else { $plugins = serendipity_plugin_api::enum_plugins($plugin_placement); } if (!is_array($plugins)) { continue; } $sort_idx = 0; foreach ($plugins as $plugin_data) { $i++; $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid']); $key = urlencode($plugin_data['name']); $css_key = 's9ycid' . str_replace('%', '-', $key); $is_plugin_owner = $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'); $is_plugin_editable = $is_plugin_owner || $plugin_data['authorid'] == '0'; $cname = explode(':', $plugin_data['name']); if (!is_object($plugin)) { $name = $title = ERROR . '!'; $desc = ERROR . ': ' . $plugin_data['name']; $can_configure = false; } else { /* query for its name, description and configuration data */ $bag = new serendipity_property_bag(); $plugin->introspect($bag); $name = serendipity_specialchars($bag->get('name')); $desc = '<details class="plugin_data">'; $desc .= '<summary><var class="perm_name">' . $cname[0] . '</var></summary>'; $desc .= '<div class="plugin_desc clearfix">' . serendipity_specialchars($bag->get('description')) . '</div>'; $desc .= '<span class="block_level">' . VERSION . ': ' . $bag->get('version') . '</span>'; $desc .= '</details>'; $title = serendipity_plugin_api::get_plugin_title($plugin, '[' . $name . ']'); if ($bag->is_set('configuration') && ($plugin->protected === FALSE || $plugin_data['authorid'] == '0' || $plugin_data['authorid'] == $serendipity['authorid'] || serendipity_checkPermission('adminPluginsMaintainOthers'))) { $can_configure = true; } else { $can_configure = false; } } if ($opts === null) { $opts = array('left' => LEFT, 'right' => RIGHT, 'hide' => HIDDEN); } $event_opts = array('event' => PLUGIN_ACTIVE, 'eventh' => PLUGIN_INACTIVE); if ($event_only) { $gopts = $event_opts; } else { $gopts = $opts; } $data['placement'][$plugin_placement]['plugin_data'][$i]['sort_idx'] = $sort_idx; $data['placement'][$plugin_placement]['plugin_data'][$i]['css_key'] = $css_key; $data['placement'][$plugin_placement]['plugin_data'][$i]['is_plugin_editable'] = $is_plugin_editable; $data['placement'][$plugin_placement]['plugin_data'][$i]['is_plugin_owner'] = $is_plugin_owner; $data['placement'][$plugin_placement]['plugin_data'][$i]['name'] = $plugin_data['name']; $data['placement'][$plugin_placement]['plugin_data'][$i]['authorid'] = $plugin_data['authorid']; $data['placement'][$plugin_placement]['plugin_data'][$i]['can_configure'] = $can_configure; $data['placement'][$plugin_placement]['plugin_data'][$i]['key'] = $key; $data['placement'][$plugin_placement]['plugin_data'][$i]['title'] = $title; $data['placement'][$plugin_placement]['plugin_data'][$i]['desc'] = $desc; $data['placement'][$plugin_placement]['plugin_data'][$i]['placement'] = $plugin_data['placement']; $data['placement'][$plugin_placement]['plugin_data'][$i]['gopts'] = $gopts; $sort_idx++; } } $data['total'] = $i; return serendipity_smarty_show('admin/show_plugins.fnc.tpl', $data); }
/** * * check if the user have the needed rights to do something by userid * * @see checkUser * @access private * @return boolean * */ function checkPageUser($authorid) { global $serendipity; if (empty($authorid) || (int) $authorid === 0) { return true; } $user = (array) serendipity_fetchUsers($authorid); return $this->checkUser($user[0]); }
function import() { global $serendipity; // Force user to select a blog to act on if (empty($this->data['bId']) || $this->data['bId'] == 0) { echo 'Please select a blog to import!'; return false; } // Save this so we can return it to its original value at the end of this method. $noautodiscovery = isset($serendipity['noautodiscovery']) ? $serendipity['noautodiscovery'] : false; if ($this->data['autodiscovery'] == 'false') { $serendipity['noautodiscovery'] = 1; } $this->getTransTable(); // Prepare export request $req = new HTTP_Request('http://www.blogger.com/feeds/' . $this->data['bId'] . '/archive'); $req->addHeader('GData-Version', 2); $req->addHeader('Authorization', 'AuthSub token="' . $this->data['bAuthToken'] . '"'); // Attempt fetch blog export $req->sendRequest(); // Handle errors if ($req->getResponseCode() != '200') { echo "Error occured while trying to export the blog."; return false; } // Export success echo '<span class="block_level">Successfully exported entries from Blogger</span>'; // Get Serendipity authors list $authorList = array(); $s9y_users = serendipity_fetchUsers(); foreach ($s9y_users as $user) { $authorList[$user['authorid']] = $user['username']; } unset($s9y_users); // Load export $bXml = simplexml_load_string($req->getResponseBody()); // Process entries $entryList = $entryFailList = array(); foreach ($bXml->entry as $bEntry) { // Check entry type switch ($bEntry->category['term']) { case 'http://schemas.google.com/blogger/2008/kind#post': // Process posts: // Create author if not in serendipity $author = (string) $bEntry->author->name; if (!array_search($author, $authorList)) { serendipity_db_insert('authors', array('right_publish' => 1, 'realname' => $author, 'username' => $author, 'userlevel' => 0, 'password' => md5($this->data['defaultpass']))); $authorid = serendipity_db_insert_id('authors', 'authorid'); $authorList[$authorid] = $author; } $sEntry = array('title' => $this->decode((string) $bEntry->title), 'isdraft' => $bEntry->children('http://purl.org/atom/app#')->control->draft == 'yes' ? 'true' : 'false', 'allow_comments' => count($bEntry->xpath("*[@rel='replies']")) > 0 ? 'true' : 'false', 'timestamp' => strtotime($bEntry->published), 'body' => $this->strtr((string) $bEntry->content), 'extended' => '', 'categories' => $this->data['bCategory'], 'author' => $author, 'authorid' => $authorid); // Add entry to s9y echo '..~.. '; if (is_int($id = serendipity_updertEntry($sEntry))) { // Add entry id to processed table for later lookups $entryList[(string) $bEntry->id] = array($id, $sEntry['title'], 0); } else { // Add to fail list $entryFailList[] = $sEntry['title']; } break; case 'http://schemas.google.com/blogger/2008/kind#comment': // Process comments: // Extract entry id for comment $cEntryId = $bEntry->xpath("thr:in-reply-to[@ref]"); $cEntryId = (string) $cEntryId[0]['ref']; // Check to make sure the related entry has been added to s9y if (array_key_exists($cEntryId, $entryList)) { // Add to s9y $sComment = array('entry_id ' => $entryList[$cEntryId][0], 'parent_id' => 0, 'timestamp' => strtotime($bEntry->published), 'author' => (string) $bEntry->author->name, 'email' => (string) $bEntry->author->email, 'url' => (string) isset($bEntry->author->uri) ? $bEntry->author->uri : '', 'ip' => '', 'status' => 'approved', 'body' => $this->strtr((string) $bEntry->content), 'subscribed' => 'false', 'type' => 'NORMAL'); serendipity_db_insert('comments', $sComment); // Update entry list with comment count $entryList[$cEntryId][2]++; } break; } } // Report on resultant authors echo '<span class="block_level">Current list of authors: </span>' . join(', ', array_values($authorList)); // Do cleanup and report on entries echo '<span class="block_level">The following entries were successfully imported:</span>'; echo '<ul>'; foreach ($entryList as $eId => $eDetails) { // Update comment count for entry in s9y serendipity_db_query("UPDATE " . $serendipity['dbPrefix'] . "entries SET comments = " . $eDetails[2] . " WHERE id = " . $eDetails[0]); echo '<li>' . $eDetails[1] . ' comments(' . $eDetails[2] . ')</li>'; } echo '</ul>'; // Report fails echo '<span class="block_level">The following entries ran into trouble and was not imported:</span>'; echo '<ul>'; foreach ($entryFailList as $eId => $eDetails) { echo '<li>' . $eDetails . '</li>'; } echo '</ul>'; // Reset autodiscovery $serendipity['noautodiscovery'] = $noautodiscovery; // All done! echo '<span class="msg_notice">Import finished.</span>'; return true; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; if ($event == 'frontend_header') { $start_url = $serendipity['baseURL']; $start_title = $serendipity['blogTitle']; echo '<link rel="start" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; if ($serendipity['GET']['action'] == 'read' && !empty($serendipity['GET']['id'])) { // Article detail view echo '<link rel="up" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; $this->backAndForth($this->showPaging($serendipity['GET']['id'])); // END article detail view echo '<link rel="canonical" href="' . $this->getEntry($serendipity['GET']['id']) . '" />' . "\n"; } elseif ($serendipity['GET']['action'] == 'read' && is_array($serendipity['range'])) { // Specific Date Archives view echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n"; echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n"; $links = array(); $add_query = ''; $year = date('Y', $serendipity['range'][0]); $month = date('m', $serendipity['range'][0]); $day = date('d', $serendipity['range'][0]); $pageMonthNext = array('day' => '1', 'month' => $month + 1, 'year' => $year); $pageMonthPrev = array('day' => '1', 'month' => $month - 1, 'year' => $year); $pageDayNext = array('day' => $day + 1, 'month' => $month, 'year' => $year); $pageDayPrev = array('day' => $day - 1, 'month' => $month, 'year' => $year); $diff = $serendipity['range'][1] - $serendipity['range'][0]; if (isset($serendipity['GET']['category'])) { $categoryid = (int) serendipity_db_escape_string($serendipity['GET']['category']); $add_query = '/C' . $categoryid; } if ($diff < 86400) { // Paging day by day $ts = mktime(0, 0, 0, $pageDayPrev['month'], $pageDayPrev['day'], $pageDayPrev['year']); $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false))); $ts = mktime(0, 0, 0, $pageDayNext['month'], $pageDayNext['day'], $pageDayNext['year']); $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false))); } elseif ($diff < 86400 * 28) { // Paging by week // TODO - Don't know :-) } else { // Paging by month $ts = mktime(0, 0, 0, $pageMonthPrev['month'], $pageMonthPrev['day'], $pageMonthPrev['year']); $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false))); $ts = mktime(0, 0, 0, $pageMonthNext['month'], $pageMonthNext['day'], $pageMonthNext['year']); $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false))); } $this->backAndForth($links); // END Specific Date Archives view } elseif ($serendipity['GET']['action'] == 'archives') { // Full month/year archives overview echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n"; // END Full month/year archives overview echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n"; } elseif (!empty($serendipity['GET']['category'])) { // Category based view $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); if (function_exists('serendipity_categoryURL')) { $categories_url = serendipity_categoryURL($cInfo, 'serendipityHTTPPath'); } else { $categories_url = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cInfo['categoryid'], 'title' => $cInfo['category_name'])), 'serendipityHTTPPath'); } echo '<link rel="up" href="' . $categories_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cInfo['category_name']) : htmlspecialchars($cInfo['category_name'], ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; echo '<link rel="canonical" href="' . $categories_url . '" />' . "\n"; $categories = serendipity_fetchCategories('all'); $links = array(); if (is_array($categories) && count($categories)) { $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); $capture_next = false; foreach ($categories as $cat) { if ($capture_next) { $links['next'] = $this->getCat($cat); break; } if (is_array($prev_cat) && $cat['categoryid'] == $serendipity['GET']['category']) { $links['prev'] = $this->getCat($prev_cat); $capture_next = true; } $prev_cat = $cat; } } $this->backAndForth($links); // END Category based view } elseif (!empty($serendipity['GET']['viewAuthor'])) { // User view $uInfo = serendipity_fetchUsers(); $links = array(); if (is_array($uInfo)) { $capture_next = false; foreach ($uInfo as $user) { if ($capture_next) { $links['next'] = $this->getUser($user); break; } if ($user['authorid'] == $serendipity['GET']['viewAuthor']) { $authors_url = $this->getUser($user); echo '<link rel="up" href="' . $authors_url['link'] . '" title="' . $authors_url['title'] . '" />' . "\n"; echo '<link rel="canonical" href="' . $authors_url['link'] . '" />' . "\n"; if (is_array($prev_user)) { $links['prev'] = $this->getUser($prev_user); $capture_next = true; } } $prev_user = $user; } $this->backAndForth($links); } // END User view } else { // Frontpage $this->backAndForth(); // END Frontpage if ($serendipity['view'] == 'start') { echo '<link rel="canonical" href="' . $serendipity['baseURL'] . '" />' . "\n"; } } } }
<?php } else { ?> <input type="submit" name="SAVE_NEW" value="<?php echo CREATE_NEW_USER; ?> " class="serendipityPrettyButton input_button" /> <?php } ?> </div> </form> <?php } elseif ($serendipity['GET']['adminAction'] == 'delete' && serendipity_checkPermission('adminUsersDelete')) { $user = serendipity_fetchUsers($serendipity['GET']['userid']); $group_intersect = serendipity_intersectGroup($user[0]['authorid']); if (serendipity_checkPermission('adminUsersMaintainOthers') || serendipity_checkPermission('adminUsersMaintainSame') && $group_intersect) { ?> <form action="?serendipity[adminModule]=users" method="post"> <div> <?php printf(DELETE_USER, (int) $serendipity['GET']['userid'], htmlspecialchars($user[0]['realname'])); ?> <br /><br /> <?php echo serendipity_setFormToken(); ?> <input type="hidden" name="serendipity[user]" value="<?php echo (int) $serendipity['GET']['userid']; ?>
function showUsers() { global $serendipity; if (!empty($serendipity['POST']['submitProfile'])) { echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } if (!empty($serendipity['POST']['submitProfileOptions'])) { echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; } if (!empty($serendipity['POST']['createVcard'])) { if ($this->createVCard($serendipity['POST']['profileUser'])) { echo '<div class="serendipityAdminMsgSuccess">' . DONE . ': ' . sprintf(PLUGIN_EVENT_USERPROFILES_VCARDCREATED_AT, serendipity_strftime('%H:%M:%S')) . '</div>'; echo '<div class="serendipityAdminMsgNote"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="" />' . IMPORT_NOTES . ': ' . PLUGIN_EVENT_USERPROFILES_VCARDCREATED_NOTE . '</div>'; } else { echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . ERROR . ': ' . PLUGIN_EVENT_USERPROFILES_VCARDNOTCREATED . '</div>'; } } echo '<form action="?" method="post" class="userprofileform">' . "\n"; echo '<input type="hidden" name="serendipity[adminModule]" value="event_display" />' . "\n"; echo '<input type="hidden" name="serendipity[adminAction]" value="profiles" />' . "\n"; echo "<div>\n"; echo '<strong>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars(PLUGIN_EVENT_USERPROFILES_SELECT) : htmlspecialchars(PLUGIN_EVENT_USERPROFILES_SELECT, ENT_COMPAT, LANG_CHARSET)) . '</strong><br /><br />' . "\n"; echo USER . ' <select name="serendipity[profileUser]">' . "\n"; $users = serendipity_fetchUsers(); foreach ($users as $user) { echo '<option value="' . $user['authorid'] . '" ' . (empty($serendipity['POST']['profileUser']) && $serendipity['authorid'] == $user['authorid'] || $serendipity['POST']['profileUser'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; } echo '</select>' . "\n"; echo ' <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[viewUser]" value="' . VIEW . '" />' . "\n"; if ($this->checkUser($user)) { echo ' <input class="serendipityPrettyButton input_button" type="submit" name="submit" value="' . EDIT . '" />' . "\n"; echo ' <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[editOptions]" value="' . ADVANCED_OPTIONS . '" />' . "\n"; ## very very bad the next line (show only when edit the local_properties) if (!empty($serendipity['POST']['profileUser']) && empty($serendipity['POST']['editOptions']) && empty($serendipity['POST']['viewUser'])) { echo ' <input class="serendipityPrettyButton input_button" type="submit" name="serendipity[createVcard]" value="' . PLUGIN_EVENT_USERPROFILES_VCARD . '" />' . "\n"; } } echo "</div><br />\n<hr />\n"; if (!empty($serendipity['POST']['profileUser'])) { $user = serendipity_fetchUsers($serendipity['POST']['profileUser']); if ($this->checkUser($user[0])) { if (!empty($serendipity['POST']['viewUser']) && $serendipity['POST']['profileUser'] != $serendipity['authorid']) { $this->showUser($user[0]); } elseif (!empty($serendipity['POST']['editOptions']) || !empty($serendipity['POST']['submitProfileOptions'])) { $this->editOptions($user[0]); } else { $this->editUser($user[0]); } } else { $this->showUser($user[0]); } } else { $user = serendipity_fetchUsers($serendipity['authorid']); $this->editUser($user[0]); } echo "</form>\n\n"; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); $links = array(); if (isset($hooks[$event])) { $sort_order = array('timestamp' => DATE, 'isdraft' => PUBLISH . '/' . DRAFT, 'a.realname' => AUTHOR, 'category_name' => CATEGORY, 'last_modified' => LAST_UPDATED, 'title' => TITLE); $per_page_max = 50; $per_page = array('12', '16', '25', $per_page_max); switch ($event) { case 'frontend_fetchentries': if ($this->fetchLimit > 0) { $serendipity['fetchLimit'] = $this->fetchLimit; } break; case 'frontend_configure': $_SERVER['REQUEST_URI'] = str_replace('%2Fplugin%2Ffilter%2F', '/plugin/filter/', $_SERVER['REQUEST_URI']); break; case 'entries_footer': $link = $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'plugin/filter/'; ?> <div id="filter_entries_container"> <br /> <hr /> <form action="<?php echo $link; ?> " method="get"> <?php if ($serendipity['rewrite'] == 'none') { ?> <input type="hidden" name="/plugin/filter/" value="" /> <?php } ?> <table width="100%"> <tr> <td colspan="6" style="text-align: left"><strong><?php echo FILTERS; ?> </strong> - <?php echo FIND_ENTRIES; ?> </td> </tr> <tr> <td width="80"><?php echo AUTHOR; ?> </td> <td> <select name="filter[author]"> <option value="">--</option> <?php $users = serendipity_fetchUsers(); if (is_array($users)) { foreach ($users as $user) { echo '<option value="' . $user['authorid'] . '" ' . (isset($_SESSION['filter']['author']) && $_SESSION['filter']['author'] == $user['authorid'] ? 'selected="selected"' : '') . '>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)) . '</option>' . "\n"; } } ?> </select> </td> <td width="80"><?php echo CATEGORY; ?> </td> <td> <select name="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'] . '"' . ($_SESSION['filter']['category'] == $cat['categoryid'] ? ' selected="selected"' : '') . '>' . str_repeat(' ', $cat['depth']) . $cat['category_name'] . '</option>' . "\n"; } ?> </select> </td> <td width="80"><?php echo CONTENT; ?> </td> <td><input size="10" type="text" name="filter[body]" value="<?php echo isset($_SESSION['filter']['body']) ? function_exists('serendipity_specialchars') ? serendipity_specialchars($_SESSION['filter']['body']) : htmlspecialchars($_SESSION['filter']['body'], ENT_COMPAT, LANG_CHARSET) : ''; ?> " /></td> </tr> <tr> <td colspan="6" style="text-align: left"><strong><?php echo SORT_ORDER; ?> </strong></td> </tr> <tr> <td><?php echo SORT_BY; ?> </td> <td> <select name="sort[order]"> <?php foreach ($sort_order as $so_key => $so_val) { echo '<option value="' . $so_key . '" ' . (isset($_SESSION['sort']['order']) && $_SESSION['sort']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>' . "\n"; } ?> </select> </td> <td><?php echo SORT_ORDER; ?> </td> <td> <select name="sort[ordermode]"> <option value="DESC" <?php echo isset($_SESSION['sort']['ordermode']) && $_SESSION['sort']['ordermode'] == 'DESC' ? 'selected="selected"' : ''; ?> ><?php echo SORT_ORDER_DESC; ?> </option> <option value="ASC" <?php echo isset($_SESSION['sort']['ordermode']) && $_SESSION['sort']['ordermode'] == 'ASC' ? 'selected="selected"' : ''; ?> ><?php echo SORT_ORDER_ASC; ?> </option> </select> </td> <td><?php echo ENTRIES_PER_PAGE; ?> </td> <td> <select name="sort[perPage]"> <?php foreach ($per_page as $per_page_nr) { echo '<option value="' . $per_page_nr . '" ' . (isset($_SESSION['sort']['perPage']) && $_SESSION['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" /></td> </tr> </table> </form> </div> <?php return true; break; case 'external_plugin': $uri_parts = explode('?', str_replace('&', '&', $eventData)); $parts = explode('/', $uri_parts[0]); $plugincode = $parts[0]; unset($parts[0]); $uri = $_SERVER['REQUEST_URI']; $puri = parse_url($uri); $queries = explode('&', str_replace(array('%5B', '%5D'), array('[', ']'), $puri['query'])); foreach ($queries as $query_part) { $query = explode('=', $query_part); switch ($query[0]) { case 'filter[author]': $_GET['filter']['author'] = urldecode($query[1]); break; case 'filter[category]': $_GET['filter']['category'] = urldecode($query[1]); break; case 'filter[body]': $_GET['filter']['body'] = urldecode($query[1]); break; case 'sort[order]': $_GET['sort']['order'] = urldecode($query[1]); break; case 'sort[ordermode]': $_GET['sort']['ordermode'] = urldecode($query[1]); break; case 'sort[perPage]': $_GET['sort']['perPage'] = urldecode($query[1]); break; } } if (is_array($_GET['filter'])) { $_SESSION['filter'] = $_GET['filter']; } if (is_array($_GET['sort'])) { $_SESSION['sort'] = $_GET['sort']; } /* Attempt to locate hidden variables within the URI */ foreach ($serendipity['uriArguments'] as $k => $v) { if ($v[0] == 'P') { /* Page */ $page = substr($v, 1); if (is_numeric($page)) { $serendipity['GET']['page'] = $page; unset($serendipity['uriArguments'][$k]); } } } switch ($plugincode) { case 'filter': $perPage = (int) (!empty($_SESSION['sort']['perPage']) ? $_SESSION['sort']['perPage'] : $per_page[0]); if ($perPage > $per_page_max) { $perPage = $per_page_max; } $serendipity['fetchLimit'] = $perPage; $this->fetchLimit = $perPage; $page = (int) $serendipity['GET']['page']; if ($page == 0) { $page = 1; } $offSet = $perPage * ($page - 1); if (empty($_SESSION['sort']['ordermode']) || $_SESSION['sort']['ordermode'] != 'ASC') { $_SESSION['sort']['ordermode'] = 'DESC'; } if (!empty($_SESSION['sort']['order']) && !empty($sort_order[$_SESSION['sort']['order']])) { $orderby = serendipity_db_escape_string($_SESSION['sort']['order'] . ' ' . $_SESSION['sort']['ordermode']); } else { $orderby = 'timestamp ' . serendipity_db_escape_string($_SESSION['sort']['ordermode']); } $filter = array(); if (!empty($_SESSION['filter']['author'])) { $filter[] = "e.authorid = '" . serendipity_db_escape_string($_SESSION['filter']['author']) . "'"; } if (!empty($_SESSION['filter']['category'])) { $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($_SESSION['filter']['category']) . "'"; } if (!empty($_SESSION['filter']['body'])) { if ($serendipity['dbType'] == 'mysql') { $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($_SESSION['filter']['body']) . "')"; $full = true; } } $filter_sql = implode(' AND ', $filter); // Fetch the entries $entries = serendipity_fetchEntries(false, false, serendipity_db_limit($offSet, $perPage), true, false, $orderby, $filter_sql); $serendipity['smarty_raw_mode'] = true; include_once S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; serendipity_printEntries($entries); $raw_data = ob_get_contents(); ob_end_clean(); $serendipity['smarty']->assign('CONTENT', $raw_data); $serendipity['smarty']->assign('is_raw_mode', false); serendipity_gzCompression(); $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath')); break; } return true; break; default: return false; break; } } else { return false; } }
/** * Prints a media item * * @param array Array of image metadata * @param string URL for maintenance tasks * @param boolean Whether to show maintenance task items * @param int how many media items to display per row * @param boolean Enclose within a table cell? * @param array Additional Smarty variables * @return string Generated HTML * */ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lineBreak = 3, $enclose = true, $smarty_vars = array()) { global $serendipity; $form_hidden = ''; // do not add, if not for the default media list form if (($serendipity['GET']['adminAction'] == 'default' || empty($serendipity['GET']['adminAction'])) && !$serendipity['GET']['fid']) { foreach ($serendipity['GET'] as $g_key => $g_val) { // do not add token, since this is assigned separately to properties and list forms if (!is_array($g_val) && $g_key != 'page' && $g_key != 'token') { $form_hidden .= ' <input type="hidden" name="serendipity[' . $g_key . ']" value="' . serendipity_specialchars($g_val) . '">' . "\n"; } } } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $order_fields = serendipity_getImageFields(); // reset filename for building template filters, since this is hardcoded as 'only_filename' unset($order_fields['i.name']); $media = array('manage' => $manage, 'multiperm' => serendipity_checkPermission('adminImagesDirectories'), 'lineBreak' => $lineBreak, 'lineBreakP' => round(1 / $lineBreak * 100), 'url' => $url, 'enclose' => $enclose, 'token' => serendipity_setFormToken(), 'form_hidden' => $form_hidden, 'blimit_path' => empty($smarty_vars['limit_path']) ? '' : basename($smarty_vars['limit_path']), 'only_path' => $serendipity['GET']['only_path'], 'only_filename' => $serendipity['GET']['only_filename'], 'sortorder' => $serendipity['GET']['sortorder'], 'keywords_selected' => $serendipity['GET']['keywords'], 'filter' => $serendipity['GET']['filter'], 'sort_order' => $order_fields, 'simpleFilters' => $serendipity['simpleFilters'], 'hideSubdirFiles' => $serendipity['GET']['hideSubdirFiles'], 'authors' => serendipity_fetchUsers(), 'sort_row_interval' => array(8, 16, 50, 100), 'nr_files' => count($file), 'keywords' => explode(';', $serendipity['mediaKeywords']), 'thumbSize' => $serendipity['thumbSize'], 'sortParams' => array('perpage', 'order', 'ordermode')); $media = array_merge($media, $smarty_vars); $media['files'] =& $file; if (count($paths) > 0) { $media['paths'] =& $paths; } else { $media['paths'] =& serendipity_getMediaPaths(); } $serendipity['smarty']->assignByRef('media', $media); if ($enclose) { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); return serendipity_smarty_show('admin/media_pane.tpl'); } else { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); return serendipity_smarty_show('admin/media_properties.tpl'); } }
if ($v[0] == 'P') { /* Page */ $page = substr($v, 1); if (is_numeric($page)) { $serendipity['GET']['page'] = $page; unset($_args[$k]); unset($serendipity['uriArguments'][$k]); } } } if (!$is_multiauth) { $matches[1] = serendipity_searchPermalink($serendipity['permalinkAuthorStructure'], implode('/', $serendipity['uriArguments']), $matches[1], 'author'); $serendipity['GET']['viewAuthor'] = $matches[1]; $serendipity['GET']['action'] = 'read'; } $uInfo = serendipity_fetchUsers($serendipity['GET']['viewAuthor']); if (!is_array($uInfo)) { $serendipity['view'] = '404'; $serendipity['viewtype'] = '404_3'; header('HTTP/1.0 404 Not found'); header('Status: 404 Not found'); } else { $serendipity['head_title'] = sprintf(ENTRIES_BY, $uInfo[0]['realname']); $serendipity['head_subtitle'] = $serendipity['blogTitle']; } include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; } else { if (preg_match(PAT_SEARCH, $uri, $matches)) { $serendipity['view'] = 'search'; $_args = $serendipity['uriArguments']; /* Attempt to locate hidden variables within the URI */
echo NAME; ?> </td> <td><input class="input_textbox" type="text" name="serendipity[name]" value="<?php echo htmlspecialchars($from['name']); ?> " /></td> </tr> <tr> <td valign="top"><?php echo USERCONF_GROUPS; ?> </td> <td><select name="serendipity[members][]" multiple="multiple" size="5"> <?php $allusers = serendipity_fetchUsers(); $users = serendipity_getGroupUsers($from['id']); $selected = array(); foreach ((array) $users as $user) { $selected[$user['id']] = true; } foreach ($allusers as $user) { echo '<option value="' . (int) $user['authorid'] . '" ' . (isset($selected[$user['authorid']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n"; } ?> </select> </td> </tr> <tr> <td colspan="2"> </td> </tr>
/** * Returns HTML code for the ownership column of the plugin listing * * Used by the function show_plugins() * * @access private * @see show_plugins() * @param int ID of the current user * @param string plugin name * @param boolean Toggle whether the plugin belongs to the current author * @return null */ function ownership($authorid, $name, $is_plugin_owner = false) { global $serendipity; static $users = array(); if (empty($users)) { $users = serendipity_fetchUsers(); } if ($is_plugin_owner) { ?> <select name="serendipity[ownership][<?php echo $name; ?> ]"> <option value="0"><?php echo ALL_AUTHORS; ?> </option> <?php } foreach ($users as $user) { if (!$is_plugin_owner && $user['authorid'] == $authorid) { $realname = htmlspecialchars($user['realname']); } elseif ($is_plugin_owner) { ?> <option value="<?php echo $user['authorid']; ?> "<?php echo $user['authorid'] == $authorid ? ' selected="selected"' : ''; ?> ><?php echo htmlspecialchars($user['realname']); ?> </option> <?php } } if ($is_plugin_owner) { ?> </select> <?php } else { echo empty($realname) ? ALL_AUTHORS : $realname; } }
function showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more = array()) { global $serendipity; switch ($element) { case 'sticky': ?> <div class="entryproperties_sticky"> <input class="input_checkbox" type="checkbox" name="serendipity[properties][is_sticky]" id="properties_is_sticky" value="true" <?php echo $is_sticky; ?> /> <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> " for="properties_is_sticky"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> </label> </div> <?php return true; case 'frontpage': ?> <div class="entryproperties_frontpage"> <input class="input_checkbox" type="checkbox" name="serendipity[properties][no_frontpage]" id="properties_no_frontpage" value="true" <?php echo $no_frontpage; ?> /> <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> " for="properties_no_frontpage"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> </label> </div> <?php return true; case 'hiderss': ?> <div class="entryproperties_hiderss"> <input class="input_checkbox" type="checkbox" name="serendipity[properties][hiderss]" id="properties_hiderss" value="true" <?php echo $hiderss; ?> /> <label title="<?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS_DESC; ?> " for="properties_hiderss"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS; ?> </label> </div> <?php return true; case 'access': ?> <br /><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS; ?> :<br /> <div class="entryproperties_access_list" style="margin-left: 10px"> <?php foreach ($access_values as $radio_title => $radio_value) { ?> <input class="input_radio" type="radio" name="serendipity[properties][access]" id="properties_access_<?php echo $radio_value; ?> " value="<?php echo $radio_value; ?> " <?php echo $radio_value == $access ? 'checked="checked"' : ''; ?> /> <label title="<?php echo $radio_title; ?> " for="properties_access_<?php echo $radio_value; ?> "> <?php echo $radio_title; ?> </label> <?php } ?> </div> <?php return true; case 'password': ?> <br /><?php echo PASSWORD; ?> :<br /> <div style="margin-left: 10px" class="entryproperties_access_pw"> <input autocomplete="off" class="input_textbox" type="password" name="serendipity[properties][entrypassword]" value="<?php echo htmlspecialchars($password); ?> " /> </div> <?php return true; case 'groups': if ($use_groups) { $my_groups = serendipity_getGroups($serendipity['authorid']); ?> <br /><?php echo PERM_READ . ': <em>' . GROUP . '</em>'; ?> <br /> <select class="entryproperties_access_groups" onchange="document.getElementById('properties_access_member').checked = true;" style="margin-left: 5px" multiple="multiple" name="serendipity[properties][access_groups][]" size="4"> <?php foreach ($my_groups as $group) { if ('USERLEVEL_' == substr($group['confvalue'], 0, 10)) { $group['name'] = constant($group['confvalue']); } ?> <option value="<?php echo $group['id']; ?> " <?php echo in_array($group['id'], $access_groups) ? 'selected="selected"' : ''; ?> ><?php echo htmlspecialchars($group['name']); ?> </option> <?php } echo '</select><br />'; } return true; case 'authors': if ($use_users) { ?> <br /><?php echo PERM_READ . ': <em>' . AUTHOR . '</em>'; ?> <br /> <select class="entryproperties_access_users" onchange="document.getElementById('properties_access_member').checked = true;" style="margin-left: 5px" multiple="multiple" name="serendipity[properties][access_users][]" size="4"> <?php $users = serendipity_fetchUsers('', 'hidden'); foreach ($users as $user) { ?> <option value="<?php echo $user['authorid']; ?> " <?php echo in_array($user['authorid'], $access_users) ? 'selected="selected"' : ''; ?> ><?php echo htmlspecialchars($user['realname']); ?> </option> <?php } echo '</select><br />'; } return true; case 'author': ?> <br /><?php echo AUTHOR; ?> :<br /> <div class="entryproperties_access_author" style="margin-left: 10px"> <select name="serendipity[change_author]"> <?php if (isset($serendipity['POST']['change_author'])) { $selected_user = $serendipity['POST']['change_author']; } elseif (!empty($eventData['authorid'])) { $selected_user = $eventData['authorid']; } else { $selected_user = $serendipity['authorid']; } $avail_users =& $this->getValidAuthors(); foreach ($avail_users as $user) { echo '<option value="' . $user['authorid'] . '" ' . ($selected_user == $user['authorid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($user['realname']) . '</option>' . "\n"; } ?> </select> </div> <?php return true; case 'markup': ?> <br /><div class="entryproperties_markup"> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP; ?> <br /> <div style="margin-left: 10px"> <select name="serendipity[properties][disable_markups][]" multiple="multiple" size="4"> <?php $plugins = serendipity_plugin_api::get_event_plugins(); if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { if (!is_array($plugin_data['p']->markup_elements)) { continue; } if (isset($serendipity['POST']['properties']['disable_markups']) && in_array($plugin_data['p']->instance, $serendipity['POST']['properties']['disable_markups'])) { $selected = true; } elseif (isset($eventData['properties']['ep_disable_markup_' . $plugin_data['p']->instance])) { $selected = true; } else { $selected = false; } echo '<option ' . ($selected ? 'selected="selected"' : '') . ' value="' . $plugin_data['p']->instance . '">' . htmlspecialchars($plugin_data['p']->title) . '</option>' . "\n"; } } ?> </select> </div> </div> <?php return true; case 'customfields': ?> <br /><div class="entryproperties_customfields"> <?php $fields = trim($this->get_config('customfields')); if (!empty($fields)) { $fields = explode(',', $fields); } if (is_array($fields) && count($fields) > 0) { ?> <br /> <?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS; ?> :<br /> <em><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1 . '<br />' . sprintf(PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3, 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance); ?> </em><br /> <div style="margin-left: 10px"> <table id="serendipity_customfields"> <?php foreach ($fields as $fieldname) { $fieldname = htmlspecialchars(trim($fieldname)); if (isset($serendipity['POST']['properties'][$fieldname])) { $value = $serendipity['POST']['properties'][$fieldname]; } elseif (!empty($eventData['properties']['ep_' . $fieldname])) { $value = $eventData['properties']['ep_' . $fieldname]; } else { $value = ''; } ?> <tr> <td class="customfield_<?php echo $fieldname; ?> customfield_name"><strong><?php echo $fieldname; ?> </strong></td> <td class="customfield_<?php echo $fieldname; ?> customfield_value"><textarea id="prop<?php echo htmlspecialchars($fieldname); ?> " name="serendipity[properties][<?php echo htmlspecialchars($fieldname); ?> ]"><?php echo htmlspecialchars($value); ?> </textarea></td> <td valign="top"><script type="text/javascript" language="JavaScript">document.write('<input class="serendipityPrettyButton input_button" type="button" name="insImage" value="<?php echo MEDIA; ?> " onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=prop<?php echo htmlspecialchars($fieldname); ?> &serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton" />');</script></td> </tr> <?php } ?> </table> </div> <?php } ?> </div> <?php return true; } }
function showBackend($element, $eventData, $is_sticky, $no_frontpage, $hiderss, $access_values, $access, $password, $use_groups, $access_groups, $use_users, $access_users, $more = array()) { global $serendipity; switch ($element) { case 'sticky': ?> <div class="entryproperties_sticky adv_opts_box form_check"> <input id="properties_is_sticky" name="serendipity[properties][is_sticky]" type="checkbox" value="true" <?php echo $is_sticky; ?> > <label for="properties_is_sticky"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_STICKYPOSTS; ?> </label> </div> <?php return true; case 'frontpage': ?> <div class="entryproperties_frontpage adv_opts_box form_check"> <input id="properties_no_frontpage" name="serendipity[properties][no_frontpage]" type="checkbox" value="true" <?php echo $no_frontpage; ?> > <label for="properties_no_frontpage"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_NO_FRONTPAGE; ?> </label> </div> <?php return true; case 'hiderss': ?> <div class="entryproperties_hiderss adv_opts_box form_check"> <input id="properties_hiderss" name="serendipity[properties][hiderss]" type="checkbox" value="true" <?php echo $hiderss; ?> > <label for="properties_hiderss"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_HIDERSS; ?> </label> </div> <?php return true; case 'access': ?> <fieldset class="entryproperties_access_list adv_opts_box"> <span class="wrap_legend"><legend><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_ACCESS; ?> :</legend></span> <div class="clearfix"> <?php foreach ($access_values as $radio_title => $radio_value) { ?> <div class="form_radio"> <input id="properties_access_<?php echo $radio_value; ?> " name="serendipity[properties][access]" type="radio" value="<?php echo $radio_value; ?> " <?php echo $radio_value == $access ? 'checked="checked"' : ''; ?> > <label for="properties_access_<?php echo $radio_value; ?> "><?php echo $radio_title; ?> </label> </div> <?php } ?> </div> </fieldset> <?php return true; case 'password': ?> <div class="entryproperties_access_pw adv_opts_box adv_opts_box form_field"> <label for="properties_access_pw"><?php echo PASSWORD; ?> :</label> <input type="password" name="ignore_password" value="" style="display:none"> <input id="properties_access_pw" name="serendipity[properties][entrypassword]" type="password" autocomplete="off" value="<?php echo serendipity_specialchars($password); ?> "> </div> <?php return true; case 'groups': if ($use_groups) { $my_groups = serendipity_getGroups($serendipity['authorid']); ?> <div class="entryproperties_access_groups adv_opts_box form_multiselect"> <label for="properties_access_groups"><?php echo PERM_READ . ': ' . GROUP; ?> </label> <select id="properties_access_groups" name="serendipity[properties][access_groups][]" multiple="multiple" size="4" onchange="document.getElementById('properties_access_member').checked = true;"> <?php foreach ($my_groups as $group) { if ('USERLEVEL_' == substr($group['confvalue'], 0, 10)) { $group['name'] = constant($group['confvalue']); } ?> <option value="<?php echo $group['id']; ?> " <?php echo in_array($group['id'], $access_groups) ? 'selected="selected"' : ''; ?> ><?php echo serendipity_specialchars($group['name']); ?> </option> <?php } echo '</select>'; echo '</div>'; } return true; case 'authors': if ($use_users) { ?> <div class="entryproperties_access_users adv_opts_box form_multiselect"> <label for="properties_access_users"><?php echo PERM_READ . ': ' . AUTHOR; ?> </label> <select id="properties_access_users" name="serendipity[properties][access_users][]" multiple="multiple" size="4" onchange="document.getElementById('properties_access_member').checked = true;"> <?php $users = serendipity_fetchUsers('', 'hidden'); foreach ($users as $user) { ?> <option value="<?php echo $user['authorid']; ?> " <?php echo in_array($user['authorid'], $access_users) ? 'selected="selected"' : ''; ?> ><?php echo serendipity_specialchars($user['realname']); ?> </option> <?php } echo '</select>'; echo '</div>'; } return true; case 'author': ?> <div class="entryproperties_access_author adv_opts_box form_select"> <label for="properties_access_author"><?php echo AUTHOR; ?> :</label> <select id="properties_access_author" name="serendipity[change_author]"> <?php if (isset($serendipity['POST']['change_author'])) { $selected_user = $serendipity['POST']['change_author']; } elseif (!empty($eventData['authorid'])) { $selected_user = $eventData['authorid']; } else { $selected_user = $serendipity['authorid']; } $avail_users =& $this->getValidAuthors(); foreach ($avail_users as $user) { echo '<option value="' . $user['authorid'] . '" ' . ($selected_user == $user['authorid'] ? ' selected="selected"' : '') . '>' . serendipity_specialchars($user['realname']) . '</option>' . "\n"; } ?> </select> </div> <?php return true; case 'markup': ?> <div class="entryproperties_markup adv_opts_box form_multiselect"> <label for="properties_markup"><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_DISABLE_MARKUP; ?> </label> <select id="properties_markup" name="serendipity[properties][disable_markups][]" multiple="multiple" size="4"> <?php $plugins = serendipity_plugin_api::get_event_plugins(); if (is_array($plugins)) { // foreach() operates on copies of values, but we want to operate on references, so we use while() @reset($plugins); while (list($plugin, $plugin_data) = each($plugins)) { if (!is_array($plugin_data['p']->markup_elements)) { continue; } if (isset($serendipity['POST']['properties']['disable_markups']) && in_array($plugin_data['p']->instance, $serendipity['POST']['properties']['disable_markups'])) { $selected = true; } elseif (isset($eventData['properties']['ep_disable_markup_' . $plugin_data['p']->instance])) { $selected = true; } else { $selected = false; } // automatically mark nl2br markup parser as disabled, when WYSIWYG is active if (!$selected && $serendipity['wysiwyg'] && $plugin_data['p']->act_pluginPath == 'serendipity_event_nl2br') { $selected = true; } echo '<option ' . ($selected ? 'selected="selected"' : '') . ' value="' . $plugin_data['p']->instance . '">' . serendipity_specialchars($plugin_data['p']->title) . '</option>' . "\n"; } } ?> </select> </div> <?php return true; case 'customfields': ?> <div class="entryproperties_customfields adv_opts_box"> <?php $fields = trim($this->get_config('customfields')); // Capture special characters for "," and ":" $special_from = array('\\,', '\\:'); $special_to = array(chr(0x1), chr(0x2)); $special_read = array(',', ':'); $fields = str_replace($special_from, $special_to, $fields); if (!empty($fields)) { $fields = explode(',', $fields); } if (is_array($fields) && count($fields) > 0) { ?> <h4><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS; ?> </h4> <span><?php echo PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC1 . sprintf(PLUGIN_EVENT_ENTRYPROPERTIES_CUSTOMFIELDS_DESC3, 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . $this->instance); ?> </span> <div class="serendipity_customfields clearfix"> <?php foreach ($fields as $fieldname) { $fieldparts = explode(':', $fieldname); $fieldname = $fieldparts[0]; $_fieldname = serendipity_specialchars(trim($fieldname)); if (isset($serendipity['POST']['properties'][$_fieldname])) { $value = $serendipity['POST']['properties'][$_fieldname]; } elseif (!empty($eventData['properties']['ep_' . $_fieldname])) { $value = $eventData['properties']['ep_' . $_fieldname]; } else { $value = trim(str_replace($special_to, $special_read, $fieldparts[1])); } ?> <div id="ep_column_<?php echo $_fieldname; ?> " class="clearfix form_area media_choose"> <label for="prop<?php echo $_fieldname; ?> "><?php echo $_fieldname; ?> </label> <textarea id="prop<?php echo $_fieldname; ?> " class="change_preview" name="serendipity[properties][<?php echo $_fieldname; ?> ]" data-configitem="prop<?php echo $_fieldname; ?> "><?php echo serendipity_specialchars($value); ?> </textarea> <button class="customfieldMedia" type="button" name="insImage" title="<?php echo MEDIA; ?> "><span class="icon-picture"></span><span class="visuallyhidden"><?php echo MEDIA; ?> </span></button> <?php if (preg_match('/(\\.jpg|\\.png|\\.bmp)$/', $value)) { ?> <figure id="prop<?php echo $_fieldname; ?> _preview"> <figcaption><?php echo PREVIEW; ?> </figcaption> <img src="<?php echo $value; ?> " alt=""/> </figure> <?php } ?> </div> <?php } ?> </div> <?php } ?> </div> <?php return true; } }
function import_wpxrss() { // TODO: Backtranscoding to NATIVE charset. Currently only works with UTF-8. $dry_run = false; $serendipity['noautodiscovery'] = 1; $uri = $this->data['url']; require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; serendipity_request_start(); $req = new HTTP_Request($uri, array('allowRedirects' => true, 'maxRedirects' => 5)); $res = $req->sendRequest(); if (PEAR::isError($res) || $req->getResponseCode() != '200') { serendipity_request_end(); echo IMPORT_FAILED . ': ' . htmlspecialchars($this->data['url']); echo "<br />\n"; return false; } $fContent = $req->getResponseBody(); serendipity_request_end(); echo strlen($fContent) . " Bytes<br />\n"; if (version_compare(PHP_VERSION, '5.0') === -1) { printf(UNMET_REQUIREMENTS, 'PHP >= 5.0'); echo "<br />\n"; return false; } $xml = simplexml_load_string($fContent); unset($fContent); /* ************* USERS **********************/ $_s9y_users = serendipity_fetchUsers(); $s9y_users = array(); if (is_array($s9y_users)) { foreach ($_s9y_users as $v) { $s9y_users[$v['realname']] = $v; } } /* ************* CATEGORIES **********************/ $_s9y_cat = serendipity_fetchCategories('all'); $s9y_cat = array(); if (is_array($s9y_cat)) { foreach ($_s9y_cat as $v) { $s9y_cat[$v['category_name']] = $v['categoryid']; } } $wp_ns = 'http://wordpress.org/export/1.0/'; $dc_ns = 'http://purl.org/dc/elements/1.1/'; $content_ns = 'http://purl.org/rss/1.0/modules/content/'; $wp_core = $xml->channel->children($wp_ns); foreach ($wp_core->category as $idx => $cat) { //TODO: Parent generation unknown. $cat_name = (string) $cat->cat_name; if (!isset($s9y_cat[$cat_name])) { $cat = array('category_name' => $cat_name, 'category_description' => '', 'parentid' => 0, 'category_left' => 0, 'category_right' => 0); printf(CREATE_CATEGORY, htmlspecialchars($cat_name)); echo "<br />\n"; if ($dry_run) { $s9y_cat[$cat_name] = time(); } else { serendipity_db_insert('category', $cat); $s9y_cat[$cat_name] = serendipity_db_insert_id('category', 'categoryid'); } } } /* ************* ITEMS **********************/ foreach ($xml->channel->item as $idx => $item) { $wp_items = $item->children($wp_ns); $dc_items = $item->children($dc_ns); $content_items = $item->children($content_ns); // TODO: Attachments not handled if ((string) $wp_items->post_type == 'attachment' or (string) $wp_items->post_type == 'page') { continue; } $entry = array('title' => (string) $item->title, 'isdraft' => (string) $wp_items->status == 'publish' ? 'false' : 'true', 'allow_comments' => (string) $wp_items->comment_status == 'open' ? true : false, 'categories' => array(), 'body' => (string) $content_items->encoded); if (preg_match('@^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$@', (string) $wp_items->post_date, $timematch)) { $entry['timestamp'] = mktime($timematch[4], $timematch[5], $timematch[6], $timematch[2], $timematch[3], $timematch[1]); } else { $entry['timestamp'] = time(); } if (isset($item->category[1])) { foreach ($item->category as $idx => $category) { $cstring = (string) $category; if (!isset($s9y_cat[$cstring])) { echo "WARNING: {$category} unset!<br />\n"; } else { $entry['categories'][] = $s9y_cat[$cstring]; } } } else { $cstring = (string) $item->category; $entry['categories'][] = $s9y_cat[$cstring]; } $wp_user = (string) $dc_items->creator; if (!isset($s9y_users[$wp_user])) { if ($dry_run) { $s9y_users[$wp_user]['authorid'] = time(); } else { $s9y_users[$wp_user]['authorid'] = serendipity_addAuthor($wp_user, md5(time()), $wp_user, '', USERLEVEL_EDITOR); } printf(CREATE_AUTHOR, htmlspecialchars($wp_user)); echo "<br />\n"; } $entry['authorid'] = $s9y_users[$wp_user]['authorid']; if ($dry_run) { $id = time(); } else { $id = serendipity_updertEntry($entry); } $s9y_cid = array(); // Holds comment ids to s9y ids association. $c_i = 0; foreach ($wp_items->comment as $comment) { $c_i++; $c_id = (string) $comment->comment_id; $c_pid = (string) $comment->comment_parent; $c_type = (string) $comment->comment_type; if ($c_type == 'pingback') { $c_type2 = 'PINGBACK'; } elseif ($c_type == 'trackback') { $c_type2 = 'TRACKBACK'; } else { $c_type2 = 'NORMAL'; } $s9y_comment = array('entry_id ' => $id, 'parent_id' => $s9y_cid[$c_pd], 'author' => (string) $comment->comment_author, 'email' => (string) $comment->comment_author_email, 'url' => (string) $comment->comment_author_url, 'ip' => (string) $comment->comment_author_IP, 'status' => empty($comment->comment_approved) || $comment->comment_approved == '1' ? 'approved' : 'pending', 'subscribed' => 'false', 'body' => (string) $comment->comment_content, 'type' => $c_type2); if (preg_match('@^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$@', (string) $comment->comment_date, $timematch)) { $s9y_comment['timestamp'] = mktime($timematch[4], $timematch[5], $timematch[6], $timematch[2], $timematch[3], $timematch[1]); } else { $s9y_comment['timestamp'] = time(); } if ($dry_run) { $cid = time(); } else { serendipity_db_insert('comments', $s9y_comment); $cid = serendipity_db_insert_id('comments', 'id'); if ($s9y_comment['status'] == 'approved') { serendipity_approveComment($cid, $id, true); } } $s9y_cid[$c_id] = $cid; } echo "Entry '" . htmlspecialchars($entry['title']) . "' ({$c_i} comments) imported.<br />\n"; } return true; }
echo serendipity_getTemplateFile('admin/img/admin_msg_success.png'); ?> " alt="" /><?php echo sprintf(MODIFIED_USER, htmlspecialchars($_POST['realname'])); ?> </div> <?php } } ?> <form action="?serendipity[adminModule]=personal&serendipity[adminAction]=save" method="post"> <?php echo serendipity_setFormToken(); $template = serendipity_parseTemplate(S9Y_CONFIG_USERTEMPLATE); $user = serendipity_fetchUsers($serendipity['authorid']); $from = $user[0]; $from['groups'] = serendipity_getGroups($serendipity['authorid']); unset($from['password']); serendipity_printConfigTemplate($template, $from, true, false); ?> <div align="right"><input class="serendipityPrettyButton input_button" type="submit" name="SAVE" value="<?php echo SAVE; ?> " /></div> </form> <?php $add = array('internal' => true); serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_profiles', $from, $add); /* vim: set sts=4 ts=4 expandtab : */
$term = serendipity_mb('strtolower', $term); $filter[] = "(lower(title) LIKE '%{$term}%' OR lower(body) LIKE '%{$term}%' OR lower(extended) LIKE '%{$term}%')"; $full = true; } else { if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) { $filter[] = "MATCH (title,body,extended) AGAINST ('" . $term . "' IN BOOLEAN MODE)"; } else { $filter[] = "MATCH (title,body,extended) AGAINST ('" . $term . "')"; } $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); $users = serendipity_fetchUsers('', 'hidden', true); $categories = serendipity_fetchCategories(); $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); $data['drawList'] = true; $data['sort_order'] = $sort_order; $data['perPage'] = $perPage; $data['per_page'] = $per_page; $data['urltoken'] = serendipity_setFormToken('url'); $data['formtoken'] = serendipity_setFormToken(); $data['users'] = $users; $data['categories'] = $categories; $data['offSet'] = $offSet; $data['use_iframe'] = $serendipity['use_iframe']; $data['page'] = $page; $data['totalEntries'] = serendipity_getTotalEntries(); $data['simpleFilters'] = $serendipity['simpleFilters'];
/** * Prints a media item * * @param array Array of image metadata * @param string URL for maintenance tasks * @param boolean Whether to show maintenance task items * @param int how many media items to display per row * @param boolean Enclose within a table cell? * @param array Additional Smarty variables * @param boolean If TRUE, will echo Smarty output. * @return string Smarty block name * */ function serendipity_showMedia(&$file, &$paths, $url = '', $manage = false, $lineBreak = 3, $enclose = true, $smarty_vars = array(), $smarty_display = true) { global $serendipity; $form_hidden = ''; foreach ($serendipity['GET'] as $g_key => $g_val) { if (!is_array($g_val) && $g_key != 'page') { $form_hidden .= '<input type="hidden" name="serendipity[' . $g_key . ']" value="' . htmlspecialchars($g_val) . '" />'; } } serendipity_smarty_init(); $media = array('manage' => $manage, 'lineBreak' => $lineBreak, 'lineBreakP' => round(1 / $lineBreak * 100), 'url' => $url, 'enclose' => $enclose, 'zoomIMG' => serendipity_getTemplateFile('admin/img/big_zoom.png'), 'renameIMG' => serendipity_getTemplateFile('admin/img/big_rename.png'), 'resizeIMG' => serendipity_getTemplateFile('admin/img/big_resize.png'), 'rotatecwIMG' => serendipity_getTemplateFile('admin/img/big_rotate_cw.png'), 'rotateccwIMG' => serendipity_getTemplateFile('admin/img/big_rotate_ccw.png'), 'configureIMG' => serendipity_getTemplateFile('admin/img/configure.png'), 'deleteIMG' => serendipity_getTemplateFile('admin/img/big_delete.png'), 'prevIMG' => serendipity_getTemplateFile('admin/img/previous.png'), 'nextIMG' => serendipity_getTemplateFile('admin/img/next.png'), 'token' => serendipity_setFormToken(), 'form_hidden' => $form_hidden, 'blimit_path' => basename($limit_path), 'only_path' => $serendipity['GET']['only_path'], 'only_filename' => $serendipity['GET']['only_filename'], 'sortorder' => $serendipity['GET']['sortorder'], 'keywords_selected' => $serendipity['GET']['keywords'], 'filter' => $serendipity['GET']['filter'], 'sort_order' => serendipity_getImageFields(), 'authors' => serendipity_fetchUsers(), 'sort_row_interval' => array(8, 16, 50, 100), 'nr_files' => count($file), 'keywords' => explode(';', $serendipity['mediaKeywords'])); $media = array_merge($media, $smarty_vars); $media['files'] =& $file; if (count($paths) > 0) { $media['paths'] =& $paths; } else { $media['paths'] =& serendipity_getMediaPaths(); } $serendipity['smarty']->assign_by_ref('media', $media); if ($enclose) { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); $block = 'admin/media_pane.tpl'; if ($smarty_display) { $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_pane.tpl', 'serendipityPath')); } } else { serendipity_smarty_fetch('MEDIA_ITEMS', 'admin/media_items.tpl'); $block = 'admin/media_properties.tpl'; if ($smarty_display) { $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_properties.tpl', 'serendipityPath')); } } return $block; }
function show() { global $serendipity; if ($this->selected()) { if (!headers_sent()) { header('HTTP/1.0 200'); header('Status: 200 OK'); } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $pt = preg_replace('@[^a-z0-9]@i', '_', $this->get_config('pagetitle')); $_ENV['staticpage_pagetitle'] = $pt; $serendipity['smarty']->assign('staticpage_pagetitle', $pt); if ($this->get_config('articleformat') == TRUE) { echo '<div class="serendipity_Entry_Date"> <h3 class="serendipity_date">' . PLUGIN_CUSTOMARCHIVE_TITLE . '</h3>'; } echo '<h4 class="serendipity_title"><a href="#">' . $this->get_config('headline') . '</a></h4>'; if ($this->get_config('articleformat') == TRUE) { echo '<div class="serendipity_entry"><div class="serendipity_entry_body">'; } $first_entry = serendipity_db_query("SELECT min(timestamp) AS first FROM {$serendipity['dbPrefix']}entries WHERE isdraft = 'false' LIMIT 1", true); if (is_array($first_entry) && $first_entry['first'] > 0) { $first_year = date('Y', $first_entry['first']); } else { $first_year = date('Y') - 1; } $page = $this->get_config('pagetitle'); $custom_sortfield = array(array('value' => 'timestamp', 'desc' => DATE), array('value' => 'title', 'desc' => TITLE), array('value' => 'category', 'desc' => CATEGORY)); $custom_sortorder = array(array('value' => 'asc', 'desc' => SORT_ORDER_ASC), array('value' => 'desc', 'desc' => SORT_ORDER_DESC)); $custom_sortyears = array(); $custom_sortyears[] = array('value' => 'all', 'desc' => COMMENTS_FILTER_ALL); for ($i = $first_year; $i <= date('Y'); $i++) { $custom_sortyears[] = array('value' => $i, 'desc' => $i); } $custom_sortauthors = array(); $custom_sortauthors[] = array('value' => 'all', 'desc' => COMMENTS_FILTER_ALL); $users = serendipity_fetchUsers(); if (is_array($users)) { foreach ($users as $user) { $custom_sortauthors[] = array('value' => $user['authorid'], 'desc' => $user['realname']); } } $this->setDefaultValue('custom_sortfield', $custom_sortfield, 'timestamp'); $this->setDefaultValue('custom_sortorder', $custom_sortorder, 'asc'); $this->setDefaultValue('custom_sortyears', $custom_sortyears, date('Y')); $this->setDefaultValue('custom_sortauthors', $custom_sortauthors, 'all'); ?> <form action="<?php echo $serendipity['baseURL']; ?> index.php?" method="get"> <div> <input type="hidden" name="serendipity[subpage]" value="<?php echo $page; ?> " /> <?php echo SORT_BY; ?> <br /> <?php echo $this->dropdown('custom_sortfield', $custom_sortfield); echo $this->dropdown('custom_sortorder', $custom_sortorder); echo $this->dropdown('custom_sortyears', $custom_sortyears); echo $this->dropdown('custom_sortauthors', $custom_sortauthors); ?> <input type="submit" name="submit" value="<?php echo GO; ?> " /> </div> </form> <?php $this->showEntries(); if ($this->get_config('articleformat') == TRUE) { echo '</div></div></div>'; } } }
/** * 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 workPopfetcher(&$eventData) { global $serendipity; static $debug = null; if ($debug === null) { $debug = $this->debug = serendipity_db_bool($this->get_config('debug')); } // updertEntry() will not function unless this is set: $serendipity['POST']['properties']['fake'] = 'fake'; $_SESSION['serendipityRightPublish'] = true; $this->out('<h3>' . PLUGIN_MF_NAME . ' v' . POPFETCHER_VERSION . ' @ ' . date("D M j G:i:s T Y") . '</h3>'); $debug_file = null; // DEVELOPERS: If set to a filename, you can bypass fetching POP and use a file instead. $debug_mail = $this->get_config('debug_mail'); if (strlen($debug_mail) != '' && file_exists($debug_mail)) { $debug_file = $debug_mail; } if ($debug_file != null) { $this->debug = true; } $authorid = $this->get_config('author'); if (empty($authorid) || $authorid == 'empty') { $authorid = isset($serendipity['authorid']) ? $serendipity['authorid'] : 1; } $mailserver = trim($this->get_config('mailserver')); $mailport = $this->get_config('mailport'); $mailuser = trim($this->get_config('mailuser')); $mailpass = trim($this->get_config('mailpass')); $timeout = $this->get_config('timeout'); $deleteflag = serendipity_db_bool($this->get_config('deleteflag')); $apopflag = serendipity_db_bool($this->get_config('apopflag')); $blogflag = serendipity_db_bool($this->get_config('blogflag')); $striptagsflag = serendipity_db_bool($this->get_config('striptagsflag')); $publishflag = serendipity_db_bool($this->get_config('publishflag')); $onlyfrom = $this->get_config('onlyfrom', ''); $maildir = trim($this->get_config('maildir')); $category = trim($this->get_config('category')); $adflag = serendipity_db_bool($this->get_config('adflag')); $plaintext_is_body_flag = serendipity_db_bool($this->get_config('plaintext_is_body')); $plaintext_use_extended_flag = serendipity_db_bool($this->get_config('plaintext_use_extended')); $list_virus = array('.pif', '.vbs', '.scr', '.bat', '.com', '.exe'); $list_imagetype = array('jpg', 'jpeg', 'gif', 'png', 'x-png', 'pjpeg'); $list_imageext = array('.gif', '.jpg', '.png', '.jpeg'); $list_ignore = array('.smil'); $output = ''; $dirpath = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $maildir; $dupcount = 0; // Upload directory must end with a slash character if (strrchr($dirpath, '/') != '/') { $output = MF_ERROR7; $this->out('<br />' . $output . '<br />'); return true; } // Upload directory must be writable if (!is_writable($dirpath)) { $output = MF_ERROR6; $this->out('<br />' . $output . '<br />'); return true; } if (serendipity_db_bool($this->get_config('subfolder'))) { $dirpath = $dirpath . '/' . date('Y'); if (!is_dir($dirpath)) { mkdir($dirpath); } $dirpath = $dirpath . '/' . date('m') . '/'; if (!is_dir($dirpath)) { mkdir($dirpath); } $maildir .= date('Y') . '/' . date('m') . '/'; } $maildir = str_replace('//', '/', $maildir); // Category (if specified) must exist if (!empty($category)) { $cid = serendipity_fetchCategoryInfo(null, $category); if ($cid == false) { $output = MF_ERROR8; $this->out('<br />' . $output . '<br />'); return true; } } if ($debug_file === null) { // Create new instance of POP3 connection $pop3 = new POP3($mailserver, $timeout); // Attempt to connect to mail server if (!$pop3->connect($mailserver, $mailport)) { $output = MF_ERROR1 . ': ' . $pop3->ERROR; $this->out('<br />' . $output . '<br />'); return true; } // Try APOP login if requested, otherwise, regular login if ($apopflag) { $Count = $pop3->apop($mailuser, $mailpass); } else { $Count = $pop3->login($mailuser, $mailpass); } // Check for error retrieving number of msgs in mailbox if ($Count === false or $Count == -1) { $output = MF_ERROR2 . ': ' . $pop3->ERROR; $this->out('<br />' . $output . '<br />'); return true; } // If no msgs in mailbox, exit if ($Count == 0) { $output = MF_MSG1; $this->out('<br />' . $output . '<br />'); return true; } // Get the list of email msgs $msglist = $pop3->uidl(); // Check for error in getting list of email msgs if (!is_array($msglist)) { $output = MF_ERROR3 . ': ' . $pop3->ERROR; $this->out('<br />' . $output . '<br />'); $pop3->quit(); return true; } } else { // Developer debug switch which reads from a file and not a POP3 connection. $dfiles = explode(':', $debug_file); $Count = count($dfiles); } $Message = array(); // ************************ // Fetch each email msg and attachments and put it into the $Message array // ************************ for ($i = 1; $i <= $Count; $i++) { // Messages are numbered starting with '1', not '0' if ($debug_file === null) { $MessArray = $pop3->get($i); } else { $MessArray = file($dfiles[$i - 1]); } // Should have an array. If not, there was an error if (!$MessArray or gettype($MessArray) != "array") { $output = MF_ERROR4 . ': ' . $pop3->ERROR; $this->out('<br />' . $output . '<br />'); $pop3->quit(); return true; } // Extract the msg from MessArray and store it in Message $Message[$i - 1] = ''; while (list($lineNum, $line) = each($MessArray)) { $Message[$i - 1] .= $line; } // Delete the msg if ($deleteflag && $debug_file === null) { $pop3->delete($i); } } if ($debug_file === null) { // Close the connection to the mail server $pop3->quit(); } // ************************ // Message processing section starts here // ************************ $this->out('<br />' . MF_MSG2 . ': ' . $Count . '<br />'); if ($deleteflag) { $this->out(MF_MSG11 . '<br />'); } else { $this->out(MF_MSG12 . '<br />'); } $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; // Process each email msg foreach ($Message as $M) { $decode = new mimeDecode($M); #$this->out(print_r($M, true)); $s = $decode->decode($params); #$this->out(print_r($s, true)); if ($debug_file !== null) { // DEBUG Struct // echo '<pre>'; // print_r($s); // echo '</pre>'; } if ($s == null) { $this->out('<br />' . MF_ERROR9); return true; } $date = isset($s->headers['date']) ? $s->headers['date'] : MF_MSG3; $from = isset($s->headers['from']) ? $s->headers['from'] : MF_MSG4; if (!empty($onlyfrom) && trim($from) != trim($onlyfrom)) { $this->out('<br />' . sprintf(MF_ERROR_ONLYFROM, '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($from) : htmlspecialchars($from, ENT_COMPAT, LANG_CHARSET)) . '"', '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($onlyfrom) : htmlspecialchars($onlyfrom, ENT_COMPAT, LANG_CHARSET)) . '"')); continue; } if (empty($s->ctype_parameters['charset'])) { $s->ctype_parameters['charset'] = 'UTF-8'; } if (strtolower($s->ctype_parameters['charset']) == 'us-ascii') { $s->ctype_parameters['charset'] = 'ISO-8859-1'; } $subject = $this->decode(isset($s->headers['subject']) ? $s->headers['subject'] : MF_MSG17, $s->ctype_parameters['charset'], true); #$subject = $this->decode(isset($s->headers['subject']) ? $s->headers['subject'] : MF_MSG17, $s->ctype_parameters['charset']); #$subject = isset($s->headers['subject']) ? $s->headers['subject'] : MF_MSG17; $this->out('<hr />'); $this->out(MF_MSG5 . $date . '<br />'); $this->out(MF_MSG6 . (function_exists('serendipity_specialchars') ? serendipity_specialchars($from) : htmlspecialchars($from, ENT_COMPAT, LANG_CHARSET)) . '<br />'); $this->out(MF_MSG16 . $subject . '<br />'); // Find the author associated with the from address and // set them as the author of the post. $useAuthor = null; if ($authorid == 'byemail') { // We don't have tons of authors .. like two so this isn't a problem // If I wanted this to be "production" quality, I would have to add // a new s9y function that let you retrieve an author given an email address // I suppose I could go with a convention that the base name of the // email address had to be the author's name too. Lookup by name is // supported by s9y. $auths = serendipity_fetchUsers(); $vals = array(); $clean = strtolower($this->cleanEmail($from)); foreach ($auths as $auth) { if (isset($auth['email']) && strtolower($auth['email']) == $clean) { $useAuthor = $auth['authorid']; break; } } if (is_null($useAuthor)) { $this->out('<br />' . sprintf(MF_ERROR_NOAUTHOR, '"' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($clean) : htmlspecialchars($clean, ENT_COMPAT, LANG_CHARSET)) . '"')); continue; } } else { $useAuthor = $authorid; } $postattach = array(); $postbody = array(); $postex = array(); $verizonflag = false; $tmobileflag = false; $firstattachment = false; $firsttext = false; $o2flag = stristr($from, 'mms.o2online.de') !== FALSE; // A mail message with attachments is a series of "parts" if (isset($s->parts) and is_array($s->parts)) { if ($debug_file !== null || $debug) { $this->out('<pre>' . print_r($s->parts, true) . '</pre>'); } $textpref = $this->get_config('textpref'); if ($textpref != 'both') { $has_html = false; $has_text = false; $parts_html = array(); $parts_text = array(); foreach ($s->parts as $idx => $p) { if ($p->ctype_primary == 'text' && $p->ctype_secondary == 'html') { if ($debug_file !== null || $debug) { $this->out("This part is text/html.<br />\n"); } $has_html = true; $parts_html[] = $idx; } elseif ($p->ctype_primary == 'text' && $p->ctype_secondary == 'plain') { if ($debug_file !== null || $debug) { $this->out("This part is text/plain.<br />\n"); } $has_text = true; $parts_text[] = $idx; } } if ($debug_file !== null || $debug) { $this->out("Preference is: {$textpref}.<br />\n"); } if ($textpref == 'text' && $has_html) { if ($debug_file !== null || $debug) { $this->out("Preference is text/plain.<br />\n"); } foreach ($parts_html as $pidx) { if ($debug_file !== null || $debug) { $this->out("Stripping HTML part {$pidx}, because preference is plaintext.<br />\n"); } unset($s->parts[$pidx]); } } if ($textpref == 'html' && $has_text) { if ($debug_file !== null || $debug) { $this->out("Preference is text/html.<br />\n"); } foreach ($parts_text as $pidx) { if ($debug_file !== null || $debug) { $this->out("Stripping text part {$pidx}, because preference is html.<br />\n"); } unset($s->parts[$pidx]); } } } foreach ($s->parts as $p) { if ($debug_file !== null || $debug) { $this->out("Analyzing mail:<br />\n Disposition: {$p->disposition}<br />\n Body: " . (isset($p->body) ? 'Set' : 'Not Set') . "<br />\n Primary CType: {$p->ctype_primary}<br />\n Secondary CType: {$p->ctype_secondary}<br />\n Filename: {$p->d_parameters[filename]}\n .<br />\n"); } // Handle msgs with attachments and messages with images that are inlined if (isset($p->disposition) and $p->disposition == 'attachment' and isset($p->body) or isset($p->disposition) and $p->disposition == 'inline' and isset($p->body) and $p->ctype_primary == 'image' or !empty($p->body) and $p->ctype_primary == 'image') { $this->handleImage($p, $debug, $debug_file, $tmobileflag, $adflag, $dirpath, $list_virus, $list_ignore, $plaintext_is_body_flag, $firsttext, $plaintext_use_extended_flag, $postex, $postbody, $dupcount, $maildir, $authorid, $list_imagetype, $list_imageext, $subject); } elseif (strtolower($p->ctype_primary) == 'text' and isset($p->body)) { if ($debug_file !== null || $debug) { $this->out("<br />\nRecognized text part.<br />\n"); } if (trim($subject) == SPRINTPCS_IDENT_PICTURE) { $p->body = sprintpcs_pictureshare($maildir, $p->body, $authorid); if (strstr($p->body, ERROR_CHECK)) { $this->out('<br />' . $p->body); return true; } } if (trim($subject) == SPRINTPCS_IDENT_ALBUM) { $p->body = sprintpcs_albumshare($maildir, $p->body, $authorid); if (strstr($p->body, ERROR_CHECK)) { $this->out('<br />' . $p->body); return true; } } if (trim($subject) == SPRINTPCS_IDENT_VIDEO) { $p->body = sprintpcs_videoshare($maildir, $p->body, $authorid); if (strstr($p->body, ERROR_CHECK)) { $this->out('<br />' . $p->body); return true; } } if (stristr($subject, CINGULAR_IDENT_PICTURE)) { $p->body = cingular_photo($maildir, $p->body); if (strstr($p->body, ERROR_CHECK)) { $this->out('<br />' . $p->body); return true; } } if (stristr($p->body, VERIZON_IDENT_PICTURE)) { $p->body = verizon_photo($maildir, $p->body); $verizonflag = true; if (strstr($p->body, ERROR_CHECK)) { $this->out('<br />' . $p->body); return true; } } // Because text and HTML attachments get inlined // sometimes (notably Hotmail), // we want to collect them all and attach them to the // regular msg body $bodytext = trim($this->decode($p->body, $p->ctype_parameters['charset'])); if (empty($bodytext)) { continue; } // Strip evil HTML if (preg_match('@<body[^>]*>(.+)</body>@imsU', $bodytext, $m)) { if ($debug_file !== null || $debug) { $this->out("Reduced HTML text.<br />\n"); } $bodytext = $m[1]; } if ($adflag && preg_match('@T\\-Mobile MMS@', $bodytext) && preg_match('@http://www\\.T\\-Mobile\\.(de|nl|com)/mms@', $bodytext)) { if ($debug_file !== null || $debug) { $this->out("<br />\nSkipping T-Mobile ad.<br />\n"); } continue; } if ($firsttext && $plaintext_use_extended_flag) { $postex[] = $bodytext; } else { $postbody[] = $bodytext; $firsttext = true; } } elseif (is_array($p->parts)) { if ($debug_file !== null || $debug) { $this->out("<br />\nRecognized text/multipart.<br />\n"); } if ($textpref != 'both') { $has_html = false; $has_text = false; $parts_html = array(); $parts_text = array(); foreach ($p->parts as $idx => $subp) { if ($subp->ctype_primary == 'text' && $subp->ctype_secondary == 'html') { $has_html = true; $parts_html[] = $idx; } elseif ($subp->ctype_primary == 'text' && $subp->ctype_secondary == 'plain') { $has_text = true; $parts_text[] = $idx; } } if ($textpref == 'text' && $has_html) { foreach ($parts_html as $pidx) { if ($debug_file !== null || $debug) { $this->out("Stripping HTML part {$pidx}, because preference is plaintext.<br />\n"); } unset($p->parts[$pidx]); } } if ($textpref == 'html' && $has_text) { foreach ($parts_text as $pidx) { if ($debug_file !== null || $debug) { $this->out("Stripping text part {$pidx}, because preference is html.<br />\n"); } unset($p->parts[$pidx]); } } } foreach ($p->parts as $subpart) { if ($subpart->ctype_primary == 'text' && $subpart->ctype_secondary == 'html' && $o2flag) { $bodytext = trim($this->decode(popfetcher_provider_o2::getBody($subpart->body), $subpart->ctype_parameters['charset'])); if (empty($bodytext)) { continue; } if ($firsttext && $plaintext_use_extended_flag) { $postex[] = $bodytext; } else { $postbody[] = $bodytext; $firsttext = true; } } elseif ($subpart->ctype_primary == 'text') { $bodytext = trim($this->decode($subpart->body, $subpart->ctype_parameters['charset'])); if (preg_match('@<body[^>]*>(.+)</body>@imsU', $bodytext, $m)) { if ($debug_file !== null || $debug) { $this->out("Reduced HTML text.<br />\n"); } $bodytext = $m[1]; } if ($firsttext && $plaintext_use_extended_flag) { $postex[] = $bodytext; } else { $postbody[] = $bodytext; $firsttext = true; } } elseif ($subpart->ctype_primary == 'image') { // Handle inline multipart images $this->handleImage($subpart, $debug, $debug_file, $tmobileflag, $adflag, $dirpath, $list_virus, $list_ignore, $plaintext_is_body_flag, $firsttext, $plaintext_use_extended_flag, $postex, $postbody, $dupcount, $maildir, $authorid, $list_imagetype, $list_imageext, $subject); } } } else { if ($debug_file !== null || $debug) { $this->out("<br />\nRecognized unknown part.<br />\n"); } if ($p->disposition == 'inline' && isset($p->d_parameters['filename'])) { // Use makeFilename to get rid of spaces and other oddities $filename = serendipity_makeFilename($p->d_parameters['filename']); // if no file extension exists, add default .txt file extension if (!strrpos($filename, ".")) { $filename = $filename . 'txt'; } if ($debug_file !== null || $debug) { $this->out("<br />\nStoring attachment as {$filename}<br />\n"); } $this->out('<br />' . MF_MSG8 . $filename); $fullname = $dirpath . $filename; // Extract file extension and file name for various processing $ext = substr(strrchr($filename, "."), 0); $name = substr($filename, 0, strrpos($filename, ".")); // Skip message and all attachments if possible virus found $lext = strtolower($ext); if (in_array($lext, $list_virus)) { $output = MF_MSG19 . ': ' . $filename; $this->out('<br />' . $output . '<br />'); continue 2; } if (in_array($lext, $list_ignore)) { $this->out('<br />' . MF_MSG20 . '<br />'); continue; } // Check for duplicate filename. Give dup file name file.time().dup.ext if (is_file($fullname)) { $this->out('<br />' . MF_MSG14 . $filename); $name = $name . time() . $dupcount . 'dup'; $filename = $name . $ext; $fullname = $dirpath . $filename; $dupcount++; } $fp = fopen($fullname, 'w'); if (!$fp) { $this->out('<br />' . MF_ERROR5 . $fullname); return true; } fwrite($fp, $p->body); fclose($fp); serendipity_insertImageInDatabase($filename, $maildir, $authorid, NULL); $attlink = '<a class="popfetcherfile" href="' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $maildir . $filename . '" target="_blank">' . $filename . '</a>'; // Inline pictures to match the structure of the mail if ($plaintext_is_body_flag) { // Only the first image is embedded in body, or if no extended entry is used if (!$firstattachment || !$plaintext_use_extended_flag) { $postbody[] = $attlink; } else { $postex[] = $attlink; $firsttext = true; } } else { // Standard attachment mode $postattach[] = $attlink; } $firstattachment = true; $this->out('<br />' . MF_MSG13 . $filename); } $this->out('<br />' . MF_MSG9); // Tmobile sends a weird nested text and html // sub-attachment (at least the nokia does) if (isset($s->headers['x-operator']) and strtolower($s->headers['x-operator']) == TMOBILE_IDENT_PICTURE) { $p->body = tmobile_photo($maildir, $p->body); $tmobileflag = true; if (strstr($p->body, ERROR_CHECK)) { $this->out('<br />' . $p->body); return true; } } } } if ($blogflag) { if (trim($subject) == SPRINTPCS_IDENT_ALBUM || trim($subject) == SPRINTPCS_IDENT_PICTURE || trim($subject) == SPRINTPCS_IDENT_VIDEO || stristr($subject, CINGULAR_IDENT_PICTURE) || ($verizonflag and $subject == MF_MSG17) || ($tmobileflag and $subject == MF_MSG17)) { $time = strtotime($s->headers['date']); $stamp = $time == -1 ? date("l, F j, Y, g:ia") : date("l, F j, Y, g:ia", $time); $subject = MF_MSG23 . $stamp; } $msgbody = implode("<br />\n", $postbody); $msgbody .= implode("<br />\n", $postattach); //New draft post $entry = $this->workEntry($subject, $msgbody, $useAuthor, $postex, $cid, $s); } } elseif (strtolower($s->ctype_primary) == 'text') { // Email msg with no attachments if ($blogflag) { if (trim($subject) == SPRINTPCS_IDENT_ALBUM || trim($subject) == SPRINTPCS_IDENT_PICTURE || trim($subject) == SPRINTPCS_IDENT_VIDEO || stristr($subject, CINGULAR_IDENT_PICTURE) || (stristr($s->body, VERIZON_IDENT_PICTURE) and $subject == MF_MSG17) || ($tmobileflag and $subject == MF_MSG17)) { $time = strtotime($s->headers['date']); $stamp = $time == -1 ? date("l, F j, Y, g:ia") : date("l, F j, Y, g:ia", $time); $subject = MF_MSG23 . $stamp; } $bodytext = trim($this->decode($s->body, $s->ctype_parameters['charset'])); $entry = $this->workEntry($subject, $bodytext, $useAuthor, $postex, $cid, $s); } else { $this->out('<br />' . MF_MSG20); } } else { $this->out('<br />' . MF_MSG10 . '<br />'); } } echo '<br /><hr />'; }