コード例 #1
0
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        $this->debug = serendipity_db_bool($this->get_config('debug'));
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'backend_sidebar_entries':
                    if ($serendipity['serendipityUserlevel'] >= USERLEVEL_CHIEF) {
                        if ($serendipity['version'][0] == '1') {
                            ?>
                        <li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=aggregator"><?php 
                            echo PLUGIN_AGGREGATOR_TITLE;
                            ?>
</a></li>
<?php 
                        } else {
                            ?>
                        <li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=aggregator"><?php 
                            echo PLUGIN_AGGREGATOR_TITLE;
                            ?>
</a></li>
<?php 
                        }
                    }
                    break;
                case 'backend_sidebar_entries_event_display_aggregator':
                    $this->showFeeds();
                    break;
                case 'cronjob':
                    if ($this->get_config('cronjob') == $eventData) {
                        serendipity_event_cronjob::log('Aggregator', 'plugin');
                        $this->fetchFeeds();
                        # Fetch first, expire later (some feeds offer old stuff)
                        $this->expireFeeds();
                    }
                    return true;
                    break;
                case 'aggregator_feedlist':
                    $this->parseShowFeed($eventData);
                    return true;
                    break;
                case 'external_plugin':
                    if ($eventData == 'opmlfeeds.xml') {
                        header('Content-Type: text/xml; charset=utf-8');
                        echo '<?xml version="1.0" encoding="utf-8" ?>' . "\n";
                        $modified = gmdate('D, d M Y H:i:s \\G\\M\\T', serendipity_serverOffsetHour(time(), true));
                        print <<<EOF
<opml version="1.0">
<head>
    <title>{$serendipity['blogTitle']}</title>
    <dateModified>{$modified}</dateModified>
    <ownerName>Serendipity - http://www.s9y.org/</ownerName>
</head>
<body>
EOF;
                        $feeds = serendipity_db_Query("\n                                    SELECT c.categoryid,\n                                           f.feedname,\n                                           f.feedurl,\n                                           f.htmlurl\n                                     FROM {$serendipity['dbPrefix']}category AS c\n                                LEFT JOIN {$serendipity['dbPrefix']}aggregator_feedcat AS fc\n                                       ON fc.categoryid = c.categoryid\n                                LEFT JOIN {$serendipity['dbPrefix']}aggregator_feeds AS f\n                                       ON fc.feedid = f.feedid", false, 'assoc');
                        $xml = array();
                        if (is_array($feeds)) {
                            foreach ($feeds as $feed) {
                                $xml[$feed['categoryid']][] = $feed;
                            }
                        }
                        if (is_array($cats = serendipity_fetchCategories())) {
                            $cats = $this->showRecursive($cats, $xml, 'categoryid', 'parentid', VIEWMODE_THREADED);
                        }
                        print "</body>\n</opml>";
                        return;
                    }
                    if ($eventData != 'aggregator') {
                        return;
                    }
                    $this->fetchFeeds();
                    # Fetch first, expire later (some feeds offer old stuff)
                    $this->expireFeeds();
                    break;
            }
        }
        return true;
    }
コード例 #2
0
    function event_hook($event, &$bag, &$eventData, $addData = null)
    {
        global $serendipity;
        $hooks =& $bag->get('event_hooks');
        if (isset($hooks[$event])) {
            switch ($event) {
                case 'cronjob':
                    if ($this->get_config('cronjob') == $eventData) {
                        serendipity_event_cronjob::log('DBClean', 'plugin');
                        $days = (int) $this->get_config('days');
                        if ($days > 0) {
                            $this->cleanDB('cronjoblog', $days);
                            $this->cleanDB('spamblocklog', $days);
                            $this->cleanDB('spamblock_htaccess', $days);
                            $this->cleanDB('visitors', $days);
                            $this->cleanDB('referrers', $days);
                            $this->cleanDB('exits', $days);
                        }
                    }
                    return true;
                    break;
                case 'external_plugin':
                    switch ($eventData) {
                        case 'dbclean':
                            if (!(serendipity_checkPermission('siteConfiguration') || serendipity_checkPermission('blogConfiguration'))) {
                                return;
                            }
                            $days = $_REQUEST['days'];
                            if (is_numeric($days)) {
                                if (isset($_REQUEST['cronjoblog'])) {
                                    $this->cleanDB('cronjoblog', $days);
                                }
                                if (isset($_REQUEST['spamblocklog'])) {
                                    $this->cleanDB('spamblocklog', $days);
                                }
                                if (isset($_REQUEST['spamblock_htaccess'])) {
                                    $this->cleanDB('spamblock_htaccess', $days);
                                }
                                if (isset($_REQUEST['visitors'])) {
                                    $this->cleanDB('visitors', $days);
                                }
                                if (isset($_REQUEST['referrers'])) {
                                    $this->cleanDB('referrers', $days);
                                }
                                if (isset($_REQUEST['exits'])) {
                                    $this->cleanDB('exits', $days);
                                }
                            }
                            #redirect the user back to the menu
                            echo '<meta http-equiv="REFRESH" content="0;url=serendipity_admin.php?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=dbclean">';
                            return true;
                            break;
                    }
                    return true;
                    break;
                case 'backend_sidebar_admin':
                    if ($serendipity['version'][0] == '1') {
                        echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=dbclean">' . PLUGIN_EVENT_DBCLEAN_NAME . '</a></li>';
                    } else {
                        echo '<li><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=dbclean">' . PLUGIN_EVENT_DBCLEAN_NAME . '</a></li>';
                    }
                    return true;
                    break;
                case 'backend_sidebar_entries_event_display_dbclean':
                    $this->displayMenu();
                    return true;
                    break;
                case 'css_backend':
                    if ($serendipity['version'][0] > 1) {
                        ?>

#dbcleanTable {
    border: 1px solid #aaa;
    border-bottom: 0 none;
    width: 100%;
}

#dbcleanTable thead tr {
    background-color: #eee;
}

#dbcleanTable tr {
    border-bottom: 1px solid #aaa;
}

#dbcleanTable th,
#dbcleanTable td {
    padding: .125em .25em;
}

