function cleanup()
 {
     $err = false;
     $bugp = $this->get_config('bugpath');
     $path = $this->get_config('path');
     // allow numeric client ID only
     if ($err = preg_match("/^[^0-9]+\$/", $this->get_config('client_id'))) {
         printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_CID_ERROR, S9YPOT_ERR_END);
     }
     // webbug path must be absolute, no trailing slash
     if (!empty($bugp) && ($err = !preg_match("/^http(.*)[^\\/]\$/", $bugp))) {
         printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_BUGURL_ERROR, S9YPOT_ERR_END);
     }
     // path must be absolute, no trailing slash
     if (!empty($path) && ($err = !preg_match("/^[\\/].*[^\\/]\$/", $path))) {
         printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_PATH_ERROR, S9YPOT_ERR_END);
     }
     // check for an existing POT installation
     $location = sprintf("%s/%s", $this->get_config('path'), $this->get_config('fname'));
     if (!empty($path) && ($err = !file_exists($location))) {
         printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_FNAME_ERROR, S9YPOT_ERR_END);
     }
     // s9y plugin error messaging is quite sub-optimal, print explanation what happened
     // reset all config values so nothing gets logged using a wrong client ID (logging will fail due to wrong path)
     if ($err || empty($bugp) && empty($path)) {
         $this->set_config('client_id', S9YPOT_DEFAULT_CID);
         $this->set_config('path', S9YPOT_DEFAULT_PATH);
         $this->set_config('fname', S9YPOT_DEFAULT_FNAME);
         $this->set_config('bugpath', S9YPOT_BUGDEFAULT_FNAME);
         printf("%s%s%s", S9YPOT_ERR_START, S9YPOT_ERR_RESET, S9YPOT_ERR_END);
     }
     serendipity_plugin_api::remove_plugin_value($this->instance, array('path', 'fname', 'client_id', 'bugpath'));
 }
    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="&gt;" 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('&quot;', '"', $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 generate_content(&$title)
 {
     $plug = $this->get_config('event_plugin', 'false');
     if ($plug == 'false') {
         return;
     }
     $wrap =& serendipity_plugin_api::get_event_plugins($plug);
     $faketitle = '';
     if (is_object($wrap)) {
         $wrap->generate_content($faketitle);
     }
     if ($this->get_config('title') != '') {
         $title = $this->get_config('title');
     } else {
         $title = $faketitle;
     }
 }
 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;
 }
Exemplo n.º 10
0
 */
$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 : */
 function uninstall()
 {
     serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
     serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
 }
 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 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");
         }
     }
 }
<?php

// Contributed by Christian Machmeier <*****@*****.**>
// Randomizing contributed by Christian Brabandt <*****@*****.**>
if (IN_serendipity !== true) {
    die("Don't hack!");
}
@serendipity_plugin_api::load_language(dirname(__FILE__));
class serendipity_plugin_recententries extends serendipity_plugin
{
    var $title = PLUGIN_RECENTENTRIES_TITLE;
    function introspect(&$propbag)
    {
        $this->title = $this->get_config('title', $this->title);
        $propbag->add('name', PLUGIN_RECENTENTRIES_TITLE);
        $propbag->add('description', PLUGIN_RECENTENTRIES_BLAHBLAH);
        $propbag->add('stackable', true);
        $propbag->add('author', 'Christian Machmeier, Christian Brabandt, Judebert, Don Chambers');
        $propbag->add('version', '2.6');
        $propbag->add('requirements', array('serendipity' => '1.6', 'smarty' => '2.6.7', 'php' => '4.1.0'));
        $propbag->add('configuration', array('title', 'number', 'number_from', 'dateformat', 'category', 'randomize', 'show_where'));
        $propbag->add('groups', array('FRONTEND_VIEWS'));
    }
    function introspect_config_item($name, &$propbag)
    {
        global $serendipity;
        switch ($name) {
            case 'title':
                $propbag->add('type', 'string');
                $propbag->add('name', TITLE);
                $propbag->add('description', TITLE_FOR_NUGGET);
Exemplo n.º 15
0
 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 {
Exemplo n.º 16
0
/**
 * 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;
}
 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;
 }
 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 .= '&bull; <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 .= '&bull; <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 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 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;
}
/**
 * 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;
    }
}
    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'];
                        ?>
]">&nbsp;<?php 
                        echo $service['name'];
                        ?>
&nbsp;&nbsp;</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]">&nbsp;<?php 
                    echo NONE;
                    ?>
&nbsp;&nbsp;</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 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;
     }
 }
Exemplo n.º 24
0
     $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;
Exemplo n.º 25
0
            $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) {
Exemplo n.º 26
0
        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&amp;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 : */
Exemplo n.º 27
0
     echo sprintf(CREATING_PRIMARY_AUTHOR, htmlspecialchars($_POST['user'])) . '...';
     $authorid = serendipity_addAuthor($_POST['user'], $_POST['pass'], $_POST['realname'], $_POST['email'], USERLEVEL_ADMIN, 1);
     $mail_comments = serendipity_db_bool($_POST['want_mail']) ? 1 : 0;
     serendipity_set_user_var('mail_comments', $mail_comments, $authorid);
     serendipity_set_user_var('mail_trackbacks', $mail_comments, $authorid);
     serendipity_set_user_var('right_publish', 1, $authorid);
     serendipity_addDefaultGroup('USERLEVEL_EDITOR_DESC', USERLEVEL_EDITOR);
     serendipity_addDefaultGroup('USERLEVEL_CHIEF_DESC', USERLEVEL_CHIEF);
     serendipity_addDefaultGroup('USERLEVEL_ADMIN_DESC', USERLEVEL_ADMIN);
     echo ' <strong>' . DONE . '</strong><br />';
     echo SETTING_DEFAULT_TEMPLATE . '... ';
     serendipity_set_config_var('template', $serendipity['defaultTemplate']);
     echo ' <strong>' . DONE . '</strong><br />';
     echo INSTALLING_DEFAULT_PLUGINS . '... ';
     include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
     serendipity_plugin_api::register_default_plugins();
     echo ' <strong>' . DONE . '</strong><br />';
 }
 echo sprintf(ATTEMPT_WRITE_FILE, '.htaccess') . '... ';
 $errors = serendipity_installFiles($basedir);
 if ($errors === true) {
     echo ' <strong>' . DONE . '</strong><br />';
 } else {
     echo ' <strong>' . FAILED . '</strong><br />';
     foreach ($errors as $error) {
         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 . '</div>';
     }
 }
 if (serendipity_updateConfiguration()) {
     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="" />' . SERENDIPITY_INSTALLED . '</div>';
     echo '<div align="center" style="font-size: large"><a href="' . $_POST['serendipityHTTPPath'] . '">' . VISIT_BLOG_HERE . '</a></div>';
Exemplo n.º 28
0
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]);
}
 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);
 }
Exemplo n.º 30
0
        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'];