public function forgotpassword()
 {
     $data = '';
     $post = $this->input->post();
     if ($post) {
         $error = array();
         $e_flag = 0;
         if (!valid_email(trim($post['email'])) && trim($post['email']) == '') {
             $error['email'] = 'Please enter email.';
             $e_flag = 1;
         }
         if ($e_flag == 0) {
             $where = array('email' => trim($post['email']), 'role' => 'admin');
             $user = $this->common_model->selectData(ADMIN, '*', $where);
             if (count($user) > 0) {
                 $newpassword = random_string('alnum', 8);
                 $data = array('password' => md5($newpassword));
                 $upid = $this->common_model->updateData(ADMIN, $data, $where);
                 $emailTpl = $this->load->view('email_templates/admin_forgot_password', array('username' => $user[0]->name, 'password' => $newpassword), true);
                 $ret = sendEmail($user[0]->email, SUBJECT_LOGIN_INFO, $emailTpl, FROM_EMAIL, FROM_NAME);
                 if ($ret) {
                     $flash_arr = array('flash_type' => 'success', 'flash_msg' => 'Login details sent successfully.');
                 } else {
                     $flash_arr = array('flash_type' => 'error', 'flash_msg' => 'An error occurred while processing.');
                 }
                 $data['flash_msg'] = $flash_arr;
             } else {
                 $error['email'] = "Invalid email address.";
             }
         }
         $data['error_msg'] = $error;
     }
     $this->load->view('index/forgotpassword', $data);
 }
Example #2
0
function add_comment($moderator_email)
{
    $caller = strtolower($_POST["url"]);
    //$_SERVER['HTTP_REFERER'];
    $filename = md5($caller);
    $abs_comment_file = realpath('.') . '/' . $filename . '.xml';
    $date_value = time();
    $comment_id = $date_value . '-' . rand(1, 100000000);
    $author_value = processText($_POST["name"]);
    $subject_value = trim(processText($_POST["subject"]));
    $msg_value = processText($_POST["message"]);
    $email = processText($_POST["email"]);
    $site = processText($_POST["site"]);
    $title = processText($_POST["title"]);
    $parent_id = processText($_POST["id"]);
    $dom_id = processText($_POST["domid"]);
    $moderate = processText($_POST["moderate"]);
    // 0 No moderate, 1: waiting for moderate 2: trash 3: spamn 4: approved
    $max_reply = intval(processText($_POST["max"]));
    $secured = empty($_SERVER["HTTPS"]) ? '' : $_SERVER["HTTPS"] == "on" ? "s" : "";
    $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $secured;
    $ec_path = $protocol . '://' . $_SERVER['HTTP_HOST'] . processText($_POST["path"]);
    if (empty($parent_id)) {
        $parent_id = null;
    }
    $ip = $_SERVER["REMOTE_ADDR"];
    $ret = addComment($abs_comment_file, $caller, $title, $dom_id, $comment_id, $date_value, $author_value, $subject_value, $email, $site, $msg_value, $ip, $moderate, $parent_id, $max_reply);
    $msg_value = str_replace(array("\r", "\n"), "<br />", $msg_value);
    echo json_encode(array("id" => $comment_id, "comment" => '<li class="ec-comment" id="' . $comment_id . '">' . '   <div class="avatar"></div>' . '   <span class="user-name author">' . $author_value . '</span> <br/>' . '   <span class="comment-html">' . (empty($subject_value) ? '' : '      <strong>' . $subject_value . '</strong><br /><br />') . $msg_value . '   </span><br/>' . '   <span class="comment-time">' . ago(time() - $date_value * 1) . '</span><br/>' . ($ret ? '   <button name="reply" id="reply_' . $comment_id . '">Reply</button>' : "") . '</li>'));
    // send email to moderator
    if ($moderate == "1") {
        $body = 'A new comment is waiting for your approval:<br /><br />' . 'Author:' . $author_value . '(IP: ' . $ip . ')<br/>' . 'Email:' . $email . '<br/>' . 'URL:' . $site . '<br/>' . 'Subject:' . $subject_value . '<br/>' . 'Whois:<a href="http://whois.arin.net/rest/ip/' . $ip . '" target="_blank">http://whois.arin.net/rest/ip/' . $ip . '</a><br/>' . 'Comment:<br/>' . '<blockquote>' . $msg_value . '</blockquote><br/>' . 'To moderate this message, click <a href="' . $ec_path . 'ec-dashboard.html">' . $ec_path . 'ec-dashboard.html</a><br/>' . '<br/>' . 'Thanks for choosing EastComment<br/><br/>' . '<a href="http://www.jswidget.com/lab/easy-comment.html" target="_blank">http://www.jswidget.com/lab/easy-comment.html</a>';
        sendEmail($moderator_email, $body);
    }
}
 public function register()
 {
     //完成注册,注册完成发送一封激活邮件
     if (IS_POST) {
         $model = new \Model\UserModel();
         if ($data = $model->create()) {
             $validate = uniqid();
             $data['validate'] = $validate;
             if ($model->add($data)) {
                 //注册成功,发送邮件激活
                 $email = I('post.email');
                 $title = '注册用户,完成激活';
                 $url = "http://web.com/index.php/Home/User/active/key/" . $validate . "/email/" . $email;
                 $content = "亲,您已注册成功,赶紧激活使用吧!请<a href='{$url}'>单击激活</a>";
                 if (sendEmail($email, $content, $title)) {
                     $this->success('邮件发送成功,请尽快激活', U('login'), 1);
                     exit;
                 }
                 $this->error('发送邮件失败,请重新注册');
             }
             $this->error('注册失败');
         }
         $this->error($model->getError());
     }
     $this->display();
 }
