home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / php.exe / CodeLib.php < prev    next >
Encoding:
Text File  |  2001-07-03  |  5.2 KB  |  164 lines

  1. //**************************************
  2.     //     
  3.     // Name: CodeLib
  4.     // Description:This is a group of functi
  5.     //     ons I wrote so I didn't have to write th
  6.     //     ings over and over in an HTML file..
  7.     // By: Dennis Wrenn
  8.     //
  9.     //This code is copyrighted and has    // limited warranties.Please see http://
  10.     //     www.Planet-Source-Code.com/xq/ASP/txtCod
  11.     //     eId.243/lngWId.8/qx/vb/scripts/ShowCode.
  12.     //     htm    //for details.    //**************************************
  13.     //     
  14.     
  15.     <?
  16.     //#############################COUNTER F
  17.     //     UNCTIONS#############################\\
  18.     //create a directory called hits in your
  19.     //     
  20.     //main directory
  21.     function gethits($logpath) {
  22.         $hits = 0;
  23.         $logpath = "./hits/".$logpath.".hits";
  24.         If (file_exists($logpath)) {
  25.             $filenum = fopen($logpath,"r");
  26.             if ($filenum > 0) {
  27.                 $filesize = filesize($logpath);
  28.                 $hits = fread($filenum,$filesize+1);
  29.                 fclose($filenum);
  30.             }
  31.         } else {
  32.             $filenum = fopen($logpath,"w");
  33.             fwrite($filenum,$hits);
  34.             fclose($filenum);
  35.         }
  36.         return $hits;
  37.     }
  38.     function addhit($logpath) {
  39.         $hits = 0;
  40.         $logpath = "./hits/".$logpath.".hits";
  41.         If (file_exists($logpath)) {
  42.             $filenum = fopen($logpath,"r");
  43.             if ($filenum > 0) {
  44.                 //Get the current file hit count
  45.                 $filesize = filesize($logpath);
  46.                 $hits = fread($filenum,$filesize);
  47.                 fclose($filenum);
  48.                 //Increment the hit counter
  49.                 $hits++;
  50.                 $filenum = fopen($logpath,"w");
  51.                 fwrite($filenum,$hits);
  52.                 fclose($filenum);
  53.             }
  54.         }else{
  55.             $hits++;
  56.             $filenum = fopen($logpath,"w");
  57.             fwrite($filenum,$hits);
  58.             fclose($filenum);
  59.         }
  60.         return;
  61.     }
  62.     //#############################IP FUNCTI
  63.     //     ONS#############################\\
  64.     //logs IP for forums and stuff like that
  65.     //     
  66.     function logip($path) {
  67.         global $REMOTE_ADDR;
  68.         writetolog($path, "$REMOTE_ADDR*\n");
  69.     }
  70.     function parseips($ips) {
  71.         return str_replace("*", "<BR>", $ips);
  72.     }
  73.     //#############################FILE FUNC
  74.     //     TIONS#############################\\
  75.     //for logip functions, and others I will
  76.     //     soon write
  77.     function writetolog($logfile, $texttowrite) {
  78.         $filenum = fopen($logfile,"a");
  79.         fwrite($filenum,$texttowrite);
  80.         fclose($filenum);
  81.     }
  82.     function openfile($path) {
  83.     if(file_exists($path) == 0) {
  84.     return "";
  85.     }
  86.     else
  87.     {
  88.     $thefilesize = filesize($path);
  89.     $filenum = fopen($path,"r");
  90.     $filecontent = fread($filenum, $thefilesize+1);
  91.     fclose($filenum);
  92.     return $filecontent;
  93.     }
  94.     }
  95.     //#############################HEADER AN
  96.     //     D FOOTER#############################\\
  97.     //use like this:
  98.     //showheader("title","path");
  99.     function showheader($title, $path) {
  100.         $link = ; //link color
  101.         $alink = ; //active link color
  102.         $vlink = ; //visited link color
  103.         $bgcolor = ; // BG color
  104.         $text = ; // textcolor
  105.         addhit($path);
  106.         echo "<HTML>\n";
  107.         echo "<HEAD>\n";
  108.         echo "<TITLE>$title</TITLE>\n";
  109.         echo "<HEAD>\n";
  110.         echo "<BODY BGCOLOR=$bgcolor TEXT=$text LINK=$link ALINK=$alink VLINK=$vlink>\n";
  111.         echo "<FONT FACE=\"Arial\" SIZE=2>\n";
  112.         showsidebar($title);
  113.             
  114.         echo "<BR>\n";
  115.     }
  116.     function showfooter($path) {
  117.         echo "<P>\n";
  118.         echo "<BR>\n";
  119.         echo "<CENTER>";
  120.         echo "<FONT COLOR=\"#0000FF\" SIZE=2>\n";
  121.         echo "There have been <B>";
  122.         echo gethits($path);
  123.         echo "</B> visitors to this page since 12/19/2000 <BR>\n";
  124.         echo "Copyright ⌐ 2000 Your Name ";
  125.         echo "All rights reserved <BR> \n";
  126.         echo "</FONT>\n";
  127.         echo "</TD>\n</TR>\n</TABLE>\n";
  128.         echo "</CENTER>\n";
  129.         echo "</FONT>\n";
  130.         echo "</BODY>\n</HTML>";
  131.     }
  132.     function showsidebar($title) {
  133.     //look at screenshot, and change what yo
  134.     //     u need.
  135.         echo "<TABLE BORDER=3 BORDERCOLOR=\"#336699\" WIDTH=100% HEIGHT=100% CELLPADDING=\"20\" CELLSPACING=0>\n";
  136.         echo "<TR>\n<TD WIDTH=15% BGCOLOR=\"#336699\" VALIGN=\"CENTER\" ALIGN=\"CENTER\"><IMG SRC=\"images/dw.gif\"></TD>";
  137.         echo "<TD WIDTH=85% BGCOLOR=\"#336699\" VALIGN=\"CENTER\" ALIGN=\"CENTER\">";
  138.         echo "<FONT COLOR=\"#FFFFFF\">\n";
  139.         showtitle($title);
  140.         echo "</FONT>\n";
  141.         echo "<TR>\n<TD WIDTH=15% BGCOLOR=\"#336699\" VALIGN=\"TOP\" ALIGN=\"CENTER\">";
  142.     //create a file called sidebar.txt
  143.     //and put some links in there. It 
  144.     //must be in HTML format.EG:
  145.     //<A HREF="link1.htm">Link1</A&
  146.     //     gt;<BR>
  147.     //<A HREF="link2.htm">link2</A&
  148.     //     gt;<BR>
  149.     //etc
  150.     //be sure to leave a blank line at the t
  151.     //     op of the
  152.     //file.
  153.         $file = openfile("sidebar.txt");
  154.         echo "$file";
  155.         echo "</TD>\n<TD WIDTH=85% VALIGN=\"TOP\" ALIGN=\"LEFT\">";
  156.     }
  157.     function showtitle($title) {
  158.         echo "\n<H1><CENTER>$title</CENTER></H1>\n";
  159.     }
  160.     function showsubtitle($stitle,$size=2) {
  161.         echo "<FONT COLOR=\"#0000FF\">\n<H$size><CENTER>$stitle</CENTER></H$size>\n</FONT>";
  162.     }
  163.     ?>
  164.