Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 6.9
Author Message
TheosEleos
Life Cycles Becoming CPU Cycles



Joined: Sep 18, 2003
Posts: 960
Location: Missouri

PostPosted: Sat Jan 24, 2004 8:34 am Reply with quote

I would like a simple script that will tell me how much space is left on the server.

I have a lot of ftp users and I would like for them to be able to see how much space is left on the server. I really don't want everyone logging in to cpanel.

If I could make it a module I can protect it with Protector System or something.

Can this be done?

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website AIM Address ICQ Number
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Sat Jan 24, 2004 9:45 am Reply with quote

Check this link for all kinds of tools for server management http://www.hotscripts.com/PHP/Scripts_and_Programs/Server_Management/index.html .
 
View user's profile Send private message
TheosEleos







PostPosted: Sun Jan 25, 2004 1:36 pm Reply with quote

I found something but am having a hard time converting it to a module. I get this after I enter a password, doesn't matter if the password is right or wrong.


Quote:
Sorry, you can't access this file directly...


Here is the module I created.

http://www.phenylshouse.com/members/prophet/Diskspace.zip
 
chatserv
Member Emeritus



Joined: May 02, 2003
Posts: 1389
Location: Puerto Rico

PostPosted: Sun Jan 25, 2004 10:54 pm Reply with quote

Change diskspace.php to:
Code:
<?

#####################################################################
#  DiskSpace 0,23
#  Released under the terms of the GNU General Public License.
#  Please refer to the README file for more information.
#####################################################################

#####################################################################
# PLEASE EDIT THE FOLLOWING VARIABLES:
#####################################################################

# Please choose a language file:
$languageFile = "./modules/Diskspace/language_files/english.php";

# Your home directory on the server. Check the README file if you
# don't know how to find your home directory.
$user_home = "/home/ph/public_html";

# The available hard disk space for your user on the server --
# measured in megabytes.
$available_space = "1500";

# Choose a password. You will have to enter this password when you
# view DiskSpace in a browser.
$password = "test";

#####################################################################
# THAT'S IT! NO MORE EDITING NECESSARY.
#####################################################################



require($languageFile);

exec("du -s $user_home", $du);   # This will output something like "3383    /home/user"
$brugtplads = split(" ", $du[0]);

$brugtplads = $brugtplads[0] / 1024;
$pladstilbage = $available_space - $brugtplads;

$p = $available_space / 100;
$p_brugtplads = round($brugtplads / $p);
$p_pladstilbage = round($pladstilbage / $p);

$bredde_brugt = $p_brugtplads * 3;   # This is used as the "width" attribute in the "<img>" tag.
$bredde_tilbage = $p_pladstilbage * 3;   # This is used as the "width" attribute in the "<img>" tag.

function afrunding($tal) {
        global $module_name;
   if (ereg("\.", $tal)) {               # Example: $tal = 12.2547821
      $tal = split("\.", $tal);         # $tal[0] = 12 and $tal[1] = 2547821
      $tal[1] = substr($tal[1], 0, 2);      # $tal[1] = 25
      $ciffer1 = substr($tal[1], 0, 1);      # $ciffer1 = 2
      $ciffer2 = substr($tal[1], 1, 2);      # $ciffer2 = 5
      if ($ciffer2 >= 5) $ciffer1 = $ciffer1 + 1;   # $ciffer1 now becomes 3
      $tal = "$tal[0].$ciffer1";         # $tal is now 12.3
   }
   return $tal;
}



echo "<html><head><title>DiskSpace</title>\n";
echo "<style type=text/css><!--\n";
echo "body {background:white; font-family:lucida,helvetica}\n";
echo "--></style>\n";
echo "</head>\n";
include("header.php");

if (!$adgangskode) {
   OpenTable();
   echo "<body onLoad=document.forms[0].adgangskode.focus()>\n";
   echo "<form action=modules.php?name=$module_name&amp;file=diskspace method=post>\n";
   echo "$l1<br>\n";
   echo "<input type=text name=adgangskode size=20>\n";
   echo "<input type=submit value=\"$l9\">\n";
   echo "</form>\n";
   echo "</body></html>";
   CloseTable();
}

if ($adgangskode && $adgangskode != $password) {
   OpenTable();
   echo "<body>\n";
   echo "<h2>$l2</h2>\n";
   echo "</body></html>";
   CloseTable();
}

if ($adgangskode == $password) {
   OpenTable();
   echo "<body>\n";
   echo "<h2>$l3</h2>\n";
   echo "<img src=image.gif height=20 width=$bredde_brugt alt=\"$l4: $p_brugtplads$l7\">";
   echo "<img src=image_gray.gif height=20 width=$bredde_tilbage alt=\"$l5: $p_pladstilbage$l7\"><p>\n";

   echo "<img src=image.gif height=20 width=10 alt=\"$l6\"><img src=image_gray.gif height=20 width=10 alt=\"$l6\">\n";
   echo "$l6: $available_space $l8 (100$l7)<p>\n";
   echo "<img src=image.gif height=20 width=20 alt=\"$l4\">\n";
   echo "$l4: ".afrunding($brugtplads)." $l8 ($p_brugtplads$l7)<p>\n";
   echo "<img src=image_gray.gif height=20 width=20 alt=\"$l5\">\n";
   echo "$l5: ".afrunding($pladstilbage)." $l8 ($p_pladstilbage$l7)\n";

   echo "</body></html>";
   CloseTable();
}
include("footer.php");
?>

and index.php to:
Code:
<?php

        if (!eregi("modules.php", $PHP_SELF)) die ("You can't access this file directly...");

        $module_name = basename(dirname(__FILE__));
        require_once("mainfile.php");
        $pagetitle = "- Available Space";
        global $module_name;

        include("modules/$module_name/diskspace.php");

?>
 
View user's profile Send private message Visit poster's website
TheosEleos







PostPosted: Sun Jan 25, 2004 11:34 pm Reply with quote

That worked perfect. Can you help me with the images? They didn't work at all.

Thanks for your time, chatserv.
 
TheosEleos







PostPosted: Sun Jan 25, 2004 11:38 pm Reply with quote

I figured it out.

Thanks again. Very Happy
 
chatserv







PostPosted: Sun Jan 25, 2004 11:54 pm Reply with quote

Wink
 
Display posts from previous:       
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Ravens PHP Scripts And Web Hosting Forum Index -> phpnuke 6.9

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©