From 5204485094d0f9dd7cbb5156cf402c86fcbb7ceb Mon Sep 17 00:00:00 2001 From: xgizzmo Date: Mon, 24 Jul 2006 22:14:54 +0000 Subject: [PATCH] Fix for bug 397 and 498 thanks pb1dft --- config/ampache.cfg.php.dist | 10 ++++++++-- lib/debug.php | 12 ++++++++++-- lib/ui.lib.php | 20 ++++++++++++++++++++ modules/captcha/captcha.php | 30 +++++++++--------------------- register.php | 2 +- templates/show_test.inc | 6 +++++- 6 files changed, 53 insertions(+), 27 deletions(-) diff --git a/config/ampache.cfg.php.dist b/config/ampache.cfg.php.dist index bb0adc7a..f91d3be8 100644 --- a/config/ampache.cfg.php.dist +++ b/config/ampache.cfg.php.dist @@ -296,14 +296,20 @@ refresh_limit = "60" #mail_domain = "domain.tld" # This setting will be used as mail from address. +# It will also be used to notify if a registration occured. # You need to change this when you activate public_registration. #mail_from = "info@domain.tld" +# This setting turns on/off admin notify off registration. +# DEFAULT: false +#admin_notify_reg = "false" + # This setting will allow all registrants to be auto-approved # as a user. By default, they will be added as a guest and # must be "promoted" by the admin. -# DEFAULT: false -#auto_user = "false" +# POSSIBLE VALUES: guest, user, admin +# DEFAULT: guest +#auto_user = "guest" # This will display the user agreement when registering # For agreement text, edit templates/user_agreement.php diff --git a/lib/debug.php b/lib/debug.php index b6564d8e..637ca178 100644 --- a/lib/debug.php +++ b/lib/debug.php @@ -34,6 +34,8 @@ file is readable, overkill I know.. @param level 0 is readable, 1 detailed info */ + + function read_config_file($file,$level=0) { $fp = @fopen($file, 'r'); @@ -186,7 +188,7 @@ function check_php_pcre() { least set the needed variables */ function check_config_values($conf) { - + $error = new Error(); if (!$conf['local_host']) { return false; } @@ -211,7 +213,13 @@ function check_config_values($conf) { if (!isset($conf['sess_cookiesecure'])) { return false; } - + if (isset($conf['debug'])) { + if (!isset($conf['log_path'])) { + $error->add_error('log_path',_("You defined the option \"debug = on\" but didn't define a log path for the log to be stored")); + return false; + } + } + return true; } // check_config_values diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 7ccd43b6..3b7d7150 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1106,6 +1106,26 @@ 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 /** diff --git a/modules/captcha/captcha.php b/modules/captcha/captcha.php index 039d1907..9f6c0a06 100644 --- a/modules/captcha/captcha.php +++ b/modules/captcha/captcha.php @@ -46,8 +46,7 @@ class captcha { function form($title="→ retype that here", $more="
Enter the correct letters and numbers from the image into the text box.
This small test serves as access restriction against malicious bots.
Simply reload the page if this graphic is too hard to read.
") { $pw = captcha::mkpass(); $hash = captcha::hash($pw); -// $maxsize = (strpos("MSIE", $_SERVER["HTTP_USER_AGENT"]) ? 1000 : 6000); - $maxsize = 100; + $maxsize = (strpos("MSIE", $_SERVER["HTTP_USER_AGENT"]) ? 1000 : 6000); @header("Vary: User-Agent"); $img = "data:image/jpeg;base64," . base64_encode(captcha::image($pw, 200, 60, CAPTCHA_INVERSE, $maxsize)); @@ -61,20 +60,10 @@ class captcha { . ''.$more.'' . ''; -// '' -// ''.$alt. '' -// . '' -// . '' -// . '
'.$alt. ''.$title. '
' -// ''.$title. '
' -// . '' -// . '
'.$more.'
'; - #-- js/html fix if ("MSIE") { - $base = "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]/ampache/captcha.php"; -// $base = "http://10.60.60.16/ampache/captcha.php"; -// . substr(realpath(__FILE__), strlen($_SERVER["DOCUMENT_ROOT"])); +// $base = "http://$_SERVER[SERVER_NAME]:$_SERVER[SERVER_PORT]".$conf('web_path')."/modules/captcha/captcha.php"; + $base = $_SERVER['PHP_SELF']; $html .= <</* /* generates alternative (non-graphic), human-understandable @@ -245,8 +228,13 @@ if (/Microsoft/.test(navigator.appName)) { } #-- let JFIF stream be generated -// $quality = 67; +/* Drop down quality if browser is MSIE */ +if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$_SERVER["HTTP_USER_AGENT"],$matched)){ $quality = 8; + } else { + $quality = 100; + } + $s = array(); do { ob_start(); ob_implicit_flush(0); diff --git a/register.php b/register.php index 8461f458..df3fa5cf 100644 --- a/register.php +++ b/register.php @@ -143,7 +143,7 @@ switch ($action) { /* Attempt to create the new user */ $access = 'disabled'; - if (conf('auto_user')) { $access = '5'; } + if (conf('auto_user')) { $access = conf('auto_user'); } $new_user = $GLOBALS['user']->create($username,$fullname,$email,$pass1,$access); if (!$new_user) { diff --git a/templates/show_test.inc b/templates/show_test.inc index 237f48cc..54157c65 100644 --- a/templates/show_test.inc +++ b/templates/show_test.inc @@ -174,7 +174,11 @@ $row_classes = array('even','odd'); + completely parse your config file"); + echo " "; + $error->print_error('log_path'); + echo " "; + ?>