Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timetracker upgrades #147

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d501da7
Update fr.lang
Ben0it-T Oct 6, 2024
8e491b7
Fix navigation to Puncher
Ben0it-T Oct 6, 2024
7a2bc48
Update database structure
Ben0it-T Oct 6, 2024
8ae09e4
Add ttSession class
Ben0it-T Oct 6, 2024
dea5335
Add session handler stuff
Ben0it-T Oct 6, 2024
3f454ff
Fix custom_logo
Ben0it-T Oct 6, 2024
b90a9a9
Merge branch 'fix-navigation-to-puncher'
Ben0it-T Oct 8, 2024
7018d66
Merge branch 'fix-custom_logo-if-file-not-exists'
Ben0it-T Oct 8, 2024
65a4bb7
Merge branch 'feature-store-sessions-in-db'
Ben0it-T Oct 8, 2024
86797d7
Fix setRowBackground not defined
Ben0it-T Oct 8, 2024
c818aa6
Merge branch 'fix-setRowBackground-is-not-defined'
Ben0it-T Oct 8, 2024
0288f09
Fix calendar.gif not found
Ben0it-T Oct 8, 2024
64be0ef
Merge branch 'fix-calendar.gif-not-found'
Ben0it-T Oct 8, 2024
42ac5b5
Update htaccess
Ben0it-T Oct 8, 2024
e77e740
Merge branch 'update-htaccess'
Ben0it-T Oct 8, 2024
1bff9a2
Feature add notes to puncher
Ben0it-T Oct 10, 2024
2f831f6
fix puncher get values when uncompletedToday
Ben0it-T Oct 10, 2024
c6928cb
fix-line-breaks-in-comments
Ben0it-T Oct 10, 2024
c707867
fix-line-breaks-in-comments-2
Ben0it-T Oct 11, 2024
cc7e591
fix-line-breaks-in-comments-3
Ben0it-T Oct 11, 2024
060af9a
Fix reports fillDropdowns
Ben0it-T Oct 11, 2024
774ccc2
Fix group_edit handlePluginCheckboxes is not defined
Ben0it-T Oct 11, 2024
d60e20b
Fix reports incorrect use of label
Ben0it-T Oct 11, 2024
057ab8e
Update database structure
Ben0it-T Oct 12, 2024
297863b
Add option to set hash algorithm
Ben0it-T Oct 12, 2024
6cac07c
Add password hash stuff
Ben0it-T Oct 12, 2024
17f0fd1
Add option to set hash options
Ben0it-T Oct 12, 2024
bfda5b7
Update fr.lang
Ben0it-T Oct 12, 2024
b780ed9
Upgrade smarty 4.5.1
Ben0it-T Oct 13, 2024
5e120e1
Update Smarty initialization
Ben0it-T Oct 13, 2024
51bde4c
Upgrade smarty 4.5.4
Ben0it-T Oct 13, 2024
67dd3d2
Fix smarty unregistered functions in templates
Ben0it-T Oct 14, 2024
09df675
Fix smarty unregistered static method in templates
Ben0it-T Oct 15, 2024
90f9bcd
Upgrade pear to 1.10.15
Ben0it-T Oct 15, 2024
ea66e86
Upgrade MDB2 to 2.5.0b5
Ben0it-T Oct 15, 2024
d1144b3
Upgrade net-smtp to 1.12.1
Ben0it-T Oct 15, 2024
5c53775
Upgrade net-socket to-1.2.2
Ben0it-T Oct 15, 2024
2656c4e
Upgrade mail to 2.0.0
Ben0it-T Oct 15, 2024
6c3798b
Restore MDB2 to 2.5.0b5 modified version
Ben0it-T Oct 15, 2024
6ec1645
Fix smarty unregistered function file_exists in report tpl
Ben0it-T Oct 15, 2024
6abfc67
Update MDB2_Driver_mysqli - PHP Deprecated
Ben0it-T Oct 15, 2024
036981b
Add PEAR packages version (readme)
Ben0it-T Oct 15, 2024
339ac92
Update MDB2 mktime
Ben0it-T Oct 16, 2024
e87639d
Update PEAR packages version (readme)
Ben0it-T Oct 17, 2024
af764fa
Fix some PHP deprecated warnings
Ben0it-T Oct 18, 2024
ea35243
Fix time edit issue
Ben0it-T Oct 19, 2024
01debf9
Fix expenses, report, time, week issues
Ben0it-T Oct 19, 2024
e5ad33f
Fix exports issue
Ben0it-T Oct 19, 2024
e2880ff
Fix behalfUser
Ben0it-T Oct 19, 2024
1dedf90
Fix time issue
Ben0it-T Oct 19, 2024
879abbd
Fix time (paid issue)
Ben0it-T Oct 19, 2024
5cd03e8
Update .htaccess
Ben0it-T Oct 19, 2024
ef39860
Fix creation of dynamic properties is deprecated
Ben0it-T Oct 19, 2024
7ea3739
Fix imagefilledpolygon
Ben0it-T Oct 19, 2024
46d8d05
Fix implicit conversion from float to int
Ben0it-T Oct 19, 2024
d543de1
Fix timesheet issue
Ben0it-T Oct 19, 2024
bc0a8a0
Fix timesheet delete js issue
Ben0it-T Oct 19, 2024
ea8b0b1
Fix locking
Ben0it-T Oct 19, 2024
d6e62d1
Fix puncher (paid issue)
Ben0it-T Oct 20, 2024
8b7fa51
Update FormElement. Add minlength attribute
Ben0it-T Oct 20, 2024
dd09ef6
Update FormElement
Ben0it-T Oct 20, 2024
457b28a
Add login minlength
Ben0it-T Oct 20, 2024
d4e8f5d
Add login maxlength
Ben0it-T Oct 20, 2024
2820e5c
Add passwd minlength
Ben0it-T Oct 20, 2024
4afe517
Use mb_strlen instead of strlen
Ben0it-T Oct 20, 2024
eefe47a
Update passwd maxlength
Ben0it-T Oct 20, 2024
e5311d6
Fix site_map undefined array key issue
Ben0it-T Oct 20, 2024
8b40da3
Updade project & task maxlength
Ben0it-T Oct 20, 2024
ada6cad
Fix update user issue
Ben0it-T Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# General
.DS_Store
._*
_*
*~
*.sublime-project
*.sublime-workspace
.idea/
.vscode/
Thumbs.db
nbproject/

