first attempt to get register up and running

--HG--
branch : quitta-gsoc-2013
This commit is contained in:
Quitta 2013-06-19 23:53:53 +02:00
parent c22e1de52d
commit 4f822c37fe
3 changed files with 85 additions and 5 deletions

View file

@ -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));
}
}

View file

@ -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

View 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
);