0

I currently don't have any code to detecting hard driver information. I want to know total disk space, and serial number if possible.


I have worked on getting client's IP ADDRESS, and it worked. The code for detecting IP ADDRESS from the server itself:

<?php

$_SERVER;
echo $_SERVER['SERVER_ADDR'];

?>
i'm PosSible
  • 1,373
  • 2
  • 11
  • 30
  • 2
    Let me see if I understand the question... You want to get a users Hard drive space and serial number from a web request handled by PHP? That's impossible. If you mean finding out disk space on the server itself, thats possible as shown below in the answers. – Tristan Mar 14 '14 at 06:02
  • I'm a new and beginner coder but I believe that detecting hard drive total space with PHP works because one of my teachers is really good at coding. Although, I'm not sure about the serial number... –  Mar 14 '14 at 06:06
  • Duplicate Question http://stackoverflow.com/questions/2425841/how-to-get-the-disk-space-on-a-server – Boopathi Rajan Mar 14 '14 at 06:06
  • There is a huge difference between calculating the hard drive of the system running the PHP code, and the system requesting a url that is processed with PHP. You can get the IP address of a client who requests a page processed with PHP, however retrieving a random clients Hard drive space is not possible with PHP. I don't want random websites knowing how much hard drive space I have, thats personal information! (Sort of...) – Tristan Mar 14 '14 at 06:08
  • What type of information can be detected through a server? –  Mar 14 '14 at 06:14
  • Not much besides information regarding the request. Here is information on what is available to you from the client. http://www.php.net/manual/en/reserved.variables.server.php – Tristan Mar 14 '14 at 06:21

3 Answers3

1

for linux or unix servers use:

disk_total_space("/"); 

This gives you the size of the disk in bytes.

in windows use:

disk_total_space("C:");

Replace C: by the relevant drive symbol. This also gives you the size of the drive in bytes

Note: disk_free_space("/") in linux/unix or disk_free_space("drive letter:") in windows gives you the disk free space.

From the above two you can calculate the disk space used.

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33
Bobby
  • 268
  • 1
  • 7
0

The simplest way to get the visitor’s/client’s ipaddress is using the $_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables.

However, sometimes this does not returns the correct ipaddress of the visitor, so we can use some other server variables to get the ipaddress.

getenv() is used to get the value of an environment variable in PHP

to get free disk space

echo disk_free_space("C:");

for more reference: link here

to get total disk space

echo disk_total_space("C:");

for more reference: link here

i'm PosSible
  • 1,373
  • 2
  • 11
  • 30
  • -1 because your code gives the info about server while the question is asked about the client hard drive info, I don't understand why this answer is accepted ?? – Hirdesh Vishwdewa Aug 03 '16 at 06:52
  • @easycoder `disk_free_space()` work both side, see the question problem is to check hardisk total space. – i'm PosSible Aug 05 '16 at 06:11
0

PHP is a server sided language and it wont be able to "get" information from the clients machine, because its architecture prohibits it. Since it is usually running in the DOM; all that it can do is query(if you will) the browser for the referer or user_agent, but that will just tell you, browser version, OS type, etc. Just simple information about the client. If you want to dig deeper you will need to go JS(old fashion); then you can design(write) an applet that will dig that information out for you. The reason why this approach will work is simply because JS is already installed on the client machines(>90% probability) and then you can have the JS applet give you the goods. You can add some AS3 to a flash file and have that collect the data for you, however, it will be limited information.

  • When you said dig deeper, I got excited. Like is JS used to dig information through a server? I have many more questions. –  Mar 14 '14 at 06:22
  • If you create a java applet, once a client visits your site it will ask them to install it on their system, once that is done. whatever code you wrote on the applet will be executed in the client(there are a few safe guards against maliciousness though, so unfortunately no free rein) Once that happens you can use js to pull the information you want from the client, disk size, folder structure, etc... As for the serial # of their HD, well that is a bit too deep for JS to go. but you can get a good deal of other information. – user2975403 Mar 14 '14 at 06:33
  • Will I be able to grab their keystrokes information? More like a trojan site. –  Mar 14 '14 at 08:33