# Config
config.php

# WEB-INF
WEB-INF/cache/
WEB-INF/templates_c/*.*
WEB-INF/templates_c/import_*
WEB-INF/templates_c/tt*
WEB-INF/lib/tcpdf/
nbproject/
upload/
.vscode/
Thumbs.db
*.DS_Store
*~
.idea/
api/
api/
1 change: 1 addition & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Options -Indexes
AddDefaultCharset utf-8

# Restrict access to Time Tracker only from certain IPs.
Expand Down
4 changes: 2 additions & 2 deletions 2fa.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
$cl_auth_code = $request->getParameter('auth_code');

$form = new Form('twoFactorAuthForm');
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'login','value'=>$cl_login));
$form->addInput(array('type'=>'text','maxlength'=>'80','name'=>'login','value'=>$cl_login));
$form->getElement('login')->setEnabled(false);
$form->addInput(array('type'=>'password','maxlength'=>'50','name'=>'password','value'=>$cl_password));
$form->addInput(array('type'=>'password','maxlength'=>'128','name'=>'password','value'=>$cl_password));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'auth_code','value'=>$cl_auth_code));
$form->addInput(array('type'=>'submit','name'=>'btn_login','value'=>$i18n->get('button.login')));

Expand Down
4 changes: 4 additions & 0 deletions WEB-INF/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Files ~ "\.(jpg|jpeg|png|gif)$">
order deny,allow
allow from all
</Files>
Empty file added WEB-INF/cache/keepme
Empty file.
27 changes: 27 additions & 0 deletions WEB-INF/config.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ define('WEEKEND_START_DAY', 6);
// define('PHP_SESSION_PATH', '/tmp/timetracker'); // Directory must exist and be writable.


// SESSION_HANDLER
// Set session storage.
// 'file' : file stroage. Default value
// 'db' : db stroage
define('SESSION_HANDLER', 'file');


// LOGIN_COOKIE_NAME
//
// Cookie name for user login to remember it between browser sessions.
Expand Down Expand Up @@ -132,6 +139,26 @@ define('REPORT_FOOTER', true);
// ldap - authentication against an LDAP directory such as OpenLDAP or Windows Active Directory.
define('AUTH_MODULE', 'db');

// Password hash algorithm
// Possible values
// - DEFAULT ; bcrypt algorithm
// - BCRYPT : crypt blowfish algorithm
// - ARGON2I : Argon2i hashing algorithm (only available if PHP has been compiled with Argon2 support)
// - ARGON2ID : Argon2id hashing algorithm (only available if PHP has been compiled with Argon2 support)
define('AUTH_DB_HASH_ALGORITHM', 'BCRYPT');

// Password hash options
//
define('AUTH_DB_HASH_ALGORITHM_OPTIONS', array('cost' => 10));

// Login minlength
//
//define('AUTH_DB_LOGIN_MINLENGTH', 5);

// Password minlength
//
//define('AUTH_DB_PWD_MINLENGTH', 12);

// LDAP authentication examples.
// Go to https://www.anuko.com/time-tracker/install-guide/ldap-auth/index.htm for detailed configuration instructions.

Expand Down
Empty file added WEB-INF/configs/keepme
Empty file.
10 changes: 6 additions & 4 deletions WEB-INF/lib/Auth.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ class Auth {
// isAuthenticated - checks authentication status for user.
function isAuthenticated() {
if (isset($_SESSION['authenticated'])) {
// This check does not work properly because we are not getting here. Need to improve.
// if (!isset($_COOKIE[LOGIN_COOKIE_NAME])) {
// die ("Your browser's cookie functionality is turned off. Please turn it on.");
// }
// This check does not work properly because we are not getting here. Need to improve.
// if (!isset($_COOKIE[LOGIN_COOKIE_NAME])) {
// die ("Your browser's cookie functionality is turned off. Please turn it on.");
// }

global $smarty;
$smarty->assign('authenticated', true); // Used in header.tpl for menu display.
return true;
}
session_write_close();
global $smarty;
$smarty->assign('authenticated', false); // Used in header.tpl for menu display.
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion WEB-INF/lib/I18n.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function get($key) {
}
eval("\$value = \$this->keys".$str.";");
} else {
$value = $this->keys[$key];
$value = isset($this->keys[$key]) ? $this->keys[$key] : '';
}
return $value;
}
Expand Down
37 changes: 35 additions & 2 deletions WEB-INF/lib/auth/Auth_db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,41 @@ function authenticate($login, $password)
{
$mdb2 = getConnection();

if (AUTH_DB_HASH_ALGORITHM !== '') {
$sql = "SELECT id, password as hash FROM tt_users"." WHERE login = ".$mdb2->quote($login)." AND status = 1";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) {
die($res->getMessage());
}
$val = $res->fetchRow();
if (isset($val['id']) && $val['id'] > 0) {
if (password_verify($password, $val['hash'])) {
if (password_needs_rehash($val['hash'], PASSWORD_ALGORITHM, AUTH_DB_HASH_ALGORITHM_OPTIONS)) {
$sql = "update `tt_users` set `password` = '".password_hash($password, PASSWORD_ALGORITHM, AUTH_DB_HASH_ALGORITHM_OPTIONS)."' where `id` = " . $mdb2->quote($val['id']);
$affected = $mdb2->exec($sql);
if (is_a($res, 'PEAR_Error')) die($res->getMessage());
}
return array('login'=>$login,'id'=>$val['id']);
}
}
}
else {
// md5 hash
$sql = "SELECT id FROM tt_users"." WHERE login = ".$mdb2->quote($login)." AND password = md5(".$mdb2->quote($password).") AND status = 1";
$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) {
die($res->getMessage());
}
$val = $res->fetchRow();
if (isset($val['id']) && $val['id'] > 0) {
return array('login'=>$login,'id'=>$val['id']);
}
}
return false;

/*
// Try md5 password match first.
$sql = "SELECT id FROM tt_users".
" WHERE login = ".$mdb2->quote($login)." AND password = md5(".$mdb2->quote($password).") AND status = 1";
$sql = "SELECT id FROM tt_users"." WHERE login = ".$mdb2->quote($login)." AND password = md5(".$mdb2->quote($password).") AND status = 1";

$res = $mdb2->query($sql);
if (is_a($res, 'PEAR_Error')) {
Expand Down Expand Up @@ -74,6 +106,7 @@ function authenticate($login, $password)
}

return false;
*/
}

