Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use DBI;
- use POSIX qw(strftime);
- use Time::Piece;
- use Date::Calc qw/Delta_Days/;
- my $dsn = 'dbi:mysql:spotify:localhost:3306';
- my $user = 'spotify';
- my $pass = 'vfwgm3gryg';
- $proxy = "bijastard";
- $tmpfile = "/home/spotify/results.txt";
- my $dbh = DBI->connect($dsn, $user, $pass)
- or die "Can’t connect to the DB: $DBI::errstr\n";
- my $sth = $dbh->prepare("select id, user, pass, country, meil, status, last from users");
- $sth->execute;
- while(my($id, $user, $pass, $country, $meil, $status, $last) = $sth->fetchrow_array()) {
- if ( $status == "1" ) {
- $now = strftime "%Y-%m-%d", localtime;
- $diff = Date::Calc::Delta_Days( split(/-/, $last), split(/-/, $now) );
- if ( $diff > 7 ) {
- if ( $country = "FR" ) {
- $command = "/usr/bin/java -jar /home/spotify/FR.jar $user $pass $proxy > $tmpfile 2>&1";
- system("$command");
- my $f = "$tmpfile";
- open (F, $f) || die "Could not open $f: $!\n";
- my @f = <F>;
- close F;
- my $lines = @f;
- if ( $lines = "9") {
- $query = "UPDATE `spotify`.`users` SET `last` = '$now' WHERE `users`.`user` = '$user' LIMIT 1 ;";
- $query_handle->execute();
- open(FILE, '>>/home/spotify/logs/success');
- print FILE "$now $country $user \n";
- close(FILE);
- } else {
- $command = "/usr/bin/java -jar /home/spotify/UK.jar $user $pass $proxy > $tmpfile 2>&1";
- system("$command");
- my $f = "$tmpfile";
- open (F, $f) || die "Could not open $f: $!\n";
- my @f = <F>;
- close F;
- my $lines = @f;
- if ( $lines = "9" ) {
- $query = "UPDATE `spotify`.`users` SET `last` = '$now' WHERE `users`.`user` = '$user' LIMIT 1 ;";
- $query_handle = $dbh->prepare($query);
- $query_handle->execute();
- open(FILE, '>>/home/spotify/logs/success');
- print FILE "$now $country $user \n";
- close(FILE);
- } else {
- open(FILE, '>>/home/spotify/logs/dontneed');
- print FILE "$now $country $user \n";
- close(FILE);
- } else {
- open(FILE, '>>/home/spotify/logs/inactive');
- print FILE "$now $country $user \n";
- close(FILE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement