/**
  * Sends a single sms
  *
  * @return mixed
  */
 public function sendSms($message, $number)
 {
     try {
         $smsghMessage = new \Message();
         $smsghMessage->setContent($message);
         $smsghMessage->setTo($number);
         $smsghMessage->setFrom($this->getSenderName());
         $smsghMessage->setRegisteredDelivery(true);
         $messageResponse = $this->getApiMessage()->sendMessage($smsghMessage);
         if ($messageResponse instanceof \MessageResponse) {
             echo $messageResponse->getStatus();
         } elseif ($messageResponse instanceof \HttpResponse) {
             echo "\nServer Response Status : " . $messageResponse->getStatus();
         }
     } catch (\Exception $ex) {
         dd($ex);
     }
 }
		$to = array(
			'Ken Bergquist' => '*****@*****.**',
			'Lasheaka McClellan' => '*****@*****.**',
			'Tyre Johnson' => '*****@*****.**',
			'Dona-Marie Mintz' => '*****@*****.**',
			'Nicholas Slater' => '*****@*****.**'
		);
		//$to = array('Ken Bergquist' => '*****@*****.**');
		$from = array('Ken Bergquist' => '*****@*****.**');
		$subject = "HCV-TARGET 2 Site Source Upload Notification";
		$email = new Message ();
		foreach ($from as $name => $address) {
			$email->setFrom($address);
			$email->setFromName($name);
		}
		$email->setSubject($subject);
		$email->setBody($html);
		foreach ($to as $name => $address) {
			$email->setTo($address);
			$email->setToName($name);
			if (!$debug) {
				if (!$email->send()) {
					error_log("ERROR: Failed to send Site Source Upload digest");
				}
			}
		}
		d($email);
	} else {
		error_log("NOTICE: No site source uploads were available to be digested");
	}
}
Exemplo n.º 3
0
        $errMsg = 'Please complete the \'To\' and \'Subject\' fields.';
    }
}
if (isset($_GET['action'])) {
    $action = $_GET['action'];
} else {
    $action = 'new';
}
if (isset($_SESSION['currentMessage'])) {
    $message = unserialize($_SESSION['currentMessage']);
} else {
    $message = new Message();
}
switch ($action) {
    case 'reply':
        $message->setTo($message->getFrom(true));
        $message->setCc('');
        break;
    case 'replyall':
        $message->setTo($message->getFrom(true));
        break;
    case 'forward':
        $message->setTo('');
        $message->setCc('');
        break;
}
header("Content-Type: application/x-blueprint+xml");
header("Cache-Control: no-cache");
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<page style="list">
Exemplo n.º 4
0
	/**
	 * @param $userid
	 * @param $headers
	 * @param $table_csv
	 * @param array $fields
	 * @param $parent_chkd_flds
	 * @param $export_file_name
	 * @param $debug
	 * @param null $comment
	 * @param array $to
	 */
	public static function do_sendit($userid, $headers, $table_csv, $fields = array(), $parent_chkd_flds, $export_file_name, $comment = null, $to = array(), $debug)
	{
		global $project_id, $user_rights, $app_title, $lang, $redcap_version; // we could use the global $userid, but we need control of it for setting the user as [CRON], so this is passed in args.
		$return_val = false;
		$export_type = 0; // this puts all files generated here in the Data Export category in the File Repository
		$today = date("Y-m-d_Hi"); //get today for filename
		$projTitleShort = substr(str_replace(" ", "", ucwords(preg_replace("/[^a-zA-Z0-9 ]/", "", html_entity_decode($app_title, ENT_QUOTES)))), 0, 20); // shortened project title for filename
		$originalFilename = $projTitleShort . "_" . $export_file_name . "_DATA_" . $today . ".csv"; // name the file for storage
		$today = date("Y-m-d-H-i-s"); // get today for comment, subsequent processing as needed
		$docs_comment_WH = $export_type ? "Data export file created by $userid on $today" : fix_case($export_file_name) . " file created by $userid on $today. $comment"; // unused, but I keep it around just in case
		/**
		 * setup vars for value export logging
		 */
		$chkd_fields = implode(',', $fields);
		/**
		 * turn on/off exporting per user rights
		 */
		if (($user_rights['data_export_tool'] || $userid == '[CRON]') && !$debug) {
			$table_csv = addBOMtoUTF8($headers . $table_csv);
			/**
			 * Store the file in the file system and log the activity, handle if error
			 */
			if (!DataExport::storeExportFile($originalFilename, $table_csv, true)) {
				log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Data Export Failed");
			} else {
				log_event("", "redcap_data", "data_export", "", str_replace("'", "", $chkd_fields) . (($parent_chkd_flds == "") ? "" : ", " . str_replace("'", "", $parent_chkd_flds)), "Export data for SendIt");
				/**
				 * email file link and download password in two separate emails via REDCap SendIt
				 */
				$file_info_sql = db_query("SELECT docs_id, docs_size, docs_type FROM redcap_docs WHERE project_id = $project_id ORDER BY docs_id DESC LIMIT 1"); // get required info about the file we just created
				if ($file_info_sql) {
					$docs_id = db_result($file_info_sql, 0, 'docs_id');
					$docs_size = db_result($file_info_sql, 0, 'docs_size');
					$docs_type = db_result($file_info_sql, 0, 'docs_type');
				}
				$yourName = 'PRIORITIZE REDCap';
				$expireDays = 3; // set the SendIt to expire in this many days
				/**
				 * $file_location:
				 * 1 = ephemeral, will be deleted on $expireDate
				 * 2 = export file, visible only to rights in file repository
				 */
				$file_location = 2;
				$send = 1; // always send download confirmation
				$expireDate = date('Y-m-d H:i:s', strtotime("+$expireDays days"));
				$expireYear = substr($expireDate, 0, 4);
				$expireMonth = substr($expireDate, 5, 2);
				$expireDay = substr($expireDate, 8, 2);
				$expireHour = substr($expireDate, 11, 2);
				$expireMin = substr($expireDate, 14, 2);

				// Add entry to sendit_docs table
				$query = "INSERT INTO redcap_sendit_docs (doc_name, doc_orig_name, doc_type, doc_size, send_confirmation, expire_date, username,
					location, docs_id, date_added)
				  VALUES ('$originalFilename', '" . prep($originalFilename) . "', '$docs_type', '$docs_size', $send, '$expireDate', '" . prep($userid) . "',
					$file_location, $docs_id, '" . NOW . "')";
				db_query($query);
				$newId = db_insert_id();

				$logDescrip = "Send file from file repository (Send-It)";
				log_event($query, "redcap_sendit_docs", "MANAGE", $newId, "document_id = $newId", $logDescrip);

				// Set email subject
				$subject = "[PRIORITIZE] " . $comment;
				$subject = html_entity_decode($subject, ENT_QUOTES);

				// Set email From address
				$from = array('Ken Bergquist' => '*****@*****.**');

				// Begin set up of email to send to recipients
				$email = new Message();
				foreach ($from as $name => $address) {
					$email->setFrom($address);
					$email->setFromName($name);
				}
				$email->setSubject($subject);

				// Loop through each recipient and send email
				foreach ($to as $name => $address) {
					// If a non-blank email address
					if (trim($address) != '') {
						// create key for unique url
						$key = strtoupper(substr(uniqid(md5(mt_rand())), 0, 25));

						// create password
						$pwd = generateRandomHash(8, false, true);

						$query = "INSERT INTO redcap_sendit_recipients (email_address, sent_confirmation, download_date, download_count, document_id, guid, pwd)
						  VALUES ('$address', 0, NULL, 0, $newId, '$key', '" . md5($pwd) . "')";
						$q = db_query($query);

						// Download URL
						$url = APP_PATH_WEBROOT_FULL . 'redcap_v' . $redcap_version . '/SendIt/download.php?' . $key;

						// Message from sender
						$note = "$comment for $today";
						// Get YMD timestamp of the file's expiration time
						$expireTimestamp = date('Y-m-d H:i:s', mktime($expireHour, $expireMin, 0, $expireMonth, $expireDay, $expireYear));

						// Email body
						$body = "<html><body style=\"font-family:Arial;font-size:10pt;\">
							$yourName {$lang['sendit_51']} \"$originalFilename\" {$lang['sendit_52']} " .
							date('l', mktime($expireHour, $expireMin, 0, $expireMonth, $expireDay, $expireYear)) . ",
							" . DateTimeRC::format_ts_from_ymd($expireTimestamp) . "{$lang['period']}
							{$lang['sendit_53']}<br><br>
							{$lang['sendit_54']}<br>
							<a href=\"$url\">$url</a><br><br>
							$note
							<br>-----------------------------------------------<br>
							{$lang['sendit_55']} " . CONSORTIUM_WEBSITE_DOMAIN . ".
							</body></html>";

						// Construct email and send
						$email->setTo($address);
						$email->setToName($name);
						$email->setBody($body);
						if ($email->send()) {
							// Now send follow-up email containing password
							$bodypass = "******"font-family:Arial;font-size:10pt;\">
								{$lang['sendit_50']}<br><br>
								$pwd<br><br>
								</body></html>";
							$email->setSubject("Re: $subject");
							$email->setBody($bodypass);
							sleep(2); // Hold for a second so that second email somehow doesn't reach the user first
							$email->send();
						} else {
							error_log("ERROR: pid=$project_id: Email to $name <$address> NOT SENT");
						}

					}
				}
			}
			unset($table_csv);
		}
	}
