This repository has been archived by the owner on Apr 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
install.php
79 lines (65 loc) · 2.63 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Landing point for GlotPress installation
*/
define('GP_INSTALLING', true);
require_once( 'gp-load.php' );
require_once( BACKPRESS_PATH . 'class.bp-sql-schema-parser.php' );
require_once( GP_PATH . GP_INC . 'install-upgrade.php' );
require_once( GP_PATH . GP_INC . 'schema.php' );
$show_htaccess_instructions = false;
$action = 'upgrade';
if ( gp_get_option( 'gp_db_version' ) <= gp_get_option_from_db( 'gp_db_version' ) && ! isset( $_GET['force'] ) ) {
$success_message = __( 'You already have the latest version, no need to upgrade!' );
}
else if ( gp_is_installed() ) {
$success_message = __( 'GlotPress was successully upgraded!' );
$errors = gp_upgrade();
$show_htaccess_instructions = ! gp_set_htaccess() && empty( $errors );
}
else if ( defined('CUSTOM_USER_TABLE') ) {
$errors = gp_install();
$success_message = __( 'GlotPress was successully installed!' );
if ( ! $errors ) {
gp_create_initial_contents();
}
$show_htaccess_instructions = ! gp_set_htaccess() && empty( $errors );
$action = 'installed';
}
else if( isset( $_POST['user_name'], $_POST['user_name'], $_POST['admin_password'], $_POST['admin_password2'], $_POST['admin_email'] ) ) {
$user_name = trim( stripslashes_deep( $_POST['user_name'] ) );
$admin_password = stripslashes_deep( $_POST['admin_password'] );
$admin_password_check = stripslashes_deep( $_POST['admin_password2'] );
$admin_email = trim( stripslashes_deep( $_POST['admin_email'] ) );
$errors = array();
if ( empty( $user_name ) ) {
$errors[] = __( 'Please provide a valid username.' );
} elseif ( $user_name != sanitize_user( $user_name, true ) ) {
$errors[] = __( 'The username you provided has invalid characters.' );
} elseif ( empty( $admin_password ) ) {
$errors[] = __( 'Please specify a password.' );
} elseif ( $admin_password != $admin_password_check ) {
$errors[] = __( 'Your passwords do not match. Please try again.' );
} else if ( empty( $admin_email ) ) {
$errors[] = __( 'You must provide an email address.' );
} elseif ( ! is_email( $admin_email ) ) {
$errors[] = __( 'You have an invalid email Address.' );
}
if( ! $errors ) {
$errors = gp_install();
$success_message = __( 'GlotPress was successully installed!' );
$success_message .= ' <a href="' . gp_url_login() . '">' . __('Log in') . '</a>';
if ( ! $errors ) {
gp_create_initial_contents( $user_name, $admin_password, $admin_email );
}
$show_htaccess_instructions = ! gp_set_htaccess() && empty( $errors );
$action = 'installed';
} else {
$action = 'install';
}
}
else {
$action = 'install';
$user_name = $admin_email = '';
}
gp_tmpl_load( 'install', get_defined_vars() );