dcuellar Posted January 29, 2008 Share Posted January 29, 2008 Good morning phpfreaks.com! I am currently using a shopping cart for my website which uses a thumbnail image per product. Below the product is the product name, which is clickable and will direct you to the product info. I'd really like to be able to automatically make the thumbnail clickable to do the same thing. Here is my store: http://www.unifiedchamp.com/ucforum/cartplog.php Here is my php script: <?php /********************************************************************************************* CartPlog Lite License ============================================================================================== This software is as-is, no warranty of any kind, use at your own risk. You are granted free use of this software. However, you are not permitted under any circumstances to redistribute the software, whether in whole or in part. Also, the 'powered by' links must remain intact and visible. Make sure to understand that this is *not GPL software. Do not redistribute it, and do not use parts of it in other software. This software is copyrighted in its entirety to 'calorie' a/k/a � ThinkDing LLC 2007, all rights reserved. The software author/entity are in no way responsible for your site content. All copyright notices and 'powered by' links must not be changed or removed. Do not use this software if obtained from a warez site! *********************************************************************************************/ // ####################### SET PHP ENVIRONMENT ############################ error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ######################## define('THIS_SCRIPT', 'cartplog'); define('CARTPLOG_VERSION', 'Lite v.1.0.0'); if ($_REQUEST['do'] == 'postback') { define('SKIP_SESSIONCREATE', 1); } // ################### PRE-CACHE TEMPLATES AND DATA ####################### if (empty($_REQUEST['do'])) { $_REQUEST['do'] = 'viewindex'; } $phrasegroups = array('cartplogfrontend'); $specialtemplates = array(); $globaltemplates = array(); $actiontemplates = array( 'checkout' => array( 'cartplog_basket_item', 'cartplog_view_cart' ), 'viewcart' => array( 'cartplog_basket_item', 'cartplog_view_cart' ), 'viewcategory' => array( 'cartplog_category_item', 'cartplog_view_category' ), 'viewhistory' => array( 'cartplog_history_item', 'cartplog_history_list', 'cartplog_view_history' ), 'viewindex' => array( 'cartplog_category_list', 'cartplog_basket_summary', 'cartplog_product_item', 'cartplog_view_index' ), 'viewitem' => array( 'cartplog_view_item' ) ); // ####################### REQUIRE VB BACK-END ############################ // cartplog in main forum directory require_once('./global.php'); // ###################### CHECK CARTPLOG ACCESS ########################### // #################### INITIALIZE SOME VARIABLES ######################### $cartplog = array(); // do not remove this !!! // do not hide, change, remove, etcetera !!! $cartplog['powered_by'] = '<br /><div class="smallfont" align="center"><a href="http://www.photoplog.com/">' . $vbphrase['cartplog_powered_by_cartplog'] . ' ' . CARTPLOG_VERSION . '</a></div>'; // do not hide, change, remove, etcetera !!! $footer = $cartplog['powered_by'] . $footer; $cartplog_currencies = array('AUD', 'CAD', 'EUR', 'GBP', 'USD'); $cartplog['currency_code'] = 'USD'; if (isset($cartplog_currencies[$vbulletin->options['cartplog_currency']])) { $cartplog['currency_code'] = $cartplog_currencies[$vbulletin->options['cartplog_currency']]; } // #################### INITIALIZE COOKIE SESSION ######################### if ($_REQUEST['do'] != 'postback') { $vbulletin->input->clean_array_gpc('c', array( COOKIE_PREFIX . 'cartplog' => TYPE_NOHTML )); $cartplog['cookie'] = $vbulletin->GPC[COOKIE_PREFIX . 'cartplog']; if ($cartplog['cookie']) { $cartplog_count_check = $db->query_first("SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' AND completed = 0 "); if ($cartplog_count_check['cnt'] != 1) { $cartplog['cookie'] = ''; vbsetcookie('cartplog', '', false); } } if (empty($cartplog['cookie'])) { $cartplog_hash = rand() . TIMENOW . uniqid(microtime(), true) . $vbulletin->userinfo['userid']; $cartplog['cookie'] = md5($cartplog_hash); $cartplog_flag = true; while ($cartplog_flag) { $cartplog_count_check = $db->query_first("SELECT COUNT(*) AS cnt FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); if ($cartplog_count_check['cnt']) { $cartplog_hash = rand() . TIMENOW . uniqid(microtime(), true) . $vbulletin->userinfo['userid']; $cartplog['cookie'] = md5($cartplog_hash); } else { $cartplog_flag = false; $db->query_write("INSERT INTO " . TABLE_PREFIX . "cartplog_sessions (sessionid, userid, completed, dateline, products) VALUES ( '" . $db->escape_string($cartplog['cookie']) . "', " . intval($vbulletin->userinfo['userid']) . ", 0, " . intval(TIMENOW) . ", 'a:0:{}' ) "); vbsetcookie('cartplog', $cartplog['cookie']); } } } } else if ($_REQUEST['do'] == 'postback') { $vbulletin->nozip = true; } // ######################## START MAIN SCRIPT ############################# if ($_REQUEST['do'] == 'viewindex') { // full table scan but no one should have millions of products $cartplog_product_infos = $db->query_read("SELECT productid, catid, thumb, title, price, sales FROM " . TABLE_PREFIX . "cartplog_products ORDER BY RAND() LIMIT 15"); $cartplog['product_list'] = ''; $cartplog_count = 0; $cartplog_max_productid = 0; $cartplog_max_salescnt = 0; while ($cartplog_product_info = $db->fetch_array($cartplog_product_infos)) { $cartplog_count ++; $cartplog['product_productid'] = intval($cartplog_product_info['productid']); $cartplog['product_catid'] = intval($cartplog_product_info['catid']); $cartplog['product_thumb'] = strval($cartplog_product_info['thumb']); $cartplog['product_title'] = htmlspecialchars_uni($cartplog_product_info['title']); $cartplog['product_price'] = round(floatval($cartplog_product_info['price']), 2); $cartplog['product_sales'] = intval($cartplog_product_info['sales']); $cartplog_max_productid = max($cartplog_max_productid, $cartplog['product_productid']); $cartplog_max_salescnt = max($cartplog_max_salescnt, $cartplog['product_sales']); eval('$cartplog[\'product_list\'] .= "' . fetch_template('cartplog_product_item') . '";'); if ($cartplog_count % 3 == 0) { $cartplog['product_list'] .= '</tr><tr>'; } } $db->free_result($cartplog_product_infos); $cartplog['product_list'] = eregi_replace(preg_quote('</tr><tr>') . '$', '', $cartplog['product_list']); while ($cartplog_count % 3 != 0) { $cartplog['product_list'] .= '<td class="alt1" align="center" valign="bottom"> </td>'; $cartplog_count ++; } $cartplog_count = 0; $cartplog_product_info = $db->query_first("SELECT productid, catid, thumb, title, price FROM " . TABLE_PREFIX . "cartplog_products WHERE productid = " . intval($cartplog_max_productid) . " "); $cartplog['newest_product'] = ''; $cartplog['product_productid'] = intval($cartplog_product_info['productid']); $cartplog['product_catid'] = intval($cartplog_product_info['catid']); $cartplog['product_thumb'] = strval($cartplog_product_info['thumb']); $cartplog['product_title'] = htmlspecialchars_uni($cartplog_product_info['title']); $cartplog['product_price'] = round(floatval($cartplog_product_info['price']), 2); eval('$cartplog[\'newest_product\'] .= "' . fetch_template('cartplog_product_item') . '";'); $db->free_result($cartplog_product_info); $cartplog_product_infos = $db->query_read("SELECT productid, catid, thumb, title, price FROM " . TABLE_PREFIX . "cartplog_products WHERE sales = " . intval($cartplog_max_salescnt) . " LIMIT 5"); $cartplog['popular_products'] = ''; while ($cartplog_product_info = $db->fetch_array($cartplog_product_infos)) { $cartplog['product_productid'] = intval($cartplog_product_info['productid']); $cartplog['product_catid'] = intval($cartplog_product_info['catid']); $cartplog['product_thumb'] = strval($cartplog_product_info['thumb']); $cartplog['product_title'] = htmlspecialchars_uni($cartplog_product_info['title']); $cartplog['product_price'] = round(floatval($cartplog_product_info['price']), 2); eval('$cartplog[\'popular_products\'] .= "' . fetch_template('cartplog_product_item') . '";'); $cartplog['popular_products'] .= '</tr><tr>'; } $db->free_result($cartplog_product_infos); $cartplog['popular_products'] = eregi_replace(preg_quote('</tr><tr>') . '$', '', $cartplog['popular_products']); $cartplog_category_infos = $db->query_read("SELECT catid, title, products FROM " . TABLE_PREFIX . "cartplog_categories ORDER BY displayorder "); $cartplog['category_list'] = ''; while ($cartplog_category_info = $db->fetch_array($cartplog_category_infos)) { $cartplog['category_catid'] = intval($cartplog_category_info['catid']); $cartplog['category_products'] = intval($cartplog_category_info['products']); $cartplog['category_title'] = htmlspecialchars_uni($cartplog_category_info['title']); eval('$cartplog[\'category_list\'] .= "' . fetch_template('cartplog_category_list') . '";'); } $db->free_result($cartplog_category_infos); $cartplog_basket_check = $db->query_first("SELECT products FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); $cartplog['basket_count'] = 0; $cartplog['basket_total'] = 0; if ($cartplog_basket_check['products']) { $cartplog_basket_check['products'] = unserialize($cartplog_basket_check['products']); if (!is_array($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } foreach($cartplog_basket_check['products'] AS $cartplog_basket_productid => $cartplog_basket_array) { $cartplog['basket_count'] += intval($cartplog_basket_array['quantity']); $cartplog['basket_total'] += round(intval($cartplog_basket_array['quantity']) * floatval($cartplog_basket_array['price']), 2); } } else { $cartplog_basket_check['products'] = array(); } $db->free_result($cartplog_basket_check); $cartplog['basket_total'] = number_format($cartplog['basket_total'], 2, '.', ''); eval('$cartplog[\'basket_summary\'] = "' . fetch_template('cartplog_basket_summary') . '";'); $navbits = array(); $navbits['cartplog.php' . $vbulletin->session->vars['sessionurl_q']] = htmlspecialchars_uni($vbphrase['cartplog']); $navbits[''] = htmlspecialchars_uni($vbphrase['cartplog_shopping_cart']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('cartplog_view_index') . '");'); } if ($_REQUEST['do'] == 'viewcategory') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogcatid' => TYPE_UINT, )); $cartplog['categoryid'] = $vbulletin->GPC['cartplogcatid']; $cartplog_product_infos = $db->query_read("SELECT productid, thumb, title, price FROM " . TABLE_PREFIX . "cartplog_products WHERE catid = " . intval($cartplog['categoryid']) . " ORDER BY title ASC "); $cartplog['category_items'] = ''; if ($cartplog_product_infos) { while ($cartplog_product_info = $db->fetch_array($cartplog_product_infos)) { $cartplog['productid'] = intval($cartplog_product_info['productid']); $cartplog['thumb'] = strval($cartplog_product_info['thumb']); $cartplog['title'] = htmlspecialchars_uni($cartplog_product_info['title']); $cartplog['price'] = round(floatval($cartplog_product_info['price']), 2); eval('$cartplog[\'category_items\'] .= "' . fetch_template('cartplog_category_item') . '";'); } $db->free_result($cartplog_product_infos); $navbits = array(); $navbits['cartplog.php' . $vbulletin->session->vars['sessionurl_q']] = htmlspecialchars_uni($vbphrase['cartplog']); $navbits[''] = htmlspecialchars_uni($vbphrase['cartplog_view_category']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('cartplog_view_category') . '");'); } else { $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewindex'; exec_header_redirect($cartplog_url); exit(); } } if ($_REQUEST['do'] == 'viewcart' || $_REQUEST['do'] == 'checkout') { $cartplog['checkout'] = 0; if ($_REQUEST['do'] == 'checkout') { $cartplog['checkout'] = 1; $cartplog_paypal_api = $db->query_first("SELECT settings FROM " . TABLE_PREFIX . "paymentapi WHERE classname = 'paypal' "); $cartplog['ppemail'] = ''; $cartplog['primaryemail'] = ''; $cartplog_paypal_api['settings'] = unserialize($cartplog_paypal_api['settings']); if (is_array($cartplog_paypal_api['settings'])) { foreach($cartplog_paypal_api['settings'] AS $cartplog_paypal_api_title => $cartplog_paypal_api_array) { if ($cartplog_paypal_api_title == 'ppemail') { $cartplog['ppemail'] = strtolower($cartplog_paypal_api_array['value']); } if ($cartplog_paypal_api_title == 'primaryemail') { $cartplog['primaryemail'] = strtolower($cartplog_paypal_api_array['value']); } } } } $cartplog_basket_check = $db->query_first("SELECT products FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); $cartplog['basket_items'] = ''; $cartplog['basket_total'] = 0; $cartplog['basket_hidden'] = ''; $cartplog['xnum'] = 0; if ($cartplog_basket_check['products']) { $cartplog_basket_check['products'] = unserialize($cartplog_basket_check['products']); if (!is_array($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } foreach($cartplog_basket_check['products'] AS $cartplog_basket_productid => $cartplog_basket_array) { $cartplog['basket_productid'] = intval($cartplog_basket_productid); $cartplog['basket_quantity'] = intval($cartplog_basket_array['quantity']); $cartplog['basket_thumb'] = strval($cartplog_basket_array['thumb']); $cartplog['basket_title'] = htmlspecialchars_uni($cartplog_basket_array['title']); $cartplog['basket_price'] = round(floatval($cartplog_basket_array['price']), 2); $cartplog['basket_options'] = nl2br(htmlspecialchars_uni($cartplog_basket_array['options'])); $cartplog['basket_lineprice'] = round($cartplog['basket_quantity'] * $cartplog['basket_price'], 2); $cartplog['basket_total'] += $cartplog['basket_lineprice']; eval('$cartplog[\'basket_items\'] .= "' . fetch_template('cartplog_basket_item') . '";'); if ($cartplog['checkout']) { $cartplog['xnum'] ++; $cartplog['basket_options'] = str_replace('<br />', ', ', $cartplog['basket_options']); if (!vbstrlen($cartplog['basket_options'])) { $cartplog['basket_options'] = $vbphrase['none']; } $cartplog['basket_hidden'] .= ' <input type="hidden" name="item_name_' . $cartplog['xnum'] . '" value="' . $cartplog['basket_title'] . '" /> <input type="hidden" name="item_number_' . $cartplog['xnum'] . '" value="' . $cartplog['cookie'] . '" /> <input type="hidden" name="amount_' . $cartplog['xnum'] . '" value="' . $cartplog['basket_price'] . '" /> <input type="hidden" name="quantity_' . $cartplog['xnum'] . '" value="' . $cartplog['basket_quantity'] . '" /> <input type="hidden" name="shipping_' . $cartplog['xnum'] . '" value="0.00" /> <input type="hidden" name="on0_' . $cartplog['xnum'] . '" value="' . $vbphrase['options'] . '" /> <input type="hidden" name="os0_' . $cartplog['xnum'] . '" value="' . $cartplog['basket_options'] . '" /> '; } } } else { $cartplog_basket_check['products'] = array(); } $cartplog['basket_total'] = number_format($cartplog['basket_total'], 2, '.', ''); $navbits = array(); $navbits['cartplog.php' . $vbulletin->session->vars['sessionurl_q']] = htmlspecialchars_uni($vbphrase['cartplog']); $navbits[''] = htmlspecialchars_uni($vbphrase['cartplog_view_cart']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('cartplog_view_cart') . '");'); } if ($_REQUEST['do'] == 'viewhistory') { $cartplog_transaction_infos = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "cartplog_transactions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " ORDER BY dateline DESC "); $cartplog['history_items'] = ''; $cartplog['history_list'] = ''; while ($cartplog_transaction_info = $db->fetch_array($cartplog_transaction_infos)) { $cartplog['history_items'] = ''; $cartplog['sessionid'] = htmlspecialchars_uni($cartplog_transaction_info['sessionid']); $cartplog['total'] = round(floatval($cartplog_transaction_info['total']), 2); $cartplog['status'] = htmlspecialchars_uni($cartplog_transaction_info['status']); $cartplog['date'] = vbdate($vbulletin->options['dateformat'], intval($cartplog_transaction_info['dateline'])); $cartplog_transaction_info['products'] = unserialize($cartplog_transaction_info['products']); if (!is_array($cartplog_transaction_info['products'])) { $cartplog_transaction_info['products'] = array(); } foreach($cartplog_transaction_info['products'] AS $cartplog_transaction_productid => $cartplog_transaction_array) { $cartplog['productid'] = intval($cartplog_transaction_productid); $cartplog['quantity'] = intval($cartplog_transaction_array['quantity']); $cartplog['thumb'] = strval($cartplog_transaction_array['thumb']); $cartplog['title'] = htmlspecialchars_uni($cartplog_transaction_array['title']); $cartplog['price'] = round(floatval($cartplog_transaction_array['price']), 2); $cartplog['options'] = nl2br(htmlspecialchars_uni($cartplog_transaction_array['options'])); $cartplog['lineprice'] = round($cartplog['quantity'] * $cartplog['price'], 2); if ($cartplog['thumb']) { $cartplog['thumb'] = '<img style="' . $vbulletin->options['cartplog_thumbcss'] . '" src="' . $cartplog['thumb'] . '" alt="" border="0" />'; } else { $cartplog['thumb'] = '<img style="' . $vbulletin->options['cartplog_thumbcss'] . '" src="../' . $vbulletin->options['cleargifurl'] . '" alt="" border="0" />'; } eval('$cartplog[\'history_items\'] .= "' . fetch_template('cartplog_history_item') . '";'); } eval('$cartplog[\'history_list\'] .= "' . fetch_template('cartplog_history_list') . '";'); } $db->free_result($cartplog_transaction_infos); if (!$cartplog['history_list']) { $cartplog['history_list'] = '<tr><td class="alt1">' . $vbphrase['none'] . '</td></tr>'; } $navbits = array(); $navbits['cartplog.php' . $vbulletin->session->vars['sessionurl_q']] = htmlspecialchars_uni($vbphrase['cartplog']); $navbits[''] = htmlspecialchars_uni($vbphrase['cartplog_view_history']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('cartplog_view_history') . '");'); } if ($_REQUEST['do'] == 'viewitem') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogproductid' => TYPE_UINT, )); $cartplog['productid'] = $vbulletin->GPC['cartplogproductid']; $cartplog_product_check = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "cartplog_products WHERE productid = " . intval($cartplog['productid']) . " "); if ($cartplog_product_check) { $cartplog['product_productid'] = intval($cartplog_product_check['productid']); $cartplog['product_thumb'] = strval($cartplog_product_check['thumb']); $cartplog['product_title'] = htmlspecialchars_uni($cartplog_product_check['title']); $cartplog['product_description'] = strval($cartplog_product_check['description']); $cartplog['product_price'] = round(floatval($cartplog_product_check['price']), 2); $cartplog['product_options'] = ''; $cartplog_product_options = array_map('trim', unserialize($cartplog_product_check['options'])); if (!is_array($cartplog_product_options)) { $cartplog_product_options = array(); } foreach($cartplog_product_options AS $cartplog_options_key => $cartplog_options_title) { if (vbstrlen($cartplog_options_title)) { $cartplog['options_title'] = htmlspecialchars_uni($cartplog_options_title); $cartplog['product_options'] .= '<option value="' . $cartplog['options_title'] . '">' . $cartplog['options_title'] . '</option>'; $cartplog['product_options'] .= "\n"; } } if ($cartplog['product_options']) { $cartplog['product_options'] = '<select name="cartplogoptions">' . $cartplog['product_options'] . '</select>'; } $navbits = array(); $navbits['cartplog.php' . $vbulletin->session->vars['sessionurl_q']] = htmlspecialchars_uni($vbphrase['cartplog']); $navbits[''] = htmlspecialchars_uni($vbphrase['cartplog_view_item']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('cartplog_view_item') . '");'); } else { $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewindex'; exec_header_redirect($cartplog_url); exit(); } } if ($_REQUEST['do'] == 'additem') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogproductid' => TYPE_UINT, 'cartplogoptions' => TYPE_STR, 'cartplogsubmit' => TYPE_STR )); $cartplog['productid'] = $vbulletin->GPC['cartplogproductid']; $cartplog['options'] = $vbulletin->GPC['cartplogoptions']; $cartplog['submit'] = $vbulletin->GPC['cartplogsubmit']; if ($cartplog['submit'] == $vbphrase['cartplog_continue_shopping']) { $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewindex'; exec_header_redirect($cartplog_url); exit(); } $cartplog_product_check = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "cartplog_products WHERE productid = " . intval($cartplog['productid']) . " "); if ($cartplog_product_check) { if ($cartplog_product_check['options']) { $cartplog_product_check['options'] = array_map('trim', unserialize($cartplog_product_check['options'])); if (is_array($cartplog_product_check['options']) && vbstrlen($cartplog['options'])) { $cartplog_search_key = array_search($cartplog['options'], $cartplog_product_check['options']); if ($cartplog_search_key === false) { $cartplog['options'] = ''; } } else { $cartplog['options'] = ''; } } else { $cartplog['options'] = ''; } $cartplog_basket_check = $db->query_first("SELECT products FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); if ($cartplog_basket_check['products']) { $cartplog_basket_check['products'] = unserialize($cartplog_basket_check['products']); if (!is_array($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } if ($cartplog_basket_check['products'][$cartplog['productid']]) { $cartplog_basket_check['products'][$cartplog['productid']]['quantity'] ++; if (vbstrlen($cartplog_basket_check['products'][$cartplog['productid']]['options']) && vbstrlen($cartplog['options'])) { $cartplog_basket_check['products'][$cartplog['productid']]['options'] .= ', ' . $cartplog['options']; } else if (vbstrlen($cartplog['options'])) { $cartplog_basket_check['products'][$cartplog['productid']]['options'] = $cartplog['options']; } } else { $cartplog_basket_check['products'][$cartplog['productid']] = array( 'quantity' => 1, 'thumb' => $cartplog_product_check['thumb'], 'title' => $cartplog_product_check['title'], 'price' => $cartplog_product_check['price'], 'options' => $cartplog['options'] ); } $cartplog_basket_check['products'] = serialize($cartplog_basket_check['products']); $db->query_write("UPDATE " . TABLE_PREFIX . "cartplog_sessions SET products = '" . $db->escape_string($cartplog_basket_check['products']) . "' WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); } } $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewcart'; exec_header_redirect($cartplog_url); exit(); } if ($_REQUEST['do'] == 'removeitem') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogproductid' => TYPE_UINT )); $cartplog['productid'] = $vbulletin->GPC['cartplogproductid']; $cartplog_basket_check = $db->query_first("SELECT products FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); if ($cartplog_basket_check['products']) { $cartplog_basket_check['products'] = unserialize($cartplog_basket_check['products']); if (!is_array($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } unset($cartplog_basket_check['products'][$cartplog['productid']]); $cartplog_basket_check['products'] = serialize($cartplog_basket_check['products']); $db->query_write("UPDATE " . TABLE_PREFIX . "cartplog_sessions SET products = '" . $db->escape_string($cartplog_basket_check['products']) . "' WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); } $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewcart'; exec_header_redirect($cartplog_url); exit(); } if ($_REQUEST['do'] == 'updatequantity') { $vbulletin->input->clean_array_gpc('r', array( 'cartplogquantity' => TYPE_ARRAY, 'cartplogsubmit' => TYPE_STR )); $cartplog['quantity'] = $vbulletin->GPC['cartplogquantity']; $cartplog['submit'] = $vbulletin->GPC['cartplogsubmit']; if ($cartplog['submit'] == $vbphrase['cartplog_continue_shopping']) { $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewindex'; exec_header_redirect($cartplog_url); exit(); } if ($cartplog['submit'] == $vbphrase['cartplog_checkout']) { $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=checkout'; exec_header_redirect($cartplog_url); exit(); } $cartplog_basket_check = $db->query_first("SELECT products FROM " . TABLE_PREFIX . "cartplog_sessions WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); if ($cartplog_basket_check['products']) { $cartplog_basket_check['products'] = unserialize($cartplog_basket_check['products']); if (!is_array($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } if (!empty($cartplog_basket_check['products'])) { foreach($cartplog['quantity'] AS $cartplog_basket_productid => $cartplog_basket_quantity) { $cartplog_basket_productid = max(0, intval($cartplog_basket_productid)); $cartplog_basket_quantity = max(0, intval($cartplog_basket_quantity)); if (!$cartplog_basket_quantity) { unset($cartplog_basket_check['products'][$cartplog_basket_productid]); } else { $cartplog_basket_check['products'][$cartplog_basket_productid]['quantity'] = $cartplog_basket_quantity; } } if (empty($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } $cartplog_basket_check['products'] = serialize($cartplog_basket_check['products']); $db->query_write("UPDATE " . TABLE_PREFIX . "cartplog_sessions SET products = '" . $db->escape_string($cartplog_basket_check['products']) . "' WHERE userid = " . intval($vbulletin->userinfo['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['cookie']) . "' "); } } $cartplog_url = 'cartplog.php?' . $vbulletin->session->vars['sessionurl'] . 'do=viewcart'; exec_header_redirect($cartplog_url); exit(); } if ($_REQUEST['do'] == 'postback') { $cartplog_paypal_postback = 'cmd=_notify-validate'; foreach($_POST AS $cartplog_paypal_key => $cartplog_paypal_value) { if (!empty($cartplog_paypal_value)) { $cartplog_paypal_postback .= '&' . $cartplog_paypal_key . '=' . urlencode($cartplog_paypal_value); } } $cartplog_paypal_result = false; $cartplog_used_curl = false; if (function_exists('curl_init') && $cartplog_paypal_curl = curl_init()) { curl_setopt($cartplog_paypal_curl, CURLOPT_URL, 'http://www.paypal.com/cgi-bin/webscr'); curl_setopt($cartplog_paypal_curl, CURLOPT_POST, true); // for x-www-form-urlencoded curl_setopt($cartplog_paypal_curl, CURLOPT_POSTFIELDSIZE, strlen($cartplog_paypal_postback)); curl_setopt($cartplog_paypal_curl, CURLOPT_POSTFIELDS, $cartplog_paypal_postback); curl_setopt($cartplog_paypal_curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($cartplog_paypal_curl, CURLOPT_TIMEOUT, 30); $cartplog_paypal_result = curl_exec($cartplog_paypal_curl); // retuns false on failure curl_close($cartplog_paypal_curl); if ($cartplog_paypal_result !== false) { $cartplog_used_curl = true; } } if (!$cartplog_used_curl) { $cartplog_paypal_header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $cartplog_paypal_header .= "Host: www.paypal.com\r\n"; $cartplog_paypal_header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $cartplog_paypal_header .= "Content-Length: " . strlen($cartplog_paypal_postback) . "\r\n\r\n"; $cartplog_paypal_header .= $cartplog_paypal_postback; $cartplog_paypal_errno = $cartplog_paypal_errstr = ''; if ($cartplog_paypal_fsockopen = fsockopen('www.paypal.com', 80, $cartplog_paypal_errno, $cartplog_paypal_errstr, 30)) { stream_set_timeout($cartplog_paypal_fsockopen, 30); fwrite($cartplog_paypal_fsockopen, $cartplog_paypal_header); while (!feof($cartplog_paypal_fsockopen)) { $cartplog_paypal_result = fgets($cartplog_paypal_fsockopen, 1024); } fclose($cartplog_paypal_fsockopen); } } if ($cartplog_paypal_result == 'VERIFIED') { $vbulletin->input->clean_array_gpc('p', array( 'item_number1' => TYPE_NOHTML, 'business' => TYPE_NOHTML, 'receiver_email' => TYPE_NOHTML, 'mc_gross' => TYPE_NUM, 'payment_status' => TYPE_NOHTML, 'txn_id' => TYPE_NOHTML, 'txn_type' => TYPE_NOHTML )); $cartplog['item_number'] = $vbulletin->GPC['item_number1']; $cartplog['business'] = $vbulletin->GPC['business']; $cartplog['receiver_email'] = $vbulletin->GPC['receiver_email']; $cartplog['mc_gross'] = $vbulletin->GPC['mc_gross']; $cartplog['payment_status'] = $vbulletin->GPC['payment_status']; $cartplog['txn_id'] = $vbulletin->GPC['txn_id']; $cartplog['txn_type'] = $vbulletin->GPC['txn_type']; $cartplog_paypal_api = $db->query_first("SELECT settings FROM " . TABLE_PREFIX . "paymentapi WHERE classname = 'paypal' "); $cartplog['ppemail'] = ''; $cartplog['primaryemail'] = ''; $cartplog_paypal_api['settings'] = unserialize($cartplog_paypal_api['settings']); if (is_array($cartplog_paypal_api['settings'])) { foreach($cartplog_paypal_api['settings'] AS $cartplog_paypal_api_title => $cartplog_paypal_api_array) { if ($cartplog_paypal_api_title == 'ppemail') { $cartplog['ppemail'] = strtolower($cartplog_paypal_api_array['value']); } if ($cartplog_paypal_api_title == 'primaryemail') { $cartplog['primaryemail'] = strtolower($cartplog_paypal_api_array['value']); } } } if ($vbulletin->GPC['business'] == $cartplog['ppemail'] || $vbulletin->GPC['receiver_email'] == $cartplog['primaryemail']) { $cartplog_basket_check = $db->query_first("SELECT cartplog_sessions.*, user.username, user.userid FROM " . TABLE_PREFIX . "cartplog_sessions AS cartplog_sessions, " . TABLE_PREFIX . "user AS user WHERE cartplog_sessions.userid = user.userid AND cartplog_sessions.sessionid = '" . $db->escape_string($cartplog['item_number']) . "' "); $cartplog['sessionid'] = strval($cartplog_basket_check['sessionid']); $cartplog['userid'] = intval($cartplog_basket_check['userid']); $cartplog['products'] = strval($cartplog_basket_check['products']); $cartplog['username'] = strval($cartplog_basket_check['username']); $cartplog['basket_total'] = 0; $cartplog['popular'] = array(); $cartplog['products2'] = ''; if ($cartplog_basket_check['products']) { $cartplog_basket_check['products'] = unserialize($cartplog['products']); if (!is_array($cartplog_basket_check['products'])) { $cartplog_basket_check['products'] = array(); } foreach($cartplog_basket_check['products'] AS $cartplog_basket_productid => $cartplog_basket_array) { $cartplog['basket_total'] += round(intval($cartplog_basket_array['quantity']) * floatval($cartplog_basket_array['price']), 2); $cartplog['popular'][] = intval($cartplog_basket_productid); if (!vbstrlen($cartplog_basket_array['options'])) { $cartplog_basket_array['options'] = $vbphrase['none']; } $cartplog['products2'] .= "\n\t" . $vbphrase['cartplog_quantity'] . ": " . $cartplog_basket_array['quantity'] . "\n\t" . $vbphrase['title'] . ": " . $cartplog_basket_array['title'] . "\n\t" . $vbphrase['options'] . ": " . $cartplog_basket_array['options'] . "\n"; } } if (!$cartplog['products2']) { $cartplog['products2'] = $vbphrase['cartplog_unknown']; } $cartplog['basket_total'] = number_format($cartplog['basket_total'], 2, '.', ''); $cartplog['mc_gross'] = number_format(floatval($cartplog['mc_gross']), 2, '.', ''); $cartplog_transaction_info = $db->query_first("SELECT txnid FROM " . TABLE_PREFIX . "cartplog_transactions WHERE txnid = '" . $db->escape_string($cartplog['txn_id']) . "' AND class = 'paypal' "); if (!$cartplog_transaction_info) { $db->query_write("INSERT INTO " . TABLE_PREFIX . "cartplog_transactions (sessionid, txnid, userid, total, status, class, dateline, products) VALUES ( '" . $db->escape_string($cartplog['sessionid']) . "', '" . $db->escape_string($cartplog['txn_id']) . "', " . intval($cartplog['userid']) . ", " . floatval($cartplog['mc_gross']) . ", '" . $db->escape_string($cartplog['payment_status']) . "', 'paypal', " . intval(TIMENOW) . ", '" . $db->escape_string($cartplog['products']) . "' ) "); $db->query_write("UPDATE " . TABLE_PREFIX . "cartplog_sessions SET completed = 1 WHERE userid = " . intval($cartplog['userid']) . " AND sessionid = '" . $db->escape_string($cartplog['sessionid']) . "' "); } $cartplog['products'] = $cartplog['products2']; $cartplog_phrase = 'cartplog_payment_unknown'; if ($cartplog['txn_type'] == 'cart' && $cartplog['payment_status'] == 'Completed' && $cartplog['basket_total'] == $cartplog['mc_gross']) { $cartplog_phrase = 'cartplog_payment_received'; if (!empty($cartplog['popular'])) { $db->query_write("UPDATE " . TABLE_PREFIX . "cartplog_products SET sales = sales + 1 WHERE productid IN (" . implode(',', $cartplog['popular']) . ") "); } } else if ($cartplog['payment_status'] == 'Refunded' || $cartplog['payment_status'] == 'Reversed') { $cartplog_phrase = 'cartplog_payment_reversed'; } if ($vbulletin->options['paymentemail']) { if (!$vbphrase) { $vbphrase = init_language(); } $cartplog['username'] = unhtmlspecialchars($cartplog['username']); $cartplog_subject = $cartplog_message = ''; eval(fetch_email_phrases($cartplog_phrase, 0, '', 'cartplog_')); $cartplog_emails = explode(' ', $vbulletin->options['paymentemail']); foreach($cartplog_emails AS $cartplog_email) { $cartplog_email = trim($cartplog_email); if ($cartplog_email) { vbmail($cartplog_email, $cartplog_subject, $cartplog_message, true); } } } if (SAPI_NAME == 'cgi' OR SAPI_NAME == 'cgi-fcgi') { header('Status: 200 OK'); } else { header('HTTP/1.1 200 OK'); } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/ Share on other sites More sharing options...
adam291086 Posted January 29, 2008 Share Posted January 29, 2008 sorry i dont have time to read all of that. To make an image into a like you need to do something like <A HREF="www.example.com"><img src="images2/bart.gif"></A> so where ever you make the link for the product copy it and paste it just before the image source. Then add </a> after the image scr Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/#findComment-452307 Share on other sites More sharing options...
dcuellar Posted January 29, 2008 Author Share Posted January 29, 2008 Will that work with all the new products I add? I want it to automatically create the link like the title of the product does. check it out here. http://www.unifiedchamp.com/ucforum/cartplog.php Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/#findComment-452711 Share on other sites More sharing options...
dcuellar Posted January 30, 2008 Author Share Posted January 30, 2008 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/#findComment-453341 Share on other sites More sharing options...
dcuellar Posted January 30, 2008 Author Share Posted January 30, 2008 I'm thinking it's somewhere in here. Someone, anyone? while ($cartplog_product_info = $db->fetch_array($cartplog_product_infos)) { $cartplog['product_productid'] = intval($cartplog_product_info['productid']); $cartplog['product_catid'] = intval($cartplog_product_info['catid']); $cartplog['product_thumb'] = strval($cartplog_product_info['thumb']); $cartplog['product_title'] = htmlspecialchars_uni($cartplog_product_info['title']); $cartplog['product_price'] = round(floatval($cartplog_product_info['price']), 2); eval('$cartplog[\'popular_products\'] .= "' . fetch_template('cartplog_product_item') . '";'); $cartplog['popular_products'] .= '</tr><tr>'; } Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/#findComment-453422 Share on other sites More sharing options...
dcuellar Posted January 30, 2008 Author Share Posted January 30, 2008 Actually, here's the template: <td class="alt1" <if condition="$cartplog_count">style="padding: 25px; border: 1px solid #CCCCCC;" </if>align="center" valign="bottom"> <if condition="$cartplog[product_thumb]"> <img style="$vboptions[cartplog_thumbcss]" src="$cartplog[product_thumb]" alt="" border="0" /> <else /> <img style="$vboptions[cartplog_thumbcss]" src="$stylevar[imgdir_misc]/cartplog_no_image.gif" alt="" border="0" /> </if> <br /> <div class="smallfont"><a href="cartplog.php?$session[sessionurl]do=viewitem&cartplogproductid=$cartplog[product_productid]">$cartplog[product_title]</a></div> <div class="smallfont">$vbphrase[cartplog_price]: $cartplog[product_price] $cartplog[currency_code]</div> <div class="smallfont"><a href="cartplog.php?$session[sessionurl]do=viewcategory&cartplogcatid=$cartplog[product_catid]">$vbphrase[cartplog_view_category]</a></div> </td> I see an a href attached to the [product_title] but I'm not sure where to put it for the thumb. Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/#findComment-453536 Share on other sites More sharing options...
dcuellar Posted January 30, 2008 Author Share Posted January 30, 2008 nevermind. I tried something and it worked. Thanks, anyways! Quote Link to comment https://forums.phpfreaks.com/topic/88373-solved-help-with-thumbnails/#findComment-453539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.