Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uniformisation de la récupération des URLs de site #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lodel/scripts/class.errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public function __construct($errstr, $errno, $errfile, $errline, $http_code = 50
{
$sujet = "[BUG] LODEL ".C::get('version', 'cfg')." - ".C::get('site', 'cfg');
$contenu = "Erreur sur la page ";
if (isset($_SERVER['HTTP_HOST']))
$contenu .= "http://".$_SERVER['HTTP_HOST'].($_SERVER['SERVER_PORT'] != 80 ? ":". $_SERVER['SERVER_PORT'] : '').$_SERVER['REQUEST_URI']." (' ".$_SERVER["REMOTE_ADDR"]." ')\n";
if (C::get('siteurl'))
$contenu .= dirname(C::get('siteurl')) . $_SERVER['REQUEST_URI'];

$contenu .= (E_USER_ERROR == $this->code || E_USER_NOTICE == $this->code || E_USER_WARNING == $this->code) ? '' : 'PHP ';
$contenu .= "Error ".(isset(self::$type[$this->code]) ? "(".self::$type[$this->code].")" : '')." in file '".$this->file."' on line ".$this->line." : ".$this->message;
@mail(C::get('contactbug', 'cfg'), $sujet, $contenu);
Expand Down
6 changes: 3 additions & 3 deletions lodel/scripts/class.siteManage.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ function manageSite()
C::set('path', '/'. $name);
}
}

if (!C::get('url')) {
C::set('url', 'http://'. $_SERVER['SERVER_NAME']. ($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != "80" ? ':'. $_SERVER['SERVER_PORT'] : ""). preg_replace("/\blodeladmin\/.*/", '', $_SERVER['REQUEST_URI']). substr(C::get('path'), 1));
C::set('url', dirname(C::get('currenturl'), 2) . C::get('path'));
}

if (C::get('reinstall')) {
$status = -32;
}
Expand Down
3 changes: 2 additions & 1 deletion lodel/scripts/context.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ private function __construct(array &$cfg)
self::$filter = null;
self::$_cfg = $cfg; // set the config vars
self::$_cfg['https'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? true : false);
self::$_cfg['base_url'] = isset($_SERVER['SERVER_NAME']) ? "${_SERVER['REQUEST_SCHEME']}://${_SERVER['SERVER_NAME']}" . (!in_array($_SERVER['SERVER_PORT'], ['80', '443']) ? $_SERVER['SERVER_PORT'] : '') : '';
$GLOBALS['tp'] = $GLOBALS['tableprefix'] = $cfg['tableprefix'];
defined('SITEROOT') || define('SITEROOT', '');
function_exists('cache_get') || include 'cachefunc.php';
Expand Down Expand Up @@ -325,7 +326,7 @@ function_exists('validfield') || include 'validfunc.php';
self::$_context['version'] = self::$_cfg['version'];
self::$_context['shareurl'] = self::$_cfg['shareurl'];
self::$_context['extensionscripts'] =self::$_cfg['extensionscripts'];
self::$_context['currenturl'] = isset($_SERVER['SERVER_NAME']) ? 'http'.(self::$_cfg['https'] ? 's' : '').'://'. $_SERVER['SERVER_NAME']. ($_SERVER['SERVER_PORT'] != 80 ? ':'. $_SERVER['SERVER_PORT'] : ''). $_SERVER['REQUEST_URI'] : '';
self::$_context['currenturl'] = self::$_cfg['base_url'] . $_SERVER['REQUEST_URI'];
self::$_context['siteroot'] = (defined('SITEROOT') ? SITEROOT : '');
self::$_context['sharedir'] = self::$_cfg['sharedir'];
self::$_context['tp'] = self::$_context['tableprefix'] = self::$_cfg['tableprefix'];
Expand Down
2 changes: 1 addition & 1 deletion lodel/scripts/logic/class.users.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ protected function _sendPrivateInformation(&$context)
$context['sitetitle'] = $row['title'];
$context['islodeladmin'] = false;
} else { // lodeladmin
$context['siteurl'] = 'http://'. $_SERVER['SERVER_NAME']. ($_SERVER['SERVER_PORT']!=80 ? ':'. $_SERVER['SERVER_PORT'] : '').dirname($_SERVER['REQUEST_URI']);
$context['siteurl'] = dirname($context['currenturl'], 2);
$context['sitetitle'] = $context['siteurl'];
$context['islodeladmin'] = true;
}
Expand Down
7 changes: 4 additions & 3 deletions lodel/scripts/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public function back($back = 1)
global $db;

$idsession = C::get('idsession', 'lodeluser');

$offset = $back-1;
usemaindb();
// selectionne les urls dans la pile grâce à l'idsession et suivant la
Expand All @@ -172,16 +173,16 @@ public function back($back = 1)
or trigger_error('SQL ERROR :<br />'.$GLOBALS['db']->ErrorMsg(), E_USER_ERROR);
$row = $result->fetchRow();
$result->Close();
$id = $row['id'];
$id = $row['id'];
$newurl = $row['url'];

if ($id) {
$db->execute(lq("
DELETE FROM #_TP_urlstack
WHERE id>='{$id}' AND idsession='{$idsession}' AND site='".$this->_site."'"))
or trigger_error('SQL ERROR :<br />'.$GLOBALS['db']->ErrorMsg(), E_USER_ERROR);

$newurl = 'http'.(C::get('https', 'cfg') ? 's' : '').'://'. $_SERVER['SERVER_NAME']. ($_SERVER['SERVER_PORT'] != 80 ? ":". $_SERVER['SERVER_PORT'] : ''). $newurl;
$newurl = dirname(C::get('siteurl')) . $newurl;
} else {
$ext = defined('backoffice') || defined('backoffice-lodeladmin') ? 'php' : C::get('extensionscripts');
$newurl = "index.". $ext;
Expand Down
9 changes: 5 additions & 4 deletions lodel/src/lodel/admin/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
C::set('env', 'admin');

$login = C::get('login');

if($login && C::get('passwd') && C::get('passwd2')) {
include 'loginfunc.php';
$retour = change_passwd(C::get('datab'), $login, C::get('old_passwd'), C::get('passwd'), C::get('passwd2'));

switch($retour)
{
case true:
Expand All @@ -46,7 +47,7 @@
break;
} else {
check_internal_messaging();
header ("Location: http".(C::get('https', 'cfg') ? 's' : '')."://". $_SERVER['SERVER_NAME']. ($_SERVER['SERVER_PORT'] != 80 ? ':'. $_SERVER['SERVER_PORT'] : ''). C::get('url_retour'));
header("Location: " . $context['siteurl'] . C::get('url_retour'));
}
}
break;
Expand Down Expand Up @@ -88,7 +89,7 @@
}
}
check_internal_messaging();
header ("Location: http".(C::get('https', 'cfg') ? 's' : '')."://". $_SERVER['SERVER_NAME']. ($_SERVER['SERVER_PORT'] != 80 ? ':'. $_SERVER['SERVER_PORT'] : ''). C::get('url_retour'));
header("Location: " . $context['siteurl'] . C::get('url_retour'));
} while (0);
}

Expand All @@ -112,4 +113,4 @@
echo $e->getContent();
exit();
}
?>
?>