<?php 
                    }
                    return true;
                    break;
                default:
                    return false;
            }
        } else {
            return false;
        }
    }
コード例 #3
0
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'cronjob':
                 if ($this->get_config('cronjob') == $eventData) {
                     serendipity_event_cronjob::log('Spartacus', 'plugin');
                     $avail = array();
                     $install = array();
                     $meth = array('event', 'sidebar');
                     $active = serendipity_plugin_api::get_installed_plugins();
                     $avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
                     $avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
                     #echo "XAVAIL:<pre>" . print_r($avail, true) . "</pre>";
                     $install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
                     $install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
                     #echo "XINSTALL:<pre>" . print_r($install, true) . "</pre>";
                     $mailtext = '';
                     foreach ($meth as $method) {
                         foreach ($install[$method] as $class_data) {
                             #echo "Probe " . $class_data['name']. "<br />\n"; // DEBUG
                             $pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
                             $plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
                             if (is_object($plugin)) {
                                 #echo "Non cached<br />\n";
                                 #echo "<pre>" . print_r($avail[$method][$class_data['name']], true) . "</pre>";
                                 // Object is returned when a plugin could not be cached.
                                 $bag = new serendipity_property_bag();
                                 $plugin->introspect($bag);
                                 // If a foreign plugin is upgradable, keep the new version number.
                                 if (isset($avail[$method][$class_data['name']])) {
                                     $class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
                                 }
                                 $props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
                                 #echo "<pre>" . print_r($props, true) . "</pre>";
                             } elseif (is_array($plugin)) {
                                 // Array is returned if a plugin could be fetched from info cache
                                 $props = $plugin;
                                 #echo "Cached<br />\n";
                             } else {
                                 $props = false;
                                 #echo "Error<br />\n";
                             }
                             if (is_array($props)) {
                                 #echo "<pre>" . print_r($props, true) . "</pre>\n";
                                 if (version_compare($props['version'], $props['upgrade_version'], '<')) {
                                     $mailtext .= ' * ' . $class_data['name'] . " NEW VERSION: " . $props['upgrade_version'] . " - CURRENT VERSION: " . $props['version'] . "\n";
                                 }
                             } else {
                                 $mailtext .= " X ERROR: " . $class_data['true_name'] . "\n";
                             }
                         }
                     }
                     if (!empty($mailtext)) {
                         serendipity_sendMail($serendipity['blogMail'], 'Spartacus update report ' . $serendipity['baseURL'], $mailtext, $serendipity['blogMail']);
                         echo nl2br($mailtext);
                     }
                 } else {
                     $propbag->add('type', 'suboption');
                 }
                 break;
             case 'external_plugin':
                 if (!serendipity_db_bool($this->get_config('enable_remote'))) {
                     return false;
                 }
                 if ($eventData == $this->get_config('remote_url')) {
                     header('Content-Type: text/plain');
                     $avail = array();
                     $install = array();
                     $meth = array('event', 'sidebar');
                     $active = serendipity_plugin_api::get_installed_plugins();
                     $avail['event'] = $this->buildList($this->fetchOnline('event'), 'event');
                     $avail['sidebar'] = $this->buildList($this->fetchOnline('sidebar'), 'sidebar');
                     $install['event'] = serendipity_plugin_api::enum_plugin_classes(true);
                     $install['sidebar'] = serendipity_plugin_api::enum_plugin_classes(false);
                     foreach ($meth as $method) {
                         echo "LISTING: {$method}\n-------------------\n";
                         foreach ($install[$method] as $class_data) {
                             $pluginFile = serendipity_plugin_api::probePlugin($class_data['name'], $class_data['classname'], $class_data['pluginPath']);
                             $plugin = serendipity_plugin_api::getPluginInfo($pluginFile, $class_data, $method);
                             if (is_object($plugin)) {
                                 // Object is returned when a plugin could not be cached.
                                 $bag = new serendipity_property_bag();
                                 $plugin->introspect($bag);
                                 // If a foreign plugin is upgradable, keep the new version number.
                                 if (isset($avail[$method][$class_data['name']])) {
                                     $class_data['upgrade_version'] = $avail[$method][$class_data['name']]['upgrade_version'];
                                 }
                                 $props = serendipity_plugin_api::setPluginInfo($plugin, $pluginFile, $bag, $class_data, 'local', $avail[$method]);
                             } elseif (is_array($plugin)) {
                                 // Array is returned if a plugin could be fetched from info cache
                                 $props = $plugin;
                             } else {
                                 $props = false;
                             }
                             if (is_array($props)) {
                                 #print_r($props);
                                 if (version_compare($props['version'], $props['upgrade_version'], '<')) {
                                     echo "UPGRADE: " . $class_data['name'] . " -- " . $props['upgrade_version'] . "\n";
                                 } else {
                                     echo "OK: " . $class_data['name'] . " -- " . $props['version'] . "\n";
                                 }
                             } else {
                                 echo "ERROR: " . $class_data['true_name'] . "\n";
                             }
                         }
                     }
                 }
                 break;
             case 'backend_pluginlisting_header':
                 if (serendipity_db_bool($this->get_config('enable_plugins'))) {
                     echo '<div id="upgrade_notice" class="clearfix">';
                     echo '    <a id="upgrade_sidebar" class="button_link" href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew&amp;serendipity[only_group]=UPGRADE">' . PLUGIN_EVENT_SPARTACUS_CHECK_SIDEBAR . '</a>';
                     echo '    <a id="upgrade_event" class="button_link" href="?serendipity[adminModule]=plugins&amp;serendipity[adminAction]=addnew&amp;serendipity[only_group]=UPGRADE&amp;serendipity[type]=event">' . PLUGIN_EVENT_SPARTACUS_CHECK_EVENT . '</a> ';
                     echo '</div>';
                 }
                 break;
             case 'backend_templates_fetchlist':
                 if (serendipity_db_bool($this->get_config('enable_themes'))) {
                     $eventData = $this->buildTemplateList($this->fetchOnline('template', true), 'template');
                 }
                 break;
             case 'backend_templates_fetchtemplate':
                 if (serendipity_db_bool($this->get_config('enable_themes'))) {
                     if (!empty($eventData['GET']['spartacus_fetch'])) {
                         $this->download($this->fetchOnline('template', true), $eventData['GET']['theme'], 'templates');
                     }
                 }
                 break;
             case 'backend_plugins_fetchlist':
                 if (serendipity_db_bool($this->get_config('enable_plugins'))) {
                     $type = isset($serendipity['GET']['type']) && !empty($serendipity['GET']['type']) ? $serendipity['GET']['type'] : 'sidebar';
                     $eventData = array('pluginstack' => $this->buildList($this->fetchOnline($type), $type), 'errorstack' => array(), 'upgradeURI' => '&amp;serendipity[spartacus_upgrade]=true', 'baseURI' => '&amp;serendipity[spartacus_fetch]=' . $type);
                 }
                 break;
             case 'backend_plugins_fetchplugin':
                 if (serendipity_db_bool($this->get_config('enable_plugins'))) {
                     if (!empty($eventData['GET']['spartacus_fetch'])) {
                         $baseDir = $this->download($this->fetchOnline($eventData['GET']['spartacus_fetch'], true), $eventData['GET']['install_plugin']);
                         if ($baseDir === false) {
                             $eventData['install'] = false;
                         } elseif (!empty($baseDir)) {
                             $eventData['GET']['pluginPath'] = $baseDir;
                         } else {
                             $eventData['GET']['pluginPath'] = $eventData['GET']['install_plugin'];
                         }
                         if ($eventData['GET']['spartacus_upgrade']) {
                             $eventData['install'] = false;
                         }
                     }
                 }
                 break;
             case 'backend_directory_create':
                 if (serendipity_db_bool($this->get_config('use_ftp')) && !is_dir($eventData)) {
                     return $this->make_dir_via_ftp($eventData);
                 }
                 break;
             default:
                 return false;
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #4
0
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         switch ($event) {
             case 'cronjob':
                 if ($this->get_config('cronjob') == $eventData) {
                     serendipity_event_cronjob::log('Facebook', 'plugin');
                     $this->fetchFacebook();
                 }
                 return true;
                 break;
             case 'external_plugin':
                 $parts = explode('_', $eventData);
                 if ($parts[0] == 'facebookcomments') {
                     $this->fetchFacebook();
                 }
                 return true;
                 break;
             case 'frontend_header':
                 if (!isset($GLOBALS['entry'][0])) {
                     return true;
                 }
                 // Taken from: http://developers.facebook.com/docs/opengraph/
                 echo '<!--serendipity_event_facebook-->' . "\n";
                 echo '<meta property="og:title" content="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($GLOBALS['entry'][0]['title']) : htmlspecialchars($GLOBALS['entry'][0]['title'], ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n";
                 echo '<meta property="og:description" content="' . substr(strip_tags($GLOBALS['entry'][0]['body']), 0, 200) . '..." />' . "\n";
                 echo '<meta property="og:type" content="article" />' . "\n";
                 echo '<meta property="og:site_name" content="' . $serendipity['blogTitle'] . '" />' . "\n";
                 echo '<meta property="og:url" content="http' . ($_SERVER['HTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . (function_exists('serendipity_specialchars') ? serendipity_specialchars($_SERVER['REQUEST_URI']) : htmlspecialchars($_SERVER['REQUEST_URI'], ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n";
                 if (preg_match('@<img.*src=["\'](.+)["\']@imsU', $GLOBALS['entry'][0]['body'] . $GLOBALS['entry'][0]['extended'], $im)) {
                     if (preg_match('/^http/i', $im[1])) {
                         echo '<meta property="og:image" content="' . $im[1] . '" />' . "\n";
                     } else {
                         echo '<meta property="og:image" content="http' . ($_SERVER['HTTPS'] ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $im[1] . '" />' . "\n";
                     }
                 }
                 return true;
                 break;
                 // Print out image html for the user avatar into the frontend_display
             // Print out image html for the user avatar into the frontend_display
             case 'frontend_display':
                 if (!isset($eventData['comment'])) {
                     return true;
                 }
                 // Add facebook avatar to $eventData['comment']
                 if (preg_match('@^facebook_@i', $eventData['ctitle']) && preg_match('@^(.*)\\@@i', $eventData['email'], $fbid)) {
                     $eventData['comment'] = '
                     <div class="facebook_avatar serendipity_image_left">
                       <img src="https://graph.facebook.com/' . $fbid[1] . '/picture?type=square" alt="Facebook" />
                     </div><div class="facebook_comment">' . $eventData['comment'] . '</div>';
                     $eventData['comment_class'] .= ' facebook_avatar ';
                 }
                 return true;
                 break;
             default:
                 return false;
         }
     } else {
         return false;
     }
 }
コード例 #5
0
 function event_hook($event, &$bag, &$eventData, $addData = null)
 {
     global $serendipity;
     $hooks =& $bag->get('event_hooks');
     if (isset($hooks[$event])) {
         // Find out if we run this plugin externally or from the admin menu
         $adminmenu = $this->get_config('adminmenu');
         switch ($event) {
             case 'backend_sidebar_entries':
                 if (!$adminmenu) {
                     return false;
                 }
                 echo '<li class="serendipitySideBarMenuLink serendipitySideBarMenuEntryLinks"><a href="?serendipity[adminModule]=event_display&amp;serendipity[adminAction]=popfetcher">' . PLUGIN_MF_NAME . '</a></li>';
                 break;
             case 'external_plugin':
                 if ($adminmenu) {
                     return false;
                 }
                 $hidename = $this->get_config('hidename');
                 $events = explode('_', $eventData);
                 if ($events[0] != trim($hidename)) {
                     return false;
                 }
             case 'backend_sidebar_entries_event_display_popfetcher':
                 $this->workPopfetcher($eventData);
                 return true;
                 break;
             case 'cronjob':
                 if ($this->get_config('cronjob') == $eventData) {
                     serendipity_event_cronjob::log('Popfetcher', 'plugin');
                     $this->workPopfetcher($eventData);
                 }
                 return true;
                 break;
             default:
                 return false;
                 break;
         }
     } else {
         return false;
     }
 }