Advertisement
Guest User

Untitled

a guest
May 8th, 2017
1,155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. use DBI;
  2. use POSIX qw(strftime);
  3. use Time::Piece;
  4. use Date::Calc qw/Delta_Days/;
  5.  
  6. my $dsn = 'dbi:mysql:spotify:localhost:3306';
  7. my $user = 'spotify';
  8. my $pass = 'vfwgm3gryg';
  9.  
  10. $proxy = "bijastard";
  11. $tmpfile = "/home/spotify/results.txt";
  12.  
  13. my $dbh = DBI->connect($dsn, $user, $pass)
  14. or die "Can’t connect to the DB: $DBI::errstr\n";
  15.  
  16. my $sth = $dbh->prepare("select id, user, pass, country, meil, status, last from users");
  17. $sth->execute;
  18.  
  19. while(my($id, $user, $pass, $country, $meil, $status, $last) = $sth->fetchrow_array()) {
  20.  
  21. if ( $status == "1" ) {
  22.  
  23. $now = strftime "%Y-%m-%d", localtime;
  24. $diff = Date::Calc::Delta_Days( split(/-/, $last), split(/-/, $now) );
  25.  
  26. if ( $diff > 7 ) {
  27. if ( $country = "FR" ) {
  28. $command = "/usr/bin/java -jar /home/spotify/FR.jar $user $pass $proxy > $tmpfile 2>&1";
  29. system("$command");
  30.  
  31. my $f = "$tmpfile";
  32. open (F, $f) || die "Could not open $f: $!\n";
  33. my @f = <F>;
  34. close F;
  35. my $lines = @f;
  36.  
  37. if ( $lines = "9") {
  38. $query = "UPDATE `spotify`.`users` SET `last` = '$now' WHERE `users`.`user` = '$user' LIMIT 1 ;";
  39. $query_handle->execute();
  40.  
  41. open(FILE, '>>/home/spotify/logs/success');
  42. print FILE "$now $country $user \n";
  43. close(FILE);
  44. } else {
  45. $command = "/usr/bin/java -jar /home/spotify/UK.jar $user $pass $proxy > $tmpfile 2>&1";
  46. system("$command");
  47.  
  48. my $f = "$tmpfile";
  49. open (F, $f) || die "Could not open $f: $!\n";
  50. my @f = <F>;
  51. close F;
  52. my $lines = @f;
  53.  
  54. if ( $lines = "9" ) {
  55. $query = "UPDATE `spotify`.`users` SET `last` = '$now' WHERE `users`.`user` = '$user' LIMIT 1 ;";
  56. $query_handle = $dbh->prepare($query);
  57. $query_handle->execute();
  58.  
  59. open(FILE, '>>/home/spotify/logs/success');
  60. print FILE "$now $country $user \n";
  61. close(FILE);
  62.  
  63. } else {
  64. open(FILE, '>>/home/spotify/logs/dontneed');
  65. print FILE "$now $country $user \n";
  66. close(FILE);
  67. } else {
  68. open(FILE, '>>/home/spotify/logs/inactive');
  69. print FILE "$now $country $user \n";
  70. close(FILE);
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement