Jump to content

[function.file-get-contents]: failed to open stream: HTTP request failed!


mck.workman

Recommended Posts

Hey! I am trying to get a database table of users but am running into the error:

 

Warning: file_get_contents(http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=68583) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 in get_user_from_parameter(nabble:utilities.naml:890) - <n.get_user_from_parameter.as_user_page.do/> - public v in C:\xampp\htdocs\website4js\stanford\loadUsernames.php on line 32

 

I have looked it up and it may be a security thing...The urls I am getting are http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=68583 but the error adds an nodes& part that screws it up. Any way around this?

 

<?PHP 
$maxPage = 0;
$mainPage = "http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=app_people&node=136";
$mainContent = file_get_contents($mainPage);
$pattern = "/(?<=\"Page )\d\d+/";
preg_match_all($pattern, $mainContent, $pageNumb);

//find the max page
for($i=0;$i<sizeof($pageNumb[0]);$i++) {
if($pageNumb[0][$i] > $maxPage) {
	$maxPage = $pageNumb[0][$i];
}
}
//echo('Max page is: '.$maxPage.'\n');

//Get an array of all the pages
$pages = array();
for($i=1;$i<$maxPage;$i++) {
 $pages[$i] = "http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=app_people&node=136&i=".($i*20);
} 
//print_r($userPages);

//Get personal page urls and add to MySQL
mysql_connect("localhost" , "root") or die("Cant connect");
mysql_select_db("protegeusers") or die("Cant find database");
foreach($pages as $url) {
$urlContents = file_get_contents($url);
$pattern = "/http:\/\/protege-ontology-editor-knowledge-acquisition-system\.136\.n4\.nabble\.com\/template\/NamlServlet\.jtp\?macro=.+;user=\d+/";
preg_match_all($pattern, $urlContents, $personalPage);
foreach($personalPage as $user) {
	 for($i=0; $i<sizeof($user);$i++) {
		[color=green]$userContents = file_get_contents($user[$i]);[/color]
		$pattern1 = "/user\/SendEmail\.jtp\?type=user.+;user=\d+/";
		$pattern2 = "/(?<=\">Send Email to ).+(?=<)/";
		preg_match_all($pattern1, $userContents, $userEmail);
		preg_match_all($pattern2, $userContents, $username);
		[color=green]print_r($username);
		print_r($email);[/color]
		//$query = "INSERT INTO users (username, userurl) values ('$userName','$userUrl')";
		//mysql_query($query);
	 }
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.