Пример #1
0
 function report($msgid)
 {
     $params = $this->getParams();
     if ($params->user && $params->pass && $msgid) {
         $xml_data = '<Query xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="SmsApi">' . '<Credential>' . '<Password>' . $params->pass . '</Password>' . '<Username>' . $params->user . '</Username>' . '</Credential>' . '<MessageId>' . $msgid . '</MessageId>' . '</Query>';
         $URL = "http://api.1sms.com.tr/v1/xml/syncreply/Query";
         $ch = curl_init($URL);
         curl_setopt($ch, CURLOPT_MUTE, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
         curl_setopt($ch, CURLOPT_POSTFIELDS, "{$xml_data}");
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $output = curl_exec($ch);
         curl_close($ch);
         $simple = XMLToArray($output);
         $cvp = $simple["QUERYRESPONSE"]["RESPONSE"]["STATUS"]["CODE"];
         if ($cvp == 200) {
             return "success";
         } else {
             return "error";
         }
     } else {
         return null;
     }
 }
Пример #2
0
function XMLToArray($xml)
{
    if ($xml instanceof SimpleXMLElement) {
        $children = $xml->children();
        $return = null;
    }
    foreach ($children as $element => $value) {
        if ($value instanceof SimpleXMLElement) {
            $values = (array) $value->children();
            if (count($values) > 0) {
                $return[$element] = XMLToArray($value);
            } else {
                if (!isset($return[$element])) {
                    $return[$element] = (string) $value;
                } else {
                    if (!is_array($return[$element])) {
                        $return[$element] = array($return[$element], (string) $value);
                    } else {
                        $return[$element][] = (string) $value;
                    }
                }
            }
        }
    }
    if (is_array($return)) {
        return $return;
    } else {
        return $false;
    }
}
Пример #3
0
/**
 * Generates an array out of an xml-string.
 * This function is used at the management of the extras field in the mysql-database
 * Uses expat XML parser / PHP XML-functions.
 *
 * @return  returns an array
 */
function XML2Array($text)
{
    $text = '<SAVE>' . $text . '</SAVE>';
    $text = utf8_encode($text);
    // needed for PHP5
    $result = XMLToArray($text);
    return $result;
}
Пример #4
0
function XML2Arr($data, $uppercase = 1) {
	return XMLToArray($data, $uppercase);
}
Пример #5
0
function commsy_XMLToArray($xml)
{
    if ($xml instanceof SimpleXMLElement) {
        $children = $xml->children();
        $return = null;
    } else {
        $xml = simplexml_load_string($xml);
        if ($xml instanceof SimpleXMLElement) {
            $children = $xml->children();
        } else {
            $children = array();
        }
        $return = null;
    }
    foreach ($children as $element => $value) {
        if (strstr($element, 'XML_')) {
            $element_begin = substr($element, 0, 4);
            if ($element_begin = 'XML_') {
                $element = substr($element, 4);
            }
        }
        if ($value instanceof SimpleXMLElement) {
            $counter = 0;
            foreach ($value->children() as $children) {
                $counter++;
            }
            if ($counter > 0) {
                $return[$element] = XMLToArray($value);
            } else {
                if (!empty($element) and $element == 'extras') {
                    $value = unserialize((string) $value);
                } elseif (isset($value)) {
                    // convert > and < to their html entities (gt; and &lt;)
                    if (strstr($value, "%CS_AND;")) {
                        $value = ereg_replace("%CS_AND;", "&", $value);
                    }
                    if (strstr($value, "%CS_LT;")) {
                        $value = ereg_replace("%CS_LT;", "<", $value);
                    }
                    if (strstr($value, "%CS_GT;")) {
                        $value = ereg_replace("%CS_GT;", ">", $value);
                    }
                } else {
                    $value = '';
                }
                if (!isset($return[$element])) {
                    if (is_array($value)) {
                        $return[$element] = $value;
                    } else {
                        $return[$element] = (string) $value;
                    }
                } else {
                    if (!is_array($return[$element])) {
                        $return[$element] = array($return[$element], (string) $value);
                    } else {
                        $return[$element][] = (string) $value;
                    }
                }
            }
        }
    }
    if (is_array($return)) {
        return $return;
    } else {
        return false;
    }
}