From 43127662abfeb6987e661dbd16ba82d5493f22dc Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Fri, 31 Aug 2001 22:29:23 +0000 Subject: [PATCH] Some more fixes to work with register_globals Off; Change one debug echo. --- setup/inc/class.schema_proc_pgsql.inc.php | 2 +- setup/inc/class.setup.inc.php | 48 ++++++------- setup/inc/class.setup_html.inc.php | 85 +++++++++-------------- setup/inc/class.setup_lang.inc.php | 3 +- setup/inc/functions.inc.php | 35 ++-------- 5 files changed, 67 insertions(+), 106 deletions(-) diff --git a/setup/inc/class.schema_proc_pgsql.inc.php b/setup/inc/class.schema_proc_pgsql.inc.php index 682461b0d6..779a3bf1f6 100644 --- a/setup/inc/class.schema_proc_pgsql.inc.php +++ b/setup/inc/class.schema_proc_pgsql.inc.php @@ -408,7 +408,7 @@ function GetSequenceForTable($oProc,$table,&$sSequenceName) { global $DEBUG; - if($DEBUG) { echo '
GetSequenceForTable: You rang?'; } + if($DEBUG) { echo '
GetSequenceForTable: ' . $table; } $oProc->m_odb->query("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE 'seq_$table' AND relkind='S' ORDER BY relname",__LINE__,__FILE__); $oProc->m_odb->next_record(); diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index 1d22058f2c..bfa7dd2f3e 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -82,27 +82,27 @@ $FormLogout == 'ldapimport' || $FormLogout == 'sqltoarray') { - setcookie("ConfigPW"); // scrub the old one - setcookie("ConfigDomain"); // scrub the old one - setcookie("ConfigLang"); - $phpgw_info["setup"]["ConfigLoginMSG"] = "You have successfully logged out"; + setcookie('ConfigPW'); // scrub the old one + setcookie('ConfigDomain'); // scrub the old one + setcookie('ConfigLang'); + $GLOBALS['phpgw_info']['setup']['ConfigLoginMSG'] = 'You have successfully logged out'; return False; } - elseif($FormLogout == "header") + elseif($FormLogout == 'header') { - setcookie("HeaderPW"); // scrub the old one - $phpgw_info["setup"]["HeaderLoginMSG"] = "You have successfully logged out"; + setcookie('HeaderPW'); // scrub the old one + $GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'You have successfully logged out'; return False; } } elseif (isset($ConfigPW)) { - if ($ConfigPW != $phpgw_domain[$ConfigDomain]["config_passwd"] && $auth_type == "Config") + if ($ConfigPW != $phpgw_domain[$ConfigDomain]["config_passwd"] && $auth_type == 'Config') { - setcookie("ConfigPW"); // scrub the old one - setcookie("ConfigDomain"); // scrub the old one - setcookie("ConfigLang"); - $phpgw_info["setup"]["ConfigLoginMSG"] = "Invalid session cookie (cookies must be enabled)"; + setcookie('ConfigPW'); // scrub the old one + setcookie('ConfigDomain'); // scrub the old one + setcookie('ConfigLang'); + $phpgw_info['setup']['ConfigLoginMSG'] = 'Invalid session cookie (cookies must be enabled)'; return False; } else @@ -114,41 +114,41 @@ { if (isset($ConfigLogin)) { - if ($FormPW == $phpgw_domain[$FormDomain]["config_passwd"] && $auth_type == "Config") + if ($FormPW == $phpgw_domain[$FormDomain]['config_passwd'] && $auth_type == 'Config') { - setcookie("HeaderPW"); // scrub the old one - setcookie("ConfigPW",$FormPW); - setcookie("ConfigDomain",$FormDomain); - setcookie("ConfigLang",$ConfigLang); + setcookie('HeaderPW'); // scrub the old one + setcookie('ConfigPW',$FormPW); + setcookie('ConfigDomain',$FormDomain); + setcookie('ConfigLang',$ConfigLang); $ConfigDomain = $FormDomain; return True; } else { - $phpgw_info["setup"]["ConfigLoginMSG"] = "Invalid password"; + $phpgw_info['setup']['ConfigLoginMSG'] = 'Invalid password'; return False; } } elseif (isset($HeaderLogin)) { - if ($FormPW == $phpgw_info["server"]["header_admin_password"] && $auth_type == "Header") + if ($FormPW == $phpgw_info['server']['header_admin_password'] && $auth_type == 'Header') { - setcookie("HeaderPW",$FormPW); + setcookie('HeaderPW',$FormPW); return True; } else { - $phpgw_info["setup"]["HeaderLoginMSG"] = "Invalid password"; + $GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'Invalid password'; return False; } } } elseif (isset($HeaderPW)) { - if ($HeaderPW != $phpgw_info["server"]["header_admin_password"] && $auth_type == "Header") + if ($HeaderPW != $phpgw_info['server']['header_admin_password'] && $auth_type == 'Header') { - setcookie("HeaderPW"); // scrub the old one - $phpgw_info["setup"]["HeaderLoginMSG"] = "Invalid session cookie (cookies must be enabled)"; + setcookie('HeaderPW'); // scrub the old one + $GLOBALS['phpgw_info']['setup']['HeaderLoginMSG'] = 'Invalid session cookie (cookies must be enabled)'; return False; } else diff --git a/setup/inc/class.setup_html.inc.php b/setup/inc/class.setup_html.inc.php index 74a034a150..d093c9a378 100644 --- a/setup/inc/class.setup_html.inc.php +++ b/setup/inc/class.setup_html.inc.php @@ -33,8 +33,6 @@ function setup_tpl_dir($app_name='setup') { - global $phpgw_info; - // hack to get tpl dir if (is_dir(PHPGW_SERVER_ROOT)) { @@ -52,57 +50,48 @@ function show_header($title = '',$nologoutbutton = False, $logoutfrom = 'config', $configdomain = '') { - global $phpgw_info, $setup_tpl, $HTTP_SERVER_VARS; - - $setup_tpl->set_var('lang_charset',lang('charset')); + $GLOBALS['setup_tpl']->set_var('lang_charset',lang('charset')); if ($nologoutbutton) { $btn_logout = ' '; } else { - $btn_logout = ''.lang('Logout').''; + $btn_logout = ''.lang('Logout').''; } - $setup_tpl->set_var('lang_setup', lang('setup')); - $setup_tpl->set_var('page_title',$title); + $GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup')); + $GLOBALS['setup_tpl']->set_var('page_title',$title); if ($configdomain == '') { - $setup_tpl->set_var('configdomain',""); + $GLOBALS['setup_tpl']->set_var('configdomain',""); } else { - $setup_tpl->set_var('configdomain',' - ' . lang('Domain') . ': '.$configdomain); + $GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': '.$configdomain); } - $setup_tpl->set_var('pgw_ver',$phpgw_info['server']['versions']['phpgwapi']); - $setup_tpl->set_var('logoutbutton',$btn_logout); - $setup_tpl->pparse('out','T_head'); + $GLOBALS['setup_tpl']->set_var('pgw_ver',$phpgw_info['server']['versions']['phpgwapi']); + $GLOBALS['setup_tpl']->set_var('logoutbutton',$btn_logout); + $GLOBALS['setup_tpl']->pparse('out','T_head'); //$setup_tpl->set_var('T_head',''); } function show_footer() { - global $phpgw_info, $setup_tpl; - - $setup_tpl->pparse('out','T_footer'); - unset($setup_tpl); + $GLOBALS['setup_tpl']->pparse('out','T_footer'); + unset($GLOBALS['setup_tpl']); } function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)') { - global $phpgw_info, $setup_tpl; - - $setup_tpl->set_var('V_alert_word',$alert_word); - $setup_tpl->set_var('V_alert_msg',$alert_msg); - $setup_tpl->pparse('out','T_alert_msg'); + $GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word); + $GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg); + $GLOBALS['setup_tpl']->pparse('out','T_alert_msg'); } function make_frm_btn_simple($pre_frm_blurb='',$frm_method='POST',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='') { - // are these golbals necessary? - global $phpgw_info, $setup_tpl; - - // a simple form has simple components + /* a simple form has simple components */ $simple_form = $pre_frm_blurb ."\n" .'
' ."\n" @@ -114,10 +103,7 @@ function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='') { - // are these golbals necessary? - global $phpgw_info, $setup_tpl; - - // a simple href link has simple components + /* a simple href link has simple components */ $simple_link = $pre_link_blurb .'' .$href_text .' ' @@ -127,54 +113,51 @@ function login_form() { - global $phpgw_info, $phpgw_domain, $setup_tpl; - // begin use TEMPLATE login_main.tpl - $setup_tpl->set_var('ConfigLoginMSG',$phpgw_info['setup']['ConfigLoginMSG']); - $setup_tpl->set_var('HeaderLoginMSG',$phpgw_info['setup']['HeaderLoginMSG']); + $GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',$GLOBALS['phpgw_info']['setup']['ConfigLoginMSG']); + $GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',$GLOBALS['phpgw_info']['setup']['HeaderLoginMSG']); - if ($phpgw_info['setup']['stage']['header'] == '10') + if ($GLOBALS['phpgw_info']['setup']['stage']['header'] == '10') { // begin use SUB-TEMPLATE login_stage_header, // fills V_login_stage_header used inside of login_main.tpl - $setup_tpl->set_var('lang_select',lang_select()); - if (count($phpgw_domain) > 1) + $GLOBALS['setup_tpl']->set_var('lang_select',lang_select()); + if (count($GLOBALS['phpgw_domain']) > 1) { // use BLOCK B_multi_domain inside of login_stage_header - $setup_tpl->parse('V_multi_domain','B_multi_domain'); + $GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain'); // in this case, the single domain block needs to be nothing - $setup_tpl->set_var('V_single_domain',''); + $GLOBALS['setup_tpl']->set_var('V_single_domain',''); } else { - reset($phpgw_domain); - $default_domain = each($phpgw_domain); - $setup_tpl->set_var('default_domain_zero',$default_domain[0]); + reset($GLOBALS['phpgw_domain']); + $default_domain = each($GLOBALS['phpgw_domain']); + $GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain[0]); // use BLOCK B_single_domain inside of login_stage_header - $setup_tpl->parse('V_single_domain','B_single_domain'); + $GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain'); // // in this case, the multi domain block needs to be nothing - $setup_tpl->set_var('V_multi_domain',''); + $GLOBALS['setup_tpl']->set_var('V_multi_domain',''); } // end use SUB-TEMPLATE login_stage_header // put all this into V_login_stage_header for use inside login_main - $setup_tpl->parse('V_login_stage_header','T_login_stage_header'); + $GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header'); } else { // begin SKIP SUB-TEMPLATE login_stage_header - $setup_tpl->set_var('V_multi_domain',''); - $setup_tpl->set_var('V_single_domain',''); - $setup_tpl->set_var('V_login_stage_header',''); + $GLOBALS['setup_tpl']->set_var('V_multi_domain',''); + $GLOBALS['setup_tpl']->set_var('V_single_domain',''); + $GLOBALS['setup_tpl']->set_var('V_login_stage_header',''); } // end use TEMPLATE login_main.tpl // now out the login_main template - $setup_tpl->pparse('out','T_login_main'); + $GLOBALS['setup_tpl']->pparse('out','T_login_main'); } function get_template_list() { - global $phpgw_info; $d = dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates'); //$list['user_choice']['name'] = 'user_choice'; //$list['user_choice']['title'] = 'Users Choice'; @@ -187,7 +170,7 @@ if (file_exists ($f)) { include($f); - $list[$entry]['title'] = 'Use ' . $phpgw_info['template'][$entry]['title'] . 'interface'; + $list[$entry]['title'] = 'Use ' . $GLOBALS['phpgw_info']['template'][$entry]['title'] . 'interface'; } else { diff --git a/setup/inc/class.setup_lang.inc.php b/setup/inc/class.setup_lang.inc.php index ba8075fc47..1d360ffcd8 100644 --- a/setup/inc/class.setup_lang.inc.php +++ b/setup/inc/class.setup_lang.inc.php @@ -34,7 +34,8 @@ */ function phpgw_setup_lang() { - global $ConfigLang; + $ConfigLang = $GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'] ? $GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'] : $GLOBALS['HTTP_POST_VARS']['ConfigLang']; + if(!$ConfigLang) { $lang = 'en'; diff --git a/setup/inc/functions.inc.php b/setup/inc/functions.inc.php index 647abdc61d..bc9d13d6a3 100644 --- a/setup/inc/functions.inc.php +++ b/setup/inc/functions.inc.php @@ -38,7 +38,7 @@ $p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_', $p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_') { - global $phpgw_info, $phpgw, $phpgw_domain; + global $phpgw_info; /* error_reporting(0); */ list($appname,$classname) = explode(".", $class); @@ -77,28 +77,6 @@ return $obj; } - function oldCreateObject($classname, $constructor_param = "") - { - global $phpgw, $phpgw_info, $phpgw_domain; - $classpart = explode (".", $classname); - $appname = $classpart[0]; - $classname = $classpart[1]; - if (!$phpgw_info["flags"]["included_classes"][$classname]) - { - $phpgw_info["flags"]["included_classes"][$classname] = True; - include(PHPGW_INCLUDE_ROOT."/".$appname."/inc/class.".$classname.".inc.php"); - } - if ($constructor_param == "") - { - $obj = new $classname; - } - else - { - $obj = new $classname($constructor_param); - } - return $obj; - } - // This is needed is some parts of setup, until we include the API directly function filesystem_separator() { @@ -153,11 +131,10 @@ */ function lang($key, $m1="", $m2="", $m3="", $m4="", $m5="", $m6="", $m7="", $m8="", $m9="", $m10="" ) { - global $phpgw_setup; // # TODO: check if $m1 is of type array. // If so, use it instead of $m2-$mN (Stephan) $vars = array( $m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9, $m10 ); - $value = $phpgw_setup->translate("$key", $vars ); + $value = $GLOBALS['phpgw_setup']->translate("$key", $vars ); return $value; } @@ -195,7 +172,7 @@ function lang_select() { - global $ConfigLang; + $ConfigLang = $GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'] ? $GLOBALS['HTTP_COOKIE_VARS']['ConfigLang'] : $GLOBALS['HTTP_POST_VARS']['ConfigLang']; $select = '