Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function checkDonations(){
- if($this->AuthFunction() == true){
- $full_insert_data = array();
- $data = $this->getSoldDonations();
- $this->donationmessages[] = "Found ".count($data)." finished auctions";
- foreach($data as $auction){
- $check_donation_list = $this->db_connection->prepare("SELECT *
- FROM auction WHERE auctionid = :id");
- $check_donation_list->bindValue(':id', $auction, PDO::PARAM_INT);
- $check_donation_list->execute();
- if($check_donation_list->rowcount() == 0){
- $get_postMeta = $this->db_connection->prepare("SELECT post_id, meta_key, meta_value FROM wp_postmeta
- WHERE post_id = :id AND meta_value = 'added' AND meta_key = 'auction_added_status'");
- $get_postMeta->bindValue(':id', $auction, PDO::PARAM_INT);
- $get_postMeta->execute();
- if($get_postMeta->rowcount() == 0){
- $this->donationmessages[] = "Found a new auction with auction id: ".$auction;
- $get_bid = $this->db_connection->prepare("SELECT bid, name, email, auction_id FROM wp_wdm_bidders
- WHERE auction_id = :id ORDER BY bid DESC");
- $get_bid->bindValue(':id', $auction, PDO::PARAM_INT);
- $get_bid->execute();
- if($get_bid->rowcount() > 0){
- $biddata = $get_bid->fetch(PDO::FETCH_ASSOC);
- $auctionpost = $this->getSettings($auction, "gettitle");
- $get_userip = $this->db_connection->prepare("SELECT ip FROM wp_user_login_log WHERE user_login = :id");
- $get_userip->bindValue(':id', $biddata['name'], PDO::PARAM_STR);
- $get_userip->execute();
- if($get_userip->rowcount() > 0){
- $userip = $get_userip->fetchAll(PDO::FETCH_ASSOC);
- $userip = $userip[0]["ip"];
- }else{
- $userip = "NOIP";
- }
- $full_insert_data[$auction]['bid'] = $biddata['bid'];
- $full_insert_data[$auction]['itemname'] = $auctionpost;
- $full_insert_data[$auction]['username'] = $biddata['name'];
- $full_insert_data[$auction]['email'] = $biddata['email'];
- $full_insert_data[$auction]['ip'] = $userip;
- $this->donationmessages[] = "The highest bid for this auction was: ".$full_insert_data[$auction]['bid'];
- try{
- $set_new_donation = $this->db_connectionSecond->prepare("INSERT INTO
- auction (itemname, price, username, email, ip)
- VALUES (:itemname, :price, :username, :email, :ip)");
- $set_new_donation->bindValue(':itemname', $full_insert_data[$auction]['itemname'], PDO::PARAM_STR);
- $set_new_donation->bindValue(':price', $full_insert_data[$auction]['bid'], PDO::PARAM_INT);
- $set_new_donation->bindValue(':username', $full_insert_data[$auction]['username'], PDO::PARAM_STR);
- $set_new_donation->bindValue(':email', $full_insert_data[$auction]['email'], PDO::PARAM_STR);
- $set_new_donation->bindValue(':ip', $full_insert_data[$auction]['ip'], PDO::PARAM_STR);
- $set_new_donation->execute();
- catch(PDOException $e) {
- echo "Something went wrong. Please report this error.";
- file_put_contents('/PDOErrors.txt', $e->getMessage(), FILE_APPEND);
- }
- if($set_new_donation->rowcount() > 0){
- $this->donationmessages[] = "A new donation has been added. Auction number: ".$auction;
- $this->create_post_meta($auction, "auction_added_status", "added", true);
- }else{
- $this->donationmessages[] = "A new donation has NOT been added. Auction number: ".$auction;
- }
- }else{
- $payamount = 0;
- $this->donationmessages[] = "There were no bids for this auction.";
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement