Esempio n. 1
0
/**
 * @param $config
 */
function civicrm_main(&$config)
{
    global $sqlPath, $crmPath, $cmsPath, $installType;
    if ($installType == 'drupal') {
        $siteDir = isset($config['site_dir']) ? $config['site_dir'] : getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']);
        civicrm_setup($cmsPath . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . $siteDir . DIRECTORY_SEPARATOR . 'files');
    } elseif ($installType == 'wordpress') {
        civicrm_setup(WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'files');
    }
    $dsn = "mysql://{$config['mysql']['username']}:{$config['mysql']['password']}@{$config['mysql']['server']}/{$config['mysql']['database']}?new_link=true";
    civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm.mysql');
    if (!empty($config['loadGenerated'])) {
        civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm_generated.mysql', TRUE);
    } else {
        if (isset($config['seedLanguage']) and preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $config['seedLanguage']) and file_exists($sqlPath . DIRECTORY_SEPARATOR . "civicrm_data.{$config['seedLanguage']}.mysql") and file_exists($sqlPath . DIRECTORY_SEPARATOR . "civicrm_acl.{$config['seedLanguage']}.mysql")) {
            civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . "civicrm_data.{$config['seedLanguage']}.mysql");
            civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . "civicrm_acl.{$config['seedLanguage']}.mysql");
        } else {
            civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm_data.mysql');
            civicrm_source($dsn, $sqlPath . DIRECTORY_SEPARATOR . 'civicrm_acl.mysql');
        }
    }
    // generate backend settings file
    if ($installType == 'drupal') {
        $configFile = $cmsPath . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . $siteDir . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    } elseif ($installType == 'wordpress') {
        $configFile = $cmsPath . DIRECTORY_SEPARATOR . 'civicrm.settings.php';
    }
    $string = civicrm_config($config);
    civicrm_write_file($configFile, $string);
}
 /**
  * Check everything except the database.
  */
 public function check()
 {
     global $crmPath, $installType;
     $this->errors = NULL;
     $this->requirePHPVersion('5.3.4', array(ts("PHP Configuration"), ts("PHP5 installed"), NULL, ts("PHP version %1", array(1 => phpversion()))));
     // Check that we can identify the root folder successfully
     $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . 'README.txt', array(ts("File permissions"), ts("Does the webserver know where files are stored?"), ts("The webserver isn't letting me identify where files are stored."), $this->getBaseDir()), TRUE);
     // CRM-6485: make sure the path does not contain PATH_SEPARATOR, as we don’t know how to escape it
     $this->requireNoPathSeparator(array(ts("File permissions"), ts('Does the CiviCRM path contain PATH_SEPARATOR?'), ts('The path %1 contains PATH_SEPARATOR (the %2 character).', array(1 => $this->getBaseDir(), 2 => PATH_SEPARATOR)), $this->getBaseDir()));
     $requiredDirectories = array('CRM', 'packages', 'templates', 'js', 'api', 'i', 'sql');
     foreach ($requiredDirectories as $dir) {
         $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . $dir, array(ts("File permissions"), ts("Folder '%1' exists?", array(1 => $dir)), ts("There is no '%1' folder.", array(1 => $dir))), TRUE);
     }
     $configIDSiniDir = NULL;
     global $cmsPath;
     $siteDir = getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']);
     if ($installType == 'drupal') {
         // make sure that we can write to sites/default and files/
         $writableDirectories = array($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir . CIVICRM_DIRECTORY_SEPARATOR . 'files', $cmsPath . CIVICRM_DIRECTORY_SEPARATOR . 'sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir);
     } elseif ($installType == 'wordpress') {
         // make sure that we can write to uploads/civicrm/
         $upload_dir = wp_upload_dir();
         $files_dirname = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm';
         if (!file_exists($files_dirname)) {
             wp_mkdir_p($files_dirname);
         }
         $writableDirectories = array($files_dirname);
     }
     foreach ($writableDirectories as $dir) {
         $dirName = CIVICRM_WINDOWS ? $dir : CIVICRM_DIRECTORY_SEPARATOR . $dir;
         $testDetails = array(ts("File permissions"), ts("Is the %1 folder writeable?", array(1 => $dir)), NULL);
         $this->requireWriteable($dirName, $testDetails, TRUE);
     }
     //check for Config.IDS.ini, file may exist in re-install
     $configIDSiniDir = array($cmsPath, 'sites', $siteDir, 'files', 'civicrm', 'upload', 'Config.IDS.ini');
     if (is_array($configIDSiniDir) && !empty($configIDSiniDir)) {
         $configIDSiniFile = implode(CIVICRM_DIRECTORY_SEPARATOR, $configIDSiniDir);
         if (file_exists($configIDSiniFile)) {
             unlink($configIDSiniFile);
         }
     }
     // Check for rewriting
     if (isset($_SERVER['SERVER_SOFTWARE'])) {
         $webserver = strip_tags(trim($_SERVER['SERVER_SOFTWARE']));
     } elseif (isset($_SERVER['SERVER_SIGNATURE'])) {
         $webserver = strip_tags(trim($_SERVER['SERVER_SIGNATURE']));
     }
     if ($webserver == '') {
         $webserver = ts("I can't tell what webserver you are running");
     }
     // Check for $_SERVER configuration
     $this->requireServerVariables(array('SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME'), array(ts("Webserver config"), ts("Recognised webserver"), ts("You seem to be using an unsupported webserver. The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set.")));
     // Check for MySQL support
     $this->requireFunction('mysql_connect', array(ts("PHP Configuration"), ts("MySQL support"), ts("MySQL support not included in PHP.")));
     // Check for JSON support
     $this->requireFunction('json_encode', array(ts("PHP Configuration"), ts("JSON support"), ts("JSON support not included in PHP.")));
     // Check for xcache_isset and emit warning if exists
     $this->checkXCache(array(ts("PHP Configuration"), ts("XCache compatibility"), ts("XCache is installed and there are known compatibility issues between XCache and CiviCRM. Consider using an alternative PHP caching mechanism or disable PHP caching altogether.")));
     // Check memory allocation
     $this->requireMemory(32 * 1024 * 1024, 64 * 1024 * 1024, array(ts("PHP Configuration"), ts("Memory allocated (PHP config option 'memory_limit')"), ts("CiviCRM needs a minimum of %1 MB allocated to PHP, but recommends %2 MB.", array(1 => 32, 2 => 64)), ini_get("memory_limit")));
     return $this->errors;
 }
