"Tofu_Session", "auth" => "Tofu_Default_Auth", "perm" => "Tofu_Perm", "user" => "Tofu_User")); //$auth->login_if(! $perm->have_perm('user')); // login if not authenticated as a user function add_user() { $db = new DB_Tofu_Session; if (!$perm->have_perm("admin")) { // Do we have permission to do so? print "
You do not have permission to create users.
"; return 0; } // Do we have all necessary data? if (empty($username) || empty($password)) { print "Please fill out Username and Password!
"; return 0; } // Does the user already exist? // NOTE: This should be a transaction, but it isn't $db->query("select * from auth_user where username='$username'"); if ($db->nf()>0) { print "User $username already exists!
"; return 0; } // Create a uid and insert the user... $u_id=md5(uniqid($hash_secret)); $permlist = addslashes(implode($perms,",")); $permlist = 'user'; $query = "insert into auth_user values('$u_id','$username','$password','$permlist','$tofu_id')"; $db->query($query); if ($db->affected_rows() == 0) { print "Failed: $query
"; break; } return $u_id; } function edit($row) { echo "\n"; } function load($id) { if (! is_numeric($id)) { return ''; } $query ="select user.id as user_id, user.name as user_name, user.login as user_login, user.profile as user_profile, user.url as user_url, user.phone as user_phone, user.password as user_password, user.email as user_email, user.address as user_address, user.city as user_city, user.state as user_state, user.zip as user_zip, user.country as user_country, user.status_id as user_status_id, DATE_FORMAT( user.date_added, '%M %D, %Y') as user_date_added, user.favorite_ethnicity_id as user_favorite_ethnicity_id from user where user.id = $id"; $res = run_query($query); return mysql_fetch_array($res); } function view($view, $id, $sort) { global $db_tofu; $query = "select user.id, user.name, user.login, user.address, user.city, user.state, user.country, user.zip, user.email, user.url, user.phone, user.profile, user.status_id, DATE_FORMAT( user.date_added, '%m/%d/%y') as date_added, user.favorite_ethnicity_id, ethnicity.name as ethnicity from user, ethnicity where user.favorite_ethnicity_id = ethnicity.id"; if (! empty($id)) { $query .= "\n and user.id = $id "; } if ($sort) { $query .= "\n order by " . $sort; } else { $query .= "\n order by name\n"; } $res = run_query($query); if ($view == 'long') { //while ($row = mysql_fetch_array($res)) { while ($db_tofu->next_record()) { longView($db_tofu->Record); } } else { echo "| \n";
echo "\n " . $row['name'] . " \n"; // need restricting views of email addr. need profile settings for this if (($row['id'] == $GLOBALS['auth']->auth['tofu_id']) || ($GLOBALS['perm']->have_perm('admin')) ) { echo "\n" . preg_replace("/@/", "(at)",$row['email']) . "\n"; } echo "\n" . $row['url'] . " \n"; $clean_city = strtolower($row['city']); $clean_city = preg_replace("/\s|\./", "", $clean_city); // city echo "" . $row['city'] . " "; // state echo ", " . $row['state'] . " " . $row['zip'] . " "; // country echo "" . $row['country'] . " "; // echo $row['city'] . ", " . $row['state'] . " " . $row['zip'] . " \n" . $row['country'] . "\n"; echo " Reviews: " . $row['login'] . "'s reviews \n"; if (! empty($row['profile'])) { echo " Profile:\n"; echo $row['profile'] . " \n"; } echo "Joined: " . $row['date_added'] . " \n"; if ($no_image) { echo "Add Image"; } if (($row['id'] == $GLOBALS['auth']->auth['tofu_id']) || ($GLOBALS['perm']->have_perm('admin')) ) { echo " "; echo " ";
echo " Edit\n";
}
echo " | ";
if (! empty($image_row['name'])) {
echo " |