Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 08-06-2010, 02:58 PM
99SIVTEC 99SIVTEC is offline
 
Join Date: Nov 2001
Posts: 281
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help converting Prosperent product script to vbulletin

I don't know how many of you have used Prosperent.com on your sites, but they have an awesome product API that lets you pull back products based on a keyword. When someone buys one of the products, you get a commission. I've been using their regular TCPA ads for a few months on my automotive sites and i've made quite a bit of money, but I think I (and everyone here) can make a great deal more if we can integrate their API into vbulletin as a plugin. I started on this basic idea of doing a product search engine. I have it working, but now I need to convert it into something that will work with Vbulletin and I have no idea how to register the variables with Vbulletin (and I did read the article on it). So, if anyone is willing to take a look, I want to keep the whole project open source.

Here is the results page I need help converting:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv=content-type content="text/html; charset=utf-8">
<title>
<?=$trimmed?> - Prosperent Product Search</title>
<link type="text/css" rel="stylesheet" href="http://www.highaltitudeimports.com/search/css/prosperent_css.css">
<link type="text/css" rel="stylesheet" href="http://www.highaltitudeimports.com/search/css/prosperent_css1.css">

<!--[if lte IE 7]>
 <style>.rsaquo{margin-top:-2px}.grid .result,.ps-sprite{display:inline;zoom:1}.ps-sprite{font-size:1px}.grid{zoom:1}.grid .result-cont {vertical-align: baseline}#lhs-ref {left: 8px}</style>
 <![endif]-->

<style type=text/css>
#gbar, #guser {
	font-size:13px;
	padding-top:1px !important
}
#gbar {
	float:left;
	height:22px
}
#guser {
	padding-bottom:7px !important;
	text-align:right
}
.gbh, .gbd {
	border-top:1px solid #c9d7f1;
	font-size:1px
}
.gbh {
	height:0;
	position:absolute;
	top:24px;
	width:100%
}
#gbs, .gbm {
	background:#fff;
	left:0;
	position:absolute;
	text-align:left;
	visibility:hidden;
	z-index:1000
}
.gbm {
	border:1px solid;
	border-color:#c9d7f1 #36c #36c #a2bae7;
	z-index:1001
}
.gb1 {
	margin-right:.5em
}
.gb1, .gb3 {
	zoom:1
}
.gb2 {
	display:block;
	padding:.2em .5em
}
.gb2, .gb3 {
	text-decoration:none;
	border-bottom:none
}
a.gb1, a.gb2, a.gb3, a.gb4 {
	color:#00c !important
}
.gbi .gb3, .gbi .gb2, .gbi .gb4 {
	color:#dd8e27 !important
}
.gbf .gb3, .gbf .gb2, .gbf .gb4 {
	color:#900 !important
}
a.gb2:hover {
	background:#36c;
	color:#fff !important
}
</style>
</head>
<body>
<div >
<div id="srp-header" >
  <?
