Пример #1
0
function OVH()
{
    global $ovh_status;
    // -- Detection des arguments --
    $args = func_get_args();
    if (sizeof($args) < 2) {
        return false;
    }
    $api = $args[0];
    if (!is_string($api)) {
        return false;
    }
    $ssid = $args[1];
    if (sizeof($args) > 2) {
        $params = $args[2];
    } else {
        $params = null;
    }
    if (is_array($ssid)) {
        list($params, $ssid) = array($ssid, $params);
    }
    if (is_array($ssid) || !is_array($params) && !is_null($params)) {
        return false;
    }
    if (!is_null($ssid)) {
        $full_params[] = $ssid;
    }
    if (!is_null($params)) {
        $full_params[] = $params;
    }
    // -- Temporisation --
    $delay = 250;
    list($usec, $sec) = explode(" ", microtime());
    $t = round((double) $usec * 1000 + (double) $sec * 1000);
    static $time = 0;
    if ($time == 0) {
        $time = $t - $delay;
    }
    if ($t - $time < $delay) {
        usleep($delay - ($t - $time));
    }
    $time = $t;
    // -- Initialisation du client SOAP --
    static $soap_client, $options;
    static $init = false;
    $return = false;
    if (!$init) {
        require "SOAP/Client.php";
        $soap_client = new SOAP_Client("http://ovh.com:1663");
        $soap_client->setEncoding("UTF-8");
        $options = array("namespace" => "urn:manager", "trace" => 1, "timeout" => 10);
        $init = true;
    }
    // -- Verrouillage --
    if ($api == "ClearNicSessions") {
        if (defined("OVHCLEARNIC")) {
            return $return;
        } else {
            define("OVHCLEARNIC", true);
        }
    }
    // -- Execution de la fonction API --
    $result = $soap_client->call($api, $full_params, $options);
    if (!PEAR::isError($result)) {
        $result = get_object_vars($result);
        // -- Conversion des objets en tableaux --
        if (!function_exists('OVH_OBJ_CONV')) {
            function OVH_OBJ_CONV($r)
            {
                if (is_object($r)) {
                    $r = get_object_vars($r);
                }
                if (is_array($r)) {
                    $r = array_map('OVH_OBJ_CONV', $r);
                }
                return $r;
            }
        }
        $result = array_map('OVH_OBJ_CONV', $result);
        // -- Traitement du resultat --
        if (!isset($result["status"]) && isset($result["value"])) {
            if (is_numeric($result["value"])) {
                $ovh_status = $result["value"];
            } else {
                $ovh_status = $result["status"];
            }
        } else {
            $ovh_status = $result["status"];
        }
        if (isset($result["ie"])) {
            $ovh_status .= "/" . $result["ie"];
        }
        if (isset($result["msg"])) {
            $ovh_status .= " - " . $result["msg"];
        }
        switch ($result["status"]) {
            case 100:
                $return = $result;
                break;
            case 304:
                if (ovh("ClearNicSessions", $params) !== false) {
                    $return = ovh($api, $ssid, $params);
                }
                break;
        }
    }
    return $return;
}
Пример #2
0
            } else {
                $msg = $messages['error_validate'];
            }
            break;
        case 'validate_unsub':
            include './temp_unsub.php';
            $key = $_GET['key'];
            if (isset($temp[$key])) {
                $ssid = ovh('Login', array('nic' => $config['nic'], 'password' => $config['pass']));
                $result = ovh('MailingListUnsub', $ssid['value'], array('domain' => $config['domain'], 'ml' => $config['ml'], 'email' => $temp[$key]));
                if ($result) {
                    $msg = sprintf($messages['confirm_validate'], $temp[$key]);
                } else {
                    $msg = $messages['error_validate'];
                    $msg .= $ovh_status ? '<br />' . $ovh_status : '';
                }
                ovh('Logout');
                $temp_file = file_get_contents('./temp_unsub.php');
                $new_temp_file = str_replace("'" . $key . "' => '" . $temp[$key] . "',\n", "", $temp_file);
                $handle = fopen('./temp_unsub.php', 'w');
                @fwrite($handle, $new_temp_file);
                fclose($handle);
            } else {
                $msg = $messages['error_validate'];
            }
            break;
        default:
            die('Access denied!');
    }
}
include 'confirmation.php';