mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-25 10:20:54 +00:00
first attempt to get register up and running
--HG-- branch : quitta-gsoc-2013
This commit is contained in:
parent
c22e1de52d
commit
4f822c37fe
3 changed files with 85 additions and 5 deletions
|
@ -235,5 +235,26 @@ class Users{
|
||||||
// done!
|
// done!
|
||||||
return $salt;
|
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"],
|
'init' => $_POST["Email"],
|
||||||
'unhashpass' => $_POST["Password"],
|
'unhashpass' => $_POST["Password"],
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
'access' => REQUEST_TIME
|
'access' => $_SERVER['REQUEST_TIME']
|
||||||
);
|
);
|
||||||
//header( 'Location: email_sent.php' );
|
//header( 'Location: email_sent.php' );
|
||||||
write_user( $edit );
|
write_user( $edit );
|
||||||
|
@ -30,7 +30,48 @@ 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
|
// add user locally here
|
||||||
|
|
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