#!/usr/bin/env php database. Please select one of: \n\n" . join("\n", $tables) . "\n\n"); } // Make sure op is valid. if (isset($op) && !in_array($op, $valid_ops)) { die(basename($_SERVER['argv'][0]) . " Warning: Operation '$op' is not something I know how to do Please select one of: " . join(", ", $valid_ops) . "\n"); } // Get DB table column info. $qid = dbQuery("DESCRIBE " . mysql_real_escape_string($db_tbl)); while ($row = mysql_fetch_row($qid)) { $cols[] = $row; } // Loop through columns if (is_array($cols) && !empty($cols)) { foreach ($cols as $col) { // Human readable. $field = $col[0]; $title = ucfirst(str_replace('_', ' ', $field)); $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]); // Get primary key. if ('PRI' == $col[3]) { $primary_key = $field; } // Column headers. $headers[$field] = $title; // Column data. if (preg_match("/enum\('true'\)/", $col[1])) { $listrows[] = "<\x3fphp echo (!empty(\$list[\$i]['$field'])) ? '•' : ''; \x3f>"; } else if ( 'tinytext' == $type || 'text' == $type || 'mediumtext' == $type || 'longtext' == $type || 'tinyblob' == $type || 'blob' == $type || 'mediumblob' == $type || 'longblob' == $type ) { $listrows[] = "<\x3fphp echo strlen(\$list[\$i]['$field'])<50 \x3f oTxt(\$list[\$i]['$field'], true) : oTxt(trim(substr(\$list[\$i]['$field'], 0, 50)) . '...'); \x3f>"; } else if (preg_match('/.*(begin|start).*date.*/i', $field)) { $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$CFG->date_format, strtotime(\$list[\$i]['$field'])); \x3f>"; } else if (preg_match('/.*(end|expire).*date.*/i', $field)) { $listrows[] = "<\x3fphp echo '9999-12-31' == \$list[\$i]['$field'] ? '' : date(\$CFG->date_format, strtotime(\$list[\$i]['$field'])); \x3f>"; } else if (preg_match('/datetime/i', $type)) { $listrows[] = "<\x3fphp echo '0000-00-00 00:00:00' == \$list[\$i]['$field'] ? '' : date(\$CFG->date_format, strtotime(\$list[\$i]['$field'])); \x3f>"; } else if (preg_match('/date/i', $type)) { $listrows[] = "<\x3fphp echo '0000-00-00' == \$list[\$i]['$field'] ? '' : date(\$CFG->date_format, strtotime(\$list[\$i]['$field'])); \x3f>"; } else if (preg_match('/(amount|_rate)/i', $field)) { $listrows[] = "<\x3fphp printf('$%01.2f', \$list[\$i]['$field']); \x3f>"; } else if (preg_match('/(added_by_admin_id)/i', $field)) { $listrows[] = "<\x3fphp echo oTxt(\$list[\$i]['added_admin_username']); \x3f>"; } else if (preg_match('/(modified_by_admin_id)/i', $field)) { $listrows[] = "<\x3fphp echo oTxt(\$list[\$i]['modified_admin_username']); \x3f>"; } else if ('rank' == $field) { $listrows[] = "]\" value=\"<\x3fphp echo \$list[\$i]['rank']; \x3f>\" size=\"5\" />"; } else { $listrows[] = "<\x3fphp echo oTxt(\$list[\$i]['$field'], true); \x3f>"; } } } else { die(basename($_SERVER['argv'][0]) . " Warning: $db_tbl does not have any columns.\n"); } // Print the template out. echo isset($op) ? '' : <<
<\x3fphp printHiddenSession(false); \x3f>
<\x3fphp echo _("Add <##>"); \x3f>
.")); \x3f>" /> " />
E_O_F; // Print header rows. if (!isset($op) || 'headerrows' == $op) { foreach ($headers as $field=>$title) { if ($field == $primary_key) { echo " \n"; } else { echo " \n"; } } } echo isset($op) ? '' : <<  <\x3fphp for (\$i = 0; \$i <= \$page->last_item - \$page->first_item && \$page->total_items > 0; \$i++) { \x3f> E_O_F; // Print List rows. if (!isset($op) || 'listrows' == $op) { foreach ($listrows as $col_data) { ?> " href="<\x3fphp echo ohref(\$_SERVER['PHP_SELF'] . "?op=del&$primary_key=" . \$list[\$i]['$primary_key']); \x3f>" onclick="javascript:return confirm('<\x3fphp printf(_("Are you sure you want to delete the record %s? This action is permanent and cannot be undone."), oTxt(\$list[\$i]['______RECORD_NAME______'])) \x3f>')">Delete   <\x3fphp } \x3f>
   <\x3fphp echo \$so->printSortHeader('$db_tbl.$field', _(\"ID\"), 'ASC'); \x3f><\x3fphp echo \$so->printSortHeader('$db_tbl.$field', _(\"$title\"), 'ASC'); \x3f>
" href="<\x3fphp echo ohref(\$_SERVER['PHP_SELF'] . '?op=edit&$primary_key=' . \$list[\$i]['$primary_key']); \x3f>">Edit   " href="<\x3fphp echo ohref("\$CFG->admin_url/record_versions.php?record_table=$db_tbl&record_key=$primary_key&boomerang=true&record_val=" . \$list[\$i]['$primary_key']); \x3f>">    
<\x3fphp if (\$page->total_pages > 1) { \x3f>
<\x3fphp echo _("Pages:"); \x3f> <\x3fphp \$page->printPageNumbers() \x3f>
<\x3fphp } \x3f>
E_O_F; ?>