Rustywolf Posted March 15, 2010 Share Posted March 15, 2010 Im making a blocked site checker for ym school i want it to read data from a text file with URL's in it how would i achieve this? sort of like: <?php //get the url from text file $url = "url"; $fp = fsockopen($url, 80, $errno, $errstr, 30); if(!fp) { echo 'blocked'; } else { echo 'Unblock'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/195272--/ Share on other sites More sharing options...
abazoskib Posted March 15, 2010 Share Posted March 15, 2010 why dont you use file() and a foreach loop to go through each URL Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026183 Share on other sites More sharing options...
trq Posted March 15, 2010 Share Posted March 15, 2010 if (in_array($_SERVER['REMOTE_ADDR'], file('ipaddresses.txt')) { echo 'Blocked'; } else { echo 'Not Blocked'; } Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026187 Share on other sites More sharing options...
Rustywolf Posted March 15, 2010 Author Share Posted March 15, 2010 Not what i need thorpe. Care to give an example abazoskib? Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026193 Share on other sites More sharing options...
trq Posted March 15, 2010 Share Posted March 15, 2010 Not what i need thorpe. Care to give an example abazoskib? Why don't you actually describe what it is you want then? Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026200 Share on other sites More sharing options...
Rustywolf Posted March 15, 2010 Author Share Posted March 15, 2010 I thought the brief source code and the description i gave set an example? Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026207 Share on other sites More sharing options...
trq Posted March 15, 2010 Share Posted March 15, 2010 Indeed it does, and I completely misread your post. <?php foreach (file('urls.txt') as $url) { if (!fsockopen($url, 80, $errno, $errstr, 30)) { echo 'blocked'; } else { echo 'Unblock'; } } ?> I would also have assumed however that you would have been easily able to take my example and modify it to your needs.[/code] Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026218 Share on other sites More sharing options...
Rustywolf Posted March 15, 2010 Author Share Posted March 15, 2010 Exactly what i needed. Thanks throrpe Quote Link to comment https://forums.phpfreaks.com/topic/195272--/#findComment-1026221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.