Thread: Autosquirt script
Basil

Hello ,

This script is driving me crazy.

It is used to autosquirt urls in Robs-tool

This is the code:
<?

php

 
/**
* Brought to you by http://www.oofff.com for scraping and form filling

tutor

 ials
* in

php

 .
*
* This software is subject to the Link License Agreement (tm).For use of this
* script you agree to giving a backlink from your BEST domain or a blog
* post on your best blog about http://www.OOOFF.com. Requested anchor text
* for links "

php

 

tutor

 ials", "

php

  scraping

tutor

 ials", "

php

  form filling

tutor

 ials"
*
*
* For any suggestions on what can be improved please email fishoff@tobad.com
*
*
* This is meant for Eli's SQUIRT submission tool (http://squirt.robstool.com)
* if you are a memeber and hate manually adding your url's everyday this script
* combined with the lazy mans friend, cron, will automate that for you.
*
* You want to copy these files in this zip to your server and set the files
* writable that it tells you to in the section below. Enter your url's into
* the urllist file in this format.
*
* http://www.url1.com,keyword1,keyword2,keyword3
* http://www.url2.com,keyword1,keyword2,keyword3
*
* In this script set the variables at the top. If you keep the same structure in the
* zip file you should just have to set your LOCATION of the directory where the script
* is located. Then set your password and login.
*
*
*
* Set these variables
*/

