Beispiel #1
1
 public static function toXml($data, $rootNodeName = 'data', $xml = null)
 {
     // turn off compatibility mode as simple xml throws a wobbly if you don't.
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if ($xml == null) {
         $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
     }
     // loop through the data passed in.
     foreach ($data as $key => $value) {
         // no numeric keys in our xml please!
         if (is_numeric($key)) {
             // make string key...
             $key = "child_" . (string) $key;
         }
         // replace anything not alpha numeric
         $key = preg_replace('/[^a-z]/i', '', $key);
         // if there is another array found recrusively call this function
         if (is_array($value)) {
             $node = $xml->addChild($key);
             // recrusive call.
             ArrayToXML::toXml($value, $rootNodeName, $node);
         } else {
             // add single node.
             $value = htmlentities($value);
             $xml->addChild($key, $value);
         }
     }
     // pass back as string. or simple xml object if you want!
     return $xml->asXML();
 }
Beispiel #2
0
 /**
  * Convert an XML document to a multi dimensional array
  * Pass in an XML document (or SimpleXMLElement object) and this recrusively loops through and builds a representative array
  *
  * @param string $xml - XML document - can optionally be a SimpleXMLElement object
  * @return array ARRAY
  */
 public static function toArray($xml)
 {
     if (is_string($xml)) {
         $xml = new SimpleXMLElement($xml);
     }
     $children = $xml->children();
     if (!$children) {
         return (string) $xml;
     }
     $arr = array();
     foreach ($children as $key => $node) {
         $node = ArrayToXML::toArray($node);
         // support for 'anon' non-associative arrays
         if ($key == 'anon') {
             $key = count($arr);
         }
         // if the node is already set, put it into an array
         if (isset($arr[$key])) {
             if (!is_array($arr[$key]) || !isset($arr[$key][0])) {
                 $arr[$key] = array($arr[$key]);
             }
             $arr[$key][] = $node;
         } else {
             $arr[$key] = $node;
         }
     }
     return $arr;
 }
 public function format(array $result, $pretty = false)
 {
     //debug_op($result, true);
     $xml = ArrayToXML::toXML($result, Response::XML_ROOT);
     if ($pretty) {
         $doc = new \DOMDocument('1.0');
         $doc->preserveWhiteSpace = false;
         $doc->loadXML($xml);
         $doc->formatOutput = true;
         return $doc->saveXML();
     } else {
         return $xml;
     }
 }
Beispiel #4
0
 public function showArray($array)
 {
     if ($this->mFormat != 'xml') {
         $array = $this->removeElementKey('_element', $array);
     }
     switch ($this->mFormat) {
         case 'json':
             $prefix = $suffix = "";
             if (!is_null($this->mCallback)) {
                 $prefix = preg_replace("/[^][.\\'\\\"_A-Za-z0-9]/", "", $this->mCallback) . "(";
                 $suffix = ")";
             }
             $this->outputText($prefix . json_encode($array) . $suffix);
             break;
         case 'php':
             $this->outputText(serialize($array));
             break;
         case 'xml':
             $this->outputText('<?xml version="1.0"?>');
             $this->outputText(ArrayToXML::recXmlPrint('api', $array, $this->mIsHtml ? -2 : null));
             break;
         case 'yaml':
             require_once '/data/project/xtools/yaml.php';
             $this->outputText(Spyc::YAMLDump($array));
             break;
         case 'txt':
             $this->outputText(print_r($array, true));
             break;
         case 'dbg':
             $this->outputText(var_export($array, true));
             break;
     }
     if ($this->mIsHtml) {
         echo "\n</pre>";
     }
 }
Beispiel #5
0
 /**
  * Private method: make the request
  *
  */
 private function _request($data, $replace = array(), $attribs = array())
 {
     if (is_array($data)) {
         $atx = new ArrayToXML($data, $replace, $attribs);
         $xml = $atx->getXML();
     } else {
         //assume raw xml otherwise, we need this because we have to build
         //  our own sometimes because assoc arrays don't support same name keys
         $xml = $data;
     }
     $fields = array("jsessionid" => isset($this->_jsessionid) ? $this->_jsessionid : '', "xml" => $xml);
     $response = $this->_httpPost($fields);
     if ($response) {
         $arr = ArrayToXML::xml2array($response);
         if (isset($arr["Envelope"]["Body"]["RESULT"]["SUCCESS"])) {
             return $arr;
         } else {
             //throw new \Exception("HTTP Error: Invalid data from the server");
         }
     } else {
         //throw new \Exception("HTTP request failed");
     }
 }
