LICENSE: AGPLv2 # # This script is designed to launch a CLI script on the voicemail server through # the triggering process # # CHANGELOG: # 161016-2014 - First build of script based upon admin_NANPA_updater.php # 170409-1543 - Added IP List validation code # $version = '2.14-2'; $build = '170409-1543'; $startMS = microtime(); require("dbconnect_mysqli.php"); require("functions.php"); $server_ip=$WEBserver_ip; $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; $PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF); if (isset($_GET["stage"])) {$stage=$_GET["stage"];} elseif (isset($_POST["stage"])) {$stage=$_POST["stage"];} if (isset($_GET["container_id"])) {$container_id=$_GET["container_id"];} elseif (isset($_POST["container_id"])) {$container_id=$_POST["container_id"];} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} $block_scheduling_while_running=0; ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,active_voicemail_server,enable_languages,language_method FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$MAIN.="$stmt\n";} $qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { $row=mysqli_fetch_row($rslt); $non_latin = $row[0]; $outbound_autodial_active = $row[1]; $slave_db_server = $row[2]; $reports_use_slave_db = $row[3]; $active_voicemail_server = $row[4]; $SSenable_languages = $row[5]; $SSlanguage_method = $row[6]; } ##### END SETTINGS LOOKUP ##### ########################################### if ($non_latin < 1) { $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); } else { $PHP_AUTH_PW = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_PW); $PHP_AUTH_USER = preg_replace("/'|\"|\\\\|;/","",$PHP_AUTH_USER); } $container_id = preg_replace('/[^-_0-9a-zA-Z]/','',$container_id); $NOW_DATE = date("Y-m-d"); $stmt="SELECT selected_language from vicidial_users where user='$PHP_AUTH_USER';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $sl_ct = mysqli_num_rows($rslt); if ($sl_ct > 0) { $row=mysqli_fetch_row($rslt); $VUselected_language = $row[0]; } $user_auth=0; $auth=0; $reports_auth=0; $qc_auth=0; $auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'QC',1,0); if ( ($auth_message == 'GOOD') or ($auth_message == '2FA') ) { $user_auth=1; if ($auth_message == '2FA') { header ("Content-type: text/html; charset=utf-8"); echo _QXZ("Your session is expired").". "._QXZ("Click here to log in").".\n"; exit; } } if ($user_auth > 0) { $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 8;"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $auth=$row[0]; $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $reports_auth=$row[0]; $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 1 and qc_enabled='1';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $qc_auth=$row[0]; $reports_only_user=0; $qc_only_user=0; if ( ($reports_auth > 0) and ($auth < 1) ) { $ADD=999999; $reports_only_user=1; } if ( ($qc_auth > 0) and ($reports_auth < 1) and ($auth < 1) ) { if ( ($ADD != '881') and ($ADD != '100000000000000') ) { $ADD=100000000000000; } $qc_only_user=1; } if ( ($qc_auth < 1) and ($reports_auth < 1) and ($auth < 1) ) { $VDdisplayMESSAGE = _QXZ("You do not have permission to be here"); Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } } else { $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); if ($auth_message == 'LOCK') { $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } if ($auth_message == 'IPBLOCK') { $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); Header("HTTP/1.0 401 Unauthorized"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; exit; } if (strlen($active_voicemail_server)<7) { echo _QXZ("ERROR: Admin -> System Settings -> Active Voicemail Server is not set")."\n"; exit; } header ("Content-type: text/html; charset=utf-8"); if ($SSnocache_admin=='1') { header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 } echo "\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; if ($SSnocache_admin=='1') { echo "\n"; echo "\n"; echo "\n"; } if ( ($SSadmin_modify_refresh > 1) and (preg_match("/^3/",$ADD)) ) { $modify_refresh_set=1; if (preg_match("/^3/",$ADD)) {$modify_url = "$PHP_SELF?$QUERY_STRING";} echo "\n"; } echo "