define('LOCATION',"/usr/bin/

php

  /home/username/public_html/squirt/squirtsubmitter.

php

 "); //base location for you script, we need our locations to be fully qualified as we're going to run this from cron
$username = "username"; //login for squirt
$password = "pass"; //password for squirt
$limit = 10; //this is the number of submissions you're allowed to do a day
$wait_time = 60; //this is the wait time between submissions as not to overload Eli's server
$urllist = LOCATION."/home/username/public_html/squirt/urllist.txt"; // location of you list of url with keywords see formating - MAKE SURE THIS IS WRITABLE
$senturls = LOCATION."/home/username/public_html/squirt/senturls.txt"; // location for the url's you have already submitted, backup - MAKE SURE THIS IS WRITABLE
$cookie_location = LOCATION.'/home/username/public_html/squirt/tmp/cookie.txt'; // make sure this file exisits on your server and is writable


/////////////////// Internals - Don't look here this stuff is secret/////////////////////////////

set_time_limit(0);
$last_urls_flag = null; //this is the flag that says to empty the urllist file
$urls = file($urllist); // opens the file and then loads each line into an array


//checks if you have less then the max urls and assigns that to the number to work on.
if(count($urls) < $limit){
$limit = count($urls);
$last_urls_flag = 1;
}

echo "As you now begin questioning your sexuality....homo!<br>Ask yourself am I gay?<br>If you're a member of wickedfire.com the answer is probably a resounding, YES!<br>Here we go.......<br>";flush();
if($limit < 1){

echo "Hey douche bag, you forgot to put url's in your list!<br>";

}else{

$login_result = Login($username,$password,$cookie_location); // calls the function below to log into squirt
if(!$login_result){ //checks if logged in ok

die("Couldn't login!<br>Check you login and password is set right?<br>Applauseo you have a fully qualified path to the location of your cookie file?<br>Is the Directory writable?");

}else{

echo "Logged In!<br>";flush();
for($i = 0; $i < $limit; $i++){

$line = $urls[$i]; // access the element of your url array
$line_parts = explode(",",$line); // splits the line from the urllist.txt into an array

// these assign the parts fo the array we just split to variables and trims off any whitespace
$url = trim($line_parts[0]);
$keyword1 = trim($line_parts[1]);
$keyword2 = trim($line_parts[2]);
$keyword3 = trim($line_parts[3]);

//this calls thr function below to submit you url with keywords

$submit_result = submitUrl($url,$keyword1,$keyword2,$keyword3,$cookie_location);
if(!isset($submit_result)){
die('Couldn't submit for some reason, looks like you need to

learn

  to debug code Applause');
}
echo "$url submitted.<br>";flush();
sleep($wait_time); // pause between submits
}

//gets the url's you just submitted running the script and puts them in a file for backup
$submitted_urls = array_slice($urls,0,$limit);
echo "Writing $senturls<br>";flush();
foreach($submitted_urls as $line){
file_put_contents($senturls,$line,FILE_APPEND);
}

//puts the remain urls that haven't been sent back in to the urllist file for next time
$remaining_urls = array_slice($urls,$limit);
echo "Writing $urllist<br>";flush();
if(!isset($last_urls_flag)){
foreach ($remaining_urls as $line){
file_put_contents($urllist,$line);
}
}else{
file_put_contents($urllist,''); // blanks out the file
}

}
echo "Now go get Bent, Bitches!";flush();

}

function curl($url,$cookie_location,$cookie = 1,$post = null){

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_location);
if($cookie == 0){
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_location);
}else{
curl_setopt($ch, CURLOPT_COOKIE,$cookie_location);
}
if (isset($post)){
curl_setopt($ch, CURLOPT_POST, $post);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$c_out = curl_exec($ch);
curl_close($ch);

return $c_out;

}
function Login($username,$password,$cookie){

$url = "http://squirt.robstool.com/cgi-bin/log.pl";
$post = "logging_in=true&login=".urlencode($username)."&password=".urlencode($password);

$page = curl($url,$cookie,0,$post);

$

regex

  = "/panel/";
if(preg_match($

regex

 ,$page)){
return 1;
}
}
function submitUrl($url,$keyword1,$keyword2,$keyword3,$cookie){

$url = "http://squirt.robstool.com/panel";
$post = "mod=doaddsubmission&url=".urlencode($url)."&keyword1=".urlencode($keyword1)."&keyword2=".urlencode($keyword2)."&keyword3=".urlencode($keyword3);

$page = curl($url,$cookie,1,$post);

$

regex

  = "/Estimated

SEO

  Rating/";
if(preg_match($

regex

 ,$page)){
return 1;
}

}

?>






I get the follwing error code:

Warning: file(/usr/bin/

php

  /home/username/public_html/squirt/squirtsubmitter.

php

 /home/username/public_html/squirt/urllist.txt) [function.file]: failed to open stream: No such file or directory in /home/username/public_html/squirt/squirtsubmitter.

php

  on line 49
As you now begin questioning your sexuality....homo!
Ask yourself am I gay?
If you're a member of wickedfire.com the answer is probably a resounding, YES!
Here we go.......
Logged In!
Couldn't submit for some reason, looks like you need to

learn

  to debug code Smiley

As you understand this dude is calling me homo for two days now and he doesn't submit my urls 
Do you see any errors in the code?

I have curl enabled in my server.

The script with other usefull scripts and ideas is located for free in: http://www.oooff.com/scripts/squirt/squirt-submitter-tool.

php

 

Any ideas ?

p.s Perkiset I love the color of your template !

perkiset

Hey Basil -

The very first line that defines the constant LOCATION needs to be a fully qualified path to <that

mac

 hine's> instance of

PHP

  followed by a space then followed by the <name of this script> as it is on your

mac

 hine.

To test this, you should be able to "copy" that line and execute it in the shell by hand - my guess is that if you do that you'll get a shell error because it does not exist. This might also be a privileges error, but that is less likely.

Does that make sense? Hope so, it is a bit confusing...

/p

Basil

Hello Perkiset,
Thank you for helping ,I am enter in the deep waters now:

-The very first line that defines the constant LOCATION:

me:/usr/bin/

php

  /home/username/public_html/squirt/squirtsubmitter.

php

 


-needs to be a fully qualified path to <that

mac

 hine's> instance of

PHP

  (you mean the specific version of

php

   Applause)
followed by a space(where I must put a space ?) then followed by the <name of this script> as it is on your

mac

 hine.

To test this, you should be able to "copy" that line and execute it in the shell by hand (I don't know how to do that! I don't know what do you mean shell and how I enter in the shell mode ! Applause )- my guess is that if you do that you'll get a shell error because it does not exist. This might also be a privileges error, but that is less likely(if you mean permissions I have change all in 777).
The whole program is the script and two txt files.In one file you enter the links you want to program automatic submission with the cron job and the other txt file is for "deposit" the already submitted urls.
So if you have 500 urls when the cron job runs it submits 10 ,puts the ten urls to the already submitted txt and leaves the warehouse of urls with 490 urls.
Thank you very much for your patience  Applause

perkiset

Ahhh... you're not an SSH kind of guy, are you?

Here's what I meant - on a

Linux

  box (which is most likely where your script is sitting) you can use SSH (Secure Shell) to log on to the box at what looks like a DOS prompt. The line in the LOCATION constant is actually a command - it says "Use the

php

  interpreter at /usr/local/bin/

php

  to execute the script at /home/baz..." etc. What I was saying was to drop down to a shell and try to execute that command by hand - at the prompt you would type in the exact command that you see in the LOCATION variable. It would either run... or fail. My guess is that it would fail, meaning that the script file name is not correct - in other words, the LOCATION variable is not pointing to the real file name of the script - that's basically what that error message says.

I hope that I have not been condecending in this post - I don't know what your level of experience with

Linux

  is.

/p

Basil


Hello,

I have imagine that you meant that but ,I have never done it, the script is in a reseller account where I don't think I have this kind of access.On the vps where is this kind of button I have entered, saw unknown terminology,they asked my driver license and I stepped out. Applause

I am suspecting too that my path is wrong.How I can check, or be sure what is the correct path from cpanel?
Is there any way?

I have entered the http://www.yourdomain.com/mysetup.

php

  but everything seems ok.

An other way to run it manually is to type in the browser www.mydomain.com/autosquirt/squirtsubmitter.

php

 

I receive the same message  Applause

perkiset

Without terminal access it's a little more tricky.

I think with a GUI FTP program you may get to see the the entire file path... I am not sure. But perhaps you can use something like that to try to "find" the file and its relationship to the file system.

More tricky, is to upload some

PHP

  scripts that will simply tell you about the directory that <it> is in... although as I'm typing this I'm thinking that a VERY UNSECURE but workable solution would be to create a little web page that allows you to post a string ... then

PHP

  will "execute" that string as

PHP

  code. This is MONUMENTALLY dangerous for you to leave on the box, but if you were to put something up there you could execute some commands like "echo shellexec('pwd')" which would return the present working directory that the

PHP

  interpreter is operating from. Given a little webpage like that, you could just about interrogate anything about your

mac

 hine.

Did I tell you that leaving a page like that on your system was dangerous?  Applause

Good luck Bas... also - you might see if SSH access is available on that

mac

 hine - some hosts simply charge you a little more for it. This might be a worthy charge for you to have. If not, then creating yourself a little suite of apps that mimic that capability would be great to have in your toolbox...

/p

joost

Hi Basil

just make a file info.

php

  with this in it:


<?

php

 

php

 info();
?>

and call it with your browser.
Then find document_root, there should be your full server path.


Perkiset's Place Home   Politics @ Perkiset's