Beispiel #6
0
 private function _request($data)
 {
     $atx = new ArrayToXML($data, array(), array());
     $fields = array("jsessionid" => isset($this->_jsessionid) ? $this->_jsessionid : '', "xml" => $atx->getXML());
     $response = $this->_httpPost($fields);
     if ($response) {
         $arr = xml2array($response);
         if (isset($arr["Envelope"]["Body"]["RESULT"]["SUCCESS"])) {
             return $arr;
         } else {
             throw new Exception("HTTP Error: Invalid data from the server");
         }
     } else {
         throw new Exception("HTTP request failed");
     }
 }
Beispiel #7
0
 /**
  * The main function for converting to an XML document.
  * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
  *
  * @param array $data
  * @param string $rootNodeName - what you want the root node to be - defaultsto data.
  * @param SimpleXMLElement $xml - should only be used recursively
  * @return string XML
  */
 public static function toXml($data, $rootNodeName = 'data', &$xml = null)
 {
     // turn off compatibility mode as simple xml throws a wobbly if you don't.
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if (is_null($xml)) {
         $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
     }
     // loop through the data passed in.
     foreach ($data as $key => $value) {
         // if numeric key, assume array of rootNodeName elements
         if (is_numeric($key)) {
             $key = $rootNodeName;
         }
         // delete any char not allowed in XML element names
         $key = preg_replace('/[^a-z0-9\\-\\_\\.\\:]/i', '', $key);
         // if there is another array found recrusively call this function
         if (is_array($value)) {
             // create a new node unless this is an array of elements
             $node = ArrayToXML::isAssoc($value) ? $xml->addChild($key) : $xml;
             // recrusive call - pass $key as the new rootNodeName
             ArrayToXML::toXml($value, $key, $node);
         } else {
             // add single node.
             $value = htmlentities($value);
             $xml->addChild($key, $value);
         }
     }
     // pass back as string. or simple xml object if you want!
     return $xml->asXML();
 }
$active = $_POST['active'];
if ($userId = validateToken($token)) {
    $username = getUsername($userId);
    $acl_allow = acl_check('patients', 'notes', $username);
    if ($acl_allow) {
        $noteIds_array = explode(',', $noteIds);
        foreach ($noteIds_array as $noteId) {
            switch ($active) {
                case 1:
                    reappearPnote($noteId);
                    break;
                case 0:
                    disappearPnote($noteId);
                    break;
            }
        }
        $xml_array['status'] = 0;
        $xml_array['reason'] = 'The Patient notes has been updated';
    } else {
        $xml_string .= "<status>-2</status>\n";
        $xml_string .= "<reason>You are not Authorized to perform this action</reason>\n";
    }
} else {
    $xml_array['status'] = -2;
    $xml_array['reason'] = 'Invalid Token';
}
$xml = ArrayToXML::toXml($xml_array, 'PatientNotes');
echo $xml;
?>