Exemplo n.º 5
0
<?php

// Let us test the SDK
require './Smsgh/Api.php';
$auth = new BasicAuth("user123", "password123");
// instance of ApiHost
$apiHost = new ApiHost($auth);
// instance of AccountApi
$accountApi = new AccountApi($apiHost);
// Get the account profile
// Let us try to send some message
$messagingApi = new MessagingApi($apiHost);
try {
    // Send a quick message
    $messageResponse = $messagingApi->sendQuickMessage("Husby", "+2332432191768", "I love you dearly Honey. See you in the evening...");
    $mesg = new Message();
    $mesg->setContent("I will eat the beautiful Food you have");
    $mesg->setTo("+233244219234");
    $mesg->setFrom("+233204567867");
    $mesg->setRegisteredDelivery(true);
    // Let us say we want to send the message 3 days from today
    $mesg->setTime(date('Y-m-d H:i:s', strtotime('+1 week')));
    $messageResponse = $messagingApi->sendMessage($mesg);
    if ($messageResponse instanceof MessageResponse) {
        echo $messageResponse->getStatus();
    } elseif ($messageResponse instanceof HttpResponse) {
        echo "\nServer Response Status : " . $messageResponse->getStatus();
    }
} catch (Exception $ex) {
    echo $ex->getTraceAsString();
}
Exemplo n.º 6
0
 public function notify($title)
 {
     global $redcap_version;
     $dark = "#800000";
     //#1a74ba  1a74ba
     $light = "#FFE1E1";
     //#ebf6f3
     $border = "#800000";
     //FF0000";	//#a6d1ed	#3182b9
     // Run notification
     $url = APP_PATH_WEBROOT_FULL . "redcap_v{$redcap_version}/" . "DataEntry/index.php?pid={$this->project_id}&page={$this->instrument}&id={$this->record}&event_id={$this->event_id}";
     // Message (email html painfully copied from box.net notification email)
     $msg = RCView::table(array('cellpadding' => '0', 'cellspacing' => '0', 'border' => '0', 'style' => 'border:1px solid #bbb; font:normal 12px Arial;color:#666'), RCView::tr(array(), RCView::td(array('style' => 'padding:13px'), RCView::table(array('style' => 'font:normal 15px Arial'), RCView::tr(array(), RCView::td(array('style' => 'font-size:18px;color:#000;border-bottom:1px solid #bbb'), RCView::span(array('style' => 'color:black'), RCVieW::a(array('style' => 'color:black'), 'REDCap AutoNotification Alert')) . RCView::br())) . RCView::tr(array(), RCView::td(array('style' => 'padding:10px 0'), RCView::table(array('style' => 'font:normal 12px Arial;color:#666'), RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Title") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), "<b>{$title}</b>")))) . RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Project") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), REDCap::getProjectTitle())))) . ($this->redcap_event_name ? RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Event") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), "{$this->redcap_event_name}")))) : '') . RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Instrument") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), $this->instrument)))) . RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Record") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), $this->record)))) . RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Date/Time") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), date('Y-m-d H:i:s'))))) . RCView::tr(array(), RCView::td(array('style' => 'text-align:right'), "Message") . RCView::td(array('style' => 'padding-left:10px;color:#000'), RCView::span(array('style' => 'color:black'), RCView::a(array('style' => 'color:black'), $this->config['message']))))))) . RCView::tr(array(), RCView::td(array('style' => "border:1px solid {$border};background-color:{$light};padding:20px"), RCView::table(array('style' => 'font:normal 12px Arial', 'cellpadding' => '0', 'cellspacing' => '0'), RCView::tr(array('style' => 'vertical-align:middle'), RCView::td(array(), RCView::table(array('cellpadding' => '0', 'cellspacing' => '0'), RCView::tr(array(), RCView::td(array('style' => "border:1px solid #600000;background-color:{$dark};padding:8px;font:bold 12px Arial"), RCView::a(array('class' => 'hide', 'style' => 'color:#fff;white-space:nowrap;text-decoration:none', 'href' => $url), "View Record"))))) . RCView::td(array('style' => 'padding-left:15px'), "To view this record, visit this link:" . RCView::br() . RCView::a(array('style' => "color:{$dark}", 'href' => $url), $url))))))))));
     $msg = "<HTML><head></head><body>" . $msg . "</body></html>";
     // Determine number of emails to send
     // Prepare message
     $email = new Message();
     $email->setTo($this->config['to']);
     $email->setFrom($this->config['from']);
     $email->setSubject($this->config['subject']);
     $email->setBody($msg);
     // Send Email
     if (!$email->send()) {
         error_log('Error sending mail: ' . $email->getSendError() . ' with ' . json_encode($email));
         exit;
     }
     //		error_log ('Email sent');
     // Add Log Entry
     $data_values = "title,{$title}\nrecord,{$this->record}\nevent,{$this->redcap_event_name}";
     REDCap::logEvent('AutoNotify Alert', $data_values);
 }
