-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.php
123 lines (107 loc) · 3.06 KB
/
install.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/*
CREATE TABLE IF NOT EXISTS `stats` (
`CommonName` text NOT NULL,
`RealAddress` text NOT NULL,
`BytesReceived` text NOT NULL,
`BytesSent` text NOT NULL,
`Since` text NOT NULL,
`VirtualAddress` text NOT NULL,
`LastRef` text NOT NULL,
`updated` bigint(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
* * * * * cd [cron location]; php cron.php
*/
require 'config/mysql.php';
require 'config/openvpn.php';
require 'functions/functions.php';
function install()
{
$conn = mysql_connect(get_mysql_host(), get_mysql_user(), get_mysql_pass());
if(!$conn)
{
logMsg('Could not connect to the MySQL Server. Please validate your login & connection information:');
logMsg(' host: ' . get_mysql_host());
logMsg(' user: ' . get_mysql_user());
logMsg(' ' . mysql_error());
return;
}
$selectDb = mysql_select_db(get_mysql_db());
if(!$selectDb)
{
logMsg('Could not select the MySQL Database. Please validate the login information and permissions on the database.');
logMsg(' db: ' + get_mysql_db());
logMsg(' ' . mysql_error());
return;
}
$sql = 'CREATE TABLE IF NOT EXISTS `stats` (
`CommonName` text NOT NULL,
`RealAddress` text NOT NULL,
`BytesReceived` text NOT NULL,
`BytesSent` text NOT NULL,
`Since` text NOT NULL,
`VirtualAddress` text NOT NULL,
`LastRef` text NOT NULL,
`updated` bigint(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;';
$result = mysql_query($sql);
if(!$result)
{
logMsg("Could not create table: ". mysql_error());
return;
}
$tmpFile = '/tmp/crontab.txt';
$output = shell_exec('crontab -l');
file_put_contents($tmpFile, $output);
$newCron = '* * * * * cd ' . dirname(__FILE__) . '; php ' . dirname(__FILE__) . '/openvpn-cron.php';
if( strpos($output,$newCron) !== false)
{
//Do nothing
}
else
{
file_put_contents($tmpFile, $output.$newCron.PHP_EOL);
echo exec('crontab '.$tmpFile);
}
$errors = 0;
//Validate that the time zone settings are correct
if(date_default_timezone_get()!=ini_get('date.timezone'))
{
$errors += 1;
echo "ensure that the 'date.timezone' value in the php.ini has been set correctly".PHP_EOL;
}
echo'
<section class="content-header">
<h1>Install</h1>
<ol class="breadcrumb">
<li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
<li>Admin</li>
<li class="active">Install</li>
</ol>
</section>
<br/>
<div class="box">
<center>
';
if($errors==0)
{
echo ' <h1>Install Succeeded</h1>';
}
else
{
echo ' Install had some warnings';
}
echo '
</center>
<br/>
</div>
';
}
require 'include/page_vars.php';
$page_install = TRUE;
require 'include/page_start.php';
require 'include/page_end.php';
echo $page_start;
install();
echo $page_end;
?>