From: Andrew Dolgov Date: Thu, 17 Mar 2011 16:16:44 +0000 (+0300) Subject: use CURL when it is available, remove option USE_CURL X-Git-Tag: 1.5.2~16 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=014d3ad823d653eed424ac95cac454b5ca6d06f3;p=tt-rss.git use CURL when it is available, remove option USE_CURL --- diff --git a/config.php-dist b/config.php-dist index bd61c9bf..b4d09f43 100644 --- a/config.php-dist +++ b/config.php-dist @@ -71,9 +71,6 @@ define('CHECK_FOR_NEW_VERSION', true); // Check for new versions of tt-rss automatically. - define('USE_CURL', false); - // Use CURL to fetch remote data instead of PHP built-in fopen() - define('DIGEST_ENABLE', true); // Global option to enable daily digests. Also toggles the ability of users // to forward articles by email. diff --git a/functions.php b/functions.php index 9090d8cf..c9a8c868 100644 --- a/functions.php +++ b/functions.php @@ -374,7 +374,7 @@ $login = urlencode($login); $pass = urlencode($pass); - if (USE_CURL) { + if (function_exists('curl_init')) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); @@ -453,62 +453,9 @@ if (!$favicon_url) $favicon_url = rewrite_relative_url($url, "/favicon.ico"); - // Run a test to see if what we have attempted to get actually exists. - if(USE_CURL || url_validate($favicon_url)) { - return $favicon_url; - } else { - return false; - } + return $favicon_url; } // function get_favicon_url - /** - * Check if a link is a valid and working URL. - * - * @param mixed $link A URL to check - * @access public - * @return boolean True if the URL is valid, false otherwise. - */ - function url_validate($link) { - - $url_parts = @parse_url($link); - - if ( empty( $url_parts["host"] ) ) - return false; - - if ( !empty( $url_parts["path"] ) ) { - $documentpath = $url_parts["path"]; - } else { - $documentpath = "/"; - } - - if ( !empty( $url_parts["query"] ) ) - $documentpath .= "?" . $url_parts["query"]; - - $host = $url_parts["host"]; - $port = $url_parts["port"]; - - if ( empty($port) ) - $port = "80"; - - $socket = @fsockopen( $host, $port, $errno, $errstr, 30 ); - - if ( !$socket ) - return false; - - fwrite ($socket, "HEAD ".$documentpath." HTTP/1.0\r\nHost: $host\r\n\r\n"); - - $http_response = fgets( $socket, 22 ); - - $responses = "/(200 OK)|(30[123])/"; - if ( preg_match($responses, $http_response) ) { - fclose($socket); - return true; - } else { - return false; - } - - } // function url_validate - function check_feed_favicon($site_url, $feed, $link) { $favicon_url = get_favicon_url($site_url); @@ -775,9 +722,7 @@ $icon_url = substr($icon_url, 0, 250); if ($icon_url && $orig_icon_url != $icon_url) { - if (USE_CURL || url_validate($icon_url)) { - db_query($link, "UPDATE ttrss_feeds SET icon_url = '$icon_url' WHERE id = '$feed'"); - } + db_query($link, "UPDATE ttrss_feeds SET icon_url = '$icon_url' WHERE id = '$feed'"); } if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) { diff --git a/sanity_check.php b/sanity_check.php index e6e58b2a..c9d0fe92 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -5,7 +5,7 @@ define('SCHEMA_VERSION', 81); if (!file_exists("config.php")) { - print "Fatal Error: You forgot to copy + print "Fatal Error: You forgot to copy config.php-dist to config.php and edit it.\n"; exit; } @@ -41,7 +41,7 @@ if (file_exists("xml-export.php") || file_exists("xml-import.php")) { print "Fatal Error: XML Import/Export tools (xml-export.php - and xml-import.php) could be used maliciously. Please remove them + and xml-import.php) could be used maliciously. Please remove them from your TT-RSS instance.\n"; exit; } @@ -52,12 +52,6 @@ exit; } - if (USE_CURL && ! function_exists("curl_init")) { - print "Fatal Error: You have enabled USE_CURL, but your PHP - doesn't seem to support CURL functions."; - exit; - } - if (!defined('SESSION_EXPIRE_TIME')) { $err_msg = "config: SESSION_EXPIRE_TIME is undefined"; } @@ -89,7 +83,7 @@ if ($link) { $result = db_query($link, "SELECT id FROM ttrss_users WHERE id = 1"); - if (db_num_rows($result) != 1) { + if (db_num_rows($result) != 1) { $err_msg = "config: SINGLE_USER_MODE is enabled but default admin account (UID=1) is not found."; } } @@ -114,7 +108,7 @@ if (!defined('DEFAULT_UPDATE_METHOD') || (DEFAULT_UPDATE_METHOD != 0 && DEFAULT_UPDATE_METHOD != 1)) { - $err_msg = "config: DEFAULT_UPDATE_METHOD should be either 0 or 1."; + $err_msg = "config: DEFAULT_UPDATE_METHOD should be either 0 or 1."; } if (!is_writable(ICONS_DIR)) { @@ -149,10 +143,6 @@ $err_msg = "php.ini: Safe mode is not supported. If you wish to continue, remove this test from sanity_check.php and proceeed at your own risk. Please note that your bug reports will not be accepted or reviewed."; } - if (defined('USE_CURL_FOR_ICONS')) { - $err_msg = "config: USE_CURL_FOR_ICONS has been renamed to USE_CURL."; - } - if ($err_msg) { print "Fatal Error: $err_msg\n"; exit; diff --git a/sanity_config.php b/sanity_config.php index 67e373a6..a6bdb64c 100644 --- a/sanity_config.php +++ b/sanity_config.php @@ -1,3 +1,3 @@ - +$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'MAGPIE_FETCH_TIME_OUT', 'MAGPIE_CACHE_DIR', 'MAGPIE_CACHE_AGE', 'ICONS_DIR', 'ICONS_URL', 'SINGLE_USER_MODE', 'TMP_DIRECTORY', 'ENABLE_UPDATE_DAEMON', 'DAEMON_SLEEP_INTERVAL', 'DATABASE_BACKED_SESSIONS', 'SESSION_CHECK_ADDRESS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'DAEMON_UPDATE_LOGIN_LIMIT', 'CHECK_FOR_NEW_VERSION', 'DIGEST_ENABLE', 'DIGEST_EMAIL_LIMIT', 'DAEMON_SENDS_DIGESTS', 'ENABLE_TRANSLATIONS', 'MYSQL_CHARSET', 'DEFAULT_UPDATE_METHOD', 'SIMPLEPIE_CACHE_DIR', 'SIMPLEPIE_CACHE_IMAGES', 'COUNTERS_MAX_AGE', 'DIGEST_FROM_NAME', 'DIGEST_FROM_ADDRESS', 'DIGEST_SUBJECT', 'DIGEST_SMTP_HOST', 'DIGEST_SMTP_LOGIN', 'DIGEST_SMTP_PASSWORD', 'DAEMON_FEED_LIMIT', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'LOCK_DIRECTORY', 'ENABLE_GZIP_OUTPUT', 'PHP_EXECUTABLE', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'FEEDBACK_URL', 'FORCE_ARTICLE_PURGE', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_TWEET_BUTTON', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'CONFIG_VERSION'); ?>