function extractFirst($text,$num=3) {
// Create array of sentences using period as the divider
$words = explode('.',$text);
$extract = '';
if (count($words) > 1) {
// Rebuild, using number defined by $num, and adding period back in.
for ($i=0;$i<$num;$i++) {
$extract .= $words[$i].'.';
}
}
else {
$extract = $words[0].'.';
}
return $extract;
}
$var = @$_GET['q'] ; // get the query for the search engine (if applicable)
$trimmed = trim($var); //trim whitespace from the stored variable
if($q == true)
{
?>
  <form method="GET" action="<?=$PHP_SELF?>" name="search">
    <table>
      <tr>
        <td><a id="srp-logo" href="http://www.highaltitudeimports.com" title="Prosperent Search"> <img width="167" height="222" alt="Prosperent" src="http://www.highaltitudeimports.com/search/img/nav_logo13.png" /> </a></td>
        <td><table id="search-input" cellspacing="0">
            <tr>
              <td class="srchBoxCont" nowrap><input class="srch_box" maxlength="2048" name="q" size="41"
 value="<?=$trimmed?>"
 title="Search Products"></td>
              <td nowrap><div class="srchButtonRightShadow">
                  <div class="srchButtonBorder">
                    <input class="srch_button" type="submit" value="Search" id="srchButton">
                  </div>
                </div></td>
            </tr>
            <tr>
              <td colspan="2" class="search_advanced"><a 
 href="/" id="advsearch" ></a></td>
            </tr>
          </table></td>
      </tr>
    </table>
  </form>
  <?
}
elseif($q == false)
{
?>
  <form method="GET" action="<?=$PHP_SELF?>" name="search">
    <table>
      <tr>
        <td><a id="srp-logo" href="http://www.highaltitudeimports.com" title="Prosperent Search"> <img width="167" height="222" alt="Prosperent" src="http://www.highaltitudeimports.com/search/img/nav_logo13.png" /> </a></td>
        <td><table id="search-input" cellspacing="0">
            <tr>
              <td class="srchBoxCont" nowrap><input class="srch_box" maxlength="2048" name="q" size="41"
 value="search"
 title="Search Products"></td>
              <td nowrap><div class="srchButtonRightShadow">
                  <div class="srchButtonBorder">
                    <input class="srch_button" type="submit" value="Search" id="srchButton">
                  </div>
                </div></td>
            </tr>
            <tr>
              <td colspan="2" class="search_advanced"><a 
 href="/" id="advsearch" ></a></td>
            </tr>
          </table></td>
      </tr>
    </table>
  </form>
  <?  } ?>
</div>
<div id="result-count"> </div>
<div id="lhs-ref">
  <div class="lhs-group" id="ref-brand">
    <p class="ref_active"><span class="rsaquo">&rsaquo;</span>More Results:</p>
    <ul class="popular-ref">
      
    </ul>
  </div>
</div>
<div class="list lhs">
  <div class="content-cont">
    <div id="ads-top">
      <ol>
        <li class="first"> 
          <script type="text/javascript"><!--
prosperent_uid = 214536;
/*HAI Search Page*/
prosperent_unit = 8473674;
prosperent_ad_width = 468;
prosperent_ad_height = 60;
prosperent_custom_query = '<?=$trimmed?>';
//-->
</script> 
          <script type="text/javascript"
src="http://prosperent.com/js/ad.js">
</script> 
        </li>
      </ol>
    </div>
    <div id="view-sort">
      <div class="fr view-sort-cont"> <nobr>Sort by:</nobr>
        <select name=scoring onchange="window.location='\x2Fproducts?q=shoes\x26show=dd&scoring='+this.options[this.selectedIndex].value;">
          <option value="r" selected>Relevance
          <option value="p">Price: low to high
          <option value="pd">Price: high to low
        </select>
        <p class="clear_right"></p>
      </div>
      <?php
require_once('Prosperent_Api.php');
  $prosperentApi = new Prosperent_Api(array(
      'api_key'    => 'db08d33e981e05fdd1bd39de70a85248',
      'query'      => $trimmed,
      'visitor_ip' => $_SERVER['REMOTE_ADDR'],
      'channel_id' => 0,
      'page'       => 1,
      'limit'      => 10
  ));
$prosperentApi->set_debugMode(true);

$results = $prosperentApi->fetch();

foreach ($results['data'] as $record)
{
?>
      <ol id="results">
        <li class="result" id="res0">
          <div class="result-cont">
            <p class="result-image"> <a href="<?=$record['affiliate_url']?>" ><img 
 src="<?=$record['image_url']?>" width="90"
 alt="<?=$record['keyword']?>" title="<?=$record['keyword']?>"></a> </p>
            <div class="result-price-seller">
              <p class="result-price" id="price0"> <span class="main-price">$
                <?=$record['price']?>
                </span> </p>
              <div class="result-seller"> <cite>
                <?=$record['merchant']?>
                </cite> </div>
            </div>
            <div class="result-title-description">
              <h3 class="result-title"> <a href="<?=$record['affiliate_url']?>" >
                <?=$record['keyword']?>
                </a> </h3>
              <p class="result-description">
                <?=extractFirst($record['description'])?>
                <b>...</b>. </p>
              <div class="result-rating"> </div>
            </div>
          </div>
        </li>
      </ol>
      <?
}
?>
      <div id="visual_tools">
        <div class="v-ref-sixpack">
          <div class="v-ref-hdr">Shop by brand</div>
          <div class="v-ref-hdr"></div>
          <?php
