Beispiel #1
0
 $pid_contacts = pcntl_fork();
 if (!$pid_contacts) {
     /*
     	We are the fork!
     	* Validate configuration provided
     	* Establish a connection to the CardDAV backend
     	* Listen on the message queue for incomming contact lookup requests
     	* Pull contact name from CardDAV
     	* Save into cache (just an array) for next time.
     */
     $pid_child = getmypid();
     $log->info("[contacts] Launched CardDAV contacts/address book lookup worker fork");
     $log->debug("[child {$pid_child}] is contacts worker ");
     // verify installed modules
     if (!class_exists('XMLWriter')) {
         $log->error_fatal("PHP XMLWriter module must be installed to enable CardDAV functionality");
     }
     // verify configuration
     if (!$config["SMStoXMPP"]["contacts_url"]) {
         $log->error_fatal("[contacts] No contacts_url provided to query for CardDAV contacts.");
     }
     if (!$config["SMStoXMPP"]["contacts_store"]) {
         $log->error_fatal("[contacts] No contacts_store provided to store downloaded contacts to avoid large re-syncs");
     } else {
         if (!file_exists($config["SMStoXMPP"]["contacts_store"])) {
             // attempt to create the directory, we may just be missing the top level dir and have rights to create
             if (mkdir($config["SMStoXMPP"]["contacts_store"])) {
                 @chmod($config["SMStoXMPP"]["contacts_store"], 0770);
                 @chown($config["SMStoXMPP"]["contacts_store"], $config["SMStoXMPP"]["app_user"]);
                 @chgrp($config["SMStoXMPP"]["contacts_store"], $config["SMStoXMPP"]["app_group"]);
             } else {
Beispiel #2
0
$log->debug("[listener] Debug URL: {$_SERVER['REQUEST_URI']}");
/*
	Determine Device

	SMStoXMPP supports a number of different devices and types, we need to discover
	which one is providing information to this page and then fetch and process the
	information accordingly.
*/
$device = null;
if (isset($_GET["device"])) {
    $device = $_GET["device"];
}
// other ID fields for other gateways?
if (!$device) {
    header('HTTP/1.1 500 Internal Server Error');
    $log->error_fatal("[listener] No destination device was specified - make sure you're setting the ?device=myphone option.");
}
/*
	Launch gateway/device logic

	All the gateway/device logic is broken into include files that are only loaded into
	the particular worker fork which is using that gateway. If we can't load it for some
	reason we should fail with an error to all the apps.
*/
if (!$config[$device]) {
    header('HTTP/1.1 500 Internal Server Error');
    $log->error_fatal("[listener] An invalid destination device was requested - make sure you are using the correct ?device=example tag");
}
if (!$config[$device]["gw_type"]) {
    header('HTTP/1.1 500 Internal Server Error');
    $log->error_fatal("[listener] There is no gateway set! Unable to proceed!");