Location: PHPKode > scripts > skad_class > skad_class/skad_class.php
<?

class skad_class {

        // DATABASE VALUES

        var $s_host     = "localhost";                //        host
        var $s_username = "user";                       //        username
        var $s_password = "nb_pass";                   //        password
        var $s_database = "dbyour";                     //        database name
        var $s_table    = "skad_table";                   //        refs table

        // XCLUDE REFERERS
	// add your domain to remove it from statistics

	var $ex_ref = array("lidwin.pl", "tanienotebooki.pl");

	// TOP REFERERS
	var $s_top = 50;

        function skad_class($s_name) {

                $this->s_name = $s_name;
                $this->s_db_link = mysql_connect ($this->s_host, $this->s_username, $this->s_password);
                mysql_select_db ($this->s_database);
        }

        function main() {
                if ($this->is_excluded()) {
                        $this->s_add();
                }
        }

        function is_excluded() {

                $odpow = 1;
                if(!$this->s_name){
                        $odpow=0;
                }

                for($i=0;$i<count($this->ex_ref);$i++){
                        $temp_n = quotemeta($this->ex_ref[$i]);
                        if(eregi($temp_n,$this->s_name)){
                              $odpow = 0;
                        }
                }
                return $odpow;
        }

        function s_add() {
                $dane = eregi_replace ("http://","",$this->s_name);
                $itt = eregi ("^[^/]*", $dane, $zmienna);
                $wynik = $zmienna[0];
                $zap = "SELECT id, przegl FROM $this->s_table WHERE przegl='$wynik'";
                $wykonaj = mysql_query($zap);
                $ilejest = mysql_num_rows($wykonaj);
                if($ilejest){
                        $wiersz = mysql_fetch_array($wykonaj);
                        $zap = "UPDATE $this->s_table SET ile=ile+1 WHERE id='$wiersz[id]'";
                }else{
                        $zap = "INSERT INTO $this->s_table (przegl,ile) VALUES ('$wynik','1')";
                }
                mysql_query($zap);
        }
	function show() {
                $zap = "SELECT id, przegl, ile FROM $this->s_table ORDER BY ile DESC LIMIT 0,$this->s_top";
		$wykonaj = mysql_query($zap);
		$ilejest = mysql_num_rows($wykonaj);
		$i=0;
		echo "<h2 align='center'>Where are you from?</h2><p align='center'></p><br><br>";
		echo "<table align='center' width='400' cellpadding='3' cellspacing='1' bgcolor='#000000'>
			<tr bgcolor='#CCCCCC'><td align='right'>LP.</td><td width='200'>REFERER</td><td>CLIKS</td></tr>";
			while($wiersz = mysql_fetch_array($wykonaj)){
  				$i++;
  				if($i<6){
					echo "<tr bgcolor='#DDDDDD'><td align='right'><h3><font color='blue'>$i.</td>
					      <td><h3><font color='blue'>$wiersz[przegl]</td>
					      <td><h3><font color='blue'>$wiersz[ile]</td></tr>";
  				}else{
  					echo "<tr bgcolor='#DDDDDD'><td align='right'>$i.</td>
					      <td>$wiersz[przegl]</td>
                                              <td>$wiersz[ile]</td></tr>";
  				}
			}
		echo "</table>";
        }
}

?>
Return current item: skad_class