Skip to content

Commit

Permalink
Merge pull request #4 from pi-engine/master
Browse files Browse the repository at this point in the history
Fixes issue for redirection bug
  • Loading branch information
krisxoofoo committed May 2, 2013
2 parents 9202177 + babb9ec commit 5980ebd
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions lib/Pi/Markup/Renderer/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Pi\Markup\Renderer;

use Pi;
use Pi\Markup\Parser\AbstractParser;
//use Pi\Security\Security;

Expand Down
8 changes: 4 additions & 4 deletions usr/module/system/src/Controller/Admin/MemberController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function indexAction()
*/
foreach ($users as $id => &$user) {
$user['role'] = $roleList[$user['role']];
$user['role_staff'] = $roleList[$user['role_staff']];
$user['role_staff'] = isset($user['role_staff']) ? $roleList[$user['role_staff']] : '';
}

$paginator = Paginator::factory(intval($count));
Expand All @@ -136,7 +136,7 @@ public function indexAction()
$title = __('Member list');
$this->view()->assign('title', $title);
$this->view()->assign('users', $users);
$this->view()->assign('role', $role);
//$this->view()->assign('role', $role);
$this->view()->assign('roles', $roles);
}

Expand All @@ -148,7 +148,7 @@ public function roleAction()
return;
}

$active = $this->params('active', null);
//$active = $this->params('active', null);
$page = $this->params('p', 1);
$limit = 50;
$offset = (int) ($page - 1) * $limit;
Expand Down Expand Up @@ -211,7 +211,7 @@ public function roleAction()

foreach ($users as $id => &$user) {
$user['role'] = $roleList[$user['role']];
$user['role_staff'] = $roleList[$user['role_staff']];
$user['role_staff'] = isset($user['role_staff']) ? $roleList[$user['role_staff']] : '';
}
}

Expand Down
10 changes: 7 additions & 3 deletions usr/module/system/src/Controller/Front/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ public function indexAction()

// Display login form
$form = $this->getForm();
$redirect = $this->params('redirect') ?: $this->request->getServer('HTTP_REFERER');
if ($redirect) {
$form->setData(array('redirect' => urlencode($redirect)));
$redirect = $this->params('redirect');
if (null === $redirect) {
$redirect = $this->request->getServer('HTTP_REFERER');
}
if (null !== $redirect) {
$redirect = $redirect ? urlencode($redirect) : '';
$form->setData(array('redirect' => $redirect));
}
$this->renderForm($form);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function indexAction()
{
$id = $this->params('id');
if (!$id) {
$this->redirect()->toRoute('user');
$this->redirect()->toRoute('user', array('controller' => 'account'));
return;
}
if (is_numeric($id)) {
Expand Down
6 changes: 6 additions & 0 deletions usr/module/system/src/Controller/Front/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public function indexAction()
return;
}

// If already logged in
if (Pi::service('authentication')->hasIdentity()) {
$this->redirect()->toRoute('user', array('controller' => 'account'));
return;
}

// Display register form
$form = $this->getForm();
$this->renderForm($form);
Expand Down
9 changes: 7 additions & 2 deletions usr/module/system/src/Form/LoginForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,17 @@ public function init()
'type' => 'csrf',
));

$redirect = Pi::engine()->application()->getRequest()->getServer('HTTP_REFERER') ?: Pi::engine()->application()->getRequest()->getRequestUri();
$request = Pi::engine()->application()->getRequest();
$redirect = $request->getQuery('redirect');
if (null === $redirect) {
$redirect = $request->getServer('HTTP_REFERER') ?: $request->getRequestUri();
}
$redirect = $redirect ? urlencode($redirect) : '';
$this->add(array(
'name' => 'redirect',
'type' => 'hidden',
'attributes' => array(
'value' => urlencode($redirect),
'value' => $redirect,
),
));

