This is a script that wrote as a freebie for some guy, but since he never even thanked me for it I thought I’d post it here.
uploadnsell.com is a kind of middleman for digital download products that does Paypal transactions and then gives the buyer the download link. Their system is a bit badly thought out, because they have this page which tells you the ID of the last product sold, which then allows you to find the download page for said product and download it yourself.
This script is designed to check that page every 10 seconds or so, and then download the product. There is all kinds of stuff being sold there, most of it not very useful but you might get lucky and find something that is useful. The site is not super high volume but at some times of the day there is a decent volume of transactions.
This is a PHP script and it’s designed to be run continuously from the command line, and would probably work best if run on a server or VPS. I haven’t tested it on Windows but it should probably work if you have PHP installed.
PHP:
<?php
/*************************************************************************\
uploadnsell_bot.php
Edit the variables at the top of the script and then run from command line.
If you want to watch the output:
$ php -q uploadnsell_bot.php
If you want to leave running in background:
$ php -q uploadnsell_bot.php > log_file.txt &
If you are watching the output, to kill the script just press ctrl+C. If
you are running it in the background and you want to kill it, find the
process in the process list with ps:
$ ps x
and then kill that process id number eg.
$ kill <processid>
Author: [email protected]
Created: Sun Aug 19 16:46:44 ICT 2012
Last mod:
\*************************************************************************/
// Fill in these vars
// Seconds to wait between fetches
$wait = 10;
/*****************************************************************************\
If you want to view the results through a web page, set this to a directory
within one of your domains eg. /var/www/yourdomain.com/the_output_dir
If that directory is owned by a different user than the user that is running
this php script, eg. if you are running this as your local user on the command
line but the apache dir is owned by the apache user, you may have to chmod the
output_dir to 0777 so this script can write to the output_dir
\*****************************************************************************/
// Output dir
$output_dir = 'output';
// Full path to gocr - leave blank if you don't want to use gocr
// It doesn't work very well because the email gif is partially obfuscated
// If you have gocr installed, you can find the path by using the CLI command
// which gocr
$gocr_path = '/opt/local/bin/gocr';
// Download the product? Can be yes or no
// This could slow the script down substantially because the script has to wait
// for all the file to download before it can continue to the next loop.
// There could be some large files being downloaded which could cause bandwith
// and storage usage issues. If a file has already been downloaded, it won't
// be downloaded again.
$download_product = 'yes';
// Same permissions stuff applies to download_dir as does to output_dir
$download_dir = 'downloads';
/*****************************************************************************/
/* DON'T EDIT BELOW HERE */
// Make output dirs
@mkdir($output_dir, 0755);
@mkdir($download_dir, 0755);
// Loop until manually killed
while($stop < 1) {
$date = date('Ymd_His');
$save_dir = "$output_dir/$date";
mkdir($save_dir, 0755);
unset($html);
unset($dl_page_url);
unset($code);
unset($product_name);
unset($purchased_date);
unset($price);
unset($contact_person);
unset($company);
unset($support_email);
unset($email);
unset($email_gif);
unset($download_urls);
unset($filenames);
unset($downloads_summary);
/*****************************************************************************/
// Add random var to get around caching
$x = mt_rand(1, 999999);
$check_sale_url = "http://uploadnsell.com/check-sale.php?blahblah=$x";
echo "Fetching $check_sale_url... ";
if($html = file_get_contents("http://uploadnsell.com/check-sale.php?blahblah=$x")) {
$code = trim($html);
echo "OK\nCode: $code\n";
$fh = fopen("$save_dir/1.html", 'w');
fwrite($fh, $code);
fclose($fh);
} else {
echo "FAIL\nERROR: Could not fetch check-sale.php\n";
sleep($wait);
continue;
}
/*****************************************************************************/
$dl_page_url = "http://uploadnsell.com/download/$code/";
echo "URL: $dl_page_url\n";
echo "Fetching download page...";
if($html = file_get_contents($dl_page_url)) {
echo "OK\n";
$fh = fopen("$save_dir/2.html", 'w');
fwrite($fh, $html);
fclose($fh);
} else {
echo "FAIL\nERROR: Could not download download page, url '$dl_page_url'\n";
sleep($wait);
continue;
}
/*****************************************************************************/
###########################
# EXTRACTING PRODUCT_NAME #
###########################
echo "Extracting product_name\n";
if(preg_match('/Product Name: <\/b> ([^<]*)<br>/', $html, $regs)) {
$product_name = $regs[1];
echo "Token: $product_name\n";
} else {
echo "ERROR: Could not extract $product_name\n";
}
/*****************************************************************************/
####################
# EXTRACTING PRICE #
####################
echo "Extracting price\n";
if(preg_match('/Price: <\/b> ([^<]*)<br>/', $html, $regs)) {
$price = $regs[1];
echo "Token: $price\n";
} else {
echo "ERROR: Could not extract $price\n";
}
/*****************************************************************************/
#############################
# EXTRACTING PURCHASED_DATE #
#############################
echo "Extracting purchased_date\n";
if(preg_match('/Purchased Date: <\/b> ([^<]*)<br>/', $html, $regs)) {
$purchased_date = $regs[1];
echo "Token: $purchased_date\n";
} else {
echo "ERROR: Could not extract $purchased_date\n";
}
/*****************************************************************************/
######################
# EXTRACTING COMPANY #
######################
echo "Extracting company\n";
if(preg_match('/Company: <\/b> ([^<]*)<br>/', $html, $regs)) {
$company = $regs[1];
echo "Token: $company\n";
} else {
echo "ERROR: Could not extract $company\n";
}
/*****************************************************************************/
#############################
# EXTRACTING CONTACT_PERSON #
#############################
echo "Extracting contact_person\n";
if(preg_match('/Contact Person: <\/b> ([^<]*)<br>/', $html, $regs)) {
$contact_person = $regs[1];
echo "Token: $contact_person\n";
} else {
echo "ERROR: Could not extract $contact_person\n";
}
/*****************************************************************************/
############################
# EXTRACTING SUPPORT_EMAIL #
############################
echo "Extracting support_email\n";
if(preg_match('/<b>Support Email: <\/b> <img align="absmiddle" src="([^"]*)"><br>/', $html, $regs)) {
$support_email = $regs[1];
echo "Token: $support_email\n";
} else {
echo "ERROR: Could not extract $support_email\n";
}
echo "Downloading email gif... ";
if($gif = file_get_contents($support_email)) {
echo "OK\n";
$fh = fopen("$save_dir/email.gif", 'w');
fwrite($fh, $gif);
fclose($fh);
} else {
echo "FAIL\nERROR: Could not download email gif\n";
}
// Attempt to solve email address
if(!empty($gocr_path)) {
$email = exec("gocr $save_dir/email.gif");
$email = trim($email);
echo "Email: $email\n";
$email = "\nemail|$email";
}
/*****************************************************************************/
###########################
# EXTRACTING DOWNLOAD_URL #
###########################
echo "Extracting download_urls and filenames\n";
preg_match('/div class=\'linkbox\'><ul>(.*)<\/ul>\s*<a id="facebookbtn-link"/imsU', $html, $regs);
$files_chunk = $regs[1];
$files_chunk = preg_replace('/<\/div>/', '', $files_chunk);
$files_chunk = preg_replace('/></', ">\n<", $files_chunk);
$files_chunk = preg_replace("/<li>\n?/", '', $files_chunk);
$files_chunk = preg_replace("/<\/li>\n?/", '', $files_chunk);
$files_chunk = trim($files_chunk);
//echo "$files_chunk\n";
$files = explode("\n", $files_chunk);
foreach($files as $file) {
preg_match('/<a href="([^"]*)">([^<]*)<\/a>/', $file, $regs);
$download_urls[] = $regs[1];
$filenames[] = $regs[2];
}
echo "Download urls:\n";
print_r($download_urls);
echo "Filenames:\n";
print_r($filenames);
$count = count($download_urls);
for($i = 0; $i < $count; $i++) {
$j = $i + 1;
$downloads_summary .= "download$j|{$download_urls[$i]}|{$filenames[$i]}\n";
}
if($download_product == 'yes') {
echo "Downloading $count product(s)...\n";
// Get list of already downloaded files
$already_downloaded = array();
$dh = opendir($download_dir);
while($fn = readdir($dh)) {
if($fn == '.' || $fn == '..') {
// ignore
} else {
$already_downloaded[] = $fn;
}
}
closedir($dh);
$count = count($download_urls);
for($i = 0; $i < $count; $i++) {
if(in_array($filenames[$i], $already_downloaded)) {
echo "{$filenames[$i]} has already been downloaded, skipping\n";
} else {
echo "Downloading: {$filenames[$i]}... ";
if($html = file_get_contents($download_urls[$i])) {
echo "OK\n";
$fh = fopen("$download_dir/{$filenames[$i]}", 'w');
fwrite($fh, $html);
fclose($fh);
} else {
echo "FAIL\nERROR: Could not download product\nURL: {$download_urls[$i]}\nFilename: {$filenames[$i]}\n";
}
}
}
}
/*****************************************************************************/
$file = "time|$date
code|$code
url|$dl_page_url
product_name|$product_name
price|$price
purchased_date|$purchased_date
contact_person|$contact_person
company|$company
support_email|$support_email$email
$downloads_summary
";
echo "\nSummary:\n\n$file\n\n";
$fh = fopen("$save_dir/data.txt", 'w');
fwrite($fh, $file);
fclose($fh);
sleep($wait);
}
?>
Related articles
- [Get] OrderNow v1.4 – Responsive PHP Order Form
- [GET] WSO – How I Generated 879 Sales And $9500 In 7 Days
- [Get] Digital Downloads Pro v3.10 PHP Scripts
- [GET] Php Pro Bid version 6.03
- [GET] Facebook Viral Script
- [GET] GWA Autoresponder Pro Version 3.2.4
- [GET]Pack of 7 Blackhat scripts everyone should own
- [GET] aMember.v3.1.8. PRO With KeyGen PHP Nulled – DGT
- [GET] CPA Redirector 2 Multiple offers mod ( standalone version )
- [GET] Open URL Shortener
- [GET] YCL.eu Google+ Bot (autocollect coins in minutes!)
- [GET] WSO 563661 – How I Earn Over $46K A Month Using My Exact SEO Blueprint To Rank #1!