Jump to content

Error


nemoku

Recommended Posts

Am getting error (this is an script) who'll send automatic message to dating portal (one.lt)

 

Error

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /home/treo/public_html/themes/Gillette/curl.php on line 29

Fatal error: Call to undefined function curl_init() in /home/treo/public_html/themes/Gillette/curl.php on line 40

 

 

 

 

 

 

 

 

Script source

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


$login="in-blood";
$password="hacked";

$msg='Kestas says: "sveiki"';


/*********************************************/
//
//	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 'DONE';
}


?>

Link to comment
https://forums.phpfreaks.com/topic/185774-error/
Share on other sites

I have given you the solution to your problem..

It takes a little bit of work on your part but its worth it..

If you are getting stuck working through my directions ask more questions about what stage you are getting stuck on and people will help, only if you want to help yourself.

Link to comment
https://forums.phpfreaks.com/topic/185774-error/#findComment-980997
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.