} if (file_exists($ci->getFilenameOnDisk(FALSE, TRUE))) { rename($ci->getFilenameOnDisk(FALSE, TRUE), $ci->getFilenameOnDisk(FALSE, FALSE)); } } else { if (file_exists($ci->getFilenameOnDisk(TRUE))) { rename($ci->getFilenameOnDisk(TRUE), $ci->getFilenameOnDisk(FALSE)); } } } /* Give the admin-user full rights */ $admUser = User::GetUsers(new UserSearchParameters(CMDLINE_USERID)); /* @var $admUser User */ if ($admUser) { $admUser = $admUser[0]; $admUser->setRights(Rights::getTotalRights()); User::Update($admUser, $admUser); } /* Introduce CANDYPATH constant and write to config */ if (defined('CANDYIMAGEPATH') && !defined('CANDYPATH')) { if (($configfile = file_get_contents('config.php')) !== FALSE) { $configfile = str_replace('CANDYIMAGEPATH', 'CANDYPATH', $configfile); if (file_put_contents('config.php', $configfile) === FALSE) { $e = new Error(NULL, $lang->g('ErrorSetupWritingConfig')); Error::AddError($e); $NoError = FALSE; } } else { $e = new Error(NULL, $lang->g('ErrorSetupWritingConfig')); Error::AddError($e); $NoError = FALSE;
$SmtpHostname = isset($_POST['txtSmtpHostname']) && strlen($_POST['txtSmtpHostname']) > 0 ? (string) $_POST['txtSmtpHostname'] : NULL; $SmtpUsername = isset($_POST['txtSmtpUsername']) && strlen($_POST['txtSmtpUsername']) > 0 ? (string) $_POST['txtSmtpUsername'] : NULL; $SmtpPassword = isset($_POST['txtSmtpPassword']) && strlen($_POST['txtSmtpPassword']) > 0 ? (string) $_POST['txtSmtpPassword'] : NULL; $SmtpPort = isset($_POST['txtSmtpPort']) && intval($_POST['txtSmtpPort']) > 0 ? intval($_POST['txtSmtpPort']) : 0; $SmtpAuth = array_key_exists('chkSmtpAuth', $_POST); $PasswordOK = $_POST['txtRepeatPassword'] == $_POST['txtPassword']; $EmailOK = Utils::ValidateEmail($UserEmail); $DBsettingsSet = isset($DBHostName) && isset($DBUserName) && isset($DBPassword); if ($PasswordOK && $EmailOK && $DBsettingsSet) { /* @var $dbi DBi */ if (@($dbi = new DBi($DBHostName, $DBUserName, $DBPassword, 'mysql'))) { $DBConnectOK = $dbi->connect_errno == 0; if ($DBConnectOK) { if ($dbi->ExecuteMulti(sprintf($CreateDBSQL, $dbi->real_escape_string($DBName)))) { $UserSalt = Utils::GenerateGarbage(20); if ($dbi->query(sprintf($InsertUserSQL, $dbi->real_escape_string($UserName), $dbi->real_escape_string(Utils::HashString($Password, $UserSalt)), $dbi->real_escape_string($UserSalt), $dbi->real_escape_string($UserFirstName), $dbi->real_escape_string($UserLastName), $dbi->real_escape_string($UserEmail), $dbi->real_escape_string(serialize(Rights::getTotalRights()))))) { $NewUserID = $dbi->insert_id; $NewConfig = sprintf($ConfigTemplate, str_ireplace('\\', '\\\\', $CandyPath), str_ireplace('\\', '\\\\', $CandyVideoThumbPath), $DBHostName, $DBUserName, $DBPassword, $DBName, $NewUserID, $SmtpFromAddress, $SmtpFromName, $SmtpHostname, $SmtpUsername, $SmtpPassword, $SmtpPort, $SmtpAuth ? 'TRUE' : 'FALSE', $UserFirstName, $UserLastName); if (@file_put_contents('config.php', $NewConfig, LOCK_EX) !== FALSE) { if (is_dir('cache') || mkdir('cache', 0700, TRUE)) { $i = new Info($lang->g('MessageAllDoneConfigWritten')); Info::AddInfo($i); header('location:login.php'); exit; } else { $e = new Error(NULL, $lang->g('ErrorSetupCreatingCacheDir')); Error::AddError($e); } } else { $e = new Error(NULL, $lang->g('ErrorSetupWritingConfig')); Error::AddError($e);