1

Please help, i spent 3 days now for solving of this problem. I try get authorization and show after page like "/index.php?page=xml", but I get only login page, some cookies saved to local server.

Here is PHP curl code:

    <?php

$login = 'XX';
$password = 'XX';
$site = 'http://site';

$cookies = dirname(__FILE__) . '/cookies.txt';

$automatic = curl_init();

curl_setopt($automatic, CURLOPT_USERAGENT, $user_agent);
curl_setopt($automatic, CURLOPT_REFERER, "http://google.com/");
curl_setopt($automatic, CURLOPT_TIMEOUT, 10);

curl_setopt($automatic, CURLOPT_URL, $site . '/index.php?page=index');


curl_setopt($automatic, CURLOPT_RETURNTRANSFER, true);
curl_setopt($automatic, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($automatic, CURLOPT_POST, true);
curl_setopt($automatic, CURLOPT_POSTFIELDS, "user.auth.login=$login&user.auth.pass=$password");

curl_setopt($automatic, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($automatic, CURLOPT_COOKIEJAR, $cookies);

curl_exec($automatic);

curl_setopt($automatic, CURLOPT_URL, $site. '/index.php?page=xml');
$demo = curl_exec($automatic);

curl_close($automatic);

echo $demo;
?>

Cookies.txt:

site FALSE  /   FALSE   1429273488  def.sess.number 2a86dcf7d2a896f323fb2931337efe60

The site form:

<form name=enterform action="/index.php?page=index" method=post>
    <table border=0 cellspacing=0 cellpadding=2 width=740>
        <tr>

            <td valign=bottom bgcolor=#01568D width=80>
                <input type=input maxlength=32 size=9 class="logindata" name="user.auth.login" value="" onKeyDown="return TrapKeyDown(event);" onKeyPress="return TrapKeyPress(event);"><br>
                <input type=password maxlength=32 size=9 class="logindata" name="user.auth.pass" onKeyDown="return TrapKeyDown(event);" onKeyPress="return TrapKeyPress(event);">
            </td>
        </tr>
        <tr>
            <td bgcolor=#01568D height=40 colspan=2 align=right valign=bottom><a href="javascript:document.forms['enterform'].submit();"><font class="startbuttons">LOGIN</font></a>&nbsp;</td>
</tr>
    </table>
    </form>

Whagt I do wrong?

user2421781
  • 399
  • 2
  • 5
  • 16
  • session number in cookies can change from login to login – Nikos M. Apr 17 '15 at 08:39
  • Could you explain more? – user2421781 Apr 17 '15 at 08:46
  • i think session number is created per user login and it might have expired when calling the curl script so it will be invalid – Nikos M. Apr 17 '15 at 08:48
  • Now i undestood, but don't know how it can be fixed by code :( – user2421781 Apr 17 '15 at 08:51
  • Are you sure the expected `$_POST` keys are with dots? If so, they will be converted to underscores: `user.auth.login` becomes `user_auth_login` on the receiving end. Looks like there is no way around it: http://stackoverflow.com/questions/68651/get-php-to-stop-replacing-characters-in-get-or-post-arrays – n-dru Apr 17 '15 at 08:55
  • Yes, form on remote server is with dots :( but from browser it works – user2421781 Apr 17 '15 at 09:18

0 Answers0