Example #4
0
function sendUserLogsViaMail($classID)
{
    $conn = getMainConnection();
    $query = "SELECT * FROM info WHERE ID = '" . $classID . "'";
    $result = mysql_query($query);
    $numrows = mysql_affected_rows();
    if ($numrows == 1) {
        $member = mysql_fetch_array($result);
        if ($member['activeflag'] != 0) {
            getTemporaryConnection($member['databasename']);
        }
    }
    $query = "SELECT * FROM login_logs WHERE lastlogin <= '" . time() . "' AND lastlogin >= '" . (time() - 86400) . "'";
    $result = mysql_query($query);
    $mail_string = '';
    while ($member = mysql_fetch_array($result)) {
        $time = date("F j, Y, g:i a", $member['lastlogin']);
        $user = getUser($member['userID'])->getName();
        $mail_string .= $user . ' logged in at ' . $time . ' from the ip ' . $member['ip'] . '<br />';
    }
    //echo $mail_string;
    $toEmail = '*****@*****.**';
    $toName = 'Ace Chemistry';
    $fromEmail = '*****@*****.**';
    $fromName = 'My Class - Knowledge Portal';
    $subject = 'Staff Login Logs : ' . date("d-m-Y");
    $body = 'Staff Login Logs <hr /><br />' . $mail_string;
    $flag = sendEmail($toEmail, $toName, $fromEmail, $fromName, $subject, $body, '');
    return $flag;
}
function addUser($email, $first_name, $last_name, $phone, $address, $town, $organization, $country, $zip, $october6, $october7, $october8, $october9, $october10, $msg_email, $msg_phone)
{
    $db = getDb();
    //$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
    try {
        $stmt = $db->prepare('INSERT INTO users (email, first_name, last_name, phone, address, town, organization, country, zip, october6, october7, october8, october9, october10, msg_email, msg_phone)
							VALUES ("' . $email . '", "' . $first_name . '", "' . $last_name . '", "' . $phone . '", "' . $address . '", "' . $town . '", "' . $organization . '", "' . $country . '", "' . $zip . '", ' . $october6 . ', ' . $october7 . ', ' . $october8 . ', ' . $october9 . ', ' . $october10 . ', ' . $msg_email . ', ' . $msg_phone . ')');
        //	$stmt = $db->prepare('INSERT INTO users (email, first_name, last_name, phone, address, town, organization, country, zip, october6, october7, october8, october9, october10, msg_email, msg_phone)
        //							VALUES ("' . $email .'", "' . $first_name .'", "' . $last_name .'", "' . $phone .'", "' . $address .'", "' . $town .'", "' . $organization .'", "' . $country .'", "' . $zip .'", true, false, true, true, false, true, true)');
        /*$stmt->bindValue(':email', $email, PDO::PARAM_STR);
        	$stmt->bindValue(':first_name', $first_name, PDO::PARAM_STR);
        	$stmt->bindValue(':last_name', $last_name, PDO::PARAM_STR);
        	$stmt->bindValue(':phone', $phone, PDO::PARAM_STR);
        	$stmt->bindValue(':address', $address, PDO::PARAM_STR);
        	$stmt->bindValue(':town', $town, PDO::PARAM_STR);
        	$stmt->bindValue(':organization', $organization, PDO::PARAM_STR);
        	$stmt->bindValue(':country', $country, PDO::PARAM_STR);
        	$stmt->bindValue(':zip', $zip, PDO::PARAM_STR);
        	$stmt->bindValue(':october6', $october6, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october7', $october7, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october8', $october8, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october9', $october9, PDO::PARAM_BOOL);
        	$stmt->bindValue(':october10', $october10, PDO::PARAM_STR);
        	$stmt->bindValue(':msg_email', $msg_email, PDO::PARAM_BOOL);
        	$stmt->bindValue(':msg_phone', $msg_phone, PDO::PARAM_BOOL); */
        $stmt->execute();
        // TODO: This does not work, please fix
    } catch (PDOException $e) {
        //		echo $e->getMessage();
    }
    sendEmail($first_name, $last_name, $october6, $october7, $october8, $october9, $october10, $email);
    //	print_r($db->errorInfo());
}
  function registration()
  {
      $this->loadModel('User');
      $this->loadModel('Role');
      if ($this->request->is('post')) {
          $this->User->set($this->request->data);
          if ($this->User->validates()) {
              //$this->request->data['User']['password'] = md5($this->request->data['User']['password']);
              $mail_data = $this->User->save($this->request->data);
              // send mail :
              $from = $mail_data['User']['email'];
              $subject = "New technician registration";
              $user_name = $mail_data['User']['name'];
              $email_user = $mail_data['User']['email'];
              $password = $this->request->data['User']['password'];
              $role_id = $mail_data['User']['role_id'];
              $to = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
              $mail_content = __('Name:', 'beopen') . $user_name . PHP_EOL . __('Email:', 'beopen') . $email_user . PHP_EOL . __('Password:'******'beopen') . $password . PHP_EOL . __('Role Id:', 'beopen') . $role_id . PHP_EOL . __($url = Router::url(array("controller" => "users", "action" => "login"), true));
              sendEmail($from, $user_name, $to, $subject, $mail_content);
              // End send mail
              $msg = '<div class="alert alert-success">
 <button type="button" class="close" data-dismiss="alert">&times;</button>
 <strong> User Created succeesfully </strong>
 </div>';
          } else {
              $msg = $this->generateError($this->User->validationErrors);
          }
          $this->Session->setFlash($msg);
          // return $this->redirect('create');
      }
      $this->set('roles', $this->Role->find("list"));
  }
function _request_new_password()
{
    if (isset($_POST['email'])) {
        $user = new User(getdbh());
        $ID = $user->checkEmail($_POST['email']);
        if (isset($ID['ID'])) {
            $setToken = $user->setRecover($ID['ID'], $_POST['email']);
            if ($setToken != false) {
                $body = 'Pentru a schimba parola apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/recover_password/' . $setToken . '"> AICI </a>';
                if (sendEmail('Schimbare parola', $body, '*****@*****.**', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de resetare a parolei a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul nu a fost trimis";
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Tokenul este gresit sau au trecut mai mult de 2 zile de la cererea de recuperare parola";
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Acest user nu exista";
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    } else {
        redirect('main/index');
    }
}
Example #8
0
function main($contactForm)
{
    // Checks if something was sent to the contact form, if not, do nothing
    if (!$contactForm->isDataSent()) {
        return;
    }
    // validates the contact form and initialize the errors
    $contactForm->validate();
    $errors = array();
    // if the contact form is not valid...
    if (!$contactForm->isValid()) {
        // gets the error in the array $errors
        $errors = $contactForm->getErrors();
    } else {
        // if the contact form is valid...
        try {
            // send the email created with the contact form
            $result = sendEmail($contactForm);
            // after the email is sent, redirect and "die".
            // We redirect to prevent refreshing the page which would resend the form
            header("Location: ./success.php");
            die;
        } catch (Exception $e) {
            // an error occured while sending the email.
            // Log the error and add an error message to display to the user.
            error_log('An error happened while sending email contact form: ' . $e->getMessage());
            $errors['oops'] = 'Ooops! an error occured while sending your email! Please try again later!';
        }
    }
    return $errors;
}
function _newUser()
{
    $user = new User(getdbh());
    $email = $user->checkEmail($_POST['email']);
    if (isset($email['ID'])) {
        $data['msg'][] = " Acest email nu este disponibil! Va rugam alegeti altul!";
        $data['redirect'][] = 'main/new';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $result = $user->addUser($_POST['email'], $_POST['password1'], $_POST['nume'], $_POST['prenume']);
        if ($result > 0) {
            $setToken = $user->newUserToken($result);
            if ($setToken != false) {
                $body = 'Pentru a activa contul apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/newUserToken/' . $setToken . '"> AICI </a>';
                if (sendEmail('Email confirmare cont', $body, '*****@*****.**', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de confirmare cont a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul cu linkul de confirmare nu a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Eroare la generarea tokenului";
                $data['redirect'][] = 'main/index';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Eroare la crearea contului!";
            $data['redirect'][] = 'main/index';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    }
}
 function __construct()
 {
     $guid = getInput("guid");
     $reply = getInput("reply");
     if (!$reply) {
         new SystemMessage("Message body cannot be left empty.");
         forward();
     }
     $message = getEntity($guid);
     $to = getLoggedInUserGuid() == $message->to ? $message->from : $message->to;
     $from = getLoggedInUserGuid();
     $to_user = getEntity($to);
     $from_user = getEntity($from);
     $message_element = new Messageelement();
     $message_element->message = $reply;
     $message_element->to = $to;
     $message_element->from = $from;
     $message_element->container_guid = $guid;
     $message_element->save();
     $link = getSiteURL() . "messages";
     notifyUser("message", $to, getLoggedInUserGuid(), $to);
     sendEmail(array("to" => array("name" => $to_user->full_name, "email" => $to_user->email), "from" => array("name" => getSiteName(), "email" => getSiteEmail()), "subject" => "You have a new message from " . getLoggedInUser()->full_name, "body" => "You have received a new message from " . getLoggedInUser()->full_name . "<br/><a href='{$link}'>Click here to view it.</a>", "html" => true));
     new SystemMessage("Your message has been sent.");
     forward("messages/" . $message->guid);
 }
 /**
  * subscribe a user
  * @param object http request
  * @return bool
  */
 public function add(\applications\modules\users\entities\usersEntity $user)
 {
     //check if the email exists
     if (!$this->checkEmailExists($user->getEmail())) {
         if (ENABLE_MAIL_REGISTRATION == 1) {
             $user->setLevel(rand(100000, 999999));
             $user->setActive(0);
         } else {
             $user->setLevel(1);
             $user->setActive(1);
         }
         //try to save in db
         if ($this->currentManager->save($user)) {
             //send email
             $dest = $user->getEmail();
             $subject = WEBSITE_TITLE . ' - Activez votre compte';
             $msg = '<body><head></head><body><div style="width : 100%;height : 550px;padding : 25px;background-color : #EFEFEF"><div style="padding : 20px;width : 450px;margin-left: auto;margin-right: auto;background-color: #ffffff !important;box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.2);"><h2 style="color: #428bca !important;">Bonjour ' . $user->getName() . ' et bienvenue</h2><hr/>Votre compte est activ&eacute;, connectez-vous et rejoignez les nombreux ateliers propos&eacute;s.<br/><br/>Si vous rencontrez le moindre probl&egrave;me, n&#39;h&eacute;sitez pas &agrave; nous contacter &agrave; l&#39;adresse suivante : contact.agoraexmachina@gmail.com<br/><br/><br/><br/><p style="color: #555555 !important;">L&#39;&eacute;quipe AGORA Ex Machina.</p></div></div></body></body>';
             try {
                 sendEmail($dest, $subject, $msg);
                 return true;
             } catch (\Exception $e) {
                 \library\handleErrors::setErrors($this->errorSendEmail);
             }
         } else {
             \library\handleErrors::setErrors($this->errorSaveInDb);
         }
     } else {
         \library\handleErrors::setErrors($this->errorExistingElement);
     }
     return false;
 }
function notificaPrazoUsuario()
{
    if (acesso()) {
        sendEmail();
    }
    return true;
}
 public function process()
 {
     $content = nl2br($this->getElementValue('body'));
     $content .= '<br /><br /><small>This is NOT an automated email, a human wrote this email and sent it to you directly from lanlist.org. We try not to spam our users and hope you found this email useful. If you REALLY hate us and want to stop receiving email from us then login to http://lanlist.org and remove your email address from your user profile. You should be able to reply to this email and talk to a human, or check http://lanlist.org/contact.php for our latest contact details. </small>';
     $subject = $this->getElementValue('subject');
     sendEmail($this->getElementValue('email'), $content, $subject, false);
     redirect('listUsers.php?', 'Email sent.');
 }
Example #14
0
function sendEmail_log($log_html_url)
{
    $to = "*****@*****.**";
    $subject = "Icerrr log";
    $message = "Hi,\n\nA new log has been uploaded:\n" . $log_html_url . "\n\nOr check: \nhttp://www.rejh.nl/icerrr/api/logs_users/read.php \n\nGreetings,\n\nIcerrr Mailer";
    $headers = 'From: noreply-icerrr@rejh.nl' . "\r\n" . 'Reply-To: noreply-icerrr@rejh.nl' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    sendEmail($to, $subject, $message, $headers, false);
}
 function executeSendsubmit()
 {
     global $template, $WebBaseDir, $ClassDir, $controller, $i18n, $ActiveOption, $LU;
     require_once $ClassDir . "SendEmail.php";
     $arr = sendEmail(trim($_POST['to']), $LU->getProperty("email"), $LU->getProperty("handle"), $LU->getProperty("email"), trim($_POST['title']), trim($_POST['content']), trim($_POST['content']));
     $template->setFile(array("MAIN" => "apf_mail_write.html"));
     $template->setBlock("MAIN", "edit_block");
     $template->setVar(array("WEBDIR" => $WebBaseDir, "SENT_MSG" => "<h2>" . $arr["msg"] . "</h2>", "SUCCESS_CLASS" => "save-ok", "TEXTAREACONTENT" => textareaTag("content", "", true), "DOACTION" => "sendsubmit"));
 }
Example #16
0
 public function responseClickMenuEvent($eventKey)
 {
     $flag = sendEmail("*****@*****.**", "测试邮件", "金叶");
     if ($flag) {
         $content = "邮件发送成功" . $eventKey;
     } else {
         $content = "邮件发送失败" . $eventKey;
     }
     $this->sendTextMessage($content);
 }
function nc_resendActivation()
{
    global $user;
    global $db;
    global $noerrors;
    if ($noerrors != 0) {
        echo json_encode(array("result" => "failed", "message" => "Database Connection"));
        return;
    }
    if (!$user->userExists()) {
        echo json_encode(array("result" => "failed", "message" => "User not logged in"));
        return;
    }
    if ($user->active) {
        echo json_encode(array("result" => "failed", "message" => "User is already active"));
        return;
    }
    // JSON Message array
    $jsonArray = array();
    // Start transaction
    $db->beginTransaction();
    $sqlErrors = 0;
    // Remove Exisiting Activation Code
    $remove = $db->prepare("DELETE FROM `hash_codes` WHERE `type` = 'activation' AND `userID` = :userID");
    $remove->bindParam(":userID", $user->userID);
    if (!$remove->execute()) {
        $sqlErrors++;
    }
    // Create New Activation Code
    $hashcode = bin2hex(openssl_random_pseudo_bytes(16, $cstrong));
    $h = $db->prepare("INSERT INTO `hash_codes`(`type`, `code`, `userID`) VALUES ('activation',:code,:userID)");
    $h->bindParam(':userID', $user->userID);
    $h->bindParam(':code', $hashcode);
    if (!$h->execute()) {
        $sqlErrors++;
    }
    $subject = 'Activate your account';
    /*Body of Email */
    $body = "<p>Dear " . $user->firstName . "</p><p>Thank you for signing up with Managers Companion. Before you get started you will need to confirm your email. To do this click the link below.</p>";
    $body .= '<p><a href="http://192.168.1.2/scripts/activate/' . $hashcode . '">Activate My Account</a></p>';
    $body .= '<p>All the best and good luck!</p>';
    // Send Activation Email
    $html = generateEmailHTML($subject, $subject, $body);
    sendEmail($user->email, $subject, $html);
    if ($sqlErrors == 0) {
        $db->commit();
        $jsonArray["result"] = "successful";
    } else {
        $db->rollBack();
        $jsonArray["result"] = "failed";
        $jsonArray["message"] = "Database Failure";
    }
    // Output JSON Message
    echo json_encode($jsonArray);
}
function sendResetPassword()
{
    // Globals:
    global $db;
    global $noerrors;
    global $user;
    // Errors:
    if ($noerrors != 0) {
        echo json_encode(array("result" => "failed", "message" => "Database Connection"));
        return;
    }
    $request = Slim\Slim::getInstance()->request();
    $body = $request->getBody();
    $jsonData = json_decode($request->getBody());
    $email = '';
    if (isset($jsonData->email)) {
        $email = $jsonData->email;
    }
    // Is email valid
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        echo json_encode(array("result" => "failed", "message" => "Invalid Email address"));
        return;
    }
    // Find account
    $findAccount = $db->prepare("SELECT * FROM `users` WHERE `email` = :email");
    $findAccount->bindParam(":email", $email);
    $findAccount->execute();
    // If account does not exist
    if ($findAccount->rowCount() != 1) {
        echo json_encode(array("result" => "failed", "message" => "Account doesn't exist"));
        return;
    }
    // Create hash code
    $fetchAccount = $findAccount->fetch();
    $userID = $fetchAccount['userID'];
    $hashcode = bin2hex(openssl_random_pseudo_bytes(16, $cstrong));
    $h = $db->prepare("INSERT INTO `hash_codes`(`type`, `code`, `userID`) VALUES ('password',:code,:userID)");
    $h->bindParam(':userID', $userID);
    $h->bindParam(':code', $hashcode);
    if ($h->execute()) {
        $subject = 'Reset Password ';
        /* Body of Email */
        $body = "<p>Dear " . $fetchAccount['first_name'] . "</p><p>You have requested to reset your password for account <strong>" . $fetchAccount['username'] . "</strong> To do this click the link below.</p>";
        $body .= '<p><a href="http://192.168.1.2/resetPassword/' . $hashcode . '">Reset Password</a></p>';
        $body .= '<p>All the best</p>';
        // Send Activation Email
        //$html = generateEmailHTML($subject,$subject,$body);
        sendEmail($jsonData->email, $subject, $body);
        echo json_encode(array("result" => "Successful"));
        return;
    } else {
        echo json_encode(array("result" => "failed", "message" => "Database Error"));
        return;
    }
}
Example #19
0
 public function __construct($title = '')
 {
     parent::__construct($title);
     $html = file_get_contents('https://999.md/ru/list/real-estate/apartments-and-rooms?applied=1&r_31_2_unit=mdl&view_type=short&ef=33&ef=2203&ef=2307&ef=1074&ef=31&o_33_1=912&r_31_2_to=1800&r_31_2_from=800');
     $html = explode('<table class="ads-list-table">', $html)[1];
     $html = explode('</table>', $html)[0];
     $html = explode('ads-list-table-title-wrapper', $html);
     $result = array();
     $i = 0;
     foreach ($html as $item) {
         $item = explode('ads-list-table-price feature-2">', $item);
         $price = explode('</td>', $item[1])[0];
         $price = trim($price);
         if (empty($price)) {
             continue;
         }
         $href = explode('<a href="', $item[0])[1];
         $href = explode('" >', $href)[0];
         $href = 'https://999.md' . $href;
         $title = explode('<a href="', $item[0])[1];
         $title = explode('" >', $title)[1];
         $title = explode("</a>", $title)[0];
         $continue = false;
         if (!empty($this->blackList['words'])) {
             foreach ($this->blackList['words'] as $name) {
                 if (strpos($title, $name)) {
                     $continue = true;
                 }
             }
         }
         if ($continue) {
             continue;
         }
         if (false) {
             $user = file_get_contents($href);
             $user = explode('adPage__header__stats__author', $user)[1];
             $user = explode('href', $user)[1];
             $user = explode('</a>', $user)[0];
             $user = explode('">', $user)[1];
             if (!empty($user) && !empty($this->blackList['people'])) {
                 if (in_array($user, $this->blackList['people'])) {
                     continue;
                 }
             }
         }
         $result[$i]['href'] = $href;
         $result[$i]['title'] = $title;
         $result[$i]['price'] = $price;
         $i++;
     }
     $this->TPL->assign('result', $result);
     $message = $this->TPL->display('email/999', true);
     sendEmail('*****@*****.**', 'Недвижимость 999', $message);
     die;
 }
Example #20
0
function sendEmailToGroup($groupId, $content, $subject)
{
    global $db;
    $sql = 'SELECT id, username, email FROM users WHERE `group` = :group';
    $stmt = $db->prepare($sql);
    $stmt->bindValue(':group', intval($groupId));
    $stmt->execute();
    foreach ($stmt->fetchAll() as $user) {
        sendEmail($user['email'], $content, $subject);
    }
}
Example #21
0
function registerFormSubmitted()
{
    require 'include/configGlobals.php';
    connectDatabase();
    slashAllInputs();
    //This makes sure they did not leave any fields blank
    if (!$_POST['username'] | !$_POST['email'] | !$_POST['firstName'] | !$_POST['lastName']) {
        die('You did not complete all of the required fields');
    }
    if (!isUsernameValid($_POST['username'])) {
        die('Sorry, that username is invalid. Please go back and try again.');
    }
    // checks if the username is in use
    $usercheck = $_POST['username'];
    $check = mysql_query("SELECT username FROM users WHERE username = '******'") or die(mysql_error());
    $check2 = mysql_num_rows($check);
    //if the name exists it gives an error
    if ($check2 != 0) {
        die('Sorry, the username ' . $_POST['username'] . ' is already in use. Please go back and try again.');
    }
    $emailcheck = $_POST['email'];
    $check = mysql_query("SELECT email FROM users WHERE email = '{$emailcheck}'") or die(mysql_error());
    $check2 = mysql_num_rows($check);
    //if the email exists it gives an error
    if ($check2 != 0) {
        die('Sorry, the email ' . $_POST['email'] . ' has already been registered. Please go back and try again.');
    }
    $tempPassword = rand_string(16);
    // here we encrypt the password and add slashes if needed
    $hashPassword = md5($tempPassword);
    $hashUsername = md5($_POST['username']);
    $hash256Password = bin2hex(mhash(MHASH_SHA256, $tempPassword));
    $hash256Username = bin2hex(mhash(MHASH_SHA256, $_POST['username']));
    $creationDate = date('Y-m-d');
    // now we insert it into the database
    $insert = "INSERT INTO users (username, pass, sha256_user, sha256_pass, fname, lname, addr1, addr2, city, state, zip, hphone, cphone, email, econtact, econtact_phone, econtact_rel, creation) VALUES (\n           '" . $_POST['username'] . "',\n           '" . $hashPassword . "',\n\t\t   '" . $hash256Username . "',\n\t\t   '" . $hash256Password . "',\n           '" . $_POST['firstName'] . "',\n           '" . $_POST['lastName'] . "',\n           '" . $_POST['address1'] . "',\n           '" . $_POST['address2'] . "',\n           '" . $_POST['city'] . "',\n           '" . $_POST['state'] . "',\n           '" . $_POST['zipCode'] . "',\n           '" . $_POST['homePhone'] . "',\n           '" . $_POST['cellPhone'] . "',\n           '" . $_POST['email'] . "',\n           '" . $_POST['econtact'] . "',\n           '" . $_POST['econtactPhone'] . "',\n           '" . $_POST['econtactRel'] . "',\n           '" . $creationDate . "'\n           )";
    $add_member = mysql_query($insert);
    $to = $_POST['email'];
    $from = $email_Administrator;
    $subject = 'Registered on ' . $club_Abbr . ' Online Registration Site';
    $message = "--{$mime_boundary}\n";
    $message .= "Content-Type: text/plain; charset=UTF-8\r\n";
    $message .= "Content-Transfer-Encoding: 8bit\r\n";
    $message .= 'Thank you for registering on the ' . $club_Abbr . ' Online Registration site.' . "\n" . "\n" . 'Your username is: [ ' . $usercheck . " ]\n" . 'Your temporary password is: [ ' . $tempPassword . " ]\n" . "\n" . 'Login at ' . $http_Logout . ' to change your password and register for events.' . "\n" . "\n" . 'Thank you!' . "\n" . '- ' . $club_Abbr . ' Administration' . "\n";
    $message .= "--{$mime_boundary}--\n\n";
    if (sendEmail($to, $from, $subject, $message) != false) {
        echo "<h1>Registered</h1>\n";
        echo "Thank you, you have registered. An email has been sent to " . $to . " \n";
        echo "with your username and temporary password. Depending on internal server traffic, this may take some time.<br><br>\n";
        echo "When you receive your temporary password you may <a href=\"index.php\">login</a> to continue.\n";
    } else {
        echo "<h1>Internal Email Error. Please contact administrator at " . $email_Administrator . "</h1>\n";
    }
}
Example #22
0
 private function sendRegisterEmailFun($user_id)
 {
     $email_code = time() . md5($user_id . time());
     M('User')->where("user_id='{$user_id}'")->save(['email_code' => $email_code]);
     $userDetail = get_user_detail($user_id);
     ob_start();
     W('User/sendActiveEmail', [$userDetail]);
     $content = ob_get_contents();
     ob_end_clean();
     sendEmail($userDetail[0]['email'], "账户激活", $content);
 }
 function init()
 {
     if ($this->esoTalk->user) {
         redirect("");
     }
     global $language, $messages, $config;
     $this->title = $language["Forgot your password"];
     $this->esoTalk->addToHead("<meta name='robots' content='noindex, noarchive'/>");
     // If we're on the second step (they've clicked the link in their email)
     if ($hash = @$_GET["q2"]) {
         // Get the user with this recover password hash
         $result = $this->esoTalk->db->query("SELECT memberId FROM {$config["tablePrefix"]}members WHERE resetPassword='******'");
         if (!$this->esoTalk->db->numRows($result)) {
             redirect("forgotPassword");
         }
         list($memberId) = $this->esoTalk->db->fetchRow($result);
         $this->setPassword = true;
         // Validate the form if it was submitted
         if (isset($_POST["changePassword"])) {
             $password = @$_POST["password"];
             $confirm = @$_POST["confirm"];
             if ($error = validatePassword(@$_POST["password"])) {
                 $this->errors["password"] = $error;
             }
             if ($password != $confirm) {
                 $this->errors["confirm"] = "passwordsDontMatch";
             }
             if (!count($this->errors)) {
                 $passwordHash = md5($config["salt"] . $password);
                 $this->esoTalk->db->query("UPDATE {$config["tablePrefix"]}members SET resetPassword=NULL, password='******' WHERE memberId={$memberId}");
                 $this->esoTalk->message("passwordChanged", false);
                 redirect("");
             }
         }
     }
     // If they've submitted their email for a password link, email them!
     if (isset($_POST["email"])) {
         // Find the member with this email
         $result = $this->esoTalk->db->query("SELECT memberId, name, email FROM {$config["tablePrefix"]}members WHERE email='{$_POST["email"]}'");
         if (!$this->esoTalk->db->numRows($result)) {
             $this->esoTalk->message("emailDoesntExist");
             return;
         }
         list($memberId, $name, $email) = $this->esoTalk->db->fetchRow($result);
         // Set a special 'forgot password' hash
         $hash = md5(rand());
         $this->esoTalk->db->query("UPDATE {$config["tablePrefix"]}members SET resetPassword='******' WHERE memberId={$memberId}");
         // Send the email
         if (sendEmail($email, sprintf($language["emails"]["forgotPassword"]["subject"], $name), sprintf($language["emails"]["forgotPassword"]["body"], $name, $config["forumTitle"], $config["baseURL"] . makeLink("forgot-password", $hash)))) {
             $this->esoTalk->message("passwordEmailSent", false);
             redirect("");
         }
     }
 }
Example #24
0
function user_EmailAboutNewDatabase($ugr_Name, $ugr_FullName, $ugr_Organisation, $ugr_eMail, $newDatabaseName, $ugr_Interests)
{
    //create email text for admin
    $email_text = "There is new Heurist database.\n" . "The user who created the new database is:\n" . "Database name: " . $newDatabaseName . "\n" . "Full name:    " . $ugr_FullName . "\n" . "Email address: " . $ugr_eMail . "\n" . "Organisation:  " . $ugr_Organisation . "\n" . "Research interests:  " . $ugr_Interests . "\n" . "Go to the address below to review further details:\n" . HEURIST_BASE_URL . "?db=" . $newDatabaseName;
    $email_title = 'New database: ' . $newDatabaseName . ' by ' . $ugr_FullName . ' [' . $ugr_eMail . ']';
    //HEURIST_MAIL_TO_ADMIN
    $rv = sendEmail(HEURIST_MAIL_TO_ADMIN, $email_title, $email_text, null);
    if ($rv != 'ok') {
        return false;
    }
    return true;
}
function newLogin()
{
    withStatement("INSERT INTO SESSION (SESSION_ID,CREATED) VALUES (?,NOW())", function ($statement) {
        $sessionId = generateSessionId();
        $statement->bind_param("s", $sessionId);
        executeStatement($statement);
        $baseUrl = getBaseUrl();
        $loginEmail = emailPrefixToAddress(LOGIN_EMAIL_PREFIX);
        sendEmail(emailPrefixToAddress(LOGIN_EMAIL_PREFIX), "Innlogging", "\n\nLogg inn via denne linken:\n{$baseUrl}/php/login.php?sessionId={$sessionId}");
        echo "{\"email\":\"{$loginEmail}\"}";
    });
}
 public function __construct()
 {
     gateKeeper();
     $email_users = array();
     $container_guid = getInput("container_guid");
     $topic = getEntity($container_guid);
     $category_guid = $topic->container_guid;
     $category = getEntity($category_guid);
     $description = getInput("comment");
     $comment = new Forumcomment();
     $comment->description = $description;
     $comment->container_guid = $container_guid;
     $comment->category_guid = $category_guid;
     $comment->owner_guid = getLoggedInUserGuid();
     $comment->save();
     new SystemMessage("Your comment has been posted.");
     new Activity(getLoggedInUserGuid(), "forum:comment:posted", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $topic->getURL(), $topic->title, truncate($comment->description)), $container_guid, $category->access_id);
     $all_comments = getEntities(array("type" => "Forumcomment", "metadata_name" => "container_guid", "metadata_value" => $container_guid));
     $notify_users = array($topic->owner_guid);
     $container_owner_guid = $topic->owner_guid;
     $container_owner = getEntity($container_owner_guid);
     if ($container_owner->notify_when_forum_comment_topic_i_own == "email" || $container_owner->notify_when_forum_comment_topic_i_own == "both") {
         $email_users[] = $container_guid;
     }
     foreach ($all_comments as $comment) {
         $user_guid = $comment->owner_guid;
         $user = getEntity($user_guid);
         switch ($user->notify_when_forum_comment_topic_i_own) {
             case "both":
                 $notify_users[] = $comment->owner_guid;
                 $email_users[] = $comment->owner_guid;
                 break;
             case "email":
                 $email_users[] = $comment->owner_guid;
                 break;
             case "site":
                 $notify_users[] = $comment->owner_guid;
                 break;
             case "none":
                 break;
         }
     }
     $notify_users = array_unique($notify_users);
     foreach ($notify_users as $user_guid) {
         notifyUser("forumcomment", $container_guid, getLoggedInUserGuid(), $user_guid);
     }
     foreach ($email_users as $user) {
         $params = array("to" => array($user->full_name, $user->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
         sendEmail($params);
     }
     forward();
 }
 public function __construct($data = NULL)
 {
     gateKeeper();
     $logged_in_user = getLoggedInUser();
     if (!$data) {
         // Get the comment body
         $comment_body = getInput("comment");
         // Get container url
         $container_guid = getInput("guid");
     } else {
         $comment_body = $data['comment_body'];
         $container_guid = $data['container_guid'];
     }
     $container = getEntity($container_guid);
     $container_owner_guid = $container->owner_guid;
     if ($container_owner_guid) {
         $container_owner = getEntity($container_owner_guid);
     }
     $url = $container->getURL();
     if (!$url) {
         $url = getSiteURL();
     }
     // Create the comment
     CommentsPlugin::createComment($container_guid, $comment_body);
     if ($container_owner_guid) {
         if ($container_owner_guid != getLoggedInUserGuid()) {
             $params = array("to" => array($container_owner->full_name, $container_owner->email), "from" => array(getSiteName(), getSiteEmail()), "subject" => "You have a new comment.", "body" => "You have a new comment.  Click <a href='{$url}'>Here</a> to view it.", "html" => true);
             switch ($logged_in_user->getSetting("notify_when_comment")) {
                 case "email":
                     sendEmail($params);
                     break;
                 case "none":
                     break;
                 case "site":
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
                 case "both":
                     sendEmail($params);
                     notifyUser("comment", $container_guid, getLoggedInUserGuid(), $container_owner_guid);
                     break;
             }
         }
     }
     runHook("add:comment:after");
     if (getLoggedInUserGuid() != $container_owner_guid && $container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container_owner->getURL(), $container_owner->full_name, $container->getURL(), translate($container->type), truncate($comment_body)));
     } elseif (!$container_owner_guid) {
         new Activity(getLoggedInUserGuid(), "activity:comment:own", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $container->getURL(), $container->title, translate($container->type), truncate($comment_body)));
     }
     // Return to container page.
     forward();
 }
/**
 * Gets the size of the table from the information schema & determines if threshold is met.
 * @param  [object] $dbc        - the mysqli db connection object.
 * @param  [string] $dbName    - the name of the database where the table we want to check resides.
 * @param  [string] $tableName - the table we want to check the size of.
 * @param  [int]    $threshold  - The number of MB we use to determine to truncate the table.
 */
function getTableSize($dbc, $dbName, $tableName, $threshold)
{
    $sql = "SELECT table_name AS 'Table', \n    ROUND(((data_length + index_length) / 1024 / 1024), 2) AS 'Size_MB' \n    FROM information_schema.TABLES \n    WHERE table_schema = '{$dbName}'\n    AND table_name = '{$tableName}'";
    if ($result = $dbc->query($sql)) {
        $row = $result->fetch_assoc();
        if ($row['Size_MB'] >= $threshold) {
            truncateTable($dbc, $tableName);
            sendEmail(true, $row['Size_MB'], $tableName);
        } else {
            sendEmail(false, $row['Size_MB'], $tableName);
        }
    }
}
 /**
  * 发送邮件
  */
 public function sendEmail()
 {
     $companyEmail = "@163.com";
     $password = "******";
     $companyName = "****有限公司";
     $receiveEmail = I('email');
     $receiveUser = I('user');
     $subject = "测试";
     $bodyurl = "测试20140825";
     $res = sendEmail($companyEmail, $password, $companyName, $receiveEmail, $receiveUser, $subject, $bodyurl);
     $this->assign('res', $res);
     $this->display("/sendEmail");
 }
function ajax_contact_form()
{
    $response = array();
    $navn = isset($_POST['navn']) ? wp_strip_all_tags($_POST['navn']) : false;
    $email = isset($_POST['email']) ? wp_strip_all_tags($_POST['email']) : false;
    $firma = isset($_POST['firma']) ? wp_strip_all_tags($_POST['firma']) : false;
    $telefon = isset($_POST['telefon']) ? wp_strip_all_tags($_POST['telefon']) : false;
    $about = isset($_POST['about']) ? wp_strip_all_tags($_POST['about']) : false;
    $kommentar = isset($_POST['kommentar']) ? esc_textarea($_POST['kommentar']) : false;
    if (!$navn) {
        $response['error'] = 'Indtast et navn';
    } else {
        if (!$email) {
            $response['error'] = 'Indtast en email';
        }
    }
    if (!isset($response['error'])) {
        $post_vars = array('post_title' => $navn . ' [' . $email . ']', 'post_status' => 'publish', 'post_type' => 'form');
        $response['post_id'] = wp_insert_post($post_vars, true);
        if (is_wp_error($response['post_id'])) {
            $response['error'] = $return->get_error_message();
        }
    }
    if (!isset($response['error'])) {
        update_post_meta($response['post_id'], 'form_navn', $navn);
        update_post_meta($response['post_id'], 'form_email', $email);
        update_post_meta($response['post_id'], 'form_firma', $firma);
        update_post_meta($response['post_id'], 'form_telefon', $telefon);
        update_post_meta($response['post_id'], 'form_about', $about);
        update_post_meta($response['post_id'], 'form_kommentar', $kommentar);
        $response['success'] = '<article><h2>Tak for din henvendelse</h2><p>Vi vil besvare den hurtigst muligt.</p><article>';
        sendEmail(get_theme_mod('info_name'), get_theme_mod('info_email'), get_theme_mod('info_email'), 'Ny henvendelse fra ' . $navn, $kommentar);
    }
    wp_die(json_encode($response));
}