Expand Down
2 changes: 1 addition & 1 deletion usr/module/system/template/admin/member-index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<form method='GET'>
<?php _e('Select a role: '); ?><select id='role-selection' list-url='<?php echo $this->url('admin', array('controller' => 'member', 'action' => 'role', 'role' => '')) ?>'>
<?php foreach ($roles as $roleName => $roleTitle) { ?>
<option value="<?php echo $roleName; ?>"<?php if ($role == $roleName) { echo ' selected'; } ?>><?php echo $this->escape($roleTitle); ?></option>
<option value="<?php echo $roleName; ?>"<?php if (isset($role) && $role == $roleName) { echo ' selected'; } ?>><?php echo $this->escape($roleTitle); ?></option>
<?php } ?>
</select>
</form>
Expand Down
2 changes: 1 addition & 1 deletion www/setup/src/Controller/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function init()

$vars = $this->wizard->getPersist('siteconfig');
if (empty($vars)) {
$vars['adminname'] = 'root';
$vars['adminname'] = 'admin';
$hostname = preg_replace('/^www\./i', '', $_SERVER['SERVER_NAME']);
if (false === strpos($hostname, '.')) {
$hostname .= '.com';
Expand Down
14 changes: 4 additions & 10 deletions www/setup/src/Controller/Finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

namespace Pi\Setup\Controller;

use Pi;
use RecursiveIteratorIterator;
use RecursiveDirectoryIterator;
Expand All @@ -35,7 +36,6 @@ public function indexAction()
{
$wizard = $this->wizard;
$vars = $wizard->getPersist('paths');
//$this->normalizeHost($vars);
$configs = array();

/**#@+
Expand All @@ -50,12 +50,6 @@ public function indexAction()
}
}
$content = str_replace('%host%', $vars['config']['path'] . '/host.php', $content);
/*
$content = preg_replace('/(define\()([\'"])(PI_PATH_LIB)\\2,\s*([\'"])(.*?)\\4\s*\)/', 'define(\'PI_PATH_LIB\', \'' . $vars['lib']['path'] . '\')', $content);
$content = preg_replace('/(define\()([\'"])(PI_PATH_WWW)\\2,\s*([\'"])(.*?)\\4\s*\)/', 'define(\'PI_PATH_WWW\', \'' . $vars['www']['path'] . '\')', $content);
$content = preg_replace('/(define\()([\'"])(PI_PATH_VAR)\\2,\s*([\'"])(.*?)\\4\s*\)/', 'define(\'PI_PATH_VAR\', \'' . $vars['var']['path'] . '\')', $content);
$content = preg_replace('/(define\()([\'"])(PI_PATH_HOST)\\2,\s*([\'"])(.*?)\\4\s*\)/', 'define(\'PI_PATH_HOST\', \'' . $vars['config']['path'] . '/host.php\')', $content);
*/
$configs[] = array('file' => $file, 'content' => $content);
/**#@-*/

Expand Down Expand Up @@ -99,16 +93,16 @@ public function indexAction()
$readPaths .= "</ul>";

$message = <<<'HTML'
<h2>Congratulatons! The system is set up successfully. <a href='../index.php'>Click to visit your website!</a></h2>
<h2>Congratulatons! The system is set up successfully. <a href='../index.php?redirect=0'>Click to visit your website!</a></h2>
<h3>Security advisory</h3>
<ol>For security considerations please make sure the following operations are done:
<li>Remove the installation folder <strong>%s</strong> from your server.</li>
<li>Remove the installation folder <strong>{www}/setup/</strong> from your server manually.</li>
<li>Set configuration directories and files to readonly: %s</li>
</ol>
<h3>Support</h3>
<p>Visit <a href='http://www.xoopsengine.org/' rel='external'>Pi Engine Development Site</a> in case you need any help.</p>
HTML;
$this->content = sprintf(_t($message), basename(dirname(__DIR__)), $readPaths);
$this->content = sprintf(_t($message), $readPaths);

$path = Pi::path('cache');
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
Expand Down

0 comments on commit 5980ebd

Please sign in to comment.