Project

General

Profile

« Previous | Next » 

Revision 987

Added by aldus over 15 years ago

Bugfixes for ticket 728 (install without tables) - see changelog for details.

View differences:

save.php
22 22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 23

  
24 24
*/
25
$debug = true;
25 26

  
27
if (true === $debug) {
28
	ini_set('display_errors', 1);
29
	error_reporting(E_ALL);
30
}
26 31
// Start a session
27 32
if(!defined('SESSION_STARTED')) {
28 33
	session_name('wb_session_id');
......
126 131
}
127 132

  
128 133
function add_slashes($input) {
129
		if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
130
			return $input;
131
		}
132
		$output = addslashes($input);
133
		return $output;
134
	if ( get_magic_quotes_gpc() || ( !is_string($input) ) ) {
135
		return $input;
134 136
	}
137
	$output = addslashes($input);
138
	return $output;
139
}
135 140

  
136 141
// Begin check to see if form was even submitted
137 142
// Set error if no post vars found
......
364 369

  
365 370
// Check if we should install tables
366 371
if($install_tables == true) {
367
	
372
	if (!defined('WB_INSTALL_PROCESS')) define ('WB_INSTALL_PROCESS', true);
368 373
	// Remove tables if they exist
369 374

  
370 375
	// Pages table
......
693 698
	if($database->is_error()) {
694 699
		set_error($database->get_error());
695 700
	}
701

  
702
// end of if install_tables	
703
} else {
704
	/**
705
	 *	DB - Exists
706
	 *	Tables also?
707
	 *
708
	 */
709
	$requested_tables = array("pages","sections","settings","users","groups","search","addons");
710
	for($i=0;$i<count($requested_tables);$i++) $requested_tables[$i] = $table_prefix.$requested_tables[$i];
696 711
	
712
	$result = mysql_list_tables( DB_NAME );
713
	$all_tables = array();
714
	for($i=0; $i < mysql_num_rows($result); $i++) $all_tables[] = mysql_table_name($result, $i);
715

  
716
	$missing_tables = array();
717
	foreach($requested_tables as $temp_table) {
718
		if (!in_array($temp_table, $all_tables)) {
719
			$missing_tables[] = $temp_table;
720
		}
721
	}
722
	
723
	/**
724
	 *	If one or more needed tables are missing, so 
725
	 *	we can't go on and have to display an error
726
	 */
727
	if ( count($missing_tables) > 0 ) {
728
		$error_message  = "One or more tables are missing in the selected database <b><font color='#990000'>".DB_NAME."</font></b>.<br />";
729
		$error_message .= "Please install the missing tables or choose 'install tables' as recommend.<br />";
730
		$error_message .= "Missing tables are: <b>".implode(", ", $missing_tables)."</b>";
731
		
732
		set_error( $error_message );
733
	}
734
	
735
	/**
736
	 *	Try to get some default settings ...
737
	 */
738
	$vars = array(
739
		'DEFAULT_THEME'	=> "wb_theme",
740
		'THEME_URL'		=> WB_URL."/templates/wb_theme",
741
		'THEME_PATH'	=> WB_PATH."/templates/wb_theme",
742
		'LANGUAGE'		=> $_POST['default_language'],
743
		'SERVER_EMAIL'	=> "admin@yourdomain.com",
744
		'SMART_LOGIN'	=> false
745
	);
746
	foreach($vars as $k => $v) if (!defined($k)) define($k, $v);
747
	
748
	if (!isset($MESSAGE)) include (WB_PATH."/languages/".LANGUAGE.".php");
749
	
750
	/**
751
	 *	The important part ...
752
	 *	Is there an valid user?
753
	 */
754
	$result = $database->query("SELECT * from ".$table_prefix."users where username='".$_POST['admin_username']."'");
755
	if ( $database->is_error() ) {
756
		set_error ($database->get_error() );
757
	}
758
	if ($result->numRows() == 0) {
759
		/**
760
		 *	No matches found ... user properly unknown
761
	 	 */
762
	 	set_error ("Unkown user. Please use a valid username.");
763
	} else {
764
	 	
765
		$data = $result->fetchRow();
766
	 	/**
767
	 	 *	Does the password match
768
	 	 */
769
	 	if ( md5($_POST['admin_password']) != $data['password']) {
770
	 		set_error ("Password didn't match");
771
	 	}
772
	}
697 773
}
698

  
699 774
// Log the user in and go to Website Baker Administration
700 775
$thisApp = new Login(
701
							array(
702
									"MAX_ATTEMPS" => "50",
703
									"WARNING_URL" => ADMIN_URL."/login/warning.html",
704
									"USERNAME_FIELDNAME" => 'admin_username',
705
									"PASSWORD_FIELDNAME" => 'admin_password',
706
									"REMEMBER_ME_OPTION" => SMART_LOGIN,
707
									"MIN_USERNAME_LEN" => "2",
708
									"MIN_PASSWORD_LEN" => "2",
709
									"MAX_USERNAME_LEN" => "30",
710
									"MAX_PASSWORD_LEN" => "30",
711
									'LOGIN_URL' => ADMIN_URL."/login/index.php",
712
									'DEFAULT_URL' => ADMIN_URL."/start/index.php",
713
									'TEMPLATE_DIR' => ADMIN_PATH."/login",
714
									'TEMPLATE_FILE' => "template.html",
715
									'FRONTEND' => false,
716
									'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
717
									'USERS_TABLE' => TABLE_PREFIX."users",
718
									'GROUPS_TABLE' => TABLE_PREFIX."groups",
719
							)
720
					);
776
		array(
777
				"MAX_ATTEMPS" => "50",
778
				"WARNING_URL" => ADMIN_URL."/login/warning.html",
779
				"USERNAME_FIELDNAME" => 'admin_username',
780
				"PASSWORD_FIELDNAME" => 'admin_password',
781
				"REMEMBER_ME_OPTION" => SMART_LOGIN,
782
				"MIN_USERNAME_LEN" => "2",
783
				"MIN_PASSWORD_LEN" => "2",
784
				"MAX_USERNAME_LEN" => "30",
785
				"MAX_PASSWORD_LEN" => "30",
786
				'LOGIN_URL' => ADMIN_URL."/login/index.php",
787
				'DEFAULT_URL' => ADMIN_URL."/start/index.php",
788
				'TEMPLATE_DIR' => ADMIN_PATH."/login",
789
				'TEMPLATE_FILE' => "template.html",
790
				'FRONTEND' => false,
791
				'FORGOTTEN_DETAILS_APP' => ADMIN_URL."/login/forgot/index.php",
792
				'USERS_TABLE' => TABLE_PREFIX."users",
793
				'GROUPS_TABLE' => TABLE_PREFIX."groups",
794
		)
795
);
721 796
?>

Also available in: Unified diff