예제 #1
0
function validateInstance($instance)
{
    if ($instance == 'www' || $instance == 'www.' || $instance == 'dev') {
        $ret = false;
        echo json_encode(array('exists' => $ret));
        die;
    }
    // Check that the selected instance name is a valid standard host name
    $validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
    if (!$validate->isValid($instance)) {
        $ret = false;
        echo json_encode(array('exists' => $ret));
        die;
    }
    $cupid = new Cupid();
    $cupid->init();
    $exists = $cupid->instanceExists($instance);
    if (!$exists) {
        $ret = true;
        echo json_encode(array('exists' => $ret));
    } else {
        $ret = false;
        echo json_encode(array('exists' => $ret));
    }
    $cupid->disconnect();
}