function generate_content(&$title) { global $serendipity; $title = $this->title; $fullentry = serendipity_db_bool($this->get_config('fullentry', 'true')); ?> <form id="searchform" action="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?> " method="get"> <div> <input type="hidden" name="serendipity[action]" value="search" /> <input type="hidden" name="serendipity[fullentry]" value="<?php echo $fullentry; ?> " /> <input type="text" id="serendipityQuickSearchTermField" name="serendipity[searchTerm]" size="13" /> <input class="quicksearch_submit" type="submit" value=">" name="serendipity[searchButton]" title="<?php echo GO; ?> " style="width: 2em;" /> </div> <div id="LSResult" style="display: none;"><div id="LSShadow"></div></div> </form> <?php serendipity_plugin_api::hook_event('quicksearch_plugin', $serendipity); }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $eventData = array('display_dat' => ''); serendipity_plugin_api::hook_event('frontend_display:html_layout', $eventData); echo $eventData['display_dat']; }
function showSearch() { global $serendipity; $this->setupDB(); $term = serendipity_db_escape_string($serendipity['GET']['searchTerm']); if ($serendipity['dbType'] == 'postgres') { $group = ''; $distinct = 'DISTINCT'; $find_part = "(c.title ILIKE '%{$term}%' OR c.body ILIKE '%{$term}%')"; } elseif ($serendipity['dbType'] == 'sqlite') { $group = 'GROUP BY id'; $distinct = ''; $term = serendipity_mb('strtolower', $term); $find_part = "(lower(c.title) LIKE '%{$term}%' OR lower(c.body) LIKE '%{$term}%')"; } else { $group = 'GROUP BY id'; $distinct = ''; $term = str_replace('"', '"', $term); if (preg_match('@["\\+\\-\\*~<>\\(\\)]+@', $term)) { $find_part = "MATCH(c.title,c.body) AGAINST('{$term}' IN BOOLEAN MODE)"; } else { $find_part = "MATCH(c.title,c.body) AGAINST('{$term}')"; } } $querystring = "SELECT c.title AS ctitle, c.body, c.author, c.entry_id, c.timestamp AS ctimestamp, c.url, c.type,\n e.id, e.title, e.timestamp\n FROM {$serendipity['dbPrefix']}comments AS c\n LEFT OUTER JOIN {$serendipity['dbPrefix']}entries AS e\n ON e.id = c.entry_id\n WHERE c.status = 'approved'\n AND {$find_part}\n {$group}\n ORDER BY c.timestamp DESC"; $results = serendipity_db_query($querystring, false, 'assoc'); if (!is_array($results)) { if ($results !== 1 && $results !== true) { echo function_exists('serendipity_specialchars') ? serendipity_specialchars($results) : htmlspecialchars($results, ENT_COMPAT, LANG_CHARSET); } $results = array(); } $myAddData = array("from" => "serendipity_plugin_commentsearch:generate_content"); foreach ($results as $idx => $result) { $results[$idx]['permalink'] = serendipity_archiveURL($result['id'], $result['title'], 'baseURL', true, $result); $results[$idx]['comment'] = $result['body']; //(function_exists('serendipity_specialchars') ? serendipity_specialchars(strip_tags($result['body'])) : htmlspecialchars(strip_tags($result['body']), ENT_COMPAT, LANG_CHARSET)); serendipity_plugin_api::hook_event('frontend_display', $results[$idx], $myAddData); // let the template decide, if we want to have tags or not $results[$idx]['commenthtml'] = $results[$idx]['comment']; $results[$idx]['comment'] = strip_tags($results[$idx]['comment']); } $serendipity['smarty']->assign(array('comment_searchresults' => count($results), 'comment_results' => $results)); $filename = 'plugin_commentsearch_searchresults.tpl'; $tfile = serendipity_getTemplateFile($filename, 'serendipityPath'); if (!$tfile) { $tfile = dirname(__FILE__) . '/' . $filename; } $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY]; $serendipity['smarty']->security_settings[INCLUDE_ANY] = true; $content = $serendipity['smarty']->fetch('file:' . $tfile); $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion; echo $content; }
function show() { global $serendipity; $include_file = realpath($this->get_config('include')); ob_start(); include $include_file; $content = ob_get_contents(); ob_end_clean(); if (serendipity_db_bool($this->get_config('markup'))) { $entry = array('body' => $content); serendipity_plugin_api::hook_event('frontend_display', $entry); echo $entry['body']; } else { echo $content; } }
function uninstall(&$propbag) { global $serendipity; serendipity_plugin_api::hook_event('backend_cache_purge', $this->title); serendipity_plugin_api::hook_event('backend_cache_entries', $this->title); // delete directory with external images from articles $upload_dir = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . 'plugin_mobile_output/'; if (is_dir($upload_dir)) { // delete all files in the upload directory $files = glob($upload_dir . '*'); if (is_array($files) && !empty($files)) { foreach ($files as $file) { @unlink($file); } } @rmdir($upload_dir); } }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title'); $show_where = $this->get_config('show_where', 'both'); if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) { return false; } else { if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) { return false; } } if ($this->get_config('markup', 'true') == 'true') { $entry = array('html_nugget' => $this->get_config('content')); serendipity_plugin_api::hook_event('frontend_display', $entry); echo $entry['html_nugget']; } else { echo $this->get_config('content'); } }
function showPaging($id = false) { global $serendipity; if (!$id) { return false; } $links = array(); $cond = array(); $cond['and'] = " AND e.isdraft = 'false' AND e.timestamp <= " . serendipity_serverOffsetHour(time(), true); serendipity_plugin_api::hook_event('frontend_fetchentry', $cond); $querystring = "SELECT\n e.id, e.title, e.timestamp\n FROM\n {$serendipity['dbPrefix']}entries e\n {$cond['joins']}\n WHERE\n e.id [COMP] " . (int) $id . "\n {$cond['and']}\n ORDER BY e.id [ORDER]\n LIMIT 1"; $prevID = serendipity_db_query(str_replace(array('[COMP]', '[ORDER]'), array('<', 'DESC'), $querystring)); $nextID = serendipity_db_query(str_replace(array('[COMP]', '[ORDER]'), array('>', 'ASC'), $querystring)); if ($link = $this->makeLink($prevID)) { $links['prev'] = $link; } if ($link = $this->makeLink($nextID)) { $links['next'] = $link; } return $links; }
*/ $serendipity['permissionLevels'] = array(USERLEVEL_EDITOR => USERLEVEL_EDITOR_DESC, USERLEVEL_CHIEF => USERLEVEL_CHIEF_DESC, USERLEVEL_ADMIN => USERLEVEL_ADMIN_DESC); /* * Check if the installed version is higher than the version of the config */ if (IS_up2date === false && !defined('IN_upgrader')) { if (preg_match(PAT_CSS, $_SERVER['REQUEST_URI'], $matches)) { $css_mode = 'serendipity_admin.css'; return 1; } serendipity_die(sprintf(SERENDIPITY_NEEDS_UPGRADE, $serendipity['versionInstalled'], $serendipity['version'], $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php')); } // We don't care who tells us what to do if (!isset($serendipity['GET']['action'])) { $serendipity['GET']['action'] = isset($serendipity['POST']['action']) ? $serendipity['POST']['action'] : ''; } if (!isset($serendipity['GET']['adminAction'])) { $serendipity['GET']['adminAction'] = isset($serendipity['POST']['adminAction']) ? $serendipity['POST']['adminAction'] : ''; } // Some stuff... if (!isset($_SESSION['serendipityAuthedUser'])) { $_SESSION['serendipityAuthedUser'] = false; } if (isset($_SESSION['serendipityUser'])) { $serendipity['user'] = $_SESSION['serendipityUser']; } if (isset($_SESSION['serendipityEmail'])) { $serendipity['email'] = $_SESSION['serendipityEmail']; } serendipity_plugin_api::hook_event('frontend_configure', $serendipity); /* vim: set sts=4 ts=4 expandtab : */
$admin_section = COMMENTS; break; case 'category': case 'categories': if (!serendipity_checkPermission('adminCategories')) { break; } include S9Y_INCLUDE_PATH . 'include/admin/category.inc.php'; $admin_section = CATEGORIES; break; case 'logout': echo LOGGEDOUT; break; case 'event_display': if ($serendipity['no_create'] !== true) { serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_' . $serendipity['GET']['adminAction'], $serendipity); } break; case 'maintenance': include S9Y_INCLUDE_PATH . 'include/admin/maintenance.inc.php'; $admin_section = MENU_MAINTENANCE; break; default: include S9Y_INCLUDE_PATH . 'include/admin/overview.inc.php'; $admin_section = ADMIN_FRONTPAGE; break; } $main_content = ob_get_contents(); ob_end_clean(); } if ($ajax) {
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; static $login_url = null; if ($login_url === null) { $login_url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/loginbox'; } $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'frontend_saveComment': if (!isset($serendipity['csuccess'])) { $serendipity['csuccess'] = 'true'; } if (serendipity_db_bool($this->get_config('registered_only')) && !serendipity_userLoggedIn() && $addData['source2'] != 'adduser') { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = PLUGIN_ADDUSER_REGISTERED_ONLY_REASON; return false; } if (serendipity_db_bool($this->get_config('registered_only')) && !$this->inGroup() && $addData['source2'] != 'adduser') { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = PLUGIN_ADDUSER_REGISTERED_ONLY_REASON; return false; } if (serendipity_db_bool($this->get_config('true_identities')) && !serendipity_userLoggedIn()) { $user = str_replace(" b", '', $addData['name']); $user = serendipity_db_escape_string(preg_replace('@\\s+@', ' ', trim($user))); $user = trim($user); $authors = serendipity_db_query("SELECT authorid FROM {$serendipity['dbPrefix']}authors WHERE realname = '" . $user . "'"); if (is_array($authors) && isset($authors[0]['authorid'])) { $eventData = array('allow_comments' => false); $serendipity['messagestack']['comments'][] = sprintf(PLUGIN_ADDUSER_REGISTERED_CHECK_REASON, $login_url, 'onclick="javascript:loginbox = window.open(this.href, \'loginbox\', \'width=300,height=300,locationbar=no,menubar=no,personalbar=no,statusbar=yes,status=yes,toolbar=no\'); return false;"'); } } break; case 'external_plugin': if ($eventData != 'loginbox') { return true; } $out = array(); serendipity_plugin_api::hook_event('backend_login_page', $out); serendipity_smarty_init(); $serendipity['smarty']->assign(array('loginform_add' => $out, 'loginform_url' => $login_url, 'loginform_user' => $_SESSION['serendipityUser'], 'loginform_mail' => $_SESSION['serendipityEmail'], 'close_window' => defined('LOGIN_ACTION'), 'is_logged_in' => serendipity_userLoggedIn(), 'is_error' => defined('LOGIN_ERROR'))); $filename = 'loginbox.tpl'; $tfile = serendipity_getTemplateFile($filename, 'serendipityPath'); if (!$tfile || $tfile == $filename) { $tfile = dirname(__FILE__) . '/' . $filename; } $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY]; $serendipity['smarty']->security_settings[INCLUDE_ANY] = true; $serendipity['smarty']->display($tfile); break; case 'frontend_display': if (serendipity_db_bool($this->get_config('registered_only')) && !serendipity_userLoggedIn()) { $serendipity['messagestack']['comments'][] = sprintf(PLUGIN_ADDUSER_REGISTERED_ONLY_REASON, $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[subpage]=adduser', $serendipity['baseURL'] . 'serendipity_admin.php'); $eventData['allow_comments'] = false; } break; case 'frontend_configure': if (isset($serendipity['POST']['action']) && isset($serendipity['POST']['user']) && isset($serendipity['POST']['pass'])) { serendipity_login(); if (serendipity_userLoggedIn()) { define('LOGIN_ACTION', 'login'); header('X-s9y-auth: Login'); } else { define('LOGIN_ERROR', true); } } elseif (isset($serendipity['POST']['action']) && isset($serendipity['POST']['logout'])) { serendipity_logout(); if (!serendipity_userLoggedIn()) { header('X-s9y-auth: Logout'); define('LOGIN_ACTION', 'logout'); } } if ((serendipity_db_bool($this->get_config('registered_only')) || serendipity_db_bool($this->get_config('true_identities'))) && $_SESSION['serendipityAuthedUser']) { if (defined('IN_serendipity_admin') && $serendipity['GET']['adminAction'] == 'doEdit') { // void } else { $serendipity['COOKIE']['name'] = isset($_SESSION['serendipityRealname']) ? $_SESSION['serendipityRealname'] : $_SESSION['serendipityUser']; $serendipity['COOKIE']['email'] = $_SESSION['serendipityEmail']; if ($serendipity['POST']['comment']) { $serendipity['POST']['name'] = $serendipity['COOKIE']['name']; $serendipity['POST']['email'] = $serendipity['COOKIE']['email']; } } } return true; break; case 'entry_display': if ($serendipity['GET']['subpage'] == 'adduser' || $serendipity['POST']['subpage'] == 'adduser' || !empty($serendipity['GET']['adduser_activation']) || !empty($this->clean_page)) { if (is_array($eventData)) { $eventData['clean_page'] = true; } } break; case 'entries_header': if ($serendipity['GET']['subpage'] == 'adduser' || $serendipity['POST']['subpage'] == 'adduser' || !empty($serendipity['GET']['adduser_activation'])) { $this->clean_page = true; $url = $serendipity['baseURL'] . $serendipity['indexFile']; $hidden['subpage'] = 'adduser'; $username = substr($serendipity['POST']['adduser_user'], 0, 40); $password = substr($serendipity['POST']['adduser_pass'], 0, 32); $email = $serendipity['POST']['adduser_email']; echo '<div id="adduser_form" style="padding-left: 4px; padding-right: 10px"><a id="adduser"></a>'; // Get the config from the sidebar plugin $pair_config = array('userlevel' => USERLEVEL_EDITOR, 'no_create' => false, 'right_publish' => false, 'instructions' => $this->get_config('instructions', ''), 'usergroups' => array(), 'straight_insert' => false, 'approve' => false, 'use_captcha' => false); $config = serendipity_db_query("SELECT name, value FROM {$serendipity['dbPrefix']}config WHERE name LIKE 'serendipity_plugin_adduser:%'"); if (is_array($config)) { foreach ($config as $conf) { $names = explode('/', $conf['name']); if ($names[1] == 'instructions' && !empty($pair_config['instructions'])) { continue; } if ($names[1] == 'usergroups') { $ug = (array) explode(',', $conf['value']); foreach ($ug as $cid) { if ($cid === false || empty($cid)) { continue; } $pair_config[$names[1]][$cid] = $cid; } } else { $pair_config[$names[1]] = serendipity_get_bool($conf['value']); } } } if (!serendipity_common_adduser::adduser($username, $password, $email, $pair_config['userlevel'], $pair_config['usergroups'], $pair_config['no_create'], $pair_config['right_publish'], $pair_config['straight_insert'], $pair_config['approve'], $pair_config['use_captcha'])) { serendipity_common_adduser::loginform($url, $hidden, $pair_config['instructions'], $username, $password, $email, $pair_config['use_captcha']); } echo '</div>'; } return true; break; default: return false; } } else { return false; } }
/** * Save a comment made by a visitor * * @access public * @param int The ID of an entry * @param array An array that holds the input data from the visitor * @param string The type of a comment (normal/trackback) * @param string Where did a comment come from? (internal|trackback|plugin) * @return boolean Returns true if the comment could be added */ function serendipity_saveComment($id, $commentInfo, $type = 'NORMAL', $source = 'internal') { global $serendipity; $query = "SELECT id, allow_comments, moderate_comments, last_modified, timestamp, title FROM {$serendipity['dbPrefix']}entries WHERE id = '" . (int) $id . "'"; $ca = serendipity_db_query($query, true); $commentInfo['type'] = $type; $commentInfo['source'] = $source; serendipity_plugin_api::hook_event('frontend_saveComment', $ca, $commentInfo); if (!is_array($ca) || serendipity_db_bool($ca['allow_comments'])) { if ($GLOBALS['tb_logging']) { $fp = fopen('trackback2.log', 'a'); fwrite($fp, '[' . date('d.m.Y H:i') . '] insert comment into DB' . "\n"); fclose($fp); } $commentInfo['comment_cid'] = serendipity_insertComment($id, $commentInfo, $type, $source, $ca); $commentInfo['comment_id'] = $id; serendipity_plugin_api::hook_event('frontend_saveComment_finish', $ca, $commentInfo); return true; } else { if ($GLOBALS['tb_logging']) { $fp = fopen('trackback2.log', 'a'); fwrite($fp, '[' . date('d.m.Y H:i') . '] discarding comment from DB' . "\n"); fclose($fp); } return false; } }
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation'] && isset($serendipity['POST']['new_timestamp']) && $serendipity['POST']['new_timestamp'] != date(DATE_FORMAT_2, $serendipity['POST']['chk_timestamp'])) { // The user changed the timestamp, now set the DB-timestamp to the user's date $entry['timestamp'] = strtotime($serendipity['POST']['new_timestamp']); if ($entry['timestamp'] == -1) { echo DATE_INVALID . '<br />'; // The date given by the user is not convertable. Reset the timestamp. $entry['timestamp'] = $serendipity['POST']['timestamp']; } } // Save server timezone in database always, so substract the offset we added for display; otherwise it would be added time and again if (!empty($entry['timestamp'])) { $entry['timestamp'] = serendipity_serverOffsetHour($entry['timestamp'], true); } // Save the entry, or just display a preview $use_legacy = true; serendipity_plugin_api::hook_event('backend_entry_iframe', $use_legacy); if ($use_legacy) { if ($serendipity['POST']['preview'] != 'true') { /* We don't need an iframe to save a draft */ if ($serendipity['POST']['isdraft'] == 'true') { echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . IFRAME_SAVE_DRAFT . '</div><br />'; serendipity_updertEntry($entry); } else { if ($serendipity['use_iframe']) { echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . IFRAME_SAVE . '</div><br />'; serendipity_iframe_create('save', $entry); } else { serendipity_iframe($entry, 'save'); } } } else {
/** * Gets all available media directories * * @return array * */ function &serendipity_getMediaPaths() { global $serendipity; $aExclude = array("CVS" => true, ".svn" => true); serendipity_plugin_api::hook_event('backend_media_path_exclude_directories', $aExclude); $paths = array(); $aResultSet = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', false, NULL, 1, NULL, FALSE, $aExclude); foreach ($aResultSet as $sKey => $sFile) { if ($sFile['directory']) { array_push($paths, $sFile); } unset($aResultSet[$sKey]); } serendipity_directoryACL($paths, 'read'); usort($paths, 'serendipity_sortPath'); return $paths; }
<br /> <br /> <h3><?php echo EVENT_PLUGINS; ?> </h3> <a href="?serendipity[adminModule]=plugins&serendipity[adminAction]=addnew&serendipity[type]=event" class="serendipityIconLink"><img src="<?php echo serendipity_getTemplateFile('admin/img/install.png'); ?> " style="border: 0px none ; vertical-align: middle; display: inline;" alt="" /><?php echo sprintf(CLICK_HERE_TO_INSTALL_PLUGIN, EVENT_PLUGIN); ?> </a> <?php serendipity_plugin_api::hook_event('backend_plugins_event_header', $serendipity); ?> <?php show_plugins(true); ?> <?php if (count($serendipity['memSnaps']) > 0) { ?> <h3>Memory Usage</h3> <div> <pre><?php print_r($serendipity['memSnaps']); ?> </pre> </div>
/** * Load global available/configured options for a specific theme * into an array. * * @param array Referenced variable coming from the config.inc.php file, where the config values will be stored in * @param array Current template configuration * @return array Final return array with default values */ function serendipity_loadGlobalThemeOptions(&$template_config, &$template_loaded_config, $supported = array()) { global $serendipity; if ($supported['navigation']) { $navlinks = array(); $conf_amount = array('var' => 'amount', 'name' => NAVLINK_AMOUNT, 'type' => 'string', 'default' => '5', 'scope' => 'global'); // This always needs to be present, if not it could happen that the template options do have an older version of this variable $template_config[] = $conf_amount; if (!isset($template_loaded_config['amount']) || empty($template_loaded_config['amount'])) { $template_loaded_config['amount'] = $conf_amount['default']; } // Check if we are currently inside the admin interface. if ($serendipity['POST']['adminModule'] == 'templates' && $serendipity['POST']['adminAction'] == 'configure' && !empty($serendipity['POST']['template']['amount'])) { $template_loaded_config['amount'] = (int) $serendipity['POST']['template']['amount']; } for ($i = 0; $i < $template_loaded_config['amount']; $i++) { $navlinks[] = array('title' => $template_loaded_config['navlink' . $i . 'text'], 'href' => $template_loaded_config['navlink' . $i . 'url']); $template_config[] = array('var' => 'navlink' . $i . 'text', 'name' => NAV_LINK_TEXT . ' #' . ($i + 1), 'type' => 'string', 'default' => 'Link #' . ($i + 1), 'scope' => 'global'); $template_config[] = array('var' => 'navlink' . $i . 'url', 'name' => NAV_LINK_URL . ' #' . ($i + 1), 'type' => 'string', 'default' => '#', 'scope' => 'global'); } $serendipity['smarty']->assignByRef('navlinks', $navlinks); } // Forward thinking. ;-) serendipity_plugin_api::hook_event('backend_templates_globalthemeoptions', $template_config, $supported); }
function servePlugin($matches) { global $serendipity; $serendipity['view'] = 'plugin'; if (strpos($matches[2], 'admin/') !== false) { include S9Y_INCLUDE_PATH . 'include/genpage.inc.php'; } serendipity_plugin_api::hook_event('external_plugin', $matches[2]); }
break; } $user = serendipity_fetchAuthor($serendipity['authorid']); // chrome-compatible, from Oliver Gassner, adapted from TextPattern. Hi guys, keep it up. :-) $bookmarklet = "javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='" . $serendipity['baseURL'] . "',l=d.location,e=encodeURIComponent,p='serendipity_admin.php?serendipity[adminModule]=entries&serendipity[adminAction]=new&serendipity[title]='+e(d.title)+'&serendipity[body]='+e(s)+'&serendipity[url]='+location.href,u=f+p;a=function(){%20%20if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=800,height=800'))%20%20%20%20l.href=u;};if(/Firefox/.test(navigator.userAgent))%20%20setTimeout(a,0);else%20%20a();void(0)"; $data['bookmarklet'] = $bookmarklet; $data['username'] = $user[0]['realname']; $data['js_failure_file'] = serendipity_getTemplateFile('admin/serendipity_editor.js'); $output = array(); serendipity_plugin_api::hook_event('backend_frontpage_display', $output); $data['backend_frontpage_display'] = $output['more']; $data['usedVersion'] = $serendipity['version']; $data['updateCheck'] = $serendipity['updateCheck']; $data['curVersion'] = serendipity_getCurrentVersion(); $data['update'] = version_compare($data['usedVersion'], $data['curVersion'], '<'); serendipity_plugin_api::hook_event('plugin_dashboard_updater', $output, $data['curVersion']); $data['updateButton'] = $output; // Can be set through serendipity_config_local.inc.php if (!isset($serendipity['dashboardCommentsLimit'])) { $serendipity['dashboardCommentsLimit'] = 5; } if (!isset($serendipity['dashboardLimit'])) { $serendipity['dashboardLimit'] = 5; } if (!isset($serendipity['dashboardDraftLimit'])) { $serendipity['dashboardDraftLimit'] = 5; } $comments = serendipity_db_query("SELECT c.*, e.title FROM {$serendipity['dbPrefix']}comments c\n LEFT JOIN {$serendipity['dbPrefix']}entries e ON (e.id = c.entry_id)\n ORDER BY c.id DESC LIMIT " . (int) $serendipity['dashboardCommentsLimit']); if (is_array($comments) && count($comments) > 0) { foreach ($comments as &$comment) { $comment['entrylink'] = serendipity_archiveURL($comment['entry_id'], 'comments', 'serendipityHTTPPath', true) . '#c' . $comment['id'];
function amazon_fetch($asin, $mode) { global $serendipity; if (!class_exists('serendipity_event_amazonchooser')) { return; } $country = trim($this->get_config('server')); list($country_url, $mode_list) = Amazon_country_code($country); $mode_names = Amazon_return_mode_array(); if (!is_dir($serendipity['serendipityPath'] . 'templates_c/amazonget/')) { mkdir($serendipity['serendipityPath'] . 'templates_c/amazonget/'); } if (!in_array($mode, $mode_list)) { $mode = "All"; } $data = array(); serendipity_plugin_api::hook_event('serendipity_event_amazonchooser_devinfo', $data); $AWSAccessKey = $data['dtoken']; $secretKey = $data['secretKey']; $AssociateTag = $data['aaid']; if (@(include_once "Cache/Lite.php")) { $cache_obj = new Cache_Lite(array('cacheDir' => $serendipity['serendipityPath'] . 'templates_c/amazonget/', 'automaticSerialization' => true, 'lifeTime' => 43200)); $results = $cache_obj->get('amazonlookup' . $asin); } if (!$results['return_date']) { $results = Amazon_ItemLookup($AWSAccessKey, $AssociateTag, $secretKey, $mode, $asin, $country_url); if ($results['return_date'] && class_exists('Cache_Lite') && is_object($cache_obj)) { $cache_obj->save($results, 'amazonlookup' . $asin); } } if ($results['count'] == 0 || $results['return_count'] == 0) { $results['items'] = ""; } return $results; }
function fetchTwitter(&$eventData) { require_once S9Y_PEAR_PATH . 'HTTP/Request.php'; // Was lastrun successfull? if (isset($this->avatarConfiguration['twitter_found']) && !$this->avatarConfiguration['twitter_found']) { return false; } // Let other plugins fill metadata. CommentSpice is perhaps able to fetch twitter infos. try { $original_url = $eventData['url']; $this->log("hook_event: avatar_fetch_userinfos"); $askforData = array("type" => "twitter"); serendipity_plugin_api::hook_event('avatar_fetch_userinfos', $eventData, $askforData); } catch (Exception $e) { $this->log($e); } if (empty($eventData['url'])) { return false; } $url = $eventData['url']; $eventData['url'] = $original_url; $parts = @parse_url($url); if (!is_array($parts)) { return false; } if ($parts['host'] == 'twitter.com' || $parts['host'] == 'www.twitter.com') { $path = trim($parts['path']); $dirs = explode('/', $path); $twittername = $dirs[1]; //if ($twittername=='#!') $twittername = $dirs[2]; $this->log("Twitteruser found ({$url}): {$twittername}"); $twitter_search = 'http://search.twitter.com/search.atom?q=from%3A' . $twittername . '&rpp=1'; serendipity_request_start(); $req = new HTTP_Request($twitter_search); $req->sendRequest(); $this->last_error = $req->getResponseCode(); if ($req->getResponseCode() != 200) { $this->last_error = $req->getResponseCode(); serendipity_request_end(); $this->log("Twitter Error: {$this->last_error}"); return false; } $response = trim($req->getResponseBody()); serendipity_request_end(); $parser = xml_parser_create(); $vals = array(); $index = array(); $success = xml_parse_into_struct($parser, $response, $vals, $index); xml_parser_free($parser); if ($success) { foreach ($index['LINK'] as $index) { if ($vals[$index]['attributes']['REL'] == 'image') { $img_url = $vals[$index]['attributes']['HREF']; $success = true; break; } } if ($success) { $success = $this->saveAndResponseAvatar($eventData, $img_url); } } $this->avatarConfiguration['twitter_found'] = $success; return $success; } return false; }
/** * Show the plugin configuration * * @access public * @param object A plugin object * @param object The plugins property bag object * @param string The name of the plugin * @param string The description of the plugin * @param array The property bag 'configuration' array, holding the array of config items. * @param boolean Shows the surrounding HTML table? * @param boolean Shows the FORM submit button? * @param boolean Shows a plugin's "example" method output? * @param boolean Spawn a plugins' configuration WYSIWYG items? * @param string The array index name of POSTed values ($serendipity['POST'][xxx]) * @param array An array that groups certain config keys * @return string The configuration HTML */ function serendipity_plugin_config(&$plugin, &$bag, &$name, &$desc, &$config_names, $showTable = true, $showSubmit = true, $showExample = true, $spawnNuggets = true, $postKey = 'plugin', $config_groups = NULL) { global $serendipity; if (empty($config_names)) { return false; } $tfile = "/admin/plugin_config_item.tpl"; $data = array(); if ($showSubmit && $postKey != 'plugin') { $data['showSubmit_head'] = true; } if ($showTable) { $data['showTable'] = true; } $elcount = 0; $htmlnugget = array(); $plugin_options = array(); $data['config_names'] = $config_names; foreach ($config_names as $config_item) { $elcount++; $cbag = new serendipity_property_bag(); $plugin->introspect_config_item($config_item, $cbag); $data['cname'] = $cname = serendipity_specialchars($cbag->get('name')); $data['cdesc'] = $cdesc = serendipity_specialchars($cbag->get('description')); $value = $plugin->get_config($config_item, 'unset'); $lang_direction = serendipity_specialchars($cbag->get('lang_direction')); if (empty($lang_direction)) { $lang_direction = LANG_DIRECTION; } $data['lang_direction'] = $lang_direction; /* Apparently no value was set for this config item */ if ($value === 'unset') { /* Try and the default value for the config item */ $value = $cbag->get('default'); /* Still, we don't have a value, try and get (bool)false - from an old plugin */ if ($value === '') { $value = $plugin->get_config($config_item, false, true); } } if (isset($_POST['serendipity'][$postkey][$config_item])) { if (is_array($_POST['serendipity'][$postkey][$config_item])) { $hvalue = $_POST['serendipity'][$postkey][$config_item]; array_walk($hvalue, 'serendipity_specialchars'); } else { $hvalue = serendipity_specialchars($_POST['serendipity'][$postkey][$config_item]); } } else { $hvalue = serendipity_specialchars($value); } $radio = array(); $select = array(); $per_row = null; $text_rows = null; $input_type = null; $data['is_multi_select'] = $is_multi_select = false; $data['ctype'] = $ctype = $cbag->get('type'); $data['elcount'] = $elcount; $data['hvalue'] = $hvalue; $data['postKey'] = $postKey; $data['config_item'] = $config_item; $assign_plugin_config = function ($data) use(&$plugin_options, $tfile, $config_item) { $plugin_options[$config_item] = array('config' => serendipity_smarty_show($tfile, $data), 'ctype' => $data['ctype']); }; switch ($ctype) { case 'seperator': // compat, due being misspelled // compat, due being misspelled case 'separator': case 'suboption': $assign_plugin_config($data); break; case 'multiselect': $data['is_multi_select'] = $is_multi_select = true; case 'select': $data['ctype'] = 'select'; if (is_array($hvalue)) { $selected_options = $hvalue; } elseif ($is_multi_select) { $selected_options = explode('^', $hvalue); } else { $selected_options = array($hvalue => $hvalue); } $data['selected_options'] = $selected_options; $data['pre_selected'] = $pre_selected = (array) $cbag->get('select_preselected'); $data['select_size'] = $select_size = $cbag->get('select_size'); $data['select'] = $select = $cbag->get('select_values'); $assign_plugin_config($data); break; case 'tristate': $data['ctype'] = 'tristate'; $per_row = 3; $radio['value'][] = 'default'; $radio['desc'][] = USE_DEFAULT; case 'boolean': $data['ctype'] = 'boolean'; $radio['value'][] = 'true'; $radio['desc'][] = YES; $radio['value'][] = 'false'; $radio['desc'][] = NO; case 'radio': $data['ctype'] = 'radio'; if (!count($radio) > 0) { $radio = $cbag->get('radio'); } if (empty($per_row)) { $per_row = $cbag->get('radio_per_row'); if (empty($per_row)) { $per_row = 2; } } $data['per_row'] = $per_row; $data['radio_button'] = array(); $counter = 0; foreach ($radio['value'] as $radio_index => $radio_value) { $id = serendipity_specialchars($config_item . $radio_value); $counter++; $checked = ""; if ($radio_value == 'true' && ($hvalue === '1' || $hvalue === 'true')) { $checked = " checked"; } elseif ($radio_value == 'false' && ($hvalue === '' || $hvalue === 'false')) { $checked = " checked"; } elseif ($radio_value == $hvalue) { $checked = " checked"; } $data['radio_button'][$radio_index]['id'] = $id; $data['radio_button'][$radio_index]['checked'] = $checked; $data['radio_button'][$radio_index]['counter'] = $counter; $data['radio_button'][$radio_index]['value'] = $radio_value; $data['radio_button'][$radio_index]['index'] = serendipity_specialchars($radio['desc'][$radio_index]); } $assign_plugin_config($data); break; case 'string': $data['ctype'] = 'string'; if (empty($input_type)) { $input_type = $cbag->get('input_type'); if (empty($input_type)) { $input_type = "text"; } } $data['input_type'] = $input_type; $assign_plugin_config($data); break; case 'html': $data['ctype'] = 'html'; case 'text': $data['ctype'] = 'text'; if (empty($text_rows)) { $text_rows = $cbag->get('rows'); if (empty($text_rows)) { $text_rows = 20; } } $data['text_rows'] = $text_rows; if ($cbag->get('type') == 'html') { $htmlnugget[] = $elcount; if (!function_exists('serendipity_emit_htmlarea_code')) { @(include_once dirname(__FILE__) . '/functions_entries_admin.inc.php'); } // use SpawnMulti false per default (for multi nugget textareas, eg linklist sidebar plugin) - but where do we use jsname though? serendipity_emit_htmlarea_code("nuggets{$elcount}", "nuggets{$elcount}"); } $assign_plugin_config($data); break; case 'content': $data['ctype'] = 'content'; $data['cbag_default'] = $cbag->get('default'); $assign_plugin_config($data); break; case 'custom': $data['ctype'] = 'custom'; $data['cbag_custom'] = $cbag->get('custom'); $assign_plugin_config($data); break; case 'hidden': $data['ctype'] = 'hidden'; $data['cbag_value'] = $cbag->get('value'); $assign_plugin_config($data); break; case 'media': $data['ctype'] = 'media'; // Print the HTML to display the popup media selector $preview_width = $cbag->get('preview_width'); if (!$preview_width || $preview_width == "") { $preview_width = '400px'; } $preview_height = $cbag->get('preview_height'); if (!$preview_height || $preview_height == "") { $preview_height = '100px'; } $data['preview_width'] = $preview_width; $data['preview_height'] = $preview_height; $data['value'] = $value; $assign_plugin_config($data); break; case 'sequence': $data['ctype'] = 'sequence'; // For the drag-n-drop to work, the list must be included in // a container (probably an <ol>) that JavaScript can access // (easiest by ID), with <li> children that have unique IDs, // and handles with ids of 'g'.$li_id. // I can't get it to work unless there's a class of // pluginmanager_container on the ol, either. // The drag-n-drop returns the list of IDs in order. $data['sequencejs_output'] = $sequencejs_output = $serendipity['sequencejs_output']; if (!$sequencejs_output) { $serendipity['sequencejs_output'] = true; } // I want this generic sequence widget to hide the ID, but // display a name or description with an optional picture. // (This would allow users to identify choices by thumbnail.) // Therefore, I need an array with keys 'id', 'display', and // 'imgurl' (or similar) to generate each list item. // Get the data we need to display the list if (!$value) { $value = $eventData['default']; } $data['value'] = $value; $data['cname'] = $cname = $cbag->get('name'); $data['cdesc'] = $cdesc = $cbag->get('description'); $data['checkable'] = $checkable = $cbag->get('checkable'); /** Unordered array of values */ $items = $cbag->get('values'); if (!is_array($items)) { $items = null; } /** Array specifying order to use values in $items */ $order = null; if ($value) { $data['store_order'] = $store_order = $order = explode(',', $value); } // $items is the list of things to sequence. It's not in // order, and reordering PHP arrays is problematic. So // we keep it unordered, and access its values according // to another array (appropriately named $order). if (is_array($items)) { // Allow simple value for any sequence item foreach ($items as $key => $item) { if (!is_array($item)) { // Replace this item with an empty array unset($items[$key]); $items[$item] = array(); } } // Make sure all the items are in the order list; new items // go on the end (new items could have been added without // this config item being updated) // Also fill out thumbnails and display names foreach ($items as $id => $junk) { if ($order == null) { $order = array($id); } else { if (!in_array($id, $order)) { $order[] = $id; } } // If there's no defined display name, default to the ID if (!isset($items[$id]['display'])) { $items[$id]['display'] = $id; } // If there's no image, we just won't display anything. } // Make sure all the items to be ordered exist! Otherwise // we could try to sequence nothing. $filtered = array(); foreach ($order as $id) { if (array_key_exists($id, $items)) { $filtered[] = $id; } } $order = $filtered; } else { // If there's nothing to sequence, make the order in // which to use them valid, but empty $order = array(); } // Start the row, add one cell for the name and description $data['items'] = $items; $sort_idx = 0; $data['last'] = $last = count($order) - 1; foreach ($order as $id) { // Create the variables required to print this item if ($sort_idx > 0) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx - 1)]; $swapping[(int) ($sort_idx - 1)] = $temp; $data['order_id'][$sort_idx]['oneup'] = $oneup = implode(',', $swapping); } if ($sort_idx < $last) { $swapping = $order; $temp = $swapping[(int) $sort_idx]; $swapping[(int) $sort_idx] = $swapping[(int) ($sort_idx + 1)]; $swapping[(int) ($sort_idx + 1)] = $temp; $data['order_id'][$sort_idx]['onedown'] = $onedown = implode(',', $swapping); } $data['order_id'][$sort_idx]['id'] = $id; $data['order_id'][$sort_idx]['sort_idx'] = $sort_idx; // Print the HTML // // Set the item and its ID // Make a handle with ID 'g$id' // Add the item contents // Luddite submit buttons (please, think of the scriptless!) // Next, please $sort_idx++; } // foreach end if (!is_array($items) or empty($order)) { // Print the empty message $data['no_sequence'] = sprint(NONE); } // Print the Javascript to drag-n-drop the list // Finish the row $assign_plugin_config($data); break; default: $data['ctype'] = 'default'; // Unknown configuration key. Let the plugin handle it. $addData = func_get_args(); $eventData = array('config_item' => $config_item, 'cbag' => $cbag, 'plugin' => $plugin, 'value' => $value, 'bag' => $bag, 'postKey' => $postKey); ob_start(); serendipity_plugin_api::hook_event('backend_pluginconfig_' . $ctype, $eventData, $addData); $plugin_options[$config_item]['config'] = ob_get_contents(); $plugin_options[$config_item]['ctype'] = 'default'; ob_end_clean(); break; } } $data['config_groups'] = $config_groups; $data['plugin_options'] = $plugin_options; if (is_array($config_groups)) { foreach ($config_groups as $config_header => $config_groupkeys) { foreach ($config_groupkeys as $config_groupkey) { unset($plugin_options[$config_groupkey]); } } } $data['plugin_options_ungrouped'] = $plugin_options; if ($showSubmit) { $data['showSubmit_foot'] = true; } if ($showExample && method_exists($plugin, 'example')) { $data['showExample'] = true; $data['plugin_example'] = $plugin->example(); } if ($spawnNuggets && isset($serendipity['wysiwyg']) && $serendipity['wysiwyg'] && count($htmlnugget) > 0) { $data['spawnNuggets'] = true; $ev = array('nuggets' => $htmlnugget, 'skip_nuggets' => false); serendipity_plugin_api::hook_event('backend_wysiwyg_nuggets', $ev); $data['ev'] = $ev; } return serendipity_smarty_show('admin/plugin_config.tpl', $data); }
function print_entries(&$entries) { $extended = true; $preview = false; $addData = array('extended' => $extended, 'preview' => $preview, 'no_scramble' => true); serendipity_plugin_api::hook_event('entry_display', $entries, $addData); /* pre-walk the array to collect them keyed by date */ $bydate = array(); if (!is_array($entries) || $entries[0] == false) { return; } $lastDate = ''; for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) { $d = $this->prep_out(serendipity_formatTime(DATE_FORMAT_ENTRY, $entries[$x]['timestamp'])); $bydate[$d][] = $entries[$x]; } foreach ($bydate as $date => $ents) { $header = $date; foreach ($ents as $x => $entry) { $this->print_entry($x, $entry, $header); $header = false; } // end for-loop (entries) } // end for-loop (dates) }
function generate_content(&$title) { global $serendipity; $number = $this->get_config('number'); $displaydate = $this->get_config('displaydate', 'true'); $dateformat = $this->get_config('dateformat'); $sidebartitle = $title = $this->get_config('sidebartitle', $this->title); $rssuri = $this->get_config('rssuri'); $target = $this->get_config('target'); $cachetime = $this->get_config('cachetime'); $feedtype = $this->get_config('feedtype', 'rss'); $markup = $this->get_config('markup', 'false'); $bulletimg = $this->get_config('bulletimg'); $charset = $this->get_config('charset', 'native'); if (!$number || !is_numeric($number) || $number < 1) { $showAll = true; } else { $showAll = false; } if (!$dateformat || strlen($dateformat) < 1) { $dateformat = '%A, %B %e. %Y'; } if (!$cachetime || !is_numeric($cachetime)) { $cachetime = 10800; // 3 hours in seconds } $smarty = serendipity_db_bool($this->get_config('smarty')); if ($this->get_config('template') != 'plugin_remoterss.tpl') { $smarty = true; } if (trim($rssuri)) { $feedcache = $serendipity['serendipityPath'] . 'templates_c/remoterss_cache_' . md5(preg_replace('@[^a-z0-9]*@i', '', $rssuri) . $this->get_config('template')) . '.dat'; if (!file_exists($feedcache) || filesize($feedcache) == 0 || filemtime($feedcache) < time() - $cachetime) { $this->debug('Cachefile does not existing.'); if (!$this->urlcheck($rssuri)) { $this->debug('URLCheck failed'); echo '<!-- No valid URL! -->'; } elseif ($feedtype == 'rss') { $this->debug('URLCheck succeeded. Touching ' . $feedcache); // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog. @touch($feedcache); require_once S9Y_PEAR_PATH . 'Onyx/RSS.php'; $c = new Onyx_RSS($charset); $this->debug('Running Onyx Parser'); $c->parse($rssuri); $this->encoding = $c->rss['encoding']; $use_rss_link = serendipity_db_bool($this->get_config('use_rss_link')); $rss_elements = explode(',', $this->get_config('show_rss_element')); $escape_rss = serendipity_db_bool($this->get_config('escape_rss')); $i = 0; $content = ''; $smarty_items = array(); while (($showAll || $i < $number) && ($item = $c->getNextItem())) { if (empty($item['title'])) { continue; } $content .= '<div class="rss_item">'; if ($use_rss_link) { $content .= '<div class="rss_link"><a href="' . serendipity_specialchars($this->decode($item['link'])) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . '>'; } if (!empty($bulletimg)) { $content .= '<img src="' . $bulletimg . '" border="0" alt="*" /> '; } $is_first = true; foreach ($rss_elements as $rss_element) { $rss_element = trim($rss_element); if (!$is_first) { $content .= '<span class="rss_' . preg_replace('@[^a-z0-9]@imsU', '', $rss_element) . '">'; } if ($escape_rss) { $content .= $this->decode($item[$rss_element]); } else { $content .= serendipity_specialchars($this->decode($item[$rss_element])); } if ($smarty) { $item['display_elements'][preg_replace('@[^a-z0-9]@imsU', '', $rss_element)] = $this->decode($item[$rss_element]); } if (!$is_first) { $content .= '</span>'; } if ($is_first && $use_rss_link) { $content .= '</a></div>'; // end of first linked element } $is_first = false; } if ($is_first && $use_rss_link) { // No XML element has been configured. $content .= '</a></div>'; } $content .= "<br />\n"; $item['timestamp'] = @strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']); if (!($item['timestamp'] == -1) and $displaydate == 'true') { $content .= '<div class="serendipitySideBarDate">' . serendipity_specialchars(serendipity_formatTime($dateformat, $item['timestamp'], false)) . '</div>'; } if ($smarty) { $smarty_items['items'][$i] = $item; $smarty_items['items'][$i]['css_class'] = preg_replace('@[^a-z0-9]@imsU', '', $rss_element); foreach ($item as $key => $val) { $smarty_items['items'][$i]['decoded_' . str_replace(':', '_', $key)] = $this->decode($key); } } $content .= '</div>'; // end of rss_item ++$i; } if ($smarty) { $smarty_items['use_rss_link'] = $use_rss_link; $smarty_items['bulletimg'] = $bulletimg; $smarty_items['escape_rss'] = $escape_rss; $smarty_items['displaydate'] = $displaydate; $smarty_items['dateformat'] = $dateformat; $smarty_items['target'] = $target; $serendipity['smarty']->assign_by_ref('remoterss_items', $smarty_items); $tpl = $this->get_config('template'); if (empty($tpl)) { $tpl = 'plugin_remoterss.tpl'; } // Template specifics go here switch ($tpl) { case 'plugin_remoterss_nasaiotd.tpl': $smarty_items['nasa_image'] = $c->getData('image'); break; } $content = $this->parseTemplate($tpl); } $this->debug('Caching Feed (' . strlen($content) . ' bytes)'); $fp = @fopen($feedcache, 'w'); if (trim($content) != '' && $fp) { fwrite($fp, $content); fclose($fp); $this->debug('Feed cache written'); } else { $this->debug('Could not write (empty?) cache.'); echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />'; if (trim($content) == '') { $this->debug('Getting old feedcache'); $content = @file_get_contents($feedcache); } } $this->debug('RSS Plugin finished.'); } elseif ($feedtype == 'atom') { $this->debug('URLCheck succeeded. Touching ' . $feedcache); // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog. @touch($feedcache); require_once S9Y_PEAR_PATH . '/simplepie/simplepie.inc'; $this->debug('Running simplepie Parser'); $simplefeed = new SimplePie(); $simplefeed->cache = false; $simplefeed->set_feed_url($rssuri); $success = $simplefeed->init(); $simplefeed->set_output_encoding($charset); $simplefeed->handle_content_type(); $this->encoding = $charset; $use_rss_link = serendipity_db_bool($this->get_config('use_rss_link')); $rss_elements = explode(',', $this->get_config('show_rss_element')); $escape_rss = serendipity_db_bool($this->get_config('escape_rss')); $i = 0; $content = ''; $smarty_items = array(); foreach ($simplefeed->get_items() as $simpleitem) { // map SimplePie items to s9y items $item['title'] = $simpleitem->get_title(); $item['link'] = $simpleitem->get_permalink(); $item['pubdate'] = $simpleitem->get_date('U'); $item['date'] = $simpleitem->get_date('U'); $item['description'] = $simpleitem->get_description(); $item['content'] = $simpleitem->get_content(); $item['author'] = $simpleitem->get_author(); if (!$showAll && $i > $number) { break; } if (empty($item['title'])) { continue; } $content .= '<div class="rss_item">'; if ($use_rss_link) { $content .= '<div class="rss_link"><a href="' . serendipity_specialchars($this->decode($item['link'])) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . '>'; } if (!empty($bulletimg)) { $content .= '<img src="' . $bulletimg . '" border="0" alt="*" /> '; } $is_first = true; foreach ($rss_elements as $rss_element) { $rss_element = trim($rss_element); if (!$is_first) { $content .= '<span class="rss_' . preg_replace('@[^a-z0-9]@imsU', '', $rss_element) . '">'; } if ($escape_rss) { $content .= $this->decode($item[$rss_element]); } else { $content .= serendipity_specialchars($this->decode($item[$rss_element])); } if ($smarty) { $item['display_elements'][preg_replace('@[^a-z0-9]@imsU', '', $rss_element)] = $this->decode($item[$rss_element]); } if (!$is_first) { $content .= '</span>'; } if ($is_first && $use_rss_link) { $content .= '</a></div>'; // end of first linked element } $is_first = false; } if ($is_first && $use_rss_link) { // No XML element has been configured. $content .= '</a></div>'; } $content .= "<br />\n"; $item['timestamp'] = @strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']); if (!($item['timestamp'] == -1) and $displaydate == 'true') { $content .= '<div class="serendipitySideBarDate">' . serendipity_specialchars(serendipity_formatTime($dateformat, $item['timestamp'], false)) . '</div>'; } if ($smarty) { $smarty_items['items'][$i] = $item; $smarty_items['items'][$i]['css_class'] = preg_replace('@[^a-z0-9]@imsU', '', $rss_element); foreach ($item as $key => $val) { $smarty_items['items'][$i]['decoded_' . str_replace(':', '_', $key)] = $this->decode($key); } } $content .= '</div>'; // end of rss_item ++$i; } if ($smarty) { $smarty_items['use_rss_link'] = $use_rss_link; $smarty_items['bulletimg'] = $bulletimg; $smarty_items['escape_rss'] = $escape_rss; $smarty_items['displaydate'] = $displaydate; $smarty_items['dateformat'] = $dateformat; $smarty_items['target'] = $target; $serendipity['smarty']->assign_by_ref('remoterss_items', $smarty_items); $tpl = $this->get_config('template'); if (empty($tpl)) { $tpl = 'plugin_remoterss.tpl'; } // Template specifics go here switch ($tpl) { case 'plugin_remoterss_nasaiotd.tpl': $smarty_items['nasa_image'] = $c->getData('image'); break; } $content = $this->parseTemplate($tpl); } $this->debug('Caching Feed (' . strlen($content) . ' bytes)'); $fp = @fopen($feedcache, 'w'); if (trim($content) != '' && $fp) { fwrite($fp, $content); fclose($fp); $this->debug('Feed cache written'); } else { $this->debug('Could not write (empty?) cache.'); echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />'; if (trim($content) == '') { $this->debug('Getting old feedcache'); $content = @file_get_contents($feedcache); } } $this->debug('RSS Plugin (Atom) finished.'); } elseif ($feedtype == 'opml') { // Touching the feedcache file will prevent loops of death when the RSS target is the same URI than our blog. @touch($feedcache); $opml = new s9y_remoterss_OPML(); $opmltree = $opml->parseOPML($rssuri); if (OPMLDEBUG == 1) { echo "\n<pre>\n"; print_r($opmltree); echo "\n</pre>\n"; } if ($opmltree['tag'] === 'opml') { $head = $opml->getOPMLHead($opmltree); $ownerName = $opml->getOPMLTag($head, 'ownerName'); $blogrolling = $ownerName != false ? $ownerName['value'] == 'Blogroll Owner' ? true : false : false; $i = 0; $content = ''; while (($showAll || $i < $number) && ($item = $opml->getOPMLOutlineAttr($opmltree, $i))) { if (!empty($item['url'])) { $url = $this->decode($item['url']); } elseif (!empty($item['htmlUrl'])) { $url = $this->decode($item['htmlUrl']); } elseif (!empty($item['xmlUrl'])) { $url = $this->decode($item['xmlUrl']); } elseif (!empty($item['urlHTTP'])) { $url = $this->decode($item['urlHTTP']); } else { $url = ''; } if (!empty($item['text'])) { $text = serendipity_specialchars($this->decode($item['text'])); } elseif (!empty($item['title'])) { $text = serendipity_specialchars($this->decode($item['title'])); } elseif (!empty($item['description'])) { $text = serendipity_specialchars($this->decode($item['description'])); } else { $text = ''; } if ($blogrolling === true && (!empty($text) || !empty($url))) { $content .= '• <a href="' . serendipity_specialchars($url) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . ' title="' . $text . '">' . $text . "</a>"; if (isset($item['isRecent'])) { $content .= ' <span style="color: Red; ">*</span>'; } $content .= "<br />"; } elseif (isset($item['type']) && $item['type'] == 'url' || !empty($url)) { $content .= '• <a href="' . serendipity_specialchars($url) . '" ' . (!empty($target) ? 'target="' . $target . '"' : '') . ' title="' . $text . '">' . $text . "</a>"; $content .= "<br />"; } ++$i; } /* Pretend to be a html_nugget so we can apply markup events. */ if ($markup == 'true') { $entry = array('html_nugget' => $content); serendipity_plugin_api::hook_event('frontend_display', $entry); $content = $entry['html_nugget']; } $fp = @fopen($feedcache, 'w'); if (trim($content) != '' && $fp) { fwrite($fp, $content); fclose($fp); } else { echo '<!-- Cache failed to ' . $feedcache . ' in ' . getcwd() . ' --><br />'; if (trim($content) == '') { $content = @file_get_contents($feedcache); } } } else { echo '<!-- Not a valid OPML feed -->'; } } else { echo '<!-- no valid feedtype -->'; } } else { $this->debug('Got feed from cache ' . $feedcache); $content = file_get_contents($feedcache); } echo $content; } else { echo PLUGIN_REMOTERSS_NOURI; } }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $max_entries = $this->get_config('max_entries'); $max_chars = $this->get_config('max_chars'); $wordwrap = $this->get_config('wordwrap'); $dateformat = $this->get_config('dateformat'); if (!$max_entries || !is_numeric($max_entries) || $max_entries < 1) { $max_entries = 15; } if (!$max_chars || !is_numeric($max_chars) || $max_chars < 1) { $max_chars = 120; } if (!$wordwrap || !is_numeric($wordwrap) || $wordwrap < 1) { $wordwrap = 30; } if (!$dateformat || strlen($dateformat) < 1) { $dateformat = '%a, %d.%m.%Y %H:%M'; } $viewtype = ''; if ($this->get_config('viewmode') == 'comments') { $viewtype .= ' AND co.type = \'NORMAL\''; } elseif ($this->get_config('viewmode') == 'trackbacks') { $viewtype .= ' AND (co.type = \'TRACKBACK\' OR co.type = \'PINGBACK\')'; } $cond = array(); $cond['and'] = ' AND e.isdraft = \'false\' '; if ($this->get_config('authorid') == 'login') { serendipity_ACL_SQL($cond, true); serendipity_plugin_api::hook_event('frontend_fetchentries', $cond, array('source' => 'entries')); } $q = 'SELECT co.body AS comment, co.timestamp AS stamp, co.author AS user, e.title AS subject, e.timestamp AS entrystamp, e.id AS entry_id, co.id AS comment_id, co.type AS comment_type, co.url AS comment_url, co.title AS comment_title, co.email AS comment_email FROM ' . $serendipity['dbPrefix'] . 'comments AS co, ' . $serendipity['dbPrefix'] . 'entries AS e ' . $cond['joins'] . ' WHERE e.id = co.entry_id AND NOT (co.type = \'TRACKBACK\' AND co.author = \'' . serendipity_db_escape_string($serendipity['blogTitle']) . '\' AND co.title != \'\') AND co.status = \'approved\' ' . $viewtype . ' ' . $cond['and'] . ' ORDER BY co.timestamp DESC LIMIT ' . $max_entries; $sql = serendipity_db_query($q); // echo $q; if ($sql && is_array($sql)) { foreach ($sql as $key => $row) { if (function_exists('mb_strimwidth')) { $comment = mb_strimwidth(strip_tags($row['comment']), 0, $max_chars, " [...]", LANG_CHARSET); } else { $comments = wordwrap(strip_tags($row['comment']), $max_chars, '@@@', 1); $aComment = explode('@@@', $comments); $comment = $aComment[0]; if (count($aComment) > 1) { $comment .= ' [...]'; } } $showurls = $this->get_config('showurls', 'trackbacks'); $isTrackBack = $row['comment_type'] == 'TRACKBACK' || $row['comment_type'] == 'PINGBACK'; if ($row['comment_url'] != '' && ($isTrackBack && ($showurls == 'trackbacks' || $showurls == 'all') || !$isTrackBack && ($showurls == 'comments' || $showurls == 'all'))) { /* Fix invalid cases in protocoll part */ $row['comment_url'] = preg_replace('@^http://@i', 'http://', $row['comment_url']); $row['comment_url'] = preg_replace('@^https://@i', 'https://', $row['comment_url']); if (substr($row['comment_url'], 0, 7) != 'http://' && substr($row['comment_url'], 0, 8) != 'https://') { $row['comment_url'] = 'http://' . $row['comment_url']; } $user = '******' . htmlspecialchars(strip_tags($row['comment_url'])) . '" title="' . htmlspecialchars(strip_tags($row['comment_title'])) . '">' . htmlspecialchars(strip_tags($row['user'])) . '</a>'; } else { $user = htmlspecialchars(strip_tags($row['user'])); } $user = trim($user); if (empty($user)) { $user = PLUGIN_COMMENTS_ANONYMOUS; } if (function_exists('mb_strimwidth')) { $pos = 0; $parts = array(); $enc = LANG_CHARSET; $comment_len = mb_strlen($comment, $enc); while ($pos < $comment_len) { $part = mb_strimwidth($comment, $pos, $wordwrap, '', $enc); $pos += mb_strlen($part, $enc); $parts[] = $part; } $comment = implode("\n", $parts); } else { $comment = wordwrap($comment, $wordwrap, "\n", 1); } $entry = array('comment' => $comment, 'email' => $row['comment_email'], 'url' => $row['comment_url'], 'author' => $row['user']); // Let's help the BBCOde plugin a bit: if (class_exists('serendipity_event_bbcode')) { $entry['comment'] = preg_replace('@((\\[.*)[\\n\\r]+(.*\\]))+@imsU', '\\2\\3', $entry['comment']); $entry['comment'] = preg_replace('@((\\[.+\\].*)[\\r\\n]+(.*\\[/.+\\]))+@imsU', '\\2\\3', $entry['comment']); } $addData = array('from' => 'serendipity_plugin_comments:generate_content'); serendipity_plugin_api::hook_event('frontend_display', $entry, $addData); printf('<div class="plugin_comment_wrap">' . PLUGIN_COMMENTS_ABOUT . '</div>', '<div class="plugin_comment_subject"><span class="plugin_comment_author">' . $user . '</span>', ' <a class="highlight" href="' . serendipity_archiveURL($row['entry_id'], $row['subject'], 'baseURL', true, array('timestamp' => $row['entrystamp'])) . '#c' . $row['comment_id'] . '" title="' . htmlspecialchars($row['subject']) . '">' . htmlspecialchars($row['subject']) . '</a></div>' . "\n" . '<div class="plugin_comment_date">' . htmlspecialchars(serendipity_strftime($dateformat, $row['stamp'])) . '</div>' . "\n" . '<div class="plugin_comment_body">' . strip_tags($entry['comment'], '<br /><img><a>') . '</div>' . "\n\n"); } } }
function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) { static $init = false; global $serendipity; if ($init && $spawnMulti) { return true; } if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg']) { $eventData = array('init' => &$init, 'item' => &$item, 'jsname' => &$jsname, 'skip' => false); serendipity_plugin_api::hook_event('backend_wysiwyg', $eventData); if ($eventData['skip']) { return true; } if (file_exists($serendipity['serendipityPath'] . 'htmlarea/XinhaCore.js')) { $xinha = true; } else { $xinha = false; } $xinha_custom = serendipity_getTemplateFile('my_custom.js', 'serendipityHTTPPath'); if (empty($xinha_custom)) { $xinha_custom = 'htmlarea/my_custom.js'; } if (!$init) { ?> <script type="text/javascript"> _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'htmlarea/'; ?> "; _editor_lang = "<?php echo $xinha ? $serendipity['lang'] : WYSIWYG_LANG; ?> "; _editor_skin = "silva"; var editorref = ''; </script> <?php if ($xinha) { ?> <script type="text/javascript" src="htmlarea/XinhaCore.js"></script> <!-- This file can contain user customizations --> <script type="text/javascript" src="<?php echo $xinha_custom; ?> "></script> <?php } else { ?> <script type="text/javascript" src="htmlarea/htmlarea.js"></script> <?php } } $csscode = str_replace(array("\n", "'", "\r", "{LANG_DIRECTION}"), array('\\n', "\\'", "", defined('LANG_DIRECTION') ? LANG_DIRECTION : 'ltr'), file_get_contents(serendipity_getTemplateFile('style_fallback.css', 'serendipityPath')) . file_get_contents(serendipity_getTemplateFile('htmlarea.css', 'serendipityPath'))); ?> <script type="text/javascript"> // IF you want to enable HTMLArea's spellchecker, download the SpellChecker plugin from the HTMLArea homepage // (http://www.sourceforge.net/projects/itools-htmlarea) and uncomment the lines suffixed with ' // [SPELLCHECK]' // Note that the SpellChecker is a CGI-based application which needs setup in your Apache host ("Options +CGIExec") // Thanks to Randall for pointing this out! // HTMLArea.loadPlugin("SpellChecker"); // [SPELLCHECK] <?php if ($spawnMulti) { ?> // when spawning multiple editors at once, keep track of instances in this array var htmlarea_editors = new Array(); <?php } else { ?> var editor<?php echo $jsname; ?> = null; var config<?php echo $jsname; ?> = null; <?php } // end if ?> <?php if (is_array($eventData['buttons'])) { ?> var btn_callbacks = new Array(); // Serendipity standardized editor functions function serendipity_editor_getSelected(editor_id) { var editor = findXinha(editor_id); if (editor == 'undefined') { editor = findHtmlArea(editor_id); } var html = editor.getSelectedHTML(); return html; } function serendipity_editor_replaceSelected(editor_id, str) { var editor = findXinha(editor_id); if (editor == 'undefined') { editor = findHtmlArea(editor_id); } editor.insertHTML(str); } function serendipity_editor_getAll(editor_id) { var editor = findXinha(editor_id); if (editor == 'undefined') { editor = findHtmlArea(editor_id); } return editor.getEditorContent(); } function serendipity_editor_replaceAll(editor_id, str) { var editor = findXinha(editor_id); if (editor == 'undefined') { editor = findHtmlArea(editor_id); } editor.setEditorContent(str); } // Serendipity standardized editor convenience function function findXinha(editor_id) { if (typeof(xinha_editors) != 'undefined') { for (var editorName in xinha_editors) { if (editor_id == xinha_editors[editorName]._textArea.name) { return xinha_editors[editorName]; } } } return 'undefined'; } function findHtmlArea(editor_id) { if (editor_id == 'serendipity[body]') { return editorbody; } else if (editor_id == 'serendipity[extended]') { return editorextended; } else if (typeof(htmlarea_editors) != 'undefined') { return htmlarea_editors[editor_id]; } return 'undefined'; } <?php } ?> function Spawn<?php echo $jsname; ?> (<?php echo $spawnMulti ? 'id' : ''; ?> ) { editor<?php echo $jsname; ?> = new HTMLArea("<?php echo $item; ?> "<?php echo $spawnMulti ? ' + id' : ''; ?> ); <?php if ($spawnMulti) { ?> htmlarea_editors["<?php echo $item; ?> "<?php echo $spawnMulti ? ' + id' : ''; ?> ] = editor<?php echo $jsname; ?> ; <?php } // end if ?> config<?php echo $jsname; ?> = editor<?php echo $jsname; ?> .config; config<?php echo $jsname; ?> .registerButton('image_selector', '<?php echo MANAGE_IMAGES; ?> ', '<?php echo $serendipity['serendipityHTTPPath']; ?> htmlarea/images/ed_s9yimage.gif', false, function(editor, id) { window.open('<?php echo $serendipity['serendipityHTTPPath']; ?> serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo $jsname . ($spawnMulti ? "' + editor._textArea.id + '" : ''); ?> ', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); // editorref = editor<?php echo $jsname; ?> ; editorref = editor; } ); config<?php echo $jsname; ?> .toolbar.push([ "image_selector"]); <?php if (is_array($eventData['buttons'])) { foreach ($eventData['buttons'] as $button) { echo "btn_callbacks['{$button['id']}'] = {$button['javascript']};\n"; echo "var cb_{$button['id']} = btn_callbacks['{$button['id']}'];\n"; echo "config{$jsname}.registerButton('{$button['id']}', '{$button['name']}', '{$button['img_url']}', false, function (editor, id) { btn_callbacks['{$button['id']}'](editor._textArea.id, id); });\n"; echo "config{$jsname}.toolbar.push([\"{$button['id']}\"]);\n"; // Sort buttons into toolbar lists for later additions switch ($button['toolbar']) { case S9Y_WYSIWYG_TOOLBAR_FORMATTING: $toolbar[S9Y_WYSIWYG_TOOLBAR_FORMATTING][] = $button; break; case S9Y_WYSIWYG_TOOLBAR_MEDIA: case S9Y_WYSIWYG_TOOLBAR_WEB: $toolbar[S9Y_WYSIWYG_TOOLBAR_WEB][] = $button; break; default: $toolbar['other'][] = $button; break; } } } ?> <?php if ($xinha) { ?> config<?php echo $jsname; ?> .pageStyle = '<?php echo $csscode; ?> '; config<?php echo $jsname; ?> .stripScripts = false; <?php } else { ?> config<?php echo $jsname; ?> .cssFile = '<?php echo $csscode; ?> '; <?php } ?> config<?php echo $jsname; ?> .toolbar = [ [ "fontname", "space", "fontsize", "space", "formatblock", "space", "bold", "italic", "underline", "strikethrough", "separator", "subscript", "superscript", "separator", <?php if (is_array($toolbar[S9Y_WYSIWYG_TOOLBAR_FORMATTING])) { foreach ($toolbar[S9Y_WYSIWYG_TOOLBAR_FORMATTING] as $button) { echo '"' . $button['id'] . '",'; } echo '"separator",' . "\n"; } ?> "copy", "cut", "paste", "space", "undo", "redo" ], [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator", "lefttoright", "righttoleft", "separator", "orderedlist", "unorderedlist", "outdent", "indent", "separator", "forecolor", "hilitecolor", "separator", "inserthorizontalrule", "createlink", "insertimage", "image_selector", "inserttable", "htmlmode", "separator", <?php if (is_array($toolbar[S9Y_WYSIWYG_TOOLBAR_WEB])) { foreach ($toolbar[S9Y_WYSIWYG_TOOLBAR_WEB] as $button) { echo '"' . $button['id'] . '",'; } echo '"separator",' . "\n"; } ?> "popupeditor", "separator", "showhelp", "about" ] <?php if (is_array($toolbar['other'])) { echo ",\n [ "; foreach ($toolbar['other'] as $button) { echo '"' . $button['id'] . '", '; } echo '"separator" ]' . "\n"; } ?> ]; if (typeof('s9y_xinha') != 'undefined') { s9y_xinha(editor<?php echo $jsname; ?> ); } // editor<?php echo $jsname; ?> .registerPlugin(SpellChecker); // [SPELLCHECK] editor<?php echo $jsname; ?> .generate(); editor<?php echo $jsname; ?> ._textArea.className = 'serendipity_entry'; } </script> <?php } $init = true; }
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(); } $_ENV['staticpage_pagetitle'] = preg_replace('@[^a-z0-9]@i', '_', $this->get_config('pagetitle')); $serendipity['smarty']->assign('staticpage_pagetitle', $_ENV['staticpage_pagetitle']); if ($this->get_config('articleformat') == TRUE) { echo '<div class="serendipity_Entry_Date"> <h3 class="serendipity_date">' . $this->get_config('pagetitle') . '</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">'; } $include_file = realpath($this->get_config('include')); ob_start(); include $include_file; $content = ob_get_contents(); ob_end_clean(); if ($this->get_config('markup') == TRUE) { $entry = array('body' => $content); serendipity_plugin_api::hook_event('frontend_display', $entry); echo $entry['body']; } else { echo $content; } if ($this->get_config('articleformat') == TRUE) { echo '</div></div></div>'; } } }
function event_hook($event, &$bag, &$eventData) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { switch ($event) { case 'backend_display': ?> <fieldset style="margin: 5px"> <legend><?php echo PLUGIN_EVENT_WEBLOGPING_PING; ?> </legend> <?php $noneclick = ''; foreach ($this->services as $index => $service) { // Detect if the current checkbox needs to be saved. We use the field chk_timestamp to see, // if the form has already been submitted and individual changes shall be preserved $selected = $serendipity['POST']['chk_timestamp'] && $serendipity['POST']['announce_entries_' . $service['name']] || !isset($serendipity['POST']['chk_timestamp']) && $this->get_config($service['name']) == 'true' ? 'checked="checked"' : ''; $noneclick .= 'document.getElementById(\'serendipity[announce_entries_' . $service['name'] . ']\').checked = false; '; $onclick = ''; if (!empty($service['supersedes'])) { $onclick = 'onclick="'; $supersedes = explode(', ', $service['supersedes']); foreach ($supersedes as $sid => $servicename) { $onclick .= 'document.getElementById(\'serendipity[announce_entries_' . $servicename . ']\').checked = false; '; } $onclick .= '"'; } $title = sprintf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING, $service['name']) . (!empty($service['supersedes']) ? ' ' . sprintf(PLUGIN_EVENT_WEBLOGPING_SUPERSEDES, $service['supersedes']) : ''); ?> <input <?php echo $onclick; ?> class="input_checkbox" style="margin: 0px; padding: 0px; vertical-align: bottom;" type="checkbox" name="serendipity[announce_entries_<?php echo $service['name']; ?> ]" id="serendipity[announce_entries_<?php echo $service['name']; ?> ]" value="true" <?php echo $selected; ?> /> <label title="<?php echo $title; ?> " style="vertical-align: bottom; margin: 0px; padding: 0px;" for="serendipity[announce_entries_<?php echo $service['name']; ?> ]"> <?php echo $service['name']; ?> </label><br /> <?php } ?> <input onclick="<?php echo $noneclick; ?> " class="input_checkbox" style="margin: 0px; padding: 0px; vertical-align: bottom;" type="checkbox" value="none" id="serendipity[announce_entries_none]" /> <label title="<?php echo NONE; ?> " style="vertical-align: bottom; margin: 0px; padding: 0px;" for="serendipity[announce_entries_none]"> <?php echo NONE; ?> </label><br /> </fieldset> <?php return true; break; case 'backend_publish': if (!class_exists('XML_RPC_Base')) { include_once S9Y_PEAR_PATH . "XML/RPC.php"; } // First cycle through list of services to remove superseding services which may have been checked foreach ($this->services as $index => $service) { if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) { $supersedes = explode(', ', $service['supersedes']); foreach ($supersedes as $sid => $servicename) { // A service has been checked that is superseded by another checked meta-service. Remove that service from the list of services to be ping'd unset($serendipity['POST']['announce_entries_' . $servicename]); } } } foreach ($this->services as $index => $service) { if (isset($serendipity['POST']['announce_entries_' . $service['name']]) || defined('SERENDIPITY_IS_XMLRPC') && serendipity_db_bool($this->get_config($service['name']))) { if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) { printf(PLUGIN_EVENT_WEBLOGPING_SENDINGPING . '...', $service['host']); } flush(); # XXX append $serendipity['indexFile'] to baseURL? $args = array(new XML_RPC_Value($serendipity['blogTitle'], 'string'), new XML_RPC_Value($serendipity['baseURL'], 'string')); if ($service['extended']) { # the checkUrl: for when the main page is not really the main page $args[] = new XML_RPC_Value('', 'string'); # the rssUrl $args[] = new XML_RPC_Value($serendipity['baseURL'] . 'rss.php?version=2.0', 'string'); } $message = new XML_RPC_Message($service['extended'] ? 'weblogUpdates.extendedPing' : 'weblogUpdates.ping', $args); $client = new XML_RPC_Client(trim($service['path']), trim($service['host'])); # 15 second timeout may not be long enough for weblogs.com $message->createPayload(); $options = array(); serendipity_plugin_api::hook_event('backend_http_request', $options, 'weblogping'); serendipity_request_start(); $req = new HTTP_Request("http://" . $service['host'] . $service['path'], $options); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addHeader("Content-Type", "text/xml"); if (strtoupper(LANG_CHARSET) != 'UTF-8') { $payload = utf8_encode($message->payload); } else { $payload = $message->payload; } $req->addRawPostData($payload); $http_result = $req->sendRequest(); $http_response = $req->getResponseBody(); $xmlrpc_result = $message->parseResponse($http_response); if ($xmlrpc_result->faultCode()) { $out = sprintf(PLUGIN_EVENT_WEBLOGPING_SEND_FAILURE . "<br />", htmlspecialchars($xmlrpc_result->faultString())); } else { $out = PLUGIN_EVENT_WEBLOGPING_SEND_SUCCESS . "<br />"; } serendipity_request_end(); if (!defined('SERENDIPITY_IS_XMLRPC') || defined('SERENDIPITY_XMLRPC_VERBOSE')) { echo $out; } } } return true; break; case 'external_plugin': if ($eventData == 'xmlrpc_ping') { echo "XMLRPC START\n"; @define('SERENDIPITY_IS_XMLRPC', true); @define('SERENDIPITY_XMLRPC_VERBOSE', true); $this->event_hook('backend_publish', $bag, $eventData); echo "XMLRPC DONE\n"; } return true; case 'frontend_display': case 'backend_insert': case 'backend_update': case 'backend_draft': default: return false; break; } } else { return false; } }
function uninstall() { serendipity_plugin_api::hook_event('backend_cache_purge', $this->title); serendipity_plugin_api::hook_event('backend_cache_entries', $this->title); }
$data['img_height'] = $s[1]; $data['print_RESIZE_BLAHBLAH'] = sprintf(RESIZE_BLAHBLAH, serendipity_specialchars($serendipity['GET']['fname'])); $data['print_ORIGINAL_SIZE'] = sprintf(ORIGINAL_SIZE, $s[0], $s[1]); $data['formtoken'] = serendipity_setFormToken(); $data['file'] = $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . ($file['extension'] ? '.' . $file['extension'] : ""); break; case 'choose': $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); $media['file'] =& $file; if (!is_array($file)) { $media['perm_denied'] = true; break; } serendipity_prepareMedia($file); $media['file']['props'] =& serendipity_fetchMediaProperties((int) $serendipity['GET']['fid']); serendipity_plugin_api::hook_event('media_getproperties_cached', $media['file']['props']['base_metadata'], $media['file']['realfile']); if ($file['is_image']) { $file['finishJSFunction'] = $file['origfinishJSFunction'] = 'serendipity.serendipity_imageSelector_done(\'' . serendipity_specialchars($serendipity['GET']['textarea']) . '\')'; if (!empty($serendipity['GET']['filename_only']) && $serendipity['GET']['filename_only'] !== 'true') { $file['fast_select'] = true; } } $media = array_merge($serendipity['GET'], $media); $serendipity['smarty']->assignByRef('media', $media); echo serendipity_smarty_show('admin/media_choose.tpl', $data); break; default: serendipity_restoreVar($serendipity['COOKIE']['serendipity_only_path'], $serendipity['GET']['only_path']); $data['case_default'] = true; $data['showML'] = showMediaLibrary(); break;
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $to_lower = serendipity_db_bool($this->get_config('lowercase_tags', 'true')); if ($this->get_config('max_tags', 0) != 0) { $limit = "LIMIT " . $this->get_config('max_tags', 0); } else { $limit = ''; } $query = "SELECT et.tag, count(et.tag) AS total\n FROM {$serendipity['dbPrefix']}entrytags AS et\n LEFT OUTER JOIN {$serendipity['dbPrefix']}entries AS e\n ON et.entryid = e.id\n WHERE e.isdraft = 'false' " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND e.timestamp <= " . time() : '') . "\n GROUP BY et.tag\n HAVING count(et.tag) >= " . $this->get_config('treshold_tag_count') . "\n ORDER BY total DESC {$limit}"; $rows = serendipity_db_query($query); if (!is_array($rows)) { return; } // not sure if we can optimize this loop... :/ // Probably through some SQL magick. foreach ($rows as $r) { if ($to_lower) { // set to_lower for frontend sidebar list/clouds (new) foreach ($r as &$t) { if (function_exists('mb_strtolower')) { $t = mb_strtolower($t); } else { $t = strtolower($t); } } } $tags[$r['tag']] = $r['total']; } if ($this->get_config('order_by') == 'tag') { uksort($tags, 'strnatcasecmp'); serendipity_plugin_api::hook_event('sort', $tags); } else { if ($this->get_config('order_by') == 'total') { serendipity_db_bool($this->get_config('sort_desc', 'false')) ? arsort($tags) : asort($tags); } } $xml = serendipity_db_bool($this->get_config('show_xml', 'true')); $nl = serendipity_db_bool($this->get_config('show_newline', 'true')); $scaling = serendipity_db_bool($this->get_config('scale_tag', 'false')); $useRotCanvas = serendipity_db_bool($this->get_config('use_rotacloud', 'false')); $useWordCloud = serendipity_db_bool($this->get_config('use_wordcloud', 'false')); serendipity_event_freetag::displayTags($tags, $xml, $nl, $scaling, $this->get_config('max_percent', 300), $this->get_config('min_percent', 100), serendipity_db_bool($this->get_config('use_flash')), serendipity_db_bool($this->get_config('flash_bg_trans', 'false')), $this->get_config('flash_tag_color', 'ff6600'), $this->get_config('flash_bg_color', 'ffffff'), $this->get_config('flash_width', 190), $this->get_config('flash_speed', 100), $this->get_config('taglink'), $this->get_config('template'), $this->get_config('xml_image', 'img/xml.gif'), $useRotCanvas, $this->get_config('rotacloud_tag_color', '3E5F81'), $this->get_config('rotacloud_tag_border_color', 'B1C1D1'), $this->get_config('rotacloud_width', '300'), $useWordCloud); }
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 : */