473,657 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

facing a strange problem...

nabanita
9 New Member
in order to scan the complete C drive i wrote a code it is scanning almost all the folders completely however it is leaving out some which can be easily (seperately) opened and sacnned using the same code........... ............... ...........

the code used is pasted below, please suggest me how to rectify my code to solve the problem and go through all the folders not some!




Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. function DirDisply($p) 
  3.          $TrackDir=opendir($p); 
  4.          while ($file = readdir($TrackDir)) 
  5.          { 
  6.                      if ($file == "." || $file == "..") { } 
  7.                      else  
  8.                      {
  9.                             //print "<table><tr><td>$file</td>";
  10.                             //print "<td>  ".filetype($file)."</td></tr></table>"; 
  11.                             $n=$p."\\".$file; //echo"<br>$n<br>";        
  12.                             if( opendir($n) ) {@ DirDisply($n);}                     
  13.                             else 
  14.                             {
  15.                                if(is_executable($file) )
  16.                                {
  17.                                  $handle=fopen($file, "rb");
  18.                                  echo("$file");
  19.                                  $convert=bin2hex( fread( $handle, filesize($file) ) );
  20.                                  $pattern="/a900003000000040/";
  21.                                  if(preg_match($pattern, $convert))
  22.                                  {
  23.                                         echo"<b><i>VIRUS DETECTED<br></b></i>";
  24.                                  }
  25.                                  else
  26.                                         echo"YOUR COMPUTER IS RUNNING FREE OF VIRUSES";
  27.  
  28.                                  pack( "H*", $convert );
  29.                                  fclose($handle); 
  30.                                }
  31.                             }
  32.                      } 
  33.          } 
  34.          closedir($TrackDir); 
  35.          return; 
  36. ?>
  37.  
  38. <b><font face="Verdana, Arial, Helvetica, sans-serif">Current Directory Contain 
  39. Following files and Sub Directories...</font></b> 
  40. <p> 
  41.  
  42. <?php 
  43.  
  44. $p="C:";
  45. @ DirDisply($p); 
  46. ?>
Apr 3 '10 #1
2 1150
Atli
5,058 Recognized Expert Expert
Hey.

Do you have error_reporting set so that it displays errors? (See Turn on PHP Debugging Messages.)

You should also remove the @ on line 13. It could be hiding the error that is causing this.
Apr 5 '10 #2
philipwayne
50 New Member
I believe your problem is

Expand|Select|Wrap|Line Numbers
  1. $n=$p."\\".$file;
  2.  if( opendir($n) ) {@ DirDisply($n);}
  3.  
When going through the file system use forward slashes as there native to most if not all machines. /
I wouldn't use opendir( ) to test it, use is_dir( ).

But the reason this is failing is that PHP probably doesn't have permission to access folders like System32 or even Windows.
Correct permissions and probably correct the problem.
Just navigate to the php.exe [right click->properties-> compatibility-> privilege level->run as administrator], Note HUGE risk

Also I wanted to point out a few things.

1: your reverting the hexadecimal content but doing nothing with it?
Expand|Select|Wrap|Line Numbers
  1. pack( "H*", $convert );
  2.  
2: Your evaluating an expression for no reason other then wasting time.
Instead of
Expand|Select|Wrap|Line Numbers
  1. if ($file == "." || $file == "..") { } 
  2. else {
  3.  
Use
Expand|Select|Wrap|Line Numbers
  1. if ($file != "." && $file != "..") { 
  2.  
3: You function uses the return statement but nothing is returned. The only time this really should be done if you need to break out of the function return; is still wasting resources theres no need for it.
Apr 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1398
by: Jitendra Shinde | last post by:
I am facing a problem on Session. Firstly i am getting log in the application and woring with my some windows. now keeping that other window open and now from that main window i am logging out. so it throws me to the login page (as i am logged out). I am also clearing and abandoning the session. also with the FromsAuthentication.SignOut().
2
1268
by: hussein_hariri | last post by:
hello i have started working bye ASP.net but i'm facing a small problem. i'm trying to get the name of the user who logedon to the opersating system , i got the computer name, server name, domain name, and the name of the user who started the studio.net { ASPNET }. but the one who logged on to the operating system i was not able to so any one can help me? thank you for responding
1
1894
by: santoshborfalkar | last post by:
This is the Trigger which is not working properly during Update, no any record is going to be updated so pls help. I am updating the requisition table when any update in quantity in podetails table CREATE TRIGGER trig_updateRequistion ON ERP.DBO.TranPurchaseOrderDetail INSTEAD OF UPDATE
18
2090
by: Vijaykumar Dave | last post by:
I have a program for base X power N as under. The problem is that when the range specified in loop is given it works well, but when any character is pressed, it goes to infinite loop. Second problem is it works fine for smaller value of X or N but not for higher say base 15 power 20. How can I get true value displayed with such higher base or power.? Can any one help me to correct this program putting proper loop and for high value...
5
5460
by: CBidwill | last post by:
Hello, I'm a ASP.NET developer with a little experience in IIS but I'm having difficulties getting a little ASP.NET application I wrote up on my home intranet. Here's the details: - I can view the site fine where the application is hosted by browsing http://<machine name>/<application virtual directory> - When going to http://<machine name>/<application virtual directory> on a remote computer, I get paged cannot be displayed. - From the...
3
2247
by: yassinsearch | last post by:
Hi , I am facing problem text direction.(for HEBREW lanaguage) By default the direction of text field is Left to Rignt. Any SRW methods is available to set the reading direction from Right to Left at the field level in the oracle Report ver :10.1.2.0.2. For more clear understand i have attached the screen shot , Note : In FORM we have implemented , problem we are facing in the Reports.
2
2897
by: apoorva.groups | last post by:
Hi I am facing problem while using regexec function. Ex: String = "abc_def_hig" sub string = "def" regexc if I use regexec the it will find the sub string in string and it will return 0. I want to modify the sub string such that it matches only if the
0
1124
by: Dhananjay | last post by:
hi all, I am facing problem in programming.Can anybody please let me know how to solve the problem. I have a link, clicking the link opens a page in which there are some data which is coming from different tables(join realtionship). And some data has to be inserted in that page(textbox) In this page i have 2 buttons send and save. On clicking send button the page content will be sent to the particular email-id. And on clicking save...
0
1302
by: Niks | last post by:
I am facing a very strange problem in my websevice which is working on socket communication. While i am publishing my webservice to the IIS and invoking a method, a data loss problem in occuring. I seems strange because when i am using the .net framework's inbuild application development server that comes along with 2.0 framework,I am not facing this problem. I dont know why it is not working with IIS while it is working with other...
27
17672
by: davidson1 | last post by:
Hai friends..... I am using Compaq Laptop..I used to hear songs most of the time...but suddenly when i open the Windows Media Player to hear the songs..it is not singing..but gives me the following error.... Windows Media Player cannot play the file because there is a problem with your sound device. There might not be a sound device installed on your computer, it might be in use by another program, or it might not be functioning properly....
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.