require_once('Prosperent_Api.php');
  $prosperentApi = new Prosperent_Api(array(
      'api_key'    => 'db08d33e981e05fdd1bd39de70a85248',
      'query'      => $trimmed,
      'visitor_ip' => $_SERVER['REMOTE_ADDR'],
      'channel_id' => 0,
      'page'       => 1,
      'limit'      => 6
  ));
$prosperentApi->set_debugMode(true);

$results = $prosperentApi->fetch();

foreach ($results['data'] as $record)
{
?>
          <div class="v-ref">
            <div class="v-ref-img"><a href="<?=$record['affiliate_url']?>" ><img 
 src="<?=$record['image_url']?>" width="90"
 alt="<?=$record['keyword']?>" title="<?=$record['keyword']?>"></a></div>
            <a href="<?=$record['affiliate_url']?>" >
            <?=$record['brand']?>
            </a> </div>
          <?
}
?>
          <p class="clear"></p>
        </div>
      </div>
      <div id="ads-bot">
        <ol>
          <li class="first"> 
            <script type="text/javascript"><!--
prosperent_uid = 214536;
/*HAI Search Page*/
prosperent_unit = 8473674;
prosperent_ad_width = 468;
prosperent_ad_height = 60;
prosperent_custom_query = '<?=$trimmed?>';
//-->
</script> 
            <script type="text/javascript"
src="http://prosperent.com/js/ad.js">
</script> 
          </li>
        </ol>
      </div>
    </div>
    <div class="below-content">
      <div id="ps-navbar" class="n">
        <table width="1%">
          <tr>
            <td nowrap align="right">&nbsp;</td>
            <td nowrap>Page Nav</td>
            <td valign=bottom nowrap>&nbsp;</td>
          </tr>
        </table>
      </div>
      <div id="footer">
        <div id="footer-bg">
          <?        
        if($q == true)
{
?>
          <form method="get" name="fb" action="<?=$PHP_SELF?>">
            <table cellspacing="0">
              <tr>
                <td class="srchBoxCont" nowrap><input class="srch_box" type="text" name="q" size="40" maxlength="2048" value="<?=$trimmed?>"></td>
                <td nowrap><div class="srchButtonRightShadow">
                    <div class="srchButtonBorder">
                      <input class="srch_button" type="submit" value="Search" id="srchButtonB">
                    </div>
                  </div></td>
              </tr>
            </table>
          </form>
          <?
}
elseif($q == false)
{
?>
          <form method="get" name="fb" action="<?=$PHP_SELF?>">
            <table cellspacing="0">
              <tr>
                <td class="srchBoxCont" nowrap><input class="srch_box" type="text" name="q" size="40" maxlength="2048" value="search"></td>
                <td nowrap><div class="srchButtonRightShadow">
                    <div class="srchButtonBorder">
                      <input class="srch_button" type="submit" value="Search" id="srchButtonB">
                    </div>
                  </div></td>
              </tr>
            </table>
          </form>
          <? } ?>
        </div>
        <p class="bottom-links"> <a href="/" id="gHome">Home</a> <a href="http://www.Prosperent.coml">About&nbsp;</a></p>
        <div align="center">Powered by:<a href="http://www.prosperent.com">Prosperent</a></div>
      </div>
    </div>
  </div>
  <p class="clear"></p>
</div>
</body>
</html>
Here is a full working copy from their forums if you need the api class and such: http://community.prosperent.com/show...Prosperent-API
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:52 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02853 seconds
  • Memory Usage 2,229KB
  • 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)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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