Full Version: Landing Pages for Your Forum
Dream.In.Code > Programming Tutorials > PHP Tutorials
WoodiE55
Login into vBulletin's admin panel and navigate to:

Plugin System -> Add New Plugin

PRODUCT: vBulletin
HOOK LOCATION: global_start
TITLE: Landing Page
PLUGIN PHP CODE: paste the following code...

CODE

$referer = $_SERVER['HTTP_REFERER'];

//Did they get here from a search?
if((preg_match('/www\.google.*/i',$referer))
   || preg_match('/search\.atomz.*/i',$referer)
    || preg_match('/search\.live.*/i',$referer)
   || preg_match('/search\.msn.*/i',$referer)
   || preg_match('/search\.yahoo.*/i',$referer)
   || preg_match('/msxml\.excite\.com/i', $referer)
   || preg_match('/search\.lycos\.com/i', $referer)
   || preg_match('/www\.alltheweb\.com/i', $referer)
   || preg_match('/search\.aol\.com/i', $referer)
   || preg_match('/search\.iwon\.com/i', $referer)
   || preg_match('/ask\.com/i', $referer)
   || preg_match('/search\.cometsystems\.com/i', $referer)
   || preg_match('/www\.hotbot\.com/i', $referer)
   || preg_match('/www\.overture\.com/i', $referer)
   || preg_match('/www\.metacrawler\.com/i', $referer)
   || preg_match('/search\.netscape\.com/i', $referer)
   || preg_match('/www\.looksmart\.com/i', $referer)
   || preg_match('/go\.google\.com/i', $referer)
   || preg_match('/dpxml\.webcrawler\.com/i', $referer)
   || preg_match('/search\.earthlink\.net/i', $referer)
   || preg_match('/search\.viewpoint\.com/i', $referer)
   || preg_match('/www\.mamma\.com/i', $referer)
   || preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $referer)
   || preg_match('/www\.ask\.co\.uk/i', $referer)) {

  //Figure out which search and get the part of its URL which contains the search terms.
  if(preg_match('/(www\.google.*)|(search\.msn.*)|(search\.live.*)|(www\.alltheweb\.com)|(ask\.com)|(go\.google\.com)|(search\.earthlink\.net)/i',$referer))
    $delimiter = "q";
  elseif(preg_match('/www\.ask\.co\.uk/i', $referer))
    $delimiter = "ask";
  elseif(preg_match('/search\.atomz.*/i',$referer))
    $delimiter = "sp-q";
  elseif(preg_match('/search\.yahoo.*/i',$referer))
    $delimiter = "p";
  elseif(preg_match('/(msxml\.excite\.com)|(www\.metacrawler\.com)|(dpxml\.webcrawler\.com)/i', $referer))
    $delimiter = "qkw";
  elseif(preg_match('/(search\.lycos\.com)|(search\.aol\.com)|(www\.hotbot\.com)|(search\.netscape\.com)|(search\.mamma\.com)/i', $referer))
    $delimiter = "query";
  elseif(preg_match('/search\.iwon\.com/i', $referer))
    $delimiter = "searchfor";
  elseif(preg_match('/search\.cometsystems\.com/i', $referer))
    $delimiter = "qry";
  elseif(preg_match('/www\.overture\.com/i', $referer))
    $delimiter = "Keywords";
  elseif(preg_match('/www\.looksmart\.com/i', $referer))
    $delimiter = "key";
  elseif(preg_match('/search\.viewpoint\.com/i', $referer))
    $delimiter = "k";
  elseif(preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $referer))
    $delimiter = "string";

  $pattern = "/^.*" . $delimiter . "=([^&]+)&?.*\$/i";
  $query = preg_replace($pattern, '$1', $referer);

  //Remove quotation marks.
  $query = preg_replace('/\'|"/','',$query);

    $query_array = preg_split ("/[\s,\+\.]+/",$query);
    $query_terms = implode(" ", $query_array);
    $terms = htmlspecialchars(urldecode($query_terms));

}


PLUGIN IS ACTIVE: Yes

PRESS SAVE.

Now just add $terms in any template you want.



+++ IF YOU'RE USING Ted S - Improved Welcome headers from vbulletin.org +++

Styles & Templates -> Style Manager -> welcome_headers

FIND THIS:

CODE
<phrase 1="faq.php?$session[sessionurl]" 2="register.php?$session[sessionurl]" 3="$vboptions[bbtitle]" 4="sendmessage.php$session[sessionurl]">$vbphrase[welcome_guest]</phrase>


REPLACE WITH:

CODE
<phrase 1="faq.php?$session[sessionurl]" 2="register.php?$session[sessionurl]" 3="$vboptions[bbtitle]" 4="sendmessage.php$session[sessionurl]" 5="$terms">$vbphrase[welcome_guest]</phrase>


SAVE!


NOTE: The difference in the code is adding: 5="$terms" to the phrases. This will allow the $terms variable to work with the welcome headers for guest.
BamaStangGuy
Not working for me. Did exactly as instructions said. Copied and pasted then used the $terms to call it
WoodiE55
QUOTE(BamaStangGuy @ 5 Dec, 2006 - 08:02 PM) *

Not working for me. Did exactly as instructions said. Copied and pasted then used the $terms to call it


I don't think this would cause an issue, but what version of vBulletin are you using?

The above instructions worked for 3.5.4


-Michael
BamaStangGuy
QUOTE(WoodiE55 @ 5 Dec, 2006 - 08:05 PM) *

QUOTE(BamaStangGuy @ 5 Dec, 2006 - 08:02 PM) *

Not working for me. Did exactly as instructions said. Copied and pasted then used the $terms to call it


I don't think this would cause an issue, but what version of vBulletin are you using?

The above instructions worked for 3.5.4


-Michael


3.6.0 patched
skyhawk133
I just updated the PHP portion of the code to include live.com. Yahoo is having a weird issue with the cop variable... should be pulling the p variable instead. Live.com should work now though.
BamaStangGuy
QUOTE(skyhawk133 @ 5 Dec, 2006 - 08:13 PM) *

I just updated the PHP portion of the code to include live.com. Yahoo is having a weird issue with the cop variable... should be pulling the p variable instead. Live.com should work now though.


lol go figure cause Yahoo is where I get my most referrers
skyhawk133
I'll get it fixed up for ya wink2.gif It's just an issue with the regular expression the guy who wrote it originally is using.

Also, if you want to output each word uppercase, add $terms = ucwords($terms); before the closing bracket in the first section of code.
WoodiE55
QUOTE(skyhawk133 @ 5 Dec, 2006 - 08:21 PM) *

I'll get it fixed up for ya wink2.gif It's just an issue with the regular expression the guy who wrote it originally is using.

Also, if you want to output each word uppercase, add $terms = ucwords($terms); before the closing bracket in the first section of code.


skyhawk,

Thanks so much for your help on this! I owe you.


-Michael
skyhawk133
Have you noticed any increase/change in your registration rate?
WoodiE55
QUOTE(skyhawk133 @ 6 Dec, 2006 - 07:24 AM) *

Have you noticed any increase/change in your registration rate?


Average RCNitroTalk.com for the last month or two receives about 5 new members each day. Yesterday it jumped to 8 new members. It'll be interesting to watch over the next week or two to really be able to get a sense of how well this works or not.


-Michael
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.