<?php

require "../includes/includeMeBlank.php";
$returnsAndTabs = array("&#09;", "&#10;", "&#11;", "&#13;", "&#12;", "\r", "\n", "\r\n", "\t");
$engOnCallRegularExpression = "<B>" . date('j') . "</B>.*?<TABLE.*?<TABLE.*?(ENG-ON CALL).*?(SECONDARY).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?(ENG-COMM).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</a>.*?(ENG_DBA).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?(INT-PRIM).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?(INT-SEC).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?(NE).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?(OPS  REMOTE MGR & BACKUPS).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?(OPS REMOTE MGR BACKUP).*?NEWWINDOW\\('(.*?)'.*?>(.*?)</A>.*?</TABLE>";
/* OPSEC STUFF .*?(OPSSEC).*?NEWWINDOW\('(.*?)'.*?>(.*?)</A>  */
$netId = $netID;
$password = passDecrypt($_GET['p']);
$cookieFilename = tempnam('/tmp', 'CURLCOOKIE');
$postFields = 'netid=' . urlencode($netId) . '&passpass='******'error:' . curl_error($curl) . '<br />';
}
//could check for the string 'You are now authorized' in $loginReply here if you want to make sure login was successful
curl_close($curl);
$curl = curl_init(getenv("ONCALLCALENDARURL"));
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookieFilename);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$pageData = curl_exec($curl);
curl_close($curl);
<?php

//sendEmail.php
require '../includes/includeme.php';
require 'html2text.php';
if (!isset($_POST['priority']) || !isset($_POST['type'])) {
    echo "Invalid Post Data";
    return;
}
$sysId = '';
$passy = '';
if (isset($_POST['sysId'])) {
    $sysId = $_POST['sysId'];
}
if (isset($_SESSION['servNowPass'])) {
    $passy = passDecrypt(urldecode($_SESSION['servNowPass']));
}
$ticketEntry = '';
$type = $_POST['type'];
if ($type == 'New') {
    newEntry($_POST);
    $ticketEntry = "Sent an Executive Notification regarding this issue: <br/><br/>NEW:" . $_POST['desc'];
} else {
    if ($type == 'Update') {
        updateEntry($_POST);
        $ticketEntry = "Sent an Executive Notification regarding this issue: <br/><br/>" . $_POST['update'];
    } else {
        if ($type == 'Resolve') {
            resolved($_POST);
            $ticketEntry = "Sent an Executive Notification with the resolution: <br/><br/>" . $_POST['update'];
        } else {
    /** We need to look at deprecating this code **/
    if ($smsCheck != 'unsent' && !isset($smsCheck['ticket'])) {
        try {
            $insertQuery = $db->prepare("INSERT INTO `executiveNotificationSMS`(`ticket`, `guid`) VALUES (:incident,:guid)");
            $insertQuery->execute(array(':incident' => $incident->number, ':guid' => newGuid()));
        } catch (PDOException $e) {
            exit("error in query");
        }
        if ($env == 2) {
            mail(getenv("HIGHPRIORITYTEXT"), 'P1 Alert', $incident->number . ": \n" . $incident->short_description, 'From: ' . getenv("OPSEMAILUSERNAME") . ' <' . getenv("OPSEMAILADDRESS") . '>' . "\r\n");
        }
    }
}
// DECRYPT PASSWORD
$passy = $_GET['p'];
$password = passDecrypt($passy);
// ESTABLISH CONNECTION
try {
    $soapurl = getenv("SERVICENOWSTAGEURL") . "/incident.do?WSDL";
    if ($env == 2) {
        $soapurl = getenv("SERVICENOWURL") . "/incident.do?WSDL";
    }
    $incidentClient = new SoapClient($soapurl, array('trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_MEMORY, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'login' => $netID, 'password' => $password));
    // GET HIGH PRIORITY TICKETS FROM THE PAST 12 HOURS
    $resultSet = $incidentClient->getRecords(array('__encoded_query' => 'priority<=2^active=true^ORclosed_at>javascript:gs.hoursAgo(12)'));
    // IF A HIGH PRIORITY TICKET EXISTS
    if (isset($resultSet->getRecordsResult)) {
        // CREATE TABLE AND HEADERS
        echo '<table id="hiPriTable" class="sortable"><tr><th>Pri.</th><th>Ticket #</th><th>Description</th><th>State</th></tr>';
        if (is_array($resultSet->getRecordsResult)) {
            foreach ($resultSet->getRecordsResult as $incident) {