function sendMail($username)
{
    $db = new DbObject();
    //  <a href='doReset.php?resetid= . $randString' >Click Here to Reset Password</a>
    //generates random string and stores it in a variable
    $randString = getToken();
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: Classified Staff <*****@*****.**>' . "\r\n";
    // get the folder name where the reset file is contained
    $folder = dirname($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    $message = "\r\n    <html>\r\n    <head>\r\n      <title>Reset Password</title>\r\n    </head>\r\n    <body>\r\n    <div>  \r\n    <p>Hello {$username}</p>\r\n       <p>Please click the link below to reset your password\r</p>\r\n       <a href='https://" . $folder . "/doReset.php?resetid={$randString}' >Click Here to Reset Password</a>\r\n           \r\n           <br />\r\n\r\n    <p>Replies to this email will not be delivered.</p>\r\n       </div>\r\n    </body>\r\n    </html>\r\n    ";
    //manage the email's length
    $message = wordwrap($message, 140, "\r\n");
    // Add the reset id to the member's
    $rIdArray = array("resetID" => $randString, "username" => $username);
    $db->update($rIdArray, "Member", "username");
    // mail returns a boolean  indicating the success or delivery of mail
    return mail('cst211@cst.siast.sk.ca ', 'Classified: Password Reset', $message, $headers);
}
Example #2
0
 public function update($force_nullvalues = false, $force_validation = false)
 {
     parent::update($force_nullvalues, $force_validation);
 }
 function saveToDb($report, $table, $days)
 {
     try {
         $dbObject = new DbObject();
         $dataArray = $report->data;
         foreach ($report->metrics as $key => $value) {
             if ($value->id == "orders") {
                 $orderIndex = $key;
             }
             if ($value->id == "visits") {
                 $visitIndex = $key;
             }
             if ($value->id == "event3") {
                 $productViewIndex = $key;
             }
             if ($value->id == "carts") {
                 $cartIndex = $key;
             }
         }
         foreach ($dataArray as $data) {
             if (strpos($data->name, "unspecified") == false) {
                 $id_keyword = $data->name;
                 //md5()
                 $metricesKeyword = $data->counts;
                 $keyword = array("id" => $id_keyword, "value" => $data->name, "orders" => $metricesKeyword[$orderIndex], "visits" => $metricesKeyword[$visitIndex], "product_views" => $metricesKeyword[$productViewIndex], "carts" => $metricesKeyword[$cartIndex]);
                 if (count($dbObject->select('keyword', array('*'), 'id="' . $id_keyword . '"')) == 0) {
                     $dbObject->insert("keyword", $keyword);
                 } else {
                     $dbObject->update("keyword", $keyword, "id='" . $id_keyword . "'");
                 }
                 if ($table == "sub_category") {
                     $this->saveToSubCategory($data, $id_keyword, $orderIndex, $visitIndex, $productViewIndex, $cartIndex);
                 } elseif ($table == "brand") {
                     $this->saveToBrand($data, $id_keyword, $orderIndex, $visitIndex, $productViewIndex, $cartIndex, $this->availableDays[$days]);
                 } elseif ($table == "item_id") {
                     $this->saveToItemId($data, $orderIndex, $visitIndex, $productViewIndex, $cartIndex, $this->availableDays[$days], $keyword);
                 }
                 /*foreach ($data->breakdown as $subcategory) {
                       if (strpos($subcategory->name, "other") === false && strpos($subcategory->name, "Unspecified") === false) {
                           $id_subcategory = md5($subcategory->name);
                           $dbObject->insert("sub_category", array("id" => $id_subcategory, "value" => $subcategory->name));
                           //foreach($subcategory->counts as $metric){
                           $metrices = $subcategory->counts;
                           $dbObject->insert(
                               "three_days_sub_category_ae",
                               array("id" => md5($id_keyword . $id_subcategory),
                                   "id_sub_category" => $id_subcategory,
                                   "id_keyword" => $id_keyword,
                                   "orders" => $metrices[$orderIndex],
                                   "visits" => $metrices[$visitIndex],
                                   "product_views" => $metrices[$productViewIndex],
                                   "carts" => $metrices[$cartIndex]
                               )
                           );
                       }
                   }*/
             }
         }
         return true;
     } catch (Exception $e) {
         var_dump($e);
         return false;
     }
 }
        <?php 
if (!isset($_POST["submitPasswordChange"])) {
    loadForm(true);
} else {
    //if the passwords do not match - or password is left blank - load the form again
    //with an error message. Send false indicating that the password check failed.
    if (!checkPasswordMatch()) {
        loadForm(false);
    } else {
        $db = new DbObject();
        $passwordCheck = new PasswordChecker();
        $passwordUsernamePass = $passwordCheck->isValid($_SESSION["username"], $_POST["currentPassword"]);
        if ($passwordUsernamePass) {
            $newPassword = password_hash($_POST["newPassword1"], PASSWORD_DEFAULT);
            $passwordArray = array("password" => $newPassword, "username" => $_SESSION["username"]);
            $usernamePasswordChangeSuccess = $db->update($passwordArray, "Member", "username");
            if ($usernamePasswordChangeSuccess == 1) {
                $_SESSION["loggedIn"] = false;
                echo "<h2>Password succesfully changed! Please log in with your new credentials</h2>\n                            <h2><a href='login.php'>Log in</a> to log in</h2>";
            }
        } else {
            loadForm(false);
        }
    }
}
?>
        </div>
          <div id="toHome">
            <a href="index.php" >    <img id="logo1" alt ="classified logo" src="style\class.png"style="width:100px;height:80px"/></a>
        </div>
    </body>
Example #5
0
 /**
  * (non-PHPdoc)
  * @see DbObject::update()
  */
 function update($force = false, $force_validation = false)
 {
     try {
         $this->startTransaction();
         // 1. Call on_before_update of the TaskGroupType
         $tg = $this->getTaskGroup();
         if (!empty($tg)) {
             $tg_type = $tg->getTaskGroupTypeObject();
             $tg_type->on_before_update($this);
         }
         // 2. Call on_before_update of the Tasktype
         if ($this->task_type) {
             $this->getTaskTypeObject()->on_before_update($this);
         }
         // 3. update the task
         $validation_response = parent::update($force, $force_validation);
         if ($validation_response !== true) {
             $this->rollbackTransaction();
             $this->Log->error("Task update failed validation, rolling back transaction");
             $this->w->errorMessage($this, "Task", $validation_response, false, "/tasks/edit/" . $this->id);
         }
         // 4. Call on_after_update of the TaskType
         if ($this->task_type) {
             $this->getTaskTypeObject()->on_after_update($this);
         }
         // 5. Call on_after_update of the TaskGroupType
         if (!empty($tg_type)) {
             $tg_type->on_after_update($this);
         }
         $this->commitTransaction();
     } catch (Exception $ex) {
         $this->Log->error("Updating Task(" . $this->id . "): " . $ex->getMessage());
         $this->rollbackTransaction();
     }
 }