'
);
}
else {
$correct_fields = false;
$field_system = $fields_system[$name_field];
$diff = array_diff($field_test, $field_system);
if (!empty($diff)) {
$info_message = "";
$error_message = "";
if($diff['type']){
$error_message .= "Unsuccessful the field ".$name_field." in the table ".$table." must be set the type with ".$diff['type']." ";
}
if($diff['null']){
$error_message .= "Unsuccessful the field $name_field in the table $table must be null: (".$diff['null']."). ";
}
if($diff['default']){
$error_message .= "Unsuccessful the field $name_field in the table $table must be set ".$diff['default']." as default value. ";
}
if($field_test['null'] == "YES" || !isset($field_test['null']) || $field_test['null'] == ""){
$null_defect = " NULL";
}
else{
$null_defect = " NOT NULL";
}
if(!isset($field_test['default']) || $field_test['default'] == ""){
$default_value = "";
}
else{
$default_value = " DEFAULT ".$field_test['default'];
}
if($diff['type'] || $diff['null'] || $diff['default']){
$info_message .= "ALTER TABLE " . $table . " MODIFY COLUMN " . $name_field . " " . $field_test['type'] . $null_defect . $default_value.";";
}
if($diff['key']){
$error_message .= "Unsuccessful the field $name_field in the table $table must be set the key as defined in the SQL file. ";
$info_message .= "
Please check the SQL file for to know the kind of key needed.";
}
if($diff['extra']){
$error_message .= "Unsuccessful the field $name_field in the table $table must be set as defined in the SQL file. ";
$info_message .= "
Please check the SQL file for to know the kind of extra config needed.";
}
ui_print_error_message(__($error_message));
ui_print_info_message(__($info_message));
}
}
}
}
if ($correct_fields) {
ui_print_success_message(
__('Successful all the tables have the correct fields')
);
}
}
function extension_db_status_execute_sql_file($url, $connection) {
global $config;
if (file_exists($url)) {
$file_content = file($url);
$query = "";
foreach ($file_content as $sql_line) {
if (trim($sql_line) != "" && strpos($sql_line, "--") === false) {
$query .= $sql_line;
if (preg_match("/;[\040]*\$/", $sql_line)) {
if ($config["mysqli"] === true) {
if (!$result = mysqli_query($connection, $query)) {
echo mysqli_error(); //Uncomment for debug
echo " $query ";
return 0;
}
}
else{
if (!$result = mysql_query($query, $connection)) {
echo mysql_error(); //Uncomment for debug
echo " $query ";
return 0;
}
}
$query = "";
}
}
}
return 1;
}
else
return 0;
}
extensions_add_godmode_function('extension_db_status');
extensions_add_godmode_menu_option(__('DB Schema check'), 'DM', 'gextensions', null, "v1r1", 'gdbman');
?>