in a particular coding, i made a complete directory scan and then the files falling under a particular category are stored in a database. However the variable used for storage contains the real path(e.g. C:\wamp\www\exa mple), but the value stored in the database is different because it removes all the '\' from the variable and store a value like C:wampwwwexampl e and thus further usage of the path becomes impossible. The code written for the purpose is pasted below please suggest me a way so that the value stored in the database is the real path and not a distorted value!
THE CODE=>
<html>
<head><title>Sc an Result</title></head>
<BGSOUND SRC="Windows XP Exclamation.wav ">
<b><font face="Verdana, Arial, Helvetica, sans-serif">Current Directory Contain
Following files and Sub Directories...</font></b>
<p>
<?php
include 'opendb.php';
$found = array();$i=0;
$vc=0;
if(isset($_REQU EST['custom']))
{
$C=$_REQUEST['custom'];
if($C=="")
header('locatio n:CustomScan.ph p?y=You have not enterd appropiate drive name');
else if(!(is_dir($C) ))
header('locatio n:CustomScan.ph p?y=You have not enterd appropiate drive name');
@DirDisply($C);
}
else
header('locatio n:CustomScan.ph p?y=You have not enterd appropiate drive name');
function DirDisply($p)
{
global $found,$vc,$i;
$TrackDir=opend ir($p);
while ($file = readdir($TrackD ir))
{
if ($file == "." || $file == "..")
{
continue;
}
else
{
$n=$p."\\".$fil e;
echo $n."<br>";
$i++;
if (is_dir($n) )
@DirDisply($n);
else
{
if(is_executabl e($n) )
{
$handle=fopen($ n, "rb");
$convert=bin2he x( fread( $handle, filesize($n) ) );
$query="SELECT signature, virus FROM virusdetails";
$result=mysql_q uery($query);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$pattern="/"."{$row['signature']}"."/";
$name="{$row['virus']}";
if(preg_match($ pattern,$conver t))
{
$vc++;
$query="INSERT INTO found (signature, virus, file) VALUES ('$pattern', '$name' ,'$n')";
mysql_query($qu ery);
}
}
fclose($handle) ;
pack( "H*", $convert );continue;
}
}
}
}
closedir($Track Dir);
return;
}
echo"<br><br><b r><br><b>SCAN RESULT<br><br>< br>Total files scanned is $i </b><br><br>";
if($vc==0)
echo"<b>your computer is running free of virus</b><br>";
else
echo"<b><i>your computer has ".($vc)." occurences of virus<br><br>Th e infected files are => <br></b></i>";
$query="SELECT signature, virus, file FROM found";
$result=mysql_q uery($query);$k =1;
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
echo"$k> <b>Signature: </b><i>{$row['signature']}</i><br><b>Virus: </b><i>{$row['virus']}</i><br><b>Name Of The Infected File:</b><i>{$row['file']}</i><br>";
$k++;echo"<br>" ;
}
?>
</p>
<table align="center" cellspacing="0" >
<tr><td><center ><a href="CustomSca n.php">Previous </a></td>
<td><center>< a href="index.php ">Home</a></td>
</tr>
</table>
</body>
</html>
THE CODE=>
<html>
<head><title>Sc an Result</title></head>
<BGSOUND SRC="Windows XP Exclamation.wav ">
<b><font face="Verdana, Arial, Helvetica, sans-serif">Current Directory Contain
Following files and Sub Directories...</font></b>
<p>
<?php
include 'opendb.php';
$found = array();$i=0;
$vc=0;
if(isset($_REQU EST['custom']))
{
$C=$_REQUEST['custom'];
if($C=="")
header('locatio n:CustomScan.ph p?y=You have not enterd appropiate drive name');
else if(!(is_dir($C) ))
header('locatio n:CustomScan.ph p?y=You have not enterd appropiate drive name');
@DirDisply($C);
}
else
header('locatio n:CustomScan.ph p?y=You have not enterd appropiate drive name');
function DirDisply($p)
{
global $found,$vc,$i;
$TrackDir=opend ir($p);
while ($file = readdir($TrackD ir))
{
if ($file == "." || $file == "..")
{
continue;
}
else
{
$n=$p."\\".$fil e;
echo $n."<br>";
$i++;
if (is_dir($n) )
@DirDisply($n);
else
{
if(is_executabl e($n) )
{
$handle=fopen($ n, "rb");
$convert=bin2he x( fread( $handle, filesize($n) ) );
$query="SELECT signature, virus FROM virusdetails";
$result=mysql_q uery($query);
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
$pattern="/"."{$row['signature']}"."/";
$name="{$row['virus']}";
if(preg_match($ pattern,$conver t))
{
$vc++;
$query="INSERT INTO found (signature, virus, file) VALUES ('$pattern', '$name' ,'$n')";
mysql_query($qu ery);
}
}
fclose($handle) ;
pack( "H*", $convert );continue;
}
}
}
}
closedir($Track Dir);
return;
}
echo"<br><br><b r><br><b>SCAN RESULT<br><br>< br>Total files scanned is $i </b><br><br>";
if($vc==0)
echo"<b>your computer is running free of virus</b><br>";
else
echo"<b><i>your computer has ".($vc)." occurences of virus<br><br>Th e infected files are => <br></b></i>";
$query="SELECT signature, virus, file FROM found";
$result=mysql_q uery($query);$k =1;
while($row = mysql_fetch_arr ay($result, MYSQL_ASSOC))
{
echo"$k> <b>Signature: </b><i>{$row['signature']}</i><br><b>Virus: </b><i>{$row['virus']}</i><br><b>Name Of The Infected File:</b><i>{$row['file']}</i><br>";
$k++;echo"<br>" ;
}
?>
</p>
<table align="center" cellspacing="0" >
<tr><td><center ><a href="CustomSca n.php">Previous </a></td>
<td><center>< a href="index.php ">Home</a></td>
</tr>
</table>
</body>
</html>
Comment