Exemplo n.º 7
0
require 'Smsgh/Api.php';
//$auth = new BasicAuth("yralkzfn", "znbzlsho");
$auth = new BasicAuth("obxffxqt", "wmqimxzt");
// instance of ApiHost
$apiHost = new ApiHost($auth);
// instance of AccountApi
$accountApi = new AccountApi($apiHost);
// Get the account profile
// Let us try to send some message
$messagingApi = new MessagingApi($apiHost);
try {
    // Send a quick message
    //$messageResponse = $messagingApi->sendQuickMessage("Husby", "+2332432191768", "I love you dearly Honey. See you in the evening...");
    $mesg = new Message();
    $mesg->setContent($newMessage);
    $mesg->setTo($customer);
    $mesg->setFrom("+233543344100");
    $mesg->setRegisteredDelivery(true);
    // Let us say we want to send the message 3 days from today
    //$mesg->setTime(date('Y-m-d H:i:s', strtotime('+1 week')));
    $messageResponse = $messagingApi->sendMessage($mesg);
    if ($messageResponse instanceof MessageResponse) {
        echo '{"result": 1, "message": "' . $messageResponse->getStatus() . '"}';
        return;
        //echo $messageResponse->getStatus();
    } elseif ($messageResponse instanceof HttpResponse) {
        echo '{"result": 0, "message": "' . $messageResponse->getStatus() . '"}';
        return;
        // echo "\nServer Response Status : " . $messageResponse->getStatus();
    }
} catch (Exception $ex) {
Exemplo n.º 8
0
<?php

require_once 'autoload.php';
include 'checksession.php';
if (!checksession()) {
    header('Location: login.php');
}
$au = new Approval();
$commallowed = array('2', '17');
if (isset($_SESSION['operatorid'])) {
    $au->setValue('operatorid', $_SESSION['operatorid']);
    $me = new Message();
    $me->setTo($_SESSION['operatorid']);
    $nm = $me->getMessagecount();
} else {
    checksession('index.php');
}
echo <<<_END



<!DOCTYPE HTML>
    <head>
        <meta charset="utf-8" />
        <title>Divya Engineering ERP</title>
<link href="js/css/sm-core-css.css" rel="stylesheet" type="text/css" />
<link href="js/css/sm-blue/sm-blue.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-2.1.4.min.js" ></script>
<script src="js/jquery.smartmenus.js" ></script>

<script>
Exemplo n.º 9
0
    $pageNumber = $_GET['page'];
} else {
    $pageNumber = 0;
}
$total_messages = imap_num_msg($mbox);
$charset = 'UTF-8';
$structure = imap_fetchstructure($mbox, $msg_number);
foreach ($structure->parameters as $param) {
    if ($param->attribute == 'charset') {
        $charset = $param->value;
        break;
    }
}
$header = imap_headerinfo($mbox, $msg_number);
$message->setFrom($header->fromaddress);
$message->setTo($header->toaddress);
$message->setCc($header->ccaddress);
$message->setSubject($header->subject);
$message->setBody(imap_fetchbody($mbox, $msg_number, '1'));
// '1' is the text/plain version of the body in a multipart message
$message->setDate($header->date);
$_SESSION['currentMessage'] = serialize($message);
if ($msg_number > 1) {
    $prev_message = imap_uid($mbox, $msg_number - 1);
} else {
    $prev_message = null;
}
if ($msg_number < $total_messages) {
    $next_message = imap_uid($mbox, $msg_number + 1);
} else {
    $next_message = null;
Exemplo n.º 10
0
 public function sendMessage()
 {
     if (isset($_POST['send-msg'])) {
         $to = $_POST['msgTo'];
         $msg = new Message();
         $msg->setTo($to);
         $currentUser = wp_get_current_user();
         $msg->setFrom($currentUser->ID);
         $msg->setSubject($_POST['subject']);
         $msg->setMessage($_POST['message']);
         $msg->send();
         $this->redirect(admin_url('admin.php?page=vmp-msgs'));
     }
 }