Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    NEED HELP about disk_free_space and disk_total_space


    sir how can i see others disk space or total disk space in network
    using php sir.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    In network?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0

    hard disk space.


    Originally Posted by ManiacDan
    In network?
    yes sir in network sir.....
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Originally Posted by p_grahambel
    yes sir in network sir.....
    Off topic: This is not the military, you don't need to end every sentence with "Sir". Is this common in India? I've noticed it quite often, and I find it rather weird to be called either "Sir" or "dear".
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by Jacques1
    Off topic: This is not the military, you don't need to end every sentence with "Sir". Is this common in India? I've noticed it quite often, and I find it rather weird to be called either "Sir" or "dear".
    OK DEAR
    SO YOU have any comment here? abt finding disk space or total space in network?

    Comments on this post

    • Jacques1 agrees : *lol* I didn't say you should call everybody "dear" now. That's weird. You say that to your sweetheart, but not random people on the internet. ;-)
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by ManiacDan
    In network?

    PHP Code:


    yes in network dear.. im using switch and a server and i want to get there hardisk space and total space my dear.. any ideas?


    <?php

    $hostname 
    gethostbyaddr("192.168.100.10");

    function 
    ping($hostname$port$timeout)
    {
      
    $tB microtime(true);
      
    $fP fSockOpen($hostname$port$errno$errstr$timeout);


      if (!
    $fP) { return "off"; }
      
    $tA microtime(true);
      return 
    round((($tA $tB) * 1000), 0)." ms";


    }



    echo 
    ping ("$hostname",80,10);





    $df disk_free_space("D:");
    $df2 disk_free_space("C:");

    $dt =  disk_total_space("D:");
    $dt2 disk_total_space("C:");

    $du $dt $df;
    $du2 $dt2 $df2;

    $dp sprintf('%.2f',($du $dt) * 100);
    $dp2 sprintf('%.2f',($du2 $dt2) * 100);

    $df formatSize($df);
    $du formatSize($du);
    $dt formatSize($dt);
    $df2 formatSize($df2);
    $du2 formatSize($du2);
    $dt2 formatSize($dt2);


        function 
    formatSize$bytes )
        {
                
    $types = array( 'B''KB''MB''GB''TB' );
                for( 
    $i 0$bytes >= 1024 && $i < ( count$types ) -); $bytes /=1024$i++ );
                        return( 
    round$bytes) . " " $types[$i] );
        }
    ?>
    <style type='text/css'>

        .progress {
                border: 2px solid #5E96E4;
            height: 32px;
                width: 540px;
                margin: 75px auto;
        }

        .progress .prgbar {
             background: Gold;
            width: <?php echo "$dp;" ?>%;
            position: relative;
            height: 32px;
            z-index: 999;
        }
            .progress .prgbar2 {
             background: Gold;
            width: <?php echo "$dp2;" ?>%;
            position: relative;
            height: 32px;
            z-index: 999;
        }

        .progress .prgtext {
                color: white;
                text-align: center;
                font-size: 15px;
                padding: 9px 0 0;
                width: 540px;
                position: absolute;
                z-index: 1000;
        }
        .progress .prginfo {
                margin: 3px 0;
        }



        </style>


    </head>

    <body bgcolor = "white">


        <div class='progress'>
            <div class='prgtext'><?php echo $dp?>% Disk Used of <?php echo " ".$dt?>
            </div>
            <div class='prgbar'></div>
                <div class='prginfo'>
                        <span style='float: left;'><?php echo "Drive D:"?></br>
                                                    <?php echo "$du used space of $dt"?></br>
                                                   <?php echo "$df free space of $dt"?></br>


                        </span>


                    <span style='clear: both;'></span>
                </div>
        </div>


            <div class='progress'>
            <div class='prgtext'><?php echo $dp2?>% Disk Used of <?php echo " ".$dt2?>
            </div>
            <div class='prgbar2'></div>
                <div class='prginfo'>
                        <span style='float: left;'><?php echo "Drive C:"?></br>
                                                    <?php echo "$du2 used space of $dt2"?></br>
                                                   <?php echo "$df2 free space of $dt2"?></br>


                        </span>


                    <span style='clear: both;'></span>
                </div>
        </div>

    </html>
    </body>
  12. #7
  13. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    disk_free_space will not work on remote files (ie: over a network).

    You need the support of some other network protocol to make this happen. For example:
    - if each machine on the network has a web server on it, you can host a file on that web server which returns the free disk space when called
    - if each machine on the network is running an ssh server, you can connect over ssh, then run a manual command like "df -h" (on Linux)
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by E-Oreo
    disk_free_space will not work on remote files (ie: over a network).

    You need the support of some other network protocol to make this happen. For example:
    - if each machine on the network has a web server on it, you can host a file on that web server which returns the free disk space when called
    then is there a php code for that sir?
  16. #9
  17. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    PHP code could be written to do it, however I have not written it.

    If you wish to take the HTTP approach then the process is not that difficult.

    You need to deploy a script to each server does something like construct an array of filesystem space (assuming you have more than one filesystem) and then echo's the array using something like serialize or json_encode to encode the array as a string.

    Then on your "central" server, you can issue an HTTP request using file_get_contents to each of the servers and request the URL of the script that you deployed to each server. Then you can unserialize or json_decode the response and do whatever you wish with it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by E-Oreo
    PHP code could be written to do it, however I have not written it.

    If you wish to take the HTTP approach then the process is not that difficult.

    You need to deploy a script to each server does something like construct an array of filesystem space (assuming you have more than one filesystem) and then echo's the array using something like serialize or json_encode to encode the array as a string.

    Then on your "central" server, you can issue an HTTP request using file_get_contents to each of the servers and request the URL of the script that you deployed to each server. Then you can unserialize or json_decode the response and do whatever you wish with it.




    ahahah i didnt get it..... but my point is when u ping an ip address in the localhost in a php style format hmmmm can it be posible to get his total space? nor free space?

    here is my code but it can only specify my own drive in my computer

    [PHPNET]

    <html>
    <body>


    <?php

    $hostname = gethostbyaddr("192.168.100.10");

    function ping($hostname, $port, $timeout)
    {
    $tB = microtime(true);
    $fP = fSockOpen($hostname, $port, $errno, $errstr, $timeout);


    if (!$fP) { return "off"; }
    $tA = microtime(true);
    return round((($tA - $tB) * 1000), 0)." ms";


    }



    echo ping ("$hostname",80,10);





    $df = disk_free_space("D:");
    $df2 = disk_free_space("C:");

    $dt = disk_total_space("D:");
    $dt2 = disk_total_space("C:");

    $du = $dt - $df;
    $du2 = $dt2 - $df2;

    $dp = sprintf('%.2f',($du / $dt) * 100);
    $dp2 = sprintf('%.2f',($du2 / $dt2) * 100);

    $df = formatSize($df);
    $du = formatSize($du);
    $dt = formatSize($dt);
    $df2 = formatSize($df2);
    $du2 = formatSize($du2);
    $dt2 = formatSize($dt2);


    function formatSize( $bytes )
    {
    $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
    for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /=1024, $i++ );
    return( round( $bytes, 2 ) . " " . $types[$i] );
    }
    ?>
    <style type='text/css'>

    .progress {
    border: 2px solid #5E96E4;
    height: 32px;
    width: 540px;
    margin: 75px auto;
    }

    .progress .prgbar {
    background: Gold;
    width: <?php echo "$dp;" ?>%;
    position: relative;
    height: 32px;
    z-index: 999;
    }
    .progress .prgbar2 {
    background: Gold;
    width: <?php echo "$dp2;" ?>%;
    position: relative;
    height: 32px;
    z-index: 999;
    }

    .progress .prgtext {
    color: white;
    text-align: center;
    font-size: 15px;
    padding: 9px 0 0;
    width: 540px;
    position: absolute;
    z-index: 1000;
    }
    .progress .prginfo {
    margin: 3px 0;
    }



    </style>


    </head>

    <body bgcolor = "white">


    <div class='progress'>
    <div class='prgtext'><?php echo $dp; ?>% Disk Used of <?php echo " ".$dt; ?>
    </div>
    <div class='prgbar'></div>
    <div class='prginfo'>
    <span style='float: left;'><?php echo "Drive D:"; ?></br>
    <?php echo "$du used space of $dt"; ?></br>
    <?php echo "$df free space of $dt"; ?></br>


    </span>


    <span style='clear: both;'></span>
    </div>
    </div>


    <div class='progress'>
    <div class='prgtext'><?php echo $dp2; ?>% Disk Used of <?php echo " ".$dt2; ?>
    </div>
    <div class='prgbar2'></div>
    <div class='prginfo'>
    <span style='float: left;'><?php echo "Drive C:"; ?></br>
    <?php echo "$du2 used space of $dt2"; ?></br>
    <?php echo "$df2 free space of $dt2"; ?></br>


    </span>


    <span style='clear: both;'></span>
    </div>
    </div>

    </html>
    </body>

    [/PHPNET]
  20. #11
  21. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    disk_free_space only allows you to specify a drive in your own computer. Neither disk_free_space nor any other functions allow you to specify a drive that is not in your own computer.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by E-Oreo
    disk_free_space only allows you to specify a drive in your own computer. Neither disk_free_space nor any other functions allow you to specify a drive that is not in your own computer.

    how? wut function? fsocket?
  24. #13
  25. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    PHP does not have a function that does what you want.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    14
    Rep Power
    0
    Originally Posted by E-Oreo
    PHP does not have a function that does what you want.
    awts.... then what can i do? then what programming languages that have that function?
  28. #15
  29. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Dearest p_grahambel, E-Oreo gave you two possible solutions. Use them.

    If you ignore solutions just because you don't understand them yet, you won't go very far.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo