Phalcon Framework 5.9.3

ParseError: Unclosed '{' on line 582

/tmp/cache/volt/%%srv%%chathispanoengine%%releases%%100%%apps%%web%%views%%stories%%view.volt.compiled (590)
#0Phalcon\Mvc\View\Engine\Volt->render
#1Phalcon\Mvc\View->engineRender
#2Phalcon\Mvc\View->processRender
#3Phalcon\Mvc\View->render
#4Phalcon\Mvc\Application->handle
/srv/ChatHispanoEngine/releases/100/apps/Application.php (150)
  1. <?php
  2.  
  3. // namespace ChatHispanoEngine;
  4.  
  5. /**
  6. * Application driver class to initialize Phalcon and
  7. * other resources.
  8. */
  9. class Application extends \Phalcon\Mvc\Application
  10. {
  11. private static $mode = 'dev';
  12.  
  13. private static $DEFAULT_MODULE = 'api';
  14.  
  15. public const MODE_PRODUCTION = 'prod';
  16. public const MODE_STAGING = 'staging';
  17. public const MODE_TEST = 'test';
  18. public const MODE_DEVELOPMENT = 'dev';
  19.  
  20. /**
  21. * Set application mode and error reporting level.
  22. */
  23. public function __construct($defaultModule, $env = 'dev')
  24. {
  25. $this->modules = array(
  26. 'core' => array(
  27. 'className' => 'ChatHispanoEngine\Core\Module',
  28. 'path' => __DIR__.'/Core/Module.php',
  29. ),
  30. 'api' => array(
  31. 'className' => 'ChatHispanoEngine\Api\Module',
  32. 'path' => __DIR__.'/Api/Module.php',
  33. ),
  34. 'login' => array(
  35. 'className' => 'ChatHispanoEngine\Login\Module',
  36. 'path' => __DIR__.'/Login/Module.php',
  37. ),
  38. 'oidc' => array(
  39. 'className' => 'ChatHispanoEngine\Oidc\Module',
  40. 'path' => __DIR__.'/Oidc/Module.php',
  41. ),
  42. 'web' => array(
  43. 'className' => 'ChatHispanoEngine\Web\Module',
  44. 'path' => __DIR__.'/Web/Module.php',
  45. ),
  46. 'backoffice' => array(
  47. 'className' => 'ChatHispanoEngine\Backoffice\Module',
  48. 'path' => __DIR__.'/Backoffice/Module.php',
  49. ),
  50. 'movil' => array(
  51. 'className' => 'ChatHispanoEngine\Movil\Module',
  52. 'path' => __DIR__.'/Movil/Module.php',
  53. ),
  54. 'regwebexternal' => array(
  55. 'className' => 'ChatHispanoEngine\RegWebExternal\Module',
  56. 'path' => __DIR__.'/Regwebexternal/Module.php',
  57. ),
  58. 'cdn' => array(
  59. 'className' => 'ChatHispanoEngine\Cdn\Module',
  60. 'path' => __DIR__.'/Cdn/Module.php',
  61. ),
  62. 'shorten' => array(
  63. 'className' => 'ChatHispanoEngine\Shorten\Module',
  64. 'path' => __DIR__.'/Shorten/Module.php',
  65. ),
  66. );
  67.  
  68. static::$DEFAULT_MODULE = $defaultModule;
  69. self::$mode = $env;
  70.  
  71. self::$mode = trim(file_get_contents(__DIR__.'/../config/environment.txt'));
  72. define('ENVIRONMENT', self::$mode);
  73.  
  74. if (!defined('PHALCON_MODE')) {
  75. $mode = getenv('PHALCON_MODE');
  76. $mode = $mode ? $mode : self::$mode;
  77. define('PHALCON_MODE', $mode);
  78. }
  79.  
  80. switch (self::getMode()) {
  81. case self::MODE_PRODUCTION:
  82. case self::MODE_STAGING:
  83. error_reporting(0);
  84. break;
  85. case self::MODE_TEST:
  86. case self::MODE_DEVELOPMENT:
  87. ini_set('display_errors', 'On');
  88. error_reporting(E_ALL);
  89. break;
  90. }
  91. }
  92.  
  93. /**
  94. * Register the services here to make them general or register in
  95. * the ModuleDefinition to make them module-specific.
  96. */
  97. protected function _registerServices()
  98. {
  99. $defaultModule = self::$DEFAULT_MODULE;
  100. $modules = $this->modules;
  101. $config = include __DIR__.'/../config/config.php';
  102. $env_config = include __DIR__.'/../config/config_'.ENVIRONMENT.'.php';
  103. $config->merge($env_config);
  104.  
  105. $di = new \Phalcon\DI\FactoryDefault();
  106.  
  107. include __DIR__.'/../config/loader.php';
  108. include __DIR__.'/../config/services.php';
  109. include __DIR__.'/../config/routing.php';
  110.  
  111. $this->setDI($di);
  112. }
  113.  
  114. /**
  115. * Run the application.
  116. */
  117. public function main()
  118. {
  119. if (static::MODE_PRODUCTION === static::getMode()) {
  120. $this->mainProd();
  121. } else {
  122. $this->mainDev();
  123. }
  124. }
  125.  
  126. private function getRequestUri()
  127. {
  128. if (!isset($_SERVER)) {
  129. return "/";
  130. }
  131. if (!is_array($_SERVER)) {
  132. return "/";
  133. }
  134. if (!isset($_SERVER['REQUEST_URI'])) {
  135. return "/";
  136. }
  137. return $_SERVER['REQUEST_URI'];
  138. }
  139.  
  140. /**
  141. * Run the development environment.
  142. */
  143. private function mainDev()
  144. {
  145. (new \Phalcon\Support\Debug())->listen();
  146.  
  147. $this->_registerServices();
  148. $this->registerModules($this->modules);
  149.  
  150. $response = $this->handle($this->getRequestUri());
  151. $response->send();
  152. }
  153.  
  154. /**
  155. * Run the production environment.
  156. */
  157. private function mainProd()
  158. {
  159. try {
  160. $this->registerModules($this->modules);
  161. $this->_registerServices();
  162.  
  163. $response = $this->handle($this->getRequestUri());
  164. $response->send();
  165. } catch (\Exception $e) {
  166. $logger = new \Phalcon\Logger\Adapter\Stream(__DIR__.'/../logs/'.date('Y-m-d').'.log');
  167. $msg = "[".$_SERVER['SERVER_NAME']."] [".$_SERVER['REQUEST_URI']."] [".$e->getCode()."] ".$e->getMessage()." at ".$e->getFile()." (".$e->getLine().")";
  168. $msg .= "\n".$e->getTraceAsString();
  169. $logger->process(new \Phalcon\Logger\Item($msg, "error", 100));
  170. $logger->close();
  171.  
  172. // remove view contents from buffer
  173. ob_clean();
  174.  
  175. $errorCode = 500;
  176. $errorView = __DIR__.'/../public/errors/error.html';
  177.  
  178. if (401 === $e->getCode()) {
  179. // 401 UNAUTHORIZED
  180. $errorCode = 401;
  181. } elseif (403 === $e->getCode()) {
  182. // 403 FORBIDDEN
  183. $errorCode = 403;
  184. } elseif (404 === $e->getCode()
  185. || $e instanceof Phalcon\Mvc\View\Exception
  186. || $e instanceof Phalcon\Mvc\Dispatcher\Exception) {
  187. // 404 NOT FOUND
  188. $errorCode = 404;
  189. }
  190.  
  191. // Get error view contents. Since we are including the view
  192. // file here you can use PHP and local vars inside the error view.
  193. ob_start();
  194. include_once $errorView;
  195. $contents = ob_get_contents();
  196. ob_end_clean();
  197.  
  198. // send view to header
  199. $response = $this->getDI()->getShared('response');
  200. $response->resetHeaders()
  201. ->setStatusCode($errorCode, null)
  202. ->setContent($contents)
  203. ->send()
  204. ;
  205.  
  206. /**
  207. * We try to register in MongoDB the error to be able to
  208. * track it in backoffice and/or receive emails
  209. */
  210. try {
  211. $system_log_manager = $this->getDI()->get('system_log_manager');
  212. if ($errorCode == 500) {
  213. $system_log_manager->createError([
  214. 'ip' => $_SERVER['SERVER_ADDR'],
  215. 'host' => $_SERVER['SERVER_NAME'],
  216. 'process' => 'php-fpm',
  217. 'message' => $e->getMessage(),
  218. 'file' => $e->getFile(),
  219. 'line' => $e->getLine(),
  220. ]);
  221. } else {
  222. $system_log_manager->createWarning([
  223. 'ip' => $_SERVER['SERVER_ADDR'],
  224. 'host' => $_SERVER['SERVER_NAME'],
  225. 'process' => 'php-fpm',
  226. 'message' => $e->getMessage(),
  227. 'file' => $e->getFile(),
  228. 'line' => $e->getLine(),
  229. ]);
  230. }
  231. } catch (\Exception $e) {
  232. }
  233. }
  234. }
  235.  
  236. public function slowLog($t)
  237. {
  238. $config = $this->getDI()->get('config');
  239. $irc_manager = $this->getDI()->get('inspircd_irc_manager');
  240. $server = gethostname() ? gethostname() : 'unknown';
  241. $uri = "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
  242. if (substr($_SERVER['REQUEST_URI'], 0, 10) == '/historias') {
  243. return;
  244. }
  245. $msg = "\x02[SLOWLOG] [".str_pad($server, 6, " ", STR_PAD_LEFT)."] [".str_pad(round($t, 1), 5, " ", STR_PAD_LEFT)."s] PATH=\x02 ".$_SERVER['REQUEST_URI']
  246. ."\x02 TYPE=\x02 ".$_SERVER['REQUEST_METHOD']."\x02 URI=\x02 ".$uri;
  247. $irc_manager->privmsgOrderEnqueue('AAAAAI', $config->irc->debug_channel, $msg);
  248. }
  249.  
  250. /**
  251. * Get the current mode.
  252. *
  253. * @return string
  254. */
  255. public static function getMode()
  256. {
  257. return self::$mode;
  258. }
  259. }
#5Application->mainDev
/srv/ChatHispanoEngine/releases/100/apps/Application.php (122)
  1. <?php
  2.  
  3. // namespace ChatHispanoEngine;
  4.  
  5. /**
  6. * Application driver class to initialize Phalcon and
  7. * other resources.
  8. */
  9. class Application extends \Phalcon\Mvc\Application
  10. {
  11. private static $mode = 'dev';
  12.  
  13. private static $DEFAULT_MODULE = 'api';
  14.  
  15. public const MODE_PRODUCTION = 'prod';
  16. public const MODE_STAGING = 'staging';
  17. public const MODE_TEST = 'test';
  18. public const MODE_DEVELOPMENT = 'dev';
  19.  
  20. /**
  21. * Set application mode and error reporting level.
  22. */
  23. public function __construct($defaultModule, $env = 'dev')
  24. {
  25. $this->modules = array(
  26. 'core' => array(
  27. 'className' => 'ChatHispanoEngine\Core\Module',
  28. 'path' => __DIR__.'/Core/Module.php',
  29. ),
  30. 'api' => array(
  31. 'className' => 'ChatHispanoEngine\Api\Module',
  32. 'path' => __DIR__.'/Api/Module.php',
  33. ),
  34. 'login' => array(
  35. 'className' => 'ChatHispanoEngine\Login\Module',
  36. 'path' => __DIR__.'/Login/Module.php',
  37. ),
  38. 'oidc' => array(
  39. 'className' => 'ChatHispanoEngine\Oidc\Module',
  40. 'path' => __DIR__.'/Oidc/Module.php',
  41. ),
  42. 'web' => array(
  43. 'className' => 'ChatHispanoEngine\Web\Module',
  44. 'path' => __DIR__.'/Web/Module.php',
  45. ),
  46. 'backoffice' => array(
  47. 'className' => 'ChatHispanoEngine\Backoffice\Module',
  48. 'path' => __DIR__.'/Backoffice/Module.php',
  49. ),
  50. 'movil' => array(
  51. 'className' => 'ChatHispanoEngine\Movil\Module',
  52. 'path' => __DIR__.'/Movil/Module.php',
  53. ),
  54. 'regwebexternal' => array(
  55. 'className' => 'ChatHispanoEngine\RegWebExternal\Module',
  56. 'path' => __DIR__.'/Regwebexternal/Module.php',
  57. ),
  58. 'cdn' => array(
  59. 'className' => 'ChatHispanoEngine\Cdn\Module',
  60. 'path' => __DIR__.'/Cdn/Module.php',
  61. ),
  62. 'shorten' => array(
  63. 'className' => 'ChatHispanoEngine\Shorten\Module',
  64. 'path' => __DIR__.'/Shorten/Module.php',
  65. ),
  66. );
  67.  
  68. static::$DEFAULT_MODULE = $defaultModule;
  69. self::$mode = $env;
  70.  
  71. self::$mode = trim(file_get_contents(__DIR__.'/../config/environment.txt'));
  72. define('ENVIRONMENT', self::$mode);
  73.  
  74. if (!defined('PHALCON_MODE')) {
  75. $mode = getenv('PHALCON_MODE');
  76. $mode = $mode ? $mode : self::$mode;
  77. define('PHALCON_MODE', $mode);
  78. }
  79.  
  80. switch (self::getMode()) {
  81. case self::MODE_PRODUCTION:
  82. case self::MODE_STAGING:
  83. error_reporting(0);
  84. break;
  85. case self::MODE_TEST:
  86. case self::MODE_DEVELOPMENT:
  87. ini_set('display_errors', 'On');
  88. error_reporting(E_ALL);
  89. break;
  90. }
  91. }
  92.  
  93. /**
  94. * Register the services here to make them general or register in
  95. * the ModuleDefinition to make them module-specific.
  96. */
  97. protected function _registerServices()
  98. {
  99. $defaultModule = self::$DEFAULT_MODULE;
  100. $modules = $this->modules;
  101. $config = include __DIR__.'/../config/config.php';
  102. $env_config = include __DIR__.'/../config/config_'.ENVIRONMENT.'.php';
  103. $config->merge($env_config);
  104.  
  105. $di = new \Phalcon\DI\FactoryDefault();
  106.  
  107. include __DIR__.'/../config/loader.php';
  108. include __DIR__.'/../config/services.php';
  109. include __DIR__.'/../config/routing.php';
  110.  
  111. $this->setDI($di);
  112. }
  113.  
  114. /**
  115. * Run the application.
  116. */
  117. public function main()
  118. {
  119. if (static::MODE_PRODUCTION === static::getMode()) {
  120. $this->mainProd();
  121. } else {
  122. $this->mainDev();
  123. }
  124. }
  125.  
  126. private function getRequestUri()
  127. {
  128. if (!isset($_SERVER)) {
  129. return "/";
  130. }
  131. if (!is_array($_SERVER)) {
  132. return "/";
  133. }
  134. if (!isset($_SERVER['REQUEST_URI'])) {
  135. return "/";
  136. }
  137. return $_SERVER['REQUEST_URI'];
  138. }
  139.  
  140. /**
  141. * Run the development environment.
  142. */
  143. private function mainDev()
  144. {
  145. (new \Phalcon\Support\Debug())->listen();
  146.  
  147. $this->_registerServices();
  148. $this->registerModules($this->modules);
  149.  
  150. $response = $this->handle($this->getRequestUri());
  151. $response->send();
  152. }
  153.  
  154. /**
  155. * Run the production environment.
  156. */
  157. private function mainProd()
  158. {
  159. try {
  160. $this->registerModules($this->modules);
  161. $this->_registerServices();
  162.  
  163. $response = $this->handle($this->getRequestUri());
  164. $response->send();
  165. } catch (\Exception $e) {
  166. $logger = new \Phalcon\Logger\Adapter\Stream(__DIR__.'/../logs/'.date('Y-m-d').'.log');
  167. $msg = "[".$_SERVER['SERVER_NAME']."] [".$_SERVER['REQUEST_URI']."] [".$e->getCode()."] ".$e->getMessage()." at ".$e->getFile()." (".$e->getLine().")";
  168. $msg .= "\n".$e->getTraceAsString();
  169. $logger->process(new \Phalcon\Logger\Item($msg, "error", 100));
  170. $logger->close();
  171.  
  172. // remove view contents from buffer
  173. ob_clean();
  174.  
  175. $errorCode = 500;
  176. $errorView = __DIR__.'/../public/errors/error.html';
  177.  
  178. if (401 === $e->getCode()) {
  179. // 401 UNAUTHORIZED
  180. $errorCode = 401;
  181. } elseif (403 === $e->getCode()) {
  182. // 403 FORBIDDEN
  183. $errorCode = 403;
  184. } elseif (404 === $e->getCode()
  185. || $e instanceof Phalcon\Mvc\View\Exception
  186. || $e instanceof Phalcon\Mvc\Dispatcher\Exception) {
  187. // 404 NOT FOUND
  188. $errorCode = 404;
  189. }
  190.  
  191. // Get error view contents. Since we are including the view
  192. // file here you can use PHP and local vars inside the error view.
  193. ob_start();
  194. include_once $errorView;
  195. $contents = ob_get_contents();
  196. ob_end_clean();
  197.  
  198. // send view to header
  199. $response = $this->getDI()->getShared('response');
  200. $response->resetHeaders()
  201. ->setStatusCode($errorCode, null)
  202. ->setContent($contents)
  203. ->send()
  204. ;
  205.  
  206. /**
  207. * We try to register in MongoDB the error to be able to
  208. * track it in backoffice and/or receive emails
  209. */
  210. try {
  211. $system_log_manager = $this->getDI()->get('system_log_manager');
  212. if ($errorCode == 500) {
  213. $system_log_manager->createError([
  214. 'ip' => $_SERVER['SERVER_ADDR'],
  215. 'host' => $_SERVER['SERVER_NAME'],
  216. 'process' => 'php-fpm',
  217. 'message' => $e->getMessage(),
  218. 'file' => $e->getFile(),
  219. 'line' => $e->getLine(),
  220. ]);
  221. } else {
  222. $system_log_manager->createWarning([
  223. 'ip' => $_SERVER['SERVER_ADDR'],
  224. 'host' => $_SERVER['SERVER_NAME'],
  225. 'process' => 'php-fpm',
  226. 'message' => $e->getMessage(),
  227. 'file' => $e->getFile(),
  228. 'line' => $e->getLine(),
  229. ]);
  230. }
  231. } catch (\Exception $e) {
  232. }
  233. }
  234. }
  235.  
  236. public function slowLog($t)
  237. {
  238. $config = $this->getDI()->get('config');
  239. $irc_manager = $this->getDI()->get('inspircd_irc_manager');
  240. $server = gethostname() ? gethostname() : 'unknown';
  241. $uri = "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
  242. if (substr($_SERVER['REQUEST_URI'], 0, 10) == '/historias') {
  243. return;
  244. }
  245. $msg = "\x02[SLOWLOG] [".str_pad($server, 6, " ", STR_PAD_LEFT)."] [".str_pad(round($t, 1), 5, " ", STR_PAD_LEFT)."s] PATH=\x02 ".$_SERVER['REQUEST_URI']
  246. ."\x02 TYPE=\x02 ".$_SERVER['REQUEST_METHOD']."\x02 URI=\x02 ".$uri;
  247. $irc_manager->privmsgOrderEnqueue('AAAAAI', $config->irc->debug_channel, $msg);
  248. }
  249.  
  250. /**
  251. * Get the current mode.
  252. *
  253. * @return string
  254. */
  255. public static function getMode()
  256. {
  257. return self::$mode;
  258. }
  259. }
#6Application->main
/srv/ChatHispanoEngine/releases/100/public/index.php (13)
  1. <?php
  2.  
  3. date_default_timezone_set('Europe/Madrid');
  4.  
  5. require_once __DIR__.'/../vendor/autoload.php';
  6. require_once __DIR__.'/../apps/Application.php';
  7.  
  8. if (isset($_SERVER['PHALCON_APP'])) {
  9. $app = new Application($_SERVER['PHALCON_APP']);
  10. } else {
  11. $app = new Application('web');
  12. }
  13. $app->main();
  14.  
  15. try {
  16. $t = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
  17. if ($t > 6) {
  18. $app->slowLog($t);
  19. }
  20. } catch (\Exception $e) {
  21. }