// conjoon settings // file related settings InstallLogger::stdout(InstallLogger::logMessage("Adding file related information to config.ini.php"), true); $configini = str_replace('{FILES.UPLOAD.MAX_SIZE}', $_SESSION['files']['upload.max_size'], $configini); $configini = str_replace('{FILES.STORAGE.FILESYSTEM.ENABLED}', $_SESSION['files']['storage.filesystem.enabled'] ? '1' : '0', $configini); $configini = str_replace('{FILES.STORAGE.FILESYSTEM.DIR}', $_SESSION['files']['storage.filesystem.enabled'] && $_SESSION['files']['storage.filesystem.dir'] ? $_SESSION['files']['storage.filesystem.dir'] : "", $configini); // Doctrine settings InstallLogger::stdout(InstallLogger::logMessage("Adding doctrine information to config.ini.php"), true); $configini = str_replace('{DOCTRINE.CACHE.ENABLED}', $_SESSION['application']['doctrine.cache.enabled'] ? '1' : '0', $configini); $doctrineCacheConfigKeys = array('QUERY_CACHE', 'METADATA_CACHE'); foreach ($doctrineCacheConfigKeys as $doctrineCacheConfigKey) { $configini = str_replace('{DOCTRINE.CACHE.' . $doctrineCacheConfigKey . '.ENABLED}', $_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.' . strtolower($doctrineCacheConfigKey) . '.enabled'] ? '1' : '0', $configini); $configini = str_replace('{DOCTRINE.CACHE.' . $doctrineCacheConfigKey . '.TYPE}', $_SESSION['application']['doctrine.cache.' . strtolower($doctrineCacheConfigKey) . '.enabled'] && $_SESSION['application']['doctrine.cache.enabled'] ? $_SESSION['application']['doctrine.cache.' . strtolower($doctrineCacheConfigKey) . '.type'] : '', $configini); $configini = str_replace('{DOCTRINE.CACHE.' . $doctrineCacheConfigKey . '.DIR}', $_SESSION['application']['doctrine.cache.' . strtolower($doctrineCacheConfigKey) . '.enabled'] && $_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.' . strtolower($doctrineCacheConfigKey) . '.type'] == 'file' ? $_SESSION['application']['doctrine.cache.' . strtolower($doctrineCacheConfigKey) . '.dir'] : '', $configini); } // overwrite the file completely, even if it still exists from a previous // installation! InstallLogger::stdout(InstallLogger::logMessage("Writing config.ini"), true); file_put_contents('../config.ini.php', $configini); $configini = ""; // generate and update install.info.php InstallLogger::stdout(InstallLogger::logMessage("Writing installation.info.php"), true); if (!file_exists('../installation.info.php')) { $installationinfo = file_get_contents('./installation.info.php.template'); } else { $installationinfo = file_get_contents('../installation.info.php'); } $installationinfo .= "\n\r\n // generated by conjoon V" . $_SESSION['current_version'] . "\r\n // on " . date("m-d-Y H:i:s", time()) . "\r\n \$INSTALLATION_INFO[] = array(\r\n 'locale_timezone_default' => '" . $_SESSION['locale_timezone_default'] . "',\r\n 'locale_timezone_fallback' => '" . $_SESSION['locale_timezone_fallback'] . "',\r\n 'support_key' => '" . $_SESSION['support_key'] . "',\r\n 'version' => '" . $_SESSION['current_version'] . "',\r\n 'date' => '" . time() . "',\r\n 'db_host' => '" . $_SESSION['db_host'] . "',\r\n 'db_adapter' => '" . $_SESSION['db_adapter'] . "',\r\n 'db' => '" . $_SESSION['db'] . "',\r\n 'db_port' => '" . $_SESSION['db_port'] . "',\r\n 'db_user' => '" . $_SESSION['db_user'] . "',\r\n 'db_table_prefix' => '" . $_SESSION['db_table_prefix'] . "',\r\n 'edition' => '" . $_SESSION['edition'] . "',\r\n 'max_allowed_packet' => '" . $_SESSION['max_allowed_packet'] . "',\r\n 'app_path' => '" . $_SESSION['app_path'] . "',\r\n 'lib_path' => '" . $_SESSION['lib_path'] . "',\r\n 'add_include_path' => '" . $_SESSION['add_include_path'] . "',\r\n 'doc_path' => '" . $_SESSION['doc_path'] . "',\r\n 'applied_patches' => array(" . (empty($_SESSION['applied_patches']) ? "" : "'") . implode("','", isset($_SESSION['applied_patches']) && is_array($_SESSION['applied_patches']) ? array_values($_SESSION['applied_patches']) : array()) . (empty($_SESSION['applied_patches']) ? "" : "'") . "),\r\n 'ignored_patches' => array(" . (empty($_SESSION['ignored_patches']) ? "" : "'") . implode("','", isset($_SESSION['ignored_patches']) && is_array($_SESSION['ignored_patches']) ? array_values($_SESSION['ignored_patches']) : array()) . (empty($_SESSION['ignored_patches']) ? "" : "'") . "),\r\n\r\n\r\n " . ($_SESSION['cache']['default.caching'] ? "\r\n\r\n 'cache.default.caching' => 1,\r\n\r\n 'cache.db.metadata.caching' => " . ($_SESSION['cache']['db.metadata.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['db.metadata.caching'] ? "'cache.db.metadata.backend.cache_dir' => '" . $_SESSION['cache']['db.metadata.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.email.message.caching' => " . ($_SESSION['cache']['email.message.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['email.message.caching'] ? "'cache.email.message.backend.cache_dir' => '" . $_SESSION['cache']['email.message.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.email.accounts.caching' => " . ($_SESSION['cache']['email.accounts.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['email.accounts.caching'] ? "'cache.email.accounts.backend.cache_dir' => '" . $_SESSION['cache']['email.accounts.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.email.folders_root_type.caching' => " . ($_SESSION['cache']['email.folders_root_type.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['email.folders_root_type.caching'] ? "'cache.email.folders_root_type.backend.cache_dir' => '" . $_SESSION['cache']['email.folders_root_type.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.feed.item.caching' => " . ($_SESSION['cache']['feed.item.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['feed.item.caching'] ? "'cache.feed.item.backend.cache_dir' => '" . $_SESSION['cache']['feed.item.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.feed.item_list.caching' => " . ($_SESSION['cache']['feed.item_list.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['feed.item_list.caching'] ? "'cache.feed.item_list.backend.cache_dir' => '" . $_SESSION['cache']['feed.item_list.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.feed.reader.caching' => " . ($_SESSION['cache']['feed.reader.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['feed.reader.caching'] ? "'cache.feed.reader.backend.cache_dir' => '" . $_SESSION['cache']['feed.reader.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.feed.account.caching' => " . ($_SESSION['cache']['feed.account.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['feed.account.caching'] ? "'cache.feed.account.backend.cache_dir' => '" . $_SESSION['cache']['feed.account.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.feed.account_list.caching' => " . ($_SESSION['cache']['feed.account_list.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['feed.account_list.caching'] ? "'cache.feed.account_list.backend.cache_dir' => '" . $_SESSION['cache']['feed.account_list.backend.cache_dir'] . "'," : "") . "\r\n\r\n 'cache.twitter.accounts.caching' => " . ($_SESSION['cache']['twitter.accounts.caching'] ? "1" : "0") . ",\r\n " . ($_SESSION['cache']['twitter.accounts.caching'] ? "'cache.twitter.accounts.backend.cache_dir' => '" . $_SESSION['cache']['twitter.accounts.backend.cache_dir'] . "'," : "") . "\r\n\r\n\r\n " : "'cache.default.caching' => 0,") . "'application.htmlpurifier.preload_all' => " . ($_SESSION['application']['htmlpurifier.preload_all'] ? '1' : '0') . ",\r\n 'application.htmlpurifier.use_cache' => " . ($_SESSION['application']['htmlpurifier.use_cache'] ? '1' : '0') . ",\r\n 'application.htmlpurifier.cache_dir' => " . ($_SESSION['application']['htmlpurifier.use_cache'] ? "'" . $_SESSION['application']['htmlpurifier.cache_dir'] . "'" : "''") . ",\r\n\r\n 'application.doctrine.cache.enabled' => " . ($_SESSION['application']['doctrine.cache.enabled'] ? '1' : '0') . ",\r\n 'application.doctrine.cache.query_cache.enabled' => " . ($_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.query_cache.enabled'] ? '1' : '0') . ",\r\n 'application.doctrine.cache.query_cache.type' => '" . ($_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.query_cache.enabled'] ? $_SESSION['application']['doctrine.cache.query_cache.type'] : '') . "',\r\n 'application.doctrine.cache.query_cache.dir' => " . ($_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.query_cache.enabled'] && $_SESSION['application']['doctrine.cache.query_cache.type'] == 'file' ? "'" . $_SESSION['application']['doctrine.cache.query_cache.dir'] . "'" : "''") . ",\r\n\r\n 'application.doctrine.cache.metadata_cache.enabled' => " . ($_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.metadata_cache.enabled'] ? '1' : '0') . ",\r\n 'application.doctrine.cache.metadata_cache.type' => '" . ($_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.metadata_cache.enabled'] ? $_SESSION['application']['doctrine.cache.metadata_cache.type'] : '') . "',\r\n 'application.doctrine.cache.metadata_cache.dir' => " . ($_SESSION['application']['doctrine.cache.enabled'] && $_SESSION['application']['doctrine.cache.metadata_cache.enabled'] && $_SESSION['application']['doctrine.cache.metadata_cache.type'] == 'file' ? "'" . $_SESSION['application']['doctrine.cache.metadata_cache.dir'] . "'" : "''") . ",\r\n\r\n 'files.upload.max_size' => " . $_SESSION['files']['upload.max_size'] . ",\r\n 'files.storage.filesystem.enabled' => " . ($_SESSION['files']['storage.filesystem.enabled'] ? '1' : '0') . ",\r\n 'files.storage.filesystem.dir' => " . ($_SESSION['files']['storage.filesystem.enabled'] && $_SESSION['files']['storage.filesystem.dir'] ? "'" . $_SESSION['files']['storage.filesystem.dir'] . "'" : "''") . ",\r\n\r\n 'app_credentials' => array('user' => '" . $_SESSION['app_credentials']['user'] . "')\r\n );\r\n "; file_put_contents('../installation.info.php', $installationinfo); $installationinfo = ""; echo "<script type=\"text/javascript\">this.location.href=\"./index.php?action=install_chunk_2\"</script>";
* @author Thorsten Suckow-Homberg <*****@*****.**> */ /** * check if user is authorized to load script */ include './scripts/check_auth.php'; InstallLogger::getInstance($_SESSION['install_process']['INSTALL_LOGGER']); InstallLogger::stdout(InstallLogger::logMessage("Cleaning up"), true); $INSTALL = array(); $INSTALL['IMREMOVING'] = array('_configCache' => file_exists('../_configCache'), 'js' => file_exists('../js')); // delete folders from a previous installation if ($INSTALL['IMREMOVING']['js']) { InstallLogger::stdout(InstallLogger::logMessage("Removing js from previous installation")); conjoon_rmdir('../js'); } if ($INSTALL['IMREMOVING']['_configCache']) { InstallLogger::stdout(InstallLogger::logMessage("Removing _configCache from previous installation")); conjoon_rmdir('../_configCache'); } // move js folder to htdocs InstallLogger::stdout(InstallLogger::logMessage("Moving js")); rename('./files/js', '../js'); // move _configCache to htdocs InstallLogger::stdout(InstallLogger::logMessage("Moving _configCache")); rename('./files/_configCache', '../_configCache'); conjoon_copy('./htaccess.deny.txt', '../_configCache/.htaccess'); InstallLogger::stdout(InstallLogger::logMessage("Done!")); InstallLogger::stdout("Click \"Next\" to finish!"); $txt = "Done! You can find a detailed log of the update progress here: " . "<a target=\"_blank\" href=\"" . $_SESSION['install_process']['INSTALL_LOGGER'] . "\">" . $_SESSION['install_process']['INSTALL_LOGGER'] . "</a>"; echo "<script type=\"text/javascript\">parent.updateProgressNote('" . $txt . "');</script>"; echo "<script type=\"text/javascript\">parent.document.getElementById('nextButton').disabled = false;</script>";
} // ... and create new dir if necessary if ($_SESSION['application']['htmlpurifier.use_cache'] && $_SESSION['application']['htmlpurifier.cache_dir']) { conjoon_mkdir($_SESSION['application']['htmlpurifier.cache_dir']); conjoon_copy('./htaccess.deny.txt', $_SESSION['application']['htmlpurifier.cache_dir'] . '/.htaccess'); } // process doctrine cache directories InstallLogger::stdout(InstallLogger::logMessage("Processing Doctrine cache directories"), true); $doctrineCacheConfigKeys = array('query_cache', 'metadata_cache'); foreach ($doctrineCacheConfigKeys as $doctrineCacheConfigKey) { // remove old doctrine cache if needed if (isset($_SESSION['installation_info']['application.doctrine.cache.' . $doctrineCacheConfigKey . '.type']) && $_SESSION['installation_info']['application.doctrine.cache.' . $doctrineCacheConfigKey . '.type'] == 'file' && isset($_SESSION['installation_info']['application.doctrine.cache.' . $doctrineCacheConfigKey . '.dir']) && file_exists($_SESSION['installation_info']['application.doctrine.cache.' . $doctrineCacheConfigKey . '.dir'])) { @conjoon_rmdir($_SESSION['installation_info']['application.doctrine.cache.' . $doctrineCacheConfigKey . '.dir']); } // ... and create new dir if necessary if ($_SESSION['application']['doctrine.cache.' . $doctrineCacheConfigKey . '.type'] == 'file' && $_SESSION['application']['doctrine.cache.' . $doctrineCacheConfigKey . '.dir']) { conjoon_mkdir($_SESSION['application']['doctrine.cache.' . $doctrineCacheConfigKey . '.dir']); conjoon_copy('./htaccess.deny.txt', $_SESSION['application']['doctrine.cache.' . $doctrineCacheConfigKey . '.dir'] . '/.htaccess'); } } // process file related directory // ... and create new dir if necessary // dont remove previous directories snce it might be needed to // re-store previous files handled by the dirs configured // for previous installations InstallLogger::stdout(InstallLogger::logMessage("Processing file system functionality"), true); if ($_SESSION['files']['storage.filesystem.enabled'] && $_SESSION['files']['storage.filesystem.dir']) { conjoon_mkdir($_SESSION['files']['storage.filesystem.dir']); conjoon_copy('./htaccess.deny.txt', $_SESSION['files']['storage.filesystem.dir'] . '/.htaccess'); } echo "<script type=\"text/javascript\">this.location.href=\"./index.php?action=install_chunk_5\"</script>";
* Install chunk_6 * * Takes care of patching - final run * * @author Thorsten Suckow-Homberg <*****@*****.**> */ /** * check if user is authorized to load script */ include './scripts/check_auth.php'; InstallLogger::getInstance($_SESSION['install_process']['INSTALL_LOGGER']); InstallLogger::stdout(InstallLogger::logMessage("Applying patches"), true); InstallLogger::stdout(InstallLogger::logMessage("Final run!")); // PREPARE PATCHES, IF ANY! if (isset($_SESSION['patches'])) { // apply patches, if any foreach ($_SESSION['patches'] as $patch => $doApply) { InstallLogger::stdout(InstallLogger::logMessage("Applying patch {$patch}"), true); if ($doApply) { if (file_exists('./patches/' . $patch . '/run.php')) { InstallLogger::stdout(InstallLogger::logMessage("Running {$patch}...")); include_once './patches/' . $patch . '/run.php'; } else { InstallLogger::stdout(InstallLogger::logMessage("{$patch} did not exist!")); } } } } else { InstallLogger::stdout(InstallLogger::logMessage("Nothing to do here..."), true); } echo "<script type=\"text/javascript\">this.location.href=\"./index.php?action=install_chunk_7\"</script>";
/** * Removes a directory recursively. * * @param string $path */ function conjoon_rmdir($path) { $path = rtrim(str_replace("\\", "/", $path), '/') . '/'; InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[INFO] recursively deleting {$path}")); if (!file_exists($path)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[WARNING] rmdir {$path}: directory does not exist")); return; } $handle = opendir($path); for (; false !== ($file = readdir($handle));) { if ($file != "." and $file != "..") { $fullpath = $path . $file; if (is_dir($fullpath)) { conjoon_rmdir($fullpath); if (file_exists($fullpath) && is_dir($fullpath)) { if (!rmdir($fullpath)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[ERROR] could not rmdir {$fullpath}")); } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[SUCCESS] rmdir {$fullpath}")); } } } else { if (!unlink($fullpath)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[ERROR] could not unlink {$fullpath}")); } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[SUCCESS] unlink {$fullpath}")); } } } } closedir($handle); if (file_exists($path) && is_dir($path)) { if (!rmdir($path)) { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[ERROR] could not rmdir {$path}")); } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[SUCCESS] rmdir {$path}")); } } else { InstallLogger::stdout(InstallLogger::getInstance()->logMessage("[WARNING] rmdir {$path}: directory does not exist")); } }
*/ /** * Install chunk_5 * * Takes care of file operations * * @author Thorsten Suckow-Homberg <*****@*****.**> */ /** * check if user is authorized to load script */ include './scripts/check_auth.php'; $libFolder = $_SESSION['setup_ini']['lib_path']['folder']; $appFolder = $_SESSION['setup_ini']['app_path']['folder']; InstallLogger::getInstance($_SESSION['install_process']['INSTALL_LOGGER']); InstallLogger::stdout(InstallLogger::logMessage("Updating cache system..."), true); // remove old cache folders if (isset($_SESSION['installation_info']['cache.default.caching']) && $_SESSION['installation_info']['cache.default.caching']) { if (isset($_SESSION['installation_info']['cache.db.metadata.backend.cache_dir']) && file_exists($_SESSION['installation_info']['cache.db.metadata.backend.cache_dir'])) { @conjoon_rmdir($_SESSION['installation_info']['cache.db.metadata.backend.cache_dir']); @rmdir($_SESSION['installation_info']['cache.db.metadata.backend.cache_dir']); } if (isset($_SESSION['installation_info']['cache.email.message.backend.cache_dir']) && file_exists($_SESSION['installation_info']['cache.email.message.backend.cache_dir'])) { @conjoon_rmdir($_SESSION['installation_info']['cache.email.message.backend.cache_dir']); @rmdir($_SESSION['installation_info']['cache.email.message.backend.cache_dir']); } if (isset($_SESSION['installation_info']['cache.email.accounts.backend.cache_dir']) && file_exists($_SESSION['installation_info']['cache.email.accounts.backend.cache_dir'])) { @conjoon_rmdir($_SESSION['installation_info']['cache.email.accounts.backend.cache_dir']); @rmdir($_SESSION['installation_info']['cache.email.accounts.backend.cache_dir']); } if (isset($_SESSION['installation_info']['cache.email.folders_root_type.backend.cache_dir']) && file_exists($_SESSION['installation_info']['cache.email.folders_root_type.backend.cache_dir'])) {
/** * Install chunk_3 * * Takes care of db updates * * @author Thorsten Suckow-Homberg <*****@*****.**> */ /** * check if user is authorized to load script */ include './scripts/check_auth.php'; $libFolder = $_SESSION['setup_ini']['lib_path']['folder']; $text = "Updating database. Depending on your database size, this can take a while. " . "Please note that progress marked with \"failure\" " . "is not an indication for a failed update attempt... " . "Don\\'t worry, we got this."; InstallLogger::getInstance($_SESSION['install_process']['INSTALL_LOGGER']); InstallLogger::stdout(InstallLogger::logMessage($text), true); InstallLogger::stdout(InstallLogger::logMessage("Updating database")); $dbConnInfo = array('host' => $_SESSION['db_host'], 'port' => $_SESSION['db_port'], 'database' => $_SESSION['db'], 'user' => $_SESSION['db_user'], 'password' => $_SESSION['db_password'], 'prefix' => $_SESSION['db_table_prefix']); // import the sql file for the selected database $path = realpath('./files/datastore/mysql/conjoon.sql'); conjoon_createTables($path, $_SESSION['db_adapter'], $dbConnInfo); $table = ""; sleep(1); // create root user if needed if (!isset($_SESSION['installation_info']['app_credentials'])) { conjoon_createAdmin($_SESSION['db_adapter'], array('user' => $_SESSION['app_credentials']['user'], 'password' => $_SESSION['app_credentials']['password'], 'firstname' => $_SESSION['app_credentials']['firstname'], 'lastname' => $_SESSION['app_credentials']['lastname'], 'email_address' => $_SESSION['app_credentials']['email_address']), $dbConnInfo); } sleep(1); // add fixtures $path = realpath('./files/datastore/mysql/fixtures.sql'); conjoon_insertFixtures($path, $_SESSION['db_adapter'], $dbConnInfo); echo "<script type=\"text/javascript\">this.location.href=\"./index.php?action=install_chunk_4\"</script>";