예제 #1
0
    return $this->optional($value) || preg_match('/^\\d+$/', $value);
});
validator::addMethod('alpha', function ($name, $value, $param) {
    return $this->optional($value) || preg_match('#^[a-z]+$#', $value);
});
validator::addMethod('remote', function ($name, $value, $param) {
    if ($this->optional($value)) {
        return TRUE;
    }
    if (!$value) {
        return FALSE;
    }
    if (preg_match('#^http#i', $param)) {
        $domain = $param;
    } else {
        $domain = \limepie\request::currentDomain() . $param;
    }
    $domain .= '?' . $name . '=' . $value . '&test=7';
    $getHttp = function ($url, $params = []) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, FALSE);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($ch, CURLOPT_TIMEOUT, 5);
        if ($params) {
            $postData = http_build_query($params);
            curl_setopt($ch, CURLOPT_POST, count($postData));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
        }
        $output = curl_exec($ch);