ok guys i want to know if it is possible to use random text in a url area of ur script? supposing i have this code img src="http:// so instead of addin 1 url there i want to put the images urls in a text file and get them exploded in the http:// area is it possible???? i dont want to use random image
Explode Option
Collapse
X
-
Explode Option
Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!
<span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>
Tags: None
-
linkrx7 -
lol ok ill explain it again i want links to my <img src=http://here randomly change"> code to change randomly by using some random text coding, i dont want to use random image codes.
are u gettin me now?
Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!
<span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

Comment
-
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-space:pre;overflow:auto'><?php
$folder = '.';
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
$img = null;
if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}
if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);
if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}
?></div>
create a file called index.php tusing the code above, place it in a folder called logo.gif and also place your random images in this folder, then you just use a standard image link using logo.gif as the image name, this will then randomise the images you place in the folder
Hope this helps:p:p:p
Comment
-
linkrx7 -
yes bro i only want the url part to randomly change not the img src=\"http:// only the 123.com/xxx.gif only this part i want to change rendomly with some random codeFailure is not when a girls leaves you, its only when you let her go virgin. heheh!!
<span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

Comment
-
hellspawn
K create a txt file with ur links in like so. for this example will use links.txt
-blah.com/path1/path2/jig.gif
-foo.org/path1/path2/dance.jpg
etc. etc. we will use the - to distinguish between the different urls
code is:
Should do itCode:<?php $xfile = @file("links.txt"); $random_num = rand (0,count($xfile)-1); $udata = explode("-",$xfile[$random_num]); $link = $udata[1]; echo "<img src=\"http://$link\" alt=\"*\"/>"; ?>
Comment
-
guys im having problem with the random code sometimes it shows nothing on my page after u refresh the page for 2 to 3 times only then a pic shows up and agan the next will get blank. how to fix this error?
Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!
<span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

Comment
-
with this code
Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!
<span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

Comment
-
i think i know what your after lol create a file and call it links.txt cmod to 777
add in there
add as many as you want... then on the page you want to show the random links putCode:::<a href=\"YOUR LINK\">LINK NAME</a> ::<a href=\"YOUR LINK\">LINK NAME</a>
that should work fine and it would flick thru links......Code:$xfile = @file("links.txt"); $random_num = rand (0,count($xfile)-1); $udata = explode("::",$xfile[$random_num]); echo "$udata[1]";
if you want it to show images with the links add this to the links.txt
add as many as you like...Code:::<a href=\"YOUR LINK\"><img src=\"images/home.gif\" alt=\"LINK NAME OR LEAVE BLANK\"/></a>
:-) hope it works for ya
Comment
-
brother the code works fine but the problem im facing is that sometimes it dont fetch anything from links.txt file it remains blank until u refresh ur index againFailure is not when a girls leaves you, its only when you let her go virgin. heheh!!
<span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

Comment
Comment