/
console.php
65 lines (60 loc) · 2.76 KB
/
console.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/php
<?php
/*
* LimeSurvey (tm)
* Copyright (C) 2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
*
* File edited by Sam Mousa for Marcel Minke.
* This loader bypasses the default Yii loader and loads a custom console class instead.
*/
if (!isset($argv[0])) die();
define('BASEPATH','.');
/**
* Load Psr4 autoloader, should be replaced by composer autoloader at some point.
*/
require_once __DIR__ . '/../Psr4AutoloaderClass.php';
$loader = new Psr4AutoloaderClass();
$loader->register();
$loader->addNamespace('ls\\pluginmanager', __DIR__ . '/../libraries/PluginManager');
$loader->addNamespace('ls\\pluginmanager', __DIR__ . '/../libraries/PluginManager/Storage');
require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'yii.php');
// Load configuration.
$sCurrentDir=dirname(__FILE__);
$settings=require (dirname($sCurrentDir).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config-defaults.php');
$config=require (dirname($sCurrentDir).DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'internal.php');
$core = dirname($sCurrentDir) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR;
if(isset($config['config'])){
$settings=array_merge($settings,$config['config']);
}
unset ($config['defaultController']);
unset ($config['config']);
/* fix runtime path, unsure you can lauch function anywhere (if you use php /var/www/limesurvey/... : can be /root/ for config */
$runtimePath=$settings['tempdir'].'/runtime';
if(!is_dir($runtimePath) || !is_writable($runtimePath)){
$runtimePath=str_replace($settings['rootdir'],dirname(dirname(dirname(__FILE__))),$runtimePath);
}
$config['runtimePath']=$runtimePath;
// fix for fcgi
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
defined('YII_DEBUG') or define('YII_DEBUG',true);
if(isset($config))
{
require_once($core . 'ConsoleApplication.php');
$app=Yii::createApplication('ConsoleApplication', $config);
define('APPPATH', Yii::app()->getBasePath() . DIRECTORY_SEPARATOR);
$app->commandRunner->addCommands(YII_PATH.'/cli/commands');
$env=@getenv('YII_CONSOLE_COMMANDS');
if(!empty($env)){
$app->commandRunner->addCommands($env);
}
}
$app->run();
?>