Guest User

Untitled

a guest
May 7th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. function write_file($filename, $content) {
  2. $file = $filename;
  3. $file_contents = $content;
  4.  
  5. $open_file = fopen($file, "wb");
  6. fwrite($open_file, $file_contents);
  7. fclose($open_file);
  8. }
  9.  
  10. // MYSQL
  11. // Usual DB connection stuff, some minor error detection.
  12. $server = "10.0.0.172";
  13. $user = "maya";
  14. $pass = "=";
  15. $link = mysql_connect($server, $user, $pass);
  16. if (!$link) {
  17. die('Could not connect: ' . mysql_error());
  18. }
  19. $db = mysql_select_db("maya", $link);
  20. if (!$db) {
  21. die('Could not select db: '. mysql_error());
  22. }
  23.  
  24. $json_file = "latest_orders.json";
  25.  
  26. /*if (file_exists($json_file)) {
  27. $json = fopen($json_file, "r");
  28. $json_json = fread($json,filesize('./'.$json_file)+1);
  29. fclose($json);
  30.  
  31. $last_order = find_last_order($json_json);
  32. $latest_orders_json = get_orders_and_total($last_order);
  33.  
  34. write_file("latest_orders.json", $latest_orders_json);
  35. } else {*/
  36. $latest_orders_json = get_orders_and_total();
  37.  
  38. write_file("latest_orders.json", $latest_orders_json);
  39. //}
  40.  
  41. $leaderboard_json = build_leaderboard();
  42. write_file("leaderboard.json", $leaderboard_json);
  43.  
  44. mysql_close($link);
Add Comment
Please, Sign In to add comment