PDA

View Full Version : Miscellaneous Hacks - The Ultimate Random Header Mod


Jaxel
04-27-2009, 10:00 PM
This mod has been rewritten for vB4x here: https://vborg.vbsupport.ru/showthread.php?t=240629

THIS SCRIPT DOES NOT USE JAVASCRIPT!

I wrote this mod for my own website last year (http://www.8wayrun.com/). I was looking for a way to create a random header situation, while also letting people select the random header through their UserCP and FORCE a header depending on what forum they are on. If you go to my website (http://www.8wayrun.com/), a random character will appear on your header, if you ctrl+refresh, a new character will show up... if you go to our character specific forums, the character in the random header will be FORCED to the character of that specific forum... I have done my best to make this script as simple as possible.

Product Demo:
http://www.8wayrun.com/
http://www.8wayrun.com/customstyles/exm-blue-dark/header/header.php

Installation Procedure:
Create a dedicated folder on your server where you will be putting your random images.
Put the included "header.php" script into the folder you created previously in step 1.
Put the images you want randomized into the folder you created previously in step 1.
Optional Switches:
OPTIONAL: If you want, you can set this script to FORCE a header on specific forum. Its simple, when naming the files for your random images, simply name the file as the forum ID of that forum. So if you want a specific image forced when viewing forum 38, name the file 38.png.
.
OPTIONAL: If you want, you can let users SELECT which header they want on places where the script would normally randomize.
Create a new "Single-Selection Menu" profile field in your adminCP, set title and description to whatever you want. If you use numbered filenames like those in step 2, you may want to use the description field to let people know what they are selecting. (see screenshot)
For each selection option, enter an image's filename WITHOUT the extension, so wolves.png will be just "wolves".
Set Default: None
Field Required: No
Field Editable: Yes
Private Field: No
Field Searchable on Members List: No
Show on Members List: No
Display Page: Options: Other

After you submit, this field will be given a name (ex: field9). Make sure to remember this name.
.
OPTIONAL: Open up the included "header.php" script and go to the section flagged "// VALIDATE CURRENT IMAGE DATA, CHECK FID, CHECK PID". By default, the image randomizer will find ANY image with the JPG, PNG or GIF extension. However, the FORCED and SELECT settings will always look for PNG images. If you would like to change this to either JPG or GIF, you must change the two isntances of PNG to the appropriate format. Only ONE filetype is usable with the FORCED or SELECT options.
.
The script has a heirarchy of importance when searching for images. The first thing it will look for is the FORCED image from step 1. If it doesn't find a forced image, it will use the user defined image in step 2. If the user doesn't have a defined image, it will pick an image at random from the folder it resides in.

Usage Procedure:
Anywhere you want to use this random script, just link to this script, instead of an image.
<img src="DIRECTORY/header.php?fid=$forumid&pid=$bbuserinfo[field9]" />
<table background="DIRECTORY/header.php?fid=$forumid&pid=$bbuserinfo[field9]"></table>

.
The text in BLUE above is the switch for forcing an image based on the forumid. If you don't want to force images depending on the forum, you dont need to include that switch.
.
The text in RED above is the switch for forcing an image based on user control panel selection. If you don't want to give users the option to select an image manually, you dont need to include the switch. Notice that this switch has a variable called "field9"; this may not be the same in your forum. This variable should be changed to the field name I had you make note of in a previous step.

Don't forget to click INSTALL!

If you want to donate, I'm all for it... as I'm an unemployed computer programmer...

John Henry
04-28-2009, 12:43 PM
how nice :)

but where is the header.php? ;)

btw. it would be cool if it COULD use more extensions at once... like you said, now it just can either .jpg OR .png or.... but it would be awesome if it could do all at once.

since I am waiting for the header.php... could you just answer me the question... will it pick ALL the images from the folder (with the right extensions e.g. .jpg) or just if I name them like "1.jpg", "2.jpg" etc.?

edit: found this up there... thanks... even mentioning my example :D

Regards,
John Henry

Jaxel
04-28-2009, 12:59 PM
You can get it to take more than one file type for the RANDOMIZER by adding the following in the
// DEFINE VALID EXTENSIONS AND CONTENT TYPES area...

