home *** CD-ROM | disk | FTP | other *** search
Wrap
MyRedirector MyRedirector is a Redirector with graphical Statistics The Following Files are included: redirector.php3 The Redirector viewstats.php3 The Statistic-File MyRedirect.sql MySQL-Dump -------------------------------------------------------------------------------- <? ////////////////////////////////////////////////// // MyRedirector Version 1.0 // Redirector // redirect.php3 // Written by Mark Kronsbein // License: GPL // I only ask that you to NOT delete the credit! // Please mail me at mk@html-design.com // if you use this Script! Thanx! // See it in Action at http://www.gabber.de // // Installation: // Insert your Values for $hostname, $username, // $password, $userstable and $dbName and $host. // Call it like // redirect.php3?url=http://www.hostname.de ////////////////////////////////////////////////// $host = "http://www.hostname.de/"; $hostname = "localhost"; $username = "your-username"; $password = "your-password"; $userstable = "redirect"; $dbName = "your-db-name"; if ($url != $host){ MYSQL_CONNECT($hostname, $username, $password) OR DIE(mysqlerror()); @mysql_select_db( "$dbName") or die(mysqlerror()); $query = mysql_fetch_row(mysql_query( "select * from $userstable where(url = '$url')")); if ($query == false){ $hits = "1"; $query2 = "INSERT INTO $userstable (url,hits) VALUES('$url','$hits')"; } else { $hitquery = "select hits from $userstable where url = '$url'"; $result = mysql_query($hitquery); $hits = mysql_result($result, 0, "hits"); $query2 = "update $userstable set hits = hits+1 where url = '$url'"; } MYSQL_QUERY($query2); } if(!$url) { $url = "$host"; } else { Header( "Location: $url"); } ?> <? ////////////////////////////////////////////////// // MyRedirector Version 1.0 // Stats-Viewer // viewstats.php3 // Written by Mark Kronsbein // License: GPL // I only ask that you to NOT delete the credit! // Please mail me at mk@html-design.com // if you use this Script! Thanx! // See it in Action at http://www.gabber.de // // Installation: // Insert your Values for $hostname, $username, // $password, $userstable and $dbName. ////////////////////////////////////////////////// $hostname = "localhost"; $username = "your-username"; $password = "your-password"; $userstable = "redirect"; $dbName = "your-db-name"; $color10 = "#FFFF00"; /* Color for Hits between 1 and 9 */ $color20 = "#FF0000"; /* Color for Hits between 10 and 19 */ $color50 = "#008000"; /* Color for Hits between 20 and 49 */ $color1k = "#0000FF"; /* Color for Hits between 50 and 99 */ $color2k = "#0000A0"; /* Color for Hits between 100 and 199 */ $color5k = "#000040"; /* Color for Hits over 200*/ MYSQL_CONNECT($hostname, $username, $password) OR DIE( "Unable to connect to database"); @mysql_select_db( "$dbName") or die( "Unable to select database"); $query = "select * from $userstable order by hits desc"; $result = MYSQL_QUERY($query); $number = MYSQL_NUMROWS($result) or die (mysql_error()); $i = 0; IF ($number == 0) { PRINT "<CENTER><P><b>No Links tracked yet!</b></CENTER>"; } ELSEIF ($number >= 1) { WHILE ($i < $number){ $hits = mysql_result($result,$i,hits); $url = mysql_result($result,$i,url); if ($hits < 10){ $color = "$color10"; } elseif (($hits >= 10 ) AND ($hits < 20)){ $color = "$color20"; } elseif (($hits >= 20 ) AND ($hits < 50)){ $color = "$color50"; } elseif (($hits >= 50 ) AND ($hits < 100)){ $color = "$color1k"; } elseif (($hits >= 100 ) AND ($hits < 200)){ $color = "$color2k"; } elseif ($hits >= 200){ $color = "$color5k"; } PRINT "<div align=\"left\">"; print "<table COLS=3 border=\"0\" width=\"100%\"><tr><td ALIGN=LEFT with=\"400\"><b><a href=\"$url\">$url</a></b></td>"; print "<td ALIGN=right WIDTH=\"60\"><b>$hits</b></td>"; print "<td align=left WIDTH=\"$hits\" BGCOLOR=\"$color\"> </td></tr>"; $i++; PRINT "</table>\n"; } } ?> <? # # MyRedirect.sql # CREATE TABLE redirect ( url varchar(100) NOT NULL, hits int(10) DEFAULT '0' NOT NULL, PRIMARY KEY (url) ); ?>