From 7b8c52e75818b71915a9dd237fe1a91ea123f7ca Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 22 Aug 2006 16:46:15 +0000 Subject: [PATCH] fixed lead loader code to work with non-writable vicidial web directory git-svn-id: svn://192.168.202.10@201 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../TO_BE_TRANSLATED_2.0.txt | 1 + www/vicidial/listloader.php | 19 +- www/vicidial/listloader.pl | 15 +- www/vicidial/listloaderMAIN.php | 17 +- www/vicidial/listloader_rowdisplay.pl | 33 +++- www/vicidial/listloader_super.pl | 12 +- www/vicidial/new_listloader_superL.php | 164 +++++++++++++----- 7 files changed, 206 insertions(+), 55 deletions(-) diff --git a/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt b/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt index cb2b243a..94cdbdbe 100644 --- a/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt +++ b/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt @@ -18,6 +18,7 @@ Campaign Recording -<\/B> This menu allows you to choose what level of recording Add consultative transfer info to Capmaign modification screen info +Add note about phone_code being manditory for proper GMT offset encoding for proper time zone. ############################################################ AGENT Manual diff --git a/www/vicidial/listloader.php b/www/vicidial/listloader.php index 629ddd0a..6f5ec297 100644 --- a/www/vicidial/listloader.php +++ b/www/vicidial/listloader.php @@ -11,12 +11,13 @@ # 60421-1043 - check GET/POST vars lines with isset to not trigger PHP NOTICES # 60616-1006 - added listID override and gmt_offset lookup while loading # 60619-1652 - Added variable filtering to eliminate SQL injection attack threat +# 60822-1105 - fixed for nonwritable directories # # make sure vicidial_list exists and that your file follows the formatting correctly. This page does not dedupe or do any other lead filtering actions yet at this time. # -$version = '1.1.12'; -$build = '60619-1652'; +$version = '2.0.1'; +$build = '60822-1105'; header ("Content-type: text/html; charset=utf-8"); @@ -142,8 +143,16 @@ function ShowProgress(good, bad, total) { if ($leadfile and filesize($LF_path)<=8388608) { print ""; flush(); - copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); - $file=fopen("$WeBServeRRooT/vicidial/vicidial_temp_file.txt", "r"); + if ($WeBRooTWritablE > 0) + { + copy($LF_path, "$WeBServeRRooT/vicidial/vicidial_temp_file.txt"); + $lead_file = "./vicidial_temp_file.txt"; + } + else + { + $lead_file = "$LF_path"; + } + $file=fopen("$lead_file", "r"); if ($WeBRooTWritablE > 0) {$stmt_file=fopen("$WeBServeRRooT/vicidial/listloader_stmts.txt", "w");} $pulldate=date("Y-m-d H:i:s"); @@ -157,7 +166,7 @@ if ($leadfile and filesize($LF_path)<=8388608) { if (count($field_check)>=5) { flush(); - $file=fopen("./vicidial_temp_file.txt", "r"); + $file=fopen("$lead_file", "r"); $total=0; $good=0; $bad=0; print "
Processing $delim_name-delimited file... ($tab_count|$pipe_count)\n"; diff --git a/www/vicidial/listloader.pl b/www/vicidial/listloader.pl index fd2f1340..6c5a6dd0 100644 --- a/www/vicidial/listloader.pl +++ b/www/vicidial/listloader.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -### listloader.pl version 0.2 *DBI-version* +### listloader.pl version 0.3 *DBI-version* ### ### Copyright (C) 2006 Matt Florell,Joe Johnson LICENSE: GPLv2 ### @@ -11,6 +11,7 @@ # - Added gmt_offset_now lookup for each lead # 60811-1232 - Changed to DBI # 60811-1329 - changed to use /etc/astguiclient.conf for configs +# 60822-1121 - fixed for nonwritable directories # ### begin parsing run-time options ### @@ -33,10 +34,20 @@ if (length($ARGV[0])>1) { @data_in = split(/--forcelistid=/,$args); $forcelistid = $data_in[1]; + $forcelistid =~ s/ .*//gi; print "\n----- FORCE LISTID OVERRIDE: $forcelistid -----\n\n"; } else {$forcelistid = '';} + if ($args =~ /--lead-file=/i) + { + @data_in = split(/--lead-file=/,$args); + $lead_file = $data_in[1]; + $lead_file =~ s/ .*//gi; + # print "\n----- LEAD FILE: $lead_file -----\n\n"; + } + else + {$lead_file = './vicidial_temp_file.xls';} } } ### end parsing run-time options ### @@ -138,7 +149,7 @@ $total=0; $good=0; $bad=0; print "
Processing Excel file...\n"; open(STMT_FILE, "> $PATHlogs/listloader_stmts.txt"); -$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$lead_file"); my($iR, $iC, $oWkS, $oWkC); foreach $oWkS (@{$oBook->{Worksheet}}) { diff --git a/www/vicidial/listloaderMAIN.php b/www/vicidial/listloaderMAIN.php index 67ee25bc..bb292c36 100644 --- a/www/vicidial/listloaderMAIN.php +++ b/www/vicidial/listloaderMAIN.php @@ -8,6 +8,7 @@ # # changes: # 60620-1149 - Added variable filtering to eliminate SQL injection attack threat +# 60822-1105 - fixed for nonwritable directories # require("dbconnect.php"); @@ -30,7 +31,7 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $auth=$row[0]; -$fp = fopen ("./project_auth_entries.txt", "a"); +if ($WeBRooTWritablE > 0) {$fp = fopen ("./project_auth_entries.txt", "a");} $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); @@ -59,13 +60,19 @@ $browser = getenv("HTTP_USER_AGENT"); echo "You do not have permissions to load leads\n"; exit; } - fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); - fclose($fp); + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "LIST_LOAD|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); + fclose($fp); + } } else { - fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); - fclose($fp); + if ($WeBRooTWritablE > 0) + { + fwrite ($fp, "LIST_LOAD|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); + fclose($fp); + } } } diff --git a/www/vicidial/listloader_rowdisplay.pl b/www/vicidial/listloader_rowdisplay.pl index 6eab0b39..fad44122 100644 --- a/www/vicidial/listloader_rowdisplay.pl +++ b/www/vicidial/listloader_rowdisplay.pl @@ -11,6 +11,35 @@ # 60811-1329 - changed to use /etc/astguiclient.conf for configs # +### begin parsing run-time options ### +if (length($ARGV[0])>1) +{ + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help|-h/i) + { + print "allowed run time options:\n [-forcelistid=1234] = overrides the listID given in the file with the 1234\n [-h] = this help screen\n\n"; + } + else + { + if ($args =~ /--lead-file=/i) + { + @data_in = split(/--lead-file=/,$args); + $lead_file = $data_in[1]; + $lead_file =~ s/ .*//gi; + # print "\n----- LEAD FILE: $lead_file -----\n\n"; + } + else + {$lead_file = './vicidial_temp_file.xls';} + } +} +### end parsing run-time options ### + use Spreadsheet::ParseExcel; use Time::Local; use DBI; @@ -63,7 +92,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA or die "Couldn't connect to database: " . DBI->errstr; -$oBook = Spreadsheet::ParseExcel::Workbook->Parse("./vicidial_temp_file.xls"); +$oBook = Spreadsheet::ParseExcel::Workbook->Parse("$lead_file"); my($iR, $iC, $oWkS, $oWkC); $var_str=""; @@ -100,7 +129,7 @@ while ($sthArows > $rec_count) print " \r\n"; print " ".$field_name.": \r\n"; print " \r\n"; print " \r\n"; print "         \r\n"; print " \r\n";