Adding new scripts to vicidial directory

Hi
I am going to add new php scripts inside the $PATHweb/vicidial/ directory. So for security purposes; only authorised user from vicidial must have access to them, in the same way of admin.php, AST_agent_performance_detail.php and so on.
What lines do I need to add to the new php scripts?
Are the following lines right?
Am I missing something?
Is that correct?
Thanks
I am going to add new php scripts inside the $PATHweb/vicidial/ directory. So for security purposes; only authorised user from vicidial must have access to them, in the same way of admin.php, AST_agent_performance_detail.php and so on.
What lines do I need to add to the new php scripts?
Are the following lines right?
- Code: Select all
<?php
require("dbconnect.php");
$PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER'];
$PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW'];
$PHP_AUTH_USER = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_USER);
$PHP_AUTH_PW = ereg_replace("[^0-9a-zA-Z]","",$PHP_AUTH_PW);
$stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and pass='$PHP_AUTH_PW' and user_level > 7;";
if ($DB) {echo "|$stmt|\n";}
$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))
{
Header("WWW-Authenticate: Basic realm=\"VICIDIAL-LEAD-LOADER\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Invalid Username/Password: |$PHP_AUTH_USER|$PHP_AUTH_PW|\n";
exit;
}
?>
Am I missing something?
Is that correct?
Thanks