1313require_once V_ROOT_DIR . 'core/utils/Message.class.php ' ;
1414require_once V_ROOT_DIR . 'core/Request.class.php ' ;
1515require_once V_ROOT_DIR . 'api/AjaxHandler.php ' ;
16+ require_once V_ROOT_DIR . 'api/MAIN.class.php ' ;
1617
1718
1819class ChangePassword
@@ -26,14 +27,14 @@ public function dispatch()
2627
2728 $ key = addslashes (htmlspecialchars ($ _GET ['v ' ]));
2829
29- $ users = Vesta::execute (Vesta::V_LIST_SYS_USERS , 'json ' );
30+ $ cmd = Config::get ('sudo_path ' )." " .Config::get ('vesta_functions_path ' ).Vesta::V_LIST_SYS_USERS ." 'json' " ;
31+ exec ($ cmd , $ output , $ return );
32+
33+ $ users = json_decode (implode ('' , $ output ), true );
34+
3035 $ email_matched_count = array ();
3136
32- /*if (strcmp($real_key, $key_sha1) != 0) {
33- return $this->renderError('Invalid keys');
34- }*/
35-
36- foreach ($ users ['data ' ] as $ username => $ user ) {
37+ foreach ($ users as $ username => $ user ) {
3738 if ($ user ['RKEY ' ] == trim ($ key )) {
3839 $ email_matched_count [] = array_merge (array ('USERNAME ' => $ username ), $ user );
3940 }
@@ -62,22 +63,30 @@ protected function doChangePassword($users)
6263
6364 $ success = true ;
6465 foreach ($ users as $ user ) {
65- $ rs = Vesta::execute (Vesta::V_CHANGE_SYS_USER_PASSWORD , array ('USER ' => $ user ['USERNAME ' ],
66- 'PASSWORD ' => $ _POST ['secret_code ' ]));
67- if (!$ rs ) {
66+ $ cmd = Config::get ('sudo_path ' )." " .Config::get ('vesta_functions_path ' ).Vesta::V_CHANGE_SYS_USER_PASSWORD ." " .$ user ['USERNAME ' ]." " .$ _POST ['secret_code ' ];
67+ exec ($ cmd , $ output , $ return );
68+
69+ if (!$ return ) {
6870 $ success = false ;
6971 }
7072 }
7173
7274 if (!$ success ) {
73- return $ this ->showResetForm ('Something went wrong. Please contact support. ' );
75+ $ main = new MAIN ();
76+ $ about = json_decode ($ main ->aboutExecute (), TRUE );
77+
78+ return $ this ->showResetForm ('Something went wrong. Please contact support: ' .$ about ['data ' ]['company_email ' ]);
7479 }
7580
7681 return $ this ->showSuccessTpl ();
7782 }
7883
7984 public function showSuccessTpl ()
8085 {
86+ $ main = new MAIN ();
87+ $ about = json_decode ($ main ->aboutExecute (), TRUE );
88+ $ current_year = date ("Y " );
89+
8190 print <<<HTML
8291<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
8392 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
@@ -101,7 +110,7 @@ public function showSuccessTpl()
101110 <div class="b-auth-form">
102111 <div class="b-auth-form-wrap">
103112 <img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo">
104- <span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~! </span>
113+ <span style="color: #5E696B; float: right; margin-top: -48px;"> { $ about [ ' data ' ][ ' version_name ' ]} </span>
105114 <div class="b-client-title">
106115 <span class="client-title-wrap">Control Panel<i class="planets"> </i></span>
107116 </div>
@@ -111,10 +120,10 @@ public function showSuccessTpl()
111120 <div class="success-box" id="change-psw-success">Password successfully changed.</div>
112121
113122 </form>
114- <p class="forgot-pwd"> </p>
123+ <p class="forgot-pwd"><a href="/" class="forgot-pwd-url">Back to login?</a> </p>
115124 <div class="footnotes cc">
116- <p class="additional-info">For questions please contact <a href="mailto:info@vestacp.com " class="questions-url">info@vestacp.com </a></p>
117- <address class="imprint">© 2011 Vesta Control Panel</address>
125+ <p class="additional-info">For questions please contact <a href="mailto: { $ about [ ' data ' ][ ' company_email ' ]} " class="questions-url"> { $ about [ ' data ' ][ ' company_email ' ]} </a></p>
126+ <address class="imprint">© { $ current_year } Vesta Control Panel</address>
118127 </div>
119128 </div>
120129 </div>
@@ -129,9 +138,14 @@ public function showSuccessTpl()
129138 public function showResetForm ($ error_msg = '' )
130139 {
131140 if (!empty ($ error_msg )) {
132- $ error_msg = '<i > ' .$ error_msg .'</i > ' ;
141+ $ error_msg = '<div class="error-box" id="auth-error" > ' .$ error_msg .'</div > ' ;
133142 }
134-
143+
144+ $ main = new MAIN ();
145+ $ about = json_decode ($ main ->aboutExecute (), TRUE );
146+
147+ $ current_year = date ("Y " );
148+
135149 print <<<HTML
136150<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
137151 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
@@ -154,13 +168,15 @@ public function showResetForm($error_msg = '')
154168 <div id="change-psw-block" class="page2">
155169 <div class="b-auth-form">
156170 <div class="b-auth-form-wrap">
171+ <a href="/">
157172 <img width="72" height="24" alt="" src="/images/vesta-logo-2011-12-14.png" class="vesta-logo">
158- <span style="color: #5E696B; float: right; margin-top: -48px;">~!:VERSION~!</span>
173+ </a>
174+ <span style="color: #5E696B; float: right; margin-top: -48px;"> {$ about ['data ' ]['version_name ' ]}</span>
159175 <div class="b-client-title">
160176 <span class="client-title-wrap">Control Panel<i class="planets"> </i></span>
161177 </div>
162178 <form id="change_psw-form" method="post" action="" class="auth">
163- <input type="hidden" value="change" name="action">
179+ <input type="hidden" value="change" name="action">
164180
165181 <div class="form-row cc">
166182 <label for="password" class="field-label">New Password</label>
@@ -171,58 +187,24 @@ public function showResetForm($error_msg = '')
171187 <label for="confirm_password" class="field-label">ONE MORE TIME</label>
172188 <input type="password" tabindex="1" id="confirm_password" class="field-text" name="confirm_secret_code">
173189 </div>
174-
190+ { $ error_msg }
175191 <div class="form-row cc last-row">
176192 <input type="submit" tabindex="4" value="Change Password" class="sumbit-btn">
177193 </div>
178194 </form>
179- <p class="forgot-pwd"> </p>
195+
196+ <p class="forgot-pwd"><a href="/" class="forgot-pwd-url">Back to login?</a></p>\
197+
180198 <div class="footnotes cc">
181- <p class="additional-info">For questions please contact <a href="mailto:info@vestacp.com " class="questions-url">info@vestacp.com </a></p>
182- <address class="imprint">© 2011 Vesta Control Panel</address>
199+ <p class="additional-info">For questions please contact <a href="mailto: { $ about [ ' data ' ][ ' company_email ' ]} " class="questions-url"> { $ about [ ' data ' ][ ' company_email ' ]} </a></p>
200+ <address class="imprint">© { $ current_year } Vesta Control Panel</address>
183201 </div>
184202 </div>
185203 </div>
186204 </div>
187205 </body>
188206</html>
189-
190- <!--
191-
192- <center>
193- vesta password reset form
194- <hr />
195- {$ error_msg }
196- <form action="" method="POST">
197- <table>
198- <tr>
199- <td>
200- <input type="hidden" name="action" value="change" />
201- <label>Enter secret code:</label>
202- </td>
203- <td>
204- <input type="password" name="secret_code" value="" />
205- </td>
206- </tr>
207- <tr>
208- <td>
209- <label>Enter new password:</label>
210- </td>
211- <td>
212- <input type="password" name="confirm_secret_code" value="" />
213- </td>
214- </tr>
215- <tr>
216- <td colspan="2">
217- <input type="submit" name="Apply" />
218- </td>
219- </tr>
220- </table>
221- </form>
222- </center> -->
223-
224207HTML ;
225-
226208 }
227209
228210 public function renderError ($ message )
@@ -232,10 +214,9 @@ public function renderError($message)
232214HTML ;
233215
234216 }
235-
236217}
237218
238219$ changePassword = new ChangePassword ();
239220$ changePassword ->dispatch ();
240221
241- ?>
222+ ?>
0 commit comments