change background image at every refresh

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Ideas Centre
Post Reply
VixxeN
Registered User
Posts: 8
Joined: Tue Jan 29, 2019 2:25 pm

change background image at every refresh

Post by VixxeN »

Hello, can someone teach me how to make a script to change background image at every refresh?
I mean, now I will acces the site, then I will refresh / visit a subforum/topic. When I will refresh / visit to get another background image.
For example:
Image
Image

I MUST MENTION: MY STYLE IS WE_UNIVERSAL!
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 52768
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: change background image at every refresh

Post by stevemaury »

Can you provide a link to your phpBB Board?
I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
VixxeN
Registered User
Posts: 8
Joined: Tue Jan 29, 2019 2:25 pm

Re: change background image at every refresh

Post by VixxeN »

stevemaury wrote: Fri May 10, 2019 5:43 pm Can you provide a link to your phpBB Board?
http://sd.rc-rp.ro/
VixxeN
Registered User
Posts: 8
Joined: Tue Jan 29, 2019 2:25 pm

Re: change background image at every refresh

Post by VixxeN »

stevemaury wrote: Fri May 10, 2019 5:43 pm Can you provide a link to your phpBB Board?
I need to mention: I already have the images for random backgrounds.. I mean to upload them to styles folder and randomly applying them.
User avatar
Sniper_E
Registered User
Posts: 1134
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: change background image at every refresh

Post by Sniper_E »

I once created a directory, theme/images/bg.gif/ directory named bg.gif
I put all of my bg images in that directory and found a rotate.php file to put in there.
I renamed the rotate.php to index.php and it randomly selected an image in same directory.
In the colours.css I used "./images/bg.gif" for the background image.

This would work better in an extension. There should be a few out there.
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
VixxeN
Registered User
Posts: 8
Joined: Tue Jan 29, 2019 2:25 pm

Re: change background image at every refresh

Post by VixxeN »

Sniper_E wrote: Sat May 11, 2019 5:29 am I once created a directory, theme/images/bg.gif/ directory named bg.gif
I put all of my bg images in that directory and found a rotate.php file to put in there.
I renamed the rotate.php to index.php and it randomly selected an image in same directory.
In the colours.css I used "./images/bg.gif" for the background image.

This would work better in an extension. There should be a few out there.
Not working at all.. :(
User avatar
Lumpy Burgertushie
Registered User
Posts: 69223
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: change background image at every refresh

Post by Lumpy Burgertushie »

the problem is with your style. we universal does not have the same code for the header that most other styles do.

that spot where you want to put the banners is called dashboard or something like that.

none of the extensions or the manual instructions will work as written.

so, you would need random header instructions and use this line in overall_header.html:

Code: Select all

<img src="{ROOT_PATH}styles/we_universal/theme/images/dashboard.jpg?assets_version={T_ASSETS_VERSION}" alt="forum header image">
robert
Premium phpBB 3.3 Styles by PlanetStyles.net

I am pleased to announce that I have completed the first item on my bucket list. I have the bucket.
User avatar
Sniper_E
Registered User
Posts: 1134
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: change background image at every refresh

Post by Sniper_E »

VixxeN wrote: Sat May 11, 2019 6:20 am Not working at all.. :(
I downloaded we_universal again and installed it.
The image path was exactly as Robert stated above.

I went into the theme/images/ directory and created a "New folder"
Then I moved the images, dashboard.jpg and dashboard-FCF.jpg into the New folder directory.
After that I renamed the New folder directory to dashboard.jpg
Then I placed the index.php file in that directory with the images.

It worked great!

This is the random image codes in the index.php

Code: Select all

<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
        if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
            $files[] = $file; // it's good
            ++$i;
        }
    }
}
closedir($handle); // We're not using it anymore

mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
User avatar
ivailo95
Registered User
Posts: 1067
Joined: Tue Sep 05, 2017 8:00 am
Location: Bulgaria
Name: Ivailo
Contact:

Re: change background image at every refresh

Post by ivailo95 »

omg..i want the same think here..
viewtopic.php?f=496&t=2509346 , but no one look into this topic and now i suspect same topic wow :roll:

