From: Stricted Date: Mon, 4 May 2015 19:25:49 +0000 (+0200) Subject: add comments to user class X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2c424371b44b882c4b8cf3fc495eadaa007fe80d;p=GitHub%2FStricted%2FDomain-Control-Panel.git add comments to user class --- diff --git a/lang/de.lang.php b/lang/de.lang.php index 1da2725..0c13536 100644 --- a/lang/de.lang.php +++ b/lang/de.lang.php @@ -20,4 +20,4 @@ $lang['button.delete'] = 'Löschen'; $lang['button.enable'] = 'Aktivieren'; $lang['button.disable'] = 'Deaktivieren'; $lang['domain.disabled'] = 'Deaktiviert'; -$lang['footer.copyright'] = 'Domain Control Panel 3.0.0, entwickelt von stricted.net'; +$lang['footer.copyright'] = 'Domain Control Panel {$smarty.const.DNS_VERSION}, entwickelt von stricted.net'; diff --git a/lang/en.lang.php b/lang/en.lang.php index 21b696e..2d813b7 100644 --- a/lang/en.lang.php +++ b/lang/en.lang.php @@ -20,4 +20,4 @@ $lang['button.delete'] = 'Delete'; $lang['button.enable'] = 'Enable'; $lang['button.disable'] = 'Disable'; $lang['domain.disabled'] = 'Disabled'; -$lang['footer.copyright'] = 'Domain Control Panel 3.0.0, developed by stricted.net'; +$lang['footer.copyright'] = 'Domain Control Panel {$smarty.const.DNS_VERSION}, developed by stricted.net'; diff --git a/lib/system/DNS.class.php b/lib/system/DNS.class.php index 66b9f52..e005242 100644 --- a/lib/system/DNS.class.php +++ b/lib/system/DNS.class.php @@ -1,6 +1,8 @@ @@ -190,8 +192,6 @@ class DNS { self::getTPL()->setTemplateDir(DNS_DIR."/templates/".$tpl); self::getTPL()->setCompileDir(DNS_DIR."/templates/compiled/".$tpl); - /*self::getTPL()->setTemplateDir(DNS_DIR."/templates");*/ - /*self::getTPL()->setCompileDir(DNS_DIR."/templates/compiled");*/ self::getTPL()->setPluginsDir(DNS_DIR."/lib/api/smarty/plugins"); self::getTPL()->loadFilter('pre', 'hascontent'); @@ -199,11 +199,6 @@ class DNS { self::getTPL()->loadFilter('output', 'trimwhitespace'); } - /* - self::getTPL()->loadFilter('pre', 'url'); - self::getTPL()->loadFilter('output', 'url'); - */ - /* assign language variables */ self::getTPL()->assign(array( "language" => $this->language, diff --git a/lib/system/User.class.php b/lib/system/User.class.php index 33eba57..baa0d18 100644 --- a/lib/system/User.class.php +++ b/lib/system/User.class.php @@ -24,6 +24,11 @@ class User { return false; } + /** + * check if user is an Admin + * + * @return boolean + */ public static function isAdmin () { if (DNS::getSession()->status !== null && DNS::getSession()->status == 2) { return true; @@ -32,6 +37,11 @@ class User { return false; } + /** + * check if user is an Reseller + * + * @return boolean + */ public static function isReseller () { if (self::isAdmin() === true) { return true; @@ -44,6 +54,13 @@ class User { return false; } + /** + * check if user has an login cookie + * + * @param integer $userID + * @param string $hash + * @return boolean + */ public static function cookieLogin ($userID, $hash) { $query = DNS::getDB()->query("SELECT * FROM dns_user WHERE SHA1(userID) = ?", array($userID)); $row = DNS::getDB()->fetch_array($query); @@ -64,6 +81,14 @@ class User { return false; } + /** + * login the user + * + * @param string $username + * @param string $password + * @param boolean $remember + * @return boolean + */ public static function login ($username, $password, $remember = false) { $query = DNS::getDB()->query("SELECT * FROM dns_user WHERE username = ?", array($username)); $row = DNS::getDB()->fetch_array($query); @@ -90,6 +115,9 @@ class User { return false; } + /** + * log the user out + */ public static function logout () { if (isset($_COOKIE["userID"])) { setcookie("userID", '', time() - 3600); @@ -103,6 +131,17 @@ class User { session_destroy(); } + /** + * create a new user + * + * @param string $username + * @param string $email + * @param string $password + * @param string $password2 + * @param integer $reseller + * @param integer $status + * @return boolean + */ public static function createUser ($username, $email, $password, $password2, $reseller = 0, $status = 0) { $res = DNS::getDB()->query("SELECT * FROM dns_user WHERE username = ?", array($username)); $row = DNS::getDB()->fetch_array($res); @@ -118,10 +157,24 @@ class User { return false; } + /** + * delete specific user + * + * @param integer $userID + */ public static function deleteUser ($userID) { DNS::getDB()->query("DELETE FROM dns_user WHERE userID = ?", array($userID)); } + /** + * change user password + * + * @param integer $userID + * @param string $oldpassword + * @param string $newpassword + * @param string $newpassword2 + * @return boolean + */ public static function change_password ($userID, $oldpassword, $newpassword, $newpassword2) { $res = DNS::getDB()->query("SELECT * FROM dns_user WHERE userID = ?", array($userID)); $row = DNS::getDB()->fetch_array($res); @@ -139,6 +192,11 @@ class User { return false; } + /** + * generate new password salt + * + * @return string + */ public static function generateSalt() { $blowfishCharacters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./'; $maxIndex = strlen($blowfishCharacters) - 1; @@ -152,6 +210,12 @@ class User { return '$2a$08$' . $salt; } + /** + * get accessible domains for given user + * + * @param integer $userID + * @return array + */ public static function getAccessibleDomains ($userID = 0) { $data = array();