/**
  * Create Order by array
  *
  * @param mixed $data
  * @return bool|int|null|string
  */
 public function createOrder($data)
 {
     global $db;
     $newID = $db->insertFromArray(TABLE_SHOP_ORDERS, $data);
     if ($newID) {
         //Create bitcoin transaction
         BuckysBitcoinTransaction::addTransaction($data['sellerID'], $data['buyerID'], BuckysBitcoinTransaction::ACTIVITY_TYPE_PRODUCT_PURCHASE, $newID, $data['totalPrice']);
         $shopProdIns = new BuckysShopProduct();
         $product = $shopProdIns->getProductById($data['productID']);
         if (!$product['isDownloadable']) {
             $shopProdIns->updateProduct($data['productID'], ['status' => BuckysShopProduct::STATUS_SOLD]);
         }
         //Send notification if the seller wants to get notification
         $notificationIns = new BuckysShopNotification();
         $notificationIns->createNotification($data['sellerID'], $data['buyerID'], BuckysShopNotification::ACTION_TYPE_PRODUCT_SOLD, $newID);
         return $newID;
     }
     return false;
 }
Exemplo n.º 2
0
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
buckys_enqueue_stylesheet('shop.css');
buckys_enqueue_javascript('shop.js');
$TNB_GLOBALS['content'] = 'shop/index';
$TNB_GLOBALS['headerType'] = 'shop';
//Get Top Users
$shopProductIns = new BuckysShopProduct();
$catIns = new BuckysShopCategory();
$view = [];
$view['recent_products'] = $shopProductIns->getRecentProducts(10);
$view['categories'] = $catIns->getCategoryList(0);
$TNB_GLOBALS['title'] = 'BuckysRoomShop - Buy and Sell Items with Bitcoin';
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
<?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_javascript('shop.js');
buckys_enqueue_stylesheet('shop.css');
$TNB_GLOBALS['content'] = 'shop/available';
$TNB_GLOBALS['headerType'] = 'shop';
$paramCurrentPage = get_secure_integer($_REQUEST['page']);
$paramType = get_secure_string($_REQUEST['type']);
$view = [];
//Get available products
$shopProductIns = new BuckysShopProduct();
$baseURL = '/shop/available.php';
if ($paramType == 'expired') {
    $baseURL .= "?type=" . $paramType;
} else {
    $paramType = '';
}
switch ($paramType) {
    case 'expired':
        $view['pagetitle'] = 'My Expired Items';
        $view['products'] = $shopProductIns->getProductList($userID, true, BuckysShopProduct::STATUS_ACTIVE);
        $view['type'] = 'expired';
        break;
    case 'available':
    default:
        $view['products'] = $shopProductIns->getProductList($userID, false, BuckysShopProduct::STATUS_ACTIVE);
        $view['pagetitle'] = 'My Items for Sale';
Exemplo n.º 4
0
/**
 * Purchase product function
 * this function is POST
 */
function purchaseProduct()
{
    $productIns = new BuckysShopProduct();
    $orderIns = new BuckysShopOrder();
    $buyerID = get_secure_integer($_REQUEST['buyerID']);
    $productID = get_secure_integer($_REQUEST['productID']);
    $userID = buckys_is_logged_in();
    //Can  you purchase this item?
    if ($buyerID != $userID) {
        buckys_redirect('/shop/view.php?id=' . $productID, MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
    }
    //Product is active?
    $prodData = $productIns->getProductById($productID, false);
    if (!$prodData || $prodData['status'] == BuckysShopProduct::STATUS_INACTIVE) {
        echo "here";
        exit;
        buckys_redirect('/shop/index.php' . $productID, MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    }
    //Is this your product?
    if ($prodData['userID'] == $buyerID) {
        buckys_redirect('/shop/view.php?id=' . $productID, MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
    }
    //Shipping price is set?
    if (!$prodData['isDownloadable']) {
        $shippingPrice = fn_buckys_get_available_shipping_price($buyerID, $productID);
        if ($shippingPrice === null) {
            buckys_redirect('/shop/view.php?id=' . $productID, 'This item can not be shipped to your address. Check your shipping address or contact the owner.', MSG_TYPE_ERROR);
        }
    } else {
        $shippingPrice = 0;
    }
    //Do you have money?
    $balance = BuckysBitcoin::getUserWalletBalance($buyerID);
    $balance = 100;
    $total = $prodData['price'] + $shippingPrice;
    if ($total > $balance) {
        buckys_redirect('/shop/view.php?id=' . $productID, 'You do not have bitcoin enough to purchase this item.', MSG_TYPE_ERROR);
    }
    //Purchase product
    $flag = $orderIns->makePayment($buyerID, $prodData['userID'], $total);
    if ($flag) {
        if (!$prodData['isDownloadable']) {
            $buyerShippingInfoID = $orderIns->createShippingInfo($buyerID);
        } else {
            $buyerShippingInfoID = 0;
        }
        $param = ['sellerID' => $prodData['userID'], 'buyerID' => $buyerID, 'productID' => $productID, 'unitPrice' => $prodData['price'], 'shippingPrice' => $shippingPrice, 'totalPrice' => $total, 'buyerShippingID' => $buyerShippingInfoID, 'trackingNo' => '', 'createdDate' => date('Y-m-d H:i:s'), 'status' => BuckysShopOrder::STATUS_SOLD];
        if ($orderIns->createOrder($param)) {
            buckys_redirect('/shop/purchase.php', 'You have purchased an item successfully!', MSG_TYPE_SUCCESS);
        } else {
            buckys_redirect('/shop/view.php?id=' . $productID, 'Something goes wrong with your purchase. Please contact customer support!', MSG_TYPE_ERROR);
        }
    } else {
        buckys_redirect('/shop/view.php?id=' . $productID, 'Payment problem. Please contact customer support!', MSG_TYPE_ERROR);
    }
}
 /**
  * Unban Users
  *
  * @param mixed $ids
  */
 public static function unbanUsers($ids)
 {
     global $db, $TNB_GLOBALS;
     if (!is_array($ids)) {
         $ids = [$ids];
     }
     //Check the user has lready been banned or not
     $rows = $db->getResultsArray("SELECT * FROM " . TABLE_BANNED_USERS . " WHERE bannedID IN (" . implode(', ', $ids) . ")");
     if ($rows) {
         foreach ($rows as $brow) {
             $userID = $brow['bannedUserID'];
             //Change User Table
             $db->query("UPDATE " . TABLE_USERS . " SET status=1 WHERE userID=" . $userID);
             //Change Posts table
             $db->query("UPDATE " . TABLE_POSTS . " SET post_status=1 WHERE poster=" . $userID);
             //Change Activities
             $db->query("UPDATE " . TABLE_MAIN_ACTIVITIES . " SET activityStatus=1 WHERE userID=" . $userID);
             //Change Messages
             $db->query("UPDATE " . TABLE_MESSAGES . " SET messageStatus=1 WHERE sender=" . $userID);
             //Fix Comments Count
             $query = $db->prepare("SELECT count(commentID) AS c, postID FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=%d AND commentStatus=0 GROUP BY postID", $userID);
             $pcRows = $db->getResultsArray($query);
             foreach ($pcRows as $row) {
                 $db->query("UPDATE " . TABLE_POSTS . " SET `comments` = `comments` + " . $row['c'] . " WHERE postID=" . $row['postID']);
             }
             //Unblock Comments
             $db->query("UPDATE " . TABLE_POSTS_COMMENTS . " SET commentStatus=1 WHERE commenter=" . $userID);
             //Fix Likes Count
             $query = $db->prepare("SELECT count(likeID) AS c, postID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%d AND likeStatus=0 GROUP BY postID", $userID);
             $plRows = $db->getResultsArray($query);
             foreach ($plRows as $row) {
                 $db->query("UPDATE " . TABLE_POSTS . " SET `likes` = `likes` + " . $row['c'] . " WHERE postID=" . $row['postID']);
             }
             //Unblock Likes
             $db->query("UPDATE " . TABLE_POSTS_LIKES . " SET likeStatus=1 WHERE userID=" . $userID);
             //Unblock Votes for Moderator
             $query = $db->prepare("SELECT count(voteID) AS c, candidateID FROM " . TABLE_MODERATOR_VOTES . " WHERE voterID=%d AND voteStatus=0 GROUP BY candidateID", $userID);
             $vRows = $db->getResultsArray($query);
             foreach ($vRows as $row) {
                 $db->query("UPDATE " . TABLE_MODERATOR_CANDIDATES . " SET `votes` = `votes` + " . $row['c'] . " WHERE candidateID=" . $row['candidateID']);
             }
             $db->query("UPDATE " . TABLE_MODERATOR_VOTES . " SET voteStatus=1 WHERE voterID=" . $userID);
             //Unblock Replies
             $query = $db->prepare("SELECT count(r.replyID), r.topicID, t.categoryID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.status='suspended' AND r.creatorID=%d GROUP BY r.topicID", $userID);
             $rRows = $db->getResultsArray($query);
             $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `status`='publish' WHERE creatorID=" . $userID . " AND `status`='suspended'");
             foreach ($rRows as $row) {
                 $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `replies` = `replies` + " . $row['c'] . " WHERE topicID=" . $row['topicID']);
                 $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` + " . $row['c'] . " WHERE categoryID=" . $row['categoryID']);
                 BuckysForumTopic::updateTopicLastReplyID($row['topicID']);
                 BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']);
             }
             //unblock Topics
             $query = $db->prepare("SELECT count(topicID) AS tc, SUM(replies) AS rc, categoryID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND `status`='suspended' GROUP BY categoryID", $userID);
             $tRows = $db->getResultsArray($query);
             $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `status`='publish' WHERE creatorID=" . $userID . " AND `status`='suspended'");
             foreach ($tRows as $row) {
                 $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` + " . $row['rc'] . ", `topics` = `topics` + " . $row['tc'] . " WHERE categoryID=" . $row['categoryID']);
                 BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']);
             }
             //Unblock Reply Votes
             $query = $db->prepare("SELECT count(voteID) AS c, objectID FROM " . TABLE_FORUM_VOTES . " WHERE voterID=%d AND voteStatus=0 GROUP BY objectID", $userID);
             $vRows = $db->getResultsArray($query);
             foreach ($vRows as $row) {
                 $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `votes` = `votes` + " . $row['c'] . " WHERE replyID=" . $row['objectID']);
             }
             $db->query("UPDATE " . TABLE_FORUM_VOTES . " SET voteStatus=1 WHERE voterID=" . $userID);
             //Unblock page section & Trade section
             $tradeItemIns = new BuckysTradeItem();
             $tradeOfferIns = new BuckysTradeOffer();
             $pageIns = new BuckysPage();
             $tradeItemIns->massStatusChange($userID, BuckysTradeItem::STATUS_ITEM_ACTIVE);
             $tradeOfferIns->massStatusChange($userID, BuckysTradeOffer::STATUS_OFFER_ACTIVE);
             $pageIns->massStatusChange($userID, BuckysPage::STATUS_ACTIVE);
             //enable Shop Products
             $shopProdIns = new BuckysShopProduct();
             $shopProdIns->massStatusChange($userID, BuckysShopProduct::STATUS_ACTIVE);
             //Remove From banned users table
             $db->query("DELETE FROM " . TABLE_BANNED_USERS . "  WHERE bannedID=" . $brow['bannedID']);
         }
     }
 }
Exemplo n.º 6
0
<?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']);
<?php

require dirname(dirname(dirname(__FILE__))) . '/includes/bootstrap.php';
/**
 * Remove expired products
 * Items will be expired in 7 days, and the 7 will be existed in config file
 * TODO: You should call this file once every 30 min or one hour.
 */
$shopProdIns = new BuckysShopProduct();
$shopProdIns->removeExpiredProducts();
exit;
Exemplo n.º 8
0
    $bitcoinInfo = BuckysBitcoin::createWallet($TNB_GLOBALS['user']['userID'], $TNB_GLOBALS['user']['email']);
}
buckys_enqueue_stylesheet('uploadify.css');
buckys_enqueue_stylesheet('jquery.Jcrop.css');
buckys_enqueue_stylesheet('shop.css');
buckys_enqueue_javascript('uploadify/jquery.uploadify.js');
buckys_enqueue_javascript('jquery.Jcrop.js');
buckys_enqueue_javascript('jquery.color.js');
buckys_enqueue_javascript('shop.js');
buckys_enqueue_javascript('shop-edit.js');
buckys_enqueue_javascript('uploadify/flash_install.js');
$TNB_GLOBALS['content'] = 'shop/additem';
$TNB_GLOBALS['headerType'] = 'shop';
$view = [];
$countryIns = new BuckysCountry();
$shopProductIns = new BuckysShopProduct();
$view['category_list'] = BuckysShopCategory::getCategoryList(0);
$view['country_list'] = $countryIns->getCountryList();
$view['action_name'] = 'editProduct';
$paramProdID = get_secure_integer($_REQUEST['id']);
$paramType = get_secure_string($_REQUEST['type']);
$view['product'] = null;
switch ($paramType) {
    case 'relist':
        $userInfo = BuckysUser::getUserBasicInfo($userID);
        $view['my_bitcoin_balance'] = BuckysBitcoin::getUserWalletBalance($userID);
        $view['my_credit_balance'] = $userInfo['credits'];
        $view['product'] = $shopProductIns->getProductById($paramProdID, true);
        $view['type'] = 'relist';
        $view['page_title'] = 'Relist an Item';
        break;
/**
 * @param $buyerID
 * @param $productID
 * @return null
 */
function fn_buckys_get_available_shipping_price($buyerID, $productID)
{
    $shopProductIns = new BuckysShopProduct();
    $shippingInfoIns = new BuckysTradeUser();
    $myShippingData = $shippingInfoIns->getUserByID($buyerID);
    $productShippingInfo = $shopProductIns->getShippingPrice($productID);
    $availableShippingPrice = null;
    if ($myShippingData) {
        if (is_numeric($myShippingData['shippingCountryID']) && $myShippingData['shippingCountryID'] > 0) {
            if (is_array($productShippingInfo) && count($productShippingInfo) > 0) {
                foreach ($productShippingInfo as $shippingData) {
                    if ($shippingData['locationID'] == $myShippingData['shippingCountryID']) {
                        $availableShippingPrice = $shippingData['price'];
                    } else {
                        if ($shippingData['locationID'] == BuckysShopProduct::SHIPPING_LOCATION_WORLDWIDE && $availableShippingPrice == null) {
                            $availableShippingPrice = $shippingData['price'];
                        }
                    }
                }
            }
        }
    }
    return $availableShippingPrice;
}
 /**
  * Remove Account
  */
 public static function deleteUserAccount($userID)
 {
     global $db;
     $userID = intval($userID);
     //Fix Comments Count
     $query = $db->prepare("SELECT count(commentID) AS c, postID FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=%d AND commentStatus=1 GROUP BY postID", $userID);
     $pcRows = $db->getResultsArray($query);
     foreach ($pcRows as $row) {
         $db->query("UPDATE " . TABLE_POSTS . " SET `comments` = `comments` - " . $row['c'] . " WHERE postID=" . $row['postID']);
     }
     //Fix Likes Count
     $query = $db->prepare("SELECT count(likeID) AS c, postID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%d AND likeStatus=1 GROUP BY postID", $userID);
     $plRows = $db->getResultsArray($query);
     foreach ($plRows as $row) {
         $db->query("UPDATE " . TABLE_POSTS . " SET `likes` = `likes` - " . $row['c'] . " WHERE postID=" . $row['postID']);
     }
     //Block Votes for Moderator
     $query = $db->prepare("SELECT count(voteID) AS c, candidateID FROM " . TABLE_MODERATOR_VOTES . " WHERE voterID=%d AND voteStatus=1 GROUP BY candidateID", $userID);
     $vRows = $db->getResultsArray($query);
     foreach ($vRows as $row) {
         $db->query("UPDATE " . TABLE_MODERATOR_CANDIDATES . " SET `votes` = `votes` - " . $row['c'] . " WHERE candidateID=" . $row['candidateID']);
     }
     //Block Replies
     $query = $db->prepare("SELECT count(r.replyID), r.topicID, t.categoryID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.status='publish' AND r.creatorID=%d GROUP BY r.topicID", $userID);
     $rRows = $db->getResultsArray($query);
     $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `status`='suspended' WHERE creatorID=" . $userID . " AND `status`='publish'");
     foreach ($rRows as $row) {
         $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `replies` = `replies` - " . $row['c'] . " WHERE topicID=" . $row['topicID']);
         $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` - " . $row['c'] . " WHERE categoryID=" . $row['categoryID']);
         BuckysForumTopic::updateTopicLastReplyID($row['topicID']);
     }
     //Block Topics
     $query = $db->prepare("SELECT count(topicID) AS tc, SUM(replies) AS rc, categoryID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND `status`='publish' GROUP BY categoryID", $userID);
     $tRows = $db->getResultsArray($query);
     $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `status`='suspended' WHERE creatorID=" . $userID . " AND `status`='publish'");
     foreach ($tRows as $row) {
         $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` - " . $row['rc'] . ", `topics` = `topics` - " . $row['tc'] . " WHERE categoryID=" . $row['categoryID']);
         BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']);
     }
     //Block Reply Votes
     $query = $db->prepare("SELECT count(voteID) AS c, objectID FROM " . TABLE_FORUM_VOTES . " WHERE voterID=%d AND voteStatus=1 GROUP BY objectID", $userID);
     $vRows = $db->getResultsArray($query);
     foreach ($vRows as $row) {
         $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `votes` = `votes` - " . $row['c'] . " WHERE replyID=" . $row['objectID']);
     }
     //Delete Reported Objects
     $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT postID FROM " . TABLE_POSTS . " WHERE poster=" . $userID . ")");
     $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID . ")");
     $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . ")");
     //Delete From banned Users
     $db->query("DELETE FROM " . TABLE_BANNED_USERS . "  WHERE bannedUserID=" . $userID);
     //Delete Activities
     $db->query("DELETE FROM " . TABLE_MAIN_ACTIVITIES . " WHERE userID=" . $userID);
     //Delete Album Photos
     $db->query("DELETE FROM " . TABLE_ALBUMS_PHOTOS . " WHERE album_id IN (SELECT albumID FROM " . TABLE_ALBUMS . " WHERE OWNER=" . $userID . ")");
     //Delete ALbums
     $db->query("DELETE FROM " . TABLE_ALBUMS . " WHERE OWNER=" . $userID);
     //Delete Friends
     $db->query("DELETE FROM " . TABLE_FRIENDS . " WHERE userID=" . $userID . " OR userFriendID=" . $userID);
     //Delete Messages
     $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE userID=" . $userID . " OR sender=" . $userID);
     //Delete Private Messengers
     $db->query("DELETE FROM " . TABLE_MESSENGER_BLOCKLIST . " WHERE userID=" . $userID . " OR blockedID=" . $userID);
     $db->query("DELETE FROM " . TABLE_MESSENGER_BUDDYLIST . " WHERE userID=" . $userID . " OR buddyID=" . $userID);
     $db->query("DELETE FROM " . TABLE_MESSENGER_MESSAGES . " WHERE userID=" . $userID . " OR buddyID=" . $userID);
     //Delete Posts
     $posts = $db->getResultsArray("SELECT * FROM " . TABLE_POSTS . " WHERE poster=" . $userID);
     foreach ($posts as $post) {
         //Delete Comments
         $db->query("DELETE FROM " . TABLE_POSTS_COMMENTS . " WHERE postID=" . $post['postID']);
         //Delete Likes
         $db->query("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE postID=" . $post['postID']);
         //Delete hits
         $db->query("DELETE FROM " . TABLE_POSTS_HITS . " WHERE postID=" . $post['postID']);
     }
     $db->query("DELETE FROM " . TABLE_POSTS . " WHERE poster=" . $userID);
     //Delete Pages
     $pageIns = new BuckysPage();
     $pageIns->deletePageByUserID($userID);
     //Delete Trade Section which are related to this user.
     $tradeIns = new BuckysTradeItem();
     $tradeIns->deleteItemsByUserID($userID);
     //Delete Shop Section which are related to this user
     $shopIns = new BuckysShopProduct();
     $shopIns->deleteProductsByUserID($userID);
     //Delete Comments
     $db->query("DELETE FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=" . $userID);
     //Delete Likes
     $db->query("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE userID=" . $userID);
     //Delete Page Followers
     $db->query("DELETE FROM " . TABLE_PAGE_FOLLOWERS . " WHERE userID=" . $userID);
     //Getting Removed Topics
     $topicIDs = $db->getResultsArray("SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID);
     if (!$topicIDs) {
         $topicIDs = [0];
     }
     //Delete Reply Votes
     $db->query("DELETE FROM " . TABLE_FORUM_VOTES . " WHERE voterID=" . $userID);
     $db->query("DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID IN ( SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . " OR topicID IN (" . implode(", ", $topicIDs) . ") )");
     //Delete Replies
     $db->query("DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . " OR topicID IN (" . implode(", ", $topicIDs) . ")");
     //Delete Topics
     $db->query("DELETE FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID);
     //Delete Users
     /*$db->query("DELETE FROM " . TABLE_USERS . " WHERE userID=" . $userID);
     		$db->query("DELETE FROM " . TABLE_USERS_CONTACT . " WHERE userID=" . $userID);
     		$db->query("DELETE FROM " . TABLE_USERS_EDUCATIONS . " WHERE userID=" . $userID);
     		$db->query("DELETE FROM " . TABLE_USERS_EMPLOYMENTS . " WHERE userID=" . $userID);
     		$db->query("DELETE FROM " . TABLE_USERS_LINKS . " WHERE userID=" . $userID);
     		$db->query("DELETE FROM " . TABLE_USERS_TOKEN . " WHERE userID=" . $userID);*/
     //Don't delete user from the database, just update the user's status
     $db->query("UPDATE " . TABLE_USERS . " SET `status`=" . BuckysUser::STATUS_USER_DELETED . " WHERE userID=" . $userID);
     //Send
     $bitCoinInfo = BuckysUser::getUserBitcoinInfo($userID);
     if ($bitCoinInfo) {
         $userInfo = BuckysUser::getUserBasicInfo($userID);
         $content = "Your " . TNB_SITE_NAME . " account has been deleted. However, you may still access your Bitcoin wallet at:\n" . "https://blockchain.info/wallet/login\n" . "Identifier: " . $bitCoinInfo['bitcoin_guid'] . "\n" . "Password: "******"\n";
         //Send Email to User
         buckys_sendmail($userInfo['email'], $userInfo['firstName'] . ' ' . $userInfo['lastName'], TNB_SITE_NAME . ' Account has been Deleted', $content);
     }
 }
Exemplo n.º 11
0
<?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);
}
$productID = buckys_escape_query_integer($_GET['id']);
$shopProductClass = new BuckysShopProduct();
if (!$shopProductClass->isPurchased($userID, $productID)) {
    buckys_redirect('/shop/purchase.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
$productData = $shopProductClass->getProductById($productID);
if (!$productData || !$productData['isDownloadable']) {
    buckys_redirect('/shop/purchase.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
if (!file_exists(DIR_FS_SHOP_PRODUCTS . $productData['fileName'])) {
    buckys_redirect('/shop/purchase.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
$filename = preg_replace("/[^a-zA-Z0-9\\._-\\s]/", '', $productData['title']);
$filename = str_replace(" ", '-', $filename);
//Download Zip File
header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: Application/zip");
header("Content-disposition: attachment; filename=" . $filename . ".zip");
$fp = fopen(DIR_FS_SHOP_PRODUCTS . $productData['fileName'], "r");
while (!feof($fp)) {
    $buffer = fread($fp, 1024 * 1024 * 3);
    echo $buffer;
Exemplo n.º 12
0
<?php

require dirname(dirname(__FILE__)) . '/includes/bootstrap.php';
buckys_enqueue_stylesheet('shop.css');
buckys_enqueue_javascript('shop.js');
$TNB_GLOBALS['content'] = 'shop/search';
$TNB_GLOBALS['headerType'] = 'shop';
$paramCurrentPage = buckys_escape_query_string($_REQUEST['page']);
$paramQueryStr = buckys_escape_query_string($_REQUEST['q'], true);
$paramCategory = buckys_escape_query_string($_REQUEST['cat'], true);
$paramLocation = buckys_escape_query_string($_REQUEST['loc'], true);
$paramSort = buckys_escape_query_string($_REQUEST['sort']);
$paramUserID = buckys_escape_query_string($_REQUEST['user']);
$view = [];
//Get available products
$shopProductIns = new BuckysShopProduct();
$countryIns = new BuckysCountry();
$productResultList = $shopProductIns->search($paramQueryStr, $paramCategory, $paramLocation, $paramUserID);
$productResultList = $shopProductIns->sortProducts($productResultList, $paramSort);
$view['categoryList'] = $shopProductIns->countProductInCategory($productResultList);
//Create Base URL for pagination of search page
$paginationUrlBase = buckys_shop_search_url($paramQueryStr, $paramCategory, $paramLocation, $paramSort, $paramUserID);
//Display
$view['products'] = fn_buckys_pagination($productResultList, $paginationUrlBase, $paramCurrentPage, COMMON_ROWS_PER_PAGE);
$view['param']['q'] = $paramQueryStr;
$view['param']['cat'] = $paramCategory;
$view['param']['loc'] = $paramLocation;
$view['param']['sort'] = $paramSort;
$view['param']['user'] = $paramUserID;
$TNB_GLOBALS['shopSearchParam'] = $view['param'];
$view['countryList'] = $countryIns->getCountryList();
 /**
  * Delete Objects
  *
  * @param Array $ids
  */
 public static function deleteObjects($ids)
 {
     global $db;
     if (!is_array($ids)) {
         $ids = [$ids];
     }
     $ids = $db->escapeInput($ids);
     $query = $db->prepare("SELECT * FROM " . TABLE_REPORTS . " WHERE reportID IN (" . implode(", ", $ids) . ")");
     $rows = $db->getResultsArray($query);
     foreach ($rows as $row) {
         if ($row['objectType'] == 'post') {
             $post = $db->getRow("SELECT * FROM " . TABLE_POSTS . " WHERE postID=" . $row['objectID']);
             BuckysPost::deletePost($post['poster'], $post['postID']);
         } else {
             if ($row['objectType'] == 'comment') {
                 //Getting Data
                 $comment = $db->getRow("SELECT * FROM " . TABLE_POSTS_COMMENTS . " WHERE commentID=" . $row['objectID']);
                 BuckysComment::deleteComment($comment['commenter'], $comment['commentID']);
             } else {
                 if ($row['objectType'] == 'video_comment') {
                     //Getting Data
                     $comment = $db->getRow("SELECT * FROM " . TABLE_VIDEO_COMMENTS . " WHERE commentID=" . $row['objectID']);
                     BuckysVideo::deleteVideoComment($comment['commentID']);
                 } else {
                     if ($row['objectType'] == 'message') {
                         //Delete Message
                         $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE messageID=" . $row['objectID']);
                     } else {
                         if ($row['objectType'] == 'topic') {
                             //Delete Topic
                             BuckysForumTopic::deleteTopic($row['objectID']);
                         } else {
                             if ($row['objectType'] == 'reply') {
                                 //Delete Topic
                                 BuckysForumReply::deleteReply($row['objectID']);
                             } else {
                                 if ($row['objectType'] == 'shop_item') {
                                     //Delete Shop Product
                                     $shopProdIns = new BuckysShopProduct();
                                     $shopProdIns->removeProductByUserID($row['objectID'], $row['reportedID']);
                                 } else {
                                     if ($row['objectType'] == 'trade_item') {
                                         //Delete Trade Item
                                         $tradeItemIns = new BuckysTradeItem();
                                         $tradeItemIns->removeItemByUserID($row['objectID'], $row['reportedID']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //Delete the row on the report table
         $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE reportID=" . $row['reportID']);
     }
     return;
 }