Login with out noticing

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Tue Nov 01, 2005 12:58 am    Post subject: Login with out noticing Reply with quote

what do you call it when you login without logining

i mean, a simple php that will login to a site then and then go back and noone knows thay have logged in.

like that nochex thing where you can get your account balance by going on to a page and thats all thats their.

i think what you call it thats why this sounds stupid. sorry, but any ideas thanks
_________________
Check It Out... Nochex Classifieds
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Nov 01, 2005 4:27 am    Post subject: Reply with quote

You mean cookies?
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Sat Nov 05, 2005 12:06 am    Post subject: Reply with quote

OK i see i need to set the cookies but how do i get it to do that

here what i have so far

i have a login form to goto a site then it sends them off else where (which i have no control over
but i want to miss that page completely and comeback to my site but with the cookies set in their browser so they can use the content of my site.

i can set all the stuff like name host path etc... but content needs to be set through the page that sends else where[/list]
_________________
Check It Out... Nochex Classifieds
Back to top View user's profile Send private message
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Tue Nov 08, 2005 8:53 pm    Post subject: Reply with quote

i got to this at the moment

Code:

<?php
$useragent = "Mozilla/5.0 Galeon/1.2.6 (Linux i686; U;) Gecko";

set_time_limit(90);

function post_it($datastream, $url) {
   $url = preg_replace('@^https://@i', '', $url);
   $host = substr($url, 0, strpos($url, '/'));
   $uri = strstr($url, '/');

   $reqbody = '';
   foreach($datastream as $key=>$val) {
      if (!empty($reqbody)) {
         $reqbody.= '&';
      }
      $reqbody.= $key.'='.urlencode($val);
   }

   $socket = fsockopen($host, 442, $errno, $errstr);
   if (!$socket) {
      $result['errno'] = $errno;
      $result['errstr'] = $errstr;
      return $result;
   } else {
      $contentlength = strlen($reqbody);
      $reqheader =  "POST $uri HTTP/1.1\r\n"
         ."Host: $host\nUser-Agent: $useragent\r\n"
         ."Content-Type: application/x-www-form-urlencoded\r\n"
         ."Content-Length: $contentlength\r\n\r\n"
         ."$reqbody\r\n";
      fputs($socket, $reqheader);
      while (!feof($socket)) {
         $result[] = fgets($socket, 4096);
      }
      return $result;
   }
}

if ($_POST['jb'] == 'sports') {
   $data['USERID']      = $_POST['USERID'];
   $data['PASSWORD']     = $_POST['PASSWORD'];
}

$result = post_it($data, 'https://a.site.net/a.something.com/cgi/login.cgi');
if (isset ($result['errno'])) {
   $errno = $result['errno'];
   $errstr = $result['errstr'];
   echo "<b>Error $errno</b> $errstr";
   exit;
} else {
   for ($i = 0; $i< count($result); $i++) {
      echo $result[$i];
   }
}
?>


but it keeps bringing up error 500,

this script is the php2sms with a few changes please some help needed badly
_________________
Check It Out... Nochex Classifieds
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Tue Nov 08, 2005 10:54 pm    Post subject: Reply with quote

Google libcurl, should be an easier way of doing what you're after.
Libcurl in the php module form you're after, should come prepackaged with PHP4, and available for download of php.net for php5 as part of the pecl modules.

Code:
function contact($url, $postdata) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)");
  if ($postdata !== "") {
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
  } else
    curl_setopt($ch, CURLOPT_POST, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_COOKIEFILE, "jar.cookie");
  curl_setopt($ch, CURLOPT_COOKIEJAR, "jar.cookie");
  $result = curl_exec ($ch);
  curl_close ($ch);
  return $result;
}
/* Usage: contact("http://monkeynation.org", "username=Dave&password=pr0n"); */

Should work okay with the module enabled.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Wed Nov 09, 2005 12:46 am    Post subject: Reply with quote

heres what i have now but i keep getting error 500 im using php 4 with curl on

Code:

<?php
error_reporting(E_ALL);

$url = "https://wgsportsbook.worldgaming.net/www.sportsbetting.com/cgi_bin/sb23login.cgi";

if (empty($_POST['jb']) && empty($_POST['USERID']) && empty($_POST['PASSWORD'])){
       echo "
<form action=\"index.php\" method=\"post\">
<input type=\"hidden\" name=\"jb\" value=\"sports\">
<input name=\"USERID\" type=text size=8><br>
<input name=\"PASSWORD\" type=\"password\" size=8><br>
<input type=\"submit\" value=\"submit\"><br>";
}

else{   
   if ($_POST['jb'] == 'sports') {
   $params = "USERID=".$_POST['USERID']."&PASSWORD=".urldecode($_POST['PASSWORD']);
   $count = login($url,$params);
}

//
function login($url,$params){   
   $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
 
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt ($ch, CURLOPT_HEADER, 0);
   curl_setopt($ch, CURLOPT_POST,1);
   curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
   curl_setopt($ch, CURLOPT_URL,$url);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
   curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
     }
   curl_close ($ch);
   return $cnt;
}
?>


this time i left the site wicth i want users to goto but stay on my site.
_________________
Check It Out... Nochex Classifieds
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Nov 09, 2005 9:01 am    Post subject: Reply with quote

mtbiking,

Enable PHP to log errors and have a look on log/cgi.log to know what is going wrong with PHP startup.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
mtbiking
-


Joined: 18 Mar 2004
Posts: 66

PostPosted: Sun Nov 13, 2005 11:39 am    Post subject: Reply with quote

this is all thast comes up ing log/cgi.log


Quote:
CGI: [C:\PHP\php.exe ] URI: /index.php Broken pipe


im now uninstalling it and reinstalling it to see if i installed it wrong then later on try it on the linux box
_________________
Check It Out... Nochex Classifieds
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Nov 14, 2005 10:13 am    Post subject: Reply with quote

mtbiking,

Is PHP running fine? Try using a small script such as:

Code:
<?php
phpinfo();
?>


If the error persists, please check your PHP setup and especially if there is a DLL or extensions problem. You may also be using php.exe instead of php-cgi.exe.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group