Permalink
Browse files

Improve application URL usage

* Use Utils::getApplicationURL everywhere
* Correctly handle spaces site_root_path
  • Loading branch information...
1 parent 8ab465d commit e982c8419fe455ac92235b3cd2de9288e4613376 @ginatrapani ginatrapani committed Dec 18, 2012
View
9 tests/TestOfInstallerController.php
@@ -115,10 +115,10 @@ public function testFreshInstallStep1ReqsNotMet() {
$this->assertTrue(isset($controller));
$result = $controller->go();
+ $this->debug($result);
//system requirements have not been met
$this->assertNoPattern('/Your system has everything it needs to run ThinkUp./', $result);
- $this->assertPattern('/Your web server isn\'t set up to run ThinkUp. Please fix the problems below and try '.
- 'installation again./', $result);
+ $this->assertPattern('/Your web server isn\'t set up to run ThinkUp./', $result);
$this->assertPattern('/ThinkUp needs the /', $result);
//make sure install did not auto-progress to step 2 b/c
@@ -564,7 +564,10 @@ public function testFreshInstallStep3SuccessfulInstall() {
$controller = new InstallerController(true);
$this->assertTrue(isset($controller));
$result = $controller->go();
- $this->assertPattern('/ThinkUp has been installed successfully./', $result);
+ $this->debug($result);
+ $this->assertPattern('/ThinkUp has been
+installed successfully. Check your email account; an account activation
+message has been sent./', $result);
$this->restoreConfigFile();
//echo $result;
}
View
4 tests/TestOfRegisterController.php
@@ -315,7 +315,7 @@ public function testSpaceInHostName() {
$email = Mailer::getLastMail();
$this->debug("Email contents: " . $email);
- $this->assertPattern('/test%20url%20with%20spaces/', $email, 'Spaces found in activation URL.');
+ $this->assertPattern('/test\+url\+with\+spaces/', $email, 'Spaces found in activation URL.');
}
public function testSlashesInHostName() {
@@ -338,7 +338,7 @@ public function testSlashesInHostName() {
$email = Mailer::getLastMail();
$this->debug("Email contents: " . $email);
- $this->assertPattern('/test%20url%20with%20spaces\/and\/a%20few\/slashes\/too/', $email,
+ $this->assertPattern('/test\+url\+with\+spaces\/and\/a\+few\/slashes\/too/', $email,
'Spaces properly escaped;slashes are not');
}
View
7 tests/TestOfUtils.php
@@ -273,5 +273,12 @@ public function testGetApplicationURL() {
$utils_url = Utils::getApplicationURL(true);
$expected_url = 'http://127.0.0.1/my/path/to/thinkup/';
$this->assertEqual($utils_url, $expected_url);
+
+ //with spaces in site_rooth_path
+ $_SERVER['HTTP_HOST'] = "localhost";
+ $cfg->setValue('site_root_path', '/my/path and this space/to/thinkup/');
+ $utils_url = Utils::getApplicationURL(false);
+ $expected_url = 'http://localhost/my/path+and+this+space/to/thinkup/';
+ $this->assertEqual($utils_url, $expected_url);
}
}
View
2 webapp/_lib/class.Utils.php
@@ -304,6 +304,8 @@ public static function getApplicationURL($replace_localhost_with_ip = false) {
$server = ($server == 'localhost')?'127.0.0.1':$server;
}
$site_root_path = Config::getInstance()->getValue('site_root_path');
+ //URLencode everything except spaces in site_root_path
+ $site_root_path = str_replace('%2f', '/', strtolower(urlencode($site_root_path)));
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80') { //non-standard port
if (isset($_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] == '443') { //account for standard https port
$port = '';
View
1 webapp/_lib/controller/class.AccountConfigurationController.php
@@ -109,7 +109,6 @@ public function authControl() {
$invite_added = $invite_dao->addInviteCode( $invite_code ) ;
if ($invite_added == 1) { //invite generated and inserted
- $server = $_SERVER['HTTP_HOST'];
$invite_link = Utils::getApplicationURL().'session/register.php?code='. $invite_code;
$this->addSuccessMessage("Invitation created!<br />Copy this link and send it to someone you want to ".
'invite to register on your ThinkUp installation.<br /><a href="'.$invite_link.'" id="clippy_12345">'.
View
2 webapp/_lib/controller/class.ForgotPasswordController.php
@@ -46,7 +46,7 @@ public function control() {
$config = Config::getInstance();
$es->assign('apptitle', $config->getValue('app_title_prefix')."ThinkUp" );
$es->assign('recovery_url', "session/reset.php?token=$token");
- $es->assign('server', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost');
+ $es->assign('application_url', Utils::getApplicationURL($false));
$es->assign('site_root_path', $config->getValue('site_root_path') );
$message = $es->fetch('_email.forgotpassword.tpl');
View
2 webapp/_lib/controller/class.InstallerController.php
@@ -373,7 +373,7 @@ private function step3() {
'cache_pages'=>false);
$email_view = new ViewManager($cfg_array);
$email_view->caching=false;
- $email_view->assign('server', $_SERVER['HTTP_HOST'] );
+ $email_view->assign('application_url', Utils::getApplicationURL(false) );
$email_view->assign('email', urlencode($email) );
$email_view->assign('activ_code', $activation_code );
$message = $email_view->fetch('_email.registration.tpl');
View
3 webapp/_lib/controller/class.RegisterController.php
@@ -127,8 +127,7 @@ public function control(){
if ($activation_code != false) {
$es = new ViewManager();
$es->caching=false;
- $server = $_SERVER['HTTP_HOST'];
- $es->assign('server', $server );
+ $es->assign('application_url', Utils::getApplicationURL(false) );
$es->assign('email', urlencode($_POST['email']) );
$es->assign('activ_code', $activation_code );
$message = $es->fetch('_email.registration.tpl');
View
3 webapp/_lib/controller/class.UpgradeDatabaseController.php
@@ -332,8 +332,7 @@ public static function generateUpgradeToken() {
$to = join(',', $tos);
$upgrade_email = new ViewManager();
$upgrade_email->caching=false;
- $server = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; //supress test weirdness
- $upgrade_email->assign('server', $server );
+ $upgrade_email->assign('application_url', Utils::getApplicationURL(false) );
$upgrade_email->assign('token', $md5_token );
$message = $upgrade_email->fetch('_email.upgradetoken.tpl');
$config = Config::getInstance();
View
4 webapp/_lib/view/_email.forgotpassword.tpl
@@ -1,7 +1,7 @@
Hi there!
Looks like you forgot your {$apptitle|filter_xss} password. Go to this URL to reset it:
-http{if $smarty.server.HTTPS}s{/if}://{$server}{$site_root_path}{$recovery_url}
+{$application_url}{$recovery_url}
Or, if you remembered it, you can log in here and disregard this email:
-http{if $smarty.server.HTTPS}s{/if}://{$server}{$site_root_path}session/login.php
+{$application_url}session/login.php
View
2 webapp/_lib/view/_email.registration.tpl
@@ -1,5 +1,5 @@
Click on the link below to activate your new account on {$app_title|filter_xss}:
-http{if $smarty.server.HTTPS}s{/if}://{$server}{$site_root_path|escape:'urlpathinfo'}session/activate.php?usr={$email}&code={$activ_code}
+{$application_url}session/activate.php?usr={$email}&code={$activ_code}
Thanks for registering!
View
4 webapp/_lib/view/_email.upgradetoken.tpl
@@ -1,6 +1,6 @@
Looks like you're upgrading your ThinkUp installation. Great! To complete the process, click on this link to apply new database updates:
-http{if $smarty.server.HTTPS}s{/if}://{$server}{$site_root_path}install/upgrade-database.php?upgrade_token={$token}
+{$application_url}install/upgrade-database.php?upgrade_token={$token}
If you have trouble, get in touch with the ThinkUp community on the mailing list:
@@ -11,4 +11,4 @@ Or drop by our IRC channel #thinkup on irc.freenode.net.
Thanks for using ThinkUp.
-http://thinkupapp.com
+http://thinkup.com

0 comments on commit e982c84

Please sign in to comment.