now talk in topic: how can i do this , i mean to change background at every refresh
For REALLY good and VERY cheap hosting CLICK HERE
Watch "Lost in a random" game, it's the best
User avatar
KevC
Support Team Member
Support Team Member
Posts: 72339
Joined: Fri Jun 04, 2004 10:44 am
Location: Oxford, UK
Contact:

Re: change background image at every refresh

Post by KevC »

ivailo95 wrote: Sun May 12, 2019 2:21 pm omg..i want the same think here..
viewtopic.php?f=496&t=2509346 , but no one look into this topic and now i suspect same topic wow :roll:

now talk in topic: how can i do this , i mean to change background at every refresh
It's worth explaining which background you're talking about.

It turns out this topic is on about the header image.

Some people call the background the image you can see behind the categories on the index, some talk about the image down the side of the index. Unless you say which one you're on about, no one knows. I've said it before, extension requests should explain in as much detail as possible what you want. Some people are extremely vague and then wonder why they get no replies.
-:|:- Support Request Template -:|:-
Image
"Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb"
User avatar
</Solidjeuh>
Registered User
Posts: 1788
Joined: Tue Mar 29, 2016 3:45 am
Location: Aalst (Belgium)
Name: Andy Dm
Contact:

Re: change background image at every refresh

Post by </Solidjeuh> »

User avatar
ivailo95
Registered User
Posts: 1067
Joined: Tue Sep 05, 2017 8:00 am
Location: Bulgaria
Name: Ivailo
Contact:

Re: change background image at every refresh

Post by ivailo95 »

KevC wrote: Sun May 12, 2019 3:23 pm
ivailo95 wrote: Sun May 12, 2019 2:21 pm *long text*
*long text*
i made some edit in my topic
For REALLY good and VERY cheap hosting CLICK HERE
Watch "Lost in a random" game, it's the best
VixxeN
Registered User
Posts: 8
Joined: Tue Jan 29, 2019 2:25 pm

Re: change background image at every refresh

Post by VixxeN »

Sniper_E wrote: Sat May 11, 2019 6:08 pm
VixxeN wrote: Sat May 11, 2019 6:20 am Not working at all.. :(
I downloaded we_universal again and installed it.
The image path was exactly as Robert stated above.

I went into the theme/images/ directory and created a "New folder"
Then I moved the images, dashboard.jpg and dashboard-FCF.jpg into the New folder directory.
After that I renamed the New folder directory to dashboard.jpg
Then I placed the index.php file in that directory with the images.

It worked great!

This is the random image codes in the index.php

Code: Select all

<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/

// Make this the relative path to the images, like "../img" or "random/images/".
// If the images are in the same directory, leave it blank.
$folder = '';

// Space seperated list of extensions, you probably won't have to change this.
$exts = 'jpg jpeg png gif';

$files = array(); $i = -1; // Initialize some variables
if ('' == $folder) $folder = './';

$handle = opendir($folder);
$exts = explode(' ', $exts);
while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
        if (preg_match('/\.'.$ext.'$/i', $file, $test)) { // faster than ereg, case insensitive
            $files[] = $file; // it's good
            ++$i;
        }
    }
}
closedir($handle); // We're not using it anymore

mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>
Impossible to rename a directory to dashboard.jpg :/
User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: change background image at every refresh

Post by canonknipser »

Why? Do you have a file named dashboard.jpg in the folder where your directory (folder) is placed?
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB
User avatar
Sniper_E
Registered User
Posts: 1134
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: change background image at every refresh

Post by Sniper_E »

VixxeN wrote: Sat May 18, 2019 7:26 am
Sniper_E wrote: Sat May 11, 2019 6:08 pm Then I moved the images, dashboard.jpg and dashboard-FCF.jpg into the New folder directory.
Impossible to rename a directory to dashboard.jpg :/
If you want to leave the original images in the images/ directory, then name your new folder to sunshine.jpg
Pick a name, just change it in the overall_header.html to match your new directory name.
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
Post Reply

Return to “Extension Requests”