-
Notifications
You must be signed in to change notification settings - Fork 430
/
success.php
262 lines (230 loc) · 11.2 KB
/
success.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/*********************************************************************************
* This file is part of Sentrifugo.
* Copyright (C) 2014 Sapplica
*
* Sentrifugo 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.
*
* Sentrifugo 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 Sentrifugo. If not, see <http://www.gnu.org/licenses/>.
*
* Sentrifugo Support <[email protected]>
********************************************************************************/
$filepath = 'install';
require_once 'public/db_constants.php';
require_once 'public/constants.php';
require_once 'public/application_constants.php';
require_once 'public/mail_settings_constants.php';
if(file_exists($filepath))
require 'install/PHPMailer/PHPMailerAutoload.php';
else
require 'application/modules/default/library/PHPMailer/PHPMailerAutoload.php';
?>
<?php
if(!empty($_POST))
{
$msgarray = array();
if(isset($_POST['btnfinish']) && isset($_POST['mailcontent']))
{
try
{
$mysqlPDO = new PDO('mysql:host='.SENTRIFUGO_HOST.';dbname='.SENTRIFUGO_DBNAME.'',SENTRIFUGO_USERNAME, SENTRIFUGO_PASSWORD,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
if (!$mysqlPDO)
{
$msgarray['error'] = 'Could not connect to specified database' ;
}
else
{
$generatedPswd = uniqid();
$encodedPswd = md5($generatedPswd);
$query = "update main_users set emppassword = '".$encodedPswd."' where emailaddress = '".SUPERADMIN_EMAIL."' and id= 1 ";
$mysqlPDO->query($query);
$mail = sendconfirmationmail($_POST['mailcontent'],$generatedPswd);
$renamefolder = renamefolder();
if($mail != 'true')
{
if($renamefolder == 'true')
{
$msgarray['error'] = "<div>Problem encountered while sending mail to ".SUPERADMIN_EMAIL."</div><br/>
<div>Login Credentials for ".APPLICATION_NAME."</div><br/>
<div style='color: rgb(105, 145, 61); font-weight: 400; margin-bottom: 14px; margin-top: 8px;'>Username : empp0001</div>
<div style='color: rgb(105, 145, 61); font-weight: 400;'>Password : ".$generatedPswd."</div><br/><br/>
<div style='margin-bottom: 20px;'>Follow this <a style='color: rgb(172, 88, 26); text-decoration: none;' href=".BASE_URL.">link</a> to open application.</div>";
}
else
{
$msgarray['error'] = "<div>Problem encountered while sending mail to ".SUPERADMIN_EMAIL."</div><br/>
<div>Login Credentials for ".APPLICATION_NAME."</div><br/>
<div style='color: rgb(105, 145, 61); font-weight: 400; margin-bottom: 14px; margin-top: 8px;'>Username : empp0001</div>
<div style='color: rgb(105, 145, 61); font-weight: 400;'>Password : ".$generatedPswd."</div><br/><br/>
<div style='margin-bottom: 20px;'>After you delete, move or rename the install directory follow this <a style='color: rgb(172, 88, 26); text-decoration: none;' href=".BASE_URL.">link</a> to access your application. While the install directory exists, only the Install Panel will be accessible.</div>";
}
}else
{
if($renamefolder == 'true')
{
$msgarray['error'] = "<div class='sucss_mess_info'>Mail has been succesfully sent to ".SUPERADMIN_EMAIL."</div><br/>
<div>Login Credentials for ".APPLICATION_NAME."</div><br/>
<div style='color: rgb(105, 145, 61); font-weight: 400; margin-bottom: 14px; margin-top: 8px;'>Username : empp0001</div>
<div style='color: rgb(105, 145, 61); font-weight: 400;'>Password : ".$generatedPswd."</div><br/><br/>
<div style='margin-bottom: 20px;'>Follow this <a style='color: rgb(172, 88, 26); text-decoration: none;' href=".BASE_URL.">link</a> to open application.</div>";
}else
{
$msgarray['error'] = "<div>Mail has been succesfully sent to ".SUPERADMIN_EMAIL."</div><br/>
<div>Login Credentials for ".APPLICATION_NAME."</div><br/>
<div style='color: rgb(105, 145, 61); font-weight: 400; margin-bottom: 14px; margin-top: 8px;'>Username : empp0001</div>
<div style='color: rgb(105, 145, 61); font-weight: 400;'>Password : ".$generatedPswd."</div><br/><br/>
<div style='margin-bottom: 20px;'>After you delete, move or rename the install directory follow this <a style='color: rgb(172, 88, 26); text-decoration: none;' href=".BASE_URL.">link</a> to access your application. While the install directory exists, only the Install Panel will be accessible.</div>";
}
}
}
}
catch (PDOException $e)
{
$msgarray['error'] = $e->getMessage();
}
}
}
function sendconfirmationmail($content,$encodedPswd)
{
$htmlcontentdata = '<div style="width:100%;">
<div style="background-color:#eeeeee; width:80%; margin:0 auto; position:relative;">
<div><img src="public/media/images/sentrifugo-email_wizard.png" height="62" width="319" /></div>
<div style="padding:20px 20px 50px 20px;">
<div style="font-family:Arial, Helvetica, sans-serif; font-size:16px; font-weight:normal; line-height:30px; margin:0 0 20px 0;">
<div>
<div>Dear Super Admin,</div><br/>
<div>Sentrifugo has been successfully installed. Following are the Super Admin login credentials for '.APPLICATION_NAME.':</div><br/>
<div>Username : empp0001</div>
<div>Password : '.$encodedPswd.'</div><br/><br/>
<div>'.$content.'</div>
</div>
</div>
<div style="font-family:Arial, Helvetica, sans-serif; font-size:16px; font-weight:normal; line-height:30px;">
Regards,<br />
<b>Sentrifugo</b>
</div>
</div>
</div>
</div>';
$username = '';
$mail = new PHPMailer(); // create a new object
$mail->isSMTP(); // enable SMTP
$mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = (MAIL_AUTH=='true')?true:false;//$auth; // authentication enabled
if(MAIL_TLS) $mail->SMTPSecure = MAIL_TLS; // secure transfer enabled REQUIRED for GMail
// $mail->AuthType = MAIL_AUTH;
$mail->Host = MAIL_SMTP;
if(MAIL_AUTH == 'true'){
$mail->Username = MAIL_USERNAME;
$mail->Password = MAIL_PASSWORD;
}
$mail->Port = MAIL_PORT; // or 587
$mail->SMTPOptions = array('ssl' => array('verify_peer' => false,'verify_peer_name' => false,'allow_self_signed' => true));
$pos = strpos(MAIL_USERNAME, 'yahoo');
if($pos !== false)
$mail->setFrom(MAIL_USERNAME,'Do not Reply');
else
$mail->setFrom(SUPERADMIN_EMAIL,'Do not Reply');
$mail->Subject = APPLICATION_NAME." - successfully installed";
$mail->msgHTML($htmlcontentdata);
$mail->addAddress(SUPERADMIN_EMAIL,'Super Admin');
if(!$mail->Send())
return $mail->ErrorInfo;
else
return 'true';
}
function renamefolder()
{
try
{
if(is_writable("install"))
{
if(@rename("install","install_old"))
return "true";
else
return "false";
}
else
{
return "false";
}
}
catch (Exception $e)
{
return "false";
}
}
if(!empty($_POST))
{
if(isset($_POST['mailcontent']))
$content = urlencode($_POST['mailcontent']);
else
$content = 'Installation succesful';
$dbhost = $_POST['dbhost'];
$dbusername = $_POST['dbusername'];
$dbpassword = $_POST['dbpassword'];
$dbname = $_POST['dbname'];
$appname = $_POST['appname'];
$appemail = $_POST['appemail'];
$mailusername = $_POST['mailusername'];
$mailpassword = $_POST['mailpassword'];
$mailsmtp = $_POST['mailsmtp'];
$mailauth = $_POST['mailauth'];
$mailtls = $_POST['mailtls'];
$mailport = $_POST['mailport'];
$cronjoburl = $_POST['cronjoburl'];
$expirydocurl = $_POST['expirydocurl'];
$tmcronurl = $_POST['tmcronurl'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sentrifugo</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="shortcut icon" href="public/media/images/favicon.ico" />
<link href="public/media/css/successstyle.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,300,300italic,100italic,100,700italic,900,900italic' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="container">
<div class="header"> <div class="logo"></div></div>
<div class="content_wrapper">
<div id="successmsgdiv"><?php echo isset($msgarray['error'])?$msgarray['error']:'';?></div>
<form name="generatereport" id="generatereport" action="data/generatereport.php" method="post">
<input type="hidden" id="pdfcontent" name="pdfcontent" value="<?php echo $content;?>" />
<input type="hidden" id="loginusername" name="loginusername" value="empp0001" />
<input type="hidden" id="loginpwd" name="loginpwd" value="<?php echo $generatedPswd;?>" />
<input type="hidden" id="dbhost" name="dbhost" value="<?php echo $dbhost;?>" />
<input type="hidden" id="dbusername" name="dbusername" value="<?php echo $dbusername;?>" />
<input type="hidden" id="dbpassword" name="dbpassword" value="<?php echo $dbpassword;?>" />
<input type="hidden" id="dbname" name="dbname" value="<?php echo $dbname;?>" />
<input type="hidden" id="appname" name="appname" value="<?php echo $appname;?>" />
<input type="hidden" id="appemail" name="appemail" value="<?php echo $appemail;?>" />
<input type="hidden" id="mailusername" name="mailusername" value="<?php echo $mailusername;?>" />
<input type="hidden" id="mailpassword" name="mailpassword" value="<?php echo $mailpassword;?>" />
<input type="hidden" id="mailsmtp" name="mailsmtp" value="<?php echo $mailsmtp;?>" />
<input type="hidden" id="mailauth" name="mailauth" value="<?php echo $mailauth;?>" />
<input type="hidden" id="mailtls" name="mailtls" value="<?php echo $mailtls;?>" />
<input type="hidden" id="mailport" name="mailport" value="<?php echo $mailport;?>" />
<input type="hidden" id="cronjoburl" name="cronjoburl" value="<?php echo $cronjoburl;?>" />
<input type="hidden" id="expirydocurl" name="expirydocurl" value="<?php echo $expirydocurl;?>" />
<input type="hidden" id="tmcronurl" name="tmcronurl" value="<?php echo $tmcronurl;?>" />
<input type="submit" name="btnfinish" id="idbtnfinish" value="Download PDF" />
</form>
</div>
</div>
</body>
</html>
<?php } else {
header("Location: index.php");
}?>