Hello!
Task: fast authorization on the moodle site. Using sockets, tried to transfer the login and password.
<?php $host="localhost"; $url = "localhost/login/index.php"; $data = "username=".urlencode("user")."&password=".urlencode("password"); $fp = fsockopen($host, 80, $errno, $errstr, 10); if ($fp) { $out = "POST /login/index.php HTTP/1.1\n"; $out .= "Host: {$host}\n"; $out .= "Referer: {$url}/\n"; $out .= "User-Agent: firefox\n"; $out .= "Content-Type: application/x-www-form-urlencoded\n"; $out .= "Content-Length: ".strlen($data)."\n\n"; $out .= $data."\n\n"; fputs($fp, $out); while($gets=fgets($fp,2048)) { print $gets; } fclose($fp); } ?>
In the Users section on the site my user appeared. But the problem is that I did not log in.
To solve this problem, I think it is necessary for php to accept cookies from the moodle site and send it to the browser. What do you think?
Thanks for answers.