From 116de14b922e0461dc5b4aa83b7a2fc80844c994 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 4 Oct 2001 20:13:00 +0000 Subject: [PATCH] $GLOBALS, using boinfolog->write(), and closed security-hole, that non-admin users could call csv_import, if they new the url (check if user is allowed to run admin-app) --- infolog/csv_import.php | 113 +++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 50 deletions(-) diff --git a/infolog/csv_import.php b/infolog/csv_import.php index 1f417f24dd..821925f883 100644 --- a/infolog/csv_import.php +++ b/infolog/csv_import.php @@ -12,11 +12,24 @@ /* $Id$ */ - $phpgw_info['flags']['currentapp'] = 'infolog'; - $phpgw_info['flags']['enable_contacts_class'] = True; + $GLOBALS['phpgw_info']['flags'] = array( + 'currentapp' => 'infolog', + 'noheader' => True, + 'nonavbar' => True, + 'enable_contacts_class' => True + ); include("../header.inc.php"); - $phpgw->infolog = createobject('infolog.uiinfolog'); + if (!isset($GLOBALS['phpgw_info']['user']['apps']['admin']) || + !$GLOBALS['phpgw_info']['user']['apps']['admin']) // no admin + { + Header('Location: ' . $GLOBALS['phpgw']->link('/home.php')); + $GLOBALS['phpgw']->common->phpgw_exit(); + } + $GLOBALS['phpgw']->common->phpgw_header(); + echo parse_navbar(); + + $infolog = createobject('infolog.uiinfolog'); $t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); // $t->unknows = 'keep'; $t->debug = 1; $t->set_file(array('import' => 'csv_import.tpl')); @@ -26,14 +39,14 @@ $t->set_block('import','ffooter','ffooterhandle'); $t->set_block('import','imported','importedhandle'); - // $t->set_var("navbar_bg",$phpgw_info["theme"]["navbar_bg"]); - // $t->set_var("navbar_text",$phpgw_info["theme"]["navbar_text"]); + // $t->set_var("navbar_bg",$GLOBALS['phpgw_info']["theme"]["navbar_bg"]); + // $t->set_var("navbar_text",$GLOBALS['phpgw_info']["theme"]["navbar_text"]); if ($action == 'download' && (!$fieldsep || !$csvfile || !($fp=fopen($csvfile,"r")))) { $action = ''; } - $t->set_var("action_url",$phpgw->link("/infolog/csv_import.php")); - $t->set_var( $phpgw->infolog->setStyleSheet( )); + $t->set_var("action_url",$GLOBALS['phpgw']->link("/infolog/csv_import.php")); + $t->set_var( $infolog->setStyleSheet( )); $t->set_var("lang_info_action",lang("InfoLog - Import CSV-File")); $PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in trans @@ -83,20 +96,20 @@ function cat_id( $cats ) if (isset($cat2id[$cat])) { $ids[$cat] = $cat2id[$cat]; // cat is in cache } else { - if (!is_object($phpgw->categories)) { - $phpgw->categories = createobject('phpgwapi.categories'); + if (!is_object($GLOBALS['phpgw']->categories)) { + $GLOBALS['phpgw']->categories = createobject('phpgwapi.categories'); } - if ($id = $phpgw->categories->name2id( $cat )) { // cat exists + if ($id = $GLOBALS['phpgw']->categories->name2id( $cat )) { // cat exists $cat2id[$cat] = $ids[$cat] = $id; } else { // create new cat - $phpgw->categories->add( $cat,0,$cat,'','public',0); - $cat2id[$cat] = $ids[$cat] = $phpgw->categories->name2id( $cat ); + $GLOBALS['phpgw']->categories->add( $cat,0,$cat,'','public',0); + $cat2id[$cat] = $ids[$cat] = $GLOBALS['phpgw']->categories->name2id( $cat ); } } } return implode( ',',$ids ); -} - +} + switch ($action) { case '': // Start, ask Filename $t->set_var('lang_csvfile',lang('CSV-Filename')); @@ -109,7 +122,7 @@ function cat_id( $cats ) $t->parse('filenamehandle','filename'); break; - + case 'download': $pref_file = '/tmp/csv_import_info_log.php'; if (is_readable($pref_file) && ($prefs = fopen($pref_file,'r'))) { @@ -117,7 +130,7 @@ function cat_id( $cats ) // echo "

defaults = array".dump_array($defaults)."

\n"; } else { $defaults = array(); - } + } $t->set_var('lang_csv_fieldname',lang('CSV-Fieldname')); $t->set_var('lang_info_fieldname',lang('InfoLog-Fieldname')); $t->set_var('lang_translation',lang("Translation").' '.lang('help').''); @@ -149,7 +162,7 @@ function cat_id( $cats ) 'addr_id' => 'Addressbook id, to set use @addr_id(nlast,nfirst,org)' ); $mktime_lotus = "${PSep}0?([0-9]+)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*).*$ASep@mktime(${VPre}4,${VPre}5,${VPre}6,${VPre}2,${VPre}3,${VPre}1)"; - + $defaults += array( 'Land' => "addr$PSep.*[(]+([0-9]+)[)]+$ASep+${VPre}1 (${CPre}Ortsvorwahl$CPos) ${CPre}Telefon$CPos$PSep${CPre}Telefon$CPos", 'Notiz' => 'des', 'Privat' => "access${PSep}1${ASep}private${PSep}public", @@ -161,15 +174,15 @@ function cat_id( $cats ) "${PSep}${CPre}Nachname$CPos, ${CPre}Vorname$CPos", 'no CSV 1' => "type${PSep}phone", 'no CSV 2' => "subject${PSep}@substr(${CPre}Notiz$CPos,0,60).' ...'" ); - + $info_name_options = "