Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: PHP/MySQL/HTML/JavaScripts

  1. #1
    Join Date
    Aug 2005
    Posts
    13

    Default PHP/MySQL/HTML/JavaScripts

    Calculates how long it took for a page to generate.



    Code:
    <?php
    //put at top of page.
    
    //declare utime function
    function utime ()
    {
           //returns the current Unix timestamp with microseconds
           $time = explode(" ", microtime());
           $msec = (double)$time[0]; //microseconds
           $sec = (double)$time[1]; //current time measured in the number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT)
           return $sec + $msec; //return value
    }
    
    //start page loader counter
    $time_start = utime();
    ?>
    
    <?php
    //put at bottom of page.
    $time_end = utime();
    $time = round($time_end - $time_start,3).' seconds'; //calc the difference
    echo "generated in $time"; // echo result
    ?>

  2. #2
    Join Date
    Aug 2005
    Posts
    13

    Default Display Server Uptime

    This code will display your server's uptime.

    Code:
    <?php
    
    $uptime = passthru ("/usr/local/bin/uptime");
    echo $uptime;
    
    ?>

  3. #3
    Join Date
    Aug 2005
    Posts
    13

    Default Screen resolution detector

    Description:
    Detects the Screen resolution of the person visiting your site.

    Code:
    <script language="JavaScript">
    <!--
    document.write("Your current resolution is "+screen.width+"*"+screen.height)
    //-->
    </script>

  4. #4
    Join Date
    Aug 2005
    Posts
    13

    Default popup window

    Description:
    Makes a popup window using javascript.

    Code:
    <html>
    <title>simple popup window using javascript</title>
    <body>
    popup link
    </body>
    </html>

  5. #5
    Join Date
    Aug 2005
    Posts
    13

    Default page jump

    Description:
    Redirects users who disable Java Script to another page (ex. www.yahoo.com). :D

    Code:
    <html>
    <body>
    <script type="text/javascript">
    <!-- 
    document.write("");
    // -->
    </script>
    <noscript>
    <meta http-equiv="Refresh" content="0;URL=http://www.yahoo.com/">
    </noscript>
    </body>
    </html>

  6. #6
    Join Date
    Dec 2005
    Posts
    9

    Default

    do you know how to make a counter in web-page using PHP, I am still new in PHP and don't know whether I have to use mySQL to create a counter.

  7. #7
    Join Date
    Aug 2004
    Location
    USA
    Posts
    996

    Default

    Type this in the document where you want the Counter to Show UP: Must be in a .php Document Ex. Index.php

    <?php include "counter.php"; ?>
    If that don't work put this:
    <?php echo "counter.php"; ?>
    They both seemed to work for me.


    Code:
    <?php
    ###########################################
    #  Fortified and Tested by CFE-Clan.com   #
    ###########################################
    
    // Enable referer validation? 1 = YES, 0 = NO
    $check_referer = 0;
    // Domains that are allowed to access this script
    $referers = array ("localhost","yourdomain.com");
    
    #############################
    #     DO NOT EDIT BELOW     #
    #############################
    
    // Get page and log file names
    $page = htmlentities($_GET['page']);
    $logfile = "logs/" . $page . ".log";
    
    // If $check_referer is set to 1 and if HTTP_REFERER is set to
    // a value let's check refering site
    if ($check_referer == 1 && !(empty($_SERVER['HTTP_REFERER'])))
    {
    check_referer($_SERVER['HTTP_REFERER']);
    }
    
    // If the log file doesn't exist we start count from 1 ...
    if (! @$file = fopen($logfile,"r+"))
    {
    $count="1";
    }
    // If the log file exist lets read count from it
    else {
    $count = @fread($file, filesize($logfile)) or $count=0;
    fclose($file);
    // Raise the value of $count by 1
    $count++;
    }
    
    // Write the new $count in the log file
    $file = fopen($logfile,"w+") or die("Can't open/write the log file, please CHMOD logs folder to 777 (rwx-rwx-rwx)!");
    fputs($file, $count);
    fclose($file);
    
    // Print out Javascript code and exit
    echo "<font size=1pt color=#00FF00 face=verdana>This site has been visited
     $count times</font>";
    exit();
    
    // function that will check refering URL
    function check_referer($thisurl) {
    	global $referers;
    		for ($i=0;$i<count($referers);$i++)
            	{
    				if (preg_match("/$referers[$i]/i",$thisurl)) {return true;}
    			}
    	die("Invalid referer!");
    }
    ?>

  8. #8
    Join Date
    Aug 2004
    Location
    USA
    Posts
    996

    Default

    Create a <?php echo "date.php"; ?> Where you want the date to show up.

    Code:
    <?
    $mese[0]="-";
    $mese[1]="January";
    $mese[2]="February";
    $mese[3]="March";
    $mese[4]="April";
    $mese[5]="May";
    $mese[6]="June";
    $mese[7]="July";
    $mese[8]="August";
    $mese[9]="September";
    $mese[10]="Octobre";
    $mese[11]="November";
    $mese[12]="December";
    
    $giorno[0]="Sunday";
    $giorno[1]="Monday";
    $giorno[2]="Tuesday";
    $giorno[3]="Wedensday";
    $giorno[4]="Thursday";
    $giorno[5]="Friday";
    $giorno[6]="Saturday";
    
    $gisett=(int)date("w");
    $mesnum=(int)date("m");
    
    echo $giorno[$gisett]." ".$mese[$mesnum]." ".date("d")." ".date("Y");
    
    ?>

  9. #9
    Join Date
    Aug 2004
    Location
    USA
    Posts
    996

    Default

    Will show your current time on your PC Clock which you can find on the bottom right hand corner of your screen, will show the time you entered the website or page.
    Create this code where you want it to show up:
    <?php echo "time.php"; ?>

    Code:
    <?php
    
    // If your local time is *behind* the server time, then change the "+" to
    // a "-" in the $melbdate line
    // 
    // Keep in mind that you'll have to update the $hourdiff variable within the
    // script when your *local* daylight saving time/standard time changes, if
    // it is a different setting to the server daylight saving/standard time
    
    // Variable for hours
    
    $hourdiff = "-6"; // hours difference between server time and local time
    
    
    $timeadjust = ($hourdiff * 60 * 60);
    
    $melbdate = date(" H:i",time() + $timeadjust);
    
    print ("$melbdate");
    
    ?>

  10. #10
    Join Date
    Dec 2005
    Posts
    9

    Default

    thank you, that are all more than enought for me. hope I can implement those code in my page

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •