]> git.wh0rd.org Git - tt-rss.git/commitdiff
reduce the number of always included libraries
authorAndrew Dolgov <fox@fakecake.org>
Sun, 11 Dec 2011 19:10:51 +0000 (23:10 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Sun, 11 Dec 2011 19:10:51 +0000 (23:10 +0400)
backend.php
functions.php
modules/backend-rpc.php
modules/pref-users.php
register.php

index 077788dc7cf3822b6b90f042b27cbd9245d218d8..7bbec8c5a484d13e20596673ff0fecfc8ca02e51 100644 (file)
@@ -18,7 +18,6 @@
 
        require_once "functions.php";
        if ($op != "share") require_once "sessions.php";
-       require_once "modules/backend-rpc.php";
        require_once "sanity_check.php";
        require_once "config.php";
        require_once "db.php";
                5 => __("Power User"),
                10 => __("Administrator"));
 
-       
+
 
        $error = sanity_check($link);
 
 
        switch($op) { // Select action according to $op value.
                case "rpc":
-                       // Handle remote procedure calls.
+                       require_once "modules/backend-rpc.php";
                        handle_rpc_request($link);
                break; // rpc
 
                        $reply['runtime-info'] = make_runtime_info($link);
 
                        print json_encode($reply);
-
                break; // viewfeed
 
                case "pref-feeds":
index 29489b40fa11f7694db1af7ea8983f85f15361c5..974d02a5e4fc8d051b7874a73eb3f8fd682aa07b 100644 (file)
        }
 
        require_once 'db-prefs.php';
-       require_once 'errors.php';
        require_once 'version.php';
 
-       require_once 'lib/phpmailer/class.phpmailer.php';
-       require_once 'lib/sphinxapi.php';
-       require_once 'lib/tmhoauth/tmhOAuth.php';
-
-       //define('MAGPIE_USER_AGENT_EXT', ' (Tiny Tiny RSS/' . VERSION . ')');
        define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
 
        define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)');
 
        ini_set('user_agent', SELF_USER_AGENT);
 
-       require_once "lib/simplepie/simplepie.inc";
-       require_once "lib/magpierss/rss_fetch.inc";
-       require_once 'lib/magpierss/rss_utils.inc';
-       require_once 'lib/htmlpurifier/library/HTMLPurifier.auto.php';
        require_once 'lib/pubsubhubbub/publisher.php';
-       require_once 'lib/pubsubhubbub/subscriber.php';
-
-       $config = HTMLPurifier_Config::createDefault();
-
-       $allowed = "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4,s,object[classid|type|id|name|width|height|codebase],param[name|value],table,tr,td";
-
-       $config->set('HTML.SafeObject', true);
-       @$config->set('HTML', 'Allowed', $allowed);
-       $config->set('Output.FlashCompat', true);
-       $config->set('Attr.EnableID', true);
-       if (!defined('MOBILE_VERSION')) {
-               @$config->set('Cache', 'SerializerPath', CACHE_DIR . "/htmlpurifier");
-       } else {
-               @$config->set('Cache', 'SerializerPath', "../" . CACHE_DIR . "/htmlpurifier");
-       }
 
