You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					117 lines
				
				3.9 KiB
			
		
		
			
		
	
	
					117 lines
				
				3.9 KiB
			| 
								 
											19 years ago
										 
									 | 
							
								<?php
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								/* For licensing terms, see /license.txt */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								use Chamilo\CoreBundle\Framework\Container;
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								use Patchwork\Utf8\Bootup;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								use Symfony\Component\Dotenv\Dotenv;
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											19 years ago
										 
									 | 
							
								/**
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								 * All legacy Chamilo scripts should include this important file.
							 | 
						||
| 
								 
											16 years ago
										 
									 | 
							
								 */
							 | 
						||
| 
								 
											19 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								// Specification for user names:
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								// 1. ASCII-letters, digits, "." (dot), "_" (underscore) are acceptable, 40 characters maximum length.
							 | 
						||
| 
								 | 
							
								// 2. Empty username is formally valid, but it is reserved for the anonymous user.
							 | 
						||
| 
								 | 
							
								// 3. Checking the login_is_email portal setting in order to accept 100 chars maximum
							 | 
						||
| 
								 | 
							
								define('USERNAME_MAX_LENGTH', 100);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								require_once __DIR__.'/../../../vendor/autoload.php';
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								try {
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    // Check the PHP version
							 | 
						||
| 
								 | 
							
								    api_check_php_version();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    // Get settings from .env.local file created.
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    $envFile = __DIR__.'/../../../.env.local';
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    if (file_exists($envFile)) {
							 | 
						||
| 
								 | 
							
								        (new Dotenv())->load($envFile);
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        throw new \RuntimeException('APP_ENV environment variable is not defined.
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								        You need to define environment variables for configuration to load variables from a .env.local file.');
							 | 
						||
| 
								 
											9 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    $env = $_SERVER['APP_ENV'] ?? 'dev';
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    $append = $_SERVER['APP_URL_APPEND'] ?? '';
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    $kernel = new Chamilo\Kernel($env, true);
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    // Loading Request from Sonata. In order to use Sonata Pages Bundle.
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    $request = Sonata\PageBundle\Request\RequestFactory::createFromGlobals('host_with_path_by_locale');
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    // This 'load_legacy' variable is needed to know that symfony is loaded using old style legacy mode,
							 | 
						||
| 
								 | 
							
								    // and not called from a symfony controller from public/
							 | 
						||
| 
								 | 
							
								    $request->request->set('load_legacy', true);
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								    // @todo fix URL loading
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    $request->setBaseUrl($request->getRequestUri());
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    $kernel->boot();
							 | 
						||
| 
								 | 
							
								    if (!empty($append)) {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        if (substr($append, 0, 1) !== '/') {
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								            echo 'APP_URL_APPEND must start with "/"';
							 | 
						||
| 
								 | 
							
								            exit;
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        $append = "$append/";
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								        $append .= 'public';
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        $append .= '/public';
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    $container = $kernel->getContainer();
							 | 
						||
| 
								 | 
							
								    $router = $container->get('router');
							 | 
						||
| 
								 | 
							
								    $context = $router->getContext();
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    $context->setBaseUrl($append);
							 | 
						||
| 
								 | 
							
								    $router->setContext($context);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    $response = $kernel->handle($request);
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    $context = Container::getRouter()->getContext();
							 | 
						||
| 
								 | 
							
								    $context->setBaseUrl($append);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    $container = $kernel->getContainer();
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    if ($kernel->isInstalled()) {
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								        require_once $kernel->getConfigurationFile();
							 | 
						||
| 
								 
											11 years ago
										 
									 | 
							
								    } else {
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								        throw new Exception('Chamilo is not installed');
							 | 
						||
| 
								 
											12 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    //$kernel->setApi($_configuration);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    if (!isset($GLOBALS['_configuration'])) {
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								        $GLOBALS['_configuration'] = $_configuration;
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								    // Do not over-use this variable. It is only for this script's local use.
							 | 
						||
| 
								 | 
							
								    $libraryPath = __DIR__.'/lib/';
							 | 
						||
| 
								 | 
							
								    $container = $kernel->getContainer();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    // Symfony uses request_stack now
							 | 
						||
| 
								 | 
							
								    $container->get('request_stack')->push($request);
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    // Connect Chamilo with the Symfony container
							 | 
						||
| 
								 | 
							
								    // Container::setContainer($container);
							 | 
						||
| 
								 | 
							
								    // Container::setLegacyServices($container);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // The code below is not needed. The connections is now made in the file:
							 | 
						||
| 
								 | 
							
								    // src/CoreBundle/EventListener/LegacyListener.php
							 | 
						||
| 
								 | 
							
								    // This is called when when doing the $kernel->handle
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    $charset = 'UTF-8';
							 | 
						||
| 
								 | 
							
								    // Enables the portability layer and configures PHP for UTF-8
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    Bootup::initAll();
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    ini_set('log_errors', '1');
							 | 
						||
| 
								 | 
							
								    $this_section = SECTION_GLOBAL;
							 | 
						||
| 
								 | 
							
								    //Default quota for the course documents folder
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    /*$default_quota = api_get_setting('default_document_quotum');
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    //Just in case the setting is not correctly set
							 | 
						||
| 
								 | 
							
								    if (empty($default_quota)) {
							 | 
						||
| 
								 | 
							
								        $default_quota = 100000000;
							 | 
						||
| 
								 
											15 years ago
										 
									 | 
							
								    }
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    define('DEFAULT_DOCUMENT_QUOTA', $default_quota);*/
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								} catch (Exception $e) {
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    var_dump($e->getMessage());
							 | 
						||
| 
								 | 
							
								    var_dump($e->getCode());
							 | 
						||
| 
								 | 
							
								    var_dump($e->getLine());
							 | 
						||
| 
								 | 
							
								    /*echo $e->getMessage();    exit;
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    var_dump($e->getMessage());
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    var_dump($e->getCode());
							 | 
						||
| 
								 | 
							
								    var_dump($e->getLine());
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								    echo $e->getTraceAsString();
							 | 
						||
| 
								 
											7 years ago
										 
									 | 
							
								    exit;*/
							 | 
						||
| 
								 
											8 years ago
										 
									 | 
							
								}
							 |