/** * @Route("/send", methods = {"PUT", "OPTIONS"}) */ public function SendAction() { $info = $this->request->getJsonRawBody(); if (!isset($info->id)) { $this->response->setJsonContent(['message' => 'No Email Id Set!']); } else { $message = Utils::sendMail($info->id); $this->response->setJsonContent(['message' => $message]); } $this->response->send(); return; }
private static function notify($contactId, &$allRides, $potentialRideIds) { debug(__METHOD__ . "({$contactId}, " . json_encode($potentialRideIds) . ")"); $toNotify = array(); foreach ($allRides as $ride) { if (in_array($ride['Id'], $potentialRideIds)) { $toNotify[] = $ride; } } $contact = DatabaseHelper::getInstance()->getContactById($contactId); $mailBody = MailHelper::render(VIEWS_PATH . '/showInterestMail.php', array('rides' => $toNotify), $contact); Utils::sendMail(Utils::buildEmail($contact['Email']), $contact['Email'], getConfiguration('mail.addr'), getConfiguration('mail.display'), 'New rides from carpool', $mailBody); }
public function __construct($kwargs) { // if args null, construct an empty instance for a fetch if ($kwargs == null) { return; } // If we got all required field, create the user, send mail if (array_key_exists("name", $kwargs) && array_key_exists("mail", $kwargs) && array_key_exists("password", $kwargs)) { $this->id = Utils::gen_uuid(); $this->mail = $kwargs['mail']; $this->name = $kwargs['name']; $this->role = isset($kwargs['role']) ? $kwargs['role'] : User::USER; $this->password = hash("whirlpool", $kwargs['mail'] . $kwargs['password']); $this->state = User::NEED_VALID; // Send mail Utils::sendMail(Utils::VALID_TYPE, $this); } }
} // get put content parse_str(file_get_contents("php://input"), $vars); // verify that they exist and verify that the img is valid if (!isset($vars['content']) || !isset($vars['post']) || !Utils::is_uuid($vars['post'])) { header("42", true, 400); return; } $post = Post::query($vars['post']); if ($post == null) { header("42", true, 404); return; } // delete any html balise $content = preg_replace('/<[^>]*>/', '', $vars['content']); //create the comment $comment = new Comment(array('author' => $_SESSION['user'], 'post' => $vars['post'], 'content' => $content)); try { $comment->create(); } catch (Exception $e) { header("42", true, 409); return; } // send email to the author Utils::sendMail(Utils::NEW_COMMENT, User::query($post->author), $comment); // return success if created header("42", true, 201); break; default: header("42", true, 400); }
function mailEvent() { global $error; $color = DEFAULT_COLOR; $arr_submit = array(array('cal_id', 'int', true, ''), array('str_date_end', 'string', false, ''), array('str_date_start', 'string', false, ''), array('title', 'string', false, ''), array('location', 'string', false, ''), array('phone', 'phone', false, ''), array('myurl', 'string', false, ''), array('description', 'string', false, '')); $frm_submitted = validate_var($arr_submit); $frm_submitted['title'] = stripslashes($frm_submitted['title']); if (empty($frm_submitted['title'])) { echo json_encode(array('success' => false, 'error' => 'Title is required')); exit; } if (is_null($error) || empty($error)) { // get calendar admin mail $arr_calendar = Calendar::getCalendar($frm_submitted['cal_id']); $to_mail = ''; if (isset($arr_calendar['calendar_admin_email']) && !empty($arr_calendar['calendar_admin_email'])) { if (Utils::checkEmail($arr_calendar['calendar_admin_email'])) { $bln_email_correct = true; $to_mail = $arr_calendar['calendar_admin_email']; } } else { if (defined('MAIL_EVENT_MAILADDRESS')) { $mailaddress = MAIL_EVENT_MAILADDRESS; if (!empty($mailaddress)) { if (Utils::checkEmail($mailaddress)) { $bln_email_correct = true; $to_mail = $mailaddress; } else { echo json_encode(array('success' => false, 'error' => 'No correct emailaddress found')); exit; } } else { echo json_encode(array('success' => false, 'error' => 'Emailaddress in config.php is empty')); exit; } } else { echo json_encode(array('success' => false, 'error' => 'No emailaddress found')); exit; } } if (!empty($to_mail)) { $arr_user = array(); if (User::isLoggedIn()) { $arr_user = User::getUser(); } $bln_send = Utils::sendMail('mail_event', $to_mail, '', $frm_submitted, $arr_user); if ($bln_send) { echo json_encode(array('success' => true, 'msg' => 'Mail successfully send')); exit; } else { echo json_encode(array('success' => false, 'error' => 'Error while sending the email, contact the admin')); exit; } } else { // echo json_encode(array('success'=>false, 'error'=>'No calendar admin email found')); // exit; } } else { echo json_encode(array('success' => false, 'error' => $error)); exit; } }
if (!AuthHandler::isSessionExisting()) { // Try to discard bots by dropping requests with no session die; } extract($_POST); if (!Utils::isEmptyString($feedback)) { $mailHelper = new MailHelper(); $wantToStr = isset($wantTo) && isset($feedbackOptions[$wantTo]) ? $feedbackOptions[$wantTo] : _("Other"); $params = array('wantTo' => $wantToStr, 'feedback' => $feedback, 'email' => $email); $body = $mailHelper->render('views/feedbackMail.php', $params); $to = getConfiguration('feedback.mail'); $toName = getConfiguration('feedback.to.name'); $from = getConfiguration('feedback.from'); $fromName = getConfiguration('feedback.from.name'); $replyTo = Utils::isEmptyString($email) ? null : Utils::buildEmail($email); Utils::sendMail($to, $toName, $from, 'Carpool feedback', 'New carpool feedback', $body, $replyTo, $replyTo); GlobalMessage::setGlobalMessage(_('Thanks for the feedback!')); } else { GlobalMessage::setGlobalMessage(_('Please write something.'), GlobalMessage::ERROR); } // Get after post Utils::redirect('feedback.php'); } else { AuthHandler::putUserToken(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="css/reset-fonts.css"> <link rel="stylesheet" type="text/css" href="css/common.css">
public static function addUser($frm_submitted) { global $obj_db; $str_query = 'SELECT * FROM users WHERE username = "******"'; $obj_result = mysqli_query($obj_db, $str_query); $arr_user = mysqli_fetch_array($obj_result, MYSQLI_ASSOC); if ($obj_result !== false && !empty($arr_user) && $arr_user !== false) { if (SHOW_USERNAME_IN_FORM && !empty($frm_submitted['username'])) { return 'Username already exists'; } else { return 'Username (emailaddress) already exists'; } } $str_query = 'SELECT * FROM users WHERE email = "' . $frm_submitted['email'] . '"'; $obj_result2 = mysqli_query($obj_db, $str_query); $arr_user2 = mysqli_fetch_array($obj_result2, MYSQLI_ASSOC); if ($obj_result2 !== false && !empty($arr_user2) && $arr_user2 !== false) { return 'Emailaddress already exists'; } // generate random password $password = Utils::generatePassword(); $bln_insert = false; if (User::isSuperAdmin()) { $usertype = 'admin'; $admin_group = $_SESSION['calendar-uid']['uid']; $bln_insert = true; } else { if (User::isAdmin()) { $usertype = 'user'; $admin_group = $_SESSION['calendar-uid']['uid']; $bln_insert = true; } } if ($bln_insert) { $send_activation_mail = Settings::getSetting('send_activation_mail', $admin_group); $bln_send_activation_mail = $send_activation_mail == 'on'; $str_query = 'INSERT INTO users ( `firstname` ,`infix` ,`lastname` ,`username`,`password` ,`email` ,`registration_date` ,' . '`birth_date`, `active`, `ip`, `country`, `country_code`, `usertype`, `admin_group`) VALUES (' . '"' . $frm_submitted['firstname'] . '",' . '"' . $frm_submitted['infix'] . '",' . '"' . $frm_submitted['lastname'] . '",' . '"' . (isset($frm_submitted['username']) && !empty($frm_submitted['username']) ? $frm_submitted['username'] : $frm_submitted['email']) . '",' . '"' . self::getPasswordHashcode($password) . '",' . '"' . $frm_submitted['email'] . '",' . 'NOW(),' . '"",' . ($bln_send_activation_mail ? '0, ' : '1,') . '"",' . '"",' . '"",' . '"' . $usertype . '",' . $admin_group . ')'; $res = mysqli_query($obj_db, $str_query); $int_user_id = mysqli_insert_id($obj_db); $hash_code = self::getUserHashcode($int_user_id); if ($bln_send_activation_mail) { $str_query = 'UPDATE `users` SET user_hash = "' . $hash_code . '" ' . ' WHERE `user_id` = ' . $int_user_id; $res2 = mysqli_query($obj_db, $str_query); } if ($res !== false) { $admin_mail = ''; if (defined('ADMIN_EMAILADDRESS')) { $admin_mail = ADMIN_EMAILADDRESS; } if (User::isSuperAdmin()) { $bln_send = Utils::sendMail('add_admin', $frm_submitted['email'], $password, $frm_submitted); if ($frm_submitted['copy_to_admin'] && !empty($admin_mail)) { Utils::sendMail('copy_to_admin_admin_created', $admin_mail, $password, $frm_submitted); } // insert default settings settings::saveDefaultSettings($int_user_id); } else { if (User::isAdmin()) { $bln_send = Utils::sendMail('add_user', $frm_submitted['email'], $password, $frm_submitted, $int_user_id, $hash_code); if ($frm_submitted['copy_to_admin'] && !empty($admin_mail)) { Utils::sendMail('copy_to_admin_user_created', $admin_mail, $password, $frm_submitted); } } } if ($bln_send) { if (defined('SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER') && SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER) { return array('insert' => true, 'mail' => 'send', 'password' => $password); } else { return array('insert' => true, 'mail' => 'send'); } } else { if (defined('SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER') && SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER) { return array('insert' => true, 'mail' => 'notsend', 'password' => $password); } else { return array('insert' => true, 'mail' => 'notsend'); } } } else { return array('insert' => false, 'mail' => 'notsend'); } } else { return array('insert' => false, 'mail' => 'notsend', 'error' => 'You have no admin rights!'); } }
public static function updateRepeatingEvent($arr_dates, $frm_submitted) { global $obj_db; if (IGNORE_TIMEZONE) { $str_startdate = $frm_submitted['str_date_start']; $str_enddate = $frm_submitted['str_date_end']; $str_starttime = substr($frm_submitted['str_date_start'], 10); $str_endtime = substr($frm_submitted['str_date_end'], 10); } else { $str_startdate = date('Y-m-d', $frm_submitted['date_start']); $str_enddate = date('Y-m-d', $frm_submitted['date_end']); $str_starttime = date('H:i:s', $frm_submitted['date_start']); $str_endtime = date('H:i:s', $frm_submitted['date_end']); } /* * check if interval or weekdays have changed */ //TODO other intervals 2weeks // get the pattern $str_select_repeating_query = 'SELECT * FROM repeating_events WHERE rep_event_id = ' . $frm_submitted['rep_event_id']; $obj_result1 = mysqli_query($obj_db, $str_select_repeating_query); $arr_repeat_pattern = mysqli_fetch_array($obj_result1, MYSQLI_ASSOC); // update repeating_events table $str_update_query = 'UPDATE repeating_events SET rep_interval = "' . $frm_submitted['interval'] . '", ' . 'weekdays = "' . $frm_submitted['weekdays'] . '",' . 'monthday = "' . $frm_submitted['monthday'] . '",' . 'yearmonthday = "' . $frm_submitted['yearmonthday'] . '",' . 'yearmonth = "' . $frm_submitted['yearmonth'] . '",' . 'startdate = "' . $str_startdate . '",' . 'enddate = "' . $str_enddate . '" ' . 'WHERE rep_event_id = ' . $frm_submitted['rep_event_id']; $res = mysqli_query($obj_db, $str_update_query); // check if moved to another calendar $bln_change_cal_id = false; if (defined('MOVE_EVENT_TO_OTHER_CALENDAR_POSSIBLE') && MOVE_EVENT_TO_OTHER_CALENDAR_POSSIBLE === true) { if ($frm_submitted['calendar_id'] > 0 && $frm_submitted['calendar_id'] != $frm_submitted['cal_id']) { $bln_change_cal_id = true; } } // update events $str_update_events_query = 'UPDATE `events` SET title = "' . $frm_submitted['title'] . '", ' . '`color` = "' . $frm_submitted['color'] . '", '; if ($bln_change_cal_id) { $str_update_events_query .= '`calendar_id` = "' . $frm_submitted['calendar_id'] . '", '; } $str_update_events_query .= '`location` = "' . $frm_submitted['location'] . '", ' . '`description` = "' . $frm_submitted['description'] . '", ' . '`phone` = "' . $frm_submitted['phone'] . '", ' . '`myurl` = "' . $frm_submitted['myurl'] . '", ' . '`time_start` = "' . $str_starttime . '", ' . '`time_end` = "' . $str_endtime . '", ' . '`allDay` = ' . ($str_starttime == '00:00:00' && $str_endtime == '00:00:00' || $frm_submitted['allDay'] == 1 ? '1 ' : '0 ') . 'WHERE `repeating_event_id` = ' . $frm_submitted['rep_event_id']; $res2 = mysqli_query($obj_db, $str_update_events_query); /* * get all existing items in this pattern */ $arr_events_from_this_pattern = array(); $str_events_query = 'SELECT * FROM events WHERE repeating_event_id = ' . $frm_submitted['rep_event_id']; $obj_result1 = mysqli_query($obj_db, $str_events_query); while ($arr_line = mysqli_fetch_array($obj_result1, MYSQLI_ASSOC)) { $arr_events_from_this_pattern[] = $arr_line; } /* * find deleted weekdays */ $current_user_id = ''; foreach ($arr_events_from_this_pattern as $event) { if (!in_array($event['date_start'], $arr_dates)) { // delete $obj_result_del = mysqli_query($obj_db, 'DELETE FROM events WHERE event_id = ' . $event['event_id']); } else { $search = array_search($event['date_start'], $arr_dates); unset($arr_dates[$search]); } $time_start = $event['time_start']; $time_end = $event['time_end']; $current_user_id = $event['user_id']; $current_calendar_id = $event['calendar_id']; } /* * added/changed weekdays */ if ($frm_submitted['repair_pattern'] || $arr_repeat_pattern['weekdays'] != $frm_submitted['weekdays'] || $arr_repeat_pattern['startdate'] != $str_startdate || $arr_repeat_pattern['enddate'] != $str_enddate) { // add new items to pattern foreach ($arr_dates as $day) { if (IGNORE_TIMEZONE) { $frm_submitted['str_date_start'] = $day . ' ' . $time_start; $frm_submitted['str_date_end'] = $day . ' ' . $time_end; } else { $frm_submitted['date_start'] = strtotime($day . ' ' . $time_start); $frm_submitted['date_end'] = strtotime($day . ' ' . $time_end); } self::insertEvent($frm_submitted, $current_user_id); } } if ($frm_submitted['repair_pattern']) { // set bln_broken to 0 $str_update_query = 'UPDATE repeating_events SET bln_broken = 0 WHERE rep_event_id = ' . $frm_submitted['rep_event_id']; $res3 = mysqli_query($obj_db, $str_update_query); } $current_calendar_id = 0; if (!$frm_submitted['repair_pattern']) { // because then the mail is already send in the insertEevent function // notification mail to admin if ($current_calendar_id > 0 && !empty($current_user_id)) { $arr_calendar = Calendar::getCalendar($current_calendar_id); if (Calendar::calMailEventModsToAdmin($arr_calendar)) { $arr_user = User::getUserById($current_user_id); $to_mail = Calendar::getCalendarAdminEmail($arr_calendar); if (!empty($to_mail)) { $bln_send = Utils::sendMail('mail_event', $to_mail, '', $frm_submitted, $arr_user); } } } } }
<?php error_reporting(E_ALL); ini_set('display_errors', 1); extract($_POST); extract($_GET); require '../modelo/ConfirmacionReserva.php'; require '../../../config/utils.php'; require '../../../assets/libs/phpmailer/PHPMailerAutoload.php'; //error_reporting(E_ALL); ini_set('display_errors', 1); $objConfirmacion = new ConfirmacionReserva('', $prioridad, $streaming, "", $informacionconfirmacion, "url", $id, $tipoevento, $recurso, $canales, 1); $varId = $objConfirmacion->buscar_PorIdReserva($id); $objConfirmacion->actualizar_Id($varId); $var1 = $objConfirmacion->guardar(); $utils = new Utils(); $utils->sendMail("*****@*****.**", "xx", "yy", "", "", "confirmarReserva"); $var2 = $objConfirmacion->actualizarEstadoReserva($id); if ($var1 == 1 && $var2 == 1) { echo "<script>alert('Datos guardados')</script>"; echo "<script>location.href= '../../mod_reserva/vista/gestionar_reservas_confirmadas.php' </script>"; } else { echo "<script>alert('Error!')</script>"; }
/** * @Route("/createReplyMail", methods = {"POST", "OPTIONS"}) */ public function CreateReplyMailAction() { try { $info = $this->request->getJsonRawBody(); if (!isset($info->subject) || !isset($info->body) || !isset($info->toWhom) || !isset($info->handler_id)) { $this->response->setJsonContent(['message' => 'No Data!']); $this->response->send(); return; } $subject = $info->subject; $body = $info->body; $toWhom = $info->toWhom; $handler_id = $info->handler_id; $replyMail = new ReplyMail(); $original_mail = null; if (isset($info->reply_id)) { $subject = "回复:" . $subject; $original_mail = ReceiveMail::findFirst(['conditions' => 'id = ?1', 'bind' => [1 => $info->reply_id]]); if ($original_mail == null) { $this->response->setJsonContent(['message' => '原邮件不存在!']); $this->response->send(); return; } $original_mail->status = 2; $original_mail->save(); $replyMail->reply_id = $info->reply_id; } $o_id = $original_mail->id; $o_mail_id = base64_decode($original_mail->mail_id); $o_subject = base64_decode($original_mail->subject); $o_body = base64_decode($original_mail->body); $o_fromAddress = $original_mail->fromAddress; $o_receiveDate = $original_mail->receiveDate; $o_tags = base64_decode($original_mail->tags); $o_status = $original_mail->status; $o_deadline = $original_mail->deadline; $o_dispatcher_id = $original_mail->dispatcher_id; $o_handler_id = $original_mail->handler_id; if (!isset($info->mail_id)) { $uuid = Utils::create_uuid(); $replyMail->mail_id = base64_encode($uuid); } else { $replyMail->mail_id = base64_encode($info->mail_id); } $replyMail->subject = base64_encode($subject); $replyMail->body = base64_encode($body); $replyMail->toWhom = $toWhom; $replyMail->handler_id = $handler_id; if (isset($info->assessor_id)) { $replyMail->status = 1; $replyMail->assessor_id = $info->assessor_id; $replyMail->save(); } else { $replyMail->status = 0; $replyMail->save(); Utils::sendMail($replyMail->id); } $this->response->setJsonContent(['current_main' => ['id' => $replyMail->id, 'mail_id' => $replyMail->mail_id, 'subject' => base64_decode($replyMail->subject), 'body' => base64_decode($replyMail->body), 'reply_id' => $replyMail->reply_id, 'toWhom' => $replyMail->toWhom, 'reply_date' => $replyMail->replyDate, 'status' => $replyMail->status, 'handler_id' => $replyMail->handler_id, 'assessor_id' => $replyMail->assessor_id], 'original_mail' => ['id' => $o_id, 'mail_id' => $o_mail_id, 'subject' => $o_subject, 'body' => $o_body, 'fromAddress' => $o_fromAddress, 'receiveDate' => $o_receiveDate, 'tags' => $o_tags, 'status' => $o_status, 'deadline' => $o_deadline, 'dispatcher_id' => $o_dispatcher_id, 'handler_id' => $o_handler_id]]); } catch (Exception $e) { $this->response->setJsonContent(['message' => $e->getMessage()]); } $this->response->send(); return; }
$mail = $_GET['email']; // check mail is invalid if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) { header("42", true, 400); return; } // verify that the mail is in our database $db = Database::getInstance(); $stmt = $db->prepare("SELECT * FROM users WHERE mail=?"); $stmt->execute(array($mail)); if ($stmt->rowCount() == 0) { header("42", true, 404); return; } //get the user $stmt->setFetchMode(PDO::FETCH_INTO, new User(null)); $user = $stmt->fetch(); // change his password to a random string $pwd = Utils::random_string(16); $user->password = hash("whirlpool", $user->mail . $pwd); $user->update(); // send the mail Utils::sendMail(Utils::FORGOT_TYPE, $user, $pwd); } else { header("42", true, 400); return; } break; default: header("42", true, 400); }
public static function actualizarUsuarioContrasena($usu_id, $usu_nombres, $usu_apellidos, $usu_email, $usu_usuario, $usu_contrasena) { $conn = new Connect(); $utils = new Utils(); $option = "actContrasena"; $contrasena_hash = password_hash($usu_contrasena, PASSWORD_DEFAULT); $query = "UPDATE " . self::DB_TBL_USUARIO . " SET " . "usu_usuario=:usu_usuario, " . "usu_contrasena=:usu_contrasena " . " WHERE usu_id=:usu_id"; $consult = $conn->prepare($query); $consult->bindParam(":usu_id", $usu_id); $consult->bindParam(":usu_usuario", $usu_usuario); $consult->bindParam(":usu_contrasena", $contrasena_hash); if (!$consult->execute()) { echo "<script>alert('" . $query . "');</script>"; echo "<script>alert('No se actualizaron los datos, ocurrió un error!');</script>"; echo $consult->errorCode(); //echo "<script>location.href= '../vista/ges_usuarios.php' </script>"; } else { $mail_confirm = $utils->sendMail($usu_email, $usu_nombres, $usu_apellidos, $usu_usuario, $usu_contrasena, $option); echo "<script>alert('Datos actualizados correctamente');</script>"; echo "<script>location.href= '../vista/ges_usuarios.php' </script>"; } }
// Add or update ride $rideParams = array('SrcCityId' => $srcCityId, 'SrcLocation' => $srcLocation, 'DestCityId' => $destCityId, 'DestLocation' => $destLocation, 'TimeMorning' => $timeMorning, 'TimeEvening' => $timeEvening, 'Comment' => $comment, 'Notify' => $notify, 'Status' => $wantTo, 'Region' => $region); if ($isUpdateRide) { if ($db->updateRide($rideId, $srcCityId, $srcLocation, $destCityId, $destLocation, $timeMorning, $timeEvening, $comment, $wantTo, $notify, $region)) { GlobalMessage::setGlobalMessage(_("Ride successfully updated.")); } else { throw new Exception("Could not update ride"); } } else { $rideId = $db->addRide($srcCityId, $srcLocation, $destCityId, $destLocation, $timeMorning, $timeEvening, $contactId, $comment, $wantTo, $notify, $region); if (!$rideId) { throw new Exception("Could not add ride"); } AuthHandler::updateRegisteredRideStatus(true); $mailBody = MailHelper::render(VIEWS_PATH . '/registrationMail.php', array('contact' => $db->getContactById($contactId))); Utils::sendMail(Utils::buildEmail($email), $name, getConfiguration('mail.addr'), getConfiguration('mail.display'), getConfiguration('app.name') . ' Registration', $mailBody); } $db->commit(); // XXX: Should show interest even if it's update? if (!$isUpdateRide && getConfiguration('notify.immediate') == 1) { Service_ShowInterest::run($rideId); } echo json_encode(array('status' => 'ok', 'action' => $action)); } catch (PDOException $e) { $db->rollBack(); if ($e->getCode() == 23000) { // If this is a unique constraint problem - we want to display the correct message echo json_encode(array('status' => 'invalid', 'action' => $action, 'messages' => $messages)); } else { logException($e); echo json_encode(array('status' => 'err', 'action' => $action));