Skip to content

Commit d8580dd

Browse files
author
Ahmad Gneady
committed
As generated by AppGini 5.95
1 parent 922e46e commit d8580dd

30 files changed

+304
-166
lines changed

app/admin/getUsers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// This script and data application were generated by AppGini 5.93
2+
// This script and data application were generated by AppGini 5.95
33
// Download AppGini for free from https://bigprof.com/appgini/download/
44

55
/*

app/admin/incFunctions.php

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
html_attr_tags_ok($str) -- same as html_attr, but allowing HTML tags
4242
Notification() -- class for providing a standardized html notifications functionality
4343
sendmail($mail) -- sends an email using PHPMailer as specified in the assoc array $mail( ['to', 'name', 'subject', 'message', 'debug'] ) and returns true on success or an error message on failure
44-
safe_html($str) -- sanitize HTML strings, and apply nl2br() to non-HTML ones
44+
safe_html($str, $noBr = false) -- sanitize HTML strings, and apply nl2br() to non-HTML ones (unless optional 2nd param is passed as true)
4545
get_tables_info($skip_authentication = false) -- retrieves table properties as a 2D assoc array ['table_name' => ['prop1' => 'val', ..], ..]
4646
getLoggedMemberID() -- returns memberID of logged member. If no login, returns anonymous memberID
4747
getLoggedGroupID() -- returns groupID of logged member, or anonymous groupID
@@ -76,6 +76,8 @@
7676
guessMySQLDateTime($dt) -- if $dt is not already a mysql date/datetime, use mysql_datetime() to convert then return mysql date/datetime. Returns false if $dt invalid or couldn't be detected.
7777
pkGivenLookupText($val, $tn, $lookupField, $falseIfNotFound) -- returns corresponding PK value for given $val which is the textual lookup value for given $lookupField in given $tn table. If $val has no corresponding PK value, $val is returned as-is, unless $falseIfNotFound is set to true, in which case false is returned.
7878
userCanImport() -- returns true if user (or his group) can import CSV files (through the permission set in the group page in the admin area).
79+
bgStyleToClass($html) -- replaces bg color 'style' attr with a class to prevent style loss on xss cleanup.
80+
assocArrFilter($arr, $func) -- filters provided array using provided callback function. The callback receives 2 params ($key, $value) and should return a boolean.
7981
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8082
*/
8183
########################################################################
@@ -1451,14 +1453,50 @@ public static function show($options = []) {
14511453
}
14521454
}
14531455
#########################################################
1456+
function addMailRecipients(&$pm, $recipients, $type = 'to') {
1457+
if(empty($recipients)) return;
1458+
1459+
switch(strtolower($type)) {
1460+
case 'cc':
1461+
$func = [$pm, 'addCC'];
1462+
break;
1463+
case 'bcc':
1464+
$func = [$pm, 'addBCC'];
1465+
break;
1466+
case 'to':
1467+
$func = [$pm, 'addAddress'];
1468+
break;
1469+
}
1470+
1471+
// if recipients is a str, arrayify it!
1472+
if(is_string($recipients)) $recipients = [[$recipients]];
1473+
if(!is_array($recipients)) return;
1474+
1475+
// if recipients is an array, loop thru and add emails/names
1476+
foreach ($recipients as $rcpt) {
1477+
// if rcpt is string, add as email
1478+
if(is_string($rcpt) && isEmail($rcpt))
1479+
call_user_func_array($func, [$rcpt]);
1480+
1481+
// else if rcpt is array [email, name], or just [email]
1482+
elseif(is_array($rcpt) && isEmail($rcpt[0]))
1483+
call_user_func_array($func, [$rcpt[0], empty($rcpt[1]) ? '' : $rcpt[1]]);
1484+
}
1485+
}
1486+
#########################################################
14541487
function sendmail($mail) {
1455-
if(!isset($mail['to'])) return 'No recipient defined';
1456-
if(!isEmail($mail['to'])) return 'Invalid recipient email';
1488+
if(empty($mail['to'])) return 'No recipient defined';
1489+
1490+
// convert legacy 'to' and 'name' to new format [[to, name]]
1491+
if(is_string($mail['to']))
1492+
$mail['to'] = [
1493+
[
1494+
$mail['to'],
1495+
empty($mail['name']) ? '' : $mail['name']
1496+
]
1497+
];
14571498

1458-
$mail['subject'] = isset($mail['subject']) ? $mail['subject'] : '';
1459-
$mail['message'] = isset($mail['message']) ? $mail['message'] : '';
1460-
$mail['name'] = isset($mail['name']) ? $mail['name'] : '';
1461-
$mail['debug'] = isset($mail['debug']) ? min(4, max(0, intval($mail['debug']))) : 0;
1499+
if(!isEmail($mail['to'][0][0])) return 'Invalid recipient email';
14621500

14631501
$cfg = config('adminConfig');
14641502
$smtp = ($cfg['mail_function'] == 'smtp');
@@ -1474,7 +1512,7 @@ function sendmail($mail) {
14741512

14751513
if($smtp) {
14761514
$pm->isSMTP();
1477-
$pm->SMTPDebug = $mail['debug'];
1515+
$pm->SMTPDebug = isset($mail['debug']) ? min(4, max(0, intval($mail['debug']))) : 0;
14781516
$pm->Debugoutput = 'html';
14791517
$pm->Host = $cfg['smtp_server'];
14801518
$pm->Port = $cfg['smtp_port'];
@@ -1485,15 +1523,26 @@ function sendmail($mail) {
14851523
}
14861524

14871525
$pm->setFrom($cfg['senderEmail'], $cfg['senderName']);
1488-
$pm->addAddress($mail['to'], $mail['name']);
1489-
$pm->Subject = $mail['subject'];
1526+
$pm->Subject = isset($mail['subject']) ? $mail['subject'] : '';
1527+
1528+
// handle recipients
1529+
addMailRecipients($pm, $mail['to']);
1530+
if(!empty($mail['cc'])) addMailRecipients($pm, $mail['cc'], 'cc');
1531+
if(!empty($mail['bcc'])) addMailRecipients($pm, $mail['bcc'], 'bcc');
14901532

14911533
/* if message already contains html tags, don't apply nl2br */
1534+
$mail['message'] = isset($mail['message']) ? $mail['message'] : '';
14921535
if($mail['message'] == strip_tags($mail['message']))
14931536
$mail['message'] = nl2br($mail['message']);
14941537

14951538
$pm->msgHTML($mail['message'], realpath("{$curr_dir}/.."));
14961539

1540+
/*
1541+
* pass 'tag' as-is if provided in $mail ..
1542+
* this is useful for passing any desired values to sendmail_handler
1543+
*/
1544+
if(!empty($mail['tag'])) $pm->tag = $mail['tag'];
1545+
14971546
/* if sendmail_handler(&$pm) is defined (in hooks/__global.php) */
14981547
if(function_exists('sendmail_handler')) sendmail_handler($pm);
14991548

@@ -1502,13 +1551,12 @@ function sendmail($mail) {
15021551
return true;
15031552
}
15041553
#########################################################
1505-
function safe_html($str) {
1554+
function safe_html($str, $noBr = false) {
15061555
/* if $str has no HTML tags, apply nl2br */
1507-
if($str == strip_tags($str)) return nl2br($str);
1556+
if($str == strip_tags($str)) return $noBr ? $str : nl2br($str);
15081557

15091558
$hc = new CI_Input(datalist_db_encoding);
1510-
1511-
return $hc->xss_clean($str);
1559+
return $hc->xss_clean(bgStyleToClass($str));
15121560
}
15131561
#########################################################
15141562
function getLoggedGroupID() {
@@ -2192,3 +2240,23 @@ function getUploadDir($dir) {
21922240

21932241
return rtrim($dir, '\\/') . '/';
21942242
}
2243+
#########################################################
2244+
function bgStyleToClass($html) {
2245+
return preg_replace(
2246+
'/ style="background-color: rgb\((\d+), (\d+), (\d+)\);"/',
2247+
' class="nicedit-bg" data-nicedit_r="$1" data-nicedit_g="$2" data-nicedit_b="$3"',
2248+
$html
2249+
);
2250+
}
2251+
#########################################################
2252+
function assocArrFilter($arr, $func) {
2253+
if(!is_array($arr) || !count($arr)) return $arr;
2254+
if(!is_callable($func)) return false;
2255+
2256+
$filtered = [];
2257+
foreach ($arr as $key => $value)
2258+
if(call_user_func_array($func, [$key, $value]) === true)
2259+
$filtered[$key] = $value;
2260+
2261+
return $filtered;
2262+
}

app/admin/pageRebuildFields.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ function prepare_def($def) {
2828
/* make sure there is always a space before mysql words */
2929
$def = preg_replace('/(\S)(unsigned|not null|binary|zerofill|auto_increment|default)/i', '$1 $2', $def);
3030

31+
/* ignore 'not null' for auto_increment fields */
32+
$def = preg_replace('/\s+not\s+null\s+(.*?)\s+auto_increment/i', ' $1 auto_increment', $def);
33+
3134
/* treat 0.000.. same as 0 */
3235
$def = preg_replace('/([0-9])*\.0+/', '$1', $def);
3336

@@ -179,7 +182,7 @@ function fix_field($fix_table, $fix_field, $schema, &$qry) {
179182

180183
<tbody>
181184
<?php foreach($schema as $tn => $fields) { ?>
182-
<tr class="text-info"><td colspan="5"><h4 data-placement="left" data-toggle="tooltip" title="<?php echo str_replace ( "<TABLENAME>" , $tn , $Translation['table name title']) ; ?>"><i class="glyphicon glyphicon-th-list"></i> <?php echo $table_captions[$tn]; ?></h4></td></tr>
185+
<tr class="text-info"><td colspan="5"><h4 data-placement="auto top" data-toggle="tooltip" title="<?php echo str_replace ( "<TABLENAME>" , $tn , $Translation['table name title']) ; ?>"><i class="glyphicon glyphicon-th-list"></i> <?php echo $table_captions[$tn]; ?></h4></td></tr>
183186
<?php foreach($fields as $fn => $fd) { ?>
184187
<?php $diff = ((prepare_def($fd['appgini']) == prepare_def($fd['db'])) ? false : true); ?>
185188
<?php $no_db = ($fd['db'] ? false : true); ?>
@@ -190,9 +193,9 @@ function fix_field($fix_table, $fix_field, $schema, &$qry) {
190193
<td class="<?php echo ($diff ? 'bold text-danger' : ''); ?>"><?php echo thisOr("<samp>{$fd['db']}</samp>", $Translation['does not exist']); ?></td>
191194
<td>
192195
<?php if($diff && $no_db) { ?>
193-
<a href="pageRebuildFields.php?t=<?php echo $tn; ?>&f=<?php echo $fn; ?>" class="btn btn-success btn-xs btn_create" data-toggle="tooltip" data-placement="top" title="<?php echo $Translation['create field'] ; ?>"><i class="glyphicon glyphicon-plus"></i> <?php echo $Translation['create it'] ; ?></a>
196+
<a href="pageRebuildFields.php?t=<?php echo $tn; ?>&f=<?php echo $fn; ?>" class="btn btn-success btn-xs btn_create" data-toggle="tooltip" data-placement="auto top" title="<?php echo $Translation['create field'] ; ?>"><i class="glyphicon glyphicon-plus"></i> <?php echo $Translation['create it'] ; ?></a>
194197
<?php } elseif($diff) { ?>
195-
<a href="pageRebuildFields.php?t=<?php echo $tn; ?>&f=<?php echo $fn; ?>" class="btn btn-warning btn-xs btn_update" data-toggle="tooltip" title="<?php echo $Translation['fix field'] ; ?>"><i class="glyphicon glyphicon-cog"></i> <?php echo $Translation['fix it'] ; ?></a>
198+
<a href="pageRebuildFields.php?t=<?php echo $tn; ?>&f=<?php echo $fn; ?>" class="btn btn-warning btn-xs btn_update" data-toggle="tooltip" data-placement="auto top" title="<?php echo $Translation['fix field'] ; ?>"><i class="glyphicon glyphicon-cog"></i> <?php echo $Translation['fix it'] ; ?></a>
196199
<?php } ?>
197200
</td>
198201
</tr>
@@ -204,7 +207,7 @@ function fix_field($fix_table, $fix_field, $schema, &$qry) {
204207

205208
<style>
206209
.bold{ font-weight: bold; }
207-
[data-toggle="tooltip"]{ display: block !important; }
210+
[data-toggle="tooltip"]{ display: inline-block !important; }
208211
</style>
209212

210213
<script>

app/admin/pageServerStatus.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
$appgini_version = '5.93.1128';
3-
$generated_ts = '19/1/2021 9:11:17 PM';
2+
$appgini_version = '5.95.1136';
3+
$generated_ts = '28/3/2021 6:51:14 PM';
44

55
$currDir = dirname(__FILE__);
66
require("{$currDir}/incCommon.php");

app/admin/pageViewGroups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
?>
7676
<tr>
7777
<td><a href="pageEditGroup.php?groupID=<?php echo $row[0]; ?>"><?php echo $row[1]; ?></a></td>
78-
<td><?php echo thisOr($row[2]); ?></td>
78+
<td><?php echo htmlspecialchars(thisOr($row[2])); ?></td>
7979
<td class="text-right"><?php echo $groupMembersCount; ?></td>
8080
<td class="text-center">
8181
<a href="pageEditGroup.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['Edit group']; ?>"><i class="glyphicon glyphicon-pencil"></i></a>

app/admin/pageViewRecords.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
// process search
88
$memberID = new Request('memberID', 'strtolower');
9-
$groupID = max(0, intval($_GET['groupID']));
9+
$groupID = max(0, intval($_REQUEST['groupID']));
1010
$tableName = new Request('tableName');
11-
$page = max(1, intval($_GET['page']));
11+
$page = max(1, intval($_REQUEST['page']));
1212
$where = [];
1313

1414
// process sort
15-
$sortDir = ($_GET['sortDir'] == 'DESC' ? 'DESC' : '');
16-
$sort = makeSafe($_GET['sort']);
15+
$sortDir = ($_REQUEST['sortDir'] == 'DESC' ? 'DESC' : '');
16+
$sort = makeSafe($_REQUEST['sort']);
1717
if($sort != 'dateAdded' && $sort != 'dateUpdated') { // default sort is newly created first
1818
$sort = 'dateAdded';
1919
$sortDir = 'DESC';
@@ -83,8 +83,8 @@
8383
?>
8484
<span class="hspacer-md"></span>
8585
<?php
86-
$arrFields=array('desc', '');
87-
$arrFieldCaptions = array( $Translation['newer first'] , $Translation['older first'] );
86+
$arrFields = ['DESC', ''];
87+
$arrFieldCaptions = [$Translation['newer first'], $Translation['older first']];
8888
echo htmlSelect('sortDir', $arrFields, $arrFieldCaptions, $sortDir);
8989
?>
9090
</div>
@@ -98,8 +98,8 @@
9898
<tr>
9999
<th>&nbsp;</td>
100100
<th><?php echo $Translation['username'] ; ?></th>
101-
<th><?php echo $Translation["group"] ; ?></th>
102-
<th><?php echo $Translation["table"] ; ?></th>
101+
<th><?php echo $Translation['group'] ; ?></th>
102+
<th><?php echo $Translation['table'] ; ?></th>
103103
<th><?php echo $Translation['created'] ; ?></th>
104104
<th><?php echo $Translation['modified'] ; ?></th>
105105
<th><?php echo $Translation['data'] ; ?></th>

app/ajax_combo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// This script and data application were generated by AppGini 5.93
2+
// This script and data application were generated by AppGini 5.95
33
// Download AppGini for free from https://bigprof.com/appgini/download/
44

55
/*

app/assignments_autofill.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// This script and data application were generated by AppGini 5.93
2+
// This script and data application were generated by AppGini 5.95
33
// Download AppGini for free from https://bigprof.com/appgini/download/
44

55
$currDir = dirname(__FILE__);

app/assignments_dml.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Data functions (insert, update, delete, form) for table assignments
44

5-
// This script and data application were generated by AppGini 5.93
5+
// This script and data application were generated by AppGini 5.95
66
// Download AppGini for free from https://bigprof.com/appgini/download/
77

88
function assignments_insert(&$error_message = '') {
@@ -272,8 +272,7 @@ function assignments_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1,
272272
$combo_StartDate->DefaultDate = $row['StartDate'];
273273
$combo_EndDate->DefaultDate = $row['EndDate'];
274274
$urow = $row; /* unsanitized data */
275-
$hc = new CI_Input(datalist_db_encoding);
276-
$row = $hc->xss_clean($row); /* sanitize data */
275+
$row = array_map('safe_html', $row);
277276
} else {
278277
$combo_ProjectId->SelectedData = $filterer_ProjectId;
279278
$combo_ResourceId->SelectedData = $filterer_ResourceId;
@@ -553,7 +552,7 @@ function ResourceId_reload__RAND__() {
553552
}
554553

555554
// if user has insert permission to parent table of a lookup field, put an add new button
556-
if($pt_perm['insert'] && !$_REQUEST['Embedded']) {
555+
if($pt_perm['insert'] /* && !$_REQUEST['Embedded']*/) {
557556
$templateCode = str_replace("<%%ADDNEW({$ptfc[0]})%%>", '<button type="button" class="btn btn-success add_new_parent hspacer-md" id="' . $ptfc[0] . '_add_new" title="' . html_attr($Translation['Add New'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-plus-sign"></i></button>', $templateCode);
558557
}
559558
}

app/assignments_view.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
// This script and data application were generated by AppGini 5.93
2+
// This script and data application were generated by AppGini 5.95
33
// Download AppGini for free from https://bigprof.com/appgini/download/
44

55
$currDir = dirname(__FILE__);

0 commit comments

Comments
 (0)