Beispiel #9
0
                $video_name = date('Y-m-d_H-i-s') . "." . $ext;
                file_put_contents($path . "/videos/" . $video_name, base64_decode($data));
                $notes = $sitesUrl . "{$site}/documents/userdata/videos/" . $video_name;
                break;
        }
        $select_query = "SELECT *  FROM `list_options` \n        WHERE `list_id` LIKE 'lists' AND `option_id` LIKE '" . add_escape_custom($list_id) . "' AND `title` LIKE '" . add_escape_custom($list_id) . "'";
        $result_select = sqlQuery($select_query);
        $result1 = true;
        if (!$result_select) {
            $insert_list = "INSERT INTO list_options ( list_id, option_id, title, seq, is_default, option_value ) \n                            VALUES ( 'lists','" . add_escape_custom($list_id) . "','" . add_escape_custom($list_id) . "', '0','1', '0')";
            $result1 = sqlStatement($insert_list);
        }
        $strQuery = "INSERT INTO `list_options`(`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`) \n                        VALUES (\n                        '" . add_escape_custom($list_id) . "',\n                        '" . add_escape_custom($option_id) . "',\n                        '" . add_escape_custom($title) . "',\n                        '" . add_escape_custom($seq) . "',\n                        '" . add_escape_custom($is_default) . "',\n                        '" . add_escape_custom($userId) . "',\n                        '" . add_escape_custom($mapping) . "',\n                        '" . add_escape_custom($notes) . "')";
        $result = sqlStatement($strQuery);
        if ($result) {
            $xml_array['status'] = "0";
            $xml_array['reason'] = "The Resource has been added";
        } else {
            $xml_array['status'] = "-1";
            $xml_array['reason'] = "ERROR: Sorry, there was an error processing your data. Please re-submit the information again.";
        }
    } else {
        $xml_array['status'] = -2;
        $xml_array['reason'] = 'You are not Authorized to perform this action';
    }
} else {
    $xml_array['status'] = "-2";
    $xml_array['reason'] = 'Invalid Token';
}
$xml = ArrayToXML::toXml($xml_array, 'Resource');
echo $xml;
Beispiel #10
0
function Send($data)
{
    global $pgmstart, $wgXMLRoot;
    if (!is_array($data)) {
        $data = array("result" => $data);
    }
    if (!isset($data["err"])) {
        $data["err"]["id"] = 0;
        $data["err"]["msg"] = "";
    }
    $data["runtime"] = microtime(true) - $pgmstart;
    if (isset($_ENV["APIExpires"])) {
        header("Pragma: public");
        header("Cache-Control: maxage=" . ($_ENV["APIExpires"] + 0));
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $_ENV["APIExpires"]) . ' GMT');
    }
    switch (strtolower(isset($_REQUEST["format"]) ? $_REQUEST["format"] : "")) {
        case "successcode":
            header("Content-Type: text/plain");
            if ($data["err"]["id"] + 0 == 0) {
                @header($_SERVER["SERVER_PROTOCOL"] . " 200 Ok");
            } else {
                header($_SERVER["SERVER_PROTOCOL"] . " 400 " . $data["err"]["msg"]);
            }
            echo $data["err"]["id"] + 0;
            break;
        case "json":
            header("Content-Type: application/json");
            $data["Request"] = $_REQUEST;
            echo json_encode($data);
            break;
        case "jsonac":
            header("Content-Type: application/json");
            echo json_encode($data["result"]);
            break;
        case "json-in-script":
            header("Content-Type: text/javascript");
            $data["Request"] = $_REQUEST;
            if ($_REQUEST["callback"] . "" == "") {
                $_REQUEST["callback"] = str_replace(array("/"), "_", $_REQUEST["action"]);
            }
            echo strip_tags($_REQUEST["callback"]) . "(" . json_encode($data) . ");";
            break;
        case "php":
            $data["Request"] = $_REQUEST;
            echo serialize($data);
            break;
        case "html":
            $data["Request"] = $_REQUEST;
            echo '<table><tr><td>' . Array2HTML($data) . '</td></tr></table>';
            break;
        case "plain":
            header("Content-Type: text/plain; charset=utf-8");
            if ($data["err"]["id"] + 0 == 0) {
                @header($_SERVER["SERVER_PROTOCOL"] . " 200 Ok");
            } else {
                header($_SERVER["SERVER_PROTOCOL"] . " 400 " . $data["err"]["msg"]);
            }
            if ($data["err"]["id"] != 0) {
                die("ERR:" . $data["err"]["id"] . ";" . $data["err"]["msg"]);
            }
            if (is_array($data["result"])) {
                foreach ($data["result"] as $a) {
                    echo (string) $a . "\r\n";
                }
                break;
            }
            echo (string) $data["result"];
            break;
        case "xml":
        default:
            header("Content-Type: text/xml");
            $data["Request"] = $_REQUEST;
            echo ArrayToXML::toXml($data, $wgXMLRoot);
            //			echo(Array2XML($data, true));
            break;
    }
    exit(1);
}
function buildXML($toUser = '', $fromUser = '', $data = array())
{
    global $wechat;
    $xml = new ArrayToXML();
    $dataArr = array('xml' => array('#FromUserName' => $fromUser, '#ToUserName' => $toUser, '#CreateTime' => time()));
    $dataArr['xml']['#MsgType'] = $data['type'];
    if ($data['type'] == $wechat::MSGTYPE_TEXT) {
        $dataArr['xml']['#Content'] = $data['text'];
    } else {
        if ($data['type'] == $wechat::MSGTYPE_NEWS) {
            $items = $data['articles'];
            $dataArr['xml']['ArticleCount'] = sizeof($items);
            $_item = array();
            foreach ($items as $item) {
                $_item[] = array('#Title' => $item['title'], '#Description' => $item['digest'], '#PicUrl' => $item['thumb'], '#Url' => $item['url']);
            }
            $dataArr['xml']['Articles']['item'] = $_item;
        } else {
            if ($data['type'] == $wechat::MSGTYPE_IMAGE) {
                $dataArr['xml']['Image'] = array('#MediaId' => $data['media_id']);
            } else {
                if ($data['type'] == $wechat::MSGTYPE_VOICE) {
                    $dataArr['xml']['Voice'] = array('#MediaId' => $data['media_id']);
                }
            }
        }
    }
    return $xml->buildXML($dataArr);
}
Beispiel #12
0
            //Si se especifica otro formato, por el momento simplemente imprimo el array como está...
        //Si se especifica otro formato, por el momento simplemente imprimo el array como está...
        default:
            print_r($retCommentersFinal);
    }
} else {
    switch ($format) {
        //Convierto el array de posts en JSON
        case "json":
            log_action("RESPONSE: " . '{"post":' . indent(json_encode($posts)) . "}");
            echo '{"post":' . indent(json_encode($posts)) . "}";
            break;
            //Convierto el array de posts en XML, utilizando la librería
        //Convierto el array de posts en XML, utilizando la librería
        case "xml":
            $xml = new ArrayToXML();
            $xmlElement = new SimpleXMLElement($xml->toXml($posts, "posts"));
            $xmlElement->addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            $xmlElement->addAttribute("xsi:noNamespaceSchemaLocation", "http://200.69.225.53:30082/XZone.xsd");
            echo $xmlElement->asXML();
            //echo $xml->toXml($posts, "posts");
            break;
            //Si se especifica otro formato, por el momento simplemente imprimo el array como está...
        //Si se especifica otro formato, por el momento simplemente imprimo el array como está...
        default:
            print_r($posts);
    }
}
/* * ****************** Procesamiento de feeds **************** */
function processFeed($feed, $zone = null, $tags = null, $lat = null, $lon = null, $extendedString = null)
{
Beispiel #13
0
    if ($format == 'info') {
        $plugin = $mainframe->triggerEvent('onRestInfo', array($req));
    } else {
        $plugin = $mainframe->triggerEvent('onRestCall', array($req));
    }
} else {
    $plugin[0] = 'Cannot login - Please provide correct auth_user and auth_password';
}
// Generate response
switch ($format) {
    case 'json':
    default:
        $document->setMimeEncoding('application/json');
        $op = json_encode($plugin[0]);
        //		$op = custom_json::encode($plugin[0]);
        break;
    case 'xml':
        $document->setMimeEncoding('application/xml');
        $op = ArrayToXML::toXml($plugin[0]);
        break;
    case 'html':
        break;
    case 'info':
        $op = JoomlaRest::getInfo($plugin[0]);
        break;
}
// Logout
$mainframe->logout();
// Deliver response to client
echo $op;
jexit();
 /**
  * 初始化文档版本及编码
  * 
  * @param string $version   版本号
  * @param string $encoding  XML编码
  */
 public static function init($version, $encoding)
 {
     self::$doc = new DomDocument($version, $encoding);
     self::$doc->formatOutput = true;
 }
