Jump to content

Web Based Script: Random Image


NELyon
 Share

Recommended Posts

I was surfing for PHP scripts i could convert to work with Autoit Web-based. So i did this simple script. There's more detailed instructions on how to use it in the comments.

_StartWebApp()
;Your total number of images
$total = "11"
;The file type?
$file_type = ".jpg"
;What folder are they in?
$image_folder = "/backgrounds/random/";

;Ok, so here's how you use it. Put images in the $image_folderyou defined. The number of images you put in
;depends on what you put for $total. Put that many images. All of the images must have the extension you
;put for $file_type

;---------------------------------------
;       DON'T EDIT BELOW HERE
;---------------------------------------

$start = "1";

$randm = Random($start, $total)
$random = Round($randm, 0)
$image_name = $random & "." & $file_type

Echo('<img src='&$image_folder & $random & $file_type) 

;The juicy part of the script is done now. Here are the functions that made it all possible

Func _StartWebApp ($Title="", $bkimage = "", $Color = "white")
    ConsoleWrite("Content-Type: text/html" & Chr(13) & Chr(10) & Chr(13) & Chr(10))
    If $title <> "" Then ConsoleWrite("<html><head><title>"&$title&"</title></head><body bgcolor ="&$color&">")
    If $bkimage <> "" then ConsoleWrite("<html><head><title>"&$title&"</title></head><body background="&$bkimage&">")
EndFunc
    
Func echo($text)
    ConsoleWrite($text)
EndFunc

;Now... the script is finished.

Doesn't require web.au3 because i put the required functions inside the script.

DEMO:

[Click]

Edited by D-Generation X
Link to comment
Share on other sites

hey! pretty cool, but instead of

$randm = Random($start, $total)

$random = Round($randm, 0)

couldnt you just

$random = Random($start, $total, 1)

?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Ok, I got another challenge for ya. Completely take out $total and have the script search $image_folder for all files with the extension $file_type. That way, people can choose their own name instead of 1.jpg, 2.jpg, etc, and they could use as many as they want without having to go in and change $total every time.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...