Exemplo n.º 1
0
{
    $query = "SELECT * FROM auction WHERE\n\t  auction.auction_id IN( SELECT bid.auction_id FROM bid\n\t  WHERE bid.bidder_id IN( SELECT bid.bidder_id FROM bid\n\t  WHERE bid.bidder_id <> {$user_id} AND bid.auction_id IN(\n      SELECT bid.auction_id FROM bid WHERE bid.bidder_id = {$user_id}\n      GROUP BY bid.auction_id) GROUP BY bid.bidder_id ) GROUP BY\n\t  bid.auction_id ) AND auction.has_ended = '0' LIMIT 10;";
    $recommends = mysqli_query($dbconnection, $query);
    if ($recommends->num_rows == 0) {
        return '';
    }
    $str_recommends = "You may be interested in:<br><br>";
    while ($result = mysqli_fetch_array($recommends)) {
        $get_item_name_query = "SELECT name FROM item WHERE item_id = " . $result['item_id'];
        $get_item_name = mysqli_query($dbconnection, $get_item_name_query);
        $item_name = mysqli_fetch_array($get_item_name)['name'];
        $str_recommends .= 'Auction (<a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/auction.php?auction=' . $result['auction_id'] . '">' . $item_name . '</a>)<br>
                   End Date: ' . $result['end_date'] . '<br>
                   Current Price: ' . $result['current_price'] . '<br>
                   <br>';
    }
    return $str_recommends;
}
echo date("Y-m-d H:i:s") . " recommendation.php : \n";
$query = "SELECT user_id,email_address from user";
$users = mysqli_query($connection, $query);
$sender = new email_sender();
$counter = 0;
while ($user = mysqli_fetch_array($users)) {
    $str_recommends = recommend($connection, $user['user_id']);
    if ($str_recommends != '') {
        $counter++;
        $sender->send_with_log($user['email_address'], 'Recommended Items for You!!', $str_recommends);
    }
}
echo "{$counter} emails sent\n";
Exemplo n.º 2
0
if ($counter != 0) {
    $sender = new email_sender();
}
echo date("Y-m-d H:i:s") . " auction_handler.php : {$counter} auctions ended.\n";
while ($auction = mysqli_fetch_array($auctions)) {
    mysqli_query($connection, "update auction set has_ended='1' where auction_id=" . $auction['auction_id'] . "");
    $query = "select b.price, u.user_id, u.name, u.email_address\n                from bid as b\n                left join user as u\n                on b.bidder_id=u.user_id\n                where b.auction_id=" . $auction['auction_id'] . "\n                order by b.price desc\n                limit 1";
    $winner = mysqli_query($connection, $query);
    if ($winner = mysqli_fetch_array($winner)) {
        $winner_exists = true;
    } else {
        $winner_exists = false;
    }
    if ($winner_exists) {
        if ($winner['price'] < $auction['reserve_price']) {
            $sender->send_with_log($winner['email_address'], 'Your Bid Did Not Meet Reserve Price!!', 'Your bid was the highest in the auction for <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/auction.php?auction=' . $auction['auction_id'] . '">' . $auction['item_name'] . '</a>, but we are sorry that you could not get the item as your bid did not meet the reserve price set by the seller.');
            $sender->send_with_log($auction['seller_address'], 'Your Auction Ended But Below Reserve Price!!', 'Your auction for <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/auction.php?auction=' . $auction['auction_id'] . '">' . $auction['item_name'] . '</a> just ended, but the highest bid on the auction did not meet the reserve price you set.');
        } else {
            mysqli_query($connection, "update item set owner_id='" . $winner['user_id'] . "' where item_id='" . $auction['item_id'] . "'");
            mysqli_query($connection, "insert into rating (user_id, rated_by, auction_id, created_at) values ('" . $auction['seller_id'] . "', '" . $winner['user_id'] . "', '" . $auction['auction_id'] . "', NULL)");
            mysqli_query($connection, "insert into rating (user_id, rated_by, auction_id, created_at) values ('" . $winner['user_id'] . "', '" . $auction['seller_id'] . "', '" . $auction['auction_id'] . "', NULL)");
            $sender->send_with_log($winner['email_address'], 'You Won an Auction!!', 'Congratulations!!<br>
                 You won the auction for <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/auction.php?auction=' . $auction['auction_id'] . '">' . $auction['item_name'] . '</a>!!<br>
                 Now it is yours!!<br>
                 <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/">Go to the website</a> and rate the seller!!');
            $sender->send_with_log($auction['seller_address'], 'Your Auction Ended With a Winner!!', 'Congratulations!!<br>
                 Your auction <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/auction=' . $auction['auction_id'] . '">' . $auction['item_name'] . '</a> just ended with a winner and now your item is sold!!<br>
                 <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/user.php?user='******'user_id'] . '">' . $winner['name'] . '</a> won the auction!!<br>
                 <a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/">Go to the website</a> and rate the winner!!');
        }
    } else {
Exemplo n.º 3
0
<?php

require_once realpath(dirname(__FILE__) . "/resources/dbconnection.php");
require_once realpath(dirname(__FILE__) . "/resources/email.php");
echo date("Y-m-d H:i:s") . " sellers_report.php : \n";
$query = "select user_id,email_address from user where user_type='seller'";
$sellers = mysqli_query($connection, $query);
while ($seller = mysqli_fetch_array($sellers)) {
    $message = '';
    $query = "select a.end_date, a.current_price, a.reserve_price, a.auction_id, a.view_count, i.name\n              from auction as a\n              left join item as i\n              on a.item_id = i.item_id\n              where a.seller_id = '" . $seller['user_id'] . "' and a.end_date > now()";
    $auctions = mysqli_query($connection, $query);
    while ($auction = mysqli_fetch_array($auctions)) {
        $query = "select * from bid where auction_id='" . $auction['auction_id'] . "'";
        $bids = mysqli_query($connection, $query);
        $bid_count = mysqli_num_rows($bids);
        $message .= 'Auction (<a href="http://ec2-52-58-25-40.eu-central-1.compute.amazonaws.com/auction.php?auction=' . $auction['auction_id'] . '">' . $auction['name'] . '</a>)<br>
                   End Date: ' . $auction['end_date'] . '<br>
                   Current Price: ' . $auction['current_price'] . '<br>
                   Reserve Price: ' . $auction['reserve_price'] . '<br>
                   Bid Count: ' . $bid_count . ' bid(s)<br>
                   View Count: ' . $auction['view_count'] . ' view(s)<br>
                   <br>';
    }
    if ($message != '') {
        $sender = new email_sender();
        $sender->send_with_log($seller['email_address'], 'Your Current Auction Report!!', $message);
    }
}