From 7f498daeac1dbd4c301ab64166f622d128583680 Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 21 Feb 2012 07:28:58 +0000 Subject: [PATCH] Fixes for missing User Group restriction settings in several administrative and reporting scripts git-svn-id: svn://192.168.202.10@1788 3d104415-ff17-0410-8863-d5cf3c621b8a --- .../www/vicidial/AST_VICIDIAL_hopperlist.php | 30 ++++- agc_2-X/trunk/www/vicidial/admin.php | 12 +- .../vicidial/admin_listloader_third_gen.php | 39 ++++-- .../trunk/www/vicidial/admin_search_lead.php | 69 ++++++++-- .../trunk/www/vicidial/group_hourly_stats.php | 120 ++++++++++-------- .../www/vicidial/user_group_bulk_change.php | 68 ++++++---- 6 files changed, 233 insertions(+), 105 deletions(-) diff --git a/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php b/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php index 5ad077a9..b9e76cdd 100644 --- a/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php +++ b/agc_2-X/trunk/www/vicidial/AST_VICIDIAL_hopperlist.php @@ -15,6 +15,7 @@ # 101111-1253 - Added source field # 111103-1207 - Added admin_hide_phone_data and admin_hide_lead_data options # 120210-1218 - Added vendor_lead_code to output +# 120221-0059 - Added User Group restriction settings # require("dbconnect.php"); @@ -63,7 +64,28 @@ if (!isset($group)) {$group = '';} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($server_ip)) {$server_ip = '10.10.10.15';} -$stmt="select campaign_id,campaign_name from vicidial_campaigns order by campaign_id;"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$HTML_text.="|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +if ( (!eregi("-ALL",$LOGallowed_campaigns)) ) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + } +$regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + + +$stmt="select campaign_id,campaign_name from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $campaigns_to_print = mysql_num_rows($rslt); @@ -127,7 +149,7 @@ else echo "\n"; echo "---------- TOTALS\n"; - $stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "';"; + $stmt="select count(*) from vicidial_hopper where campaign_id='" . mysql_real_escape_string($group) . "' $LOGallowed_campaignsSQL;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $row=mysql_fetch_row($rslt); @@ -146,7 +168,7 @@ else echo "|ORDER |PRIORITY| LEAD ID | LIST ID | PHONE NUM | STATE | STATUS | COUNT | GMT | ALT | SOURCE| VENDOR LEAD CODE |\n"; echo "+------+--------+-----------+------------+------------+-------+--------+-------+--------+-------+-------+----------------------+\n"; - $stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now,hopper_id,alt_dial,vicidial_hopper.list_id,vicidial_hopper.priority,vicidial_hopper.source,vicidial_hopper.vendor_lead_code from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.status='READY' and vicidial_hopper.lead_id=vicidial_list.lead_id order by priority desc,hopper_id limit 5000;"; + $stmt="select vicidial_hopper.lead_id,phone_number,vicidial_hopper.state,vicidial_list.status,called_count,vicidial_hopper.gmt_offset_now,hopper_id,alt_dial,vicidial_hopper.list_id,vicidial_hopper.priority,vicidial_hopper.source,vicidial_hopper.vendor_lead_code from vicidial_hopper,vicidial_list where vicidial_hopper.campaign_id='" . mysql_real_escape_string($group) . "' and vicidial_hopper.status='READY' and vicidial_hopper.lead_id=vicidial_list.lead_id $LOGallowed_campaignsSQL order by priority desc,hopper_id limit 5000;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $users_to_print = mysql_num_rows($rslt); @@ -176,6 +198,8 @@ else if ($DB > 0) {echo "HIDELEADDATA|$row[2]|$LOGadmin_hide_lead_data|\n";} if (strlen($row[2]) > 0) {$state_temp = $row[2]; $row[2] = preg_replace("/./",'X',$state_temp);} + if (strlen($row[11]) > 0) + {$vlc_temp = $row[11]; $row[11] = preg_replace("/./",'X',$vlc_temp);} } $FMT_i = sprintf("%-4s", $i); diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index beba9fb6..22b688cf 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -3034,12 +3034,13 @@ else # 120125-2107 - Added User Group Active User In-Group Select function to User Group page # 120207-1955 - Added List territory reset function # 120213-1512 - Added remote agent max stats display and campaign VLC hopper dup check option +# 120221-0054 - Fixed Call Time and User Group restrictions on several pages # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$admin_version = '2.4-359a'; -$build = '120213-1512'; +$admin_version = '2.4-360a'; +$build = '120221-0054'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -21356,7 +21357,7 @@ if ($ADD==31) echo "Safe Harbor Call Menu: $NWB#vicidial_campaigns-safe_harbor_menu_id$NWE\n"; - echo "Voicemail: voicemail chooser$NWB#vicidial_campaigns-voicemail_ext$NWE\n"; + echo "Voicemail: voicemail chooser$NWB#vicidial_campaigns-voicemail_ext$NWE\n"; echo "Drop Transfer Group: LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # AST GUI database administration search for lead info # admin_modify_lead.php @@ -26,6 +26,7 @@ # 100622-0928 - Added field labels # 110218-1237 - Added vicidial_lead_search_log logging # 111103-1239 - Added admin_hide_phone_data and admin_hide_lead_data options +# 120221-0118 - Added User Group campaign list restrictions to search queries # require("dbconnect.php"); @@ -99,13 +100,14 @@ else { $office_no=strtoupper($PHP_AUTH_USER); $password=strtoupper($PHP_AUTH_PW); - $stmt="SELECT full_name,modify_leads,admin_hide_lead_data,admin_hide_phone_data from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $stmt="SELECT full_name,modify_leads,admin_hide_lead_data,admin_hide_phone_data,user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $LOGfullname = $row[0]; $LOGmodify_leads = $row[1]; $LOGadmin_hide_lead_data = $row[2]; $LOGadmin_hide_phone_data = $row[3]; + $LOGuser_group = $row[4]; if ($WeBRooTWritablE > 0) { @@ -120,9 +122,50 @@ else fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); fclose($fp); } + exit; } } + +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {echo "|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +$camp_lists=''; +$LOGallowed_campaignsSQL=''; +$whereLOGallowed_campaignsSQL=''; +$LOGallowed_listsSQL=''; +$whereLOGallowed_listsSQL=''; +if (!eregi("-ALL",$LOGallowed_campaigns)) + { + $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); + $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); + $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; + $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; + + $stmt="SELECT list_id from vicidial_lists $whereLOGallowed_campaignsSQL;"; + $rslt=mysql_query($stmt, $link); + $lists_to_print = mysql_num_rows($rslt); + $o=0; + while ($lists_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + $camp_lists .= "'$rowx[0]',"; + $o++; + } + $camp_lists = eregi_replace(".$","",$camp_lists); + if (strlen($camp_lists)<2) {$camp_lists="''";} + $LOGallowed_listsSQL = "and list_id IN($camp_lists)"; + $whereLOGallowed_listsSQL = "where list_id IN($camp_lists)"; + } +$regexLOGallowed_campaigns = " $LOGallowed_campaigns "; + + ?> @@ -281,13 +324,13 @@ else { if (strlen($log_lead_id)>0) { - $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log where lead_id='" . mysql_real_escape_string($log_lead_id) . "'"; - $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log where lead_id='" . mysql_real_escape_string($log_lead_id) . "'"; + $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log where lead_id='" . mysql_real_escape_string($log_lead_id) . "' $LOGallowed_listsSQL"; + $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log where lead_id='" . mysql_real_escape_string($log_lead_id) . "' $LOGallowed_listsSQL"; } if (strlen($log_phone)>0) { - $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log where phone_number='" . mysql_real_escape_string($log_phone) . "'"; - $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log where phone_number='" . mysql_real_escape_string($log_phone) . "'"; + $stmtA="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec,alt_dial from vicidial_log where phone_number='" . mysql_real_escape_string($log_phone) . "' $LOGallowed_listsSQL"; + $stmtB="SELECT lead_id,phone_number,campaign_id,call_date,status,user,list_id,length_in_sec from vicidial_closer_log where phone_number='" . mysql_real_escape_string($log_phone) . "' $LOGallowed_listsSQL"; $stmtC="SELECT extension,caller_id_number,did_id,call_date from vicidial_did_log where caller_id_number='" . mysql_real_escape_string($log_phone) . "'"; } @@ -509,7 +552,7 @@ else ##### BEGIN Lead search ##### if ($vendor_id) { - $stmt="SELECT $vicidial_list_fields from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "'"; + $stmt="SELECT $vicidial_list_fields from vicidial_list where vendor_lead_code='" . mysql_real_escape_string($vendor_id) . "' $LOGallowed_listsSQL"; } else { @@ -517,18 +560,18 @@ else { if ($alt_phone_search=="Yes") { - $stmt="SELECT $vicidial_list_fields from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' or alt_phone='" . mysql_real_escape_string($phone) . "' or address3='" . mysql_real_escape_string($phone) . "'"; + $stmt="SELECT $vicidial_list_fields from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' or alt_phone='" . mysql_real_escape_string($phone) . "' or address3='" . mysql_real_escape_string($phone) . "' $LOGallowed_listsSQL"; } else { - $stmt="SELECT $vicidial_list_fields from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "'"; + $stmt="SELECT $vicidial_list_fields from vicidial_list where phone_number='" . mysql_real_escape_string($phone) . "' $LOGallowed_listsSQL"; } } else { if ($lead_id) { - $stmt="SELECT $vicidial_list_fields from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "'"; + $stmt="SELECT $vicidial_list_fields from vicidial_list where lead_id='" . mysql_real_escape_string($lead_id) . "' $LOGallowed_listsSQL"; } else { @@ -551,7 +594,7 @@ else if ( ($SQLctA > 0) or ($SQLctB > 0) ) {$andB = 'and';} $userSQL = "$andB user='" . mysql_real_escape_string($user) . "'"; } - $stmt="SELECT $vicidial_list_fields from vicidial_list where $statusSQL $list_idSQL $userSQL"; + $stmt="SELECT $vicidial_list_fields from vicidial_list where $statusSQL $list_idSQL $userSQL $LOGallowed_listsSQL"; } else { @@ -568,7 +611,7 @@ else if ($SQLctA > 0) {$andA = 'and';} $last_nameSQL = "$andA last_name='" . mysql_real_escape_string($last_name) . "'"; } - $stmt="SELECT $vicidial_list_fields from vicidial_list where $first_nameSQL $last_nameSQL"; + $stmt="SELECT $vicidial_list_fields from vicidial_list where $first_nameSQL $last_nameSQL $LOGallowed_listsSQL"; } else { @@ -584,7 +627,7 @@ else $results_to_printX=0; if ( ($alt_phone_search=="Yes") and (strlen($phone) > 4) ) { - $stmtX="SELECT lead_id from vicidial_list_alt_phones where phone_number='" . mysql_real_escape_string($phone) . "' limit 1000;"; + $stmtX="SELECT lead_id from vicidial_list_alt_phones where phone_number='" . mysql_real_escape_string($phone) . "' $LOGallowed_listsSQL limit 1000;"; $rsltX=mysql_query($stmtX, $link); $results_to_printX = mysql_num_rows($rsltX); if ($DB) diff --git a/agc_2-X/trunk/www/vicidial/group_hourly_stats.php b/agc_2-X/trunk/www/vicidial/group_hourly_stats.php index 096e3378..50b64a2e 100644 --- a/agc_2-X/trunk/www/vicidial/group_hourly_stats.php +++ b/agc_2-X/trunk/www/vicidial/group_hourly_stats.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # CHANGES # @@ -9,6 +9,7 @@ # - Added required user/pass to gain access to this page # 90310-2138 - Added admin header # 90508-0644 - Changed to PHP long tags +# 120221-0159 - Added User Group restrictions # require("dbconnect.php"); @@ -56,7 +57,7 @@ $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $auth=$row[0]; - if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); Header("HTTP/1.0 401 Unauthorized"); @@ -75,10 +76,10 @@ if (!isset($date_with_hour)) {$date_with_hour = $date_with_hour_default;} if (!isset($begin_date)) {$begin_date = $TODAY;} if (!isset($end_date)) {$end_date = $TODAY;} - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $auth=$row[0]; +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;"; +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; $fp = fopen ("./project_auth_entries.txt", "a"); $date = date("r"); @@ -100,10 +101,12 @@ $browser = getenv("HTTP_USER_AGENT"); { $office_no=strtoupper($PHP_AUTH_USER); $password=strtoupper($PHP_AUTH_PW); - $stmt="SELECT full_name from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $LOGfullname=$row[0]; + $stmt="SELECT full_name,user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $LOGuser_group = $row[1]; + fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); fclose($fp); } @@ -111,6 +114,7 @@ $browser = getenv("HTTP_USER_AGENT"); { fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); fclose($fp); + exit; } # $stmt="SELECT full_name from vicidial_users where user='$user';"; @@ -120,6 +124,24 @@ $browser = getenv("HTTP_USER_AGENT"); } +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$HTML_text.="|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } @@ -163,41 +185,41 @@ require("admin_header.php"); if ( ($group) and ($status) and ($date_with_hour) ) { -$stmt="SELECT user,full_name from vicidial_users where user_group = '" . mysql_real_escape_string($group) . "' order by full_name desc;"; +$stmt="SELECT user,full_name from vicidial_users where user_group = '" . mysql_real_escape_string($group) . "' $LOGadmin_viewable_groupsSQL order by full_name desc;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $tsrs_to_print = mysql_num_rows($rslt); $o=0; while($o < $tsrs_to_print) - { + { $row=mysql_fetch_row($rslt); $VDuser[$o] = "$row[0]"; $VDname[$o] = "$row[1]"; $o++; - } + } $o=0; while($o < $tsrs_to_print) - { - $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]';"; + { + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' $LOGadmin_viewable_groupsSQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $VDtotal[$o] = "$row[0]"; - $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_no_hour) . " 00:00:00' and call_date <= '" . mysql_real_escape_string($date_no_hour) . " 23:59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "' $LOGadmin_viewable_groupsSQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $VDday[$o] = "$row[0]"; - $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "';"; + $stmt="select count(*) from vicidial_log where call_date >= '" . mysql_real_escape_string($date_with_hour) . ":00:00' and call_date <= '" . mysql_real_escape_string($date_with_hour) . ":59:59' and user='$VDuser[$o]' and status='" . mysql_real_escape_string($status) . "' $LOGadmin_viewable_groupsSQL;"; if ($DB) {echo "$stmt\n";} $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $VDcount[$o] = "$row[0]"; $o++; - } + } echo "\n"; @@ -213,7 +235,7 @@ echo "TSR ID TSR ID TOTAL $status $hour_calls $total_calls $day_calls\n"; + + } -echo "TOTAL $status $hour_calls $total_calls $day_calls\n"; - - -} - echo "\n"; echo "

