Nov 22, 2009

Script For Viewing A Random Image Needed

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Script For Viewing A Random Image Needed

pyost
While browsing the web, I bumped into a script that I could really use, since it's different from everything that I saw. Most scripts that view a random image contain a code that chooses an image, and then puts the <img> part into the page itself. However, on the www.greenplastic.com web site (dedicated to Radiohead), in the top left corner there is a random image module. If you look at the code, here's what is used:

CODE
<img src="http://www.greenplastic.com/images/v75/random/random.php" width="125" height="125" />


Now, how can a PHP script be an image, and what kind of script that is? If you do visit that URL, you don't get a normal page, but a radom image. Keep refreshing the page and you'll see what I'm talking about.

As for why I need this script and not one that uses the first mentioned method, it's quite simple. I want the random image to be used for a background, and that code will be entered in the CSS file. So, I want something like this:

CODE
module {
     background: #191919 url(images/random/random.php) no-repeat top left;
}


I hope you get the point. If anyone could point me to a script like this, I would be very grateful.

 

 

 


Comment/Reply (w/o sign-up)

vujsa
As long as the header information is correct when sent to the browser, the image should appear correctly even if it is a PHP file. This isn't alway true and since it is in your CSS, you probably won't validate because you are using an unknow file extention for a known file type.

mod_rewrite can fix the file extention for you though. Notice my signature image. It is PHP generated on the fly. The data it uses is statice currently but the images is refreshed as often as every 20 seconds if the file is requested that often.

Here is a very good resouce for mod_rewrite:
http://www.ilovejackdaniels.com/apache/
The cheat sheet there is very helpful.

Basically, here is the deal. I request www.domain.com/directory/image.png and the server accesses www.domain.com/directory/image.php instead.

This is how we have those nice HTML file names for all of the pages here at AstaHost even though everything is PHP driven here. smile.gif

Just set your program up in it's own directory and name it something rather unique like bgimage.php
Then if you don't already have one in that directory, create a .htaccess file.
In that .htaccess file add the following code:
CODE
RewriteEngine on

RewriteRule ^bgimage.png$ bgimage.php


This would start the script bgimage.php when the file bgimage.png is requested.

For a more dynamic program, you can also pass variable with the rewrite like so:
CODE
RewriteEngine on

RewriteRule ^background_image([A-Za-z0-9-]{1,})\.jpg$ bg_generator.php?time=$1


This would start the script bg_generator.php when the file background_image325ads123.png is requested where 325ads123 = time!

Then with $_GET['time'], you could use the timestamp to control what kind of image is shown. Basically, you could have a dark background at night and a light background during the day. Of course, you can't do that in your CSS file since there isn't a way to insert a timestamp in CSS files.

Always be sure to leave at least one blank line at the bottom of your .htaccess file to allow your cPanel to insert code if needed.

Another thing that is possible with this is to serve a different CSS everytime. ohmy.gif

You could either generate a CSS file on the fly with PHP or have several that would rotate.
CODE
RewriteEngine on

RewriteRule ^default\.css$ css_rotator.php


Then requesting default.css from any page would access the script css_rotator.php which could either create a brand new CSS file or select one from a list. If you were to generate a ne CSS, then you would probably set up a few color schemes and that could be substituted.


As for what kind of script to use, you can either writ your own or look in the forum for signature rotators. There are a couple of tutorials in here somewhere. I could help you develope your own if you wish.

Hope This Helps. cool.gif

vujsa

 

 

 


Comment/Reply (w/o sign-up)

pyost
I think mod_rewrite could help me, since the PHP extension won't work in CSS. Just to see if I got it all: I put "image.gif" in the CSS file, but mod_rewrite redirects it to image.php, so I get the php file, right?

You said that the image in your signature works the same way, but it serves a PNG image, while I need a PHP image. Sort of tongue.gif As for the script, I'll se if there's something on the net. If there isn't, I'll be sure to ask you for help.

Comment/Reply (w/o sign-up)

vhortex
QUOTE(pyost @ Aug 29 2006, 12:54 AM) *

I think mod_rewrite could help me, since the PHP extension won't work in CSS. Just to see if I got it all: I put "image.gif" in the CSS file, but mod_rewrite redirects it to image.php, so I get the php file, right?

You said that the image in your signature works the same way, but it serves a PNG image, while I need a PHP image. Sort of tongue.gif As for the script, I'll se if there's something on the net. If there isn't, I'll be sure to ask you for help.



