/v1.9/timecheck.php

https://bitbucket.org/rev22/timekoin · PHP · 24 lines · 18 code · 4 blank · 2 comment · 5 complexity · 685dfcf33315a3ba1992e4dcc8e7dd1d MD5 · raw file

  1. <?PHP
  2. include 'configuration.php';
  3. include 'function.php';
  4. if (mysql_connect(MYSQL_IP,MYSQL_USERNAME,MYSQL_PASSWORD) &&
  5. mysql_select_db(MYSQL_DATABASE) &&
  6. mysql_table(mysql_query("SELECT GET_LOCK('timekoin_timecheck',0)")) == 1) {
  7. $poll_peer = filter_sql(file_get_contents("http://timekoin.net/time.php", FALSE, $context, NULL, 12));
  8. $my_time = time();
  9. if(abs($poll_peer - $my_time) > 15 && empty($poll_peer) == FALSE)
  10. {
  11. // Timekoin peer time is not in sync
  12. mysql_query("UPDATE `options` SET `field_data` = '1' WHERE `options`.`field_name` = 'time_sync_error' LIMIT 1");
  13. }
  14. else
  15. {
  16. // Timekoin peer time is in sync
  17. mysql_query("UPDATE `options` SET `field_data` = '0' WHERE `options`.`field_name` = 'time_sync_error' LIMIT 1");
  18. }
  19. }
  20. ?>