/* Concerto Platform - Online Adaptive Testing Platform Copyright (C) 2011-2013, The Psychometrics Centre, Cambridge University This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License, and not any of the later versions. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ if (!isset($ini)) { require_once '../../Ini.php'; $ini = new Ini(); } if (!Ini::$public_registration) { echo json_encode(array("result" => -2)); exit; } $user = new User(); $_POST['modify_password'] = 1; echo json_encode(array("result" => 0, "oid" => $user->mysql_save_from_post($_POST)));
public static function create_db($db = null) { if ($db == null) { $db = Ini::$db_master_name; } $sql = sprintf("\r\n CREATE TABLE IF NOT EXISTS `%s`.`User` (\r\n `id` bigint(20) NOT NULL auto_increment,\r\n `updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\r\n `created` timestamp NOT NULL default '0000-00-00 00:00:00',\r\n `login` text NOT NULL,\r\n `firstname` text NOT NULL,\r\n `lastname` text NOT NULL,\r\n `email` text NOT NULL,\r\n `phone` text NOT NULL,\r\n `password` text NOT NULL,\r\n `last_login` timestamp NOT NULL default '0000-00-00 00:00:00',\r\n `UserInstitutionType_id` int(11) NOT NULL,\r\n `institution_name` text NOT NULL,\r\n `superuser` tinyint(1) NOT NULL,\r\n PRIMARY KEY (`id`)\r\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n ", $db); if (!mysql_query($sql)) { return false; } $admin_data = array("updated" => time(), "created" => time(), "login" => "admin", "firstname" => "unknown", "modify_password" => 0); $admin = new User(); $lid = $admin->mysql_save_from_post($admin_data); $admin = User::from_mysql_id($lid); $admin->password = $admin->calculate_raw_password_hash("admin"); $admin->superuser = 1; return $admin->mysql_save(); }