Ejemplo n.º 1
0
function serveComments()
{
    global $serendipity;
    $serendipity['view'] = 'comments';
    $uri = $_SERVER['REQUEST_URI'];
    $_args = serendipity_getUriArguments($uri, true);
    // Need to also match "." character
    $timedesc = array();
    /* Attempt to locate hidden variables within the URI */
    foreach ($_args as $k => $v) {
        if ($v == PATH_COMMENTS) {
            continue;
        }
        if (preg_match('@^(last|f|t|from|to)[\\s_-]*([\\d-/ ]+)$@', strtolower(urldecode($v)), $m)) {
            if ($m[1] == 'last') {
                $usetime = time() - $m[2] * 86400;
                $serendipity['GET']['commentStartTime'] = $usetime;
                $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $usetime);
                continue;
            }
            $date = strtotime($m[2]);
            if ($date < 1) {
                continue;
            }
            if ($m[1] == 'f' || $m[1] == 'from') {
                $serendipity['GET']['commentStartTime'] = $date;
                $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $date);
            } else {
                $serendipity['GET']['commentEndTime'] = $date;
                $timedesc['end'] = serendipity_strftime(DATE_FORMAT_SHORT, $date);
            }
        } elseif ($v == 'trackbacks' || $v == 'comments_and_trackbacks' || $v == 'comments') {
            $serendipity['GET']['commentMode'] = $v;
        } elseif (!empty($v)) {
            $serendipity['GET']['viewCommentAuthor'] .= urldecode($v);
        }
    }
    $serendipity['head_title'] = COMMENTS_FROM . ' ' . serendipity_specialchars($serendipity['GET']['viewCommentAuthor']);
    if (isset($timedesc['start']) && isset($timedesc['end'])) {
        $serendipity['head_title'] .= ' (' . $timedesc['start'] . ' - ' . $timedesc['end'] . ')';
    } elseif (isset($timedesc['start'])) {
        $serendipity['head_title'] .= ' (&gt; ' . $timedesc['start'] . ')';
    } elseif (isset($timedesc['end'])) {
        $serendipity['head_title'] .= ' (&lt; ' . $timedesc['end'] . ')';
    }
    $serendipity['head_subtitle'] = $serendipity['blogTitle'];
    $serendipity['GET']['action'] = 'comments';
    include S9Y_INCLUDE_PATH . 'include/genpage.inc.php';
}
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'genpage':
                 $args = implode('/', serendipity_getUriArguments($eventData, true));
                 if ($serendipity['rewrite'] != 'none') {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                 } else {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                 }
                 if (empty($serendipity['GET']['subpage'])) {
                     $serendipity['GET']['subpage'] = $nice_url;
                 }
                 break;
             case 'entry_display':
                 if ($this->selected()) {
                     if (is_array($eventData)) {
                         $eventData['clean_page'] = true;
                         // This is important to not display an entry list!
                     } else {
                         $eventData = array('clean_page' => true);
                     }
                 }
                 if (version_compare($serendipity['version'], '0.7.1', '<=')) {
                     $this->show();
                 }
                 return true;
                 break;
             case 'entries_header':
                 $this->show();
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     } else {
         return false;
     }
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'genpage':
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    $myi = strpos($nice_url, '?');
                    if ($myi != 0 && $serendipity['rewrite'] != 'none') {
                        $nice_url2 = substr($nice_url, $myi + 1);
                    }
                    $myi = strpos($nice_url, '?');
                    if ($myi != 0 && $serendipity['rewrite'] != 'none') {
                        $nice_url = substr($nice_url, 0, $myi);
                    }
                    $myi = strpos($nice_url, '&');
                    if ($myi != 0 && $serendipity['rewrite'] != 'none') {
                        $nice_url = substr($nice_url, 0, $myi);
                    }
                    $myi = strpos($nice_url2, '&');
                    if ($myi != 0 && $serendipity['rewrite'] != 'none') {
                        $nice_url2 = substr($nice_url2, 0, $myi);
                    }
                    $query = "SELECT entryid FROM {$serendipity['dbPrefix']}entryproperties WHERE property = 'permalink'\n                                     AND value IN ('" . serendipity_db_escape_string($nice_url) . "', '/" . serendipity_db_escape_string($nice_url) . "',\n                                                   '" . serendipity_db_escape_string($nice_url2) . "', '/" . serendipity_db_escape_string($nice_url2) . "')";
                    $retid = serendipity_db_query($query);
                    if (is_array($retid) && !empty($retid[0]['entryid'])) {
                        $this->show($retid[0]['entryid']);
                    }
                    break;
                case 'entry_display':
                    $ids = array();
                    if (!is_array($eventData)) {
                        return true;
                    }
                    foreach ($eventData as $entry) {
                        $ids[] = $entry['id'];
                    }
                    $query = "SELECT entryid,value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid IN (" . implode(', ', $ids) . ") AND property = 'permalink'";
                    $retval = serendipity_db_query($query);
                    if (is_array($retval)) {
                        foreach ((array) $retval as $pl) {
                            $this->ids[$pl['entryid']] = $pl['value'];
                        }
                    }
                    break;
                case 'frontend_display:html:per_entry':
                    if (isset($this->ids[$eventData['id']]) && stristr($this->ids[$eventData['id']], '/' . UNKNOWN) === FALSE) {
                        $eventData['link'] = $this->ids[$eventData['id']];
                        $urldata = parse_url($serendipity['baseURL']);
                        $eventData['rdf_ident'] = $urldata['scheme'] . '://' . $urldata['host'] . $this->ids[$eventData['id']];
                    }
                    break;
                case 'backend_display':
                    $permalink = !empty($serendipity['POST']['permalink']) ? $serendipity['POST']['permalink'] : '';
                    if (!empty($eventData['id']) && empty($permalink)) {
                        $query = "SELECT value FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = '" . $eventData['id'] . "' AND property = 'permalink'";
                        $retval = serendipity_db_query($query);
                        if (is_array($retval) && !empty($retval[0]['value'])) {
                            $permalink = $retval[0]['value'];
                        }
                    }
                    $title = $eventData['title'];
                    if (empty($title)) {
                        $title = UNKNOWN;
                    }
                    if (empty($permalink)) {
                        $permalink = $serendipity['rewrite'] != 'none' ? $serendipity['serendipityHTTPPath'] . 'permalink/' . serendipity_makeFilename($title) . '.html' : $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/permalink/' . serendipity_makeFilename($title) . '.html';
                    }
                    ?>
                    <fieldset style="margin: 5px">
                        <legend><?php 
                    echo PLUGIN_EVENT_CUSTOM_PERMALINKS_PL;
                    ?>
</legend>
                            <div><?php 
                    echo PLUGIN_EVENT_CUSTOM_PERMALINKS_PL_DESC;
                    ?>
<br /><br /></div>
                            <label for="permalink" title="<?php 
                    echo htmlentities(PLUGIN_EVENT_CUSTOM_PERMALINKS_PL, ENT_COMPAT, LANG_CHARSET);
                    ?>
"><?php 
                    echo PLUGIN_EVENT_CUSTOM_PERMALINKS_PL;
                    ?>
:</label> <input class="input_textbox" type="text" style="width: 60%" name="serendipity[permalink]" id="permalink" value="<?php 
                    echo function_exists('serendipity_specialchars') ? serendipity_specialchars($permalink) : htmlspecialchars($permalink, ENT_COMPAT, LANG_CHARSET);
                    ?>
