oliverw92 Posted May 9, 2008 Share Posted May 9, 2008 well im trying to make a php script to log into a forum, and eventually post on it, but im having trouble. its basically not doing anything. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Forum Connect</title> </head> <body> <? $host = "playground.thegfxedge.com"; $page = "//index.php?act=Login&CODE=00"; $data = "referer=http%3A%2F%2Fplayground.thegfxedge.com%2F%2Findex.php%3F&UserName=USERNAME&PassWord=PASSWORD&CookieDate=1"; $crlf = chr(13).chr(10); $fp = fsockopen($host, 80, $errno, $errdesc) or die("Connection to $host failed"); fputs($fp,"POST $page HTTP/1.0\r\n"); fputs($fp,"Host: $host\r\n"); fputs($fp,"Content-Type: application/x-www-form-urlencoded\r\n"); fputs($fp,"Content-Length: ".strlen($data)."\r\n"); fputs($fp,$crlf." ".$data."\r\n"); while (!feof($fp)) { echo fgets($fp, 1024); } fclose($fp); ?> </body> </html> it just gets stuck not loading. Link to comment https://forums.phpfreaks.com/topic/104944-php-post-socket/ Share on other sites More sharing options...
oliverw92 Posted May 10, 2008 Author Share Posted May 10, 2008 anybody??? Link to comment https://forums.phpfreaks.com/topic/104944-php-post-socket/#findComment-537428 Share on other sites More sharing options...
oliverw92 Posted May 10, 2008 Author Share Posted May 10, 2008 ok well iv made it so it sockets to the homepage first to get the session id, which it does, and then when i do the login socket, i supply the cookie, but it still wont login, and im sending the same stuff that tamper data receives. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Forum Connect</title> </head> <body> <? $host = "playground.thegfxedge.com"; $page = "/"; $fp = fsockopen($host, 80, $errno, $errdesc) or die("Connection to $host failed"); fwrite($fp, "GET ".$page." HTTP/1.0\r\nHost: ".$host."\r\n\r\n"); while (!feof($fp)) { $dat = fgets($fp, 1024); if (preg_match("/Set-Cookie: session_id=(.+)\; path/",$dat,$reg)) { echo "Session ID Found!: ".$reg[1]."<br>"; $ses = $reg[1]; $page = "//index.php?act=Login&CODE=01"; $cookie = "ipb_stronghold=70918bfac374698ebf109871f9b4d42d; anonlogin=-1; session_id=".$ses."; member_id=0; pass_hash=0; coppa=0"; $data = "referer=http%3A%2F%2Fplayground.thegfxedge.com%2F%2Findex.php%3F&UserName=Resourcer&PassWord=PASSWORD&CookieDate=1"; echo $data."<br>".$cookie."<br>".$ses."<br>"; $fp2 = fsockopen($host, 80, $errno, $errdesc) or die("Connection to $host failed"); fwrite($fp2, "POST ".$page." HTTP/1.0\r\nHost: ".$host."\r\nCookie: ".$cookie."\r\nContent-type: application/x-www-form-urlencoded\r\nKeep-Alive: 300\r\nConnection: keep-alive\r\nContent-length: ".strlen($data)."\r\n\r\n$data"); } } fclose($fp); while (!feof($fp2)) { $dat = fgets($fp2, 1024); echo $dat."<br>"; } fclose($fp2); ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/104944-php-post-socket/#findComment-537644 Share on other sites More sharing options...
BlueSkyIS Posted May 10, 2008 Share Posted May 10, 2008 have you looked into using curl instead of sockets? i expect that curl would be the best and/or easiest for interacting with a website. Link to comment https://forums.phpfreaks.com/topic/104944-php-post-socket/#findComment-537653 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.