From: Evan Prodromou
Date: Wed, 23 Sep 2009 13:45:22 +0000 (-0400)
Subject: Merge branch '0.8.x' into 0.9.x
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8284b3cb82f4dec6e0f2bf74dea6e1a3bc7f4eac;p=quix0rs-gnu-social.git
Merge branch '0.8.x' into 0.9.x
Conflicts:
actions/requesttoken.php
classes/File.php
install.php
lib/noticeform.php
---
8284b3cb82f4dec6e0f2bf74dea6e1a3bc7f4eac
diff --cc index.php
index 8ff67d19d9,362ab3cd37..51e30f5782
--- a/index.php
+++ b/index.php
@@@ -45,11 -29,16 +45,17 @@@ $action = null
function getPath($req)
{
if ((common_config('site', 'fancy') || !array_key_exists('PATH_INFO', $_SERVER))
- && array_key_exists('p', $req)) {
+ && array_key_exists('p', $req)
+ ) {
return $req['p'];
} else if (array_key_exists('PATH_INFO', $_SERVER)) {
- return $_SERVER['PATH_INFO'];
+ $path = $_SERVER['PATH_INFO'];
+ $script = $_SERVER['SCRIPT_NAME'];
+ if (substr($path, 0, mb_strlen($script)) == $script) {
+ return substr($path, mb_strlen($script));
+ } else {
+ return $path;
+ }
} else {
return null;
}
diff --cc install.php
index 46248c7891,30dd34496b..c2ca7e1196
--- a/install.php
+++ b/install.php
@@@ -256,17 -214,22 +256,26 @@@ function haveExternalLibrary($external_
return true;
}
+ // Attempt to include a PHP file and report if it worked, while
+ // suppressing the annoying warning messages on failure.
+ function haveIncludeFile($filename) {
+ $old = error_reporting(error_reporting() & ~E_WARNING);
+ $ok = include_once($filename);
+ error_reporting($old);
+ return $ok;
+ }
+
+/**
+ * Check if all is ready for installation
+ *
+ * @return void
+ */
function checkPrereqs()
{
- $pass = true;
+ $pass = true;
if (file_exists(INSTALLDIR.'/config.php')) {
- ?>Config file "config.php" already exists.
- Config file "config.php" already exists.
');
$pass = false;
}
@@@ -280,67 -243,54 +289,74 @@@
foreach ($reqs as $req) {
if (!checkExtension($req)) {
- ?>Cannot load required extension:
Cannot load required extension: %s
', $req);
+ $pass = false;
+ }
+ }
+ // Make sure we have at least one database module available
+ global $dbModules;
+ $missingExtensions = array();
+ foreach ($dbModules as $type => $info) {
+ if (!checkExtension($info['check_module'])) {
+ $missingExtensions[] = $info['check_module'];
+ }
+ }
+
+ if (count($missingExtensions) == count($dbModules)) {
+ $req = implode(', ', $missingExtensions);
+ printf('Cannot find mysql or pgsql extension. You need one or the other.');
+ $pass = false;
+ }
+
+ if (!is_writable(INSTALLDIR)) {
+ printf('
Cannot write config file to: %s
', INSTALLDIR);
+ printf('On your server, try this command: chmod a+w %s
', INSTALLDIR);
+ $pass = false;
+ }
+
+ // Check the subdirs used for file uploads
+ $fileSubdirs = array('avatar', 'background', 'file');
+ foreach ($fileSubdirs as $fileSubdir) {
+ $fileFullPath = INSTALLDIR."/$fileSubdir/";
+ if (!is_writable($fileFullPath)) {
+ printf('
Cannot write to %s directory: %s
', $fileSubdir, $fileFullPath);
+ printf('On your server, try this command: chmod a+w %s
', $fileFullPath);
+ $pass = false;
}
}
- if (!checkExtension('pgsql') && !checkExtension('mysql')) {
- ?>Cannot find mysql or pgsql extension. You need one or the other:
Cannot write config file to:
- On your server, try this command: chmod a+w
-
Cannot write directory:
- On your server, try this command: chmod a+w
- Installed Libraries
E_O_T;
- foreach($present_libraries as $library)
- {
+ foreach ($present_libraries as $library) {
echo '- ';
- if ($library['url']) {
- if(isset($library['url'])){
++ if (isset($library['url'])) {
echo ''.htmlentities($library['name']).'';
- }else{
+ } else {
echo htmlentities($library['name']);
}
echo '
';
diff --cc lib/util.php
index 441dcf68e3,b831859e99..56753debe0
--- a/lib/util.php
+++ b/lib/util.php
@@@ -1379,23 -1363,58 +1380,20 @@@ function common_shorten_url($long_url
} else {
$svc = $user->urlshorteningservice;
}
-
- $curlh = curl_init();
- curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
- curl_setopt($curlh, CURLOPT_USERAGENT, 'StatusNet');
- curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
-
- switch($svc) {
- case 'ur1.ca':
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url_service = new LilUrl;
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case '2tu.us':
- $short_url_service = new TightUrl;
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case 'ptiturl.com':
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url_service = new PtitUrl;
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case 'bit.ly':
- curl_setopt($curlh, CURLOPT_URL, 'http://bit.ly/api?method=shorten&long_url='.urlencode($long_url));
- $short_url = current(json_decode(curl_exec($curlh))->results)->hashUrl;
- break;
-
- case 'is.gd':
- curl_setopt($curlh, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'snipr.com':
- curl_setopt($curlh, CURLOPT_URL, 'http://snipr.com/site/snip?r=simple&link='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'metamark.net':
- curl_setopt($curlh, CURLOPT_URL, 'http://metamark.net/api/rest/simple?long_url='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'tinyurl.com':
- curl_setopt($curlh, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- default:
- $short_url = false;
+ global $_shorteners;
+ if (!isset($_shorteners[$svc])) {
+ //the user selected service doesn't exist, so default to ur1.ca
+ $svc = 'ur1.ca';
+ }
+ if (!isset($_shorteners[$svc])) {
+ // no shortener plugins installed.
+ return $long_url;
}
- curl_close($curlh);
+ $reflectionObj = new ReflectionClass($_shorteners[$svc]['callInfo'][0]);
+ $short_url_service = $reflectionObj->newInstanceArgs($_shorteners[$svc]['callInfo'][1]);
+ $short_url = $short_url_service->shorten($long_url);
- if(substr($short_url,0,7)=='http://'){
- $short_url = substr($short_url,7);
- }
return $short_url;
}