Beispiel #15
0
        switch ($action) {
            case 'add':
                $_POST['question'] = array_key_exists('question', $_POST) ? $_POST['question'] : '';
                $_POST['correct'] = array_key_exists('correct', $_POST) ? $_POST['correct'] : null;
                $_POST['answer-explanation'] = array_key_exists('answer-explanation', $_POST) ? $_POST['answer-explanation'] : '';
                $alternatives = array();
                for ($i = 0; $i < 4; $i++) {
                    $alternatives[] = $_POST['alt-' . $i];
                }
                $response = Question::add($_POST['question'], $alternatives, $_POST['correct'], $_POST['answer-explanation'], $_POST['gid']);
                break;
            case 'get':
                $response = Question::get($params[0], $params[1]);
                break;
            case 'my':
                $params[0] = count($params) >= 1 ? $params[0] : null;
                $response = Question::getMine($params[0]);
                break;
            case 'answer':
                $_POST['qid'] = array_key_exists('qid', $_POST) ? $_POST['qid'] : '';
                $_POST['aid'] = array_key_exists('aid', $_POST) ? $_POST['aid'] : '';
                $response = Question::answer($_POST['qid'], $_POST['aid']);
                break;
        }
        break;
        // end $model
}
header(200);
header('Content-type: application/xml');
print is_array($response) ? ArrayToXML::toXml($response, 'data') : '<data>' . $response . '</data>';
exit;
Beispiel #16
0
 /**
  * @author giorgio 25/set/2013
  * 
  * renders the widgets of the page as described in the passed xml config file
  * 
  * @param string $widgetsConfFilename xml configuration filename for the widgets
  * @param arrayn $optionsArray array of option to be passed to the widget loader
  * 
  * @return array|AMA_Error
  */
 public function fillin_widgetsFN($widgetsConfFilename = '', $optionsArray = array())
 {
     require_once ROOT_DIR . '/widgets/include/widget_includes.inc.php';
     if (is_file($widgetsConfFilename)) {
         try {
             $widgetAr = ArrayToXML::toArray(file_get_contents($widgetsConfFilename));
         } catch (Exception $e) {
             /*
              * see config_errors.inc.php line 167 and following.
              * depending on the erorr phase / severity something will happen...
              */
             return new ADA_Error(NULL, 'Widget configuration XML is not valid', __METHOD__, ADA_ERROR_ID_XML_PARSING);
         }
     }
     /**
      * @author giorgio 25/feb/2014
      * ArrayToXML::toArray does not return an array of array if there's
      * only one widget in the xml. Let's build an array of array even in this case.
      */
     if (!is_array(reset($widgetAr['widget']))) {
         $widgets = array($widgetAr['widget']);
     } else {
         $widgets = $widgetAr['widget'];
     }
     $retArray = array();
     foreach ($widgets as $widget) {
         // if widget is not active skip the current iteration
         if (isset($widget['active']) && intval($widget['active']) === 0 || isset($widget[$widget['id']]) && intval($widget[$widget['id']['isActive']]) === 0) {
             continue;
         }
         $wobj = new Widget($widget);
         /**
          * if there are some params passed in, tell it to the widget
          */
         if (isset($optionsArray[$wobj->templateField]) && !empty($optionsArray[$wobj->templateField])) {
             foreach ($optionsArray[$wobj->templateField] as $name => $value) {
                 $wobj->setParam($name, $value);
             }
         }
         $retArray[$wobj->templateField] = $wobj->getWidget();
     }
     return $retArray;
 }