$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpg';

However, the FORCED and the USER SELECTION options will only display the SINGLE filetype defined in the
// VALIDATE CURRENT IMAGE DATA, CHECK FID, CHECK PID area.

John Henry
04-28-2009, 01:02 PM
You can get it to take more than one file type for the RANDOMIZER by adding the following in the
// DEFINE VALID EXTENSIONS AND CONTENT TYPES area...

$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpg';

However, the FORCED and the USER SELECTION options will only display the SINGLE filetype defined in the
// VALIDATE CURRENT IMAGE DATA, CHECK FID, CHECK PID area.

thanks, that's a good compromise!

vote for motm :)

the only thing I am worrying is, what happens if you use some Seo Component (like me)... will this "user selects header..." thing be possible, as the ID is "different"... i mean, in database it isn't different (is it?) but you don't see the id in the sections...

Jaxel
04-28-2009, 01:06 PM
add an HTACCESS file to the directory turning the rewrite engine off... thats what I did on my forum and it works fine. Besides, the data is being pulled from the $forumid and $bbuserinfo... SEO and modRewrite has no access to that information; if they changed those, your forum wouldn't work.

DobieGillis?
04-28-2009, 01:16 PM
that is so cool. Just checked your site. Noice!

Sweeks
04-28-2009, 01:34 PM
Nice work, will look into this soon :)
________
Medical marijuana strains (http://strainindex.com)

The Realist
04-28-2009, 02:52 PM
Works a treat :) thanks

See www.sattalk.co.uk for a working independent demo.

Regards

ArnyVee
04-28-2009, 10:09 PM
Jaxel, I was hoping that you'd share how that works! :D

I'm definitely going to work with this one in the near future. Thanks for sharing! :up:

as7apcool
04-29-2009, 01:25 AM
thanks 4 this good work

sensimilla
04-29-2009, 07:09 AM
Looks very interesting, thanks!

Jasem
04-29-2009, 01:16 PM
Great work , thank you!

Gigio755
05-24-2009, 06:42 AM
Great!

Gigio755
05-29-2009, 11:35 AM
several errors with IE7/8 :(

EDIT:
now it work very very very well (it was my fault! with another script)!

GREAT MOD!

compact123
05-29-2009, 12:20 PM
I do not understand this mod.

applebeef
06-30-2009, 05:51 PM
Jaxel, do the images reside in the users cache with this mod?

I ask because it kinda has a quick 'scroll' down, even when you've already seen all of the images in rotation.

Also I'm especially curious because my new forum has been running really well with it, but is currently slow, and only with the header images it seems.

The forums load fine but the header images take a while (longer than usual). Hopefully this will pass.

Jaxel
06-30-2009, 11:32 PM
Yes, the images are cachable.

Merjawy
07-01-2009, 10:32 AM
sorry, but I don't fully get it

is it either or? or can you do all?

can you randomly select forum wide banners and also force certain banners on certain forums and allow users as well?

I tried it now and even forced forum gets the other banners too.. I know I am not getting it

Thanks

ShawneyJ
07-02-2009, 03:08 AM
Excellent thanks.

Jaxel can i ask what mod you are using for the sub forum set out on your forum please? or did you code it or something?
thanks. screen shot

Jaxel
07-02-2009, 05:10 AM
Excellent thanks.

Jaxel can i ask what mod you are using for the sub forum set out on your forum please? or did you code it or something?
thanks. screen shot
Its a HIGHLY MODIFIED version of this:
https://vborg.vbsupport.ru/showthread.php?t=118935

Jaxel
07-02-2009, 05:13 AM
sorry, but I don't fully get it

is it either or? or can you do all?

can you randomly select forum wide banners and also force certain banners on certain forums and allow users as well?

I tried it now and even forced forum gets the other banners too.. I know I am not getting it


Thanks

You can do as much or as little as you want... either or... and ALL.

4.The script has a heirarchy of importance when searching for images. The first thing it will look for is the FORCED image from step 1. If it doesn't find a forced image, it will use the user defined image in step 2. If the user doesn't have a defined image, it will pick an image at random from the folder it resides in.

applebeef
07-02-2009, 05:23 AM
Yes, the images are cachable.

Thanks!

One other thing, I tried doing a forced header for a forum and could not get it to work. I'm not really worried about... just thought I'd report.

ShawneyJ
07-02-2009, 05:49 AM
Its a HIGHLY MODIFIED version of this:
https://vborg.vbsupport.ru/showthread.php?t=118935

damn, been looking for a mod like that but set out like your forum for over year.
thanks anyway ;)

