home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / myredirect.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  4.6 KB  |  143 lines

  1. MyRedirector 
  2.  
  3. 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 
  4.  
  5.  
  6.  
  7. --------------------------------------------------------------------------------
  8. <? 
  9. ////////////////////////////////////////////////// 
  10. // MyRedirector Version 1.0  
  11. // Redirector 
  12. // redirect.php3 
  13. // Written by Mark Kronsbein 
  14. // License: GPL 
  15. // I only ask that you to NOT delete the credit! 
  16. // Please mail me at mk@html-design.com 
  17. // if you use this Script! Thanx! 
  18. // See it in Action at http://www.gabber.de 
  19. // 
  20. // Installation: 
  21. // Insert your Values for $hostname, $username,  
  22. // $password, $userstable and $dbName and $host. 
  23. // Call it like  
  24. // redirect.php3?url=http://www.hostname.de 
  25. ////////////////////////////////////////////////// 
  26.  
  27. $host =  "http://www.hostname.de/"; 
  28. $hostname =  "localhost"; 
  29. $username =  "your-username"; 
  30. $password =  "your-password"; 
  31. $userstable =  "redirect"; 
  32. $dbName =  "your-db-name"; 
  33.  
  34. if ($url != $host){ 
  35. MYSQL_CONNECT($hostname, $username, $password) OR DIE(mysqlerror()); 
  36. @mysql_select_db(   "$dbName") or die(mysqlerror()); 
  37. $query = mysql_fetch_row(mysql_query(  "select * from $userstable where(url = '$url')")); 
  38.  
  39. if ($query == false){ 
  40. $hits =   "1"; 
  41. $query2 =   "INSERT INTO $userstable (url,hits) VALUES('$url','$hits')"; 
  42. else { 
  43. $hitquery =   "select hits from $userstable where url = '$url'"; 
  44. $result = mysql_query($hitquery); 
  45. $hits = mysql_result($result, 0,   "hits"); 
  46. $query2 =   "update $userstable set hits = hits+1 where url = '$url'"; 
  47.  
  48. MYSQL_QUERY($query2); 
  49. if(!$url) { 
  50. $url =   "$host"; 
  51. else { 
  52.         Header(  "Location: $url"); 
  53. ?> 
  54. <?        
  55. ////////////////////////////////////////////////// 
  56. // MyRedirector Version 1.0  
  57. // Stats-Viewer 
  58. // viewstats.php3 
  59. // Written by Mark Kronsbein 
  60. // License: GPL 
  61. // I only ask that you to NOT delete the credit! 
  62. // Please mail me at mk@html-design.com 
  63. // if you use this Script! Thanx! 
  64. // See it in Action at http://www.gabber.de 
  65. // 
  66. // Installation: 
  67. // Insert your Values for $hostname, $username,  
  68. // $password, $userstable and $dbName. 
  69. ////////////////////////////////////////////////// 
  70.  
  71. $hostname =  "localhost"; 
  72. $username =  "your-username"; 
  73. $password =  "your-password"; 
  74. $userstable =  "redirect"; 
  75. $dbName =  "your-db-name"; 
  76.  
  77. $color10 =  "#FFFF00";  /* Color for Hits between 1 and 9 */ 
  78. $color20 =  "#FF0000";  /* Color for Hits between 10 and 19 */ 
  79. $color50 =  "#008000";  /* Color for Hits between 20 and 49 */ 
  80. $color1k =  "#0000FF";  /* Color for Hits between 50 and 99 */ 
  81. $color2k =  "#0000A0";  /* Color for Hits between 100 and 199 */ 
  82. $color5k =  "#000040";  /* Color for Hits over 200*/    
  83.    
  84. MYSQL_CONNECT($hostname, $username, $password) OR DIE( "Unable to connect to database"); 
  85. @mysql_select_db(  "$dbName") or die(  "Unable to select database"); 
  86. $query =  "select * from $userstable order by hits desc"; 
  87. $result = MYSQL_QUERY($query); 
  88. $number = MYSQL_NUMROWS($result) or die (mysql_error()); 
  89.  
  90. $i = 0; 
  91.  
  92. IF ($number == 0) { 
  93.         PRINT  "<CENTER><P><b>No Links tracked yet!</b></CENTER>"; 
  94. ELSEIF ($number >= 1) { 
  95.         WHILE ($i < $number){ 
  96.                 $hits = mysql_result($result,$i,hits); 
  97.                 $url = mysql_result($result,$i,url); 
  98.                 if ($hits < 10){ 
  99.                 $color =  "$color10"; 
  100.                 } 
  101.                 elseif (($hits >= 10 ) AND ($hits < 20)){ 
  102.                 $color =  "$color20"; 
  103.                 } 
  104.                 elseif (($hits >= 20 ) AND ($hits < 50)){ 
  105.                 $color =  "$color50"; 
  106.                 } 
  107.                 elseif (($hits >= 50 ) AND ($hits < 100)){ 
  108.                 $color =  "$color1k"; 
  109.                 } 
  110.                 elseif (($hits >= 100 ) AND ($hits < 200)){ 
  111.                 $color =  "$color2k"; 
  112.                 } 
  113.                 elseif ($hits >= 200){ 
  114.                 $color =  "$color5k"; 
  115.                 } 
  116.                 PRINT  "<div align=\"left\">"; 
  117.                 print  "<table COLS=3 border=\"0\" width=\"100%\"><tr><td ALIGN=LEFT with=\"400\"><b><a 
  118. href=\"$url\">$url</a></b></td>"; 
  119.                 print  "<td ALIGN=right WIDTH=\"60\"><b>$hits</b></td>"; 
  120.                 print  "<td align=left WIDTH=\"$hits\" BGCOLOR=\"$color\"> </td></tr>"; 
  121.                 $i++; 
  122.                 PRINT  "</table>\n"; 
  123.         } 
  124. ?> 
  125. <? 
  126. # MyRedirect.sql 
  127.  
  128. CREATE TABLE redirect (
  129.    url varchar(100) NOT NULL,
  130.    hits int(10) DEFAULT '0' NOT NULL,
  131.    PRIMARY KEY (url)
  132. );
  133. ?>
  134.