Esempio n. 3
0
 /**
  * Check everything except the database
  */
 function check()
 {
     global $crmPath, $installType;
     $this->errors = null;
     $this->requirePHPVersion('5.2.0', array("PHP Configuration", "PHP5 installed", null, "PHP version " . phpversion()), '5.3.0');
     // Check that we can identify the root folder successfully
     $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . 'README.txt', array("File permissions", "Does the webserver know where files are stored?", "The webserver isn't letting me identify where files are stored.", $this->getBaseDir()), true);
     $requiredDirectories = array('CRM', 'packages', 'templates', 'js', 'api', 'i', 'sql');
     foreach ($requiredDirectories as $dir) {
         $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . $dir, array("File permissions", "{$dir} folder exists", "There is no {$dir} folder"), true);
     }
     $configIDSiniDir = null;
     if ($installType == 'standalone') {
         // make sure that we can write to standalone and standalone/files
         $writableDirectories = array('standalone');
         foreach ($writableDirectories as $dir) {
             $this->requireWriteable($crmPath . CIVICRM_DIRECTORY_SEPARATOR . $dir, array("File permissions", "Is the {$dir} folder writeable?", null), true);
         }
         //check for Config.IDS.ini, file may exist in re-install
         $configIDSiniDir = array($crmPath, 'standalone', 'files', 'civicrm', 'upload', 'Config.IDS.ini');
     }
     if ($installType == 'drupal') {
         global $cmsPath;
         $siteDir = getSiteDir($cmsPath, $_SERVER['SCRIPT_FILENAME']);
         // make sure that we can write to sites/default and files/
         $writableDirectories = array('sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir . CIVICRM_DIRECTORY_SEPARATOR . 'files', 'sites' . CIVICRM_DIRECTORY_SEPARATOR . $siteDir);
         foreach ($writableDirectories as $dir) {
             $this->requireWriteable($cmsPath . CIVICRM_DIRECTORY_SEPARATOR . $dir, array("File permissions", "Is the {$dir} folder writeable?", null), true);
         }
         //check for Config.IDS.ini, file may exist in re-install
         $configIDSiniDir = array($cmsPath, 'sites', $siteDir, 'files', 'civicrm', 'upload', 'Config.IDS.ini');
     }
     if (is_array($configIDSiniDir) && !empty($configIDSiniDir)) {
         $configIDSiniFile = implode(CIVICRM_DIRECTORY_SEPARATOR, $configIDSiniDir);
         if (file_exists($configIDSiniFile)) {
             unlink($configIDSiniFile);
         }
     }
     // Check for rewriting
     if (isset($_SERVER['SERVER_SOFTWARE'])) {
         $webserver = strip_tags(trim($_SERVER['SERVER_SOFTWARE']));
     } elseif (isset($_SERVER['SERVER_SIGNATURE'])) {
         $webserver = strip_tags(trim($_SERVER['SERVER_SIGNATURE']));
     }
     if ($webserver == '') {
         $webserver = "I can't tell what webserver you are running";
     }
     // Check for $_SERVER configuration
     $this->requireServerVariables(array('SCRIPT_NAME', 'HTTP_HOST', 'SCRIPT_FILENAME'), array("Webserver config", "Recognised webserver", "You seem to be using an unsupported webserver.  The server variables SCRIPT_NAME, HTTP_HOST, SCRIPT_FILENAME need to be set."));
     // Check for MySQL support
     $this->requireFunction('mysql_connect', array("PHP Configuration", "MySQL support", "MySQL support not included in PHP."));
     // Check memory allocation
     $this->requireMemory(32 * 1024 * 1024, 64 * 1024 * 1024, array("PHP Configuration", "Memory allocated (PHP config option 'memory_limit')", "CiviCRM needs a minimum of 32M allocated to PHP, but recommends 64M.", ini_get("memory_limit")));
     return $this->errors;
 }