/** * Search items * * @param string $qStr : Query String * @param string $catStr : Category Name/ Category ID * @param string $locStr : Location / Location ID * @return array */ public function search($qStr, $catStr, $locStr, $userID) { global $db; $tradeCatIns = new BuckysTradeCategory(); $tradeLocationIns = new BuckysCountry(); //Get category data $catData = null; if (is_numeric($catStr)) { $catData = $tradeCatIns->getCategoryByID($catStr); } else { $catData = $tradeCatIns->getCategoryByName($catStr); } //Get Location data $locationData = null; if (is_numeric($locStr)) { $locationData = $tradeLocationIns->getCountryById($locStr); } else { $locationData = $tradeLocationIns->getCountryByName($locStr); } //Make Where condition $whereCondList = array(); if (isset($qStr) && $qStr != '') { $qStr = addslashes($qStr); $whereCondList[] = sprintf(" MATCH (i.title, i.subtitle, i.description) AGAINST ('%s' IN BOOLEAN MODE)", $qStr); } if (isset($catData)) { $whereCondList[] = 'i.catID=' . $catData['catID']; } else { if ($catStr != '') { return null; } } if (isset($locationData)) { $whereCondList[] = 'i.locationID=' . $locationData['countryID']; } if (isset($userID) && is_numeric($userID)) { $whereCondList[] = 'i.userID=' . $userID; } //Valid items $avaiableTime = date('Y-m-d H:i:s', time() - TRADE_ITEM_LIFETIME * 3600 * 24); $whereCondList[] = "i.createdDate >='" . $avaiableTime . "'"; $whereCondList[] = 'i.status=' . BuckysTradeItem::STATUS_ITEM_ACTIVE; $whereCond = ' WHERE ' . implode(' AND ', $whereCondList); $whereCond .= ' GROUP BY i.itemID '; $query = sprintf("SELECT i.*, (SELECT COUNT(*) FROM %s AS o WHERE i.itemID=o.targetItemID AND o.status=%d) AS offer, u.firstName, u.lastName, tu.totalRating, tu.positiveRating \n FROM %s AS i \n LEFT JOIN %s AS tu ON i.userID=tu.userID \n LEFT JOIN %s AS u ON i.userID=u.userID \n ", TABLE_TRADE_OFFERS, BuckysTradeOffer::STATUS_OFFER_ACTIVE, TABLE_TRADE_ITEMS, TABLE_TRADE_USERS, TABLE_USERS); $query = $db->prepare($query . $whereCond); $data = $db->getResultsArray($query); return $data; }
/** * Search products * * @param string $qStr : Query String * @param string $catStr : Category Name/ Category ID * @param string $locStr : Location / Location ID * @return array */ public function search($qStr, $catStr, $locStr, $userID) { global $db; $catIns = new BuckysShopCategory(); $locationIns = new BuckysCountry(); //Get category data $catData = null; if (is_numeric($catStr)) { $catData = $catIns->getCategoryByID($catStr); } else { $catData = $catIns->getCategoryByName($catStr); } //Get Location data $locationData = null; if (is_numeric($locStr)) { $locationData = $locationIns->getCountryById($locStr); } else { $locationData = $locationIns->getCountryByName($locStr); } //Make Where condition $whereCondList = []; if (isset($qStr) && $qStr != '') { $qStr = addslashes($qStr); $whereCondList[] = sprintf(" MATCH (p.title, p.subtitle, p.description) AGAINST ('%s' IN BOOLEAN MODE)", $qStr); } if (isset($catData)) { $whereCondList[] = 'p.catID=' . $catData['catID']; } else { if ($catStr != '') { return null; } } if (isset($locationData)) { $whereCondList[] = 'p.locationID=' . $locationData['countryID']; } if (isset($userID) && is_numeric($userID)) { $whereCondList[] = 'p.userID=' . $userID; } //Valid items $avaiableTime = date('Y-m-d H:i:s'); $whereCondList[] = " (p.expiryDate >='" . $avaiableTime . "' OR p.listingDuration=-1) "; $whereCondList[] = 'p.status=' . BuckysShopProduct::STATUS_ACTIVE; $whereCond = ' WHERE ' . implode(' AND ', $whereCondList); $whereCond .= ' GROUP BY p.productID '; $query = sprintf("SELECT p.*, u.firstName, u.lastName, tu.totalRating, tu.positiveRating \n FROM %s AS p \n LEFT JOIN %s AS tu ON p.userID=tu.userID \n LEFT JOIN %s AS u ON p.userID=u.userID \n ", TABLE_SHOP_PRODUCTS, TABLE_USERS_RATING, TABLE_USERS); $query = $db->prepare($query . $whereCond); $data = $db->getResultsArray($query); return $data; }
?> </div> <?php if (!$data['isDownloadable']) { ?> <div id="shipping_info_<?php echo $data['orderID']; ?> " class="row-shipping-info"> <strong>Their Shipping Information:</strong> <div> <?php $countryData = BuckysCountry::getCountryById($data['countryID']); $shippingAddressVal = '<div>' . $data['fullName'] . '</div>' . '<div>' . $data['address'] . '</div>' . '<div>' . $data['address2'] . '</div>' . '<div>' . $data['city'] . ', ' . $data['state'] . '</div>' . '<div>' . $data['zip'] . '</div>' . '<div>' . $countryData["country_title"] . '</div>'; ?> <?php echo $shippingAddressVal; ?> </div> </div> <?php } ?> </div> <div class="clear"></div> </td> <td class="n2">
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR); } buckys_enqueue_stylesheet('trade.css'); buckys_enqueue_javascript('trade.js'); $BUCKYS_GLOBALS['content'] = 'trade/shipping_info'; $BUCKYS_GLOBALS['headerType'] = 'trade'; $view = array(); //Save Shipping info $tradeUserIns = new BuckysTradeUser(); $countryIns = new BuckysCountry(); $view['update_message'] = ''; if ($_POST['action'] == 'saveShippingInfo') { $paramData = array('shippingAddress' => $_POST['shippingAddress'], 'shippingCity' => $_POST['shippingCity'], 'shippingState' => $_POST['shippingState'], 'shippingZip' => $_POST['shippingZip'], 'shippingCountryID' => $_POST['shippingCountryID']); $retVal = $tradeUserIns->updateShippingInfo($userID, $paramData); if ($retVal == false) { $view['update_message'] = 'Something goes wrong'; } else { $view['update_message'] = 'Your shipping info has been updated successfully.'; } } //Get offer_received info $view['trade_user_info'] = $tradeUserIns->getUserByID($userID); $view['country_list'] = $countryIns->getCountryList(); if (empty($view['trade_user_info'])) { buckys_redirect('/trade/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } $BUCKYS_GLOBALS['title'] = 'Shipping Info - BuckysRoomTrade';
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; $userID = buckys_is_logged_in(); buckys_enqueue_stylesheet('trade.css'); buckys_enqueue_javascript('trade.js'); $BUCKYS_GLOBALS['content'] = 'trade/view'; $BUCKYS_GLOBALS['headerType'] = 'trade'; $paramItemID = get_secure_integer($_REQUEST['id']); $view = array(); $tradeItemIns = new BuckysTradeItem(); $tradeCatIns = new BuckysTradeCategory(); $countryIns = new BuckysCountry(); $userIns = new BuckysUser(); $tradeOfferIns = new BuckysTradeOffer(); $view['item'] = $tradeItemIns->getItemById($paramItemID); $view['myID'] = $userID; if (!isset($view['item']) || $view['item']['status'] == BuckysTradeItem::STATUS_ITEM_INACTIVE) { buckys_redirect('/trade/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Check if the items owner is active one $userData = $userIns->getUserData($view['item']['userID']); if ($userData['status'] == BuckysUser::STATUS_USER_BANNED) { buckys_redirect('/trade/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Read more info from DB $catData = $tradeCatIns->getCategoryByID($view['item']['catID']); $view['item']['categoryName'] = isset($catData) ? $catData['name'] : ''; $countryData = $countryIns->getCountryById($view['item']['locationID']); $view['item']['locationName'] = isset($countryData) ? $countryData['country_title'] : ''; $view['item']['userInfo'] = $userIns->getUserBasicInfo($view['item']['userID']);
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; $userID = buckys_is_logged_in(); buckys_enqueue_stylesheet('shop.css'); buckys_enqueue_javascript('shop.js'); $TNB_GLOBALS['content'] = 'shop/view'; $TNB_GLOBALS['headerType'] = 'shop'; $paramShopID = get_secure_integer($_REQUEST['id']); $view = []; $shopProductIns = new BuckysShopProduct(); $catIns = new BuckysShopCategory(); $countryIns = new BuckysCountry(); $userIns = new BuckysUser(); $shippingInfoIns = new BuckysTradeUser(); $view['product'] = $shopProductIns->getProductById($paramShopID); $view['myID'] = $userID; if (!isset($view['product']) || $view['product']['status'] == BuckysShopProduct::STATUS_INACTIVE) { buckys_redirect('/shop/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Check if the items owner is active one $userData = $userIns->getUserData($view['product']['userID']); if ($userData['status'] == BuckysUser::STATUS_USER_BANNED) { buckys_redirect('/shop/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Read more info from DB $catData = $catIns->getCategoryByID($view['product']['catID']); $view['product']['categoryName'] = isset($catData) ? $catData['name'] : ''; $countryData = $countryIns->getCountryById($view['product']['locationID']); $view['product']['locationName'] = isset($countryData) ? $countryData['country_title'] : ''; $view['product']['userInfo'] = $userIns->getUserBasicInfo($view['product']['userID']);
/** * Get country by ID * * @param integer $countryID */ function buckys_trade_get_country_name($countryID) { $countryIns = new BuckysCountry(); $countryData = $countryIns->getCountryById($countryID); if ($countryData) { return $countryData['country_title']; } return; }
<?php echo $view['my_info']['firstName'] . ' ' . $view['my_info']['lastName'] . "<br/>"; if ($view['my_shipping_info']['shippingAddress'] != '') { echo $view['my_shipping_info']['shippingAddress'] . ' ' . $view['my_shipping_info']['shippingAddress2'] . "<br/>"; } if ($view['my_shipping_info']['shippingCity'] != '') { echo $view['my_shipping_info']['shippingCity'] . ", "; } if ($view['my_shipping_info']['shippingState'] != '') { echo $view['my_shipping_info']['shippingState'] . "<br/>"; } if ($view['my_shipping_info']['shippingZip'] != '') { echo $view['my_shipping_info']['shippingZip'] . "<br/>"; } if ($view['my_shipping_info']['shippingCountryID'] != '') { $cotD = BuckysCountry::getCountryById($view['my_shipping_info']['shippingCountryID']); echo $cotD['country_title']; } ?> </p> <label>Returns:</label> <p> <?php echo $productData['returnPolicy']; ?> </p> <label>Item:</label> <div class="clear"></div> <div class="prod-l">