Difference between revisions of "Username Checking"
From TMM Wiki
Jump to navigationJump to searchm |
TMMStephenY2 (talk | contribs) |
||
Line 6: | Line 6: | ||
}} | }} | ||
− | NATS can query your local database or password file with a script to see | + | == Username Scripts == |
− | if a username exists. | + | |
− | ID number and a username. | + | [[NATS]] can query your local database or password file with a PHP script to see |
− | return "*exists*"; if the username doesn't exist, the script should return | + | if a particular username exists in your database. This script should take two variables: a [[ct#Site|site]] ID number and a username. If the username in question exists, the script should return "*exists*"; if the username doesn't exist, the script should return |
"*available*". For example: | "*available*". For example: | ||
Line 50: | Line 50: | ||
</pre> | </pre> | ||
− | + | == Implementing Your Script == | |
− | your script | + | |
+ | To use your script, go to the [[Sites Admin]] and edit the tour you want the script to take effect on. On the Edit Tour page, go to ''Postback URLs'' and click ''Show/Hide Advanced Settings'' to expand the category. Under ''Username Post URL'', enter your script's URL to make it take effect. | ||
[[Category:Also NATS4 Article]] | [[Category:Also NATS4 Article]] |
Revision as of 12:12, 14 June 2010
NATS 3
|
---|
Username Scripts
NATS can query your local database or password file with a PHP script to see if a particular username exists in your database. This script should take two variables: a site ID number and a username. If the username in question exists, the script should return "*exists*"; if the username doesn't exist, the script should return "*available*". For example:
<?php //pull variables out of query string; $siteid = $_GET['siteid']; $username = $_GET['username']; //initialize password file $passwordfile = ' '; //set password file based on site id switch($siteid) { //if siteid = 1, passwordfile = path to password file for site 1 case 1: $passwordfile='/home/web/onesite/.htpasswd'; break; case 2: $passwordfile='/home/web/differentsite/.htpasswd'; break; } //now that we know what file to open, open that file to read $openfile = fopen($passwordfile, 'r'); //get the contents of the open file $filecontents = fread($openfile, filesize($passwordfile)); //search file contents for username if(strpos($filecontents, $username)===0) { echo '*available*'; } else { echo '*exists*';} ?>
Implementing Your Script
To use your script, go to the Sites Admin and edit the tour you want the script to take effect on. On the Edit Tour page, go to Postback URLs and click Show/Hide Advanced Settings to expand the category. Under Username Post URL, enter your script's URL to make it take effect.