Quantcast

Jump to content


Photo

PHP Headers?


  • Please log in to reply
5 replies to this topic

#1 Zeeknon

Zeeknon
  • 63 posts

Posted 28 May 2010 - 09:39 PM

I'm trying to make a function to make the headers to send with fsockopen. I'm totally lost.

echo headers("POST", "www.neopets.com", "/login.phtml", "Referer: http://www.neopets.com/hi.phtml", "username=user&password=pass&destination=%2Findex.phtml");


		function headers($method, $file, $host, $referer = "", $data = "") {
$isPost = stripos($method, "POST") !== FALSE;
$headers = ($isPost ? "POST " : "GET ").$file." HTTP/1.1\r\n";
$headers .= "Host: ".$host."\r\n";
$headers .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3\r\n";
$headers .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
$headers .= "Accept-Language: en-us,en;q=0.5\r\n";
$headers .= "Accept-Encoding: gzip,deflate\r\n";
$headers .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$headers .= "Keep-Alive: 115\r\n";
$headers .= "Connection: keep-alive\r\n";
if(isSet($referer)) {
$headers .= $referer."\r\n";
}
if($isPost) {
$headers .= "Content-Type: application/x-www-form-urlencoded\r\n";
$headers .= "Content-Length: ".strlen($data)."\r\n";
}
if(isSet($this->Cookie)) {
$headers .= $this->Cookie."\r\n\r\n";
} else {
$headers .= "\r\n\r\n";
}
if($isPost) {
$headers .= $data;
}
return $headers;
}

Here's what it echoes:
POST www.neopets.com HTTP/1.1
Host: /login.phtml
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.neopets.com/hi.phtml
Content-Type: application/x-www-form-urlencoded
Content-Length: 54


username=user&password=pass&destination=%2Findex.phtml
And when I replace "user" with my username, I get this:

Error: No username found! Please go back and re-enter your username.

I'm really stuck :(

Edited by Zeeknon, 28 May 2010 - 09:43 PM.


#2 kuwaz

kuwaz
  • 1181 posts

Posted 29 May 2010 - 09:53 AM

I'm curious why anyone would build a php header for neopets.

And of course it doesn't work, you're running a login page from one
site to another. If you don't know, you cant POST across domains, permission
just doesn't allow it.

Edited by channel_49, 29 May 2010 - 09:56 AM.


#3 Zeeknon

Zeeknon
  • 63 posts

Posted 29 May 2010 - 10:42 AM

I found what was wrong:

POST www.neopets.com HTTP/1.1
Host: /login.phtml


I'm curious why anyone would build a php header for neopets.

And of course it doesn't work, you're running a login page from one
site to another. If you don't know, you cant POST across domains, permission
just doesn't allow it.


Are you serious right now? You don't know what you're talking about.

#4 kuwaz

kuwaz
  • 1181 posts

Posted 29 May 2010 - 12:12 PM

Are you serious right now? You don't know what you're talking about.


No I was just thinking about Javascript, like GM or something, and encountered
that before. Then I realized this is php, backend, and totally different.

#5 JesterC

JesterC
  • 21 posts

Posted 30 May 2010 - 02:40 PM

No I was just thinking about Javascript, like GM or something, and encountered
that before. Then I realized this is php, backend, and totally different.


Well it kinda says php in the title, and opening tags in the code. I'm pretty sure you can send server requests with javascript. I would sit back and read, and wait till you know something before you start making useless conversations.



As for Zeek, you can do the same thing with cURL, and you can send a post to a server using the url.

#6 kuwaz

kuwaz
  • 1181 posts

Posted 31 May 2010 - 04:53 PM

Well it kinda says php in the title, and opening tags in the code. I'm pretty sure you can send server requests with javascript. I would sit back and read, and wait till you know something before you start making useless conversations.



As for Zeek, you can do the same thing with cURL, and you can send a post to a server using the url.


No you can't, not in Javascript without the help of some backend, only reason I mentioned that is because I had to make something that ran ontop of the an existing system that I had no access to edit anything behind. Try doing it with only JS, you'll end up getting failed requests, since you can't AJAX to a different server. Although there's a work around with JSON and using yahoo servers to fetch it but I never tried it.

What's the fun to carefully reading? I guess in my defence I work with both side by side, all the time, sometimes the lines blurrr. I'd type '+' in php and '.' in js. But its not like you'll believe that.

Edited by Dan, 12 June 2010 - 12:06 PM.
Formatting



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users