Nukemods Forum  
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Online Users: 65
1 members and 64 guests
health46ev26
Most users ever online was 611, 03-21-2008 at 10:10 PM.
» .::.
» .:.

Go Back   Nukemods Forum > PHP-Nuke 6.5 to 6.9 > Nuke 6.5 to 6.9 - Modules

Reply
 
LinkBack Thread Tools Display Modes
converting site to use nuke database....
Old
  (#1 (permalink))
Junior Member
 
Status: Offline
Posts: 130
Join Date: Mar 2003
Location: Austin, TX
converting site to use nuke database.... - 06-12-2003, 04:56 AM

Hi guys and girls.
This is what I'm wanting: I'm using a PHP Gedcom Viewer found at http://phpgedview.sourceforge.net/ that is independent of Nuke or MySQL. It uses it's own user database via a file called authentication.php.

The creator of the software, John Finlay said that he
Quote:
designed the authentication system to be modular so that it could easily be modified to work with a phpNuke user database. You could implement the functions in authentication.php to recognize your phpNuke users. phpGedView only cares that the functions in that file exist, not how they are implemented.
.

This is something I'm very interested in seeing implemented into his project. Not only would I like to use the existing nuke user db, but I want it also to be a module, not the iframe module I have now.

The code is as follows:
Code:
===================================================*/
//-- file that holds the users array
require "authenticate.php";

//====================================================================
//-- The following functions must be implemented by anyone wishing to
//-- extend the authentication functionality of PhpGedView
//====================================================================

//----------------------------------- authenticateUser
//-- requires a username and password and 
//-- returns true if the username and password
//-- pair allow access
function authenticateUser($username, $password) {
	global $users;
	
	if (array_key_exists($username, $users)) {
		$user = $users[$username];
		if (crypt($password, $user["password"])==$user["password"]) {
			setcookie("pgv_user", $username, time()+3600);
			return true;
		}
	}
	return false;
}

//----------------------------------- userLogout
//-- logs a user out of the system
function userLogout() {
	global $pgv_user;
	setcookie("pgv_user", "loggedout", time()-3600);
	$pgv_user = "loggedout";
}

//----------------------------------- getUserName
//-- retrieve the username from the state
//-- however you are storing it.  The default
//-- implemenation uses a cookie
function getUserName() {
	global $pgv_user;
	
	if (isset($pgv_user)) {
		if ($pgv_user=="loggedout") return "";
		return $pgv_user;
	}
	return "";
}

//----------------------------------- userIsAdmin
//-- takes a username and checks if the
//-- user has administrative privileges
//-- to change the configuration files
function userIsAdmin($username) {
	global $users;
	
	if (array_key_exists($username, $users)) {
		$user = $users[$username];
		return $user["canadmin"];
	}
	return false;
}

//----------------------------------- userCanEdit
//-- takes a username and checks if the
//-- user has write privileges to change
//-- the gedcom data
function userCanEdit($username) {
	global $users;
	
	if (array_key_exists($username, $users)) {
		$user = $users[$username];
		return $user["canedit"];
	}
	return false;
}

//----------------------------------- adminUserExists
//-- return true if an admin user has been defined
function adminUserExists() {
	global $users;
	
	if (count($users)==0) return false;
	return true;
}

//----------------------------------- storeUsers
//-- writes the users to the file
function storeUsers() {
	global $users;
	
	$authtext = "<?php\n\n\$users = array();\n\n";
	foreach($users as $key=>$user) {
		$authtext .= "\$user = array();\n";
		foreach($user as $ukey=>$value) {
			$value = preg_replace('/"/', '\\"', $value);
			$authtext .= "\$user[\"$ukey\"] = '$value';\n";
		}
		$authtext .= "\$users[\"$key\"] = \$user;\n\n";
	}
	$authtext .= "?>\n";
	$fp = fopen("authenticate.php", "w");
	if ($fp===false) {
		print "<font class=error>Could not open authentication.php file for writing.  Check file permissions.</font>

";
		return false;
	}
	fwrite($fp, $authtext);
	fclose($fp);
	return true;
}

//----------------------------------- addUser
//-- adds a new user.
//-- requires the newuser parameter to be an array
function addUser($newuser) {
	global $users;
	
	$users[$newuser["username"]]=$newuser;		
	return storeUsers();
}

//----------------------------------- deleteUser
//-- deletes the user with the given username.
function deleteUser($username) {
	global $users;
	
	unset($users[$username]);
	return storeUsers();
}

//----------------------------------- getUser
//-- returns an array for the user with the given username.
function getUser($username) {
	global $users;
	
	return $users[$username];
}

//----------------------------------- 
//-- if user wishes to logout this is where we will do it
if ((!empty($logout))&&($logout==1)) {
	userLogout();
}

?>
The phpgedview folder is currently placed in the root directory (normaly and the authentication file is in that folder. Does anyone recognize how this can be done? If so, I know I would appreciate the help, and John said he would add this to his next update on the software if we can get it working.

Thanks for any help.

Murph
 Send a message via ICQ to MurphDog Send a message via Yahoo to MurphDog Send a message via AIM to MurphDog Send a message via MSN to MurphDog  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Import phpbb to nuke platinum database jendean71 Open topics 2 06-21-2006 03:35 PM
Multiple copies of Nuke with 1 database? Scryer Nuke 7.x - General 1 07-03-2005 06:41 PM
Converting PostNuke to PHP-Nuke?? Sarge Nuke 7.x - General 2 10-21-2004 07:29 PM
Converting phpbb2 theme to Nuke question on styles MurphDog Purged Topics 1 07-14-2003 12:17 PM
Converting an an Gedcom Viewer site into a module MurphDog Nuke 6.5 to 6.9 - Modules 0 04-22-2003 10:45 PM




vBulletin Skin developed by: vBStyles.com


LinkBacks Enabled by vBSEO 3.3.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31