diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-01-02 01:06:06 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-01-02 01:06:06 +0000 |
commit | 83f3c4114164617f48f3b013027f9079ddc2675c (patch) | |
tree | 3fc5ba313a14992eb3683e2a2e46c095fc7a8f7f /lib | |
parent | 5c2efb82b74874e5f7220cb1a00479c009d9221b (diff) | |
download | ampache-83f3c4114164617f48f3b013027f9079ddc2675c.tar.gz ampache-83f3c4114164617f48f3b013027f9079ddc2675c.tar.bz2 ampache-83f3c4114164617f48f3b013027f9079ddc2675c.zip |
updated registration mojo thx pb1dft also some fluf updates
Diffstat (limited to 'lib')
32 files changed, 192 insertions, 40 deletions
diff --git a/lib/artist.lib.php b/lib/artist.lib.php index aa89e482..bfd956b6 100644 --- a/lib/artist.lib.php +++ b/lib/artist.lib.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/batch.lib.php b/lib/batch.lib.php index 5cb8494f..af4ed80a 100644 --- a/lib/batch.lib.php +++ b/lib/batch.lib.php @@ -1,19 +1,22 @@ <?php /* -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. + Copyright (c) 2001 - 2006 Ampache.org + All Rights Reserved -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. + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + 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. + 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. */ diff --git a/lib/class/access.class.php b/lib/class/access.class.php index 85fc3a81..8a0ad168 100644 --- a/lib/class/access.class.php +++ b/lib/class/access.class.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/class/album.class.php b/lib/class/album.class.php index 5b56d90a..08da4c4e 100644 --- a/lib/class/album.class.php +++ b/lib/class/album.class.php @@ -1,7 +1,8 @@ <?php /* - Copyright (c) 2004 - Ampache.org + + Copyright (c) 2001 - 2006 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 diff --git a/lib/class/artist.class.php b/lib/class/artist.class.php index 5f9267b3..961b5991 100644 --- a/lib/class/artist.class.php +++ b/lib/class/artist.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2004 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 2265afba..dcbf074e 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/class/error.class.php b/lib/class/error.class.php index 5515e41c..b3e74ba5 100644 --- a/lib/class/error.class.php +++ b/lib/class/error.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/genre.class.php b/lib/class/genre.class.php index dd664c5b..5d4e13d1 100644 --- a/lib/class/genre.class.php +++ b/lib/class/genre.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright 2001 - 2005 Ampache.org + Copyright 2001 - 2006 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index 765a2219..279134ee 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php index 06344e1c..f9dd0794 100644 --- a/lib/class/rating.class.php +++ b/lib/class/rating.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/song.class.php b/lib/class/song.class.php index d857e68a..e0f7dd36 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2004 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 16a7c722..9bf5b7f1 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/update.class.php b/lib/class/update.class.php index d6890465..4977135a 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/class/user.class.php b/lib/class/user.class.php index 8442da90..83b473a3 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -36,6 +36,8 @@ class User { var $offset_limit=25; var $email; var $last_seen; + var $reg_date; + var $validation; function User($username=0) { @@ -52,6 +54,8 @@ class User { $this->offset_limit = $info->offset_limit; $this->email = $info->email; $this->last_seen = $info->last_seen; + $this->reg_date = $info->reg_date; + $this->validation = $info->validation; $this->set_preferences(); // Make sure the Full name is always filled @@ -476,10 +480,9 @@ class User { $username = sql_escape($username); $fullname = sql_escape($fullname); $email = sql_escape($email); - /* Now Insert this new user */ - $sql = "INSERT INTO user (username, fullname, email, password, access) VALUES" . - " ('$username','$fullname','$email',PASSWORD('$password'),'$access')"; + $sql = "INSERT INTO user (username, fullname, email, password, access, reg_date) VALUES" . + " ('$username','$fullname','$email',PASSWORD('$password'),'$access', unix_timestamp())"; $db_results = mysql_query($sql, dbh()); if (!$db_results) { return false; } @@ -737,9 +740,31 @@ class User { @description calcs difference between now and last_seen if less than delay, we consider them still online */ + 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){ + $sql = "SELECT validation FROM user where username='$username'"; + $db_results = mysql_query($sql, dbh()); + $row = mysql_fetch_array($db_results); + $val = $row[validation]; + return $val; + } // get_user_validation + + /*! + @function activate_user + @activates the user from public_registration + */ + function activate_user($username) { + $sql = "UPDATE user SET disabled='0' WHERE username='$username'"; + $db_results = mysql_query($sql, dbh()); + } // activate_user } //end class + ?> diff --git a/lib/class/view.class.php b/lib/class/view.class.php index 112148ad..afc81b22 100644 --- a/lib/class/view.class.php +++ b/lib/class/view.class.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2004 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/debug.php b/lib/debug.php index c554daf7..8d24d54d 100644 --- a/lib/debug.php +++ b/lib/debug.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2004 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/duplicates.php b/lib/duplicates.php index 93e082d9..75ca2a22 100644 --- a/lib/duplicates.php +++ b/lib/duplicates.php @@ -1,4 +1,26 @@ <?php +/* + + Copyright (c) 2001 - 2006 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 + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + 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. + +*/ + + /*! @header Contains the functions for handling duplicate songs */ diff --git a/lib/flag.php b/lib/flag.php index da371793..5e16faeb 100644 --- a/lib/flag.php +++ b/lib/flag.php @@ -1,10 +1,9 @@ <?php /* - Copyright (c) 2004 Ampache.org + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/general.lib.php b/lib/general.lib.php index cc49d7be..983b4c12 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -1,5 +1,27 @@ <?php /* + + Copyright (c) 2001 - 2006 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 + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + 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. + +*/ + + +/* @header General Library This is the general library that contains misc functions that doesn't have a home elsewhere diff --git a/lib/gettext.php b/lib/gettext.php index 064173d6..602f3365 100644 --- a/lib/gettext.php +++ b/lib/gettext.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/install.php b/lib/install.php index c3c1c8b4..3ca0fb79 100644 --- a/lib/install.php +++ b/lib/install.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/log.lib.php b/lib/log.lib.php index e196a73f..0f9e6a99 100644 --- a/lib/log.lib.php +++ b/lib/log.lib.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/mpd.php b/lib/mpd.php index efbbda6e..26053267 100644 --- a/lib/mpd.php +++ b/lib/mpd.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/preferences.php b/lib/preferences.php index dea96529..c33980f3 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/rss.php b/lib/rss.php index 4fc849d2..eefb9ad1 100644 --- a/lib/rss.php +++ b/lib/rss.php @@ -1,7 +1,7 @@ <?php /* - Copyright 2001 - 2005 Ampache.org + Copyright 2001 - 2006 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or diff --git a/lib/search.php b/lib/search.php index 8484c71f..818c91d2 100644 --- a/lib/search.php +++ b/lib/search.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2004 ampache.org + Copyright (c) 2001 - 2006 ampache.org All rights reserved. This program is free software; you can redistribute it and/or diff --git a/lib/song.php b/lib/song.php index 7c9a3282..ba453d5c 100644 --- a/lib/song.php +++ b/lib/song.php @@ -1,6 +1,9 @@ <?php /* + Copyright (c) 2001 - 2006 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 as published by the Free Software Foundation; either version 2 diff --git a/lib/stream.lib.php b/lib/stream.lib.php index 57be2fe3..f1f0a366 100644 --- a/lib/stream.lib.php +++ b/lib/stream.lib.php @@ -1,7 +1,7 @@ <?php /* - Copyright 2001 - 2005 Ampache.org + Copyright 2001 - 2006 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or diff --git a/lib/themes.php b/lib/themes.php index 1c67c5a7..aac16330 100644 --- a/lib/themes.php +++ b/lib/themes.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 77693a05..e1144abb 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or @@ -1132,6 +1132,7 @@ function new_user($username, $fullname, $email, $password) { $username = sql_escape($username); $fullname = sql_escape($fullname); $email = sql_escape($email); + $validation = str_rand(20); $access = '5'; if(conf('auto_user')){ $access='25'; @@ -1146,11 +1147,12 @@ function new_user($username, $fullname, $email, $password) { /* Uhh let's not auto-pass through in this fashion FIXME */ else { /* Apparently it's a new user, now insert the user into the database*/ - $sql = "INSERT INTO user (username, fullname, email, password, access) VALUES" . - " ('$username','$fullname','$email',PASSWORD('$password'),'$access')"; + $sql = "INSERT INTO user (username, fullname, email, password, access, disabled, reg_date, validation) VALUES" . + " ('$username','$fullname','$email',PASSWORD('$password'),'$access', '1', unix_timestamp(), '$validation')"; $db_results = mysql_query($sql, dbh()); show_template('style'); - show_confirmation('Registration Complete','You have registered succesfully','/login.php'); + show_confirmation('Registration Complete','Your account has been created. However, this forum requires account activation. An activation key has been sent to the e-mail address you provided. Please check your e-mail for further information','/login.php'); + send_confirmation($username, $fullname, $email, $password, $validation); } return true; @@ -1192,6 +1194,60 @@ function good_email($email) { return true; } //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); + +} //send_confirmation + + ?> diff --git a/lib/upload.php b/lib/upload.php index 97c60118..a24c55c5 100644 --- a/lib/upload.php +++ b/lib/upload.php @@ -1,5 +1,8 @@ <?php /* + + Copyright (c) 2001 - 2006 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 diff --git a/lib/xmlrpc.php b/lib/xmlrpc.php index e1408ac8..cd6c3e70 100644 --- a/lib/xmlrpc.php +++ b/lib/xmlrpc.php @@ -1,7 +1,7 @@ <?php /* - Copyright (c) 2001 - 2005 Ampache.org + Copyright (c) 2001 - 2006 Ampache.org All rights reserved. This program is free software; you can redistribute it and/or |