Merge remote-tracking branch 'origin/4.5' into 4.5-master-2015-02-24-17-24-05
[civicrm-core.git] / install / index.php
index 93d6d7d0eb46dfed292158ae16accbcf60af2bb8..2b675c9507e02d5a44e985599ddcee1188ae9dcb 100644 (file)
@@ -21,11 +21,11 @@ ini_set('max_execution_time', 3000);
 
 if (stristr(PHP_OS, 'WIN')) {
   define('CIVICRM_DIRECTORY_SEPARATOR', '/');
-  define('CIVICRM_WINDOWS', 1 );
+  define('CIVICRM_WINDOWS', 1);
 }
 else {
   define('CIVICRM_DIRECTORY_SEPARATOR', DIRECTORY_SEPARATOR);
-  define('CIVICRM_WINDOWS', 0 );
+  define('CIVICRM_WINDOWS', 0);
 }
 
 // set installation type - drupal
@@ -50,18 +50,15 @@ else {
 global $installType;
 $installType = strtolower($_SESSION['civicrm_install_type']);
 
-if (!in_array($installType, array(
-  'drupal', 'wordpress'))) {
+if (!in_array($installType, array('drupal', 'wordpress'))) {
   $errorTitle = "Oops! Unsupported installation mode";
   $errorMsg = "";
   errorDisplayPage($errorTitle, $errorMsg);
 }
 
 global $crmPath;
-global $pkgPath;
 global $installDirPath;
 global $installURLPath;
-
 if ($installType == 'drupal') {
   $crmPath = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
   $installDirPath = $installURLPath = '';
@@ -69,30 +66,31 @@ if ($installType == 'drupal') {
 elseif ($installType == 'wordpress') {
   $crmPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR;
   $installDirPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR;
+
   $installURLPath = WP_PLUGIN_URL . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR;
 }
 
-$pkgPath = $crmPath . DIRECTORY_SEPARATOR . 'packages';
-
-set_include_path(
-  $crmPath . PATH_SEPARATOR .
-  $pkgPath . PATH_SEPARATOR .
-  get_include_path()
-);
+set_include_path(get_include_path() . PATH_SEPARATOR . $crmPath);
 
 require_once $crmPath . '/CRM/Core/ClassLoader.php';
 CRM_Core_ClassLoader::singleton()->register();
 
-$docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, 'Installation Guide',NULL,NULL,"wiki");
+$docLink = CRM_Utils_System::docURL2('Installation and Upgrades', FALSE, 'Installation Guide', NULL, NULL, "wiki");
 
 if ($installType == 'drupal') {
-  // Lets check only /modules/.
+  //lets check only /modules/.
   $pattern = '/' . preg_quote(CIVICRM_DIRECTORY_SEPARATOR . 'modules', CIVICRM_DIRECTORY_SEPARATOR) . '/';
 
-  if (!preg_match($pattern, str_replace("\\", "/", $_SERVER['SCRIPT_FILENAME']))) {
+  if (!preg_match($pattern,
+    str_replace("\\", "/", $_SERVER['SCRIPT_FILENAME'])
+  )
+  ) {
     $errorTitle = "Oops! Please Correct Your Install Location";
     $errorMsg = "Please untar (uncompress) your downloaded copy of CiviCRM in the <strong>" . implode(CIVICRM_DIRECTORY_SEPARATOR, array(
-      'sites', 'all', 'modules')) . "</strong> directory below your Drupal root directory. Refer to the online " . $docLink . " for more information.";
+        'sites',
+        'all',
+        'modules',
+      )) . "</strong> directory below your Drupal root directory. Refer to the online " . $docLink . " for more information.";
     errorDisplayPage($errorTitle, $errorMsg);
   }
 }
@@ -140,25 +138,11 @@ foreach ($langs as $locale => $_) {
   }
 }
 
-// Set the locale (works with both native gettext and phpgettext)
-define('CIVICRM_UF', 'Drupal');
-define('CIVICRM_GETTEXT_NATIVE', 1);
-global $tsLocale;
-
-$tsLocale = 'en_US';
 $seedLanguage = 'en_US';
-
 if (isset($_REQUEST['seedLanguage']) and isset($langs[$_REQUEST['seedLanguage']])) {
   $seedLanguage = $_REQUEST['seedLanguage'];
-  $tsLocale = $_REQUEST['seedLanguage'];
 }
 
-$config = CRM_Core_Config::singleton(FALSE);
-
-// The translation files are in the parent directory (l10n)
-$config->gettextResourceDir = '..' . DIRECTORY_SEPARATOR . $config->gettextResourceDir;
-$i18n = CRM_Core_I18n::singleton();
-
 global $cmsPath;
 if ($installType == 'drupal') {
   //CRM-6840 -don't force to install in sites/all/modules/
@@ -185,7 +169,10 @@ if ($alreadyInstalled) {
   if ($installType == 'drupal') {
 
     $errorMsg = "CiviCRM has already been installed in this Drupal site. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>" . implode(CIVICRM_DIRECTORY_SEPARATOR, array(
-      '[your Drupal root directory]', 'sites', $siteDir)) . "</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online " . $docLink . ".</li></ul>";
+        '[your Drupal root directory]',
+        'sites',
+        $siteDir,
+      )) . "</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online " . $docLink . ".</li></ul>";
   }
   elseif ($installType == 'wordpress') {
     $errorMsg = "CiviCRM has already been installed in this WordPress site. <ul><li>To <strong>start over</strong>, you must delete or rename the existing CiviCRM settings file - <strong>civicrm.settings.php</strong> - from <strong>" . $cmsPath . "</strong>.</li><li>To <strong>upgrade an existing installation</strong>, refer to the online " . $docLink . ".</li></ul>";
@@ -195,7 +182,7 @@ if ($alreadyInstalled) {
 
 $versionFile = $crmPath . CIVICRM_DIRECTORY_SEPARATOR . 'civicrm-version.php';
 if (file_exists($versionFile)) {
-  require_once ($versionFile);
+  require_once $versionFile;
   $civicrm_version = civicrmVersion();
 }
 else {
@@ -263,7 +250,7 @@ if ($databaseConfig) {
 if (isset($_REQUEST['go']) && !$req->hasErrors() && !$dbReq->hasErrors()) {
   // Confirm before reinstalling
   if (!isset($_REQUEST['force_reinstall']) && $alreadyInstalled) {
-    include ($installDirPath . 'template.html');
+    include $installDirPath . 'template.html';
   }
   else {
     $inst = new Installer();
@@ -273,7 +260,7 @@ if (isset($_REQUEST['go']) && !$req->hasErrors() && !$dbReq->hasErrors()) {
   // Show the config form
 }
 else {
-  include ($installDirPath . 'template.html');
+  include $installDirPath . 'template.html';
 }
 
 /**
@@ -291,37 +278,41 @@ class InstallRequirements {
   const MINIMUM_THREAD_STACK = 192;
 
   /**
-   * Just check that the database configuration is okay
+   * Just check that the database configuration is okay.
+   * @param $databaseConfig
+   * @param $dbName
    */
-  function checkdatabase($databaseConfig, $dbName) {
+  public function checkdatabase($databaseConfig, $dbName) {
     if ($this->requireFunction('mysql_connect',
-        array(
-          ts("PHP Configuration"),
-          ts("MySQL support"),
-          ts("MySQL support not included in PHP."),
-        )
-      )) {
+      array(
+        "PHP Configuration",
+        "MySQL support",
+        "MySQL support not included in PHP.",
+      )
+    )
+    ) {
       $this->requireMySQLServer($databaseConfig['server'],
         array(
-          ts("MySQL %1 Configuration", array(1 => $dbName)),
-          ts("Does the server exist?"),
-          ts("Can't find the a MySQL server on '%1'", array(1 => $databaseConfig['server'])),
+          "MySQL $dbName Configuration",
+          "Does the server exist",
+          "Can't find the a MySQL server on '$databaseConfig[server]'",
           $databaseConfig['server'],
         )
       );
       if ($this->requireMysqlConnection($databaseConfig['server'],
-          $databaseConfig['username'],
-          $databaseConfig['password'],
-          array(
-            ts("MySQL %1 Configuration", array(1 => $dbName)),
-            ts("Are the access credentials correct?"),
-            ts("That username/password doesn't work"),
-          )
-        )) {
+        $databaseConfig['username'],
+        $databaseConfig['password'],
+        array(
+          "MySQL $dbName Configuration",
+          "Are the access credentials correct",
+          "That username/password doesn't work",
+        )
+      )
+      ) {
         @$this->requireMySQLVersion("5.1",
           array(
-            ts("MySQL %1 Configuration", array(1 => $dbName)),
-            ts("MySQL version at least %1", array(1 => '5.1')),
+            "MySQL $dbName Configuration",
+            "MySQL version at least 5.1",
             "MySQL version 5.1 or higher is required, you only have ",
             "MySQL " . mysql_get_server_info(),
           )
@@ -343,7 +334,8 @@ class InstallRequirements {
           array(
             "MySQL $dbName Configuration",
             "Does MySQL thread_stack meet minimum (" . self::MINIMUM_THREAD_STACK . "k)",
-            "", // "The MySQL thread_stack does not meet minimum " . CRM_Upgrade_Form::MINIMUM_THREAD_STACK . "k. Please update thread_stack in my.cnf.",
+            "",
+            // "The MySQL thread_stack does not meet minimum " . CRM_Upgrade_Form::MINIMUM_THREAD_STACK . "k. Please update thread_stack in my.cnf.",
           )
         );
       }
@@ -406,21 +398,26 @@ class InstallRequirements {
   }
 
   /**
-   * Check everything except the database
+   * Check everything except the database.
    */
-  function check() {
+  public function check() {
     global $crmPath, $installType;
 
     $this->errors = NULL;
 
-    $this->requirePHPVersion('5.3.3', array(ts("PHP Configuration"), ts("PHP5 installed"), NULL, ts("PHP version %1", array(1 => phpversion()))));
+    $this->requirePHPVersion('5.3.3', array(
+      "PHP Configuration",
+      "PHP5 installed",
+      NULL,
+      "PHP version " . 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."),
+        "File permissions",
+        "Does the webserver know where files are stored?",
+        "The webserver isn't letting me identify where files are stored.",
         $this->getBaseDir(),
       ),
       TRUE
@@ -429,9 +426,9 @@ class InstallRequirements {
     // 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 %1 path contains the PATH_SEPARATOR (the %2 character)', array(1 => $this->getBaseDir(), 2 => PATH_SEPARATOR)),
+        'File permissions',
+        'does the CiviCRM path contain PATH_SEPARATOR?',
+        'the ' . $this->getBaseDir() . ' path contains PATH_SEPARATOR (the ' . PATH_SEPARATOR . ' character)',
         $this->getBaseDir(),
       )
     );
@@ -440,11 +437,10 @@ class InstallRequirements {
     foreach ($requiredDirectories as $dir) {
       $this->requireFile($crmPath . CIVICRM_DIRECTORY_SEPARATOR . $dir,
         array(
-          ts("File permissions"),
-          ts("%1: folder exists", array(1 => $dir)),
-          ts("%1: folder is missing", array(1 => $dir)),
-        ),
-        TRUE
+          "File permissions",
+          "$dir folder exists",
+          "There is no $dir folder",
+        ), TRUE
       );
     }
 
@@ -472,7 +468,7 @@ class InstallRequirements {
     foreach ($writableDirectories as $dir) {
       $dirName = CIVICRM_WINDOWS ? $dir : CIVICRM_DIRECTORY_SEPARATOR . $dir;
       $this->requireWriteable($dirName,
-        array(ts("File permissions"), ts("Is the %1 folder writeable?", array(1 => $dir)), NULL),
+        array("File permissions", "Is the $dir folder writeable?", NULL),
         TRUE
       );
     }
@@ -496,36 +492,40 @@ class InstallRequirements {
     }
 
     if ($webserver == '') {
-      $webserver = ts("I can't tell what webserver you are running");
+      $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."));
+    $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(ts("PHP Configuration"), ts("MySQL support"), ts("MySQL support not included in PHP."))
+      array("PHP Configuration", "MySQL support", "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."))
+      array("PHP Configuration", "JSON support", "JSON support not included in PHP.")
     );
 
     // Check for xcache_isset and emit warning if exists
     $this->checkXCache(array(
-      ts("PHP Configuration"),
-        "XCache compatibility",
-        "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.",
-      ));
+      "PHP Configuration",
+      "XCache compatibility",
+      "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 32M allocated to PHP, but recommends 64M."),
+        "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"),
       )
     );
@@ -533,25 +533,33 @@ class InstallRequirements {
     return $this->errors;
   }
 
-  function requireMemory($min, $recommended, $testDetails) {
+  /**
+   * @param $min
+   * @param $recommended
+   * @param $testDetails
+   */
+  public function requireMemory($min, $recommended, $testDetails) {
     $this->testing($testDetails);
     $mem = $this->getPHPMemory();
 
     if ($mem < $min && $mem > 0) {
-      $testDetails[2] .= " " . ts("You only have %1 of memory allocated", array(1 => ini_get("memory_limit")));
+      $testDetails[2] .= " You only have " . ini_get("memory_limit") . " allocated";
       $this->error($testDetails);
     }
     elseif ($mem < $recommended && $mem > 0) {
-      $testDetails[2] .= " " . ts("You only have %1 of memory allocated", array(1 => ini_get("memory_limit")));
+      $testDetails[2] .= " You only have " . ini_get("memory_limit") . " allocated";
       $this->warning($testDetails);
     }
     elseif ($mem == 0) {
-      $testDetails[2] .= " " . ts("We can't determine how much memory you have allocated. Install only if you're sure you've allocated at least 20 MB.");
+      $testDetails[2] .= " We can't determine how much memory you have allocated. Install only if you're sure you've allocated at least 20 MB.";
       $this->warning($testDetails);
     }
   }
 
-  function getPHPMemory() {
+  /**
+   * @return float
+   */
+  public function getPHPMemory() {
     $memString = ini_get("memory_limit");
 
     switch (strtolower(substr($memString, -1))) {
@@ -569,16 +577,19 @@ class InstallRequirements {
     }
   }
 
-  function listErrors() {
+  public function listErrors() {
     if ($this->errors) {
-      echo "<p>" . ts("The following problems are preventing me from installing CiviCRM:") . "</p>";
+      echo "<p>The following problems are preventing me from installing CiviCRM:</p>";
       foreach ($this->errors as $error) {
         echo "<li>" . htmlentities($error) . "</li>";
       }
     }
   }
 
-  function showTable($section = NULL) {
+  /**
+   * @param null $section
+   */
+  public function showTable($section = NULL) {
     if ($section) {
       $tests = $this->tests[$section];
       echo "<table class=\"testResults\" width=\"100%\">";
@@ -600,7 +611,13 @@ class InstallRequirements {
     }
   }
 
-  function requireFunction($funcName, $testDetails) {
+  /**
+   * @param string $funcName
+   * @param $testDetails
+   *
+   * @return bool
+   */
+  public function requireFunction($funcName, $testDetails) {
     $this->testing($testDetails);
 
     if (!function_exists($funcName)) {
@@ -612,7 +629,10 @@ class InstallRequirements {
     }
   }
 
-  function checkXCache($testDetails) {
+  /**
+   * @param $testDetails
+   */
+  public function checkXCache($testDetails) {
     if (function_exists('xcache_isset') &&
       ini_get('xcache.size') > 0
     ) {
@@ -621,11 +641,16 @@ class InstallRequirements {
     }
   }
 
-  function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) {
+  /**
+   * @param $minVersion
+   * @param $testDetails
+   * @param null $maxVersion
+   */
+  public function requirePHPVersion($minVersion, $testDetails, $maxVersion = NULL) {
 
     $this->testing($testDetails);
 
-    $phpVersion      = phpversion();
+    $phpVersion = phpversion();
     $aboveMinVersion = version_compare($phpVersion, $minVersion) >= 0;
     $belowMaxVersion = $maxVersion ? version_compare($phpVersion, $maxVersion) < 0 : TRUE;
 
@@ -648,7 +673,12 @@ class InstallRequirements {
     $this->error($testDetails);
   }
 
-  function requireFile($filename, $testDetails, $absolute = FALSE) {
+  /**
+   * @param string $filename
+   * @param $testDetails
+   * @param bool $absolute
+   */
+  public function requireFile($filename, $testDetails, $absolute = FALSE) {
     $this->testing($testDetails);
     if (!$absolute) {
       $filename = $this->getBaseDir() . $filename;
@@ -659,14 +689,21 @@ class InstallRequirements {
     }
   }
 
-  function requireNoPathSeparator($testDetails) {
+  /**
+   * @param $testDetails
+   */
+  public function requireNoPathSeparator($testDetails) {
     $this->testing($testDetails);
     if (substr_count($this->getBaseDir(), PATH_SEPARATOR)) {
       $this->error($testDetails);
     }
   }
 
-  function requireNoFile($filename, $testDetails) {
+  /**
+   * @param string $filename
+   * @param $testDetails
+   */
+  public function requireNoFile($filename, $testDetails) {
     $this->testing($testDetails);
     $filename = $this->getBaseDir() . $filename;
     if (file_exists($filename)) {
@@ -675,7 +712,11 @@ class InstallRequirements {
     }
   }
 
-  function moveFileOutOfTheWay($filename, $testDetails) {
+  /**
+   * @param string $filename
+   * @param $testDetails
+   */
+  public function moveFileOutOfTheWay($filename, $testDetails) {
     $this->testing($testDetails);
     $filename = $this->getBaseDir() . $filename;
     if (file_exists($filename)) {
@@ -686,13 +727,18 @@ class InstallRequirements {
     }
   }
 
-  function requireWriteable($filename, $testDetails, $absolute = FALSE) {
+  /**
+   * @param string $filename
+   * @param $testDetails
+   * @param bool $absolute
+   */
+  public function requireWriteable($filename, $testDetails, $absolute = FALSE) {
     $this->testing($testDetails);
     if (!$absolute) {
       $filename = $this->getBaseDir() . $filename;
     }
 
-    if (!is_writeable($filename)) {
+    if (!is_writable($filename)) {
       $name = NULL;
       if (function_exists('posix_getpwuid')) {
         $user = posix_getpwuid(posix_geteuid());
@@ -707,14 +753,24 @@ class InstallRequirements {
     }
   }
 
-  function requireApacheModule($moduleName, $testDetails) {
+  /**
+   * @param string $moduleName
+   * @param $testDetails
+   */
+  public function requireApacheModule($moduleName, $testDetails) {
     $this->testing($testDetails);
     if (!in_array($moduleName, apache_get_modules())) {
       $this->error($testDetails);
     }
   }
 
-  function requireMysqlConnection($server, $username, $password, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $testDetails
+   */
+  public function requireMysqlConnection($server, $username, $password, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
 
@@ -727,7 +783,11 @@ class InstallRequirements {
     }
   }
 
-  function requireMySQLServer($server, $testDetails) {
+  /**
+   * @param $server
+   * @param $testDetails
+   */
+  public function requireMySQLServer($server, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, NULL, NULL);
 
@@ -740,7 +800,11 @@ class InstallRequirements {
     }
   }
 
-  function requireMySQLVersion($version, $testDetails) {
+  /**
+   * @param $version
+   * @param $testDetails
+   */
+  public function requireMySQLVersion($version, $testDetails) {
     $this->testing($testDetails);
 
     if (!mysql_get_server_info()) {
@@ -761,7 +825,14 @@ class InstallRequirements {
     }
   }
 
-  function requireMySQLInnoDB($server, $username, $password, $database, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $testDetails
+   */
+  public function requireMySQLInnoDB($server, $username, $password, $database, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
     if (!$conn) {
@@ -789,7 +860,14 @@ class InstallRequirements {
     }
   }
 
-  function requireMySQLTempTables($server, $username, $password, $database, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $testDetails
+   */
+  public function requireMySQLTempTables($server, $username, $password, $database, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
     if (!$conn) {
@@ -812,7 +890,14 @@ class InstallRequirements {
     $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
   }
 
-  function requireMySQLTrigger($server, $username, $password, $database, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $testDetails
+   */
+  public function requireMySQLTrigger($server, $username, $password, $database, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
     if (!$conn) {
@@ -840,13 +925,19 @@ class InstallRequirements {
       $this->error($testDetails);
     }
 
-
     mysql_query('DROP TRIGGER civicrm_install_temp_table_test_trigger');
     mysql_query('DROP TABLE civicrm_install_temp_table_test');
   }
 
 
-  function requireMySQLLockTables($server, $username, $password, $database, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $testDetails
+   */
+  public function requireMySQLLockTables($server, $username, $password, $database, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
     if (!$conn) {
@@ -885,10 +976,15 @@ class InstallRequirements {
     }
 
     $result = mysql_query('DROP TEMPORARY TABLE civicrm_install_temp_table_test');
-    return;
   }
 
-  function requireMySQLAutoIncrementIncrementOne($server, $username, $password, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $testDetails
+   */
+  public function requireMySQLAutoIncrementIncrementOne($server, $username, $password, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
     if (!$conn) {
@@ -914,7 +1010,15 @@ class InstallRequirements {
     }
   }
 
-  function requireMySQLThreadStack($server, $username, $password, $database, $minValueKB, $testDetails) {
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $minValueKB
+   * @param $testDetails
+   */
+  public function requireMySQLThreadStack($server, $username, $password, $database, $minValueKB, $testDetails) {
     $this->testing($testDetails);
     $conn = @mysql_connect($server, $username, $password);
     if (!$conn) {
@@ -933,16 +1037,26 @@ class InstallRequirements {
     if (!$result) {
       $testDetails[2] = 'Could not query thread_stack.';
       $this->error($testDetails);
-    } else {
+    }
+    else {
       $values = mysql_fetch_row($result);
-      if ($values[1] < (1024*$minValueKB)) {
-        $testDetails[2] = 'MySQL "thread_stack" is ' . ($values[1]/1024) . 'k';
+      if ($values[1] < (1024 * $minValueKB)) {
+        $testDetails[2] = 'MySQL "thread_stack" is ' . ($values[1] / 1024) . 'k';
         $this->error($testDetails);
       }
     }
   }
 
-  function requireDatabaseOrCreatePermissions($server,
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $testDetails
+   * @param bool $onlyRequire
+   */
+  public function requireDatabaseOrCreatePermissions(
+    $server,
     $username,
     $password,
     $database,
@@ -978,7 +1092,11 @@ class InstallRequirements {
     }
   }
 
-  function requireServerVariables($varNames, $errorMessage) {
+  /**
+   * @param $varNames
+   * @param $errorMessage
+   */
+  public function requireServerVariables($varNames, $errorMessage) {
     //$this->testing($testDetails);
     foreach ($varNames as $varName) {
       if (!$_SERVER[$varName]) {
@@ -994,7 +1112,12 @@ class InstallRequirements {
     }
   }
 
-  function isRunningApache($testDetails) {
+  /**
+   * @param $testDetails
+   *
+   * @return bool
+   */
+  public function isRunningApache($testDetails) {
     $this->testing($testDetails);
     if (function_exists('apache_get_modules') || stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')) {
       return TRUE;
@@ -1004,11 +1127,17 @@ class InstallRequirements {
     return FALSE;
   }
 
-  function getBaseDir() {
+  /**
+   * @return string
+   */
+  public function getBaseDir() {
     return dirname($_SERVER['SCRIPT_FILENAME']) . CIVICRM_DIRECTORY_SEPARATOR;
   }
 
-  function testing($testDetails) {
+  /**
+   * @param $testDetails
+   */
+  public function testing($testDetails) {
     if (!$testDetails) {
       return;
     }
@@ -1024,7 +1153,10 @@ class InstallRequirements {
     $this->tests[$section][$test] = array("good", $message);
   }
 
-  function error($testDetails) {
+  /**
+   * @param $testDetails
+   */
+  public function error($testDetails) {
     $section = $testDetails[0];
     $test = $testDetails[1];
 
@@ -1032,26 +1164,44 @@ class InstallRequirements {
     $this->errors[] = $testDetails;
   }
 
-  function warning($testDetails) {
+  /**
+   * @param $testDetails
+   */
+  public function warning($testDetails) {
     $section = $testDetails[0];
     $test = $testDetails[1];
 
-
     $this->tests[$section][$test] = array("warning", $testDetails[2]);
     $this->warnings[] = $testDetails;
   }
 
-  function hasErrors() {
-    return sizeof($this->errors);
+  /**
+   * @return int
+   */
+  public function hasErrors() {
+    return count($this->errors);
   }
 
-  function hasWarnings() {
-    return sizeof($this->warnings);
+  /**
+   * @return int
+   */
+  public function hasWarnings() {
+    return count($this->warnings);
   }
+
 }
 
+/**
+ * Class Installer
+ */
 class Installer extends InstallRequirements {
-  function createDatabaseIfNotExists($server, $username, $password, $database) {
+  /**
+   * @param $server
+   * @param $username
+   * @param $password
+   * @param $database
+   */
+  public function createDatabaseIfNotExists($server, $username, $password, $database) {
     $conn = @mysql_connect($server, $username, $password);
 
     if (@mysql_select_db($database)) {
@@ -1059,7 +1209,8 @@ class Installer extends InstallRequirements {
       return;
     }
 
-    if (@mysql_query("CREATE DATABASE $database")) {}
+    if (@mysql_query("CREATE DATABASE $database")) {
+    }
     else {
       $errorTitle = "Oops! Could not create Database $database";
       $errorMsg = "We encountered an error when attempting to create the database. Please check your mysql server permissions and the database name and try again.";
@@ -1067,7 +1218,12 @@ class Installer extends InstallRequirements {
     }
   }
 
-  function install($config) {
+  /**
+   * @param $config
+   *
+   * @return mixed
+   */
+  public function install($config) {
     global $installDirPath;
 
     // create database if does not exists
@@ -1086,9 +1242,9 @@ class Installer extends InstallRequirements {
     if (!$this->errors) {
       global $installType, $installURLPath;
 
-      $registerSiteURL = "http://civicrm.org/civicrm/profile/create?reset=1&gid=15";
+      $registerSiteURL = "https://civicrm.org/register-site";
       $commonOutputMessage = "
-                      <li> Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='$registerSiteURL' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>
+                      <li>Have you registered this site at CiviCRM.org? If not, please help strengthen the CiviCRM ecosystem by taking a few minutes to <a href='$registerSiteURL' target='_blank'>fill out the site registration form</a>. The information collected will help us prioritize improvements, target our communications and build the community. If you have a technical role for this site, be sure to check Keep in Touch to receive technical updates (a low volume  mailing list).</li>
                       <li>We have integrated KCFinder with CKEditor and TinyMCE. This allows a user to upload images. All uploaded images are public.</li>
 ";
 
@@ -1110,7 +1266,7 @@ class Installer extends InstallRequirements {
         $output .= '<body>';
         $output .= '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
         $output .= '<ul>';
-        $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here',NULL,NULL,"wiki");
+        $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
         if (!function_exists('ts')) {
           $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
         }
@@ -1179,7 +1335,7 @@ class Installer extends InstallRequirements {
         $output .= '<body>';
         $output .= '<div style="padding: 1em;"><p class="good">CiviCRM has been successfully installed</p>';
         $output .= '<ul>';
-        $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here',NULL,NULL,"wiki");
+        $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
         if (!function_exists('ts')) {
           $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
         }
@@ -1222,7 +1378,7 @@ class Installer extends InstallRequirements {
         echo '<h1>CiviCRM Installed</h1>';
         echo '<div style="padding: 1em;"><p style="background-color: #0C0; border: 1px #070 solid; color: white;">CiviCRM has been successfully installed</p>';
         echo '<ul>';
-        $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here',NULL,NULL,"wiki");
+        $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki");
         if (!function_exists('ts')) {
           $docLinkConfig = "<a href=\"{$docLinkConfig}\">here</a>";
         }
@@ -1237,13 +1393,14 @@ class Installer extends InstallRequirements {
           {$commonOutputMessage}
 ";
 
-         echo '</ul>';
-         echo '</div>';
-       }
-     }
+        echo '</ul>';
+        echo '</div>';
+      }
+    }
 
     return $this->errors;
   }
+
 }
 
 function civicrm_install_set_drupal_perms() {
@@ -1271,8 +1428,8 @@ function civicrm_install_set_drupal_perms() {
     foreach (array_diff($perms, $allPerms) as $perm) {
       watchdog('civicrm',
         'Cannot grant the %perm permission because it does not yet exist.',
-        array(
-          '%perm' => $perm), WATCHDOG_ERROR
+        array('%perm' => $perm),
+        WATCHDOG_ERROR
       );
     }
     $perms = array_intersect($perms, $allPerms);
@@ -1281,6 +1438,12 @@ function civicrm_install_set_drupal_perms() {
   }
 }
 
+/**
+ * @param $cmsPath
+ * @param $str
+ *
+ * @return string
+ */
 function getSiteDir($cmsPath, $str) {
   static $siteDir = '';
 
@@ -1305,8 +1468,8 @@ function getSiteDir($cmsPath, $str) {
       for ($j = count($server); $j > 0; $j--) {
         $dir = implode('.', array_slice($server, -$j)) . implode('.', array_slice($uri, 0, $i));
         if (file_exists($cmsPath . CIVICRM_DIRECTORY_SEPARATOR .
-            'sites' . CIVICRM_DIRECTORY_SEPARATOR . $dir
-          )) {
+          'sites' . CIVICRM_DIRECTORY_SEPARATOR . $dir
+        )) {
           $siteDir = $dir;
           return $siteDir;
         }
@@ -1318,8 +1481,11 @@ function getSiteDir($cmsPath, $str) {
   return $siteDir;
 }
 
+/**
+ * @param $errorTitle
+ * @param $errorMsg
+ */
 function errorDisplayPage($errorTitle, $errorMsg) {
-  include ('error.html');
+  include 'error.html';
   exit();
 }
-