-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.php
61 lines (50 loc) · 1.89 KB
/
setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/*
* Copyright (c) 2010 Cal Poly Engineering Student Council
*
* Developers:
* Brian Oppenheim <[email protected]>
* Prentice Wongvibulsin <[email protected]>
*
* Project URL:
* http://www.prenticew.com/escan
*
* This file is part of eScan.
*
* eScan 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 3 of the License, or
* (at your option) any later version.
*
* eScan 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 eScan. If not, see <http://www.gnu.org/licenses/>.
*/
// SETUP DATABASE
// arguments: database name, admin username, admin password
// precondition: database name is not used, admin account is valid
// postcondition: database is initialized
function init_database($dbname, $user, $pass){
}
// GENERATE .htaccess/.htpasswd FILES
// arguments: system name, admin, password
// precondition: none
// postcondition: htpasswd file with admin user is created and
// htaccess restricts access to admin folder
function init_htfiles($name, $user, $pass){
$conf = $_SERVER['PHP_SELF'] + "/conf";
exec("rm -f $conf/.htpasswd");
exec("htpasswd -c $conf/.htpasswd $user $pass");
$file = fopen("src/admin/.htaccess", 'w') or die("ERROR: Can not write .htaccess file");
fwrite($file, "AuthUserFile $conf/.htpasswd\n");
fwrite($file, "AuthGroupFile /dev/null\n");
fwrite($file, "AuthName \"$name\"\n");
fwrite($file, "AuthType Basic\n");
fwrite($file, "require valid-user\n");
fclose($file);
}
?>