2015-07-11 08:42:58 +02:00
< ? php
/**
* @ link https :// www . humhub . org /
* @ copyright Copyright ( c ) 2015 HumHub GmbH & Co . KG
* @ license https :// www . humhub . com / licences
*/
2023-07-25 17:26:57 +02:00
2015-07-11 08:42:58 +02:00
// NOTE: Make sure this file is not accessible when deployed to production
2023-07-25 17:26:57 +02:00
use humhub\components\Response ;
2015-07-11 08:42:58 +02:00
if ( ! in_array ( @ $_SERVER [ 'REMOTE_ADDR' ], [ '127.0.0.1' , '::1' ])) {
die ( 'You are not allowed to access this file.' );
}
2023-07-25 18:13:12 +02:00
if ( isset ( $_SERVER [ 'REQUEST_URI' ]) && preg_match ( '/^[^?]*\.(?:css|(?<!manifest\.)json|(?<!sw\.)js|png|jpg|jpeg|gif|ttf|woff|woff2)(\?.+)?$/i' , $_SERVER [ 'REQUEST_URI' ])) {
2021-07-08 19:56:19 +03:00
return false ; // serve the requested resource as-is.
}
2023-07-25 17:26:57 +02:00
file_put_contents ( " php://stdout " , sprintf ( " [%s] \ e[34m%s:%d [---]: %s %s \033 [0m \n " , date ( 'D M d H:i:s Y' ), $_SERVER [ 'REMOTE_ADDR' ], $_SERVER [ 'REMOTE_PORT' ], $_SERVER [ 'REQUEST_METHOD' ], $_SERVER [ 'REQUEST_URI' ]));
2017-03-03 18:06:30 +01:00
/*defined('YII_DEBUG') or define('YII_DEBUG', true);*/
2015-07-11 08:42:58 +02:00
defined ( 'YII_ENV' ) or define ( 'YII_ENV' , 'test' );
2016-07-14 23:32:49 +02:00
defined ( 'YII_ENV_TEST' ) or define ( 'YII_ENV_TEST' , true );
2015-07-11 08:42:58 +02:00
require ( __DIR__ . '/protected/vendor/autoload.php' );
require ( __DIR__ . '/protected/vendor/yiisoft/yii2/Yii.php' );
2024-09-05 17:15:16 +04:00
$dotenv = Dotenv\Dotenv :: createImmutable ( __DIR__ , '.env' );
$dotenv -> safeLoad ();
2016-03-30 10:01:17 -04:00
$config = yii\helpers\ArrayHelper :: merge (
// add more configurations here
2016-08-21 19:58:55 +02:00
( is_readable ( __DIR__ . '/protected/humhub/tests/codeception/config/dynamic.php' )) ? require ( __DIR__ . '/protected/humhub/tests/codeception/config/dynamic.php' ) : [],
2024-09-05 17:15:16 +04:00
require ( __DIR__ . '/protected/humhub/tests/codeception/config/acceptance.php' ),
humhub\helpers\EnvHelper :: toConfig ( $_ENV ),
2016-03-30 10:01:17 -04:00
);
2015-07-11 08:42:58 +02:00
2018-10-07 20:36:19 +02:00
require_once './protected/vendor/codeception/codeception/autoload.php' ;
include './protected/humhub/tests/c3.php' ;
2023-07-25 17:26:57 +02:00
class indexTextResponseCode
{
public static ? Response $response = null ;
}
2015-07-11 08:42:58 +02:00
( new humhub\components\Application ( $config )) -> run ();
2023-07-25 17:26:57 +02:00
if ( indexTextResponseCode :: $response ) {
$code = indexTextResponseCode :: $response -> getStatusCode ();
switch ( floor ( $code / 100 )) {
case 2 :
$color = 34 ;
break ;
case 1 :
case 3 :
$color = 36 ;
break ;
case 4 :
$color = 33 ;
break ;
default :
$color = 31 ;
}
file_put_contents ( " php://stdout " , sprintf ( " [%s] \ e[%dm%s:%d [%03d]: %s %s \033 [0m \n " , date ( 'D M d H:i:s Y' ), $color , $_SERVER [ 'REMOTE_ADDR' ], $_SERVER [ 'REMOTE_PORT' ], $code , $_SERVER [ 'REQUEST_METHOD' ], $_SERVER [ 'REQUEST_URI' ]));
}