Beispiel #17
0
        }
        /**
         * User Messages 
         */
        $sql = "SELECT pnotes.id, pnotes.user, pnotes.pid, pnotes.title, pnotes.date,pnotes.body, pnotes.message_status, \n                        IF(pnotes.user != pnotes.pid,users.fname,patient_data.fname) as users_fname,\n                        IF(pnotes.user != pnotes.pid,users.lname,patient_data.lname) as users_lname,\n                        patient_data.fname as patient_data_fname, patient_data.lname as patient_data_lname\n                        FROM ((pnotes LEFT JOIN users ON pnotes.user = users.username) \n                        JOIN patient_data ON pnotes.pid = patient_data.pid) WHERE pnotes.message_status LIKE 'New' \n                        AND pnotes.deleted != '1' AND pnotes.date >= '{$date} 00:00:00' AND pnotes.date <= '{$date} 24:00:00' AND pnotes.assigned_to LIKE ?";
        $messageResult = sqlStatement($sql, array($username));
        if ($messageResult->_numOfRows > 0) {
            $xml_array["Messages"]['status'] = 0;
            $xml_array["Messages"]['reason'] = 'Messages Processed successfully';
            $count = 1;
            while ($myrow = sqlFetchArray($messageResult)) {
                foreach ($myrow as $fieldName => $fieldValue) {
                    $rowValue = xmlsafestring($fieldValue);
                    $xml_array["Messages"]['Message-' . $count][$fieldName] = $rowValue;
                }
                $count++;
            }
        } else {
            $xml_array["Messages"]['status'] = -1;
            $xml_array["Messages"]['reason'] = 'Messages not found.';
        }
    }
    $ip = $_SERVER['REMOTE_ADDR'];
    newEvent($event = 'login', $username, $groupname = 'Default', $success = '1', 'success: ' . $ip);
} else {
    newEvent($event = 'login', $username, $groupname = 'Default', $success = '1', 'failure: ' . $ip . ". user password mismatch (" . sha1($password) . ")");
    $xml_array['status'] = -1;
    $xml_array['reason'] = 'Username/Password incorrect.';
}
$xml = ArrayToXML::toXml($xml_array, 'MedMasterUser');
echo $xml;
    if ($acl_allow) {
        $strQuery = "UPDATE openemr_postcalendar_events SET \n                        pc_title = '" . add_escape_custom($pc_title) . "', \n                        pc_hometext = '" . add_escape_custom($pc_hometext) . "' , \n                        pc_catid = '" . add_escape_custom($pc_catid) . "' , \n                        pc_eventDate = '" . add_escape_custom($appointmentDate) . "', \n                        pc_startTime = '" . add_escape_custom($appointmentTime) . "', \n                        pc_endTime = '" . add_escape_custom($endTime) . "', \n                        pc_aid = '" . add_escape_custom($admin_id) . "', \n                        pc_facility = '" . add_escape_custom($facility) . "',\n                        pc_billing_location = '" . add_escape_custom($pc_billing_location) . "',\n                        pc_duration = '" . add_escape_custom($pc_duration) . "',\n                        pc_pid = '" . add_escape_custom($patientId) . "',\n                        pc_apptstatus = '" . add_escape_custom($app_status) . "' \n                    WHERE pc_eid=?";
        $result = sqlStatement($strQuery, array($appointmentId));
        $device_token_badge = getDeviceTokenBadge($provider_username, 'appointment');
        $badge = $device_token_badge['badge'];
        $deviceToken = $device_token_badge['device_token'];
        if ($deviceToken) {
            $notification_res = notification($deviceToken, $badge, $msg_count = 0, $apt_count = 0, $message = 'Appointment Updated!');
        }
        if ($result !== FALSE) {
            $xml_array['status'] = 0;
            $xml_array['reason'] = 'The Appointment has been updated.';
            if ($notification_res) {
                $xml_array['notification'] = 'Update Appointment Notification(' . $notification_res . ')';
            } else {
                $xml_array['notification'] = 'Notificaiotn Failed.';
            }
        } else {
            $xml_array['status'] = -1;
            $xml_array['reason'] = 'ERROR: Sorry, there was an error processing your request. Please re-submit the information again.';
        }
    } else {
        $xml_array['status'] = -2;
        $xml_array['reason'] = 'You are not Authorized to perform this action';
    }
} else {
    $xml_array['status'] = -2;
    $xml_array['reason'] = 'Invalid Token';
}
$xml = ArrayToXML::toXml($xml_array, 'Appointment');
echo $xml;
Beispiel #19
0
 private function _reroute_request($url, $options = [], $verb = '')
 {
     if (isset($options['xml'])) {
         if (is_array($options['xml']) && !isset($options['body'])) {
             $body = $options['xml'];
             $cutpos = strpos($url, '?');
             $node = $url;
             if ($cutpos !== false) {
                 $node = substr($node, 0, $cutpos);
             }
             $node = trim($node, '/');
             //Override body
             $options['body'] = \ArrayToXML::toXML($body, $node);
         }
         //Always remove the xml key from options.. even if it doesn't work.
         unset($options['xml']);
     }
     return parent::$verb($url, $options);
 }
