/** * @param $userID * @param $toAddress * @param $amount * @return bool */ public static function sendBitcoin($userID, $toAddress, $amount) { global $db; $bitcoinInfo = BuckysUser::getUserBitcoinInfo($userID); $amount = $amount * 100000000; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://blockchain.info/merchant/' . $bitcoinInfo['bitcoin_guid'] . '/payment?password='******'bitcoin_password']) . '&to=' . $toAddress . '&amount=' . $amount . '&from=' . $bitcoinInfo['bitcoin_address']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $return = curl_exec($ch); curl_close($ch); $returnData = json_decode($return); if (!$returnData) { buckys_add_message("There was an error to send the bitcoin: " . $return, MSG_TYPE_ERROR); return false; } if (isset($returnData->error)) { buckys_add_message('Sending Bitcoin Error: ' . $returnData->error, MSG_TYPE_ERROR); return false; } else { buckys_add_message($returnData->message); if (isset($returnData->notice) && $returnData->notice) { buckys_add_message($returnData->notice, MSG_TYPE_NOTICE); } } return true; }
/** * 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); } }