latest changes to work on getting registration working

This commit is contained in:
Botanic 2013-06-10 04:17:55 -07:00
parent ef8d9129c4
commit 765a26a90e
5 changed files with 243 additions and 308 deletions

View file

@ -1,34 +1,34 @@
<?php <?php
class Helpers{ class Helpers{
public function loadTemplate( $template, $vars = array () ) public function loadTemplate( $template, $vars = array (), $forcelibrender = false )
{ {
global $AMS_LIB; global $AMS_LIB;
global $SITEBASE; global $SITEBASE;
global $AMS_TRANS; global $AMS_TRANS;
require_once $AMS_LIB . '/smarty/libs/Smarty.class.php'; require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
$smarty = new Smarty; $smarty = new Smarty;
// turn smarty debugging on/off // turn smarty debugging on/off
$smarty -> debugging = true; $smarty -> debugging = true;
// caching must be disabled for multi-language support // caching must be disabled for multi-language support
$smarty -> caching = false; $smarty -> caching = false;
$smarty -> cache_lifetime = 120; $smarty -> cache_lifetime = 120;
if ( !helpers :: check_if_game_client () ){ if ( !helpers :: check_if_game_client () or $forcelibrender = true ){
$smarty -> template_dir = $AMS_LIB . '/ingame_templates/'; $smarty -> template_dir = $AMS_LIB . '/ingame_templates/';
$smarty -> setConfigDir( $AMS_LIB . '/configs' ); $smarty -> setConfigDir( $AMS_LIB . '/configs' );
}else{ }else{
$smarty -> template_dir = $SITEBASE . '/templates/'; $smarty -> template_dir = $SITEBASE . '/templates/';
$smarty -> setConfigDir( $SITEBASE . '/configs' ); $smarty -> setConfigDir( $SITEBASE . '/configs' );
} }
foreach ( $vars as $key => $value ){ foreach ( $vars as $key => $value ){
$smarty -> assign( $key, $value ); $smarty -> assign( $key, $value );
} }
if ( isset( $_GET["language"] ) ){ if ( isset( $_GET["language"] ) ){
$language = $_GET["language"]; $language = $_GET["language"];
if ( file_exists( $AMS_TRANS . '/' . $language . '.ini' ) ){ if ( file_exists( $AMS_TRANS . '/' . $language . '.ini' ) ){
}else{ }else{
global $DEFAULT_LANGUAGE; global $DEFAULT_LANGUAGE;
$language = $DEFAULT_LANGUAGE; $language = $DEFAULT_LANGUAGE;
@ -43,7 +43,7 @@ class Helpers{
} }
$smarty -> display( $template . '.tpl' ); $smarty -> display( $template . '.tpl' );
} }
public function check_if_game_client() public function check_if_game_client()
{ {
// if HTTP_USER_AGENT is not set then its ryzom core // if HTTP_USER_AGENT is not set then its ryzom core

View file

@ -1,7 +1,7 @@
<?php <?php
class Users{ class Users{
function add_user(){ public function add_user(){
// check if values exist // check if values exist
if ( isset( $_POST["Username"] ) and isset( $_POST["Password"] ) and isset( $_POST["Email"] ) ) if ( isset( $_POST["Username"] ) and isset( $_POST["Password"] ) and isset( $_POST["Email"] ) )
{ {
@ -66,167 +66,168 @@ class Users{
$pageElements['TAC_ERROR'] = 'TRUE'; $pageElements['TAC_ERROR'] = 'TRUE';
} }
return $pageElements; return $pageElements;
} }
}
/**
* 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 ( sql :: 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;
}
}
/**
* 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 ( sql :: 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;
}
}

View file

@ -1,14 +1,5 @@
<?php <?php
/*
Here is the current code and progress on the drupal 7 ryzom core module
//////////////////////////
todo
//////////////////////////
disable user hook
delete user hook --- ring_open -> ring users ---- nel user & nel permission ---- hook_user_cancel ---- remove character data on server
menu items that do stuff
*/
/* /*
Drupal 7 ryzom core module Drupal 7 ryzom core module
Copyright (C) 2013 Matthew Lagoe (Botanic) & Paige Offerdahl (Tobi) Copyright (C) 2013 Matthew Lagoe (Botanic) & Paige Offerdahl (Tobi)
@ -26,6 +17,9 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
require_once("/ams_lib/libinclude.php");
//output template //output template
function loadTemplate($template,$vars) function loadTemplate($template,$vars)
{ {
@ -34,7 +28,7 @@ function loadTemplate($template,$vars)
} }
/** /**
* *
* Function ryzommanage_admin * Function ryzommanage_admin
* *
* @takes Nothing * @takes Nothing
* @return array $form * @return array $form
@ -119,14 +113,14 @@ function _webpage_profile(&$form_state)
if ($email != "success") { if ($email != "success") {
form_set_error('mail', t('Not a valid email address, please check it and try again.')); form_set_error('mail', t('Not a valid email address, please check it and try again.'));
} }
if ((checkPassword($form_state['account']['pass']['#value']['pass1']) == "success" ) and ( $form_state['account']['pass']['#value']['pass1'] == if ((checkPassword($form_state['account']['pass']['#value']['pass1']) == "success" ) and ( $form_state['account']['pass']['#value']['pass1'] ==
$form_state['account']['pass']['#value']['pass2'] )) { $form_state['account']['pass']['#value']['pass2'] )) {
} }
} }
/** /**
* *
* Function ryzommanage_menu * Function ryzommanage_menu
* *
* @takes Nothing * @takes Nothing
* @return array $items * @return array $items
@ -212,7 +206,7 @@ function name_registration_admin_settings() {
} }
/** /**
* *
* Function ryzommanage_menu * Function ryzommanage_menu
* *
* @takes Int $element, &$form_state * @takes Int $element, &$form_state
* @return Nothing * @return Nothing
@ -228,7 +222,7 @@ function _check_port_value($element, &$form_state)
} }
/** /**
* *
* Function ryzommanage_block_info * Function ryzommanage_block_info
* *
* @takes Nothing * @takes Nothing
* @return array $blocks * @return array $blocks
@ -242,14 +236,14 @@ function ryzommanage_block_info()
// info: The name of the block. // info: The name of the block.
'info' => t('Ryzom Manage User Block'), 'info' => t('Ryzom Manage User Block'),
'status' => TRUE, 'status' => TRUE,
'region' => '-1', // Not usually provided. 'region' => '-1', // Not usually provided.
'visibility' => BLOCK_VISIBILITY_LISTED // Not usually provided. 'visibility' => BLOCK_VISIBILITY_LISTED // Not usually provided.
); );
return $blocks; return $blocks;
} }
/** /**
* *
* Function ryzommanage_block_view * Function ryzommanage_block_view
* *
* @takes Nothing * @takes Nothing
* @return array $block * @return array $block
@ -271,9 +265,9 @@ function ryzommanage_block_view($delta = '')
} }
/** /**
* *
* Function _collect_register * Function _collect_register
* *
* @takes * @takes
* @return Nothing * @return Nothing
* *
* Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to / * Info: Determins what to send back to client, if the client is ryzom core then send the http data if its a browser send to /
@ -292,7 +286,7 @@ function _collect_register($nids, $collection)
} }
/** /**
* *
* Function check_if_game_client * Function check_if_game_client
* *
* @takes Nothing * @takes Nothing
* @return Boolean * @return Boolean
@ -311,10 +305,10 @@ function check_if_game_client()
} }
/** /**
* *
* Function return_client_httpdata * Function return_client_httpdata
* *
* @takes * @takes
* @return * @return
* *
* Info: Returns ryzom core formatted html for use in registration via client * Info: Returns ryzom core formatted html for use in registration via client
* *
@ -328,12 +322,12 @@ function return_client_httpdata()
$user = checkUser($_POST["Username"]); $user = checkUser($_POST["Username"]);
$pass = checkPassword($_POST["Password"]); $pass = checkPassword($_POST["Password"]);
$cpass = confirmPassword(); $cpass = confirmPassword();
$email = checkEmail($_POST["Email"]); $email = checkEmail($_POST["Email"]);
} else { } else {
$user = ""; $user = "";
$pass = ""; $pass = "";
$cpass = ""; $cpass = "";
$email = ""; $email = "";
} }
//if all are good then create user //if all are good then create user
if (($user == "success") and ($pass == "success") and ($cpass == "success") and ($email == "success") and (isset($_POST["TaC"]))) { if (($user == "success") and ($pass == "success") and ($cpass == "success") and ($email == "success") and (isset($_POST["TaC"]))) {
@ -363,7 +357,7 @@ function return_client_httpdata()
} else { } else {
$pageElements['USERNAME_ERROR'] = 'FALSE'; $pageElements['USERNAME_ERROR'] = 'FALSE';
} }
if ($pass != "success") { if ($pass != "success") {
$pageElements['PASSWORD_ERROR'] = 'TRUE'; $pageElements['PASSWORD_ERROR'] = 'TRUE';
} else { } else {
@ -389,7 +383,7 @@ function return_client_httpdata()
} }
/** /**
* *
* Function checkUser * Function checkUser
* *
* @takes $username * @takes $username
* @return string * @return string
@ -420,7 +414,7 @@ function checkUser($username)
} }
/** /**
* *
* Function checkPassword * Function checkPassword
* *
* @takes $pass * @takes $pass
* @return string * @return string
@ -443,7 +437,7 @@ function checkPassword($pass)
} }
/** /**
* *
* Function confirmPassword * Function confirmPassword
* *
* @takes $pass * @takes $pass
* @return string * @return string
@ -462,12 +456,12 @@ function confirmPassword()
} }
/** /**
* *
* Function checkEmail * Function checkEmail
* *
* @takes $email * @takes $email
* @return * @return
*
* *
*
* *
*/ */
function checkEmail($email) function checkEmail($email)
@ -517,7 +511,7 @@ function validEmail($email)
// domain part has two consecutive dots // domain part has two consecutive dots
$isValid = false; $isValid = false;
} else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) { } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
// character not valid in local part unless // character not valid in local part unless
// local part is quoted // local part is quoted
if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) { if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
$isValid = false; $isValid = false;
@ -571,13 +565,13 @@ function createUser($values)
$salt = generateSALT(); $salt = generateSALT();
$hashpass = crypt($pass, $salt); $hashpass = crypt($pass, $salt);
$params = array( $params = array(
$login, $login,
$hashpass, $hashpass,
$email $email
); );
try { try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost'); $hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306'); $port = variable_get('ryzommanage_mysqlport', '3306');
@ -599,8 +593,8 @@ function createUser($values)
)) ))
))->execute(); ))->execute();
return true; return true;
} }
try { try {
$statement = $dbh->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)"); $statement = $dbh->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)");
} }
@ -617,7 +611,7 @@ function createUser($values)
))->execute(); ))->execute();
return true; return true;
} }
try { try {
$statement->execute($params); $statement->execute($params);
} }
@ -634,12 +628,12 @@ function createUser($values)
))->execute(); ))->execute();
return true; return true;
} }
createPermissions(array($login)); createPermissions(array($login));
} }
function createPermissions($values) { function createPermissions($values) {
try { try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost'); $hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306'); $port = variable_get('ryzommanage_mysqlport', '3306');
@ -659,8 +653,8 @@ function createPermissions($values) {
)) ))
))->execute(); ))->execute();
return true; return true;
} }
try { try {
$sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';"); $sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';");
$sth->execute(); $sth->execute();
@ -682,8 +676,8 @@ function createPermissions($values) {
)) ))
))->execute(); ))->execute();
return true; return true;
} }
return true; return true;
} }
@ -763,13 +757,13 @@ function ryzommanage_user_presave(&$edit, $account, $category)
} elseif (isset($_POST['pass']['pass1'])) { } elseif (isset($_POST['pass']['pass1'])) {
$pass = $_POST['pass']['pass1']; $pass = $_POST['pass']['pass1'];
} }
if (!isset($edit['name'])) { if (!isset($edit['name'])) {
$name = $user->name; $name = $user->name;
} else { } else {
$name = $edit['name']; $name = $edit['name'];
} }
if ($account->is_new == 1 ) { if ($account->is_new == 1 ) {
createUser(array($edit['name'], $pass, $edit['mail'])); createUser(array($edit['name'], $pass, $edit['mail']));
} else { } else {
@ -781,15 +775,15 @@ function ryzommanage_form_user_register_form_alter(&$form, &$form_state, $form_i
// Modification for the form with the given form ID goes here. For example, if // Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user // FORM_ID is "user_register_form" this code would run only on the user
// registration form. // registration form.
// Change the data for the username and email fields // Change the data for the username and email fields
$form['account']['name']['#maxlength'] = '12'; $form['account']['name']['#maxlength'] = '12';
$form['account']['name']['#description'] = '5-12 lower-case characters and numbers. The login (username) you create here will be your login name.<br />The name of your game characters will be chosen later on.<br />'; $form['account']['name']['#description'] = '5-12 lower-case characters and numbers. The login (username) you create here will be your login name.<br />The name of your game characters will be chosen later on.<br />';
$form['account']['mail']['#description'] = 'Please verify that the e-mail address you enter here is valid and will remain valid in the future.<br />It will be used to manage your Tempest in the Aether account.<br />'; $form['account']['mail']['#description'] = 'Please verify that the e-mail address you enter here is valid and will remain valid in the future.<br />It will be used to manage your Tempest in the Aether account.<br />';
// Add a checkbox to registration form about agreeing to terms of use. // Add a checkbox to registration form about agreeing to terms of use.
$form['terms_of_use'] = array( $form['terms_of_use'] = array(
'#type' => 'checkbox', '#type' => 'checkbox',
'#title' => t("I agree with the <a href='".variable_get('ryzommanage_TOS', '')."'>terms and conditions</a>."), '#title' => t("I agree with the <a href='".variable_get('ryzommanage_TOS', '')."'>terms and conditions</a>."),
'#required' => TRUE, '#required' => TRUE,
); );
} }
@ -798,19 +792,19 @@ function ryzommanage_form_user_profile_form_alter(&$form, &$form_state, $form_id
// Modification for the form with the given form ID goes here. For example, if // Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user // FORM_ID is "user_register_form" this code would run only on the user
// registration form. // registration form.
// Change the data for the password field // Change the data for the password field
$form['account']['pass']['#description'] = 'Password must be 5-20 characters.<br />'; $form['account']['pass']['#description'] = 'Password must be 5-20 characters.<br />';
} }
function user_edit($values) { function user_edit($values) {
$username = $values[0]; $username = $values[0];
$newpassword = $values[1]; $newpassword = $values[1];
$salt = generateSALT(); $salt = generateSALT();
$pass = crypt($newpassword, $salt); $pass = crypt($newpassword, $salt);
try { try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost'); $hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306'); $port = variable_get('ryzommanage_mysqlport', '3306');
@ -832,9 +826,9 @@ function user_edit($values) {
))->execute(); ))->execute();
return true; return true;
} }
$sql = "UPDATE `nel`.`user` SET `Password` = ? WHERE `user`.`Login` = ?"; $sql = "UPDATE `nel`.`user` SET `Password` = ? WHERE `user`.`Login` = ?";
try { try {
$q = $dbh->prepare($sql); $q = $dbh->prepare($sql);
} }
@ -850,7 +844,7 @@ function user_edit($values) {
))->execute(); ))->execute();
return true; return true;
} }
try { try {
$q->execute(array( $pass, $username)); $q->execute(array( $pass, $username));
} }
@ -866,13 +860,13 @@ function user_edit($values) {
))->execute(); ))->execute();
return true; return true;
} }
return true; return true;
} }
/** /**
* *
* Function syncdata * Function syncdata
* *
* @takes Nothing * @takes Nothing
* @return array $values * @return array $values
@ -881,7 +875,7 @@ function user_edit($values) {
* *
*/ */
function syncdata () { function syncdata () {
try { try {
$hostname = variable_get('ryzommanage_serverurl', 'localhost'); $hostname = variable_get('ryzommanage_serverurl', 'localhost');
$port = variable_get('ryzommanage_mysqlport', '3306'); $port = variable_get('ryzommanage_mysqlport', '3306');
@ -895,15 +889,15 @@ function syncdata () {
watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR);
return true; return true;
} }
$query = db_select('ryzommanage_querycache', 'q') $query = db_select('ryzommanage_querycache', 'q')
->fields('q', array('SID', 'type', 'query')); ->fields('q', array('SID', 'type', 'query'));
$result = $query->execute(); $result = $query->execute();
foreach ($result as $record) { foreach ($result as $record) {
watchdog('ryzommanage_usersync', $record->query, NULL, WATCHDOG_ERROR); watchdog('ryzommanage_usersync', $record->query, NULL, WATCHDOG_ERROR);
switch($record->type) { switch($record->type) {
case 'createPermissions': case 'createPermissions':
case 'user_edit': case 'user_edit':
@ -914,24 +908,24 @@ function syncdata () {
->condition('SID', $SID) ->condition('SID', $SID)
->execute(); ->execute();
$func = $record->type; $func = $record->type;
$func(json_decode($record->query)); $func(json_decode($record->query));
} }
} }
} }
/** /**
* *
* Function ryzommanage_cron * Function ryzommanage_cron
* *
* @takes * @takes
* @return * @return
* *
* Info: Runs the syncdata function with the drupal cron * Info: Runs the syncdata function with the drupal cron
* *
*/ */
function ryzommanage_cron() { function ryzommanage_cron() {
syncdata(); syncdata();
} }

View file

@ -10,16 +10,6 @@ $DBHOST = 'localhost' ;
$DBUSERNAME = 'shard' ; $DBUSERNAME = 'shard' ;
$DBPASSWORD = '' ; $DBPASSWORD = '' ;
$RINGDBNAME = 'ring_open' ;
$RINGDBUSERNAME = 'shard' ;
$RINGDBPASSWORD = '' ;
$NTDBName = 'nel_tool' ;
$NTUserName = 'shard' ;
$NTPassword = '' ;
$LOGRELATIVEPATH = 'logs/' ;
// If true= the server will add automatically unknown user in the database // If true= the server will add automatically unknown user in the database
// (in nel.user= nel.permission= ring.ring_user and ring.characters // (in nel.user= nel.permission= ring.ring_user and ring.characters
$ALLOW_UNKNOWN = true ; $ALLOW_UNKNOWN = true ;
@ -27,57 +17,8 @@ $ALLOW_UNKNOWN = true ;
$CREATE_RING = true ; $CREATE_RING = true ;
// site paths definitions // site paths definitions
$AMS_LIB = dirname(dirname( __FILE__ )) . '/ams_lib'; $AMS_LIB = dirname( dirname( __FILE__ ) ) . '/ams_lib';
$AMS_TRANS = $AMS_LIB . '/translations'; $AMS_TRANS = $AMS_LIB . '/translations';
$AMS_CACHEDIR = $AMS_LIB . '/cache'; $AMS_CACHEDIR = $AMS_LIB . '/cache';
$SITEBASE = dirname( __FILE__ ) . '/html/' ;
$NELTOOL_SYSTEMBASE = dirname( dirname( __FILE__ ) ) . '/admin/' ;
$NELTOOL_LOGBASE = $NELTOOL_SYSTEMBASE . '/logs/' ;
$NELTOOL_IMGBASE = $NELTOOL_SYSTEMBASE . '/imgs/' ;
$DEFAULT_LANGUAGE = 'en';
$NELTOOL_RRDTOOL = '/usr/bin/rrdtool' ;
$NELTOOL_RRDSYSBASE = $NELTOOL_SYSTEMBASE . 'graphs_output/' ;
$NELTOOL_RRDWEBBASE = $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' ;
$DEFAULT_LANGUAGE = 'en';

View file

@ -1,13 +1,12 @@
<?php <?php
function add_user(){ function add_user(){
//add user locally here // add user locally here
$return = users :: add_user();
$return = users::add_user(); return $return;
return $return; }
}
function checkUser(){ function checkUser(){
} }