Jump to content

:) Changing


nemoku

Recommended Posts

Hey :)

 

Am almost fixed script :)) Can someone help a bit? How to make changing account? Script taking account now from accounts.txt

 

Thanks. :)

 

<?php
/*********************************************/
//
//  CONFIG
//
/*********************************************/
/*********************************************/
$startPage=1;
$lastPage=12;

$file = file('accounts.txt');
$delimiter = ';';


foreach ($file as $pair)
{
list($login, $password) = explode($delimiter, trim($pair));

$msg='Labas';


/*********************************************/
//
//   END OF CONFIG
//
/*********************************************/
/*********************************************/




//DON"T EDIT ANYTHING BELOW
set_time_limit(120);
class Bot{


/*
**
** LOGIN
**
*/
function Login($login,$password)
  {
  $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL,'http://w31.one.lt/logon.do');
         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
   curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS,'username='.$login.'&password='.$password.'');
  curl_setopt($ch, CURLOPT_REFERER, 'http://w31.one.lt');
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/tmp.txt');
         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/tmp.txt');
  $site = curl_exec ($ch);

  if (curl_errno($ch))
   {
       $error = 'Error #' . curl_errno($ch) . ': ' . curl_error($ch);
       return false;
       echo $error;
       }
      else
       {
   return true;
   }

  curl_close ($ch);
  }


/*
**
** LOGOUT
**
*/
function Logout()
  {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,'http://w31.one.lt/logoff.do');
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/tmp.txt');
         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/tmp.txt');
  $site = curl_exec ($ch);
  
  if (curl_errno($ch))
   {
       $error = 'Error #' . curl_errno($ch) . ': ' . curl_error($ch);
       return false;
       echo $error;
       }
      else
       {
   //echo $site;
   return true;
       }
  curl_close ($ch);
  }





/*
**
** SendMSG
**
*/
function SendMsg($profile,$msg)
  {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,'http://w31.one.lt/saveCommentaryMessage.do');
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
  curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS,'forUserId='.$profile.'&msg='.$msg.'');
  curl_setopt($ch, CURLOPT_REFERER, 'http://w31.one.lt/');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

  curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/tmp.txt');
         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/tmp.txt');


  $site = curl_exec ($ch);

  if (curl_errno($ch))
   {
       $error = 'Error #' . curl_errno($ch) . ': ' . curl_error($ch);
       return false;
       echo $error;
       }
      else
       {
   return true;
   }
  
  curl_close ($ch);
  }



/*
**
** Get Profiles
**
*/
function GetProfiles($page)
  {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,'http://w31.one.lt/navigate.do?st.view=4&st.id=community.distantfriends.list&st.friends.page='.$page.'');
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/tmp.txt');
         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/tmp.txt');
  $site = curl_exec ($ch);
  
  if (curl_errno($ch))
   {
       $error = 'Error #' . curl_errno($ch) . ': ' . curl_error($ch);
       return false;
       echo $error;
       }
      else
       {
   //echo $site;
   return $site;
       }
  curl_close ($ch);
  }
}//end of class







$nextPage=$_GET['p'];
if($nextPage)
{$p=$nextPage;}
else
{$p=$startPage;}



if($p<=$lastPage)
{

$bot=new Bot();
$bot->Login($login,$password);

$src=$bot->GetProfiles($p);

$dom = new DomDocument;
@$dom->loadHTML($src);
$xpath = new DOMXPath($dom);
$profs = $xpath->evaluate('//div');
for ($i = 0; $i  < $profs->length; $i++)
{
$prof = $profs->item($i);
$class = $prof->getAttribute('class');
$id = $prof->getAttribute('uid');
if($class=='photoW ' && $id!='')
  {
  echo "http://w31.one.lt/navigate.do?st.id=community.friendcommentary.page&st.friend=$id";
  echo "<br>";
  //echo $id.' ['.$j++.']<br>';
  $bot->SendMsg($id,$msg);
  }
}




$bot->Logout();
echo '<meta http-equiv="refresh" content="0;url=?p='.++$p.'">';
}
else
{
echo 'Baikta ';
}


}

 

Link to comment
Share on other sites

How to make changing account?

 

If you want the accounts to be stored in a mysql database, you need to setup a database portion.

Check out some MySQL-PHP tutorials on google for a quick overview.

 

If you have any problems following the tutorials or coding your own part then let us know ;).

 

Thing is you need to know about MySQL if you want to use it, and there are plenty of tutorials out there that will save both of us time ;).

 

-CB-

Link to comment
Share on other sites

You want to login/logout and create accounts?

 

So you need to make these 3 functions. For your level i would suggest seperate files:

 

login.php

<?php

[b]// Check if logging in:[/b]
if(isset($_POST['login_name'])){
   // login
   
   // Grab File (accounts.txt)
   
   // Explode Data (Get each individual User/Pass)
   
   // Check if the user/pass exists.
   
   // If it does, then set a cookie or use sessions to store the data.
   
   // redirect to some other page
}

// otherwise.

// Display login form.

?>

 

register.php

<?php
   
   // Check if registering
   if(isset($_POST['register_name'])){
      // Santize Variables (Make sure it is safe to use them/Display them)
      
      // Check if the email or username already exists in the accounts.txt file.

      // If it doesn't then add the account to the list and redirect to login.php
   }

// otherwise

// Display the registration form.
   
?>

logout.php

<?php

// Delete cookies or sessions, redirect to another page, or login.php

?>

 

That is the basic logic of multiple user logins.

 

To change your code, you will have to check your logic on your page, as just adding the necessary parts could change your script logic in a way that would be easier to rewrite the whole thing.

 

You may be able to get away with just adding a "register_user" function, and changing your login function to accomadate multiple users.

 

IMHO, i would rewrite the whole thing (would be much quicker and easier).

 

-CB-

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.