\n"; - echo "
Please enter the group you want to get hourly stats for:
\n"; - echo "\n"; - echo "group: \n"; +echo "group:
\n"; - echo "status:   (example: XFER)
\n"; - echo "date with hour:   (example: 2004-06-25 14)
\n"; - echo "\n"; - echo "


\n"; +$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group"; +$rslt=mysql_query($stmt, $link); +$groups_to_print = mysql_num_rows($rslt); +$o=0; +$groups_list=''; +while ($groups_to_print > $o) + { + $rowx=mysql_fetch_row($rslt); + if ($group == $group) + {$groups_list .= "\n";} + else + {$groups_list .= "\n";} + $o++; + } +echo "$groups_list
\n"; +echo "status:   (example: XFER)
\n"; +echo "date with hour:   (example: 2004-06-25 14)
\n"; +echo "\n"; +echo "


\n"; $ENDtime = date("U"); @@ -285,11 +308,4 @@ echo "\n\n\n


\nscript runtime: $RUNtime seconds
"; exit; - - ?> - - - - - diff --git a/agc_2-X/trunk/www/vicidial/user_group_bulk_change.php b/agc_2-X/trunk/www/vicidial/user_group_bulk_change.php index 83c74115..c2d4fe73 100644 --- a/agc_2-X/trunk/www/vicidial/user_group_bulk_change.php +++ b/agc_2-X/trunk/www/vicidial/user_group_bulk_change.php @@ -1,13 +1,14 @@ LICENSE: AGPLv2 +# Copyright (C) 2012 Matt Florell LICENSE: AGPLv2 # # CHANGES # 81119-0918 - First build # 90309-1830 - Added admin_log logging # 90310-2144 - Added admin header # 90508-0644 - Changed to PHP long tags +# 120221-0025 - Added in User Group restrictions # header ("Content-type: text/html; charset=utf-8"); @@ -59,35 +60,35 @@ $ip = getenv("REMOTE_ADDR"); if (!isset($begin_date)) {$begin_date = $TODAY;} if (!isset($end_date)) {$end_date = $TODAY;} - $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; - if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $auth=$row[0]; +$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7 and view_reports='1';"; +if ($non_latin > 0) { $rslt=mysql_query("SET NAMES 'UTF8'");} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$auth=$row[0]; $fp = fopen ("./project_auth_entries.txt", "a"); $date = date("r"); $ip = getenv("REMOTE_ADDR"); $browser = getenv("HTTP_USER_AGENT"); - if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) +if( (strlen($PHP_AUTH_USER)<2) or (strlen($PHP_AUTH_PW)<2) or (!$auth)) { - Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); - Header("HTTP/1.0 401 Unauthorized"); - echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; - exit; + Header("WWW-Authenticate: Basic realm=\"VICI-PROJECTS\""); + Header("HTTP/1.0 401 Unauthorized"); + echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n"; + exit; } - else +else { - if($auth>0) { - $stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $LOGfullname = $row[0]; - $change_agent_campaign = $row[1]; - $modify_timeclock_log = $row[2]; + $stmt="SELECT full_name,change_agent_campaign,modify_timeclock_log,user_group from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW'"; + $rslt=mysql_query($stmt, $link); + $row=mysql_fetch_row($rslt); + $LOGfullname = $row[0]; + $change_agent_campaign = $row[1]; + $modify_timeclock_log = $row[2]; + $LOGuser_group = $row[3]; if ($webroot_writable > 0) { fwrite ($fp, "VICIDIAL|GOOD|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|$LOGfullname|\n"); @@ -101,10 +102,30 @@ $browser = getenv("HTTP_USER_AGENT"); fwrite ($fp, "VICIDIAL|FAIL|$date|$PHP_AUTH_USER|$PHP_AUTH_PW|$ip|$browser|\n"); fclose($fp); } + exit; } } -$stmt="select user_group,group_name from vicidial_user_groups order by user_group desc;"; +$stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; +if ($DB) {$HTML_text.="|$stmt|\n";} +$rslt=mysql_query($stmt, $link); +$row=mysql_fetch_row($rslt); +$LOGallowed_campaigns = $row[0]; +$LOGallowed_reports = $row[1]; +$LOGadmin_viewable_groups = $row[2]; +$LOGadmin_viewable_call_times = $row[3]; + +$LOGadmin_viewable_groupsSQL=''; +$whereLOGadmin_viewable_groupsSQL=''; +if ( (!eregi("--ALL--",$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) + { + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); + $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); + $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; + } + +$stmt="SELECT user_group,group_name from vicidial_user_groups $whereLOGadmin_viewable_groupsSQL order by user_group desc;"; $rslt=mysql_query($stmt, $link); if ($DB) {echo "$stmt\n";} $groups_to_print = mysql_num_rows($rslt); @@ -118,7 +139,6 @@ while ($i < $groups_to_print) } - ?> @@ -164,7 +184,7 @@ echo "\n"; @@ -183,7 +203,7 @@ if ($stage == "one_user_group_change") ##### GROUP CHANGE FOR ALL USERS IN THE SYSTEM EXCEPT FOR LEVEL > 6 AND ADMIN GROUP ##### if ($stage == "all_user_group_change") { - $stmt="UPDATE vicidial_users set user_group='" . mysql_real_escape_string($group) . "' where user_group!='ADMIN' and user_group < 7;"; + $stmt="UPDATE vicidial_users set user_group='" . mysql_real_escape_string($group) . "' where user_group!='ADMIN' and user_group < 7 $LOGadmin_viewable_groupsSQL;"; $rslt=mysql_query($stmt, $link); echo "All non-Admin Users changed to the $group User Group
\n"; @@ -266,6 +286,4 @@ echo "|$stage|$group|"; exit; - ?> -