<?php
$folder = '';
$exts = 'jpg jpeg png gif';
$files = array(); $i = -1;
if ('' == $folder) $folder = './';
$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) {
if (preg_match('/\.'.$ext.'$/i', $file, $test)) {
$files[] = $file;
++$i;
}
}
}
closedir($handle);
mt_srand((double)microtime()*1000000);
$rand = mt_rand(0, $i);
header('Location: '.$folder.$files[$rand]);
?>
Whose that built by, thanks
If you have your own webhosting the you can rotate on any forum using a rotate.php file.
Code:<?php $folder = ''; $exts = 'jpg jpeg png gif'; $files = array(); $i = -1; if ('' == $folder) $folder = './'; $handle = opendir($folder); $exts = explode(' ', $exts); while (false !== ($file = readdir($handle))) { foreach($exts as $ext) { if (preg_match('/\.'.$ext.'$/i', $file, $test)) { $files[] = $file; ++$i; } } } closedir($handle); mt_srand((double)microtime()*1000000); $rand = mt_rand(0, $i); header('Location: '.$folder.$files[$rand]); ?>
Then just put your image files along with that as rotate.php in your folder on your web space and link to rotate.php as an image.
Easy...
$images = glob("{*.jpg,*.JPG,*.jpeg,*.JPEG,*.png,*.PNG}", GLOB_BRACE);
readfile($images[array_rand($images)]);
I can see you take that advice to heart... awesome set of sigs SkyfallMake sure you've got some good sigs to rotate.

Or you could do it in a couple of lines:
PHP:$images = glob("{*.jpg,*.JPG,*.jpeg,*.JPEG,*.png,*.PNG}", GLOB_BRACE); readfile($images[array_rand($images)]);
Massive thread bump because I've built one of these.If you have your own webhosting the you can rotate on any forum using a rotate.php file.
<?php
declare(strict_types=1);
$imageDir = __DIR__ . '/sigs';
$stateFile = __DIR__ . '/sig_last.txt';
$allowedExt = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
$files = [];
foreach ($allowedExt as $ext) {
foreach (glob($imageDir . '/*.' . $ext) as $path) {
if (is_file($path) && is_readable($path)) {
$files[] = $path;
}
}
}
if (!$files) {
http_response_code(404);
header('Content-Type: text/plain; charset=UTF-8');
echo "No signature images found in {$imageDir}.";
exit;
}
$choice = $files[random_int(0, count($files) - 1)];
$fp = @fopen($stateFile, 'c+');
if ($fp && flock($fp, LOCK_EX)) {
rewind($fp);
$last = trim((string)stream_get_contents($fp));
if (count($files) > 1 && $last !== '') {
$pool = [];
foreach ($files as $path) {
if (basename($path) !== $last) {
$pool[] = $path;
}
}
if ($pool) {
$choice = $pool[random_int(0, count($pool) - 1)];
}
}
ftruncate($fp, 0);
rewind($fp);
fwrite($fp, basename($choice) . "\n");
fflush($fp);
flock($fp, LOCK_UN);
fclose($fp);
} elseif ($fp) {
fclose($fp);
}
$mime = 'application/octet-stream';
if (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
if ($finfo) {
$detected = finfo_file($finfo, $choice);
if (is_string($detected) && $detected !== '') {
$mime = $detected;
}
finfo_close($finfo);
}
}
header('Content-Type: ' . $mime);
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Expires: 0');
header('X-Sig-Nonce: ' . bin2hex(random_bytes(8)));
$size = filesize($choice);
if ($size !== false) {
header('Content-Length: ' . $size);
}
if ($_SERVER['REQUEST_METHOD'] === 'HEAD') {
exit;
}
readfile($choice);
Massive thread bump because I've built one of these.
You could use this php, or the next one mentioned, but there's always the chance that it'll serve the same one multiple times in a row.
This is what I'm using:
Code:<?php declare(strict_types=1); $imageDir = __DIR__ . '/sigs'; $stateFile = __DIR__ . '/sig_last.txt'; $allowedExt = ['jpg', 'jpeg', 'png', 'gif', 'webp']; $files = []; foreach ($allowedExt as $ext) { foreach (glob($imageDir . '/*.' . $ext) as $path) { if (is_file($path) && is_readable($path)) { $files[] = $path; } } } if (!$files) { http_response_code(404); header('Content-Type: text/plain; charset=UTF-8'); echo "No signature images found in {$imageDir}."; exit; } $choice = $files[random_int(0, count($files) - 1)]; $fp = @fopen($stateFile, 'c+'); if ($fp && flock($fp, LOCK_EX)) { rewind($fp); $last = trim((string)stream_get_contents($fp)); if (count($files) > 1 && $last !== '') { $pool = []; foreach ($files as $path) { if (basename($path) !== $last) { $pool[] = $path; } } if ($pool) { $choice = $pool[random_int(0, count($pool) - 1)]; } } ftruncate($fp, 0); rewind($fp); fwrite($fp, basename($choice) . "\n"); fflush($fp); flock($fp, LOCK_UN); fclose($fp); } elseif ($fp) { fclose($fp); } $mime = 'application/octet-stream'; if (function_exists('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME_TYPE); if ($finfo) { $detected = finfo_file($finfo, $choice); if (is_string($detected) && $detected !== '') { $mime = $detected; } finfo_close($finfo); } } header('Content-Type: ' . $mime); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); header('Expires: 0'); header('X-Sig-Nonce: ' . bin2hex(random_bytes(8))); $size = filesize($choice); if ($size !== false) { header('Content-Length: ' . $size); } if ($_SERVER['REQUEST_METHOD'] === 'HEAD') { exit; } readfile($choice);
It's a bit longer, but it never serves the same image twice in a row and it makes the effort to stop any caching. It's not perfect and if a few people are refreshing at the same time, there's a chance they might see repeats due to other views, but it works well.
Chuck it in your own hosting, create a directory below it called 'sigs' and put your images in there. Then call the php in[ img ] tags in your signature.![]()