" />
                    </fieldset>
<?php 
                    return true;
                    break;
                case 'backend_publish':
                case 'backend_save':
                    if (!isset($serendipity['POST']['permalink']) || !isset($eventData['id'])) {
                        return true;
                    }
                    serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entryproperties WHERE entryid = '" . $eventData['id'] . "' AND property = 'permalink'");
                    serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entryproperties (entryid, value, property) VALUES ('" . $eventData['id'] . "', '" . serendipity_db_escape_string($serendipity['POST']['permalink']) . "', 'permalink')");
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
Ejemplo n.º 4
0
         } else {
             $search[] = $v;
         }
     }
     $serendipity['GET']['action'] = 'search';
     $serendipity['GET']['searchTerm'] = urldecode(htmlspecialchars(strip_tags(implode(' ', $search))));
     include S9Y_INCLUDE_PATH . 'include/genpage.inc.php';
 } elseif (preg_match(PAT_CSS, $uri, $matches)) {
     $serendipity['view'] = 'css';
     $css_mode = $matches[1];
     include S9Y_INCLUDE_PATH . 'serendipity.css.php';
     exit;
 } else {
     if (preg_match(PAT_COMMENTS, $uri, $matches)) {
         $serendipity['view'] = 'comments';
         $_args = serendipity_getUriArguments($uri, true);
         // Need to also match "." character
         $timedesc = array();
         /* Attempt to locate hidden variables within the URI */
         $search = array();
         foreach ($_args as $k => $v) {
             if ($v == PATH_COMMENTS) {
                 continue;
             }
             if ($v[0] == 'P') {
                 /* Page */
                 $page = substr($v, 1);
                 if (is_numeric($page)) {
                     $serendipity['GET']['page'] = $page;
                     unset($_args[$k]);
                     unset($serendipity['uriArguments'][$k]);
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'backend_category_showForm':
                    $pages = $this->fetchStaticPages(true);
                    $categorypage = $this->fetchCatProp((int) $eventData);
                    if (debug_staticpage == 'true') {
                        echo "category ";
                        echo (int) $eventData . " ";
                        echo " staticpage ";
                        echo $this->fetchCatProp((int) $eventData);
                    }
                    ?>
    <tr>
        <td valign="top"><label for="staticpage_categorypage"><?php 
                    echo STATICPAGE_CATEGORYPAGE;
                    ?>
</label></td>
        <td>

          <select name="serendipity[cat][staticpage_categorypage]">
                <option value=""><?php 
                    echo NONE;
                    ?>
</option>

<?php 
                    $pages = $this->fetchStaticPages();
                    if (is_array($pages)) {
                        $pages = serendipity_walkRecursive($pages);
                        foreach ($pages as $page) {
                            if ($this->checkPageUser($page['authorid'])) {
                                echo ' <option value="' . $page['id'] . '" ' . ($page['id'] == $this->fetchCatProp((int) $eventData) ? 'selected="selected"' : '') . '>';
                                echo str_repeat('&nbsp;&nbsp;', $page['depth']) . (function_exists('serendipity_specialchars') ? serendipity_specialchars($page['pagetitle']) : htmlspecialchars($page['pagetitle'], ENT_COMPAT, LANG_CHARSET)) . '</option>';
                            }
                        }
                    }
                    ?>
            </select>


        </td>
    </tr>
<?php 
                    return true;
                    break;
                case 'backend_category_delete':
                    $this->setCatProps($eventData, null, true);
                    /*
                    **  problem: different to backend_category_update and backend_category_addNew, here $eventData did not contain the id of the category, so
                    **  the entry in the table _staticpage_categorypage is not deleted :-( Every time I get "35 AND 36" in the debug-modus.
                    **  GARVIN: Yes, the ID contains a SQL statement for Category ID because the category children are contained as well!
                    */
                    break;
                case 'backend_category_update':
                case 'backend_category_addNew':
                    $val = array('categoryid ' => (int) $eventData, 'staticpage_categorypage' => $serendipity['POST']['cat']['staticpage_categorypage']);
                    $this->setCatProps($eventData, $val);
                    break;
                case 'frontend_fetchentries':
                case 'frontend_rss':
                    $this->smarty_init();
                    break;
                case 'genpage':
                    $this->setupDB();
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    // Manko10 patch: http://board.s9y.org/viewtopic.php?f=3&t=17910&p=10426432#p10426432
                    // Check if static page exists or if this is an error 404
                    //
                    // NOTE: as soon as you set a static page to be a 404 handler
                    // from within the backend, you need to add a specific redirect rule
                    // to your .htaccess for each static page generated by other
                    // plugins such as serendipity_event_contactform
                    // This behavior might change in future releases.
                    $this->error_404 = $_SERVER['REDIRECT_STATUS'] == '404';
                    $pages = $this->fetchStaticPages(true, $nice_url);
                    if (is_array($pages)) {
                        foreach ($pages as $page) {
                            if ($page['permalink'] == $nice_url) {
                                $this->error_404 = FALSE;
                                if ($pages['is_404_page']) {
                                    $this->error_404 = TRUE;
                                }
                                break;
                            }
                        }
                    }
                    // Set static page to 404 error document if page not found
                    if ($this->error_404) {
                        $serendipity['GET']['subpage'] = $this->get404Errorpage();
                    }
                    // Set static page with is_startpage flag set as startpage
                    if ((empty($args) || preg_match('@' . $serendipity['indexFile'] . '\\??$@', trim($args))) && empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $this->getStartpage();
                    }
                    // Set static page according to requested URL
                    if (empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $nice_url;
                    }
                    if ($this->selected()) {
                        $te = $this->get_static('title_element');
                        if (!empty($te)) {
                            $serendipity['head_title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($te) : htmlspecialchars($te, ENT_COMPAT, LANG_CHARSET);
                            $serendipity['head_subtitle'] = '';
                        } else {
                            $serendipity['head_title'] = $this->get_static('headline');
                            $serendipity['head_subtitle'] = $serendipity['blogTitle'];
                        }
                    }
                    break;
                case 'frontend_header':
                    $md = function_exists('serendipity_specialchars') ? serendipity_specialchars($this->get_static('meta_description')) : htmlspecialchars($this->get_static('meta_description'), ENT_COMPAT, LANG_CHARSET);
                    $mk = function_exists('serendipity_specialchars') ? serendipity_specialchars($this->get_static('meta_keywords')) : htmlspecialchars($this->get_static('meta_keywords'), ENT_COMPAT, LANG_CHARSET);
                    if (!empty($md)) {
                        echo '        <meta name="description" content="' . $md . '" />' . "\n";
                    }
                    if (!empty($mk)) {
                        echo '        <meta name="keywords" content="' . $mk . '" />' . "\n";
                    }
                    break;
                case 'frontend_fetchentries':
                    if ($serendipity['GET']['action'] == 'search') {
                        serendipity_smarty_fetch('ENTRIES', 'entries.tpl', true);
                    }
                    break;
                case 'entry_display':
                    $this->smarty_init();
                    if ($this->selected()) {
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                            // This is important to not display an entry list!
                        } else {
                            $eventData = array('clean_page' => true);
                        }
                    }
                    break;
                case 'backend_sidebar_entries':
                    $this->setupDB();
                    echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=staticpages">' . STATICPAGE_TITLE . '</a></li>';
                    break;
                case 'backend_sidebar_entries_event_display_staticpages':
                    $this->showBackend();
                    break;
                case 'backend_media_rename':
                    // Only MySQL supported, since I don't know how to use REGEXPs differently.
                    if ($serendipity['dbType'] != 'mysql' && $serendipity['dbType'] != 'mysqli') {
                        echo STATICPAGE_MEDIA_DIRECTORY_MOVE_ENTRY . '<br />';
                        break;
                    }
                    if (!isset($eventData[0]['oldDir'])) {
                        return true;
                    }
                    if ($eventData[0]['type'] == 'dir') {
                    } elseif ($eventData[0]['type'] == 'filedir') {
                        $eventData[0]['oldDir'] .= $eventData[0]['name'];
                        $eventData[0]['newDir'] .= $eventData[0]['name'];
                    }
                    $q = "SELECT id, content, pre_content\n                            FROM {$serendipity['dbPrefix']}staticpages\n                           WHERE content     REGEXP '(src=|href=|window.open.)(\\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ")'\n                              OR pre_content REGEXP '(src=|href=|window.open.)(\\'|\")(" . serendipity_db_escape_String($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . "|" . serendipity_db_escape_string($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ")'\n                    ";
                    $dirs = serendipity_db_query($q);
                    if (is_array($dirs)) {
                        foreach ($dirs as $dir) {
                            $dir['content'] = preg_replace('@(src=|href=|window.open.)(\'|")(' . preg_quote($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . '|' . preg_quote($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ')@', '\\1\\2' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['newDir'], $dir['content']);
                            $dir['pre_content'] = preg_replace('@(src=|href=|window.open.)(\'|")(' . preg_quote($serendipity['baseURL'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . '|' . preg_quote($serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['oldDir']) . ')@', '\\1\\2' . $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $eventData[0]['newDir'], $dir['pre_content']);
                            $uq = "UPDATE {$serendipity['dbPrefix']}staticpages\n                                                     SET content     = '" . serendipity_db_escape_string($dir['content']) . "' ,\n                                                         pre_content = '" . serendipity_db_escape_string($dir['pre_content']) . "'\n                                                   WHERE id       = " . serendipity_db_escape_string($dir['id']);
                            serendipity_db_query($uq);
                        }
                        printf(STATICPAGE_MEDIA_DIRECTORY_MOVE_ENTRIES . '<br />', count($dirs));
                    }
                    break;
                case 'external_plugin':
                    $parts = explode('_', $eventData);
                    if (!empty($parts[1])) {
                        $param = (int) $parts[1];
                    } else {
                        $param = null;
                    }
                    if ($parts[0] == 'dtree.js') {
                        header('Content-Type: text/javascript');
                        echo file_get_contents(dirname(__FILE__) . '/dtree.js');
                    }
                    break;
                case 'entries_header':
                    if (!$this->isplugin()) {
                        $this->show();
                    }
                    break;
                case 'entries_footer':
                    if ($serendipity['GET']['action'] == 'search' && serendipity_db_bool($this->get_config('use_quicksearch'))) {
                        $this->showSearch();
                    }
                    break;
                case 'css_backend':
                    if (!strpos($eventData, '#serendipityStaticpagesNav')) {
                        // class exists in CSS, so a user has customized it and we don't need default
                        echo file_get_contents(dirname(__FILE__) . '/style_staticpage_backend.css');
                    }
                    break;
                default:
                    return false;
            }
            return true;
        }
        return false;
    }
Ejemplo n.º 6
0
<?php

# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved.  See LICENSE file for licensing details
if (IN_serendipity !== true) {
    die("Don't hack!");
}
include_once 'serendipity_config.inc.php';
include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
$uri = $_SERVER['REQUEST_URI'];
// need to define this again here, as index.php no longer includes this file
$uri_addData = array('startpage' => false, 'uriargs' => implode('/', serendipity_getUriArguments($uri, true)), 'view' => $serendipity['view'], 'viewtype' => isset($serendipity['viewtype']) ? $serendipity['viewtype'] : '');
if ((empty($uri_addData['uriargs']) || trim($uri_addData['uriargs']) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
    $uri_addData['startpage'] = true;
}
$serendipity['plugindata']['smartyvars'] = $uri_addData;
// Plugins can change this global variable
serendipity_plugin_api::hook_event('genpage', $uri, $uri_addData);
serendipity_smarty_init($serendipity['plugindata']['smartyvars']);
$leftSidebarElements = serendipity_plugin_api::count_plugins('left');
$rightSidebarElements = serendipity_plugin_api::count_plugins('right');
$serendipity['smarty']->assignByRef('leftSidebarElements', $leftSidebarElements);
$serendipity['smarty']->assignByRef('rightSidebarElements', $rightSidebarElements);
switch ($serendipity['GET']['action']) {
    // User wants to read the diary
    case 'read':
        if (isset($serendipity['GET']['id'])) {
            $entry = array(serendipity_fetchEntry('id', $serendipity['GET']['id']));
            if (!is_array($entry) || count($entry) < 1 || !is_array($entry[0])) {
                unset($serendipity['GET']['id']);
                $entry = array(array());
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'genpage':
                 $args = implode('/', serendipity_getUriArguments($eventData, true));
                 if ($serendipity['rewrite'] != 'none') {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                 } else {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                 }
                 if (empty($serendipity['GET']['subpage'])) {
                     $serendipity['GET']['subpage'] = $nice_url;
                 }
                 break;
             case 'entry_display':
                 if ($this->selected()) {
                     if (is_array($eventData)) {
                         $eventData['clean_page'] = true;
                         // This is important to not display an entry list!
                     } else {
                         $eventData = array('clean_page' => true);
                     }
                 }
                 return true;
                 break;
             case 'backend_sidebar_entries':
                 if ($serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF) {
                     if ($serendipity['version'][0] == '1') {
                         echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=poll">' . PLUGIN_POLL_TITLE . '</a></li>';
                     } else {
                         echo '<li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=poll">' . PLUGIN_POLL_TITLE . '</a></li>';
                     }
                 }
                 return true;
                 break;
             case 'backend_sidebar_entries_event_display_poll':
                 $this->showBackend();
                 return true;
                 break;
             case 'entries_header':
                 $this->show();
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     } else {
         return false;
     }
 }
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'genpage':
                 $args = implode('/', serendipity_getUriArguments($eventData, true));
                 if ($serendipity['rewrite'] != 'none') {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                 } else {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                 }
                 $oldsubpage = $serendipity['GET']['subpage'];
                 if (empty($serendipity['GET']['subpage'])) {
                     $serendipity['GET']['subpage'] = $nice_url;
                 }
                 if ($this->selected()) {
                     $serendipity['head_title'] = $this->get_config('pagetitle');
                     $serendipity['head_subtitle'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($serendipity['blogTitle']) : htmlspecialchars($serendipity['blogTitle'], ENT_COMPAT, LANG_CHARSET);
                 } else {
                     // Put subpage back so staticpage plugin will work
                     $serendipity['GET']['subpage'] = $oldsubpage;
                 }
                 break;
             case 'entry_display':
                 if ($this->selected()) {
                     if (is_array($eventData)) {
                         $eventData['clean_page'] = true;
                         // This is important to not display an entry list!
                     } else {
                         $eventData = array('clean_page' => true);
                     }
                 }
                 return true;
                 break;
             case 'entries_header':
                 $this->show();
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     } else {
         return false;
     }
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        $comic_cat = $this->get_config('category', '');
        $show_t = $this->get_config('show_title', 'true');
        $show_raw = $this->get_config('raw', 'true');
        $hide_fp = $this->get_config('hide', 'true');
        if ($event == 'css') {
            if (stristr('.serendipity_comics', $addData)) {
                // class exists in CSS, so a user has customized it and we don't need default
                return true;
            }
            ?>
.serendipity_comics {
	font-size: 15px;
	font-weight: bold;
    text-align: center;
    margin-top: 5px;
    margin-bottom: 10px;
    margin-left: auto;
    margin-right: auto;
    border: 0px;
    display: block;
}
<?php 
            return true;
        } elseif ($event == 'entries_header' || $event == 'frontend_fetchentries') {
            // determine location and show on the front page only
            $geturi = serendipity_getUriArguments($GLOBALS['uri']);
            if (!isset($geturi[0]) && !isset($serendipity['GET']['id']) && !isset($serendipity['GET']['category']) && $comic_cat) {
                $comic = serendipity_db_query("SELECT e.id, e.title, e.timestamp, e.body\n\t\t\t\t\tFROM {$serendipity['dbPrefix']}entries e\n\t\t\t\t\tINNER JOIN {$serendipity['dbPrefix']}entrycat\n\t\t\t\t\t\tON e.id = {$serendipity['dbPrefix']}entrycat.entryid\n\t\t\t\t\tWHERE e.isdraft =  'false'\n\t\t\t\t\t\tAND e.timestamp <= " . $this->timeOffset(time()) . "\n\t\t\t\t\t\tAND {$serendipity['dbPrefix']}entrycat.categoryid = {$comic_cat}\n\t\t\t\t\tORDER BY e.timestamp DESC\n\t\t\t\t\tLIMIT 1");
                if ($event == 'entries_header' && $serendipity['GET']['page'] == '1') {
                    if ($show_t == 'true') {
                        echo '<h4 class="serendipity_title"><a href="' . serendipity_archiveURL($comic[0]['id'], $comic[0]['title'], 'baseURL', true, array('timestamp' => $comic[0]['timestamp'])) . '">';
                        echo PLUGIN_COMICS_LATEST . (function_exists('serendipity_specialchars') ? serendipity_specialchars(serendipity_strftime(DATE_FORMAT_ENTRY, $comic['0']['timestamp'])) : htmlspecialchars(serendipity_strftime(DATE_FORMAT_ENTRY, $comic['0']['timestamp']), ENT_COMPAT, LANG_CHARSET)) . '</a></h4>';
                    }
                    if ($show_raw == 'true') {
                        echo $comic['0']['body'];
                    } else {
                        echo '<div class="serendipity_entry"><div class="serendipity_entry_body">';
                        $entry = array('html_nugget' => $comic['0']['body']);
                        serendipity_plugin_api::hook_event('frontend_display', $entry);
                        echo $entry['html_nugget'];
                        echo '</div></div>';
                    }
                    echo $this->jumplinks($comic['0']['id'], $comic_cat);
                } elseif ($event == 'frontend_fetchentries' && !$serendipity['GET']['page'] && !isset($serendipity['GET']['adminModule'])) {
                    if ($hide_fp == 'true') {
                        $cond = " INNER JOIN {$serendipity['dbPrefix']}entrycat ON e.id = {$serendipity['dbPrefix']}entrycat.entryid ";
                        if (empty($eventData['joins'])) {
                            $eventData['joins'] = $cond;
                        } else {
                            $eventData['joins'] .= $cond;
                        }
                        $cond = "{$serendipity['dbPrefix']}entrycat.categoryid != {$comic_cat}";
                    } else {
                        $cond = "e.id != {$comic['0']['id']}";
                    }
                    if (empty($eventData['and'])) {
                        $eventData['and'] = " WHERE {$cond} ";
                    } else {
                        $eventData['and'] .= " AND {$cond} ";
                    }
                }
            }
            return true;
        } elseif ($event == 'entry_display' && isset($serendipity['GET']['id']) && $comic_cat) {
            $thiscat = serendipity_fetchEntryCategories($serendipity['GET']['id']);
            if ($thiscat['0']['0'] == $comic_cat) {
                $elements = count($eventData);
                for ($i = 0; $i < $elements; $i++) {
                    unset($eventData[$i]['properties']['ep_cache_extended']);
                    $eventData[$i]['exflag'] = 1;
                    $eventData[$i]['extended'] .= sprintf($this->jumplinks($serendipity['GET']['id'], $comic_cat));
                }
            }
            return true;
        } else {
            return false;
        }
    }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'css':
                    if (strpos($eventData, '.serendipityAuthorProfile')) {
                        // class exists in CSS, so a user has customized it and we don't need default
                        return true;
                    }
                    ?>
.serendipityAuthorProfile {
    border: 1px solid #909090;
    width: 300px;
    margin-top: 5px;
    margin-bottom: 5px;
    margin-left: auto;
    margin-right: auto;
    padding: 10px;
}

.serendipityAuthorProfile dt {
    margin-top: 5px;
    font-weight: bold;
}

.serendipityAuthorProfile dd {
    margin-bottom: 5px;
}
.serendipity_authorpic {
    float: right;
    margin: 5px;
    border: 0px;
    display: block;
}

.serendipity_commentcount {
    float: right;
}
<?php 
                    return true;
                    break;
                case 'css_backend':
                    // do use in 2.0+ versions
                    if ($serendipity['version'][0] > 1) {
                        ?>

/* userprofiles plugin ------------- */
.userprofileform { margin-top: 1.5em; }

<?php 
                    }
                    break;
                case 'entries_header':
                    if (!empty($serendipity['GET']['viewAuthor'])) {
                        $tfile = serendipity_getTemplateFile('plugin_userprofile.tpl', 'serendipityPath');
                        if (!$tfile) {
                            $tfile = dirname(__FILE__) . '/plugin_userprofile.tpl';
                        }
                        $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
                        $serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
                        $profile = $this->getConfigVars($serendipity['GET']['viewAuthor']);
                        $local_properties =& $this->getLocalProperties();
                        foreach ($local_properties as $property => $info) {
                            $profile[$property] = $GLOBALS['uInfo'][0][$property];
                        }
                        $properties = array();
                        $properties = array_merge($this->properties, $this->option_properties);
                        $entry = array('body' => $profile['hobbies']);
                        serendipity_plugin_api::hook_event('frontend_display', $entry);
                        $profile['hobbies'] = $entry['body'];
                        $serendipity['smarty']->assign('userProfile', $profile);
                        $serendipity['smarty']->assign('userProfileProperties', $properties);
                        $serendipity['smarty']->assign('userProfileLocalProperties', $local_properties);
                        $serendipity['smarty']->assign('userProfileTitle', PLUGIN_EVENT_USERPROFILES_SHOW);
                        $content = $serendipity['smarty']->fetch('file:' . $tfile);
                        $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion;
                        echo $content;
                    }
                    $this->show();
                    break;
                case 'backend_sidebar_entries_event_display_profiles':
                    $this->checkSchema();
                    $this->showUsers();
                    return true;
                    break;
                case 'backend_sidebar_admin':
                    echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuUserManagement"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=profiles">' . PLUGIN_EVENT_USERPROFILES_TITLE . '</a></li>';
                    return true;
                    break;
                case 'genpage':
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    if (empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $nice_url;
                    }
                    break;
                case 'entry_display':
                    if ($this->selected()) {
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                            // This is important to not display an entry list!
                        } else {
                            $eventData = array('clean_page' => true);
                        }
                    }
                    if (version_compare($serendipity['version'], '0.7.1', '<=')) {
                        $this->show();
                    }
                    return true;
                    break;
                case 'frontend_display':
                    if ($bag->get('scrambles_true_content') && is_array($addData) && isset($addData['no_scramble'])) {
                        return true;
                    }
                case 'frontend_display_cache':
                    $this->showCommentcount($eventData);
                    if (!serendipity_db_bool($this->get_config('authorpic'))) {
                        return true;
                    }
                    if (empty($eventData['author'])) {
                        $tmp = serendipity_fetchAuthor($eventData['authorid']);
                        $author = $tmp[0]['realname'];
                    } else {
                        $author = $eventData['author'];
                    }
                    $authorname = $author;
                    if (isset($GLOBALS['i18n_filename_to'])) {
                        $author = str_replace($GLOBALS['i18n_filename_from'], $GLOBALS['i18n_filename_to'], $author);
                    }
                    if (serendipity_db_bool($this->get_config('gravatar'))) {
                        $img = 'http://www.gravatar.com/avatar.php?' . 'default=' . $this->get_config('gravatar_default', '80') . '&amp;gravatar_id=' . md5($eventData['email']) . '&amp;size=' . $this->get_config('gravatar_size', '80') . '&amp;border=&amp;rating=' . $this->get_config('gravatar_rating', 'R');
                        $this->found_images[$author] = '<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '" /><br /><span>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '</span></div>';
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } elseif (isset($this->found_images[$author])) {
                        // Author image was already found previously. Display it.
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } elseif ($img = serendipity_getTemplateFile('img/' . preg_replace('@[^a-z0-9]@i', '_', $author) . '.' . $this->get_config('extension'))) {
                        // Author image exists, save it in cache and display it.
                        $this->found_images[$author] = '<div class="serendipity_authorpic"><img src="' . $img . '" alt="' . AUTHOR . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '" /><br /><span>' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($authorname) : htmlspecialchars($authorname, ENT_COMPAT, LANG_CHARSET)) . '</span></div>';
                        $eventData['body'] = $this->found_images[$author] . $eventData['body'];
                    } else {
                        // No image found, do not try again in next article.
                        $this->found_images[$author] = '';
                    }
                    // Assign smarty variable {$entry.authorpic}
                    $eventData['authorpic'] = $this->found_images[$author];
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
Ejemplo n.º 11
0
header('Status: 200 OK');
// Session are needed to also remember an autologin user on the frontend
include 'serendipity_config.inc.php';
include 'include/functions_routing.inc.php';
header('Content-Type: text/html; charset=' . LANG_CHARSET);
if ($serendipity['CacheControl']) {
    if (!empty($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache/2')) {
        header('Cache-Control: no-cache, pre-check=0, post-check=0');
    } else {
        header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
    }
    header('Expires: 0');
    header('Pragma: no-cache');
}
$uri = $_SERVER['REQUEST_URI'];
$serendipity['uriArguments'] = serendipity_getUriArguments($uri);
if (isset($_SERVER['HTTP_REFERER']) && empty($_SESSION['HTTP_REFERER'])) {
    $_SESSION['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];
}
if (preg_match(PAT_UNSUBSCRIBE, $uri, $res)) {
    if (serendipity_cancelSubscription(urldecode($res[1]), $res[2])) {
        define('DATA_UNSUBSCRIBED', sprintf(UNSUBSCRIBE_OK, urldecode($res[1])));
    }
    $uri = '/' . PATH_UNSUBSCRIBE . '/' . $res[2] . '-untitled.html';
} else {
    define('DATA_UNSUBSCRIBED', false);
}
serendipity_checkCommentTokenModeration($uri);
if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) {
    if ($res[1] == 'comment' && serendipity_deleteComment($res[2], $res[3], 'comments')) {
        define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));
    /**
     * Hook for Serendipity events, initialize plug-in features
     *
     * @param  string                   $event
     * @param  serendipity_property_bag $bag
     * @param  array                    $eventData
     * @param  array                    $addData
     * @return boolean
     */
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        $serendipity['plugin_guestbook_version'] =& $bag->get('version');
        // set global plugin path setting, to avoid different pluginpath '/plugins/' as plugins serendipity vars
        if (!isset($serendipity['guestbook']['pluginpath'])) {
            $pluginpath = pathinfo(dirname(__FILE__));
            $serendipity['guestbook']['pluginpath'] = basename(rtrim($pluginpath['dirname'], '/')) . '/serendipity_event_guestbook/';
        }
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'frontend_configure':
                    // checking if db tables exists, otherwise install them
                    $cur = '';
                    $old = $this->get_config('version', '', false);
                    if ($old == '1.0') {
                        $cur = $old;
                    }
                    if (empty($cur) && (!empty($old) || $old == '' && $old != false)) {
                        $cur = '2.0';
                    } else {
                        $cur = $this->get_config('dbversion');
                    }
                    if ($cur == '1.0') {
                        $this->alter_db($cur);
                        $this->set_config('dbversion', '2.0');
                    } elseif ($cur == '2.0') {
                        $this->alter_db($cur);
                        $this->set_config('dbversion', '3.0');
                        $this->cleanup();
                    } elseif ($cur == '3.0') {
                        $this->alter_db($cur);
                        $this->set_config('dbversion', '4');
                    } elseif ($cur == '4') {
                        $this->alter_db($cur);
                        $this->set_config('dbversion', '5');
                    } elseif ($cur == '5') {
                        continue;
                    } else {
                        $this->install();
                        $this->set_config('dbversion', '5');
                    }
                    break;
                case 'genpage':
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    if (empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $nice_url;
                    }
                    if ($this->selected()) {
                        $serendipity['head_title'] = $this->get_config('headline');
                        $serendipity['head_subtitle'] = $this->html_specialchars($serendipity['blogTitle']);
                    }
                    break;
                case 'entry_display':
                    if ($this->selected()) {
                        // This is important to not display an entry list!
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                        } else {
                            $eventData = array('clean_page' => true);
                        }
                    }
                    return true;
                    break;
                case 'entries_header':
                    // this one really rolls up output: check form submit, generate entries and form
                    $this->generate_Page();
                    return true;
                    break;
                case 'external_plugin':
                    // [0]=guestbookdlsql; [1]=filename;
                    $gb['export'] = explode('/', $eventData);
                    if ($gb['export'][0] == 'guestbookdlsql') {
                        $file = file_get_contents($serendipity['serendipityPath'] . 'templates_c/guestbook/' . $gb['export'][1]);
                        echo $file;
                        header('Status: 302 Found');
                        header('Content-Type: application/octet-stream; charset=UTF-8');
                        // text/plain to see as file in browser
                        header('Content-Disposition: inline; filename=' . $gb['export'][1]);
                    }
                    break;
                    // put here all you css stuff you need for frontend guestbook pages
                // put here all you css stuff you need for frontend guestbook pages
                case 'css':
                    if (stristr($eventData, '#guestbook_wrapper')) {
                        // class exists in CSS, so a user has customized it and we don't need default
                        return true;
                    }
                    $tfile = serendipity_getTemplateFile('style_guestbook_frontend.css', 'serendipityPath');
                    if ($tfile) {
                        $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}');
                        $replace = array('templates/' . $serendipity['defaultTemplate'] . '/', $serendipity['guestbook']['pluginpath']);
                        $tfilecontent = str_replace($search, $replace, @file_get_contents($tfile));
                    }
                    if (!$tfile || $tfile == 'style_guestbook_frontend.css') {
                        $tfile = dirname(__FILE__) . '/style_guestbook_frontend.css';
                        $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}');
                        $tfilecontent = str_replace($search, $serendipity['guestbook']['pluginpath'], @file_get_contents($tfile));
                    }
                    if (!empty($tfilecontent)) {
                        $this->cssEventData($eventData, $tfilecontent);
                    }
                    return true;
                    break;
                case 'backend_sidebar_entries':
                    // forbid sidebar link if user is not in admin group level
                    if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) {
                        return false;
                    }
                    if ($serendipity['version'][0] < 2) {
                        echo "\n" . '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=guestbook">' . PLUGIN_GUESTBOOK_ADMIN_NAME . '</a></li>' . "\n";
                    }
                    return true;
                    break;
                case 'backend_sidebar_admin_appearance':
                    // forbid sidebar link if user is not in admin group level
                    if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) {
                        return false;
                    }
                    if ($serendipity['version'][0] > 1) {
                        echo "\n" . '<li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=guestbook">' . PLUGIN_GUESTBOOK_ADMIN_NAME . '</a></li>' . "\n";
                    }
                    return true;
                    break;
                case 'backend_sidebar_entries_event_display_guestbook':
                    // forbid entry access if user is not in admin group level
                    if ($serendipity['serendipityUserlevel'] < USERLEVEL_ADMIN) {
                        return false;
                    }
                    // show backend administration menu
                    $this->gbadminpanel();
                    return true;
                    break;
                    // put here all you css stuff you need for the backend of guestbook pages
                // put here all you css stuff you need for the backend of guestbook pages
                case 'css_backend':
                    if (stristr($eventData, '#wrapGB')) {
                        // class exists in CSS, so a user has customized it and we don't need default
                        return true;
                    }
                    $tfile = serendipity_getTemplateFile('style_guestbook_backend.css', 'serendipityPath');
                    if ($tfile) {
                        $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}');
                        $replace = array('templates/' . $serendipity['defaultTemplate'] . '/', $serendipity['guestbook']['pluginpath']);
                        $tfilecontent = str_replace($search, $replace, @file_get_contents($tfile));
                    }
                    if ((!$tfile || $tfile == 'style_guestbook_backend.css') && !$tfilecontent) {
                        $tfile = dirname(__FILE__) . '/style_guestbook_backend.css';
                        $search = array('{TEMPLATE_PATH}', '{PLUGIN_PATH}');
                        $tfilecontent = str_replace($search, $serendipity['guestbook']['pluginpath'], @file_get_contents($tfile));
                    }
                    // overwrite Serendipity 1.7 .serendipityAdminContent span !important
                    if ($serendipity['version'][0] < '2') {
                        ?>
#wrapGB .gb_entryhead span {color: #CCDDE7 !important;}
#wrapGB .gb_entrybody span {color: #222 !important;}
#wrapGB .msg_error,
#wrapGB .msg_success,
#wrapGB .msg_notice,
#wrapGB .msg_hint {
    display: block;
    margin: 1.5em 0;
    padding: .5em;
}
#wrapGB .msg_error {
    background: #f2dede;
    border: 1px solid #e4b9b9;
    color: #b94a48;
}
#wrapGB .msg_success {
    background: #dff0d8;
    border: 1px solid #c1e2b3;
    color: #468847;
}
#wrapGB .msg_notice {
    background: #fcf8e3;
    border: 1px solid #fbeed5;
    color: #c09853;
}
#wrapGB .msg_hint {
    background: #eee;
    border: 1px solid #aaa;
    color: #777;
}
<?php 
                    }
                    // add replaced css content to the end of serendipity_admin.css
                    if (!empty($tfilecontent)) {
                        $this->cssEventData($eventData, $tfilecontent);
                    }
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     static $pluginDir = null;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         if ($pluginDir === null) {
             $pluginDir = $this->get_config('lightbox_path');
         }
         switch ($event) {
             case 'entry_display':
                 if ($this->selected()) {
                     if (is_array($eventData)) {
                         $eventData['clean_page'] = true;
                         // This is important to not display an entry list!
                     } else {
                         $eventData = array('clean_page' => true);
                     }
                 }
                 return true;
                 break;
             case 'entries_header':
                 if ($this->selected()) {
                     $this->show();
                 }
                 return true;
                 break;
             case 'css':
                 // If you only want to determine if a particular needle occurs within haystack, use the faster and less memory intensive function strpos() instead.
                 if (strpos($eventData, '.exif_info') === false) {
                     $out = serendipity_getTemplateFile('serendipity_event_usergallery.css', 'serendipityPath');
                     if ($out && $out != 'serendipity_event_usergallery.css') {
                         $eventData .= file_get_contents($out);
                         // do not echo here and there, since this prevents the strpos check to work, which multiplies gallery css added to stream for multiple stacked galleries
                     } else {
                         $eventData .= file_get_contents(dirname(__FILE__) . '/serendipity_event_usergallery.css');
                     }
                 }
                 return true;
                 break;
             case 'frontend_configure':
                 if (isset($_REQUEST['gallery'])) {
                     // Disallow RSS-caching, because the entry age that is used for caching does not apply here.
                     $_GET['nocache'] = $_REQUEST['nocache'] = true;
                     // We need to set this variable to circumvent FeedBurner relocation
                     $_GET['type'] = 'comments';
                 }
                 return true;
                 break;
             case 'frontend_rss':
                 $this->showRSS($eventData);
                 return true;
                 break;
             case 'genpage':
                 $args = implode('/', serendipity_getUriArguments($eventData, true));
                 if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
                     if ($this->get_config('frontpage', 'no') == 'yes') {
                         $serendipity['GET']['subpage'] = $this->get_config('subpage');
                     }
                 }
                 if ($serendipity['rewrite'] != 'none') {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                 } else {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                 }
                 if (empty($serendipity['GET']['subpage'])) {
                     $serendipity['GET']['subpage'] = $nice_url;
                 }
                 if ($this->selected()) {
                     if ($this->get_config('base_directory') == 'gallery') {
                         // this is to avoid having the word "gallery" as blog title
                         $serendipity['head_title'] = preg_replace('@[^a-z0-9]@i', ' ', $this->get_config('title'));
                     } else {
                         $serendipity['head_title'] = preg_replace('@[^a-z0-9]@i', ' ', $this->get_config('base_directory'));
                     }
                     $serendipity['head_subtitle'] = $serendipity['blogTitle'];
                 }
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     }
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'external_plugin':
                    $events = explode('_', $eventData);
                    if ($events[0] != 'copycop') {
                        return false;
                    }
                    // TODO: Call CopyCop here somehow.
                    break;
                case 'genpage':
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    if (empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $nice_url;
                    }
                    break;
                case 'entry_display':
                    if ($this->selected()) {
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                            // This is important to not display an entry list!
                        } else {
                            $eventData = array('clean_page' => true);
                        }
                    }
                    return true;
                    break;
                case 'entries_header':
                    $this->show();
                    return true;
                    break;
                case 'backend_publish':
                    if (!$eventData['id']) {
                        return false;
                    }
                    $res = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}suggestmails WHERE entry_id = " . (int) $eventData['id'], true, 'assoc');
                    if (!is_array($res)) {
                        $res = array();
                    }
                    if (!$res['id']) {
                        return false;
                    }
                    //  CUSTOMIZE
                    serendipity_sendMail($res['email'], PLUGIN_SUGGEST_TITLE, PLUGIN_SUGGEST_PUBLISHED, $serendipity['blogMail'], null, $serendipity['blog']);
                    echo PLUGIN_SUGGEST_INFORM . "<br />\n";
                    serendipity_db_query("REPLACE INTO {$serendipity['dbPrefix']}entryproperties\n                                                       (entryid, property, value)\n                                                VALUES (" . (int) $eventData['id'] . ", 'ep_suggest_name', '" . serendipity_db_escape_string($res['name']) . "')");
                    break;
                case 'backend_display':
                    if (!$eventData['id']) {
                        return false;
                    }
                    $res = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}suggestmails WHERE entry_id = " . (int) $eventData['id'], true, 'assoc');
                    if (!is_array($res)) {
                        $res = array();
                        ?>
                    <fieldset style="margin: 5px">
                        <legend><?php 
                        echo PLUGIN_SUGGEST_TITLE;
                        ?>
</legend>
                        <div><?php 
                        echo PLUGIN_SUGGEST_INTERNAL;
                        ?>
</div>
                    </fieldset>

<?php 
                    } else {
                        //  CUSTOMIZE
                        ?>
                    <fieldset style="margin: 5px">
                        <legend><?php 
                        echo PLUGIN_SUGGEST_TITLE;
                        ?>
</legend>
                        <div>
                            <?php 
                        printf(PLUGIN_SUGGEST_META, function_exists('serendipity_specialchars') ? serendipity_specialchars($res['name']) : htmlspecialchars($res['name'], ENT_COMPAT, LANG_CHARSET), strftime('%d.%m.%Y %H:%M', $res['submitted']), function_exists('serendipity_specialchars') ? serendipity_specialchars($res['ip']) : htmlspecialchars($res['ip'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($res['email']) : htmlspecialchars($res['email'], ENT_COMPAT, LANG_CHARSET));
                        ?>
                        </div>
                    </fieldset>
<?php 
                    }
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     $serendipity['plugin_eventcal_version'] =& $bag->get('version');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'frontend_configure':
                 /* checking if db tables exists, otherwise install them */
                 $cur = $this->get_config('version');
                 $cur = !empty($cur) ? $cur : $this->get_config('dbversion');
                 if ($cur == '1.0' && !$this->get_config('dbversion')) {
                     $this->alter_db($cur);
                     $this->set_config('dbversion', '1.1');
                     $this->set_config('version', '');
                     // unset value to cleanup
                     $this->cleanup();
                     // remove_plugin_value - removes empty vars only
                 } elseif ($cur == '1.1') {
                     //void
                 } else {
                     $this->install();
                     $this->set_config('dbversion', '1.1');
                 }
                 return true;
                 break;
             case 'external_plugin':
                 // [0]=ics_export/sql_export; [1]=id/filename; [2]=month(cm); [3]=year(cy); [4]=case: no, dl, wc, ml, ud; [5] to=email; (optional) [6] ics=all (admin string)
                 $evc['export'] = explode('/', $eventData);
                 if (is_array($evc['export']) && $evc['export'][0] == 'sql_export') {
                     $file = file_get_contents($serendipity['serendipityPath'] . 'templates_c/eventcal/' . $evc['export'][1]);
                     echo $file;
                     header('Status: 302 Found');
                     header('Content-Type: application/octet-stream; charset=UTF-8');
                     // text/plain to see as file in browser
                     header('Content-Disposition: inline; filename=' . $evc['export'][1]);
                 }
                 if (is_array($evc['export']) && $evc['export'][0] == 'ics_export') {
                     $adminrequest = isset($evc['export'][6]) ? true : false;
                     $icl = $this->draw_icalendar($evc['export'][1], $evc['export'][2], $evc['export'][3], $adminrequest);
                 }
                 if (isset($icl) && !empty($eventData) && $evc['export'][4] != 'no') {
                     /* set the ical url location target to s9y/uploads or reload page with sent result */
                     if ($evc['export'][4] == 'ml' && !$evc['export'][6]) {
                         $url = $_SERVER['HTTP_HOST'] . $this->fetchPluginUri() . ($serendipity['rewrite'] == 'rewrite' ? '?' : '&') . 'serendipity[mailData]=';
                     } elseif ($evc['export'][4] == 'ml' && $evc['export'][6] == 'all') {
                         $url = $_SERVER['HTTP_HOST'] . $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=event_display&serendipity[adminAction]=eventcal&serendipity[eventcalcategory]=adevplad&serendipity[eventcaldbclean]=dbicalall&serendipity[mailData]=';
                     } else {
                         $url = $_SERVER['HTTP_HOST'] . $serendipity['serendipityHTTPPath'] . 'uploads/icalendar.ics';
                     }
                     /* write the ical string to ics file if not requested as download */
                     if ($evc['export'][4] != 'dl') {
                         $wcal = $this->write_file($icl);
                     }
                     if (serendipity_db_bool($this->get_config('log_ical'))) {
                         $ym = $evc['export'][3] . '-' . sprintf("%02d", $evc['export'][2]);
                     }
                     $sendmail = $this->get_config('log_email') ? true : false;
                     switch ($evc['export'][4]) {
                         /* download as file */
                         case 'dl':
                             echo $icl;
                             header('Status: 302 Found');
                             header('Content-Type: text/calendar; charset=UTF-8');
                             header("Content-Disposition: inline; filename=icalendar.ics");
                             // Send mail to the admin if he has set log iCal requests in config to receive these mails
                             if (serendipity_db_bool($this->get_config('log_ical'))) {
                                 $this->send_ical_log_email($this->get_config('log_email'), '', $evc['export'][5], $evc['export'][1], $ym, 'as ics download', $evc['export'][4], $sendmail);
                             }
                             break;
                             /* send file via webcal */
                         /* send file via webcal */
                         case 'wc':
                             if (serendipity_isResponseClean($url) && $wcal === true) {
                                 // Send mail to the admin if he has set log iCal requests in config to receive these mails
                                 if (serendipity_db_bool($this->get_config('log_ical'))) {
                                     $this->send_ical_log_email($this->get_config('log_email'), '', $evc['export'][5], $evc['export'][1], $ym, 'via webcal', $evc['export'][4], $sendmail);
                                 }
                                 header('Status: 302 Found');
                                 header('Content-Type: text/calendar; charset=UTF-8');
                                 header('Location: webcal://' . $url);
                             }
                             break;
                             /* send via email and attachment */
                         /* send via email and attachment */
                         case 'ml':
                             if (!empty($evc['export'][5]) && $evc['export'][5] != 'none') {
                                 $to = $evc['export'][5];
                             } else {
                                 $to = $this->get_config('log_email') ? $this->get_config('log_email') : $serendipity['serendipityEmail'];
                             }
                             if (!empty($to) && $to != '*****@*****.**') {
                                 //* @param   string  The validated recipient address of the mail, @param   string  The ical body part of the mail
                                 $result = $this->sendIcalEmail($to, $icl);
                                 //returns true or false
                                 // Send mail to the admin if he has set log iCal requests in config to receive these mails
                                 if (serendipity_db_bool($this->get_config('log_ical'))) {
                                     $this->send_ical_log_email($this->get_config('log_email'), '', $evc['export'][5], $evc['export'][1], $ym, 'as email', $evc['export'][4], $sendmail);
                                 }
                             }
                             if (serendipity_isResponseClean($url)) {
                                 header('Location: http://' . $url . ($result ? 1 : 2));
                             }
                             break;
                         default:
                             return false;
                             break;
                     }
                     exit;
                 }
             case 'genpage':
                 $args = implode('/', serendipity_getUriArguments($eventData, true));
                 if ($serendipity['rewrite'] == 'rewrite') {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                 } else {
                     $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                 }
                 if (empty($serendipity['GET']['subpage'])) {
                     $serendipity['GET']['subpage'] = $nice_url;
                 }
                 return true;
                 break;
             case 'entry_display':
                 if ($this->selected()) {
                     if (is_array($eventData)) {
                         $eventData['clean_page'] = true;
                         // This is important to not display an entry list!
                     } else {
                         $eventData = array('clean_page' => true);
                     }
                 }
                 // Silence pedantic warnings about missing default TZ settings
                 if (function_exists("date_default_timezone_get")) {
                     $tz = @date_default_timezone_get();
                     date_default_timezone_set($tz);
                 }
                 if (version_compare($serendipity['version'], '1.4', '<=')) {
                     $this->show();
                 }
                 return true;
                 break;
             case 'entries_header':
                 // this one really rolls up output
                 $this->show();
                 return true;
                 break;
                 /* put here all you css stuff you need for the frontend of eventcal pages */
             /* put here all you css stuff you need for the frontend of eventcal pages */
             case 'css':
                 if (stristr($eventData, '#eventcal_wrapper')) {
                     // class exists in CSS, so a user has customized it and we don't need default
                     return true;
                 }
                 $tfile = serendipity_getTemplateFile('style_eventcal_backend.css', 'serendipityPath');
                 if ($tfile) {
                     echo str_replace('{TEMPLATE_PATH}', 'templates/' . $serendipity['defaultTemplate'] . '/', @file_get_contents($tfile));
                 }
                 if (!$tfile || $tfile == 'style_eventcal_backend.css') {
                     $tfile = dirname(__FILE__) . '/style_eventcal_backend.css';
                     echo str_replace('{TEMPLATE_PATH}', $serendipity['eventcal']['pluginpath'], @file_get_contents($tfile));
                 }
                 return true;
                 break;
             case 'backend_sidebar_entries':
                 // forbid entry if not admin
                 if (serendipity_userLoggedIn() && $_SESSION['serendipityAuthedUser'] === true && $_SESSION['serendipityUserlevel'] == '255') {
                     echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks">
                         <a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=eventcal">
                         ' . PLUGIN_EVENTCAL_ADMIN_NAME . '
                         </a>
                     </li>';
                 }
                 return true;
                 break;
             case 'backend_sidebar_entries_event_display_eventcal':
                 // forbid entry if not admin
                 if (serendipity_userLoggedIn() && $_SESSION['serendipityAuthedUser'] === true && $_SESSION['serendipityUserlevel'] == '255') {
                     if (!is_object($serendipity['smarty'])) {
                         serendipity_smarty_init();
                         // if not set to avoid member function assign() on a non-object error, start Smarty templating
                     }
                     /* show backend administration menu */
                     $this->backend_eventcal_menu();
                 }
                 return true;
                 break;
                 /* put here all you css stuff you need for the backend of eventcal pages */
             /* put here all you css stuff you need for the backend of eventcal pages */
             case 'css_backend':
                 if (stristr($eventData, '#eventcal_wrapper')) {
                     // class exists in CSS, so a user has customized it and we don't need default
                     return true;
                 }
                 $tfile = serendipity_getTemplateFile('style_eventcal_backend.css', 'serendipityPath');
                 if ($tfile) {
                     $tfilecontent = str_replace('{TEMPLATE_PATH}', 'templates/' . $serendipity['defaultTemplate'] . '/', @file_get_contents($tfile));
                 }
                 if ((!$tfile || $tfile == 'style_eventcal_backend.css') && !$tfilecontent) {
                     $tfile = dirname(__FILE__) . '/style_eventcal_backend.css';
                     $tfilecontent = str_replace('{TEMPLATE_PATH}', $serendipity['eventcal']['pluginpath'], @file_get_contents($tfile));
                 }
                 // add replaced css content to the end of serendipity_admin.css
                 if (!empty($tfilecontent)) {
                     $this->backend_eventcal_css($eventData, $tfilecontent);
                 }
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
         // switch end
     } else {
         return false;
     }
     // isset hooks end
 }
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        $serendipity['wrapurl']['id_name'] = $this->get_config('pagetitle') ? $this->get_config('pagetitle') : 'none';
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'frontend_generate_plugins':
                    if ($this->selected() && serendipity_db_bool($this->get_config('hide_sidebar'))) {
                        $serendipity['smarty']->assign('leftSidebarElements', 0);
                        $serendipity['smarty']->assign('rightSidebarElements', 0);
                        $eventData = array();
                    }
                    break;
                case 'genpage':
                    $args = implode('/', serendipity_getUriArguments($eventData, true));
                    if ($serendipity['rewrite'] != 'none') {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $args;
                    } else {
                        $nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
                    }
                    if (empty($serendipity['GET']['subpage'])) {
                        $serendipity['GET']['subpage'] = $nice_url;
                    }
                    break;
                case 'entry_display':
                    if ($this->selected()) {
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                            // This is important to not display an entry list!
                        } else {
                            $eventData = array('clean_page' => true);
                        }
                    }
                    if (version_compare($serendipity['version'], '0.7.1', '<=')) {
                        $this->show();
                    }
                    return true;
                    break;
                case 'entries_header':
                    $this->show();
                    return true;
                    break;
                    /* put here all your css stuff you need for the wrapurl plugin frontend output */
                /* put here all your css stuff you need for the wrapurl plugin frontend output */
                case 'css':
                    if (stristr($eventData, '#plugin_wrapurl')) {
                        // class exists in CSS, so a user has customized it and we don't need default
                        return true;
                    }
                    echo '
#plugin_wrapurl_' . $serendipity['wrapurl']['id_name'] . ' { width: 100%; border: 0 none; border-collapse: collapse; border-spacing: 0; height:' . $this->get_config('height') . 'px; }
';
                    return true;
                    break;
                default:
                    return false;
                    break;
            }
        } else {
            return false;
        }
    }