Beispiel #20
0
<?php

header('Content-type: text/xml; charset=UTF-8');
require dirname(__FILE__) . '/../lib/functions.php';
$total = intval($_GET['total']);
if ($total <= 0) {
    throw new PubwichAPIError('Missing parameters');
}
$data = array();
$compteur = 0;
while ($compteur < $total) {
    $timestamp = strtotime('+' . $compteur . ' day');
    $data[] = array('year' => date('Y', $timestamp), 'month' => date('m', $timestamp), 'day' => date('d', $timestamp));
    $compteur++;
}
echo ArrayToXML::toXML($data, 'days');
$pulse = $_POST['pulse'];
$respiration = $_POST['respiration'];
$note = $_POST['note'];
$BMI = $_POST['BMI'];
$BMI_status = $_POST['BMI_status'];
$waist_circ = $_POST['waist_circ'];
$head_circ = $_POST['head_circ'];
$oxygen_saturation = $_POST['oxygen_saturation'];
if ($userId = validateToken($token)) {
    $user = getUsername($userId);
    $acl_allow = acl_check('encounters', 'auth_a', $user);
    if ($acl_allow) {
        $strQuery = "UPDATE `form_vitals` SET \n                                        `date`='" . add_escape_custom($date) . "',\n                                        `pid`='" . add_escape_custom($patientId) . "',\n                                        `user`='" . add_escape_custom($user) . "',\n                                        `groupname`='" . add_escape_custom($groupname) . "',\n                                        `authorized`='" . add_escape_custom($authorized) . "',\n                                        `activity`='" . add_escape_custom($activity) . "',\n                                        `bps`='" . add_escape_custom($bps) . "',\n                                        `bpd`='" . add_escape_custom($bpd) . "',\n                                        `weight`='" . add_escape_custom($weight) . "',\n                                        `height`='" . add_escape_custom($height) . "',\n                                        `temperature`='" . add_escape_custom($temperature) . "',\n                                        `temp_method`='" . add_escape_custom($temp_method) . "',\n                                        `pulse`='" . add_escape_custom($pulse) . "',\n                                        `respiration`='" . add_escape_custom($respiration) . "',\n                                        `note`='" . add_escape_custom($note) . "',\n                                        `BMI`='" . add_escape_custom($BMI) . "',\n                                        `BMI_status`='" . add_escape_custom($BMI_status) . "',\n                                        `waist_circ`='" . add_escape_custom($waist_circ) . "',\n                                        `head_circ`='" . add_escape_custom($head_circ) . "',\n                                        `oxygen_saturation`='" . add_escape_custom($oxygen_saturation) . "' \n                                         WHERE id = ?";
        $result = sqlStatement($strQuery, array($vital_id));
        if ($result !== FALSE) {
            $xml_array['status'] = 0;
            $xml_array['reason'] = 'Visit vital update successfully';
        } else {
            $xml_array['status'] = -1;
            $xml_array['reason'] = 'Could not update isit vital';
        }
    } else {
        $xml_string .= "<status>-2</status>\n";
        $xml_string .= "<reason>You are not Authorized to perform this action</reason>\n";
    }
} else {
    $xml_array['status'] = -2;
    $xml_array['reason'] = 'Invalid Token';
}
$xml = ArrayToXML::toXml($xml_array, 'visitvitals');
echo $xml;
                        $rowvalue = xmlsafestring($fieldvalue8);
                        $xml_array['Patient']['vitalslist']['vitals-' . $counter8][$fieldname] = $rowvalue;
                    }
                    // foreach
                    $counter8++;
                }
            } else {
                $xml_array['Patient']['vitalslist']['status'] = 1;
                $xml_array['Patient']['vitalslist']['reason'] = 'No Patient Vital Data found';
            }
            $strQuery1 = "SELECT d.date,d.size,d.url,d.docdate,d.mimetype,c2d.category_id\n                                FROM `documents` AS d\n                                INNER JOIN `categories_to_documents` AS c2d ON d.id = c2d.document_id\n                                WHERE foreign_id = ?\n                                AND category_id = 13\n                                ORDER BY category_id, d.date DESC \n                                LIMIT 1";
            $result1 = sqlQuery($strQuery1, array($p_id));
            if ($result1) {
                $xml_array['Patient']['demographics']['profile_image'] = getUrl($result1['url']);
            } else {
                $xml_array['Patient']['demographics']['profile_image'] = '';
            }
        } else {
            $xml_array['Patient']['patientdata']['status'] = 1;
            $xml_array['Patient']['patientdata']['reason'] = 'Error processing patient records';
        }
    } else {
        $xml_array['status'] = -2;
        $xml_array['reason'] = 'You are not Authorized to perform this action';
    }
} else {
    $xml_array['status'] = -2;
    $xml_array['reason'] = 'Invalid Token';
}
echo ArrayToXML::toXml($xml_array, 'PatientList');
Beispiel #23
0
 function __construct($msg)
 {
     $error = array('message' => $msg);
     echo ArrayToXML::toXML($error, 'error');
     die;
 }
