#!/usr/bin/perl
use DBI;
@data = `/usr/bin/curl http://www.kickstarter.com/projects/inxile/wasteland-2 2> /dev/null | grep class=\\\"num `;
$dbh = DBI->connect('DBI:mysql:**DB_NAME**', '**USERID**', '**PASSWORD**'
) || die "Could not connect to database: $DBI::errstr";
$backers = $data[0];
$backers =~ s/\
|\<\/div\>|\n|\,|\$//g;
$money = $data[1];
$money =~ s/\
|\<\/div\>|\n|\,|\$//g;
$sql = "INSERT INTO wastelands (backers, money) VALUES ($backers, $money)";
$sth = $dbh->prepare($sql);
$sth->execute();
$dir = "/home/ruinedkingdoms/public_html/wasteland2";
system("/usr/bin/php $dir/makechart.php 2>/dev/null > $dir/current.png");
system("/usr/bin/php $dir/public_chart.php hours 8 total > $dir/last8.png");
system("/usr/bin/php $dir/public_chart.php days 8 total> $dir/last8days.png");
system("/usr/bin/php $dir/public_chart.php hours 8 diff > $dir/last8diff.png");
system("/usr/bin/php $dir/public_chart.php days 8 diff> $dir/last8daysdiff.png");