Esempio n. 1
0
function discount30_session()
{
    $postdata = http_build_query(array('xml_req' => '<?xml version="1.0"?><magic><login><portal>disc30</portal><rkey>eCQD785EICEpWXJ14uqm9PDHxhNHrIa3T3bDH0kT9ncSDm45bYuP3pVwrgub5iv5</rkey><akey>QSN5S9Gffdtn2oTyq7XLuOSVSNJnunsr</akey><ref_ip>127.0.0.1</ref_ip></login></magic>'));
    $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
    $context = stream_context_create($opts);
    $result = file_get_contents('http://174.122.153.218/connect/getSession.php', false, $context);
    $xml = simplexml_load_string($result);
    $xmlarray = array();
    XMLToArrayFlat($xml, $xmlarray, '', true);
    $user_session = null;
    foreach ($xmlarray as $key => $value) {
        $substr = stristr($key, 'mr_session');
        if (!empty($substr)) {
            $user_session = $value;
            break;
        }
    }
    return $user_session;
}
Esempio n. 2
0
function discount30_verify_session($existing_session)
{
    $sessiondata = http_build_query(array('xml_req' => '<?xml version="1.0"?><magic><login><mr_session>' . $existing_session . '</mr_session><rkey>eCQD785EICEpWXJ14uqm9PDHxhNHrIa3T3bDH0kT9ncSDm45bYuP3pVwrgub5iv5</rkey></login></magic>'));
    $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $sessiondata));
    $context = stream_context_create($opts);
    $result = file_get_contents('http://174.122.153.218/connect/getSessionStatus.php', false, $context);
    $xml = simplexml_load_string($result);
    $xmlarray = array();
    XMLToArrayFlat($xml, $xmlarray, '', true);
    $verify_session = null;
    foreach ($xmlarray as $key => $value) {
        $substr = stristr($key, 'mr_session');
        if (!empty($substr)) {
            $verify_session = $value;
            break;
        }
    }
    if ($verify_session == $existing_session) {
        return true;
    } else {
        return false;
    }
}
Esempio n. 3
0
function XMLToArrayFlat($xml, &$return, $path = '', $root = false)
{
    $children = array();
    if ($xml instanceof SimpleXMLElement) {
        $children = $xml->children();
        if ($root) {
            // we're at root
            $path .= '/' . $xml->getName();
        }
    }
    if (count($children) == 0) {
        $return[$path] = (string) $xml;
        return;
    }
    $seen = array();
    foreach ($children as $child => $value) {
        $childname = $child instanceof SimpleXMLElement ? $child->getName() : $child;
        if (!isset($seen[$childname])) {
            $seen[$childname] = 0;
        }
        $seen[$childname]++;
        XMLToArrayFlat($value, $return, $path . '/' . $child . '[' . $seen[$childname] . ']');
    }
}