Beispiel #24
0
 /**
  * @var string $sOperation - Valid SilverPOP operation to perform. 
  * @var mixed $mData - Either an array of parameters to pass to the request || raw, validated XML string.  
  * @return string - SimpleXML Response Object ($oResponse->Body->RESULT);  
  *
  * Create the XML Payload. This method is only called from $this->fnRequest(); 
  */
 private function fnQuery($sOperation, $mData)
 {
     $oResponse = NULL;
     if (is_array($mData)) {
         $aData = array();
         $aData['Envelope']['Body'][$sOperation] = $mData;
         $oXML = new ArrayToXML($aData);
         $sXML = $oXML->getXML();
     } else {
         /*	
         	$mData could be raw data because sometimes this will need to be manually constructed 
         	(in the case of multiple child nodes, arrays cannot have the same index value);  
         */
         $sXML = $mData;
     }
     $aFields = array('jsessionid' => isset($this->sSessionID) ? $this->sSessionID : NULL, 'xml' => $sXML);
     $oResponse = $this->fnCURL($aFields);
     return $oResponse;
 }
Beispiel #25
0
 /**
  * The main function for converting to an array.
  * Pass in a XML document and this recrusively loops through and builds up an array.
  *
  * @static
  * @param  string $obj - XML document string (at start point)
  * @param  array  $arr - Array to generate
  * @return array - Array generated
  */
 public static function toArray($obj, &$arr = NULL)
 {
     if (is_null($arr)) {
         $arr = array();
     }
     if (is_string($obj)) {
         $obj = new SimpleXMLElement($obj);
     }
     // Get attributes for current node and add to current array element
     $attributes = $obj->attributes();
     foreach ($attributes as $attrib => $value) {
         $arr[ArrayToXML::attr_arr_string][$attrib] = (string) $value;
     }
     $children = $obj->children();
     $executed = FALSE;
     // Check all children of node
     foreach ($children as $elementName => $node) {
         // Check if there are multiple node with the same key and generate a multiarray
         if (array_key_exists($elementName, $arr) && $arr[$elementName] != NULL) {
             if (isset($arr[$elementName][0]) && $arr[$elementName][0] !== NULL) {
                 $i = count($arr[$elementName]);
                 ArrayToXML::toArray($node, $arr[$elementName][$i]);
             } else {
                 $tmp = $arr[$elementName];
                 $arr[$elementName] = array();
                 $arr[$elementName][0] = $tmp;
                 $i = count($arr[$elementName]);
                 ArrayToXML::toArray($node, $arr[$elementName][$i]);
             }
         } else {
             $arr[$elementName] = array();
             ArrayToXML::toArray($node, $arr[$elementName]);
         }
         $executed = TRUE;
     }
     // Check if is already processed and if already contains attributes
     if (!$executed && $children->getName() == "" && !isset($arr[ArrayToXML::attr_arr_string])) {
         $arr = (string) $obj;
     }
     return $arr;
 }
        $lab_report_catid = document_category_to_id("Lab Report");
        if ($cat_id == $lab_report_catid) {
            $device_token_badge = getDeviceTokenBadge($provider_username, 'labreport');
            $badge = $device_token_badge['badge'];
            $deviceToken = $device_token_badge['device_token'];
            if ($deviceToken) {
                $notification_res = notification($deviceToken, $badge, $msg_count = 0, $apt_count = 0, $message = 'New Labreport Notification!');
            }
        }
        if ($res) {
            $xml_array['status'] = "0";
            $xml_array['reason'] = "Document added successfully";
            if ($notification_res) {
                $xml_array['notification'] = 'Add Patient document Notification(' . $notification_res . ')';
            } else {
                $xml_array['notification'] = 'Notificaiotn Failed.';
            }
        } else {
            $xml_array['status'] = "-1";
            $xml_array['reason'] = "ERROR: Sorry, there was an error processing your data. Please re-submit the information again.";
        }
    } else {
        $xml_array['status'] = -2;
        $xml_array['reason'] = 'You are not Authorized to perform this action';
    }
} else {
    $xml_array['status'] = "-2";
    $xml_array['reason'] = 'Invalid Token';
}
$xml = ArrayToXML::toXml($xml_array, 'PatientImage');
echo $xml;
Beispiel #27
0
<?php

header('Content-type: text/xml; charset=UTF-8');
require dirname(__FILE__) . '/../lib/functions.php';
$min = intval($_GET['min']);
$max = intval($_GET['max']);
if (!$min || !$max) {
    throw new PubwichAPIError('Missing parameters');
}
$data = array();
$data[] = rand($min, $max);
echo ArrayToXML::toXML($data, 'number');