31
Mods & Plugins (Releases & Support) / Re: [MOD] Ajax Username Checker
« on: December 06, 2010, 04:10:21 PM »
Sorry about that. Forgot to use code tags instead of php tags. Should be fixed now.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
"url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php", "&"),
"url_user_availability" => $site_sess->url(ROOT_PATH."user_availability.php?check=username", "&"),
"url_user_email" => $site_sess->url(ROOT_PATH."user_availability.php?check=email", "&"),
"url_user_password" => $site_sess->url(ROOT_PATH."user_availability.php?check=password", "&"),
<script language="javascript">
//<!---------------------------------+
// Developed by Roshan Bhattarai
// Visit http://roshanbh.com.np for this script and more.
// This notice MUST stay intact for legal use
// Extensive additions by Zhono
// --------------------------------->
$(document).ready(function()
{
var userOk = 0;
var passOk = 0;
var emailOk = 0;
$("#submitButton").attr("value", "Disabled");
$("#submitButton").attr("disabled", "true");
$("#username").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_availability}",{ user_name:$(this).val() } ,function(data)
{
if(data=='userblank') //if username not entered
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_username_empty}').addClass('messageboxerror').fadeTo(900,1);
});
userOk = 0;
}
else if(data=='userlength') //if username is less than 6 or more than 20 characters
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_username_length}').addClass('messageboxerror').fadeTo(900,1);
});
userOk = 0;
}
else if(data=='userno') //if username not avaiable
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_username_taken}').addClass('messageboxerror').fadeTo(900,1);
});
userOk = 0;
}
else
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_username_good}').addClass('messageboxok').fadeTo(900,1);
});
userOk = 1;
if (userOk==1 && passOk==1 && emailOk==1) {
$("#submitButton").attr("value", "Register");
$('#submitButton').removeAttr('disabled');
} else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
}
});
});
$("#userpassword").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgboxpass").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_password}",{ user_password:$(this).val() } ,function(data)
{
if(data=='passblank') //if username not entered
{
$("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_password_empty}').addClass('messageboxerror').fadeTo(900,1);
});
passOk = 0;
}
else if(data=='passlength') //if username is less than 6 or more than 20 characters
{
$("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_password_length}').addClass('messageboxerror').fadeTo(900,1);
});
passOk = 0;
}
else
{
$("#msgboxpass").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_password_good}').addClass('messageboxok').fadeTo(900,1);
});
passOk = 1;
if (userOk==1 && passOk==1 && emailOk==1) {
$("#submitButton").attr("value", "Register");
$('#submitButton').removeAttr('disabled');
} else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
}
});
});
$("#useremail").blur(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgboxemail").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
//check the username exists or not from ajax
$.post("{url_user_email}",{ user_email:$(this).val() } ,function(data)
{
if(data=='emailblank') //if username not entered
{
$("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_email_empty}').addClass('messageboxerror').fadeTo(900,1);
});
emailOk = 0;
}
else if(data=='emailinvalid') //if username is less than 6 or more than 20 characters
{
$("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_email_invalid}').addClass('messageboxerror').fadeTo(900,1);
});
emailOk = 0;
}
else if(data=='emailno') //if username not avaiable
{
$("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_email_taken}').addClass('messageboxerror').fadeTo(900,1);
});
emailOk = 0;
}
else
{
$("#msgboxemail").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('{lang_ajax_email_good}').addClass('messageboxok').fadeTo(900,1);
});
emailOk = 1;
if (userOk==1 && passOk==1 && emailOk==1) {
$("#submitButton").attr("value", "Register");
$('#submitButton').removeAttr('disabled');
} else {
$("#submitButton").attr("disabled", "true");
$("#submitButton").attr("value", "Disabled");
}
}
});
});
});
</script>
<input type="password" name="user_password" size="30" class="input" />
<input type="password" name="user_password" size="30" class="input" id="userpassword" /><span id="msgboxpass" style="display:none"></span>
<input type="text" name="user_email" size="30" class="input" value="{user_email}" />
<input type="text" name="user_email" size="30" class="input" value="{user_email}" id="useremail" /><span id="msgboxemail" style="display:none"></span>
<input type="submit" value="{lang_submit}" class="button" />
<input type="submit" value="{lang_submit}" class="button" id="submitButton" />
?>
//----------------------------------------------------------
//-- Mod Ajax Registration Checker --
//----------------------------------------------------------
$lang['ajax_username_empty'] = "Please enter a username";
$lang['ajax_username_length'] = "Username must be between 6 and 20 characters long";
$lang['ajax_username_taken'] = "This User name already exists";
$lang['ajax_username_good'] = "Username available to register";
$lang['ajax_password_empty'] = "Please enter a password";
$lang['ajax_password_length'] = "Password must be between 6 and 20 characters long";
$lang['ajax_password_good'] = "Password is good";
$lang['ajax_email_empty'] = "Please enter an email address";
$lang['ajax_email_invalid'] = "This email address is invalid!";
$lang['ajax_email_taken'] = "This email address is already registered";
$lang['ajax_email_good'] = "Email address is good to go";
"captcha_registration" => (bool)$captcha_enable_registration
"captcha_registration" => (bool)$captcha_enable_registration,
"lang_ajax_username_empty" => $lang['ajax_username_empty'],
"lang_ajax_username_length" => $lang['ajax_username_length'],
"lang_ajax_username_taken" => $lang['ajax_username_taken'],
"lang_ajax_username_good" => $lang['ajax_username_good'],
"lang_ajax_password_empty" => $lang['ajax_password_empty'],
"lang_ajax_password_length" => $lang['ajax_password_length'],
"lang_ajax_password_good" => $lang['ajax_password_good'],
"lang_ajax_email_empty" => $lang['ajax_email_empty'],
"lang_ajax_email_invalid" => $lang['ajax_email_invalid'],
"lang_ajax_email_taken" => $lang['ajax_email_taken'],
"lang_ajax_email_good" => $lang['ajax_email_good']
<?php
// Developed by Roshan Bhattarai
// Visit http://roshanbh.com.np for this script and more.
// This notice MUST stay intact for legal use
// Extensive additions by Zhono
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
if ($_GET['check'] == "username") {
if (isset($HTTP_POST_VARS['user_name']) && !empty($HTTP_POST_VARS['user_name'])) {
$user_name = preg_replace("/[ ]{2,}/", " ", un_htmlspecialchars(trim($HTTP_POST_VARS['user_name'])));
//username length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;
if ((strlen($user_name) < $MIN_LENGTH) || (strlen($user_name) > $MAX_LENGTH)) {
echo "userlength";
} else {
if ($user_name != "") {
$sql = "SELECT ".get_user_table_field("", "user_name")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_name")." = '".strtolower($user_name)."'";
if ($site_db->not_empty($sql)) {
//user name is not availble
echo "userno";
} else {
//user name is available
echo "useryes";
}
}
}
} else {
echo "userblank";
}
}
if ($_GET['check'] == "password") {
if (isset($HTTP_POST_VARS['user_password']) && !empty($HTTP_POST_VARS['user_password'])) {
$user_password = preg_replace("/[ ]{2,}/", " ", un_htmlspecialchars(trim($HTTP_POST_VARS['user_password'])));
//password length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;
if ((strlen($user_password) < $MIN_LENGTH) || (strlen($user_password) > $MAX_LENGTH)) {
echo "passlength";
} else {
echo "passyes";
}
} else {
echo "passblank";
}
}
if ($_GET['check'] == "email") {
if (isset($HTTP_POST_VARS['user_email']) && !empty($HTTP_POST_VARS['user_email'])) {
$user_email = $HTTP_POST_VARS['user_email'];
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $user_email)){
echo "emailinvalid";
} else {
if ($user_email != "") {
$sql = "SELECT ".get_user_table_field("", "user_email")."
FROM ".USERS_TABLE."
WHERE ".get_user_table_field("", "user_email")." = '".strtolower($user_email)."'";
if ($site_db->not_empty($sql)) {
//user name is not availble
echo "emailno";
} else {
//user name is available
echo "emailyes";
}
}
}
} else {
echo "emailblank";
}
}
?>
//username length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;
and//password length
$MIN_LENGTH = 6;
$MAX_LENGTH = 20;
echo "blank";
if(data=='no') //if username not avaiable
if(data=='blank') //if username not entered
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('Please enter a username').addClass('messageboxerror').fadeTo(900,1);
});
else if(data=='no') //if username not avaiable
<?php
define('ROOT_PATH', '/home/*********/public_html/');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'includes/db_mysql.php');
include(ROOT_PATH.'includes/constants.php');
$site_db = new Db($db_host, $db_user, $db_password, $db_name) OR die("Keine Verbindung zum Datenbankserver.");
$sql = "SELECT image_id, cat_id, image_name, image_description, image_keywords, image_media_file
FROM ".IMAGES_TABLE."
WHERE image_keywords = ''";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)){
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_description = $row['image_description'];
$image_keywords = $row['image_keywords'];
$image_media_file = $row['image_media_file'];
$sql2 = "SELECT cat_id, cat_name
FROM ".CATEGORIES_TABLE."
WHERE cat_id = $cat_id";
$result2 = $site_db->query($sql2);
while ($row = $site_db->fetch_array($result2)){
$new_keywords = $row['cat_name'];
}
echo "Image ID: ".$image_id."<br>\n";
echo "Image Name: ".$image_name."<br>\n";
echo "Description: ".$image_description."<br>\n";
echo "Keywords: ".$new_keywords."<br>\n";
echo "Filename: ".$image_media_file."<br>\n";
echo "<br><hr>\n";
$sql = "UPDATE ".IMAGES_TABLE." SET image_keywords = '$new_keywords' WHERE image_id = '$image_id'";
$result = mysql_query($sql) OR die("Fehler beim Schreiben in Tabelle.");
}
@mysql_close($site_db);
?>
$url_support_check_ticket = "";
if(new_ticket_check($user_info['user_id'],$user_info['user_name'])){
$url_support_check_ticket .= "<script language=\"JavaScript\">\n<!--\n var flg2=0;\n function new_tick_blink(){\n var myElement=document.getElementById('blnk2');\n flg2^=1;\n if(flg2==1){\n myElement.style.visibility='hidden';\n }\n else{\n myElement.style.visibility='visible';\n }\n timerID = setTimeout( 'new_tick_blink()' , 500 );\n }\n //-->\n</script>\n";
$url_support_check_ticket .= "<span id=\"blnk2\"><a href=\"".$site_sess->url(ROOT_PATH."support.php")."\">".$lang['support_view']."</a></span></a><script language=\"JavaScript\">new_tick_blink();</script>";
}
RewriteRule ^(includes|sessions\.php) - [L]