Jaxel
07-02-2009, 03:48 PM
damn, been looking for a mod like that but set out like your forum for over year.
thanks anyway ;)
I will ask Atakan if I can release my version.

ShawneyJ
07-03-2009, 08:48 AM
I will ask Atakan if I can release my version.

YEAH? i will buy you a beer for sure. thx.

applebeef
07-04-2009, 07:48 AM
Jaxel, sorry to bother you again, but can you confirm that images cache with this mod?

That would be really important to me. I don't understand why it has a 'scroll down' effect every time if the images is cached.

I have a fast connection so I'm not sure can properly say that they're not caching--- they load fast either way for me-- but why the scrolling? I notice that that effect is pretty much nonexistent on your forum headers.

Here's the url to my header.php if you can take a look to confirm: http://www.wetacollectors.com/forum/headerimages/header.php?

I'd really appreciate it, thanks

Jaxel
07-04-2009, 11:37 PM
You have some weird setting on your directory... as I cant view your image...

If I go here: it will display a random image, and if I press enter on the address bar, it clearly pulls from the cache (as it loads immediately and doesnt have the scroll)
http://www.8wayrun.com/customstyles/exm-blue-dark/header/header.php

However, if I go to your script: it WONT display an image, instead it will give me a download prompt for your php file... which is something that it should never do.
http://www.wetacollectors.com/forum/headerimages/header.php

applebeef
07-05-2009, 05:41 AM
You have some weird setting on your directory... as I cant view your image...

If I go here: it will display a random image, and if I press enter on the address bar, it clearly pulls from the cache (as it loads immediately and doesnt have the scroll)
http://www.8wayrun.com/customstyles/exm-blue-dark/header/header.php

However, if I go to your script: it WONT display an image, instead it will give me a download prompt for your php file... which is something that it should never do.
http://www.wetacollectors.com/forum/headerimages/header.php

Jaxel, may I ask what browser you use? Your reply has prompted me to look at various things using both Firefox (my main browser) and Safari. Here are some of my findings:

-Your direct header DOES scroll for me in Firefox, with the loading progress bar too. Although it still happens very fast, but it's definitely there, even in instances where the same image has appeared consecutively. I wish I could video it so you could see.

-Your direct header does not scroll in Safari, as far as I can tell. It 'pops' in, which I think is the desired effect.

