function teamLeaderSelect($area, $selected)
{
    $url = getEnv('PERMISSIONSURL');
    // Ask the permission microservice which groups' users can be team leaders
    $groups = sendAuthenticatedRequest("GET", $url . "/permission/verbs/28e60394-f719-4225-85ad-fa542ab6a8df/lead");
    $teamLeads = array();
    // loop through groups and get users
    for ($i = 0; $i < count($groups["data"]); $i++) {
        $users = sendAuthenticatedRequest("GET", $url . "/groupMembers/" . $groups["data"][$i]["Guid"]);
        for ($j = 0; $j < count($users["data"]); $j++) {
            if (!in_array($users["data"][$j], $teamLeads)) {
                $teamLeads[] = $users["data"][$j];
            }
        }
    }
    $count = 0;
    for ($i = 0; $i < count($teamLeads); $i++) {
        if ($teamLeads[$i] == $selected) {
            echo "<option value='" . $teamLeads[$i] . "' selected>" . nameByNetId($teamLeads[$i]) . "</option>";
        } else {
            $count++;
            echo "<option value='" . $teamLeads[$i] . "'>" . nameByNetId($teamLeads[$i]) . "</option>";
        }
    }
    // If the selected team lead was not pulled add him/her
    if (count($teamLeads) == $count) {
        echo "<option value='" . $selected . "' selected>" . nameByNetId($selected) . "</option>";
    }
}
Ejemplo n.º 2
0
 public function __construct($arguments)
 {
     ini_set('display_errors', TRUE);
     error_reporting(E_ALL);
     $this->arguments = new Hymn_Arguments($arguments, $this->baseArgumentOptions);
     self::$fileName = $this->arguments->getOption('file');
     try {
         if (getEnv('HTTP_HOST')) {
             throw new RuntimeException('Access denied');
         }
         $action = $this->arguments->getArgument();
         if ($this->arguments->getOption('help')) {
             array_unshift($arguments, "help");
             $this->arguments = new Hymn_Arguments($arguments, $this->baseArgumentOptions);
         } else {
             if ($this->arguments->getOption('version')) {
                 array_unshift($arguments, "version");
                 $this->arguments = new Hymn_Arguments($arguments, $this->baseArgumentOptions);
             }
         }
         if (!in_array($action, array('help', 'create', 'version'))) {
             $this->readConfig();
             $this->loadLibraries();
             //				$this->setupDatabaseConnection();
         }
         $this->dispatch();
         //			self::out();
     } catch (Exception $e) {
         self::out("Error: " . $e->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**
  * @return \Codesmith\TsysTransItSDK\Connection
  */
 protected function client()
 {
     if ($this->client) {
         return $this->client;
     }
     return $this->client = new \Codesmith\TsysTransItSDK\Connection(['mid' => getEnv('mid'), 'userID' => getEnv('userID'), 'password' => getEnv('password'), 'transKey' => getEnv('transactionKey')]);
 }
 /**
  * Generates a new guid by calling out to the guid-generator micro-service, or
  *   if it can't be hit, generates one on it's own
  *
  * @return A new v4 guid
  */
 public function newGuid()
 {
     $url = getEnv('GUIDURL');
     if ($url == "") {
         $url = "http://tmt-guid.byu.edu";
     }
     // Start building curl options
     $curl_options = array();
     $curl_options[CURLOPT_URL] = $url . '/guid';
     $curl_options[CURLOPT_RETURNTRANSFER] = true;
     // Create handle and set options
     $curl_handle = curl_init();
     $success = curl_setopt_array($curl_handle, $curl_options);
     // Check failure to properly prepare curl handle
     if (!$success) {
         curl_close($curl_handle);
         return $this->newGuidLocal();
     }
     // Execute request
     $response = curl_exec($curl_handle);
     // Check for errors
     $http_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
     $err_num = curl_errno($curl_handle);
     // Failed to hit micro-service
     if ($http_code < 200 || $http_code >= 400 || $err_num != 0) {
         curl_close($curl_handle);
         return $this->newGuidLocal();
     }
     // Parse response and return
     $response = json_decode($response, false);
     $guid = $response->data;
     curl_close($curl_handle);
     return $guid;
 }
 public function __construct()
 {
     parent::__construct();
     $this->url = getEnv('GUIDURL');
     if ($this->url == "") {
         $this->url = "http://tmt-guid.byu.edu";
     }
 }
Ejemplo n.º 6
0
 public function getLogDir()
 {
     if (false !== getEnv('OPENSHIFT_LOG_DIR')) {
         return getEnv('OPENSHIFT_LOG_DIR');
     } else {
         return parent::getLogDir();
     }
 }
Ejemplo n.º 7
0
 public function loadEnvVariables()
 {
     self::loadDotenv();
     self::$host = getEnv('DB_HOST');
     self::$name = getEnv('DB_NAME');
     self::$username = getEnv('DB_USERNAME');
     self::$password = getEnv('DB_PASSWORD');
 }
Ejemplo n.º 8
0
 /** @test */
 public function should_generate_a_valid_transaction_key()
 {
     $res = $this->client()->generateKey(['mid' => getEnv('mid'), 'userID' => getEnv('userID'), 'password' => getEnv('password')]);
     $this->log(__METHOD__, $res);
     $this->assertArrayHasKey('status', $res);
     $this->assertEquals('PASS', $res['status']);
     $this->assertContains($res['responseCode'], array_keys($this->client()->approvedCodes));
 }
Ejemplo n.º 9
0
 public function __construct()
 {
     $bddCon = mysqli_connect(getEnv('DB_HOST'), getEnv('DB_USER'), getEnv('DB_PASSWORD'), getEnv('DB_NAME'));
     if (!$bddCon) {
         die("Nous sommes d&eacutesol&eacute : La connexion &agrave la base de donn&eacutees &agrave &eacutechou&eacutee ...");
     } else {
         $this->bdd = $bddCon;
     }
 }
Ejemplo n.º 10
0
 public function __construct()
 {
     $dbCon = mysqli_connect(getEnv("DB_HOST"), getEnv("DB_USERNAME"), getEnv("DB_PASSWORD"), getEnv("DB_NAME"));
     if (!$dbCon) {
         die("Nous sommes d&eacutesol&eacute : La connexion &agrave la base de donn&eacutees &agrave &eacutechou&eacutee ...");
     } else {
         $this->db = $dbCon;
     }
 }
Ejemplo n.º 11
0
function clientIPToHex($ip="") {
    $hex="";
    if($ip=="") $ip=getEnv("REMOTE_ADDR");
    $part=explode('.', $ip);
    for ($i=0; $i<=count($part)-1; $i++) {
        $hex.=substr("0".dechex($part[$i]),-2);
    }
    return $hex;
}
Ejemplo n.º 12
0
	static public function ___onCheckAccess( $env, $module, $context, $data = array() ){
		$allowUnsecuredLocalhost	= !TRUE;
		$isAuthorized	= (bool) $env->getRequest()->getHeader( 'Authorization', FALSE );
		$isLocalhost	= getEnv( 'HTTP_HOST' ) === "localhost";
		$isSecured		= $isAuthorized || ( $isLocalhost && $allowUnsecuredLocalhost );
		if( !$isSecured ){
			$message	= 'This Hydra instance is not secured by HTTP Basic Authentication. Please fix this!';
			$env->getMessenger()->noteFailure( $message );
		}
	}
Ejemplo n.º 13
0
 public static function loadEnvVariables()
 {
     if (!getenv('APP_ENV')) {
         self::loadDotenv();
     }
     self::$host = getEnv('DB_HOST');
     self::$name = getEnv('DB_NAME');
     self::$username = getEnv('DB_USERNAME');
     self::$password = getEnv('DB_PASSWORD');
     self::$connection = getEnv('DB_CONNECTION');
 }
 public function setUp()
 {
     parent::setUp();
     try {
         $dotenv = new Dotenv\Dotenv(dirname(__DIR__));
         $dotenv->load();
     } catch (Exception $e) {
         exit('Could not find a .env file.');
     }
     $this->faker = Faker\Factory::create();
     $this->object = new PaymentVault(['store-id' => getEnv('PROFIT_STARS_STORE_ID'), 'store-key' => getEnv('PROFIT_STARS_STORE_KEY'), 'entity-id' => getEnv('PROFIT_STARS_ENTITY_ID'), 'location-id' => getEnv('PROFIT_STARS_LOCATION_ID')]);
 }
Ejemplo n.º 15
0
function common_header($title = "")
{
    /* Can't open socket on sourceforge.net, I have to point the demo to my site */
    $host = getEnv("HTTP_HOST") == "canship.sourceforge.net" ? "http://www.allaboutweb.ca/sf/canship/" : "";
    ?>
<html>
<head>
	<title><?php 
    print $title ? "Canada Post Shipping Rate Calculator - A Free PHP Shipping Tool | {$title}" : "";
    ?>
</title>
	<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
	<link rel="stylesheet" type="text/css" href="main.css">
	<meta name="keywords" content="Shipping Calculator, Rate Calculator, Calculation, eParcel, Canada Post, PHP, Shipping Module, eBay, Merchant Tools, e-Commerce, Online Shopping, Online Transaction, Real time, Shipping Quote, XML, Web Service, Free Shipping, Shipping Quoter, Open Source, osCommerce, Shopping Cart, Vancouver, British Columbia, Shopping Basket, Package, Free Packaging, Width, Height, Weight, Length, International, Domestic,USA, Fedex, UPS,Expedited, Xpresspost,Priority Courier,Air Parcel, Surface, Sell Online, API, French, Shipping Rate ">
	<meta name="description" content="
	Canada Post Shipping Rate Calculator - A free PHP shipping calculator for all shipping purpose, including eBay merchants, ecommerce sites.
	This tool is developed by using API of Sell Online(tm) Shipping Module from Canada Post. Once you get a retail account from Canada Post,
	you can setup your shipping profile throught their backend.
	">
</head>

<body bgcolor="#ffffff"  marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" bottommargin="0" rightmargin="0">
<table border="0" cellpadding="10" cellspacing="0" bgcolor="#ff0000" width="100%">
<tr valign="middle">
	<td nowrap><img src="pics/canadapost.gif" width="178" height="60" alt="" border="0"></td>
	<td width="100%"><font color="#ffffff" class="pageTitle">Free PHP Canada Post Shipping Rate Calculator</font></td>
</tr>
</table>
<table border="0" cellpadding="5" cellspacing="0" width="100%" >
<tr>
	<td nowrap>[ <a href="index.php">Home</a> ]</td>
	<td nowrap>[ <a href="<?php 
    echo $host;
    ?>
ebay.demo.php">eBay Demo</a> ]</td>
	<td nowrap>[ <a href="<?php 
    echo $host;
    ?>
developer.demo.php">Developer Demo</a> ]</td>
	<td nowrap>[ <a href="merchant_tool.php">Merchant Tool</a> ]</td>
	<td nowrap>[ <a href="download.php">Download</a> ]</td>
	<td nowrap>[ <a href="index.php#contact">Contact</a> ]</td>
	<td width="100%">&nbsp;</td>
</tr>
</table>
<br><br>

<table cellpadding="0" cellspacing="0" border="0"  width="100%">
	<tr>
			<td >
<!-- --------------- Begin: Main Content -------------------------------- -->
<?php 
}
Ejemplo n.º 16
0
function compressed_output()
{
    $encoding = getEnv("HTTP_ACCEPT_ENCODING");
    $useragent = getEnv("HTTP_USER_AGENT");
    $method = trim(getEnv("REQUEST_METHOD"));
    $msie = preg_match("=msie=i", $useragent);
    $gzip = preg_match("=gzip=i", $encoding);
    if ($gzip && ($method != "POST" or !$msie)) {
        ob_start("ob_gzhandler");
    } else {
        ob_start();
    }
}
Ejemplo n.º 17
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     fwrite(STDERR, "# protoc-gen-php\n");
     $stdin = stream_get_contents(STDIN);
     $time = time();
     if (getEnv("CAPTURE")) {
         file_put_contents(sprintf("%s.input.bin", $time), $stdin);
     }
     $compiler = new \protocolbuffers\Compiler();
     $response = $compiler->compile($stdin);
     $result = $response->serializeToString();
     if (getEnv("CAPTURE")) {
         file_put_contents(sprintf("%s.output.bin", $time), $result);
     }
     fwrite(STDOUT, $result);
 }
Ejemplo n.º 18
0
 public function __construct()
 {
     $env = getEnv('DF56_ENV') ?: 'prod';
     switch ($env) {
         case 'dev':
             $this->_db = 'depanfernsender';
             $this->_host = 'localhost';
             $this->_user = '******';
             $this->_pwd = 'Alucard69';
             break;
         default:
             $this->_db = 'depanfernsender';
             $this->_host = 'depanfernsender.mysql.db';
             $this->_user = '******';
             $this->_pwd = 'Alucard69';
             break;
     }
 }
Ejemplo n.º 19
0
 /**
  * Init default localization
  */
 protected function initDefaultLocalization()
 {
     self::$localizations = $this->serviceLocator->get('config')['install_languages'];
     $this->serviceLocator->get('translator');
     $acceptLanguage = $this->intlLoaded ? Locale::acceptFromHttp(getEnv('HTTP_ACCEPT_LANGUAGE')) : null;
     $defaultLanguage = $acceptLanguage ? substr($acceptLanguage, 0, 2) : null;
     // setup locale
     self::$defaultLocalization = array_key_exists($defaultLanguage, self::$localizations) ? self::$localizations[$defaultLanguage] : current(self::$localizations);
     // init translator settings
     $translator = $this->serviceLocator->get('translator');
     $translator->setLocale(self::$defaultLocalization['locale']);
     // init default localization
     if ($this->intlLoaded) {
         Locale::setDefault(self::$defaultLocalization['locale']);
     }
     AbstractValidator::setDefaultTranslator($translator);
     self::$currentLocalization = self::$defaultLocalization;
 }
Ejemplo n.º 20
0
 /**
  * Loads all configuration parameters from a flat file
  *
  * <b>Note:</b> Default file path is set to {/usr/local}/etc/imscp/imscp.conf depending of distribution.
  *
  * @param string $pathFile Configuration file path
  */
 public function __construct($pathFile = null)
 {
     if (is_null($pathFile)) {
         if (getenv('IMSCP_CONF')) {
             $pathFile = getEnv('IMSCP_CONF');
         } else {
             switch (PHP_OS) {
                 case 'FreeBSD':
                 case 'OpenBSD':
                 case 'NetBSD':
                     $pathFile = '/usr/local/etc/imscp/imscp.conf';
                     break;
                 default:
                     $pathFile = '/etc/imscp/imscp.conf';
             }
         }
     }
     $this->_pathFile = $pathFile;
     $this->_parseFile();
 }
Ejemplo n.º 21
0
 public function phppackage()
 {
     $package = getEnv("PACKAGE");
     if ($package) {
         $result = $package;
     } else {
         if ($this->file->getOptions()->getJavaPackage()) {
             $result = $this->file->getOptions()->getJavaPackage();
         } else {
             $result = "";
             if ($this->file->getPackage()) {
                 if (!$result) {
                     $result .= ".";
                 }
                 $result .= $this->file->getPackage();
             }
         }
     }
     return $result;
 }
Ejemplo n.º 22
0
	public function __construct( $env = NULL ){
		$this->host	= getEnv( 'HTTP_HOST' );
		$this->root	= getEnv( 'DOCUMENT_ROOT' );
		$this->path	= dirname( getEnv( 'SCRIPT_NAME' ) ).'/';
		$this->uri	= $this->root.$this->path;
		$this->url	= 'http://'.$this->host.$this->path;

		$instances	= dirname( dirname( __FILE__ ) )."/config/instances.ini";
//		if( !file_exists( $instances ) )
//			die( "Missing config/instances.ini" );
/*		$file	= new File_INI_Editor( $instances, TRUE );
		if( $file->getProperty( 'uri', 'Setup' ) !== $this->uri ){
			$file->setProperty( 'uri', $this->uri, 'Setup' );
			$file->setProperty( 'url', $this->url, 'Setup' );
			$file->setProperty( 'path', $this->path, 'Setup' );
			$file->setProperty( 'host', $this->host, 'Setup' );
		}
*/
		parent::__construct( $env );
		$this->env->clock->profiler->tick( 'app' );
	}
 /**
  * Sends out an onsite notification regardless of user preferences
  * @param $type string A notification type GUID
  * @param $message string The message to send
  * @param $persons (object)array The netId, method, and email address of a specific person(s) to receive the message
  * 			usually the person to whom the message is referring (i.e. performance logs)
  */
 public function forceNotify($type, $message, $persons = null)
 {
     $typeAcc = $this->getAccessor("NotificationType");
     $notType = $typeAcc->get($type);
     // Get notifications url
     $url = getEnv('NOTIFICATIONSURL');
     // Make sure each recipient can recieve the notification
     // If not, remove them from the list and delete that preference
     $receivers = array();
     if ($persons !== null) {
         foreach ($persons as $person) {
             $receivers[] = (object) array("netId" => $person->netId, "method" => "onsite", "email" => $person->email);
         }
     } else {
         // Get recipients
         $empAcc = $this->getAccessor("Employee");
         $recipientArray = $empAcc->getByArea($this->user['area'], true, 1);
         foreach ($recipientArray as $recipient) {
             $receivers[] = (object) array("netId" => $recipient->netId, "method" => "onsite", "email" => $recipient->email);
         }
     }
     // Add notification
     $notAcc = $this->getAccessor("Notification");
     $notification = $notAcc->create(new \TMT\model\Notification((object) array("type" => $type, "area" => $this->user['areaGuid'], "message" => $message)));
     if (count($receivers) > 0) {
         // Send notification
         $this->sendAuthenticatedRequest("POST", "https://" . $url . "/notify", array("message" => $message, "receivers" => json_encode($receivers)));
         // Create notifications for each user
         $userNotAcc = $this->getAccessor("UserNotification");
         foreach ($receivers as $receiver) {
             $userNotAcc->add($receiver->netId, $notification->guid);
         }
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->url = getEnv('PERMISSIONSURL');
 }
Ejemplo n.º 25
0
 public function check_database_name()
 {
     if (isset($this->clobber) && $this->clobber) {
         return TRUE;
     }
     $db_name = strtolower($this->database_credentials['database']);
     $env = new \GR\ServerEnv($this->site_info->root_path);
     $env->setEnvVars($throw_exception = FALSE);
     if (strpos($db_name, 'prod') !== FALSE || getEnv('APP_ENV') === 'prod') {
         return FALSE;
     }
     if (strpos($db_name, 'stag') === FALSE && strpos($db_name, 'dev') === FALSE && strpos($db_name, 'local') === FALSE) {
         return 'CONFIRM';
     }
     return TRUE;
 }
Ejemplo n.º 26
0
 /**
  * 
  * Looks IP address up in ca_ips database. Returns true and loads information for the 
  * IP if the address is in the database, or false if the address is not in the database.
  *
  * @access public 
  * @param string IP address to authenticate. If it is omitted, the current client ip (taken from the REMOTE_ADDR environment variable) is used.
  * @return bool True if ip is in the database (also loads the ip record into the instance); false if ip does not exist in the database.
  */
 public function ipAuthenticate($ip = "")
 {
     if (!$ip) {
         $ip = getEnv("REMOTE_ADDR");
     }
     $ipp = explode(".", $ip);
     if (sizeof($ipp) == 4) {
         $chk = array();
         for ($i = 0; $i < 4; $i++) {
             if ($i == 3) {
                 $chk[] = "((ip4s <= " . $ipp[$i] . " AND ip4e >= " . $ipp[$i] . ") OR (ip4s IS NULL AND ip4e IS NULL))";
             } else {
                 $chk[] = "(ip" . ($i + 1) . " = " . $ipp[$i] . ")";
             }
         }
         $i = 4;
         $o_db = $this->getDb();
         while ($i > 0) {
             $sql = "\n\t\t\t\t\tSELECT wip.ip_id, wip.user_id \n\t\t\t\t\tFROM ca_ips wip\n\t\t\t\t\tINNER JOIN ca_users AS wu ON wu.user_id = wip.user_id\n\t\t\t\t\tWHERE \n\t\t\t\t";
             $sql .= join(" AND ", $chk);
             $qr_res = $o_db->query($sql);
             if ($qr_res->nextRow()) {
                 # got rule
                 return $qr_res->get("user_id");
             } else {
                 array_pop($chk);
                 if ($i < 4) {
                     array_unshift($chk, "(ip{$i} IS NULL)");
                 } else {
                     array_unshift($chk, "(ip4s IS NULL AND ip4e IS NULL)");
                 }
                 $i--;
             }
         }
     }
     return false;
 }
Ejemplo n.º 27
0
<?php

# app/config/params.php
if (getEnv("OPENSHIFT_APP_NAME") != '') {
    $container->setParameter('database_host', getEnv("OPENSHIFT_MYSQL_DB_HOST"));
    $container->setParameter('database_port', getEnv("OPENSHIFT_MYSQL_DB_PORT"));
    $container->setParameter('database_name', getEnv("OPENSHIFT_APP_NAME"));
    $container->setParameter('database_user', getEnv("OPENSHIFT_MYSQL_DB_USERNAME"));
    $container->setParameter('database_password', getEnv("OPENSHIFT_MYSQL_DB_PASSWORD"));
}
/**
 * Calls out to the new permission system to check
 *   if a user can be a superuser
 *
 * @param $netId string (optional) The netId to check for admin rights
 *   Defaults to the current user
 *
 * @return bool true if the user can be superuser, false otherwise
 */
function canBeSuperuser($netId = null)
{
    global $netID;
    if ($netId == null) {
        $netId = $netID;
    }
    $domain = getEnv('PERMISSIONSURL');
    $url = $domain . "/superuser/can/" . $netId;
    $response = sendAuthenticatedRequest("GET", $url);
    // Return response (true OR false) if request was successful, return false otherwise
    if ($response["status"] == "OK") {
        return filter_var($response["data"], FILTER_VALIDATE_BOOLEAN);
    } else {
        return false;
    }
}
Ejemplo n.º 29
0
 /**
  * Init default localization
  *
  * @return void
  */
 private function initDefaultLocalization()
 {
     try {
         // get all registered localizations
         $localization = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Localization\\Model\\LocalizationBase');
         // init default localization
         $this->localizations = $localization->getAllLocalizations();
         $acceptLanguage = Locale::acceptFromHttp(getEnv('HTTP_ACCEPT_LANGUAGE'));
         $defaultLanguage = !empty($this->userIdentity['language']) ? $this->userIdentity['language'] : ($acceptLanguage ? substr($acceptLanguage, 0, 2) : null);
         // setup locale
         $this->defaultLocalization = array_key_exists($defaultLanguage, $this->localizations) ? $this->localizations[$defaultLanguage] : current($this->localizations);
         // init translator settings
         $translator = $this->serviceLocator->get('translator');
         $translator->setLocale($this->defaultLocalization['locale']);
         // add a cache for translator
         $request = $this->serviceLocator->get('Request');
         if (!$request instanceof ConsoleRequest) {
             $translator->setCache($this->serviceLocator->get('Application\\Cache\\Dynamic'));
         }
         // init default localization
         Locale::setDefault($this->defaultLocalization['locale']);
         AbstractValidator::setDefaultTranslator($translator);
         LocalizationService::setCurrentLocalization($this->defaultLocalization);
         LocalizationService::setLocalizations($this->localizations);
     } catch (Exception $e) {
         ApplicationErrorLogger::log($e);
     }
 }
/**
 * Forces an onsite notification to all people in the area regardless of preferences, or to one person, if the fourth
 * parameter is filled.
 * @param $type string The notification type GUID
 * @param $message string The message to send
 * @param $persons (object)array The NetId, method, and email addres of a specific person(s) to receive the message, 
 * 			usually the person to whom the message is referring (i.e. performance logs)
 */
function forceNotify($type, $message, $persons = null)
{
    global $area, $areaGuid, $db;
    // Get notifications url
    $url = getEnv('NOTIFICATIONSURL');
    $receivers = array();
    if ($persons !== NULL) {
        foreach ($persons as $person) {
            $receivers[] = (object) array("netId" => $person->netId, "method" => "onsite", "email" => $person->email);
        }
    } else {
        // Get recipients
        try {
            $stmt = $db->prepare("SELECT netID, email FROM employee WHERE area=:area AND active=1");
            $stmt->execute(array(':area' => $area));
        } catch (PDOException $e) {
            exit("error in query");
        }
        while ($recipient = $stmt->fetch()) {
            $receivers[] = (object) array("netId" => $recipient->netID, "method" => "onsite", "email" => $recipient->email);
        }
    }
    $guid = newGuid();
    try {
        $stmt3 = $db->prepare("INSERT INTO notifications (message, type, area, guid) VALUES (:message, :type, :area, :guid)");
        $stmt3->execute(array(":message" => $message, ":type" => $type, ":area" => $areaGuid, ":guid" => $guid));
    } catch (PDOException $e) {
        exit("error in query");
    }
    if (count($receivers) > 0) {
        sendAuthenticatedRequest("POST", "https://" . $url . "/notify", array("message" => $message, "receivers" => json_encode($receivers)));
        foreach ($receivers as $receiver) {
            try {
                $stmt4 = $db->prepare("INSERT INTO userNotifications (netId, notificationGuid) VALUES (:netId, :guid)");
                $stmt4->execute(array(":netId" => $receiver->netId, ":guid" => $guid));
            } catch (PDOException $e) {
            }
            // catch exceptions if they arise, but try to add as many as possible
        }
    }
}