function isPasswordExternal() {
Expand Down
27 changes: 14 additions & 13 deletions WEB-INF/lib/common.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function ttValidString($val, $emptyValid = false, $maxChars = 0)
// ttValidCss is used to check user input for custom css.
function ttValidCss($val)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return true;

Expand All @@ -169,7 +169,7 @@ function ttValidCss($val)
// ttValidTranslation is used to check user input for custom translation.
function ttValidTranslation($val)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return true;

Expand All @@ -186,7 +186,7 @@ function ttValidTranslation($val)
// ttValidTranslationLine is used to check an individual line in custom translation.
function ttValidTranslationLine($val)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return false; // Empty line is not valid.

Expand All @@ -211,14 +211,15 @@ function ttValidTranslationLine($val)
// We identify these parts by 3 "stop sign" emojis (aka "octagonal sign" U+1F6D1).
function ttValidTemplateText($val)
{
$valid = strpos($val, '🛑🛑🛑') === false; // no 3 "stop sign" emojis in a row.

$valid = (is_null($val) ? false : strpos($val, '🛑🛑🛑') === false); // no 3 "stop sign" emojis in a row.
return $valid;
}

// ttValidEmail is used to check user input to validate an email string.
function ttValidEmail($val, $emptyValid = false)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return ($emptyValid ? true : false);

Expand All @@ -236,7 +237,7 @@ function ttValidEmail($val, $emptyValid = false)
// ttValidEmailList is used to check user input to validate an email string.
function ttValidEmailList($val, $emptyValid = false)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return ($emptyValid ? true : false);

Expand All @@ -254,7 +255,7 @@ function ttValidEmailList($val, $emptyValid = false)
// ttValidFloat is used to check user input to validate a float value.
function ttValidFloat($val, $emptyValid = false)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return ($emptyValid ? true : false);

Expand Down Expand Up @@ -368,7 +369,7 @@ function ttValidTime($val)
// ttValidInteger is used to check user input to validate an integer.
function ttValidInteger($val, $emptyValid = false)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return ($emptyValid ? true : false);

Expand Down Expand Up @@ -424,7 +425,7 @@ function ttValidCronSpec($val)

// But this works.
$regexp = '/^'.$fields_re.'$/';

if (is_null($val)) return false;
if (!preg_match($regexp, $val))
return false;

Expand All @@ -434,7 +435,7 @@ function ttValidCronSpec($val)
// ttValidCondition is used to check user input to validate a notification condition.
function ttValidCondition($val, $emptyValid = true)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0)
return ($emptyValid ? true : false);

