Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2005
    Location
    Peaches bed ;)
    Posts
    2,118
    Tokens
    200

    Latest Awards:

    Default is there a html code..

    that makes it so when you refresh the page the code is on, a certain image changes into other images ive specified? +rep for code or alternatives.
    Mario

  2. #2
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Like you have to refresh the page a few times to view the image..?

    I made one a while ago..
    PHP Code:
    <?php 
    ob_start
    (); 
    session_start(); 
     
    /* 
    CONFIG 
    */ 
     
    $message "Sorry, This website is not currently open!"#Message to show to users who havent refreshed. 
    $type "cookie"#Choose what method of storing refreshes you wish to use, Set to cookie to use cookies and session to use sessions 
     
    /* 
    DONT EDIT BELOW 
    */ 
     
    if($type=="cookie"
    {  
    if(
    $_COOKIE["refresh"]!=3

    if(isset(
    $_COOKIE["refresh"])) 

    $ref_value $_COOKIE["refresh"] + 1
    setcookie("refresh",$ref_value,time()+3600); 
    die(
    "$message"); 

    else 

    setcookie("refresh","1",time()+3600); 
    die(
    "$message"); 



    elseif(
    $type=="session"

    if(
    $_SESSION["refresh"]!=3

    $_SESSION["refresh"] = $_SESSION["refresh"]+1
    die(
    "$message"); 


    else 
    die(
    "No valid storing type specified!"); 
    ?>
    Just add in your image after the code.
    Last edited by MrCraig; 07-01-2008 at 05:22 PM.
    Coming and going...
    Highers are getting the better of me

  3. #3
    Join Date
    Oct 2007
    Location
    UK
    Posts
    471
    Tokens
    0

    Default

    I think he means that the image changes each time you refresh.

  4. #4
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    I think you mean refresh certain parts, umm put the image or w.e in an iframe and put a piece of code in the heading of whats redirected to the iframe of content refresh?

    Please elaborate
    How could this hapen to meeeeeeeeeeeeeee?lol.

  5. #5
    Join Date
    Oct 2007
    Location
    UK
    Posts
    471
    Tokens
    0

    Default

    If I was right in thinking that you want the image to change to another random image on each refresh, I've found two ways:

    Random.php

    PHP Code:
    <?php
    $dir 
    '.';
    $avatar_types[] = 'gif';
    $avatar_types[] = 'jpg'//add as many new image extensions as you want.

    // DO NOT EDIT BELOW THIS LINE
    $avatar array_key_exists('avatar',$_GET)?$_GET['avatar']:'';
    if (
    $avatar != '') {
    $avatar urldecode($avatar);
    }
    else {
    $avatars = array();
    $directory opendir($dir);
    while (
    $list readdir($directory)) {
    if (
    $list != '.' && $list != '..') {
    $ext_check explode('.',$list);
    foreach (
    $avatar_types as $variable => $value) {
    if (
    in_array($value,$ext_check) && !in_array($value,$avatars)) {
    $avatars[] = $list;
    }
    }
    }
    }
    closedir($directory);
    $random array_rand($avatars,1);
    $avatar $avatars[$random];
    }
    $file fopen($dir.'/'.$avatar,'r');
    $content fread($file,filesize($dir.'/'.$avatar));
    fclose($file);
    die(
    $content);
    ?>
    And then call it by..

    Code:
    <img src="random.php" alt="" />
    Or, a much simpler one, but it doesn't check if image exists

    PHP Code:
    <?php
    $file 
    rand(120);
    $file .= '.jpg';
    echo 
    '<img src="'.$file.'" >';
    ?>

Posting Permissions

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