Charl van Niekerk » Blog

Main

Latest

Archives

Powered by Blogger

ISDSL Stats

I needed a little script just to get the current month's use of my ISDSL account. This is far from a proper script but at least it's a start.

<?php
if (isset($_REQUEST['username']) && isset($_REQUEST['password']) && $_REQUEST['username'] && $_REQUEST['password']) {
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
  curl_setopt($curl, CURLOPT_COOKIEFILE, 'cookie.txt');
  curl_setopt($curl, CURLOPT_URL, 'http://users.isdsl.net/index.php?action=login');
  curl_setopt($curl, CURLOPT_POSTFIELDS, 'UserName=' . urlencode($_REQUEST['username']) . '&Password=' . urlencode($_REQUEST['password']));
  curl_exec($curl);
  curl_setopt($curl, CURLOPT_URL, 'http://users.isdsl.net/loginhistoryuid.php');
  $return = curl_exec($curl);
  curl_close($curl);
  preg_match_all("#<td>[0-9\.]+</td>#i", $return, $r);
  echo trim($r[0][count($r[0])-1], '<>td/');
} else {
  ?>
    <form method="post">
      <p>Username: <input type="text" name="username"></p>
      <p>Password: <input type="password" name="password"></p>
      <p><input type="submit" value="Login"></p>
    </form>
  <?php
}

1 Comments

Comment by Anonymous Arné on Sunday, June 01, 2008 5:55:00 AM

hehe - very nice and simple - u really like your curl stuff ;-)

Post a Comment

Copyright © 2004-2009 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.