mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-30 04:40:53 +00:00
first attempt to get register up and running
This commit is contained in:
parent
0c46da1f62
commit
6f7cf4c1ed
3 changed files with 85 additions and 5 deletions
|
@ -234,6 +234,27 @@ class Users{
|
|||
}
|
||||
// done!
|
||||
return $salt;
|
||||
}
|
||||
}
|
||||
|
||||
function create_Server_User($params)
|
||||
{
|
||||
try {
|
||||
$hostname = 'localhost';
|
||||
$port = '3306';
|
||||
$dbname = 'nel';
|
||||
$username = 'shard';
|
||||
$password = '';
|
||||
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password);
|
||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$statement = $dbh->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)");
|
||||
$statement->execute($params);
|
||||
return "success";
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
return "fail";
|
||||
}
|
||||
// createPermissions(array($login));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ function add_user(){
|
|||
'init' => $_POST["Email"],
|
||||
'unhashpass' => $_POST["Password"],
|
||||
'status' => 1,
|
||||
'access' => REQUEST_TIME
|
||||
'access' => $_SERVER['REQUEST_TIME']
|
||||
);
|
||||
//header( 'Location: email_sent.php' );
|
||||
write_user( $edit );
|
||||
|
@ -30,9 +30,50 @@ function add_user(){
|
|||
}
|
||||
|
||||
|
||||
function write_user(){
|
||||
|
||||
|
||||
function write_user($newUser){
|
||||
$login = $newUser["name"];
|
||||
$pass = $newUser["pass"];
|
||||
$email = $newUser["mail"];
|
||||
|
||||
$salt = Users::generateSALT();
|
||||
$hashpass = crypt($pass, $salt);
|
||||
|
||||
$params = array(
|
||||
$login,
|
||||
$hashpass,
|
||||
$email
|
||||
);
|
||||
|
||||
$result = Users :: create_Server_User($params);
|
||||
//test purpose
|
||||
$result = "fail";
|
||||
|
||||
$hostname = 'localhost';
|
||||
$port = '3306';
|
||||
$dbname = 'ryzom_ams';
|
||||
$username = 'shard';
|
||||
$password = '';
|
||||
|
||||
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password);
|
||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
try {
|
||||
$statement = $dbh->prepare("INSERT INTO ams_user (Login, Password, Email) VALUES (?, ?, ?)");
|
||||
$statement->execute($params);
|
||||
|
||||
if($result == "fail"){
|
||||
print('so far');
|
||||
$params = array("type" => "createUser","query" => json_encode(array($login,$pass,$email)));
|
||||
$statement = $dbh->prepare("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)");
|
||||
$statement->execute($params);
|
||||
}
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
//go to error page or something
|
||||
print_r($e);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// add user locally here
|
||||
print('Awesome');
|
||||
}
|
||||
|
|
18
code/ryzom/tools/server/ryzom_ams/www/html/sql/db.sql
Normal file
18
code/ryzom/tools/server/ryzom_ams/www/html/sql/db.sql
Normal file
|
@ -0,0 +1,18 @@
|
|||
CREATE DATABASE IF NOT EXISTS `ryzom_ams`;
|
||||
USE `ryzom_ams`;
|
||||
DROP TABLE IF EXISTS ams_user;
|
||||
DROP TABLE IF EXISTS ams_querycache;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ams_user` (
|
||||
`UId` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`Login` varchar(64) NOT NULL DEFAULT '',
|
||||
`Password` varchar(13) DEFAULT NULL,
|
||||
`Email` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`UId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='contains all users information for ryzom_ams';
|
||||
|
||||
CREATE TABLE ams_querycache (
|
||||
`SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`type` VARCHAR( 64 ) NOT NULL ,
|
||||
`query` VARCHAR( 512 ) NOT NULL
|
||||
);
|
Loading…
Reference in a new issue