update_feeds.php 996 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/php
  2. <?php
  3. define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
  4. define('DISABLE_SESSIONS', true);
  5. error_reporting(DEFAULT_ERROR_LEVEL);
  6. require_once "sanity_check.php";
  7. require_once "config.php";
  8. require_once "db.php";
  9. require_once "db-prefs.php";
  10. require_once "functions.php";
  11. $lock_filename = "update_feeds.lock";
  12. $lock_handle = make_lockfile($lock_filename);
  13. // Try to lock a file in order to avoid concurrent update.
  14. if (!$lock_handle) {
  15. die("error: Can't create lockfile ($lock_filename). ".
  16. "Maybe another process is already running.\n");
  17. }
  18. // Create a database connection.
  19. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  20. if (!$link) {
  21. if (DB_TYPE == "mysql") {
  22. print mysql_error();
  23. }
  24. // PG seems to display its own errors just fine by default.
  25. return;
  26. }
  27. init_connection($link);
  28. // Update all feeds needing a update.
  29. update_daemon_common($link);
  30. db_close($link);
  31. unlink(LOCK_DIRECTORY . "/$lock_filename");
  32. ?>