diff --git a/admin/usercontrol.php b/admin/usercontrol.php
index a652a8e3f55..00b443f6bdb 100644
--- a/admin/usercontrol.php
+++ b/admin/usercontrol.php
@@ -1,94 +1,75 @@
>> PHPSurveyor #
- #############################################################
- # > Author: Jason Cleeland #
- # > E-mail: jason@cleeland.org #
- # > Mail: Box 99, Trades Hall, 54 Victoria St, #
- # > CARLTON SOUTH 3053, AUSTRALIA
- # > Date: 20 February 2003 #
- # #
- # This set of scripts allows you to develop, publish and #
- # perform data-entry on surveys. #
- #############################################################
- # #
- # Copyright (C) 2003 Jason Cleeland #
- # #
- # 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. #
- #############################################################
+#############################################################
+# >>> PHPSurveyor #
+#############################################################
+# > Author: Jason Cleeland #
+# > E-mail: jason@cleeland.org #
+# > Mail: Box 99, Trades Hall, 54 Victoria St, #
+# > CARLTON SOUTH 3053, AUSTRALIA
+# > Date: 20 February 2003 #
+# #
+# This set of scripts allows you to develop, publish and #
+# perform data-entry on surveys. #
+#############################################################
+# #
+# Copyright (C) 2003 Jason Cleeland #
+# #
+# 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. #
+#############################################################
*/
+include("classes/htaccess.class.php");
+
if (empty($homedir)) {die("Cannot run this script directly");}
if ($accesscontrol <> 1) {exit;}
-if (!file_exists("$homedir/.htaccess"))
+//REDIRECT EVERYTHING HERE IF THERE IS NO .htaccess FILE.
+if (!file_exists("$homedir/.htaccess") && $action == "setup")
+{
+
+ $addsummary = "
"._("Creating default htaccess file")."
\n";
+ $ht = new htaccess("$homedir/.htaccess","$homedir/.htpasswd");
+ $ht->setAuthType("Basic");
+ $ht->setAuthName("PHPSurveyor Admin Interface");
+
+ $addsummary .= _("Security Levels are now set up!")."
\n
\n";
+ $addsummary .= ""._("Continue")."\n";
+
+ $addsummary = "
"._("Creating default users")."
\n";
+
+ $ht->addUser($defaultuser,$defaultpass);
+
+ if (file_exists("$homedir/.htpasswd"))
{
- //REDIRECT EVERYTHING HERE IF THERE IS NO .htaccess FILE.
- if ($action == "setup")
- {
- //DON'T DO ANYTHING UNLESS IT HAS BEEN ASKED FOR
- //CREATE HTACCESS FILE
- $addsummary = "
"._("Creating default htaccess file")."
\n";
- $fname="$homedir/.htaccess";
- echo "";
- $handle=fopen($fname, 'a') or die ("\n
\n");
- echo "";
- fputs($handle, $htaccess);
- fclose($handle);
- $addsummary .= _("Security Levels are now set up!")."\n \n\n"._("Error")." \n
\n"._("Couldn't create htaccess file. Check your config.php for \$homedir setting, and that you have write permission in the correct directory.")."\n\n
\n
\n";
- $addsummary .= ""._("Continue")."\n";
-
- //CREATE DEFAULT USER AND PASS
- $addsummary = "
"._("Creating default users")."
\n";
- if (isset($htpasswddir) && $htpasswddir) {$htpasswd = "\"$htpasswddir/htpasswd\"";} else {$htpasswd = "htpasswd";}
-
- # Form command line. Redirect STDERR to STDOUT using 2>&1
- $command = "$htpasswd -bc .htpasswd $defaultuser $defaultpass 2>&1";
- $addsummary .= "".htmlspecialchars($command)."
\n
\n";
-
- exec($command, $CommandResult, $CommandStatus);
- if ($CommandStatus) //0=success, for other possibilities see http://httpd.apache.org/docs/programs/htpasswd.html
- {
- $addsummary .= "
"; - $addsummary .= "\$CommandStatus = $CommandStatus\n"; - $addsummary .= "\$CommandResult = \n"; - foreach ($CommandResult as $Line) {$addsummary .= "$Line\n";} - $addsummary .= "\n"; - } - - if (file_exists("$homedir/.htpasswd")) - { - $addsummary .= _("Updating users table")."
" - . "\$CommandStatus = $CommandStatus\n" - . "\$CommandResult = \n"; - foreach ($CommandResult as $Line) {$addsummary .= "$Line\n";} - $addsummary .= "\n"; - } + { + $ht = new htaccess("$homedir/.htaccess","$homedir/.htpasswd"); + $ht->addUser($user,$pass); $uquery = "INSERT INTO ".db_table_name('users')." VALUES ('$user', '$pass', '{$_POST['level']}')"; $uresult = $connect->Execute($uquery); $addsummary .= "
"; $addsummary .= "\$CommandStatus = $CommandStatus\n"; $addsummary .= "\$CommandResult = \n"; foreach ($CommandResult as $Line) {$addsummary .= "$Line\n";} $addsummary .= "\n"; - } + } $uquery = "UPDATE ".db_table_name('users')." SET password='$pass', security='{$_POST['level']}' WHERE user='$user'"; $uresult = $connect->Execute($uquery); - + $addsummary .= "