mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-20 07:58:44 +00:00
initial work on ams_lib
--HG-- branch : rc-botanic-webdev
This commit is contained in:
parent
b76fe233da
commit
c256187ead
12 changed files with 513 additions and 0 deletions
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
class Helpers {
|
||||
|
||||
public function loadTemplate( $template, $vars = array () )
|
||||
{
|
||||
extract( $vars );
|
||||
include( $template );
|
||||
}
|
||||
}
|
||||
|
180
code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php
Normal file
180
code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/users.php
Normal file
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
class Users {
|
||||
|
||||
/**
|
||||
*
|
||||
* Function checkUser
|
||||
*
|
||||
* @takes $username
|
||||
* @return string
|
||||
*
|
||||
* Info: Returns a string based on if the username is valid, if valid then "success" is returned
|
||||
*
|
||||
*/
|
||||
public function checkUser($username)
|
||||
{
|
||||
if (isset($username)) {
|
||||
if (strlen($username) > 12) {
|
||||
return "Username must be no more than 12 characters.";
|
||||
} elseif (strlen($username) < 5) {
|
||||
return "Username must be 5 or more characters.";
|
||||
} elseif (!preg_match('/^[a-z0-9\.]*$/', $username)) {
|
||||
return "Username can only contain numbers and letters.";
|
||||
} elseif (db_query("SELECT COUNT(*) FROM {users} WHERE name = :name", array(
|
||||
':name' => $username
|
||||
))->fetchField()) {
|
||||
return "Username " . $username . " is in use.";
|
||||
} else {
|
||||
return "success";
|
||||
}
|
||||
} else {
|
||||
return "success";
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Function checkPassword
|
||||
*
|
||||
* @takes $pass
|
||||
* @return string
|
||||
*
|
||||
* Info: Returns a string based on if the password is valid, if valid then "success" is returned
|
||||
*
|
||||
*/
|
||||
public function checkPassword($pass)
|
||||
{
|
||||
if (isset($pass)) {
|
||||
if (strlen($pass) > 20) {
|
||||
return "Password must be no more than 20 characters.";
|
||||
} elseif (strlen($pass) < 5) {
|
||||
return "Password must be more than 5 characters.";
|
||||
} else {
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Function confirmPassword
|
||||
*
|
||||
* @takes $pass
|
||||
* @return string
|
||||
*
|
||||
* Info: Verify's $_POST["Password"] is the same as $_POST["ConfirmPass"]
|
||||
*
|
||||
*/
|
||||
public function confirmPassword()
|
||||
{
|
||||
if (($_POST["Password"]) != ($_POST["ConfirmPass"])) {
|
||||
return "Passwords do not match.";
|
||||
} else {
|
||||
return "success";
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
/**
|
||||
*
|
||||
* Function checkEmail
|
||||
*
|
||||
* @takes $email
|
||||
* @return
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function checkEmail($email)
|
||||
{
|
||||
if (isset($email)) {
|
||||
if (!validEmail($email)) {
|
||||
return "Email address is not valid.";
|
||||
} elseif (db_query("SELECT COUNT(*) FROM {users} WHERE mail = :mail", array(
|
||||
':mail' => $email
|
||||
))->fetchField()) {
|
||||
return "Email is in use.";
|
||||
} else {
|
||||
return "success";
|
||||
}
|
||||
} else {
|
||||
return "success";
|
||||
}
|
||||
return "fail";
|
||||
}
|
||||
public function validEmail($email)
|
||||
{
|
||||
$isValid = true;
|
||||
$atIndex = strrpos($email, "@");
|
||||
if (is_bool($atIndex) && !$atIndex) {
|
||||
$isValid = false;
|
||||
} else {
|
||||
$domain = substr($email, $atIndex + 1);
|
||||
$local = substr($email, 0, $atIndex);
|
||||
$localLen = strlen($local);
|
||||
$domainLen = strlen($domain);
|
||||
if ($localLen < 1 || $localLen > 64) {
|
||||
// local part length exceeded
|
||||
$isValid = false;
|
||||
} else if ($domainLen < 1 || $domainLen > 255) {
|
||||
// domain part length exceeded
|
||||
$isValid = false;
|
||||
} else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
|
||||
// local part starts or ends with '.'
|
||||
$isValid = false;
|
||||
} else if (preg_match('/\\.\\./', $local)) {
|
||||
// local part has two consecutive dots
|
||||
$isValid = false;
|
||||
} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
|
||||
// character not valid in domain part
|
||||
$isValid = false;
|
||||
} else if (preg_match('/\\.\\./', $domain)) {
|
||||
// domain part has two consecutive dots
|
||||
$isValid = false;
|
||||
} else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
|
||||
// character not valid in local part unless
|
||||
// local part is quoted
|
||||
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if ($isValid && !(checkdnsrr($domain, "MX") || checkdnsrr($domain, "A"))) {
|
||||
// domain not found in DNS
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
return $isValid;
|
||||
}
|
||||
public function generateSALT($length = 2)
|
||||
{
|
||||
// start with a blank salt
|
||||
$salt = "";
|
||||
// define possible characters - any character in this string can be
|
||||
// picked for use in the salt, so if you want to put vowels back in
|
||||
// or add special characters such as exclamation marks, this is where
|
||||
// you should do it
|
||||
$possible = "2346789bcdfghjkmnpqrtvwxyzBCDFGHJKLMNPQRTVWXYZ";
|
||||
// we refer to the length of $possible a few times, so let's grab it now
|
||||
$maxlength = strlen($possible);
|
||||
// check for length overflow and truncate if necessary
|
||||
if ($length > $maxlength) {
|
||||
$length = $maxlength;
|
||||
}
|
||||
// set up a counter for how many characters are in the salt so far
|
||||
$i = 0;
|
||||
// add random characters to $salt until $length is reached
|
||||
while ($i < $length) {
|
||||
// pick a random character from the possible ones
|
||||
$char = substr($possible, mt_rand(0, $maxlength - 1), 1);
|
||||
// have we already used this character in $salt?
|
||||
if (!strstr($salt, $char)) {
|
||||
// no, so it's OK to add it onto the end of whatever we've already got...
|
||||
$salt .= $char;
|
||||
// ... and increase the counter by one
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// done!
|
||||
return $salt;
|
||||
}
|
||||
}
|
||||
|
8
code/ryzom/tools/server/ryzom_ams/ams_lib/libinclude.php
Normal file
8
code/ryzom/tools/server/ryzom_ams/ams_lib/libinclude.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
// ***********************************************
|
||||
// Base include file for library functions for AMS
|
||||
// ***********************************************
|
||||
function __autoload( $className ){
|
||||
require_once 'autoload/' . $className . '.php';
|
||||
}
|
||||
|
1
code/ryzom/tools/server/ryzom_ams/doc.txt
Normal file
1
code/ryzom/tools/server/ryzom_ams/doc.txt
Normal file
|
@ -0,0 +1 @@
|
|||
The following variables are required and must be set to a variable (not constant) and called before including ams_lib/libinclude.php
|
81
code/ryzom/tools/server/ryzom_ams/www/config.php
Normal file
81
code/ryzom/tools/server/ryzom_ams/www/config.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
// This file contains all variables needed by other php scripts
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// Variables for database access
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// where we can find the mysql database
|
||||
$DBHOST = 'localhost' ;
|
||||
$DBNAME = 'nel' ;
|
||||
$DBUSERNAME = 'shard' ;
|
||||
$DBPASSWORD = '' ;
|
||||
|
||||
$RINGDBNAME = 'ring_open' ;
|
||||
$RINGDBUSERNAME = 'shard' ;
|
||||
$RINGDBPASSWORD = '' ;
|
||||
|
||||
$NTDBName = 'nel_tool' ;
|
||||
$NTUserName = 'shard' ;
|
||||
$NTPassword = '' ;
|
||||
|
||||
$SITETITLE = 'Ryzom Core AMS' ;
|
||||
|
||||
$LOGRELATIVEPATH = 'logs/' ;
|
||||
|
||||
// If true= the server will add automatically unknown user in the database
|
||||
// (in nel.user= nel.permission= ring.ring_user and ring.characters
|
||||
$ALLOW_UNKNOWN = true ;
|
||||
// if true= the login service automaticaly create a ring user and a editor character if needed
|
||||
$CREATE_RING = true ;
|
||||
|
||||
// site paths definitions
|
||||
$NELTOOL_SITEBASE = dirname( __FILE__ ) . '/html/' ;
|
||||
$NELTOOL_SYSTEMBASE = dirname( dirname( __FILE__ ) ) . '/admin/' ;
|
||||
$NELTOOL_LOGBASE = $NELTOOL_SYSTEMBASE . '/logs/' ;
|
||||
$NELTOOL_IMGBASE = $NELTOOL_SYSTEMBASE . '/imgs/' ;
|
||||
|
||||
$NELTOOL_RRDTOOL = '/usr/bin/rrdtool' ;
|
||||
$NELTOOL_RRDSYSBASE = $NELTOOL_SYSTEMBASE . 'graphs_output/' ;
|
||||
$NELTOOL_RRDWEBBASE = $NELTOOL_SITEBASE . 'graphs_output/' ;
|
||||
|
||||
// SQL table names
|
||||
$NELDB_PREFIX = 'neltool_' ;
|
||||
|
||||
// for later use
|
||||
// the config table will gather some of the settings
|
||||
// that are currently written in this config.php file
|
||||
$NELDB_CONFIG_TABLE = $NELDB_PREFIX . 'config';
|
||||
$NELDB_USER_TABLE = $NELDB_PREFIX . 'users' ;
|
||||
$NELDB_GROUP_TABLE = $NELDB_PREFIX . 'groups' ;
|
||||
|
||||
$NELDB_LOG_TABLE = $NELDB_PREFIX . 'logs' ;
|
||||
$NELDB_NOTE_TABLE = $NELDB_PREFIX . 'notes' ;
|
||||
|
||||
$NELDB_STAT_HD_TIME_TABLE = $NELDB_PREFIX . 'stats_hd_times' ;
|
||||
$NELDB_STAT_HD_TABLE = $NELDB_PREFIX . 'stats_hd_datas' ;
|
||||
|
||||
$NELDB_ANNOTATION_TABLE = $NELDB_PREFIX . 'annotations' ;
|
||||
$NELDB_LOCK_TABLE = $NELDB_PREFIX . 'locks' ;
|
||||
|
||||
$NELDB_APPLICATION_TABLE = $NELDB_PREFIX . 'applications' ;
|
||||
$NELDB_GROUP_APPLICATION_TABLE = $NELDB_PREFIX . 'group_applications' ;
|
||||
$NELDB_USER_APPLICATION_TABLE = $NELDB_PREFIX . 'user_applications' ;
|
||||
|
||||
$NELDB_DOMAIN_TABLE = $NELDB_PREFIX . 'domains' ;
|
||||
$NELDB_USER_DOMAIN_TABLE = $NELDB_PREFIX . 'user_domains' ;
|
||||
$NELDB_GROUP_DOMAIN_TABLE = $NELDB_PREFIX . 'group_domains' ;
|
||||
|
||||
$NELDB_SHARD_TABLE = $NELDB_PREFIX . 'shards' ;
|
||||
$NELDB_USER_SHARD_TABLE = $NELDB_PREFIX . 'user_shards' ;
|
||||
$NELDB_GROUP_SHARD_TABLE = $NELDB_PREFIX . 'group_shards' ;
|
||||
|
||||
$NELDB_RESTART_GROUP_TABLE = $NELDB_PREFIX . 'restart_groups' ;
|
||||
$NELDB_RESTART_MESSAGE_TABLE = $NELDB_PREFIX . 'restart_messages' ;
|
||||
$NELDB_RESTART_SEQUENCE_TABLE = $NELDB_PREFIX . 'restart_sequences' ;
|
||||
|
||||
$VIEW_DELAY = 0 ;
|
||||
$HARDWARE_REFRESH = 600 ;
|
||||
$LOCK_TIMEOUT = 1800 ;
|
||||
$BG_IMG = 'imgs/bg_live.png' ;
|
||||
$GAME_NAME = 'Ryzom Core';
|
||||
$WELCOME_MESSAGE = 'Welcome! Please fill in the following fields to get your new '.$GAME_NAME.' account:';
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
require( '../config.php' );
|
||||
//check if values exist
|
||||
if (isset($_POST["Username"]) and isset($_POST["Password"]) and isset($_POST["Email"]) )
|
||||
{
|
||||
//check values
|
||||
$user = checkUser($_POST["Username"]);
|
||||
$pass = checkPassword($_POST["Password"]);
|
||||
$cpass = confirmPassword();
|
||||
$email = checkEmail($_POST["Email"]);
|
||||
} else {
|
||||
$user = "";
|
||||
$pass = "";
|
||||
$cpass = "";
|
||||
$email = "";
|
||||
}
|
||||
//if all are good then create user
|
||||
if (($user == "success") and ($pass == "success") and ($cpass == "success") and ($email == "success") and (isset($_POST["TaC"]))) {
|
||||
$edit = array(
|
||||
'name' => $_POST["Username"],
|
||||
'pass' => $_POST["Password"],
|
||||
'mail' => $_POST["Email"],
|
||||
'init' => $_POST["Email"],
|
||||
'unhashpass' => $_POST["Password"],
|
||||
'status' => 1,
|
||||
'access' => REQUEST_TIME
|
||||
);
|
||||
user_save(NULL, $edit);
|
||||
header('Location: email_sent.php');
|
||||
exit;
|
||||
} else {
|
||||
$pageElements = array(
|
||||
'GAME_NAME' => $GAME_NAME,
|
||||
'WELCOME_MESSAGE' => $WELCOME_MESSAGE,
|
||||
'USERNAME' => $user,
|
||||
'PASSWORD' => $pass,
|
||||
'CPASSWORD' => $cpass,
|
||||
'EMAIL' => $email
|
||||
);
|
||||
if ($user != "success") {
|
||||
$pageElements['USERNAME_ERROR'] = 'TRUE';
|
||||
} else {
|
||||
$pageElements['USERNAME_ERROR'] = 'FALSE';
|
||||
}
|
||||
|
||||
if ($pass != "success") {
|
||||
$pageElements['PASSWORD_ERROR'] = 'TRUE';
|
||||
} else {
|
||||
$pageElements['PASSWORD_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ($cpass != "success") {
|
||||
$pageElements['CPASSWORD_ERROR'] = 'TRUE';
|
||||
} else {
|
||||
$pageElements['CPASSWORD_ERROR'] = 'FALSE';
|
||||
}
|
||||
if ($email != "success") {
|
||||
$pageElements['EMAIL_ERROR'] = 'TRUE';
|
||||
} else {
|
||||
$pageElements['EMAIL_ERROR'] = 'FALSE';
|
||||
}
|
||||
if (isset($_POST["TaC"])) {
|
||||
$pageElements['TAC_ERROR'] = 'FALSE';
|
||||
} else {
|
||||
$pageElements['TAC_ERROR'] = 'TRUE';
|
||||
}
|
||||
helpers::loadtemplate('templates/register.phtml',$pageElements);
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
function add_user(){
|
||||
echo "test";
|
||||
}
|
||||
|
||||
function checkUser(){
|
||||
|
||||
|
||||
}
|
24
code/ryzom/tools/server/ryzom_ams/www/html/index.php
Normal file
24
code/ryzom/tools/server/ryzom_ams/www/html/index.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
require( '../config.php' );
|
||||
|
||||
require( '../../ams_lib/libinclude.php' );
|
||||
|
||||
if (isset($_POST["function"])){
|
||||
require("inc/".$_POST["function"].".php");
|
||||
$_POST["function"]();
|
||||
}
|
||||
|
||||
function loadpage ($page){
|
||||
require_once('autoload/'.$page.'.php');
|
||||
}
|
||||
|
||||
$page = 'home';
|
||||
if (isset($_GET["page"])) {
|
||||
$page = $_GET["page"];
|
||||
}
|
||||
|
||||
|
||||
helpers::loadtemplate('templates/header.phtml');
|
||||
loadpage($page);
|
||||
helpers::loadtemplate('templates/footer.phtml');
|
|
@ -0,0 +1,4 @@
|
|||
<hr />
|
||||
This is a footer
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
This is a header
|
||||
<div class="ryzomuserbar"><a href="?page=register">Register</a></div>
|
||||
<hr />
|
|
@ -0,0 +1 @@
|
|||
mainpage welcome!
|
|
@ -0,0 +1,117 @@
|
|||
<div class="title">
|
||||
RYZOM CORE INGAME REGISTRATION
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<?php echo $WELCOME_MESSAGE; ?>
|
||||
</div>
|
||||
|
||||
<form name="Page1"
|
||||
method="post"
|
||||
>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="33%" <?php if ($USERNAME_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Username">Desired Username: </td>
|
||||
|
||||
<td width="25%">
|
||||
<input type="text"
|
||||
name="Username"
|
||||
value=""
|
||||
maxlength="12"
|
||||
onfocus=
|
||||
"javascript:showTooltip('5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on.', this);" />
|
||||
</td>
|
||||
|
||||
<td id="comment-Username" <?php if ($USERNAME_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($USERNAME_ERROR == "TRUE"){ echo $USERNAME;}?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="33%" <?php if ($PASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Password">Desired Password:</td>
|
||||
|
||||
<td width="25%">
|
||||
<input type="password"
|
||||
name="Password"
|
||||
value=""
|
||||
maxlength="20"
|
||||
onkeyup=
|
||||
"testPassword(document.Page1.Password.value, 'comment-Password')"
|
||||
onfocus="javascript:showTooltip(' 5-20 characters.', this);" />
|
||||
</td>
|
||||
|
||||
<td id="comment-Password" <?php if ($PASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($PASSWORD_ERROR == "TRUE"){ echo $PASSWORD;}?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="33%"<?php if ($CPASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-ConfirmPass">Confirm Password:</td>
|
||||
|
||||
<td width="25%"><input type="password"
|
||||
name="ConfirmPass"
|
||||
value=""
|
||||
maxlength="20"
|
||||
onfocus="javascript:showTooltip('Retype your Password', this);" />
|
||||
</td>
|
||||
|
||||
<td id="comment-ConfirmPass" <?php if ($CPASSWORD_ERROR == "TRUE"){ echo 'class="error"';}?>width="42%"><?php if ($CPASSWORD_ERROR == "TRUE"){ echo $CPASSWORD;}?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width="33%" <?php if ($EMAIL_ERROR == "TRUE"){ echo 'class="error"';}?> id="caption-Email">Email Address (to which a confirmation email will be sent):</td>
|
||||
|
||||
<td width="25%">
|
||||
<input type="text"
|
||||
name="Email"
|
||||
value=""
|
||||
maxlength="255"
|
||||
onfocus=
|
||||
"javascript:showTooltip('Please verify that the e-mail address you enter here is valid and will remain valid in the future. It will only be used to manage your <?php echo $GAME_NAME; ?> account.', this);" />
|
||||
</td>
|
||||
|
||||
<td id="comment-Email" <?php if ($EMAIL_ERROR == "TRUE"){ echo 'class="error"';}?> width="42%"><?php if ($EMAIL_ERROR == "TRUE"){ echo $EMAIL;}?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td width=
|
||||
"33%" <?php if ($TAC_ERROR == "TRUE"){ echo 'class="error"';}?>
|
||||
colspan="2"><input type="checkbox"
|
||||
name="TaC"
|
||||
value="1"
|
||||
onfocus="javascript:showTooltip('', this);" /><span id=
|
||||
"caption-TaC">YES, I agree to the terms of
|
||||
service</span></td><?php if ($TAC_ERROR == "TRUE"){
|
||||
echo '<td id="comment-TaC" class="error" width="42%">You must accept the Terms of Service</td>';}
|
||||
else {
|
||||
echo '<td width="42%" id="comment-TaC" >';}; ?>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="c1">
|
||||
<input type="submit"
|
||||
name="Submit"
|
||||
value="Continue" />
|
||||
</div>
|
||||
<input type="hidden" name="function" value="add_user">
|
||||
</form>
|
||||
|
||||
<div id="signupTooltip"
|
||||
class="c2"
|
||||
inset=""></div>
|
||||
|
||||
<div id="tooltip-Username">
|
||||
5-12 lower-case characters and numbers. The login (username) you create here will be
|
||||
your login name. The name of your game characters will be chosen later on.
|
||||
</div>
|
||||
|
||||
<div id="tooltip-Password">
|
||||
5-20 characters.
|
||||
</div>
|
||||
|
||||
<div id="tooltip-ConfirmPass">
|
||||
Retype your Password
|
||||
</div>
|
||||
|
||||
<div id="tooltip-Email">
|
||||
Please verify that the e-mail address you enter here is valid and will remain valid
|
||||
in the future. It will be used to manage your <?php echo $GAME_NAME; ?> account.
|
||||
</div>
|
||||
|
||||
<div id="tooltip-TaC"></div>
|
Loading…
Reference in a new issue