From: Nik Okuntseff Date: Sat, 19 Jan 2019 10:22:32 +0000 (+0000) Subject: Imporoved isTrue function to get rid of PHP warnings. X-Git-Tag: timetracker_1.19-1~355 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6079edfe4444d2d0bc2f220f8823d6fcc57f2dd5;p=timetracker.git Imporoved isTrue function to get rid of PHP warnings. --- diff --git a/WEB-INF/lib/Auth.class.php b/WEB-INF/lib/Auth.class.php index d57a0c4a..96ea8692 100644 --- a/WEB-INF/lib/Auth.class.php +++ b/WEB-INF/lib/Auth.class.php @@ -64,7 +64,7 @@ class Auth { function doLogin($login, $password) { $auth = $this->authenticate($login, $password); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '
'; var_dump($auth); echo '
'; } @@ -77,13 +77,13 @@ class Auth { $sql = "SELECT id FROM tt_users WHERE login = ".$mdb2->quote($login)." AND status = 1"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) { - if (isTrue(AUTH_DEBUG)) + if (isTrue('AUTH_DEBUG')) echo 'db error!
'; return false; } $val = $res->fetchRow(); if (!$val['id']) { - if (isTrue(AUTH_DEBUG)) + if (isTrue('AUTH_DEBUG')) echo 'login "'.$login.'" does not exist in Time Tracker database.
'; return false; } diff --git a/WEB-INF/lib/auth/Auth_db.class.php b/WEB-INF/lib/auth/Auth_db.class.php index bdde007a..a7ae0d3f 100644 --- a/WEB-INF/lib/auth/Auth_db.class.php +++ b/WEB-INF/lib/auth/Auth_db.class.php @@ -57,7 +57,7 @@ class Auth_db extends Auth { return array('login'=>$login,'id'=>$val['id']); } else { // If the OLD_PASSWORDS option is defined - set it. - if (isTrue(OLD_PASSWORDS)) { + if (isTrue('OLD_PASSWORDS')) { $sql = "SET SESSION old_passwords = 1"; $res = $mdb2->query($sql); if (is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/lib/auth/Auth_ldap.class.php b/WEB-INF/lib/auth/Auth_ldap.class.php index 23ea127e..52d4fabe 100644 --- a/WEB-INF/lib/auth/Auth_ldap.class.php +++ b/WEB-INF/lib/auth/Auth_ldap.class.php @@ -96,7 +96,7 @@ class Auth_ldap extends Auth { $lc = ldap_connect($this->params['server']); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '
'; echo '$lc='; var_dump($lc); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; @@ -106,7 +106,7 @@ class Auth_ldap extends Auth { ldap_set_option($lc, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($lc, LDAP_OPT_REFERRALS, 0); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { ldap_set_option($lc, LDAP_OPT_DEBUG_LEVEL, 7); } @@ -119,13 +119,13 @@ class Auth_ldap extends Auth { $login .= '@' . $this->params['default_domain']; } - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$login='; var_dump($login); echo '
'; } $lb = @ldap_bind($lc, $login, $password); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$lb='; var_dump($lb); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -142,7 +142,7 @@ class Auth_ldap extends Auth { $fields = array('memberof'); $sr = @ldap_search($lc, $this->params['base_dn'], $filter, $fields); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$sr='; var_dump($sr); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -154,7 +154,7 @@ class Auth_ldap extends Auth { $entries = @ldap_get_entries($lc, $sr); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$entries='; var_dump($entries); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -173,7 +173,7 @@ class Auth_ldap extends Auth { $groups[] = substr($grp_fields[0], 3); } - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$member_of'; var_dump($member_of); echo '
'; }; @@ -195,7 +195,7 @@ class Auth_ldap extends Auth { // Assuming OpenLDAP server. $login_oldap = 'uid='.$login.','.$this->params['base_dn']; - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$login_oldap='; var_dump($login_oldap); echo '
'; } @@ -207,7 +207,7 @@ class Auth_ldap extends Auth { $lb = @ldap_bind($lc, $login_oldap, $password); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$lb='; var_dump($lb); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -225,7 +225,7 @@ class Auth_ldap extends Auth { $fields = array('samaccountname', 'mail', 'memberof', 'department', 'displayname', 'telephonenumber', 'primarygroupid'); $sr = @ldap_search($lc, $this->params['base_dn'], $filter, $fields); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$sr='; var_dump($sr); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -238,7 +238,7 @@ class Auth_ldap extends Auth { $entries = @ldap_get_entries($lc, $sr); - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$entries='; var_dump($entries); echo '
'; echo 'ldap_error()='; echo ldap_error($lc); echo '
'; } @@ -258,7 +258,7 @@ class Auth_ldap extends Auth { $groups[] = substr($grp_fields[0], 3); } - if (isTrue(AUTH_DEBUG)) { + if (isTrue('AUTH_DEBUG')) { echo '$member_of'; var_dump($member_of); echo '
'; } diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index f483b3d4..6526d730 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -165,7 +165,7 @@ function check_extension($ext) // isTrue is a helper function to return correct false for older config.php values defined as a string 'false'. function isTrue($val) { - return ($val === true); + return (defined($val) && constant($val) === true); } // ttValidString is used to check user input to validate a string. diff --git a/WEB-INF/lib/mail/Mailer.class.php b/WEB-INF/lib/mail/Mailer.class.php index 68142028..30f0ffb6 100644 --- a/WEB-INF/lib/mail/Mailer.class.php +++ b/WEB-INF/lib/mail/Mailer.class.php @@ -104,8 +104,8 @@ class Mailer { $port = defined('MAIL_SMTP_PORT') ? MAIL_SMTP_PORT : '25'; $username = defined('MAIL_SMTP_USER') ? MAIL_SMTP_USER : null; $password = defined('MAIL_SMTP_PASSWORD') ? MAIL_SMTP_PASSWORD : null; - $auth = isTrue(MAIL_SMTP_AUTH); - $debug = isTrue(MAIL_SMTP_DEBUG); + $auth = isTrue('MAIL_SMTP_AUTH'); + $debug = isTrue('MAIL_SMTP_DEBUG'); $mail = Mail::factory('smtp', array ('host' => $host, 'port' => $port, @@ -116,7 +116,7 @@ class Mailer { break; } - if (isTrue(MAIL_SMTP_DEBUG)) + if (isTrue('MAIL_SMTP_DEBUG')) PEAR::setErrorHandling(PEAR_ERROR_PRINT); $res = $mail->send($recipients, $headers, $data); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index d49ca6d7..013c87a7 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.36.4706 | Copyright © Anuko | +  Anuko Time Tracker 1.18.36.4707 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/login.php b/login.php index e7254152..68a80678 100644 --- a/login.php +++ b/login.php @@ -75,7 +75,7 @@ if ($request->isPost()) { } } // isPost -if(!isTrue(MULTITEAM_MODE) && !ttOrgHelper::getOrgs()) +if(!isTrue('MULTITEAM_MODE') && !ttOrgHelper::getOrgs()) $err->add($i18n->get('error.no_groups')); // Determine whether to show login hint. It is currently used only for Windows LDAP authentication. diff --git a/mobile/login.php b/mobile/login.php index 59fc6000..26b75db4 100644 --- a/mobile/login.php +++ b/mobile/login.php @@ -80,7 +80,7 @@ if ($request->isPost()) { } } // isPost -if(!isTrue(MULTITEAM_MODE) && !ttOrgHelper::getOrgs()) +if(!isTrue('MULTITEAM_MODE') && !ttOrgHelper::getOrgs()) $err->add($i18n->get('error.no_groups')); // Determine whether to show login hint. It is currently used only for Windows LDAP authentication. diff --git a/register.php b/register.php index 0a8e6d15..4c923c73 100644 --- a/register.php +++ b/register.php @@ -29,7 +29,7 @@ require_once('initialize.php'); import('form.Form'); -if (!isTrue(MULTITEAM_MODE) || $auth->isPasswordExternal()) { +if (!isTrue('MULTITEAM_MODE') || $auth->isPasswordExternal()) { header('Location: login.php'); exit(); } diff --git a/tofile.php b/tofile.php index 990b8a55..3934471d 100644 --- a/tofile.php +++ b/tofile.php @@ -94,7 +94,7 @@ if ('xml' == $type) { print "\t<".$group_by_tag.">\n"; if ($bean->getAttribute('chduration')) { $val = $subtotal['time']; - if($val && isTrue(EXPORT_DECIMAL_DURATION)) + if($val && isTrue('EXPORT_DECIMAL_DURATION')) $val = time_to_decimal($val); print "\t\n"; } @@ -126,7 +126,7 @@ if ('xml' == $type) { if ($bean->getAttribute('chfinish')) print "\t\n"; if ($bean->getAttribute('chduration')) { $duration = $item['duration']; - if($duration && isTrue(EXPORT_DECIMAL_DURATION)) + if($duration && isTrue('EXPORT_DECIMAL_DURATION')) $duration = time_to_decimal($duration); print "\t\n"; } @@ -179,7 +179,7 @@ if ('csv' == $type) { print '"'.$subtotal['name'].'"'; if ($bean->getAttribute('chduration')) { $val = $subtotal['time']; - if($val && isTrue(EXPORT_DECIMAL_DURATION)) + if($val && isTrue('EXPORT_DECIMAL_DURATION')) $val = time_to_decimal($val); print ',"'.$val.'"'; } @@ -223,7 +223,7 @@ if ('csv' == $type) { if ($bean->getAttribute('chfinish')) print ',"'.$item['finish'].'"'; if ($bean->getAttribute('chduration')) { $val = $item['duration']; - if($val && isTrue(EXPORT_DECIMAL_DURATION)) + if($val && isTrue('EXPORT_DECIMAL_DURATION')) $val = time_to_decimal($val); print ',"'.$val.'"'; }