-My header direct link works fine for me in Firefox (obviously) but trying it in Safari does indeed lead to a download prompt. (Though the header(s) work fine in the forum itself.

-On my actual forum, which I've looked at plenty of times with both browsers and can confirm again-- the scrolling behavior is present on both browsers.


From these results I would hazard to guess you are using Safari (my header direct link doesn't load for you, your header direct link loads 'good') but it's only a guess.

Obviously I don't know further what is 'wrong', but I'm hoping you can find something in these results that might help. This is the link to the forum: http://www.wetacollectors.com/forum

Jaxel
07-05-2009, 08:07 AM
I use IE8 on this computer, and FF3 on my other computer... everything works fine on my website without issues.

But I found out what your issue is... You have the following meta tag:
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />


This means nothing on your website will cache... EVER.

applebeef
07-05-2009, 02:50 PM
Wow Jaxel you are so right, it even targets the headers specifically it looks like: <!-- no cache headers -->

How did that get there!? My Vbulletin is pretty vanilla, and quite new (only recently set up, and transferred from PHPBB3)

If that is not a 'standard' part of the code, I honestly have no idea how/why it got there, I certainly did not add that.

I will try and figure out how to remove it. Thanks a lot!

applebeef
07-05-2009, 03:10 PM
Actually, upon further inspection, it seems to be a standard part of Vbulletin code?

The sites (not mine) that I looked at all have this. In fact VB.org has this if you view page source their home page.

Even your forum has this!:
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

Granted it differs from mine in that the value "0" is present instead of "-1" (no idea what that means)

Edit: Further more reading, this is hardcoded into the forum home of Vbulletin, which explains that. It is not present for example, on a random forum page on my forum.


So is this really the problem?
:confused:

Tilly
07-12-2009, 10:15 PM
How do you link the code to your homepage? Like link the image back to your forum home?

odln018
08-20-2009, 12:28 PM
Jaxel -
I'm using your mod in conjunction with VB 3.8.4. I upgrade my PHP from 5.2.9 to 5.3, and this mod no longer functions.

I'm not receiving any errors, just no banners at all. When I revert back to 5.2.9, all functions normally again. I'm not receiving any errors, just no banners at all. When I revert back to 5.2.9, all functions normally again.

odln018
08-20-2009, 12:30 PM
Jaxel -
I'm using your mod in conjunction with VB 3.8.4. I upgrade my PHP from 5.2.9 to 5.3, and this mod no longer functions.

I'm not receiving any errors, just no banners at all. When I revert back to 5.2.9, all functions normally again.

tafreeh
09-09-2009, 03:39 AM
works great... but i have a lil issue...
check out this image
http://images.tafreehmela.com/showoriginal-2335/untitled.jpg

there is unwanted free white space above my logo? how is that?

chris&barb
09-24-2009, 07:46 PM
Does this mod work on 3.8.4? I did exactly as said and nothing happened. Where exactly is everyone placing the folder?

goxy63
10-09-2009, 11:27 PM
Is there any way to use this mod with flash animations(SWF) as Iam using them for my forums as a header?

Thanks for answer

Cheers

Gamelobby
03-25-2010, 04:31 AM
If i just want a rotating header (completely random) do i need to use these at all.?
I'm guessing i do or it wouldn't know how to connect to the images. lol (header.php)

<img src="DIRECTORY/header.php?fid=$forumid&pid=$bbuserinfo[field9]" />
<table background="DIRECTORY/header.php?fid=$forumid&pid=$bbuserinfo[field9]"></table>

But i did add both to my header teamplate, but nothing works.?
My header template is weird, so im not sure if it is my template, or the 3.8.5 version.?
<!-- bullseye background -->
<div class="vbseo_bullseye" style="width: $stylevar[outertablewidth]">

<!-- header -->
<div class="vbseo_header_container">
<div class="vbseo_header">

<!-- logo -->
<a name="top"></a>
<a href="$vboptions[forumhome].php$session[sessionurl_q]"><img id="vbseo_logo_image" src="$stylevar[titleimage]" border="0" alt="$vboptions[bbtitle]" /></a>
<h1 id="vbseo_logo_h1"><a href="$vboptions[forumhome].php$session[sessionurl_q]"></a></h1>
<p id="vbseo_logo_tagline"><a href="$vboptions[forumhome].php$session[sessionurl_q]"></a></p>
<!-- /logo -->

<!-- navigation -->
<ul class="vbseo_main_menu">
<li><a href="cmps_index.php">Home</a></li>
<li><a href="all_albums.php$session[sessionurl_q]">Pics</a></li>
<li><a href="video.php">Videos</a></li>
<li><a href="arcade.php">Arcade</a></li>
<li><a href="gameroom.php?">Casino</a></li>
<li><a href="vbgooglemapme.php">Map</a></li>
<li><a href="project.php$session[sessionurl_q]">$vbphrase[projects]</a></li>
<li><a href="blog.php$session[sessionurl_q]">$vbphrase[blogs]</a></li>



</ul>
<!-- /navigation -->

<!--VBSEO_RR_1-->

$_phpinclude_output

$ad_location[ad_header_end]
Is there a more simplified code i could use to just randomize the header..?
Also does this work with 3.8.5.?

Thanks
:cool:

psychonikeo
06-22-2010, 10:16 AM
working fantastic on 3.8.4!!! I was looking for this, so this helped me out so much!!

john102774
07-04-2010, 04:53 PM
Great Mod! Installed on 3.8.5.