forked from extern/egroupware
Cleaned up how link() works, it should work with different styles of webserver_url now
This commit is contained in:
parent
2df1e99322
commit
6deda7f240
@ -448,145 +448,175 @@
|
||||
}
|
||||
}
|
||||
|
||||
function get_image_path($appname = ''){
|
||||
global $phpgw_info;
|
||||
if ($appname == '') {
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
if (empty($phpgw_info['server']['template_set'])) {
|
||||
$phpgw_info['server']['template_set'] = 'default';
|
||||
}
|
||||
function get_image_path($appname = '')
|
||||
{
|
||||
global $phpgw_info;
|
||||
|
||||
$imagedir = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images';
|
||||
$imagedir_default = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/default/images';
|
||||
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/'.$appname.'/images';
|
||||
if ($appname == '')
|
||||
{
|
||||
$appname = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
|
||||
if (is_dir ($imagedir)){
|
||||
return $phpgw_info['server']['webserver_url'].'/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images';
|
||||
}elseif (is_dir ($imagedir_default)){
|
||||
return $phpgw_info['server']['webserver_url'].'/'.$appname.'/templates/default/images';
|
||||
}elseif (is_dir ($imagedir_olddefault)){
|
||||
return $phpgw_info['server']['webserver_url'].'/'.$appname.'/images';
|
||||
}else{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
if (empty($phpgw_info['server']['template_set']))
|
||||
{
|
||||
$phpgw_info['server']['template_set'] = 'default';
|
||||
}
|
||||
|
||||
function navbar()
|
||||
{
|
||||
global $phpgw_info, $phpgw;
|
||||
$imagedir = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images';
|
||||
$imagedir_default = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/default/images';
|
||||
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/'.$appname.'/images';
|
||||
|
||||
$phpgw_info['navbar']['home']['title'] = 'Home';
|
||||
$phpgw_info['navbar']['home']['url'] = $phpgw->link($phpgw_info['server']['webserver_url'] . '/index.php');
|
||||
$phpgw_info['navbar']['home']['icon'] = $phpgw_info['server']['webserver_url'] . '/phpgwapi/templates/'
|
||||
. $phpgw_info['server']['template_set'] . '/images/home.gif';
|
||||
if (is_dir ($imagedir))
|
||||
{
|
||||
return $phpgw_info['server']['webserver_url'].'/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images';
|
||||
}
|
||||
elseif (is_dir ($imagedir_default))
|
||||
{
|
||||
return $phpgw_info['server']['webserver_url'].'/'.$appname.'/templates/default/images';
|
||||
}
|
||||
elseif (is_dir ($imagedir_olddefault))
|
||||
{
|
||||
return $phpgw_info['server']['webserver_url'].'/'.$appname.'/images';
|
||||
}
|
||||
else
|
||||
{
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
reset($phpgw_info['user']['apps']);
|
||||
while ($permission = each($phpgw_info['user']['apps'])) {
|
||||
if (is_long($permission[0])) { continue; }
|
||||
if ($phpgw_info['apps'][$permission[0]]['status'] != 2) {
|
||||
$phpgw_info['navbar'][$permission[0]]['title'] = $phpgw_info['apps'][$permission[0]]['title'];
|
||||
$phpgw_info['navbar'][$permission[0]]['url'] = $phpgw->link($phpgw_info['server']['webserver_url']
|
||||
. '/' . $permission[0] . '/index.php');
|
||||
$icon_file = PHPGW_SERVER_ROOT . '/'.$permission[0] . '/templates/'. $phpgw_info['server']['template_set']. '/images/navbar.gif';
|
||||
if (file_exists($icon_file)){
|
||||
$phpgw_info['navbar'][$permission[0]]['icon'] = $phpgw_info['server']['webserver_url'] . '/'
|
||||
. $permission[0] . '/templates/' . $phpgw_info['server']['template_set'] . '/images/navbar.gif';
|
||||
}else{
|
||||
$phpgw_info['navbar'][$permission[0]]['icon'] = $phpgw_info['server']['webserver_url'] . '/'
|
||||
. $permission[0] . '/templates/default/images/navbar.gif';
|
||||
}
|
||||
}
|
||||
}
|
||||
$phpgw_info['navbar']['preferences']['title'] = 'preferences';
|
||||
$phpgw_info['navbar']['preferences']['url'] = $phpgw->link($phpgw_info['server']['webserver_url']
|
||||
. '/preferences/index.php');
|
||||
$phpgw_info['navbar']['preferences']['icon'] = $phpgw_info['server']['webserver_url'] . '/preferences/templates/'
|
||||
function navbar()
|
||||
{
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
$phpgw_info['navbar']['home']['title'] = 'Home';
|
||||
$phpgw_info['navbar']['home']['url'] = $phpgw->link('/index.php');
|
||||
$phpgw_info['navbar']['home']['icon'] = $phpgw_info['server']['webserver_url'] . '/phpgwapi/templates/'
|
||||
. $phpgw_info['server']['template_set'] . '/images/home.gif';
|
||||
|
||||
reset($phpgw_info['user']['apps']);
|
||||
while ($permission = each($phpgw_info['user']['apps']))
|
||||
{
|
||||
if (is_long($permission[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($phpgw_info['apps'][$permission[0]]['status'] != 2)
|
||||
{
|
||||
$phpgw_info['navbar'][$permission[0]]['title'] = $phpgw_info['apps'][$permission[0]]['title'];
|
||||
$phpgw_info['navbar'][$permission[0]]['url'] = $phpgw->link('/' . $permission[0] . '/index.php');
|
||||
$icon_file = PHPGW_SERVER_ROOT . '/'.$permission[0] . '/templates/'. $phpgw_info['server']['template_set']. '/images/navbar.gif';
|
||||
|
||||
if (file_exists($icon_file))
|
||||
{
|
||||
$phpgw_info['navbar'][$permission[0]]['icon'] = $phpgw_info['server']['webserver_url'] . '/'
|
||||
. $permission[0] . '/templates/' . $phpgw_info['server']['template_set'] . '/images/navbar.gif';
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw_info['navbar'][$permission[0]]['icon'] = $phpgw_info['server']['webserver_url'] . '/'
|
||||
. $permission[0] . '/templates/default/images/navbar.gif';
|
||||
}
|
||||
}
|
||||
}
|
||||
$phpgw_info['navbar']['preferences']['title'] = 'preferences';
|
||||
$phpgw_info['navbar']['preferences']['url'] = $phpgw->link('/preferences/index.php');
|
||||
$phpgw_info['navbar']['preferences']['icon'] = $phpgw_info['server']['webserver_url'] . '/preferences/templates/'
|
||||
. $phpgw_info['server']['template_set'] . '/images/navbar.gif';
|
||||
|
||||
if ($phpgw_info['flags']['currentapp'] == 'home' || $phpgw_info['flags']['currentapp'] == 'preferences' || $phpgw_info['flags']['currentapp'] == 'about') {
|
||||
$app = 'phpGroupWare';
|
||||
} else {
|
||||
$app = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
$phpgw_info['navbar']['about']['title'] = lang('About x',$app); // We handle this here
|
||||
// becuase its special
|
||||
$phpgw_info['navbar']['about']['url'] = $phpgw->link($phpgw_info['server']['webserver_url']
|
||||
. '/about.php','app='.$app);
|
||||
$phpgw_info['navbar']['about']['icon'] = $phpgw_info['server']['webserver_url'] . '/phpgwapi/templates/'
|
||||
if ($phpgw_info['flags']['currentapp'] == 'home' || $phpgw_info['flags']['currentapp'] == 'preferences' || $phpgw_info['flags']['currentapp'] == 'about')
|
||||
{
|
||||
$app = 'phpGroupWare';
|
||||
}
|
||||
else
|
||||
{
|
||||
$app = $phpgw_info['flags']['currentapp'];
|
||||
}
|
||||
|
||||
// We handle this here becuase its special
|
||||
$phpgw_info['navbar']['about']['title'] = lang('About x',$app);
|
||||
|
||||
$phpgw_info['navbar']['about']['url'] = $phpgw->link('/about.php','app='.$app);
|
||||
$phpgw_info['navbar']['about']['icon'] = $phpgw_info['server']['webserver_url'] . '/phpgwapi/templates/'
|
||||
. $phpgw_info['server']['template_set'] . '/images/about.gif';
|
||||
|
||||
$phpgw_info['navbar']['logout']['title'] = 'Logout';
|
||||
$phpgw_info['navbar']['logout']['url'] = $phpgw->link($phpgw_info['server']['webserver_url']
|
||||
. '/logout.php');
|
||||
$phpgw_info['navbar']['logout']['icon'] = $phpgw_info['server']['webserver_url'] . '/phpgwapi/templates/'
|
||||
$phpgw_info['navbar']['logout']['title'] = 'Logout';
|
||||
$phpgw_info['navbar']['logout']['url'] = $phpgw->link('/logout.php');
|
||||
$phpgw_info['navbar']['logout']['icon'] = $phpgw_info['server']['webserver_url'] . '/phpgwapi/templates/'
|
||||
. $phpgw_info['server']['template_set'] . '/images/logout.gif';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function app_header()
|
||||
{
|
||||
if (file_exists(PHPGW_APP_INC . '/header.inc.php')) {
|
||||
include(PHPGW_APP_INC . '/header.inc.php');
|
||||
}
|
||||
}
|
||||
function app_header()
|
||||
{
|
||||
if (file_exists(PHPGW_APP_INC . '/header.inc.php'))
|
||||
{
|
||||
include(PHPGW_APP_INC . '/header.inc.php');
|
||||
}
|
||||
}
|
||||
|
||||
function phpgw_header() {
|
||||
global $phpgw, $phpgw_info;
|
||||
function phpgw_header()
|
||||
{
|
||||
global $phpgw, $phpgw_info;
|
||||
|
||||
include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $phpgw_info['server']['template_set']
|
||||
include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $phpgw_info['server']['template_set']
|
||||
. '/head.inc.php');
|
||||
$this->navbar(False);
|
||||
include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $phpgw_info['server']['template_set']
|
||||
$this->navbar(False);
|
||||
include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $phpgw_info['server']['template_set']
|
||||
. '/navbar.inc.php');
|
||||
if ((! isset($phpgw_info['flags']['nonavbar']) || ! $phpgw_info['flags']['nonavbar']) && ! $phpgw_info['flags']['navbar_target']) {
|
||||
echo parse_navbar();
|
||||
}
|
||||
}
|
||||
if ((! isset($phpgw_info['flags']['nonavbar']) || ! $phpgw_info['flags']['nonavbar']) && ! $phpgw_info['flags']['navbar_target'])
|
||||
{
|
||||
echo parse_navbar();
|
||||
}
|
||||
}
|
||||
|
||||
function phpgw_footer()
|
||||
{
|
||||
global $phpgw, $phpgw_info, $HTMLCOMPLAINT;
|
||||
function phpgw_footer()
|
||||
{
|
||||
global $phpgw, $phpgw_info, $HTMLCOMPLAINT;
|
||||
|
||||
if (!isset($phpgw_info['flags']['nofooter']) || !$phpgw_info['flags']['nofooter']) {
|
||||
include(PHPGW_API_INC . '/footer.inc.php');
|
||||
}
|
||||
if (!isset($phpgw_info['flags']['nofooter']) || !$phpgw_info['flags']['nofooter'])
|
||||
{
|
||||
include(PHPGW_API_INC . '/footer.inc.php');
|
||||
}
|
||||
|
||||
// Clean up mcrypt
|
||||
if (is_object($this->crypto)) {
|
||||
$this->crypto->cleanup();
|
||||
unset($this->crypto);
|
||||
}
|
||||
}
|
||||
// Clean up mcrypt
|
||||
if (is_object($this->crypto))
|
||||
{
|
||||
$this->crypto->cleanup();
|
||||
unset($this->crypto);
|
||||
}
|
||||
}
|
||||
|
||||
function hex2bin($data)
|
||||
{
|
||||
$len = strlen($data);
|
||||
return pack('H' . $len, $data);
|
||||
}
|
||||
function hex2bin($data)
|
||||
{
|
||||
$len = strlen($data);
|
||||
return pack('H' . $len, $data);
|
||||
}
|
||||
|
||||
function encrypt($data) {
|
||||
global $phpgw_info, $phpgw;
|
||||
function encrypt($data)
|
||||
{
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
$data = serialize($data);
|
||||
return $phpgw->crypto->encrypt($data);
|
||||
}
|
||||
$data = serialize($data);
|
||||
return $phpgw->crypto->encrypt($data);
|
||||
}
|
||||
|
||||
function decrypt($data) {
|
||||
global $phpgw_info, $phpgw;
|
||||
function decrypt($data)
|
||||
{
|
||||
global $phpgw_info, $phpgw;
|
||||
|
||||
$data = $phpgw->crypto->decrypt($data);
|
||||
return unserialize($data);
|
||||
}
|
||||
$data = $phpgw->crypto->decrypt($data);
|
||||
return unserialize($data);
|
||||
}
|
||||
|
||||
function des_cryptpasswd($userpass, $random)
|
||||
{
|
||||
$lcrypt = "{crypt}";
|
||||
$password = crypt($userpass);
|
||||
$ldappassword = sprintf("%s%s", $lcrypt, $password);
|
||||
function des_cryptpasswd($userpass, $random)
|
||||
{
|
||||
$lcrypt = '{crypt}';
|
||||
$password = crypt($userpass);
|
||||
$ldappassword = sprintf('%s%s', $lcrypt, $password);
|
||||
|
||||
return $ldappassword;
|
||||
}
|
||||
return $ldappassword;
|
||||
}
|
||||
|
||||
function md5_cryptpasswd($userpass, $random)
|
||||
{
|
||||
|
@ -490,16 +490,10 @@
|
||||
/*************************************************************************\
|
||||
* Function to handle session support via url or cookies *
|
||||
\*************************************************************************/
|
||||
function link($url = '', $extravars = '')
|
||||
function link($url, $extravars = '')
|
||||
{
|
||||
global $phpgw, $phpgw_info, $usercookie, $kp3, $PHP_SELF;
|
||||
|
||||
/* Fix problems when PHP_SELF if used as the param */
|
||||
if ($url == $PHP_SELF)
|
||||
{
|
||||
$url = '';
|
||||
}
|
||||
|
||||
|
||||
if (! $kp3)
|
||||
{
|
||||
$kp3 = $phpgw_info['user']['kp3'];
|
||||
@ -507,7 +501,11 @@
|
||||
|
||||
// Explicit hack to work around problems with php running as CGI on windows
|
||||
// please let us know if this doesn't work for you!
|
||||
if (! $url && (PHP_OS == 'Windows' || PHP_OS == 'OS/2' || PHP_OS == 'WIN32' || PHP_OS == 'WIN16'))
|
||||
|
||||
// I am not sure how my changes will affect the following.
|
||||
// Could someone with access to a Windows install check it ? (jengo)
|
||||
|
||||
/* if (! $url && (PHP_OS == 'Windows' || PHP_OS == 'OS/2' || PHP_OS == 'WIN32' || PHP_OS == 'WIN16'))
|
||||
{
|
||||
$exe = strpos($PHP_SELF,'php.exe');
|
||||
if ($exe != false) {
|
||||
@ -517,18 +515,25 @@
|
||||
$url .= substr($PHP_SELF,$exe,strlen($PHP_SELF)-$exe);
|
||||
}
|
||||
}
|
||||
if (! $url)
|
||||
*/
|
||||
|
||||
$url = $phpgw_info['server']['webserver_url'] . $url;
|
||||
|
||||
// This needs to be tested as well. (jengo)
|
||||
|
||||
/* if (! $url)
|
||||
{
|
||||
$url_root = split ('/', $phpgw_info['server']['webserver_url']);
|
||||
/* Some hosting providers have their paths screwy.
|
||||
If the value from $PHP_SELF is not what you expect, you can use this to patch it
|
||||
It will need to be adjusted to your specific problem tho.
|
||||
*/
|
||||
// Some hosting providers have their paths screwy.
|
||||
// If the value from $PHP_SELF is not what you expect, you can use this to patch it
|
||||
// It will need to be adjusted to your specific problem tho.
|
||||
//
|
||||
//$patched_php_self = str_replace('/php4/php/phpgroupware', '/phpgroupware', $PHP_SELF);
|
||||
$patched_php_self = $PHP_SELF;
|
||||
$url = (strlen($url_root[0])? $url_root[0].'//':'') . $url_root[2] . $patched_php_self;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
if (isset($phpgw_info['server']['usecookies']) && $phpgw_info['server']['usecookies'])
|
||||
{
|
||||
if ($extravars)
|
||||
@ -549,13 +554,14 @@
|
||||
{
|
||||
$url .= '&newsmode=on';
|
||||
}
|
||||
|
||||
if ($extravars)
|
||||
{
|
||||
$url .= "&$extravars";
|
||||
$url .= '&' . $extravars;
|
||||
}
|
||||
}
|
||||
|
||||
$url = str_replace('/?', '/index.php?', $url);
|
||||
|
||||
/* $url = str_replace('/?', '/index.php?', $url);
|
||||
$webserver_url_count = strlen($phpgw_info['server']['webserver_url']);
|
||||
$slash_check = strtolower(substr($url ,0,1));
|
||||
if (substr($url ,0,$webserver_url_count) != $phpgw_info['server']['webserver_url'])
|
||||
@ -573,7 +579,7 @@
|
||||
{
|
||||
$url = $phpgw_info['server']['webserver_url'].'/'.$app.'/'.$url;
|
||||
}
|
||||
}
|
||||
} */
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user