The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Check this scirpt
Discuss Check this scirpt in the PHP Development forum on Dev Shed. Check this scirpt PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

June 12th, 2000, 06:20 AM
|
|
Junior Member
|
|
Join Date: Jun 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Please check this script for me.
<?
// copyright 2000, Dennis van der Vliet
// Version 0.1
// this script (useradd.php) check some information a user provided
// and insert, if correct the information into a table (users)
// NOTICE
// this script is release under the standard GPL license
// please mail (zappit01@hotmail.com) me when you add/use or have comment on
// this script
// ----used variables----
// $usrId, $usrName, $usrPassword, $usrEMail, $usrHomePage
// $usrICQ, $usrUrlPic, $usrTextPic, $usrRealName, $usrPosts, $usrLevel
// $usrProfile, $usrFavourites, $usrAllowEmail, $usrAllowCookies, $setPassWordLength
// $usrError, $usrErrorTemp, $query
// ----history----
// 6-6-2000: created this file
// 7-6-2000: removed all the global vars from the script, they stink
// 9-6-2000: the script is done, upgrade to version 0.1 only implanting the
// templates needs to be done.
// ----end----script----starts----here----
// include the error message script
require ("config/errors.php");
// this script contains a function called error(), when you call it like this error(1)
// it will display the error message with the number 1
// include the style sheet
require ("config/style.php");
// include the config file, all general settings are in here
require ("config/config.php");
// name: createPassword
// in: $setPassWordLength
// out: $usrPassword
// function: this function generates a random password, containing numbers and
// characters.
function createPassword ($setPassWordLength) {
// declare allowed chars
$char = explode( " ",
"a b c d e f g h i j k l m n o p q r s t u v w x y z "
. "0 1 2 3 4 5 6 7 8 9 @ # $ % & * + = ?"
. "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
);
// generate the password with a max length of X chars
for($i=0;$i<$setPassWordLength;$i++) {
srand((double)microtime()*1000000);
$rand = rand(1, 71);
$usrPassWord .= $char[$rand];
}
return $usrPassWord;
}
// END of createPassword
// name: valEMail
// in: $usrEMail
// out: $usrErrorTemp, $usrEMail
// function: this function checks or the email address is valid, if not he will report
// it
function valEMail ($usrEMail) {
require ("config/config.php");
// if the field is left empty return an error
if (empty($usrEMail)) {
return error(2);
} else {
// check the email address
if((strpos($usrEMail,"@")>0) and (strpos($usrEMail,".")>0)){
// if the user also wants to check or the host is so called "bad"
if ($setBadEMailHost == true) {
list($usrEMailUserName, $usrEMailDomain) = explode("@", $usrEMail);
// connect to server
$dbConn = mysql_connect($setMyHost, $setMyUser, $setMyPassWord);
// select database at the server
mysql_select_db($setMyDataBase, $dbConn);
// create and execute query
$sql = "SELECT host FROM eMailBan WHERE host='$usrEMailDomain'";
$query = mysql_query ($sql, $dbConn) or ("");
// how many rows are in the result?
$query = mysql_num_rows($query);
// if zero, the host is ok
if (empty($query)) {
} else {
// if 1 or more, host is so called "bad"
return error(10, $usrEMailDomain);
}
} else {
}
// if the users wants only one account per e-mail address
if ($setAllowUsersEMail == false){
// connect to server
$dbConn = mysql_connect($setMyHost, $setMyUser, $setMyPassWord);
// select database at the server
mysql_select_db($setMyDataBase, $dbConn);
// create and execute query
$sql ="SELECT name FROM users WHERE eMail='$usrEMail'";
$query = mysql_query ($sql, $dbConn) or ("");
// how many rows are in the result?
$query = mysql_num_rows($query);
// if zero it's ok
if ($query == 0) {
} else {
// if 1 or more, return the error message
return error(11, $usrEMail);
}
} else {
}
} else {
// if the e-mail address field is left blank, return this message
return error(1);
}
}
}
// END of valEmail
// name: valUsrName
// in: $usrName
// out: $usrName, $usrErrorTemp
// comment: this function check if the user name is valid/ available
function valUsrName ($usrName) {
include ("config/config.php");
// checks the user name for illegal chars
if ($usrName == quotemeta(addslashes($usrName))) {
if (empty($usrName)) {
return error(6);
// check or the username isn't to long
} else if (strlen($usrName >= $setMaxUserNameLength)) {
return error(4);
} else {
// check or the username doesn't already exists
// connect to server
$dbConn = mysql_connect($setMyHost, $setMyUser, $setMyPassWord);
// select database at the server
mysql_select_db($setMyDataBase, $dbConn);
// create and execute query
$query = mysql_query ("SELECT id FROM users WHERE name='$usrName'", $dbConn);
// how many rows are in the result?
$query = mysql_num_rows($query);
// if zero it's ok
if ($query == 0) {
} else {
// if 1 or more it isn't
return error(3);
}
}
} else {
return error(7);
}
}
// END of valUsrName
// the following functions check or a field is filled in
// but only when the user said so, this is done in config.php
// the functions are: valIcq, valRealName, valProfile, valHomepage
// valUrlPic, valTextPic
// name: valIcq
// in: $usrIcq
// out: $usrRegErrorTmp
// comment this function check or the icq number is set
function valIcq($usrICQ) {
if (empty($usrICQ)) {
return error(5);
} else {
}
}
// END of valICQ
// name: valRealName
// in: $usrRealName
// out: $usrRegErrorTmp
// comment this function check or a real name is given
function valRealName($usrRealName) {
require ("config/config.php");
if ($setReqUsrRealName == true) {
if (empty($usrRealName)) {
return error(8);
} else {
}
} else {
}
}
// END of valRealName
// name: valProfile
// in: $usrProfile
// out: $usrRegErrorTmp
// comment this function check or a profile is given
function valProfile($usrProfile) {
require ("config/config.php");
if ($setReqUsrProfile == true) {
if (empty($usrProfile)) {
return error(9);
} else {
}
} else {
}
}
// END of valProfile
// name: valHomepage
// in: $usrHomePage
// out: $usrRegErrorTmp
// comment this function check or a homepage url is given
function valHomePage($usrHomePage) {
require ("config/config.php");
if ($setReqUsrHomePage == true) {
if (empty($usrHomePage)) {
return error(14);
} else {
}
} else {
}
}
// END of valHomePage
// name: valUrlPic
// in: $usrUrlPic
// out: $usrRegErrorTmp
// comment this function check or a homepage url is given
function valUrlPic($usrUrlPic) {
require ("config/config.php");
if ($setReqUsrUrlPic == true) {
if (empty($usrUrlPic)) {
return error(12);
} else {
}
} else {
}
}
// END of valUrlPic
// name: valTextPic
// in: $usrTextPic
// out: $usrRegErrorTmp
// comment this function check or a picture text is given
function valTextPic($usrTextPic) {
require ("config/config.php");
if ($setReqUsrTextPic == true) {
if (empty($usrTextPic)) {
return error(13);
} else {
}
} else {
}
}
// END of valTextPic
// name: sendMail
// in: $usrEMail, $usrPassWord
// out: a mail
// comment: this function sends the mail including the password
function sendMail($usrEMail, $usrPassWord, $usrName, $usrRealName) {
require ("config/config.php");
// send the mail containg the message given in config.php
mail("$usrEMail", "$setEMailSubject", "$setEMailText", "From: $setAdminName <$setAdminEMail>n Reply-to: $setAdminName <$setAdminEMail>nContent-type: text/plainnX-Mailer: PHP/" . phpversion());
}
// END of sendMail
// name : insert
// in: all
// out: none
function insert($usrName, $usrPassword, $usrEMail, $usrHomePage, $usrICQ, $usrUrlPic, $usrTextPic, $usrRealName, $usrPosts, $usrProfile, $usrAllowEmail, $usrAllowCookies) {
require ("config/config.php");
// connect to server
$dbConn = mysql_connect($setMyHost, $setMyUser, $setMyPassWord);
// select database at the server
mysql_select_db($setMyDataBase, $dbConn);
// code the userpassword using md5 as method
$usrPassWord = md5($usrPassWord);
// translate some checkboxes into values
if (empty($usrAllowCookies)) {
$usrAllowCookies = "n";
} else {
$usrAllowCookies = "y";
}
if (empty($usrAllowEMail)) {
$usrAllowEMail = "n";
} else {
$usrAllowEMail = "y";
}
// execute the query
mysql_query ("INSERT INTO users (name, passWord, eMail, homePage, ICQ, urlPic, textPic, realName, userLevel, profile, allowEMail, allowCookies) VALUES ('$usrName', '$usrPassWord', '$usrEMail', '$usrHomePage', '$usrICQ', '$usrUrlPic', '$usrTextPic', '$usrRealName', 5, '$usrProfile', '$usrAllowEMail', '$usrAllowCookies')", $dbConn);
// echo a little message
echo "alle gegevens zijn succesvol verwerkt, er komt een e-mail aan met je wachtwoord";
}
// create the password
$usrPassWord = createPassWord($setPassWordLength);
// check email address
$usrRegErrorTmp =valEMail($usrEMail);
// check or address is ok
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check username
$usrRegErrorTmp = valUsrName ($usrName);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check icq
$usrRegErrorTmp = valICQ($usrICQ);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check realname
$usrRegErrorTmp = valRealName($usrRealName);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check profile
$usrRegErrorTmp = valProfile($usrProfile);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check homepage
$usrRegErrorTmp = valHomePage($usrHomePage);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check url of personal pic
$usrRegErrorTmp = valUrlPic($usrUrlPic);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
// check text of personal pic
$usrRegErrorTmp = valTextPic($usrTextPic);
// create error string
if (empty($usrRegErrorTmp)) {
} else {
$usrRegError .= $usrRegErrorTmp . "<br>";
}
if (empty($usrRegError)) {
// if there aren't any error mail the password and insert the data into the table
sendmail ($usrEMail, $usrPassWord, $usrName, $usrRealName);
insert($usrName, $usrPassword, $usrEMail, $usrHomePage, $usrICQ, $usrUrlPic, $usrTextPic, $usrRealName, $usrPosts, $usrProfile, $usrAllowEmail, $usrAllowCookies);
} else {
// if there are any error print them
echo $usrRegError;
}
?>
|

June 12th, 2000, 06:39 AM
|
 |
.Net Developer
|
|
Join Date: Feb 2000
Location: London
Posts: 987
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
|
|
What are you doing with this script??
pls explain your problem....
------------------
SR -
shiju.dreamcenter.net
"The fear of the LORD is the beginning of knowledge..."
[This message has been edited by Shiju Rajan (edited June 12, 2000).]
|

June 12th, 2000, 07:01 AM
|
|
Junior Member
|
|
Join Date: Jun 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
The script registers a user and sends the user a e-mail including the password. Oke?
|

June 12th, 2000, 07:05 AM
|
|
Junior Member
|
|
Join Date: Jun 2000
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
The script registers a user and sends the user a e-mail including the password. Oke?
|

June 12th, 2000, 08:04 AM
|
|
Registered User
|
|
Join Date: Jun 2000
Posts: 2
Time spent in forums: 52 m 19 sec
Reputation Power: 0
|
|
|
dus daarom wou je weten welke database er op free2surf zit URL
------------------
Just a skinner / www.skinners.cjb.net
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|