Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-19-2006, 10:06 PM
tgreer tgreer is offline
 
Join Date: Oct 2005
Posts: 183
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help polish Custom Guest Message plugin

If you search MSN for the phrase "tgreer Sample JDF", you'll find my forum. Currently, the first result takes you directly to a thread. Scroll down to the bottom. As a guest, you'll see a message at the bottom that shows both the search engine, and the search terms, you used. I use this in conjuction with the "Welcome Message" plugin found on this site (Installed!).

I've got this working for most of the major search engines. However, I'm not using phrases, and I'm sure my code isn't the most efficient. I'd like the forum's help in polishing this.

Plugin: name: search_terms, hook_location: global_start

PHP Code:
$keywords "";
$search_engine "";
$search_terms "";
$search_welcome "";
$search_terms "";

if ((isset(
$_SERVER['HTTP_REFERER'])) and ($_SERVER['HTTP_REFERER']!= ''))
{

  global 
$keywords;
  global 
$search_engine;
  global 
$search_terms;
  global 
$search_welcome;

  
$keywords "";
  
$url urldecode($_SERVER['HTTP_REFERER']);

  
// google
  
if (eregi("www\.google",$url))
  {
    
preg_match("'q=([^&]+)'"$url "$keywords);
    
$search_engine 'google';
    
$search_terms $keywords[1];
    
$show['showSearchWelcome'] = true;
    
$show['search_engine'] = $search_engine;
    
$show['search_terms'] = $search_terms;

  }

  
// Yahoo
  
if ((eregi("yahoo\.com",$url)) or (eregi("search\.yahoo",$url)))
  {
    
preg_match("'p=([^&]+)'"$url "$keywords);
    
$search_engine 'Yahoo';
    
$search_terms $keywords[1];
    
$show['showSearchWelcome'] = true;
    
$show['search_engine'] = $search_engine;
    
$show['search_terms'] = $search_terms;

  }

  
// MSN
  
if (eregi("search\.msn",$url))
  {
    
preg_match("'q=([^&]+)'"$url "$keywords);
    
$search_engine 'MSN';
    
$search_terms $keywords[1];
    
$show['showSearchWelcome'] = true;
    
$show['search_engine'] = $search_engine;
    
$show['search_terms'] = $search_terms;

  }

  
// AllTheWeb
  
if (eregi("www\.alltheweb",$url))
  {
    
preg_match("'q=([^&]+)'"$url "$keywords);
    
$search_engine 'AllTheWeb';
    
$search_terms $keywords[1];
    
$show['showSearchWelcome'] = true;
    
$show['search_engine'] = $search_engine;
    
$show['search_terms'] = $search_terms;

  }

  
// Looksmart
  
if (eregi("looksmart\.com",$url))
  {
    
preg_match("'qt=([^&]+)'"$url "$keywords);
    
$search_engine 'Looksmart';
    
$search_terms $keywords[1];
    
$show['showSearchWelcome'] = true;
    
$show['search_engine'] = $search_engine;
    
$show['search_terms'] = $search_terms;

  }


Because scope issues always confound me, I'm putting the terms I need inside of "show". Good, bad, ugly? You tell me.

Template: forumrules

PHP Code:
<!-- tgreer -->
<if 
condition="$show['guest']">
<
table class="tborder" cellpadding="$stylevar[cellpadding]"  cellspacing="$stylevar[cellspacing]border="0">
<
thead>
<
tr>
<
td class="tcat">You're Invited!</td>
</tr>
</thead>
<tbody>
<tr>
<td class="panel">
<div class="smallfont">
<p>

<if condition="$show['
showSearchWelcome']">
You'
ve reached this site because you searched <em>$show[search_engine]</em> for <em>$show[search_terms]</em>. <strong>PrintForum</strongdiscusses this and many other topics of interest to the digital printing industryPlease <a href='/register.php?'>join our community today</a>. Registration is free and easyDon't just <strong>browse</strong>, participate!
</if>


<if condition="!$show['
showSearchWelcome']">
<strong>PrintForum</strong> discusses many topics of interest to the digital printing industry. Please <a href='
/register.php?'>join our community today</a>. Registration is free and easy. Don't just <strong>browse</strong>, participate!
</if>


</
p>
</
div>
</
td>
</
tr>
</
tbody>
</
table>

</
td>
</
tr>
</
table>

</if>
<if 
condition="!$show['guest']">
<!-- 
tgreer -->

<
table class="tborder" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]border="0" width="180">
<
thead>
<
tr>
    <
td class="thead">
        <
a style="float:$stylevar[right]href="#top" onclick="return toggle_collapse('forumrules')"><img id="collapseimg_forumrules" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumrules].gif" alt="" border="0" /></a>
        
$vbphrase[posting_rules]
    </
td>
</
tr>
</
thead>
<
tbody id="collapseobj_forumrules" style="$vbcollapse[collapseobj_forumrules]">
<
tr>
    <
td class="alt1" nowrap="nowrap"><div class="smallfont">
        <if 
condition="!$show['codeonly']">
        <
div><phrase 1="$rules[postnew]">$vbphrase[you_may_x_post_new_threads]</phrase></div>
        <
div><phrase 1="$rules[postreply]">$vbphrase[you_may_x_post_replies]</phrase></div>
        <
div><phrase 1="$rules[attachment]">$vbphrase[you_may_x_post_attachments]</phrase></div>
        <
div><phrase 1="$rules[edit]">$vbphrase[you_may_x_edit_your_posts]</phrase></div>
        <
hr />
        </if>
        <
div><phrase 1="misc.php?$session[sessionurl]do=bbcode" 2="$bbcodeon">$vbphrase[vb_code_is_x]</phrase></div>
        <
div><phrase 1="misc.php?$session[sessionurl]do=showsmilies" 2="$smilieson">$vbphrase[smilies_are_x]</phrase></div>
        <
div><phrase 1="misc.php?$session[sessionurl]do=bbcode#imgcode" 2="$imgcodeon">$vbphrase[img_code_is_x]</phrase></div>
        <
div><phrase 1="$htmlcodeon">$vbphrase[html_code_is_x]</phrase></div>
    </
div></td>
</
tr>
</
tbody>
</
table>

<!-- 
tgreer -->
</if> 
You can see that this would benefit from using phrases. How would you clean this up?

Also, I'm interested in plugin development. How could this be turned into an importable plug-in?
Reply With Quote
  #2  
Old 01-19-2006, 10:09 PM
tgreer tgreer is offline
 
Join Date: Oct 2005
Posts: 183
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, please move this to the "questions" forum... this isn't a released plug-in by any means.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03542 seconds
  • Memory Usage 2,239KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete