This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!

Ego Ticker PHP Change

By: MattRichardson on Jan 16th, 2012  |  syntax: PHP  |  size: 0.66 KB  |  views: 33  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. date_default_timezone_set('America/New_York');
  3. $myFileYesterday = "reddit-" . date("Ymd", time() - 86400). ".txt";
  4. $myFileToday = "reddit-" . date("Ymd"). ".txt";
  5. $fhYesterday = fopen($myFileYesterday, 'r');
  6. $fhToday = fopen($myFileToday, 'r');
  7. $yesterdayScore = fread($fhYesterday, 50);
  8. $todayScore = fread($fhToday, 50);
  9. $change = $todayScore - $yesterdayScore;
  10. if ($change == 0)
  11.         echo "Unch";
  12. if ($change > 0)
  13. {
  14.         echo "+";
  15.         echo $change;
  16.         }
  17. if ($change < 0)
  18. {
  19.         echo $change;
  20. }
  21.  
  22. fclose($fhToday);
  23. fclose($fhYesterday);
  24.  
  25. $checkfile = "reddit-" . date("Ymd", time() - 172800). ".txt";
  26.  
  27. if (is_file($checkfile)) {
  28.         unlink($checkfile);
  29. }
  30. ?>
clone this paste RAW Paste Data