PageRenderTime 2ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/silverlining/mgr-scripts/master-runner.php

https://bitbucket.org/ianb/silverlining/
PHP | 43 lines | 33 code | 6 blank | 4 comment | 10 complexity | b4d0dcd66b9ac8b80da82cd8f9530a40 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. This command is like master-runner.py, and runs at the beginning of
  4. every PHP request.
  5. */
  6. if ($_SERVER['SILVER_SCRIPT_NAME']) {
  7. $_SERVER['SCRIPT_NAME'] = $_SERVER['SILVER_SCRIPT_NAME'];
  8. }
  9. if ($_SERVER['SILVER_INSTANCE_DIR']) {
  10. $silver_base = $_SERVER['SILVER_INSTANCE_DIR'];
  11. } else {
  12. $silver_base = "/var/www/{$_SERVER[SILVER_INSTANCE_NAME]}";
  13. }
  14. if (! $_SERVER['SILVER_CANONICAL_HOSTNAME']) {
  15. $_SERVER['SILVER_CANONICAL_HOSTNAME'] = $_SERVER['HTTP_HOST'];
  16. }
  17. $silver_app_ini = "$silver_base/app.ini";
  18. $silver_app_config = parse_ini_file($silver_app_ini, true);
  19. $silver_runner = $silver_app_config['production']['runner'];
  20. $silver_php_root = $silver_app_config['production']['php_root'];
  21. if ($_SERVER['SILVER_SECRET_FILE']) {
  22. define('SILVER_SECRET', file_get_contents($_SERVER['SILVER_SECRET_FILE']));
  23. } else {
  24. define('SILVER_SECRET', file_get_contents('/var/lib/silverlining/secret.txt'));
  25. }
  26. if ($_SERVER['SILVER_FUNCS']) {
  27. require_once $_SERVER['SILVER_FUNCS'];
  28. } else {
  29. require_once "/usr/local/share/silverlining/lib/silversupport/php/functions.php";
  30. }
  31. if ($_SERVER['SILVER_ENV_VARS']) {
  32. include $_SERVER['SILVER_ENV_VARS'];
  33. } else {
  34. include "{$silver_base}/silver-env-variables.php";
  35. }
  36. include "{$silver_base}/{$silver_runner}";
  37. ?>