summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/class/registration.class.php94
-rw-r--r--lib/class/user.class.php42
-rw-r--r--lib/ui.lib.php153
3 files changed, 115 insertions, 174 deletions
diff --git a/lib/class/registration.class.php b/lib/class/registration.class.php
new file mode 100644
index 00000000..7b964b7f
--- /dev/null
+++ b/lib/class/registration.class.php
@@ -0,0 +1,94 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * Registration
+ * This class handles all the doodlys for the registration
+ * stuff in ampache
+ */
+class Registration {
+
+ /**
+ * constructor
+ * This is what is called when the class is loaded
+ */
+ public function __construct() {
+
+ // Rien a faire
+
+ } // constructor
+
+ /**
+ * send_confirmation
+ * This sends the confirmation e-mail for the specified user
+ */
+ public static function send_confirmation($username,$fullname,$email,$password,$validation) {
+
+ $headers = "From: Ampache <" . Config::get('mail_from') . ">";
+ $subject = "New User Registration at " . Config::get('site_title');
+ $body = "Thank you for registering\n\n" .
+ "Please keep this e-mail for your records. Your account information is as follows:\n\n" .
+ "----------------------\n" .
+ "Username: $username\n" .
+ "Password: $password\n" .
+ "----------------------\n\n" .
+ "Your account is currently inactive. You cannot use it until you've visited the following link:\n\n" .
+ Config::get('web_path') . "/register.php?action=validate&username=$username&auth=$validation\n\n" .
+ "Thank you for registering\n";
+
+ // Send the mail!
+ mail($email,$subject,$body,$headers);
+
+ // Check to see if the admin should be notified
+ if (Config::get('admin_notify_reg')) {
+ $body = "A new user has registered\n\n" .
+ "The following values were entered.\n\n"
+ "Username:$username\nFullname:$fullname\nE-mail:$mail\n\n";
+ mail(Config::get('mail_from'),$subject,$body,$headers);
+ }
+
+ return true;
+
+ } // send_confirmation
+
+ /**
+ * show_agreement
+ * This shows the registration agreement, /config/registration_agreement.php
+ */
+ public static function show_agreement() {
+
+ $filename = Config::get('prefix') . '/config/registration_agreement.php';
+
+ if (!file_exists($filename)) { return false; }
+
+ /* Check for existance */
+ $fp = fopen($filename,'r');
+
+ if (!$fp) { return false; }
+
+ $data = fread($fp,filesize($filename));
+
+ /* Scrub and show */
+ echo $data;
+
+ } // show_agreement
+
+} // end registration class
+?>
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index 3870f910..1fa24adb 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -942,34 +942,34 @@ class User {
} // delete
- /*!
- @function is_online
- @parameter delay how long since last_seen in seconds default of 20 min
- @description calcs difference between now and last_seen
- if less than delay, we consider them still online
- */
-
- function is_online( $delay = 1200 ) {
+ /**
+ * is_online
+ * delay how long since last_seen in seconds default of 20 min
+ * calcs difference between now and last_seen
+ * if less than delay, we consider them still online
+ */
+ public function is_online( $delay = 1200 ) {
+
return time() - $this->last_seen <= $delay;
- }
- /*!
- @function get_user_validation
- @check if user exists before activation can be done.
- */
- function get_user_validation($username,$validation) {
+ } // is_online
+
+ /**
+ * get_user_validation
+ *if user exists before activation can be done.
+ */
+ public static function get_validation($username) {
- $usename = sql_escape($username);
+ $usename = Dba::escape($username);
- $sql = "SELECT validation FROM user where username='$username'";
- $db_results = mysql_query($sql, dbh());
+ $sql = "SELECT `validation` FROM `user` WHERE `username`='$username'";
+ $db_results = Dba::query($sql);
- $row = mysql_fetch_assoc($db_results);
- $val = $row['validation'];
+ $row = Dba::fetch_assoc($db_results);
- return $val;
+ return $row['validation'];
- } // get_user_validation
+ } // get_validation
/**
* get_recently_played
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 815b995a..72203091 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -145,30 +145,6 @@ function show_alphabet_list () {
} // show_alphabet_list
/**
- * show_alphabet_form
- * this shows the spiffy little form that acts as a "quick search" when browsing
- * @package General
- * @catagory Display
- */
-function show_alphabet_form($match, $text, $action) {
-
- require (conf('prefix') . '/templates/show_alphabet_form.inc.php');
-
-} // show_alphabet_form
-
-
-/**
- * show_local_control
- * shows the controls
- * for localplay
- */
-function show_local_control () {
-
- require_once(conf('prefix') . "/templates/show_localplay.inc");
-
-} // show_local_control
-
-/**
* truncate_with_ellipsis
* Correct Spelling function that truncates text to a specific lenght
* and appends three dots, or an ellipsis to the end
@@ -338,19 +314,6 @@ function set_song_rating($song_id, $rate_user, $rating) {
} // set_song_rating()
/**
- * show_clear
- * this is a hack because of the float mojo it clears the floats
- * @package Web Interface
- * @catagory Hack-o-Rama
- * @author Karl Vollmer
- */
-function show_clear() {
-
- echo "\n<br style=\"clear:both;\" />\n";
-
-} // show_clear
-
-/**
* show_page_footer
* adds page footer including html and body end tags
* @param $menu menu item to highlight
@@ -375,25 +338,6 @@ function show_page_footer($menu="Home", $admin_menu='', $display_menu=0) {
} // show_page_footer
/**
- * Show All Popular
- * This functions shows all of the possible global popular tables, this is basicly a top X where X is
- * set on a per user basis
- * @package Web Interface
- * @catagory Display
- * @author Karl Vollmer
- */
-function show_all_popular() {
-
- $artists = get_global_popular('artist');
- $albums = get_global_popular('album');
- $songs = get_global_popular('song');
- $genres = get_global_popular('genre');
-
- require_once Config::get('prefix') . '/templates/show_all_popular.inc.php';
-
-} // show_all_popular
-
-/**
* img_resize
* this automaticly resizes the image for thumbnail viewing
* only works on gif/jpg/png this function also checks to make
@@ -655,103 +599,6 @@ function good_email($email) {
} //good_email
/**
- * str_rand
- *
- *
- */
-function str_rand($length = 8, $seeds = 'abcdefghijklmnopqrstuvwxyz0123456789'){
- $str = '';
- $seeds_count = strlen($seeds);
-
- // Seed
- list($usec, $sec) = explode(' ', microtime());
- $seed = (float) $sec + ((float) $usec * 100000);
- mt_srand($seed);
-
- // Generate
- for ($i = 0; $length > $i; $i++) {
- $str .= $seeds{mt_rand(0, $seeds_count - 1)};
- }
-
- return $str;
-} //str_rand
-
-/**
- * send_confirmation
- *
- *
- */
-function send_confirmation($username, $fullname, $email, $password, $validation) {
-
-$title = conf('site_title');
-$from = "From: Ampache <".conf('mail_from').">";
-$body = "Welcome to $title
-
-Please keep this email for your records. Your account information is as follows:
-
-----------------------------
-Username: $username
-Password: $password
-----------------------------
-
-Your account is currently inactive. You cannot use it until you visit the following link:
-"
-. conf('web_path'). "/activate.php?mode=activate&u=$username&act_key=$validation
-
-Please do not forget your password as it has been encrypted in our database and we cannot retrieve it for you. However, should you forget your password you can request a new one which will be activated in the same way as this account.
-
-Thank you for registering.";
-
-
-mail($email, "Welcome to $title" , $body, $from);
-
-if (conf('admin_notify_reg')){
-
-$admin_body = "A new user has registered at $title
-
-The following values where entered;
-
-Username: $username
-Fullname: $fullname
-E-Mail: $email
-
-Click here to view user:
-"
- . conf('web_path') . "/admin/users.php?action=edit&user=$username";
-
-
-
-mail (conf('mail_from'), "New user registration at $title", $admin_body, $from);
-}
-
-
-} //send_confirmation
-
-/**
- * show_registration_agreement
- * This function reads in /config/registration_agreement.php
- * Plaintext Only
- */
-function show_registration_agreement() {
-
- $filename = Config::get('prefix') . '/config/registration_agreement.php';
-
- if (!file_exists($filename)) { return false; }
-
- /* Check for existance */
- $fp = fopen($filename,'r');
-
- if (!$fp) { return false; }
-
- $data = fread($fp,filesize($filename));
-
- /* Scrub and show */
- echo $data;
-
-} // show_registration_agreement
-
-
-/**
* show_playlist_import
* This shows the playlist import templates
*/