示例#1
0
 /**  
  * @see generate_password_recover() generate a hask link for recover a password
  * @return boolean Always return true
  */
 public function generate_password_recover()
 {
     /**
      * @var class hash_pass Class Hash_pass
      * @var class $DBsettings D.B settings
      */
     $hash_sha512 = new hash_pass();
     $DBsettings = (include $setting);
     //something do not work with $this->database[1] so we use $DBsettings[1]
     $hashed_link = $hash_sha512->hash($this->email_address, $hash_sha512->generateSalt());
     // Update new link for reset password
     $sql = "UPDATE {$DBsettings['1']}.`user_account` SET `forget_password` = '{$hashed_link}' WHERE `user_account`.`email_address` = '{$this->email_address}'";
     $reponse = $this->bdd->prepare($sql);
     $reponse->execute();
     try {
         try {
             error_reporting(E_ALL);
             ini_set('display_errors', 1);
             require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/swiftmailer/lib/swift_required.php';
         } catch (Exception $e) {
             echo 'Exception reçue : ' . $e->getMessage() . "\n";
         }
         $this->message = 'You can reset your password by using this link :' . ' www.cloudiaproject.org/controllers/account/forget' . '_password.php?link=' . $hashed_link;
         $this->subject = "Cloudia : Reset your password";
         $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")->setUsername('*****@*****.**')->setPassword('Pampa%Burger');
         // Create the Mailer using your created Transport
         $mailer = Swift_Mailer::newInstance($transport);
         // Create a message
         $message = Swift_Message::newInstance()->setSubject($this->subject)->setFrom(array('*****@*****.**' => 'ClouDIA\'s team'))->setTo(array('*****@*****.**', '*****@*****.**' => 'A name'))->setBody($this->message)->addPart('<q>TEXT DINDICATION</q>', 'text/html');
         if ($mailer->send($message)) {
             echo "Sent\n";
         } else {
             echo "Failed\n";
         }
     } catch (Exception $e) {
         echo $e->getMessage() . '<br>';
         echo '<pre>' . $e->getTraceAsString() . '</pre>';
     }
     $email_sender = new email_sender($hashed_link, $this->email_address);
     echo "before send_password_reset()";
     $email_sender->send_password_reset();
     $reponse->closeCursor();
     // End of Query
     return true;
 }
示例#2
0
<?php

require_once realpath(dirname(__FILE__) . "/resources/dbconnection.php");
require_once realpath(dirname(__FILE__) . "/resources/email.php");
$query = "select a.auction_id, i.name as item_name, i.item_id, u.user_id as seller_id, u.name as seller_name, u.email_address as seller_address, a.reserve_price\n          from auction as a\n          left join item as i\n          on i.item_id = a.item_id\n          left join user as u\n          on u.user_id = a.seller_id\n          where end_date <= now() and has_ended='0'";
$auctions = mysqli_query($connection, $query);
$counter = $auctions->num_rows;
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>
示例#3
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";
$ownerID = findUser($mysqli, $_SESSION['email'], true);
$surveyName = $_POST['name'];
$query = 'INSERT INTO surveys (name, emails, data, start, end, owner) VALUES (?, ?, ?, ?, ?, ?)';
$stmt = $mysqli->prepare($query);
$null = NULL;
$stmt->bind_param('sbbssi', $surveyName, $null, $null, $_POST['startDate'], $_POST['endDate'], $ownerID);
$stmt->send_long_data(1, mysql_escape_string($_POST['emails']));
$stmt->send_long_data(2, mysql_escape_string($_POST['data']));
if ($stmt->execute()) {
    echo 'true';
} else {
    die('Error : (' . $mysqli->errno . ') ' . $mysqli->error);
}
$survey_id = $mysqli->insert_id;
$stmt->close();
$es = new email_sender();
$send_data = [];
$emailList = str_replace('%2B', '+', htmlspecialchars($_POST['emails']));
$emails = explode(" ", $emailList);
$query = "SELECT username, email FROM users WHERE id = ? LIMIT 1";
$statement = $mysqli->prepare($query);
$statement->bind_param('s', $ownerID);
$statement->execute();
$statement->bind_result($username, $email);
$sender = $statement->fetch();
$statement->close();
$query = 'INSERT INTO links (survey_id, email, hash) VALUES (?, ?, ?)';
$stmt = $mysqli->prepare($query);
for ($i = count($emails) - 1; $i >= 0; $i--) {
    $hash = hash('sha256', $emails[$i] . " " . $survey_id);
    $send_data[$i] = ['email_sender' => $sender[0] . $email, 'name_sender' => $sender[0] . $username, 'name_survey' => $surveyName, 'email_addressee' => $emails[$i], 'link_survey' => $hash];
示例#5
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);
    }
}