1
ChadK
Posting to remote site - code debug?
  • 2004/8/3 18:48

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Hey, I have some code that I copied from http://www.zend.com/zend/tut/tut-using-output.php

I'm not really trying to DO anything, I just want to learn the technique. I'm trying to log in to my site using a php script which is included below. I pass it all of the variables found on my login form to the correct page for logging in but it always returns me to my index again instead of returning the XOOPS image from my admin page (which is what's located between the regular expression).

Anyway, have a look and see what you think I may be doing wrong. Do I NEED a PHPSESSID before I can submit the login? I did another version of this test submitting a SEARCH string to my site and returning the results which worked great... but logging in doesn't go.


Quote:
<?PHP
function login($url,$querystring,$expect){
$fp = @fopen("$url?".urlencode($querystring), "r");
if($fp){
while($in = fread($fp, 1024))
$reply .= $in;
fclose($fp);
if(ereg($expect, $reply, $reg))
return trim($reg[1]);
else
return "Error : Could not find results! <hr> $reply <hr><hr> $url <hr> $querystring <hr> $expect <hr>";

}
return "Error : Could not connect to site!";
}

echo login("http://www.aviary.info/user.php","&PHPSESSID=&uname=Myusername&pass=".md5("mypasswordhere")."&xoops_redirect=admin.php&op=login&Autologin=On&Privacy=0","<td bgcolor='#2F5376'>(.*)</td>");

?>

2
ChadK
Re: Posting to remote site - code debug?
  • 2004/8/3 18:49

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Of course the search function uses GET and the login uses POST... that may be causing some trouble. Anyone know how to work it with POST forms?

3
ChadK
Re: Posting to remote site - code debug?
  • 2004/8/3 18:57

  • ChadK

  • Quite a regular

  • Posts: 242

  • Since: 2004/7/9 1


Nevermind this question.. I found Snoopy http://sourceforge.net/projects/snoopy/

Quote:
<?PHP
include "include/Snoopy.class.php";
$snoopy = new Snoopy;

$submit_url = "http://www.aviary.info/user.php";


$submit_vars["PHPSESSID"] = "";
$submit_vars["uname"] = "Myusername";
$submit_vars["pass"] = "mypassword";
$submit_vars["xoops_redirect"] = "/admin.php";
$submit_vars["op"] = "login";
$submit_vars["Autologin"] = "On";
$submit_vars["Privacy"] = "0";
$submit_vars["submit"] = "Login !";

$snoopy->submit($submit_url,$submit_vars);
print $snoopy->results;


?>


Much easier...

4
mikeh
Re: Posting to remote site - code debug?
  • 2005/9/22 8:55

  • mikeh

  • Just popping in

  • Posts: 70

  • Since: 2002/1/18


wondering about the security aspects of using the smarty class as above to login on the same server
anyone advise ???
...

5
mikeh
Re: Posting to remote site - code debug?
  • 2005/9/22 20:55

  • mikeh

  • Just popping in

  • Posts: 70

  • Since: 2002/1/18


of course meant the snoopy class
having problems with it anyway

any suggestions
...

Login

Who's Online

80 user(s) are online (53 user(s) are browsing Support Forums)


Members: 0


Guests: 80


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits