WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : IPTables Bandwidth statics
Categories : PHP, Security, Network Click here to Update Your Picture
Digital Human
Date : Mar 31st 2005
Grade : 3 of 5 (graded 4 times)
Viewed : 11955
File : 4123.zip
Images : No Images for this code example.
Search : More code by Digital Human
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Bandwidth Statics capture tool
Give Apache execude rights to IPTABLES with VISUDO.
apache ALL=(ALL) NOPASSWD: /sbin/iptables

MySQL Database Table

CREATE TABLE `bandwidth`
(
    `uid` INTEGER (11) NOT NULL  AUTO_INCREMENT ,
    `packets` bigint (20),
    `bytes` bigint (20),
    `chain` varchar (50),
    `date` datetime,
    PRIMARY KEY (uid)
) TYPE=MyISAM


<?php
        $x
=1000;
?>
   
    <html>
    <script language=javascript>
    var count = 0;
    var running = true;

    function doRewrite() {
       if (running) {
          count++;
         
          setTimeout("doRewrite()", 1000);
          location.reload();
       }
    }
    </script>
    <body onLoad="setTimeout('doRewrite()', <? echo $x; ?>)">
    </html>

    <?php
   
// MySQL Connection

   
$con = mysql_connect("localhost","root","va654422") or die("Kan niet connecten.");
   
$db = mysql_select_db("stats");

// -v -x -L INPUT

   
$output = exec("sudo iptables -v -x -L INPUT", $in);
   
    echo
$in[0];
   
$input = explode(' ', $in[0]);
    echo
"<pre>";
    echo
"Incomming: ".$input[4]." Packets.";
    echo
"<br>Incomming: ".$input[6]." Bytes.";
    echo
"</pre>";


// -v -x -L OUTPUT

   
$output = exec("sudo iptables -v -x -L OUTPUT", $out);
   
    echo
$out[0];
   
$output = explode(' ', $out[0]);
    echo
"<pre>";
    echo
"Outgoing: ".$output[4]." Packets.";
    echo
"<br>Outgoing: ".$output[6]." Bytes.";
    echo
"</pre>";


// -v -x -L FORWARD

   
$output = exec("sudo iptables -v -x -L FORWARD", $for);
   
    echo
$for[0];
   
$forward = explode(' ', $for[0]);
    echo
"<pre>";
    echo
"Forwarded: ".$forward[4]." Packets.";
    echo
"<br>Forwarded: ".$forward[6]." Bytes.";
    echo
"</pre>";

//-t nat -xv -L PREROUTING

   
$output = exec("sudo iptables -t nat -xv -L PREROUTING", $pre);
   
    echo
$pre[0];
   
$prerouted = explode(' ', $pre[0]);
    echo
"<pre>";
    echo
"Prerouting: ".$prerouted[4]." Packets.";
    echo
"<br>Prerouting: ".$prerouted[6]." Bytes.";
    echo
"</pre>";

//-t nat -xv -L POSTROUTING

   
$output = exec("sudo iptables -t nat -xv -L POSTROUTING", $post);
   
    echo
$post[0];
   
$postrouted = explode(' ', $post[0]);
    echo
"<pre>";
    echo
"Postrouting: ".$postrouted[4]." Packets.";
    echo
"<br>Postrouting: ".$postrouted[6]." Bytes.";
    echo
"</pre>";

// Totaal Input
   
$query = mysql_query("SELECT SUM(bytes) AS TotalInput, Count(date) AS aantalDagen FROM bandwidth WHERE chain='INPUT'");

    while(
$record = mysql_fetch_object($query)){
       
       
$kb = $record->TotalInput / 1048576;

        echo
"<b>Totaal Binnenkomend: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
    }

// Totaal Uitgaand
   
$query = mysql_query("SELECT SUM(bytes) AS TotalOutput, Count(date) AS aantalDagen FROM bandwidth WHERE chain='OUTPUT'");

    while(
$record = mysql_fetch_object($query)){
       
       
$kb = $record->TotalOutput / 1048576;

        echo
"<br><b>Totaal Uitgaand: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
    }

// Totaal Forwarded
   
$query = mysql_query("SELECT SUM(bytes) AS TotalForward, Count(date) AS aantalDagen FROM bandwidth WHERE chain='FORWARD'");

    while(
$record = mysql_fetch_object($query)){
       
       
$kb = $record->TotalForward / 1048576;

        echo
"<br><b>Totaal Forward: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
    }

// Totaal Prerouting
   
$query = mysql_query("SELECT SUM(bytes) AS TotalPrerouting, Count(date) AS aantalDagen FROM bandwidth WHERE chain='PREROUTING'");

    while(
$record = mysql_fetch_object($query)){
       
       
$kb = $record->TotalPrerouting / 1048576;

        echo
"<br><b>Totaal Prerouting: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
    }

// Totaal Postrouting
   
$query = mysql_query("SELECT SUM(bytes) AS TotalPostrouting, Count(date) AS aantalDagen FROM bandwidth WHERE chain='POSTROUTING'");

    while(
$record = mysql_fetch_object($query)){
       
       
$kb = $record->TotalPostrouting / 1048576;

        echo
"<br><b>Totaal Postrouting: ".number_format($kb,2,",",".")." Mb. in ".$record->aantalDagen." dag(en).";
    }


   
mysql_close($con);
?>



A damaged image generator (class) for validating text. CAPTCHA - Completely Automated Public Turing test to tell Computers and Humans Apart
Categories : PHP, PHP Classes, Security, GD image library, Security
Function to generate readable/remeberable random password
Categories : PHP, Security, Security
Random Password Generator
Categories : PHP, Strings, Security
send_mail function to defeat Header Injection Hacking/Spamming
Categories : PHP, Email, Form Processing, Security
Client classes for Dictionary servers UPDATED: 2000-06-06
Categories : Network, Search, Complete Programs, PHP Classes, PHP
Generating and Matching Secure and Strong Password Hash
Categories : PHP, PHP Classes, Cryptography, Security
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
How to query a directory server using LDAP. Keywords: ldap_connect ldap_search
Categories : LDAP, Network, PHP
PHP Cookies - Simple cookie write/read methods that allow basic encryption
Categories : PHP, Cookies, Security, Encryption
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
Function that returns an IP Address if it's correct. IMPROVED!!!
Categories : PHP, Algorithms, Network
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags.
Categories : PHP, PHP Classes, Algorithms, Security
A login page that require username, password and userlevel.
Categories : PHP, Security, Sessions, MySQL, Databases
Distribute PHP Software Protected by a License Key.
Categories : PHP, Cryptography, Security, Software