내 스크립트하자 사람들의 포스트 짧은 15 개 주소를 확인 :foreach는 결과 시간당
$err_msg = isValidFLR($flr_post, $ip);
if (!$err_msg) {
list($randlink, $lastid, $scr) = addLink($flr_post, $ip);
$flr_post = check_input($flr_post);
$url_array[$i]['number'] = $i + 1;
$url_array[$i]['flr'] = $flr_post;
$url_array[$i]['flr_substr'] = (strlen($flr_post) > 33) ? substr($flr_post, 0, 33) . '...' : $flr_post;
$url_array[$i]['randlink'] = $randlink;
$url_array[$i]['fullrand'] = $config['indexurl'] . $config['mod_rewrite_char'] . $randlink;
$url_array[$i]['scr'] = $scr;
$url_array[$i]['id'] = $lastid;
$url_array[$i]['flr_length'] = strlen($flr_post);
$url_array[$i++]['randlink_length'] = strlen($config['indexurl'] . $config['mod_rewrite_char'] . $randlink);
} else {
die('Error, omg');
}
기능 isValidFLR 확인 주소의 호스트 이름,는 preg_match (이 경우 URL)과하지 않을 경우 차단 목록에 있습니다.
문제는, 그 경우이 (한 줄에 하나 개의 주소)와 같은 사용자 게시물 :
google.com
google.net
ksajdkljaskldjalsd.com
스크립트 반환의 잘못된 주소의 모든 것을. 사용자가 하나만 게시하려고하면 모든 유효한 올바른 주소 스크립트가 효과적입니다.
그래서이 스크립트 또는 URL 유효성 검사의 문제점은 무엇입니까?
당신의 제안은 무엇입니까?
편집 :
function isValidFLR(&$flr_post,&$ip) {
preg_match_all("!://!",$flr_post,$matches);
$match_count = count($matches[0]);
if ($match_count>=2) {
$flr_post = preg_replace("!(.+)://((.+)://(.+))!",'\2',$flr_post);
}
elseif ($match_count==0) $flr_post = 'http://'.$flr_post;
if (!preg_match('!^(http|https|ftp)://[\w-]+\.[\w-]+(\S+)?$!i', $flr_post)) {
//if (!preg_match('/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i', $flr)) {
return 'wromg address: '.$flr_post;
}
else {
$m = parse_url($flr_post);
$hostname = strtolower($m['host']);
}
// is such host..
if (preg_match('/^\d+\.\d+\.\d+\.\d+/', $hostname)) {
$ip = $hostname;
} else {
$ip = gethostbyname($hostname);
if ($ip===$hostname)
return 'host not found: '.$flr_post;
}
// does host not blocked..
if (in_array($ip,getIPs_array())) {
return 'host blocked: '.$flr_post;
}
return false;
}
함수 isValidFLR에 대한 스크립트를 포함하지 않으면 어떻게 알 수 있습니까? – ajreal
ok, 게시물 – ZeroSuf3r
을 업데이트 할 예정입니다. 코드를 멋지게 형식화하고 공백이 좋지는 않습니다. 코드 스 니펫은 깔끔하고 관련성이 있어야합니다. – ajreal