-       $purifier = new HTMLPurifier($config);
+       $purifier = false;
 
        $tz_offset = -1;
        $utc_tz = new DateTimeZone('UTC');
        function update_rss_feed_real($link, $feed, $ignore_daemon = false, $no_cache = false,
                $override_url = false) {
 
+               require_once "lib/simplepie/simplepie.inc";
+               require_once "lib/magpierss/rss_fetch.inc";
+               require_once 'lib/magpierss/rss_utils.inc';
+
                global $memcache;
 
                $debug_enabled = defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug'];
                                if ($feed_hub_url && function_exists('curl_init') &&
                                        !ini_get("open_basedir")) {
 
+                                       require_once 'lib/pubsubhubbub/subscriber.php';
+
                                        $callback_url = get_self_url_prefix() .
                                                "/public.php?op=pubsub&id=$feed";
 
                                        if (!$entry_content) $entry_content = $item["content"]["encoded"];
                                        if (!$entry_content) $entry_content = $item["content"];
 
+                                       if (is_array($entry_content)) $entry_content = $entry_content[0];
+
                                        // Magpie bugs are getting ridiculous
                                        if (trim($entry_content) == "Array") $entry_content = false;
 
        }
 
        function sanity_check($link) {
-
-               global $ERRORS;
+               require_once 'errors.php';
 
                $error_code = 0;
                $schema_version = get_schema_version($link, true);
 
                $res = trim($str); if (!$res) return '';
 
-//             if (get_pref($link, "STRIP_UNSAFE_TAGS", $owner) || $force_strip_tags) {
+               // create global Purifier object if needed
+               if (!$purifier) {
+                       require_once 'lib/htmlpurifier/library/HTMLPurifier.auto.php';
+
+                       $config = HTMLPurifier_Config::createDefault();
+
+                       $allowed = "p,a[href],i,em,b,strong,code,pre,blockquote,br,img[src|alt|title],ul,ol,li,h1,h2,h3,h4,s,object[classid|type|id|name|width|height|codebase],param[name|value],table,tr,td";
+
+                       $config->set('HTML.SafeObject', true);
+                       @$config->set('HTML', 'Allowed', $allowed);
+                       $config->set('Output.FlashCompat', true);
+                       $config->set('Attr.EnableID', true);
+                       if (!defined('MOBILE_VERSION')) {
+                               @$config->set('Cache', 'SerializerPath', CACHE_DIR . "/htmlpurifier");
+                       } else {
+                               @$config->set('Cache', 'SerializerPath', "../" . CACHE_DIR . "/htmlpurifier");
+                       }
+
+                       $purifier = new HTMLPurifier($config);
+               }
+
                $res = $purifier->purify($res);
-//             }
 
                if (get_pref($link, "STRIP_IMAGES", $owner)) {
                        $res = preg_replace('/<img[^>]+>/is', '', $res);
         */
        function send_headlines_digests($link, $limit = 100) {
 
+               require_once 'lib/phpmailer/class.phpmailer.php';
+
                if (!DIGEST_ENABLE) return false;
 
                $user_limit = DIGEST_EMAIL_LIMIT;
        }
 
        function sphinx_search($query, $offset = 0, $limit = 30) {
+               require_once 'lib/sphinxapi.php';
+
                $sphinxClient = new SphinxClient();
 
                $sphinxClient->SetServer('localhost', 9312);
 
 
        function fetch_twitter_rss($link, $url, $owner_uid) {
+
+               require_once 'lib/tmhoauth/tmhOAuth.php';
+
                $result = db_query($link, "SELECT twitter_oauth FROM ttrss_users
                        WHERE id = $owner_uid");
 
index d74c68464bf7efb280a8b926d8f15df1faa520e6..34adc8f914f13366ca09c0d0502d298237daa9b5 100644 (file)
                if ($subop == "sendEmail") {
                        $secretkey = $_REQUEST['secretkey'];
 
+                       require_once 'lib/phpmailer/class.phpmailer.php';
+
                        $reply = array();
 
                        if (DIGEST_ENABLE && $_SESSION['email_secretkey'] &&
index 984b2c55bdaa19a468748f707c442199f12e9a57..7be4eb437b952ce331658bf3e51931297fcc3d47 100644 (file)
                                $status_msg = format_notice(T_sprintf("Changed password of user <b>%s</b>
                                         to <b>%s</b>", $login, $tmp_user_pwd));
 
+                               require_once 'lib/phpmailer/class.phpmailer.php';
+
                                if ($email) {
                                        $status_msg += format_notice(T_sprintf("Notifying <b>%s</b>.", $email));
 
index 19fce711394f9367bdee97dffe7d23735fd0109a..cc453c0f28714170e4a22acde67f0b0584c5657d 100644 (file)
@@ -4,6 +4,8 @@
        // 1) templates/register_notice.txt - displayed above the registration form
        // 2) register_expire_do.php - contains user expiration queries when necessary
 
+       require_once 'lib/phpmailer/class.phpmailer.php';
+
        $action = $_REQUEST["action"];
 
        require_once "functions.php";