some people do draw the images on the fly.. using fast server processors.. it is possible to draw complex graphics.. some just copy an image file into an output stream with a header type of image..

try this one.. one of my scripts.. https://admin.maldivesliveaboards.com/includes/random.php
the script generates random chars and draws it into an image..

i have complex image drawings.. one of them was used in an ecommerce shopping cart.. the script generates thumbnails every time you view them and the output is being stored in your local pc.. not good way but it saved space from the server and removes the burden of incomplete data writes when there are a lot of people viewing a certain product and requesting thumbnails..

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : script, viewing, random, image, needed

  1. Php Script Organizer
    (3)
  2. Php Random Selector
    whats the code (2)
    Is there a PHP script that randomly selects a string from a list? example, the list is: 1-Pie
    2-Balls 3-eggs The script would view a random
    word from those 3 every time i run it. Also is there a function that gives a random number between
    0 and a number i select?....
  3. Myspacetv Download Php Script Help
    (6)
    I was trying to make a php script that can view myspace videos with jw flv player and wont to know
    how to do so if i put in
    "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=38105626" it show the video
    "http://cache01-videos02.myspacecdn.com/11/vid_e382054c036835500bacfef1ebb5157e.flv(its the flv
    video file from myspacetv), I cant see the similarity with the links please help, thanks for viewing
    this topic /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
  4. Dynamic Php Image And Better Php Code Question
    (10)
    Im working on a dynamic image, can i put 2 images in same dynamic image, and can i make this code
    shorter? if ( $goal == 31 ) { $xp2 = ('14833'); } elseif ( $goal == 32 ) { $xp2 =
    ('16456'); } elseif ( $goal == 33 ) { $xp2 = ('18247'); } elseif ( $goal == 34 ) {
    $xp2 = ('20224'); } elseif ( $goal == 35 ) { $xp2 = ('22406'); } elseif ( $goal ==
    36 ) { $xp2 = ('24815'); } elseif ( $goal == 37 ) { $xp2 = ('27473'); } elseif (
    $goal == 38 ) { $xp2 = ('30408'); } elseif ( $goal == 39 ) { $xp2 = ('33648')....
  5. Php Login Script
    (0)
    login script click the link to get your free php login script installer just follow the
    instuctions the exe gives you and it will give you the script just place the code in the sever and
    open index.html and follow on from there. what it has: it has reg page, login protection code ect.
    it is simple to use and i think quite fun but im BORN TO BE WEIRD,you will need at least one working
    mysql data base /biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif"
    /> hope you enjoy it. iknow i did from the alexmedia crew....
  6. Dynamic Gd Image
    (2)
    I dont know if someone already made a topic like this, however it's not hard to understand if
    you can php, as many know we need to start a php script with CODE and end with CODE ?>
    to make a image you need a image type, I choos .png because its much cleaner then .jpg CODE
    header("Content-type: image/png"); for the background for the image we need this code CODE
    $image = imagecreatefrompng("http://www.imagefilez.com/out.php/i252132_Userbar.png"); if we wont
    a text in the image we need a font color, we get our font color from HEX values ....
  7. Random With Functions?
    (4)
    Hey! Is it possible to use a random script on functions. Lets say I have created three functions
    (Items that a user will win if he defeates a monster). One function is a function named shield()
    and another function is named sword() and a third function is named helmet(). Now when a player
    defeates a monster, he must be awarded. So.. How can I randomize what item he should get? something
    like CODE rand(sheild(), sword(), helmet()); or? Thanks //Feelay....
  8. Make A Script Run Even If No User Is Online
    (6)
    Hey! Is there any way to make a script run, even if no user is online. Because at the moment, my
    scripts run, only when a user is online. And another thing: How can i make the following: (this is
    just an example) mysql_query"SELECT maxhp FROM users WHERE username = 'allusers'"; How can I
    select all users maxhp, in the same query? Thanks //Feelay....
  9. Writing And Testing My Own Login Script [solved]
    (20)
    i have this error QUOTE Warning: session_start() : Cannot send session cache limiter - headers
    already sent (output started at /home/eggie/public_html/race.php:2) in
    /home/eggie/public_html/race.php on line 5 in every page i have with session start...what's
    the problem?? CODE Race include("style.css"); include("config.php"); session_start();
    if(!session_is_registered(myusername)){ echo 'Your Session has Expired!'; exit;} //If you
    click race... if ($_GET =='race') { $asa=$_POST ; if(!isset($asa)) { echo 'You
    didn\'t select an....
  10. Image Popup On Mouseover
    (23)
    I need a script that does this: Lets say I have form with options...you surely know what that is...
    CODE Who do you wanna race?           Derbi Senda 50      Honda NS 50 R      Suzuki ZR
    50      Yamaha DT 50 MX      Aprilia RS 50      - ?         When i put my mouse over
    one of them i want a picture of bike on which your mouse is on to pop up... I hope you understand
    what i mean...i can't rephrase it to be more meaningful...i tried /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />....
  11. Script Request
    script request (2)
    another script request i am looking for a file manger tutorial with edit delete search upload move
    copy and a WYSIWYG(What You See Is What You Get) editer like on on freewebs.com and css editor plz
    help! i need on badly vmkrightpoint Edit"i keep search google and msn and yahoo i can't find
    on!! lol"....
  12. Free Forum Hosting Type Script Help!
    Free forum hosting type script help!!! (2)
    i want to make something like http://invisionfree.com/ that makes an dir with your phpbb 3 forum
    in it with an admin CP plz help i really want to make something like it!! i was thinking of coding
    my own with file handling but i'm not good at some of it like "when u click submit to register
    a forums it will move the phpbb3 file that leads to the users dir then it will rename the dir to
    your username so like my.site.com/username it might work" with the admin username and pass and
    admin's email it will open the config.php then edit all the data but it will ke....
  13. Login Script
    (8)
    I have another question--- i downloaded script of a game and it worked until my server changed to
    newer version of php after which it didn't work... the most probable reason is that globals are
    not enabled... now i need someone who can tell me what to put instead of what to make it work...
    this is my login.php script CODE if (!$user || !$pass) {     include("head.php");     print
    "Please fill out all fields.";     include("foot.php");     exit; } include("head.php"); $password =
    md5($pass); $password2 = md5($password); $password3 = md5($password2); $password4 =....
  14. Password Recovery Script
    (7)
    While trying to make password recovery script for "bhupinunder" i run into a problem... i made this:
    CODE $dbh = mysql_connect('localhost','jaskaran_gc','gc') or die
    ("Cannot Connect: " . mysql_error()); mysql_select_db('jaskaran_gc',$dbh); ?> ";?>
    if ($recover=answer) print"$email"; ?> and it doesn't print anything...but if i put it
    like this CODE $dbh = mysql_connect('localhost','jaskaran_gc','gc') or
    die ("Cannot Connect: " . mysql_error()); mysql_select_db('jaskaran_gc',$dbh....
  15. Warning: Mysql_result(): Supplied Argument Is Not A Valid Mysql Result Resource In ...
    This Is for My attack Script. (4)
    Hey. I am making a "Version 2.0" For my attack script, but I can't make it work. This is the
    error I am gettin: Warning: mysql_result(): supplied argument is not a valid MySQL result resource
    in And here is the code: CODE $dbQueryHealth = mysql_query("SELECT temphealth FROM
    characters WHERE user =". $_POST ."");           $currentHealth = mysql_result($dbQueryHealth, 0);
            $dbQueryExp = mysql_query("SELECT exp FROM characters WHERE user = ".$_POST ."");  
            $currentExp = mysql_result($dbQueryExp, 0); I have checked the PHP Manual,....
  16. SQL Doesn't Connect In PHP Script
    I made some code updates now the script is broken. (19)
    i have created a website and it is not working properly... i have had a website on sphosting.com and
    everything worked fine till i got some errors(i got the errors because of the crappy host)...now the
    fun part starts...they said they solved the problem but i got another one..i said them to repair it
    again and they did...now i tried to login but as i entered the info it said the info isn't
    correct...i checked the SQL and everything seemed fine..i tried again and again the error came...i
    tried than to register,entered ALL info and when this was suppose to come out "Yo....
  17. Need Help With Background Image...
    (12)
    I want to add background image to all sites on my website but some include "foot.php" and "head.php"
    and some "footer.php" and "header.php" but all include "config.php" but i dont know in which should
    i put it....any help??....
  18. Php Script Help
    help with scripting of php (1)
    Ok first a little back story of what happened and why I am asking for help. I have been playing text
    based rpgs and found that I really like them. Well I have also found that most programers don't
    want to listen to their clients in the sugestion box and when u make a content sughesstion they get
    rude or make fun of your idea. So I decided I would sart my own and make it where the users had say
    so in added content. Not saying all sugestions will get added but I will not make fun or get mad at
    them. Any who when I bought the script I was under the impression it was fu....
  19. Run A Script When Expires A Session
    (6)
    For example, when a user logins to a page -with a login form- and after validating and verifying
    it's credentials i store some information related to this user in session variables and a table
    with his state -connected- is updated, then i use it in other pages, etc. When this user logouts
    -by clicking a logout link- i release -unregister, destroy, etc- all the session variables stored
    and the same table is updated with his state -disconnected-. All of this funcionality works very
    well, the problem comes when the user do not click on the logout link and the session ....
  20. Automated Product Suggestion Script
    Compare user lists and suggest related items based on pattern matching (2)
    I recently got an idea for a project and one of the features I wanted the project to have was an
    automated suggestion service. If anyone has been to Amazon, it would work much like their
    recommended product feature. What I want to do is take several users lists of whatever but for this
    example, I'll use web links like from the browser history. I would want to suggest links to a
    user based on common links in many other users lists. User A: Amazon, Ebay, Excite, Google, Yahoo,
    MySpace, Walmart User B: Amazon, Ebay, Google, Yahoo, You Tube, MySpace, CVS User C: Amazo....
  21. Something Wrong With This Script?
    Unexpected T_SRING (9)
    Here is the code that I have: CODE $con = mysql_connect("localhost","user","password"); if
    (!$con)   {die(' Could not connect: ' . mysql_error() . ' ');}
    mysql_select_db("database", $con); $ip=$_SERVER ; echo "Adding MXP info..."; mysql_query (INSERT
    INTO mxp (date, user, victim, turns, side, gold, lost, killed, mxp, points_b, points_a, type, power,
    ip) VALUES ('$_POST ','$_POST ','$_POST ','$_POST ','$_POST
    ','$_POST ','$_POST ','$_POST ','$_POST ','$_POST
    ','$_POST ....
  22. Coders Needed To Help On A Bulletin Board System (BBS)
    php, mySql, Graphics design work, etc (4)
    I recently got involved in a Forum software script which is being developed and thought I should let
    everyone know that they need some assistance in the PHP, MySql, Html, and CSS areas. Also, some
    Visual Designers would be quite useful. AEF Forum Software is the name of the project. It is
    presently in version 1.0.3, and have some pretty cool features already, but in order to advance in
    its standings against such Boards as IPB, phpbb, Yabb, etc, more features and Themes are required.
    Good bunch of people working hard, but just not enough of us to do everything. Come h....
  23. Basics Of Php For Beginners - Suggestion
    Help Needed For Project (5)
    Hi all, I have a friend who, for his extended IT project is interested in making a website partly
    out of php. When he asked for advice my first thought was here. I would like to know some good
    websites, tutorials etc that he can use to introduce himself to php (he hasn't done much
    before). He is interested in making a simple login/subscription service where you can signup and
    then login to a 'members only' page. Any ideas and code samples that you have to share would
    be greatly appreciated. /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" a....
  24. What Would Make A Good Registration Script?
    (4)
    I see newbies all the time looking for either a login script or after a little querying you find
    they really would like to have a registration script. The first thing for such a script for a
    members area would of course be a form and being kind of old fashioned I still like to format my
    forms with a table but I do use inline CSS to make it a little nicer. I never did like forms that
    had an asterick * by a field and then a Note: Fields marked with * are required. So what I do
    instead is add a background color to those areas and then use a CSS background color statin....
  25. A Simple Checking & Validation PHP Script
    (8)
    Hi, there is sometimes that you need to password protect a directory in your site but you dont have
    access to a database or you dont need it because only a few users will access this directory, well
    the following script i develop will help in this situation. With only 2 files you can implement a
    basic security, the first file is a simple txt file where you store your users information and the
    second file is the php script. You can name the files whatever you want and can be used in any site
    with php support. The users.txt file: In this file simply put one line at the....
  26. PHP Script To Upload A File
    with password-protection. (15)
    Problem: Upload a file to the AstaHost account (that I have been granted here) throught the
    webpage I would like to know, how should I proceed on this particular problem. I know this has
    been done through cPanel, but I want to write a PHP functionality. The cPanel is accessed through
    the 2082 port, and most of the places I access internet from does not give me access through that
    port. I can access http://www.kmaheshbhat.astahost.com/ but not
    http://www.kmaheshbhat.astahost.com/cpanel or http://www.kmaheshbhat.astahost.com:2082/ . I need
    to go to one particu....
  27. Need Help With A PHP - MySQL Registration Script
    Wont INSERT into the database (13)
    hey well can some one helpme make this code work it won't INSERT INTO THE DATABSE CODE #
    register1.php # common include file to MySQL include("DB.PHP"); $Username=$_POST ; $Password=$_POST
    ; $Name=$_POST ; $Last=$_POST ; $Sex=$_POST ; $Month=$_POST ; $Day=$_POST ; $Year=$_POST ;
    $Adresse=$_POST ; $City=$_POST ; $State=$_POST ; $Zipcode=$_POST ; $Country=$_POST ; $Phone=$_POST ;
    $Email=$_POST ; $Father_Name=$_POST ; $Mother_Name=$_POST ; $Parent_Phone=$_POST ;
    $Parent_Email=$_POST ; $Level=$_POST ; $Academic=$_POST ; $Image_Link=$_POST ; $sql9="INSERT INTO
    U....
  28. Php Script To Download File From Another Site
    (11)
    hi i need a php or java script code for downloading files from other sites to my site for example:
    http://download.com/file.zip to http://mysite.com/file.zip thanks....
  29. Php Random Text Generating
    How to Generate Random Text (6)
    I was trying to figure out how to make random texts for random passwords and stuff, and I found
    someone who created this code. QUOTE //author: polmme $codelenght = 10;
    while($newcode_length $x=1; $y=3; $part = rand($x,$y); if($part==1){$a=48;$b=57;}  // Numbers
    if($part==2){$a=65;$b=90;}  // UpperCase if($part==3){$a=97;$b=122;} // LowerCase
    $code_part=chr(rand($a,$b)); $newcode_length = $newcode_length + 1; $newcode = $newcode.$code_part;
    } echo $newcode; ?> I think it's pretty good. If anyone has a better one or suggestions,
    please tell me.....
  30. Tell-a-friend script
    Make a tell-a-friend script with php!! (6)
    Hi!! I'll show you how to make a simple tell-a-friend script using php. If you put this on
    your site, your visitors will be able to recommend your site to a friend. This can be good promotion
    for your site. It's quite easy to set up too. Just copy and past the script below. Put this
    where you want the form to appear: friendtell.php " method="get"> Tell a friend:
    Put this in the file friendtell.php Your friend has been told! $myname = $from;
    $myemail = $from; $contactemail = $to; $message = " Hi!! \nI wanted to tell y....

    1. Looking for script, viewing, random, image, needed

See Also,

*SIMILAR VIDEOS*
Searching Video's for script, viewing, random, image, needed
Similar
Php Script Organizer
Php Random Selector - whats the code
Myspacetv Download Php Script Help
Dynamic Php Image And Better Php Code Question
Php Login Script
Dynamic Gd Image
Random With Functions?
Make A Script Run Even If No User Is Online
Writing And Testing My Own Login Script [solved]
Image Popup On Mouseover
Script Request - script request
Free Forum Hosting Type Script Help! - Free forum hosting type script help!!!
Login Script
Password Recovery Script
Warning: Mysql_result(): Supplied Argument Is Not A Valid Mysql Result Resource In ... - This Is for My attack Script.
SQL Doesn't Connect In PHP Script - I made some code updates now the script is broken.
Need Help With Background Image...
Php Script Help - help with scripting of php
Run A Script When Expires A Session
Automated Product Suggestion Script - Compare user lists and suggest related items based on pattern matching
Something Wrong With This Script? - Unexpected T_SRING
Coders Needed To Help On A Bulletin Board System (BBS) - php, mySql, Graphics design work, etc
Basics Of Php For Beginners - Suggestion - Help Needed For Project
What Would Make A Good Registration Script?
A Simple Checking & Validation PHP Script
PHP Script To Upload A File - with password-protection.
Need Help With A PHP - MySQL Registration Script - Wont INSERT into the database
Php Script To Download File From Another Site
Php Random Text Generating - How to Generate Random Text
Tell-a-friend script - Make a tell-a-friend script with php!!
advertisement



Script For Viewing A Random Image Needed

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com