bash_install_check.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * 2016-04-06 by plabudda
  4. *
  5. */
  6. ini_set('max_execution_time', 300);
  7. ini_set('memory_limit', '512M');
  8. define('DS', DIRECTORY_SEPARATOR);
  9. define('APP_PATH_ROOT', dirname(__FILE__));
  10. define('APP_PATH_WWW', dirname(__FILE__));
  11. define('APP_PATH_CONFIG', APP_PATH_ROOT . DS . 'config');
  12. // set ini to log errors into error log file
  13. ini_set('display_startup_errors', '0');
  14. ini_set('log_errors', '1');
  15. ini_set('error_log', '/var/log/apache2/error_log');// TODO: php.ini ?
  16. require_once APP_PATH_ROOT . DS . 'se-lib' . DS . 'Lib.php';
  17. Lib::loadClass('V');
  18. Lib::loadClass('Config');
  19. Lib::loadClass('DB');
  20. Lib::loadClass('User');
  21. if (isset($_SERVER["argv"][1])) {
  22. $_SERVER['SERVER_NAME'] = $_SERVER["argv"][1];
  23. }
  24. else if (empty($_SERVER["argv"]) && V::get('task', '', $_GET) == 'info') {
  25. $info = array();
  26. $info['max_execution_time'] = ini_get('max_execution_time');
  27. $info['memory_limit'] = ini_get('memory_limit');
  28. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">info (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($info);echo'</pre>';
  29. ini_set('max_execution_time', 300);
  30. ini_set('memory_limit', '512M');
  31. $info = array();
  32. $info['max_execution_time'] = ini_get('max_execution_time');
  33. $info['memory_limit'] = ini_get('memory_limit');
  34. echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">info (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($info);echo'</pre>';
  35. }
  36. else {
  37. die("\n The second argument should be server domain - e.g. biuro.biall-net.pl \n");
  38. }
  39. // TODO: check install
  40. Lib::loadClass('Router');
  41. Router::getRoute('Config')->reinstall();
  42. $cronTaskName = 'checkInstall';
  43. $keyToken = 'bach_install_check';
  44. $token = Router::getRoute('Cron')->generateCliAuthToken($keyToken, $cronTaskName, 300 * 10);
  45. $baseUrl = "https://{$_SERVER['SERVER_NAME']}/SE";
  46. if ('biuro.biall-net.pl' == $_SERVER['SERVER_NAME']) $baseUrl = "https://{$_SERVER['SERVER_NAME']}/SE/version-git";
  47. //file_get_contents("https://{$baseUrl}/index.php?_route=Cron&_key={$keyToken}&_token={$token}&_task=sendNofity");
  48. function runUrlTask($url) {
  49. $ch = curl_init();
  50. curl_setopt($ch, CURLOPT_VERBOSE, true);
  51. curl_setopt($ch, CURLOPT_URL, $url);
  52. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  53. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  54. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  55. $return = curl_exec($ch);
  56. curl_close($ch);
  57. return $return;
  58. }
  59. $string = runUrlTask("{$baseUrl}/index.php?_route=Cron&_key={$keyToken}&_token={$token}&_task={$cronTaskName}}");
  60. echo "DBG: string -----------------------\n{$string}\nEOF string---------------------------------\n";
  61. die(".EOF - OK\n");
  62. ?>