From: Evan Prodromou <evan@status.net> 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')) { - ?><p class="error">Config file "config.php" already exists.</p> - <?php + printf('<p class="error">Config file "config.php" already exists.</p>'); $pass = false; } @@@ -280,67 -243,54 +289,74 @@@ foreach ($reqs as $req) { if (!checkExtension($req)) { - ?><p class="error">Cannot load required extension: <code><?php echo $req; ?></code></p><?php - $pass = false; + printf('<p class="error">Cannot load required extension: <code>%s</code></p>', $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('<p class="error">Cannot find mysql or pgsql extension. You need one or the other.'); + $pass = false; + } + + if (!is_writable(INSTALLDIR)) { + printf('<p class="error">Cannot write config file to: <code>%s</code></p>', INSTALLDIR); + printf('<p>On your server, try this command: <code>chmod a+w %s</code>', 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('<p class="error">Cannot write to %s directory: <code>%s</code></p>', $fileSubdir, $fileFullPath); + printf('<p>On your server, try this command: <code>chmod a+w %s</code></p>', $fileFullPath); + $pass = false; } } - if (!checkExtension('pgsql') && !checkExtension('mysql')) { - ?><p class="error">Cannot find mysql or pgsql extension. You need one or the other: <code><?php echo $req; ?></code></p><?php - $pass = false; - } - - if (!is_writable(INSTALLDIR)) { - ?><p class="error">Cannot write config file to: <code><?php echo INSTALLDIR; ?></code></p> - <p>On your server, try this command: <code>chmod a+w <?php echo INSTALLDIR; ?></code> - <?php - $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)) { - ?><p class="error">Cannot write <?php echo $fileSubdir; ?> directory: <code><?php echo $fileFullPath; ?></code></p> - <p>On your server, try this command: <code>chmod a+w <?php echo $fileFullPath; ?></code></p> - <?php - $pass = false; - } - } - - return $pass; + + return $pass; } +/** + * Checks if a php extension is both installed and loaded + * + * @param string $name of extension to check + * + * @return boolean whether extension is installed and loaded + */ function checkExtension($name) { - if (!extension_loaded($name)) { - if (!@dl($name.'.so')) { - return false; - } + if (extension_loaded($name)) { + return true; + } elseif (function_exists('dl') && ini_get('enable_dl') && !ini_get('safe_mode')) { + // dl will throw a fatal error if it's disabled or we're in safe mode. + // More fun, it may not even exist under some SAPIs in 5.3.0 or later... + $soname = $name . '.' . PHP_SHLIB_SUFFIX; + if (PHP_SHLIB_SUFFIX == 'dll') { + $soname = "php_" . $soname; + } + return @dl($soname); + } else { + return false; } - return true; } +/** + * Show list of libraries + * + * @return void + */ function showLibs() { global $external_libraries; @@@ -388,11 -339,12 +404,11 @@@ E_O_T <h2>Installed Libraries</h2> <ul id="present_libraries"> E_O_T; - foreach($present_libraries as $library) - { + foreach ($present_libraries as $library) { echo '<li>'; - if ($library['url']) { - if(isset($library['url'])){ ++ if (isset($library['url'])) { echo '<a href=">'.$library['url'].'">'.htmlentities($library['name']).'</a>'; - }else{ + } else { echo htmlentities($library['name']); } echo '</li>'; 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; }