vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Help converting Prosperent product script to vbulletin (https://vborg.vbsupport.ru/showthread.php?t=248112)

99SIVTEC 08-06-2010 01:58 PM

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


All times are GMT. The time now is 07:03 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.01540 seconds
  • Memory Usage 1,776KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete