コード例 #1
0
ファイル: gcr.class.php プロジェクト: janaece/gc4-maingithub
 public static function initialize()
 {
     $url = explode('.', $_SERVER['HTTP_HOST']);
     if ($url[0] . '.' . $url[1] != self::rootDomainName) {
         // Repair problem where fast CGI is sending *.globalclassroom.us as
         // the $_SERVER['SERVER_NAME']
         $_SERVER['SERVER_NAME'] = str_replace('*', $url[0], $_SERVER['SERVER_NAME']);
         // redirect all http:// to https://
         if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' || $_SERVER['SERVER_PORT'] != 443) {
             header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
             die;
         }
         if ((defined('GC_SYMFONY_LOADED') && GC_SYMFONY_LOADED) == false) {
             self::loadSymfony();
             define('GC_SYMFONY_LOADED', true);
         }
         global $CFG;
         if ($institution = Doctrine::getTable('GcrInstitution')->findOneByShortName($url[0])) {
             if (isset($CFG)) {
                 GcrInstitutionTable::constructCurrentInstitution($institution);
             } else {
                 define('INTERNAL', 1);
                 define('PUBLIC', 1);
                 global $USER, $db, $THEME, $SESSION;
                 require '/var/www/globalclassroom4/web/portal/init.php';
             }
         } else {
             if ($eschool = Doctrine::getTable('GcrEschool')->findOneByShortName($url[0])) {
                 if (isset($CFG)) {
                     GcrEschoolTable::constructCurrentEschool($eschool);
                 } else {
                     require_once '/var/www/globalclassroom4/web/stratus/config.php';
                 }
             } else {
                 // redirect to front page if the short_name doesn't exist
                 header('Location: https://' . self::frontPageDomain . '/notfound');
                 die;
             }
         }
         return true;
     }
     return false;
 }
コード例 #2
0
if (isset($argv)) {
    for ($i = 0; $i < count($argv); $i++) {
        if ($argv[$i] === '--eschool') {
            if (isset($argv[$i + 1])) {
                $shortname = $argv[$i + 1];
            }
        }
    }
}
if ($shortname) {
    if ((defined('GC_SYMFONY_LOADED') && GC_SYMFONY_LOADED) == false) {
        gcr::loadSymfony();
        define('GC_SYMFONY_LOADED', true);
    }
    $eschool = Doctrine::getTable('GcrEschool')->findOneByShortName($shortname);
    GcrEschoolTable::constructCurrentEschool($eschool);
    $CFG->wwwroot = 'https://' . $shortname . '.' . gcr::moodleDomain;
    $CFG->libdir = gcr::moodleDir . 'lib';
    $CFG->dataroot = gcr::moodledataDir . $shortname;
    $CFG->dbtype = 'pgsql';
    $CFG->dblibrary = 'native';
    $CFG->dbhost = gcr::DBHostName;
    $CFG->dbname = gcr::DBName;
    $CFG->prefix = gcr::moodlePrefix;
    $CFG->dbuser = '******' . $shortname . 'admin';
    $CFG->dbpass = $CFG->current_app->getAdminPassword();
    require_once dirname(__FILE__) . '/lib/setup.php';
    // Do not edit
} else {
    if (gcr::initialize()) {
        if ($CFG->current_app->isMahara()) {