function dbv_100() { if (sql_field_type('cache_logs', 'date') != 'DATETIME') { sql("ALTER TABLE `cache_logs` CHANGE COLUMN `date` `date` DATETIME NOT NULL"); } if (sql_field_type('cache_logs_archived', 'date') != 'DATETIME') { sql("ALTER TABLE `cache_logs_archived` CHANGE COLUMN `date` `date` DATETIME NOT NULL"); } }
function get_fields() { global $tbl_users; global $fields, $field_props; array_splice($fields, 0); // clear out any existing field names array_splice($field_props, 0); // and properties $result = sql_query("select * from {$tbl_users} limit 1"); $nfields = sql_num_fields($result); for ($i = 0; $i < $nfields; $i++) { $field_name = sql_field_name($result, $i); $fields[] = $field_name; $field_props[$field_name]['type'] = sql_field_type($result, $i); $field_props[$field_name]['istext'] = $field_props[$field_name]['type'] == 'string' ? true : false; $field_props[$field_name]['isnum'] = preg_match('/(int|real)/', $field_props[$field_name]['type']) ? true : false; $field_props[$field_name]['isbool'] = $field_props[$field_name]['type'] == 'boolean' ? true : false; } sql_free($result); }
$r = sql_command($cmd); if ($r == -1) { // No need to localize this: Only the admin running this for the first time would see it. print "<p class=\"error\">Error creating the {$tbl_users} table.</p>\n"; print "<p class=\"error\">" . sql_error() . "</p>\n"; exit; } $nusers = 0; } /* Get the list of fields actually in the table. (Allows the addition of new fields later on) */ $result = sql_query("select * from {$tbl_users} limit 1"); $nfields = sql_num_fields($result); for ($i = 0; $i < $nfields; $i++) { $field_name = sql_field_name($result, $i); $fields[] = $field_name; $field_props[$field_name]['type'] = sql_field_type($result, $i); $field_props[$field_name]['istext'] = $field_props[$field_name]['type'] == 'string' ? true : false; $field_props[$field_name]['isnum'] = preg_match('/(int|real)/', $field_props[$field_name]['type']) ? true : false; } sql_free($result); /* Get localized field name */ function get_loc_field_name($name) { global $vocab; // Search for indexes "user_name", "user_password", etc, in the localization array. if (isset($vocab["user_" . $name])) { return get_vocab("user_" . $name); } // If there is no entry (likely if user-defined fields have been added), return itself. return $name; }
$r = sql_command($cmd); if ($r == -1) { // No need to localize this: Only the admin running this for the first time would see it. print "Error creating the {$tbl_users} table.<br>\n"; print sql_error() . "<br>\n"; exit; } $nusers = 0; } /* Get the list of fields actually in the table. (Allows the addition of new fields later on) */ $result = sql_query("select * from {$tbl_users} limit 1"); $nfields = sql_num_fields($result); for ($i = 0; $i < $nfields; $i++) { $field_name[$i] = sql_field_name($result, $i); // print "<p>field_name[$i] = $field_name[$i]</p>\n"; $field_type[$i] = sql_field_type($result, $i); // print "<p>field_type[$i] = $field_type[$i]</p>\n"; $field_istext[$i] = $field_type[$i] == 'string' ? true : false; // print "<p>field_istext[$i] = $field_istext[$i]</p>\n"; $field_isnum[$i] = preg_match('/(int|real)/', $field_type[$i]) ? true : false; // print "<p>field_isnum[$i] = $field_isnum[$i]</p>\n"; } sql_free($result); /* Get localized field name */ function get_loc_field_name($i) { global $field_name, $vocab; $name = $field_name[$i]; // $name = "name", "password", ... // Search for indexes "user_name", "user_password", etc, in the localization array. if (isset($vocab["user_" . $name])) {