From 45ca7d2258832cb0d2465eb16dd646d925458106 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 15 Apr 2019 14:03:52 +0000 Subject: [PATCH] Created ttDebugTracer class to hopefully help to address blank screen issues. --- WEB-INF/config.php.dist | 2 +- WEB-INF/lib/Auth.class.php | 6 ++-- WEB-INF/lib/auth/Auth_ldap.class.php | 24 ++++++------- WEB-INF/lib/ttDebugTracer.class.php | 50 ++++++++++++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- time.php | 11 ++++-- 6 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 WEB-INF/lib/ttDebugTracer.class.php diff --git a/WEB-INF/config.php.dist b/WEB-INF/config.php.dist index b9b292b6..66527ec8 100644 --- a/WEB-INF/config.php.dist +++ b/WEB-INF/config.php.dist @@ -188,7 +188,7 @@ define('AUTH_MODULE', 'db'); // array('Ldap Testers') means that the user must be a member Ldap Testers group. // array('Ldap Testers', 'Ldap Users') means the user must be a member of both Ldap Testers and Ldap Users groups. -// define('AUTH_DEBUG', false); // Note: enabling AUTH_DEBUG breaks redirects as debug output is printed before setting redirect header. Do not enable on production systems. +// define('DEBUG', false); // Note: enabling DEBUG breaks redirects as debug output is printed before setting redirect header. Do not enable on production systems. // Team managers can set monthly work hour quota for years between the following values. diff --git a/WEB-INF/lib/Auth.class.php b/WEB-INF/lib/Auth.class.php index 96ea8692..ecb48340 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('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('DEBUG')) echo 'db error!
'; return false; } $val = $res->fetchRow(); if (!$val['id']) { - if (isTrue('AUTH_DEBUG')) + if (isTrue('DEBUG')) echo 'login "'.$login.'" does not exist in Time Tracker database.
'; return false; } diff --git a/WEB-INF/lib/auth/Auth_ldap.class.php b/WEB-INF/lib/auth/Auth_ldap.class.php index 52d4fabe..5fb3dcf3 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('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('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('DEBUG')) { echo '$login='; var_dump($login); echo '
'; } $lb = @ldap_bind($lc, $login, $password); - if (isTrue('AUTH_DEBUG')) { + if (isTrue('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('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('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('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('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('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('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('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('DEBUG')) { echo '$member_of'; var_dump($member_of); echo '
'; } diff --git a/WEB-INF/lib/ttDebugTracer.class.php b/WEB-INF/lib/ttDebugTracer.class.php new file mode 100644 index 00000000..46469a90 --- /dev/null +++ b/WEB-INF/lib/ttDebugTracer.class.php @@ -0,0 +1,50 @@ +debug = true; + $this->file_name = $file_name; + } + + // prinln - prints a line. + public function println($msg) { + if ($this->debug) { + echo "$this->file_name: $msg
"; + } + } +} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 0372c8dc..a314a181 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.65.4941 | Copyright © Anuko | +  Anuko Time Tracker 1.18.65.4942 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/time.php b/time.php index 7450679b..293c574a 100644 --- a/time.php +++ b/time.php @@ -27,6 +27,7 @@ // +----------------------------------------------------------------------+ require_once('initialize.php'); +import('ttDebugTracer'); import('form.Form'); import('ttConfigHelper'); import('ttUserHelper'); @@ -35,6 +36,10 @@ import('ttClientHelper'); import('ttTimeHelper'); import('DateAndTime'); +// Initialize ttDebugTracer to print diagnostic messages. +$debug = new ttDebugTracer(__FILE__); +$debug->println('page entry after imports'); + // Access checks. if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) { header('Location: access_denied.php'); @@ -55,6 +60,7 @@ if ($request->isPost()) { exit(); } } +$debug->println('after all access checks'); // End of access checks. // Determine user for whom we display this page. @@ -66,6 +72,7 @@ if ($request->isPost() && $userChanged) { } $group_id = $user->getGroup(); +$debug->println("user_id: $user_id group_id: $group_id"); $showClient = $user->isPluginEnabled('cl'); $trackingMode = $user->getTrackingMode(); @@ -429,6 +436,8 @@ if ($request->isPost()) { $week_total = ttTimeHelper::getTimeForWeek($selected_date); $timeRecords = $showFiles? ttTimeHelper::getRecordsWithFiles($user_id, $cl_date) : ttTimeHelper::getRecords($user_id, $cl_date); +$debug->println('smarty assignments'); + $smarty->assign('selected_date', $selected_date); $smarty->assign('week_total', $week_total); $smarty->assign('day_total', ttTimeHelper::getTimeForDay($cl_date)); @@ -440,8 +449,6 @@ $smarty->assign('show_task', $showTask); $smarty->assign('show_start', $showStart); $smarty->assign('show_finish', $showFinish); $smarty->assign('show_duration', $showDuration); - - $smarty->assign('show_note_column', $showNoteColumn); $smarty->assign('show_note_row', $showNoteRow); $smarty->assign('show_files', $showFiles); -- 2.20.1