diff --git a/install.php b/install.php new file mode 100644 index 0000000..c15a60a --- /dev/null +++ b/install.php @@ -0,0 +1,451 @@ + button then try to install + if (Request::post('install_submit')) { + + if (Request::post('sitename') == '') $errors['sitename'] = __('Field "Site name" is empty', 'system'); + if (Request::post('siteurl') == '') $errors['siteurl'] = __('Field "Site url" is empty', 'system'); + if (Request::post('login') == '') $errors['login'] = __('Field "Username" is empty', 'system'); + if (Request::post('password') == '') $errors['password'] = __('Field "Password" is empty', 'system'); + if (Request::post('email') == '') $errors['email'] = __('Field "Email" is empty', 'system'); + if ( ! Valid::email(Request::post('email'))) $errors['email_valid'] = __('Email not valid', 'system'); + if (trim(Request::post('php') !== '')) $errors['php'] = true; + if (trim(Request::post('simplexml') !== '')) $errors['simplexml'] = true; + if (trim(Request::post('mod_rewrite') !== '')) $errors['mod_rewrite'] = true; + if (trim(Request::post('htaccess') !== '')) $errors['htaccess'] = true; + if (trim(Request::post('sitemap') !== '')) $errors['sitemap'] = true; + if (trim(Request::post('install') !== '')) $errors['install'] = true; + if (trim(Request::post('public') !== '')) $errors['public'] = true; + if (trim(Request::post('storage') !== '')) $errors['storage'] = true; + if (trim(Request::post('backups') !== '')) $errors['backups'] = true; + if (trim(Request::post('tmp') !== '')) $errors['tmp'] = true; + + // If errors is 0 then install cms + if (count($errors) == 0) { + + // Update options + Option::update(array('maintenance_status' => 'off', + 'sitename' => Request::post('sitename'), + 'siteurl' => Request::post('siteurl'), + 'description' => __('Site description', 'system'), + 'keywords' => __('Site keywords', 'system'), + 'slogan' => __('Site slogan', 'system'), + 'defaultpage' => 'home', + 'timezone' => Request::post('timezone'), + 'theme_site_name' => 'default', + 'theme_admin_name' => 'default')); + + // Get users table + $users = new Table('users'); + + // Insert new user with role = admin + $users->insert(array('login' => Security::safeName(Request::post('login')), + 'password' => Security::encryptPassword(Request::post('password')), + 'email' => Request::post('email'), + 'hash' => Text::random('alnum', 12), + 'date_registered' => time(), + 'role' => 'admin')); + + // Write .htaccess + $htaccess = file_get_contents('.htaccess'); + $save_htaccess_content = str_replace("/%siteurlhere%/", $rewrite_base, $htaccess); + + $handle = fopen ('.htaccess', "w"); + fwrite($handle, $save_htaccess_content); + fclose($handle); + + // Installation done :) + header("location: index.php?install=done"); + } + } +?> + + +
+ ++