update_feedbrowser.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/php
  2. <?php
  3. /* This script updates feedbrowser (e.g. Other Feeds tab) cache
  4. * If you are using update daemon, it is NOT necessary to run
  5. * this script, as updates are handled automatically. */
  6. define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
  7. define('DISABLE_SESSIONS', true);
  8. error_reporting(DEFAULT_ERROR_LEVEL);
  9. require_once "sanity_check.php";
  10. require_once "config.php";
  11. require_once "db.php";
  12. require_once "db-prefs.php";
  13. require_once "functions.php";
  14. $lock_filename = "update_feedbrowser.lock";
  15. $lock_handle = make_lockfile($lock_filename);
  16. // Try to lock a file in order to avoid concurrent update.
  17. if (!$lock_handle) {
  18. die("error: Can't create lockfile ($lock_filename). ".
  19. "Maybe another process is already running.\n");
  20. }
  21. // Create a database connection.
  22. $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
  23. if (!$link) {
  24. if (DB_TYPE == "mysql") {
  25. print mysql_error();
  26. }
  27. // PG seems to display its own errors just fine by default.
  28. return;
  29. }
  30. init_connection($link);
  31. $count = update_feedbrowser_cache($link);
  32. print "Finished, $count feeds processed.\n";
  33. db_close($link);
  34. unlink(LOCK_DIRECTORY . "/$lock_filename");
  35. ?>