~josephjamesmills/zpanelcp/zpanelcp

« back to all changes in this revision

Viewing changes to etc/zpanel/modules/password_assistant/code/controller.ext.php

  • Committer: Joseph Mills
  • Date: 2012-05-09 02:52:32 UTC
  • Revision ID: josephjamesmills@gmail.com-20120509025232-ob5xni0ggrse28c0
setup framwork for www

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
/**
4
 
 *
5
 
 * ZPanel - A Cross-Platform Open-Source Web Hosting Control panel.
6
 
 * 
7
 
 * @package ZPanel
8
 
 * @version $Id$
9
 
 * @author Bobby Allen - ballen@zpanelcp.com
10
 
 * @copyright (c) 2008-2011 ZPanel Group - http://www.zpanelcp.com/
11
 
 * @license http://opensource.org/licenses/gpl-3.0.html GNU Public License v3
12
 
 *
13
 
 * This program (ZPanel) is free software: you can redistribute it and/or modify
14
 
 * it under the terms of the GNU General Public License as published by
15
 
 * the Free Software Foundation, either version 3 of the License, or
16
 
 * (at your option) any later version.
17
 
 *
18
 
 * This program is distributed in the hope that it will be useful,
19
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 
 * GNU General Public License for more details.
22
 
 *
23
 
 * You should have received a copy of the GNU General Public License
24
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
 *
26
 
 */
27
 
class module_controller {
28
 
 
29
 
    static $error;
30
 
        static $badpassword;
31
 
 
32
 
    static function doUpdatePassword() {
33
 
        global $zdbh;
34
 
        global $controller;
35
 
 
36
 
        $currentuser = ctrl_users::GetUserDetail();
37
 
 
38
 
        $current_pass = $controller->GetControllerRequest('FORM', 'inCurPass');
39
 
        $newpass = $controller->GetControllerRequest('FORM', 'inNewPass');
40
 
        $conpass = $controller->GetControllerRequest('FORM', 'inConPass');
41
 
 
42
 
        if (fs_director::CheckForEmptyValue($newpass)) {
43
 
            // Current password is blank!
44
 
            self::$error = "error";
45
 
        } elseif (md5($current_pass) <> $currentuser['password']) {
46
 
            // Current password does not match!
47
 
            self::$error = "error";
48
 
        } else {        
49
 
            if ($newpass == $conpass) {
50
 
                        // Check for password length...
51
 
                        if (strlen($newpass) < ctrl_options::GetOption('password_minlength')) {
52
 
                        self::$badpassword = true;
53
 
                        return false;
54
 
                    }
55
 
                // Check that the new password matches the confirmation box.
56
 
                $sql = $zdbh->prepare("UPDATE x_accounts SET ac_pass_vc='" . md5($newpass) . "' WHERE ac_id_pk=" . $currentuser['userid'] . "");
57
 
                $sql->execute();
58
 
                self::$error = "ok";
59
 
            } else {
60
 
                self::$error = "error";
61
 
            }
62
 
        }
63
 
    }
64
 
 
65
 
    static function getResult() {
66
 
        if (!fs_director::CheckForEmptyValue(self::$error)) {
67
 
            if (self::$error == "ok") {
68
 
                return ui_sysmessage::shout(ui_language::translate("Your account password been changed successfully!"), "zannounceok");
69
 
            }
70
 
            if (self::$error == "error") {
71
 
                return ui_sysmessage::shout(ui_language::translate("An error occured and your ZPanel account password could not be updated. Please ensure you entered all passwords correctly and try again."), "zannounceerror");
72
 
            }
73
 
        } else {
74
 
                if (!fs_director::CheckForEmptyValue(self::$badpassword)) {
75
 
                    return ui_sysmessage::shout(ui_language::translate("Your password did not meet the minimun length requirements. Characters needed for password length") .": " . ctrl_options::GetOption('password_minlength'), "zannounceerror");
76
 
                }
77
 
           return;
78
 
        }
79
 
    }
80
 
 
81
 
    static function getModuleName() {
82
 
        $module_name = ui_module::GetModuleName();
83
 
        return $module_name;
84
 
    }
85
 
 
86
 
    static function getModuleIcon() {
87
 
        global $controller;
88
 
        $module_icon = "modules/" . $controller->GetControllerRequest('URL', 'module') . "/assets/icon.png";
89
 
        return $module_icon;
90
 
    }
91
 
 
92
 
    static function UpdatePassword($uid, $password) {
93
 
        global $zdbh;
94
 
        $sql = $zdbh->prepare("UPDATE x_accounts SET ac_pass_vc='" . md5($password) . "' WHERE ac_id_pk=$uid");
95
 
        $sql->execute();
96
 
        return true;
97
 
    }
98
 
 
99
 
        static function getModuleDesc() {
100
 
                $message = ui_language::translate(ui_module::GetModuleDescription());
101
 
        return $message;
102
 
    }
103
 
 
104
 
}
105
 
 
106
 
?>