use DOMDocument;\r
\r
/**\r
- * @brief Contains the class with install relevant stuff *\r
+ * Contains methods for installation purpose of Friendica\r
*/\r
class Install extends BaseObject\r
{\r
+ /**\r
+ * Sets the install-mode for further methods\r
+ */\r
public static function setInstallMode()\r
{\r
self::getApp()->mode = App::MODE_INSTALL;\r
}\r
\r
+ /**\r
+ * Checks the current installation environment. There are optional and mandatory checks.\r
+ *\r
+ * @param string $phpath Optional path to the PHP binary (Default is 'php')\r
+ *\r
+ * @return array First element is a list of all checks and their results,\r
+ * the second element is a list of passed checks\r
+ */\r
public static function check($phpath = 'php')\r
{\r
$checks = [];\r
\r
self::checkFunctions($checks);\r
\r
- self::checkImagik($checks);\r
+ self::checkImagick($checks);\r
\r
self::checkHtConfig($checks);\r
\r
return array($checks, $checkspassed);\r
}\r
\r
+ /**\r
+ * Executes the installation of Friendica in the given environment.\r
+ * - Creates `.htconfig.php`\r
+ * - Installs Database Structure\r
+ *\r
+ * @param string $urlpath Path based on the URL of Friendica (e.g. '/friendica')\r
+ * @param string $dbhost Hostname/IP of the Friendica Database\r
+ * @param string $dbuser Username of the Database connection credentials\r
+ * @param string $dbpass Password of the Database connection credentials\r
+ * @param string $dbdata Name of the Database\r
+ * @param string $phpath Path to the PHP-Binary (e.g. 'php' or '/usr/bin/php')\r
+ * @param string $timezone Timezone of the Friendica Installaton (e.g. 'Europe/Berlin')\r
+ * @param string $language 2-letter ISO 639-1 code (eg. 'en')\r
+ * @param string $adminmail Mail-Adress of the administrator\r
+ * @param int $rino Rino-enabled (1 = true, 0 = false)\r
+ */\r
public static function install($urlpath, $dbhost, $dbuser, $dbpass, $dbdata, $phpath, $timezone, $language, $adminmail, $rino = 1)\r
{\r
$tpl = get_markup_template('htconfig.tpl');\r
'$rino' => $rino\r
]);\r
\r
-\r
$result = file_put_contents('.htconfig.php', $txt);\r
if (! $result) {\r
self::getApp()->data['txt'] = $txt;\r
}\r
\r
- $errors = self::loadDatabase();\r
+ $errors = self::installDatabaseStructure();\r
\r
if ($errors) {\r
self::getApp()->data['db_failed'] = $errors;\r
}\r
\r
/**\r
- * checks : array passed to template\r
- * title : string\r
- * status : boolean\r
- * required : boolean\r
- * help : string optional\r
+ * Adds new checks to the array $checks\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ * @param string $title The title of the current check\r
+ * @param bool $status 1 = check passed, 0 = check not passed\r
+ * @param bool $required 1 = check is mandatory, 0 = check is optional\r
+ * @param string $help A help-string for the current check\r
+ * @param string $error_msg Optional. A error message, if the current check failed\r
*/\r
- private static function addCheck(&$checks, $title, $status, $required, $help)\r
+ private static function addCheck(&$checks, $title, $status, $required, $help, $error_msg = "")\r
{\r
$checks[] = [\r
'title' => $title,\r
];\r
}\r
\r
+ /**\r
+ * PHP Check\r
+ *\r
+ * Checks the PHP environment.\r
+ *\r
+ * - Checks if a PHP binary is available\r
+ * - Checks if it is the CLI version\r
+ * - Checks if "register_argc_argv" is enabled\r
+ *\r
+ * @param string $phpath Optional. The Path to the PHP-Binary\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
public static function checkPHP(&$phpath, &$checks)\r
{\r
$passed = $passed2 = $passed3 = false;\r
self::addCheck($checks, L10n::t('PHP cli binary'), $passed2, true, $help);\r
}\r
\r
-\r
if ($passed2) {\r
$str = autoname(8);\r
$cmd = "$phpath testargs.php $str";\r
}\r
self::addCheck($checks, L10n::t('PHP register_argc_argv'), $passed3, true, $help);\r
}\r
-\r
-\r
}\r
\r
+ /**\r
+ * OpenSSL Check\r
+ *\r
+ * Checks the OpenSSL Environment\r
+ *\r
+ * - Checks, if the command "openssl_pkey_new" is available\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
public static function checkKeys(&$checks)\r
{\r
-\r
$help = '';\r
-\r
$res = false;\r
\r
if (function_exists('openssl_pkey_new')) {\r
}\r
\r
// Get private key\r
-\r
if (!$res) {\r
$help .= L10n::t('Error: the "openssl_pkey_new" function on this system is not able to generate encryption keys') . EOL;\r
$help .= L10n::t('If running under Windows, please see "http://www.php.net/manual/en/openssl.installation.php".');\r
}\r
self::addCheck($checks, L10n::t('Generate encryption keys'), $res, true, $help);\r
-\r
}\r
\r
-\r
+ /**\r
+ * PHP functions Check\r
+ *\r
+ * Checks the following PHP functions\r
+ * - libCurl\r
+ * - GD Graphics\r
+ * - OpenSSL\r
+ * - PDO or MySQLi\r
+ * - mb_string\r
+ * - XML\r
+ * - iconv\r
+ * - POSIX\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
public static function checkFunctions(&$checks)\r
{\r
$ck_funcs = [];\r
}\r
}\r
\r
-\r
+ /**\r
+ * ".htconfig.php" - Check\r
+ *\r
+ * Checks if it's possible to create the ".htconfig.php"\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
public static function checkHtConfig(&$checks)\r
{\r
$status = true;\r
\r
}\r
\r
+ /**\r
+ * Smarty3 Template Check\r
+ *\r
+ * Checks, if the directory of Smarty3 is writable\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
public static function checkSmarty3(&$checks)\r
{\r
$status = true;\r
\r
}\r
\r
+ /**\r
+ * ".htaccess" - Check\r
+ *\r
+ * Checks, if "url_rewrite" is enabled in the ".htaccess" file\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
public static function checkHtAccess(&$checks)\r
{\r
$status = true;\r
$error_msg['url'] = $test['redirect_url'];\r
$error_msg['msg'] = $test['error'];\r
}\r
- self::addCheck($checks, L10n::t('Url rewrite is working'), $status, true, $help);\r
+ self::addCheck($checks, L10n::t('Url rewrite is working'), $status, true, $help, $error_msg);\r
} else {\r
// cannot check modrewrite if libcurl is not installed\r
/// @TODO Maybe issue warning here?\r
}\r
}\r
\r
- public static function checkImagik(&$checks)\r
+ /**\r
+ * Imagick Check\r
+ *\r
+ * Checks, if the imagick module is available\r
+ *\r
+ * @param array $checks The list of all checks (by-ref parameter!)\r
+ */\r
+ public static function checkImagick(&$checks)\r
{\r
$imagick = false;\r
$gif = false;\r
}\r
}\r
\r
- public static function loadDatabase()\r
+ /**\r
+ * Installs the Database structure\r
+ *\r
+ * @return string A possible error\r
+ */\r
+ public static function installDatabaseStructure()\r
{\r
$errors = DBStructure::update(false, true, true);\r
\r