Expand All @@ -455,7 +456,7 @@ function ttValidCondition($val, $emptyValid = true)
// For example, IPv4-mapped IPv6 addresses will fail. This may need to be fixed.
function ttValidIP($val, $emptyValid = false)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0 && $emptyValid)
return true;

Expand All @@ -475,7 +476,7 @@ function ttValidIP($val, $emptyValid = false)
// The above means Jan 1 and Dec 31 are holidays in all years, while Apr 20 is only in 2019.
function ttValidHolidays($val)
{
$val = trim($val);
$val = is_null($val) ? '' : trim($val);
if (strlen($val) == 0) return true;

$dates = explode(',', $val);
Expand Down Expand Up @@ -660,6 +661,6 @@ function ttRandomString($length = 32) {
// This mitigates a risk of CSV injection, see https://owasp.org/www-community/attacks/CSV_Injection
// Additionally, it replaces each quote character with a double quote.
function ttNeutralizeForCsv($val) {
$result = ltrim($val, '=+-@');
$result = is_null($val) ? '' : ltrim($val, '=+-@');
return str_replace('"', '""', $result);
}
1 change: 1 addition & 0 deletions WEB-INF/lib/form/ActionForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ActionForm {
var $mVariables = array();
var $mForm = null;
var $mInitForm = false;
var $name = "";

function __construct($name, &$form, $request=null) {
$this->setName($name);
Expand Down
6 changes: 4 additions & 2 deletions WEB-INF/lib/form/DateField.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class DateField extends TextField {
var $mWeekStartDay = 0;
var $mDateFormat = "d/m/Y";
var $lToday = "Today";
var $mMonthNames;
var $mWeekDayShortNames;

var $lCalendarButtons = array('today'=>'Today', 'close'=>'Close');

Expand Down Expand Up @@ -382,9 +384,9 @@ function adjustiFrame(pickerDiv, iFrameDiv) {
if (defined('DIR_NAME'))
$dir_name = trim(constant('DIR_NAME'), '/');
if (!empty($dir_name))
$app_root = '/'.$dir_name;
$app_root = '/'.$dir_name.'/';

$html .= "&nbsp;<img src=\"".$app_root."/img/calendar.gif\" width=\"16\" height=\"16\" onclick=\"displayDatePicker('".$this->name."');\">\n";
$html .= "&nbsp;<img src=\"".$app_root."img/calendar.gif\" width=\"16\" height=\"16\" onclick=\"displayDatePicker('".$this->name."');\">\n";
}

return $html;
Expand Down
4 changes: 3 additions & 1 deletion WEB-INF/lib/form/Form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function addInput($params) {
import('form.TextField');
$el = new TextField($params['name']);
if (isset($params['class'])) $el->setCssClass($params['class']);
if (isset($params['minlength'])) $el->setMinLength($params['minlength']);
if (isset($params['maxlength'])) $el->setMaxLength($params['maxlength']);
if (isset($params['placeholder'])) $el->setPLaceholder($params['placeholder']);
break;
Expand All @@ -38,7 +39,8 @@ function addInput($params) {
import('form.PasswordField');
$el = new PasswordField($params['name']);
if (isset($params['class'])) $el->setCssClass($params['class']);
if (isset($params['maxlength'])) $el->setMaxLength($params['maxlength']);
if (isset($params['minlength'])) $el->setMinLength($params['minlength']);
if (isset($params['maxlength'])) $el->setMaxLength($params['maxlength']);
break;

case 'datefield':
Expand Down
4 changes: 4 additions & 0 deletions WEB-INF/lib/form/FormElement.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class FormElement {
var $placeholder = ''; // placeholder
var $size = ''; // control size
var $max_length = ''; // max length of text in control
var $min_length = ''; // min length of text in control
var $on_change = ''; // what happens when value of control changes
var $on_click = ''; // what happens when the control is clicked
var $label = ''; // optional label for control
Expand Down Expand Up @@ -52,6 +53,9 @@ function getLabel() { return $this->label; }
function setMaxLength($value) { $this->max_length = $value; }
function getMaxLength() { return $this->max_length; }

function setMinLength($value) { $this->min_length = $value; }
function getMinLength() { return $this->min_length; }

function setStyle($value) { $this->style = $value; }
function getStyle() { return $this->style; }

Expand Down
3 changes: 3 additions & 0 deletions WEB-INF/lib/form/PasswordField.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ function getHtml() {
if ($this->style != '')
$html.= ' style="'.$this->style.'"';

if ($this->min_length != '')
$html.= ' minlength="'.$this->min_length.'"';

if ($this->max_length != '')
$html.= ' maxlength="'.$this->max_length.'"';

Expand Down
3 changes: 3 additions & 0 deletions WEB-INF/lib/form/Submit.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ function getHtml() {
if (empty($this->id))
$this->id = $this->name;

if (is_array($this->value))
return '';

// Output HTML.
$html = "\n\t<input type=\"submit\" name=\"$this->name\" id=\"$this->id\"";
$html .= " value=\"$this->value\"";
Expand Down
3 changes: 2 additions & 1 deletion WEB-INF/lib/form/Table.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ function getHtml() {

// Print rows.
if (is_array($this->mData)) {
$rowHoverBackgroundColor = ($this->isInteractive() ? "onmouseover=\"setRowBackground(this, '".$this->mBgColorOver."')\" onmouseout=\"setRowBackground(this, null)\"" : "");
for ($row = 0; $row < count($this->mData); $row++) {
$html .= "\n<tr bgcolor=\"".$this->mBgColor."\" onmouseover=\"setRowBackground(this, '".$this->mBgColorOver."')\" onmouseout=\"setRowBackground(this, null)\">\n";
$html .= "\n<tr bgcolor=\"".$this->mBgColor."\" ".$rowHoverBackgroundColor.">\n";
for ($col = 0; $col < $this->getColumnCount(); $col++) {
if (0 == $col && strtolower(get_class($this->mColumns[$col]->getRenderer())) == 'checkboxcellrenderer') {
// Checkbox for the row. Determine if selected.
Expand Down
1 change: 0 additions & 1 deletion WEB-INF/lib/form/TextArea.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ function getHtml() {
$html .= " name=\"$this->name\" id=\"$this->id\"";

if ($this->max_length!="") {
if ($this->mOnKeyPress) $this->mOnKeyPress .= ";";
$html .= " maxlength=\"$this->max_length\"";
}

Expand Down
Loading