Skip to content

Commit f9c7f3f

Browse files
committed
- Added function to create random passwords in auth library.
- Fixed {RECORDID} placeholder in SQL datasource strings.
1 parent 8eb646a commit f9c7f3f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

interface/lib/classes/auth.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ public function check_module_permissions($module) {
123123
exit;
124124
}
125125
}
126+
127+
public function get_random_password($length = 8) {
128+
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
129+
$password = '';
130+
for ($n=0;$n<$length;$n++) {
131+
$password.=$base64_alphabet[mt_rand(0,63)];
132+
}
133+
return $password;
134+
}
126135

127136
}
128137

interface/lib/classes/tform.inc.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ function decode($record,$tab) {
166166
global $conf, $app;
167167
if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab does not exist or the tab is empty (TAB: $tab).");
168168
$new_record = '';
169+
$table_idx = $this->formDef['db_table_idx'];
170+
if(isset($record[$table_idx])) $new_record[$table_idx] = intval($record[$table_idx ]);
171+
169172
if(is_array($record)) {
170173
foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) {
171174
switch ($field['datatype']) {
@@ -236,11 +239,12 @@ function getDatasourceData($field, $record) {
236239
$table_idx = $this->formDef['db_table_idx'];
237240

238241
$tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0;
242+
//$tmp_recordid = intval($this->primary_id);
239243
$querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring);
240244
unset($tmp_recordid);
241245

242246
$querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
243-
247+
244248
// Getting the records
245249
$tmp_records = $app->db->queryAllRecords($querystring);
246250
if($app->db->errorMessage != '') die($app->db->errorMessage);

0 commit comments

Comments
 (0)