<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php 
#session_start();
require_once '/var/www/bais.islamiconlineuniversity.com/bais/config.php';
//require_once('/home/eomanico/public_html/ecampus/config.php');
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/lib/blocklib.php';
//unset($_SESSION['sch_page_name']);
include "centerconn.php";
include "php_lib3/misc.php";
include "php_lib3/mysql.php";
$mysql_connect_id = mysql_start($mysql_server, $center_db, $mysql_username, $mysql_password);
?>
<link rel="stylesheet" href="CenterCMS.css" /><link rel="shortcut icon" href="http://bais.islamiconlineuniversity.com/bais/theme/ingenuous/favicon.ico" /><style type="text/css">

.class6{
	text-align: justify;
	font-size:15px;
	font-family: times new roman;      
}
ul {
list-style-image:url('http://bais.islamiconlineuniversity.com/bais/center/buttons/sqpurple.gif');
}
.class2{
font-size:15px;
font-family: times new roman;      
}
#page_header{
	width: 750px;
	margin-right: auto;
Beispiel #2
0
                }
            }
        }
        return $array_temp;
    }
}
# PHP Manual - Magic Quotes : Disabling Magic Quotes
if (get_magic_quotes_gpc() and !$magic_quotes_cleared) {
    $FORM = stripslashes_deep($FORM);
    //      $_GET = undoMagicQuotes($_GET);
    //      $_POST = undoMagicQuotes($_POST);
    //      $_COOKIE = undoMagicQuotes($_COOKIE);
    //      $_REQUEST = undoMagicQuotes($_REQUEST);
}
#$sql_debug = 1;
$mysql_connect_id = mysql_start($mysql_server, $database_name, $mysql_username, $mysql_password);
if (!$mysql_connect_id) {
    print "Unable to Connect to DB<br>" . mysql_error();
    exit;
}
#$FORM['return_query'] = ( $FORM['return_query'] ) ? "?" . $FORM['return_query'] : "";
$FORM['return_query_mark'] = $FORM['return_query'] ? "?" . preg_replace("/^\\?+/", "", $FORM['return_query']) : "";
if ($FORM['submit']) {
    if ($FORM['f'] == "add" and !$no_add) {
        $table_structure = mysql_table_structure($mysql_connect_id, $table_name);
        $primary_key_field = mysql_primary_key_field($table_structure);
        foreach ($FORM['fieldz'] as $field_name => $value) {
            if (is_array($value)) {
                $add_fields[$field_name] = join(",", $value);
            } else {
                if ($trim_fields) {
Beispiel #3
0
<?php

include "cfg.php";
include "php_lib3/misc.php";
include "php_lib3/mysql.php";
@(include "../lang/en_utf8/countries.php");
$mysql_connect_id = mysql_start($mysql_server, $moodle_db, $mysql_username, $mysql_password);
$sqlCountry = mysql_query("select distinct(`country`) as country from `mdl_user` where country<>'' and country is not null order by country");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://bais.islamiconlineuniversity.com/bais/theme/standard/styles.php" />
<link rel="stylesheet" type="text/css" href="http://bais.islamiconlineuniversity.com/bais/theme/ingenuous/styles.php" />
<meta name="description" content="" />
<!--[if IE 7]>
		    <link rel="stylesheet" type="text/css" href="http://bais.islamiconlineuniversity.com/bais/theme/standard/styles_ie7.css" />
		<![endif]-->
<!--[if IE 6]>
		    <link rel="stylesheet" type="text/css" href="http://bais.islamiconlineuniversity.com/bais/theme/standard/styles_ie6.css" />
		<![endif]-->
<meta name="keywords" content="moodle, Islamic Online University - BAIS " />
<title>Islamic Online University - BAIS</title>
<link rel="shortcut icon" href="http://bais.islamiconlineuniversity.com/bais/theme/ingenuous/favicon.ico" />
<!--<style type="text/css">/*<![CDATA[*/ body{behavior:url(http://bais.islamiconlineuniversity.com/bais/lib/csshover.htc);} /*]]>*/</style>-->
<style type="text/css">
<!--
body {
	font-family: Arial;
	font-size: 10pt;
Beispiel #4
0
<?php

include 'lib/includeall.php';
input_safe('null');
if (isset($_REQUEST["username"])) {
    $p_username = $_REQUEST["username"];
} else {
    die("One of the fields has not been set, please try again.");
}
if (isset($_REQUEST["password"])) {
    $p_password = $_REQUEST["password"];
} else {
    die("One of the fields has not been set, please try again.");
}
$createip = $_SERVER["REMOTE_ADDR"];
$con = mysql_start();
if (logonCheck($p_username, $p_password)) {
    echo "Logon successful<br />";
    echo print_r($_SESSION);
} else {
    echo "Logon error, invalid username or password";
}
page_done($con);
function mysql_generate_edit_form($connection_parameters, $table_name, $display_fields = array(), $fields_to_display_properties = array(), $form_properties = array())
{
    global $show_output_code;
    # in order to bring in html to be printed, change '"' to '\"', '$' to '\$', and then regexp '\r\n([^\r\n]+)' to '\r\n         $php_code .= "$1\\r\\n";'
    $php_code = "<?php\r\n";
    if (!$form_properties['single_page']) {
        $php_code .= "   include( \"../../php_lib3/misc.php\" );\r\n";
        $php_code .= "   include( \"../../php_lib3/misc_categories.php\" );\r\n";
        $php_code .= "   include( \"../../php_lib3/mysql.php\" );\r\n\r\n";
    }
    if (is_array($connection_parameters)) {
        $connect_id = mysql_start($connection_parameters['mysql_server'], $connection_parameters['database_name'], $connection_parameters['mysql_username'], $connection_parameters['mysql_password']);
        if (!$form_properties['single_page']) {
            $php_code .= "   \$mysql_server = \"{$connection_parameters['mysql_server']}\";\r\n";
            $php_code .= "   \$mysql_username = \"{$connection_parameters['mysql_username']}\";\r\n";
            $php_code .= "   \$mysql_password = \"{$connection_parameters['mysql_password']}\";\r\n\r\n";
            $php_code .= "   \$database_name = \"{$connection_parameters['database_name']}\";\r\n";
        }
        $php_code .= "   \$table_name = \"{$table_name}\";\r\n";
        $php_code .= "   \$mysql_connect_id = mysql_start( \$mysql_server, \$database_name, \$mysql_username, \$mysql_password );\r\n\r\n";
        $current_database = $connection_parameters['database_name'];
    } else {
        $connect_id = $connection_parameters;
        $current_database = mysql_current_databse($connect_id);
        $connection_parameters['database_name'] = $current_database;
        $php_code .= "   \$database_name = \"{$current_database}\";\r\n";
        $php_code .= "   \$table_name = \"{$table_name}\";\r\n\r\n";
    }
    $form_field_group_name = $form_properties['form_field_group_name'] ? $form_properties['form_field_group_name'] : "fieldz";
    $table_structure = mysql_table_structure($connect_id, $table_name);
    $fields_to_display = array_keys($table_structure);
    $primary_key_field = mysql_primary_key_field($table_structure);
    if ($display_fields['on']) {
        foreach ($display_fields['on'] as $value) {
            if ($table_structure[$value]) {
                # verifies that the field is actually in the table
                $fields_to_display1[] = $value;
            }
        }
        $fields_to_display = $fields_to_display1;
    } else {
        if ($display_fields['off']) {
            foreach ($display_fields['off'] as $value) {
                $find_key = array_search($value, $fields_to_display);
                if ($find_key !== False) {
                    unset($fields_to_display[$find_key]);
                }
            }
        } else {
            $all_fields = 1;
        }
    }
    if ($display_fields['hide']) {
        foreach ($display_fields['hide'] as $value) {
            if ($table_structure[$value]) {
                # verifies that the field is actually in the table
                $fields_to_hide[] = $value;
            }
        }
        $fields_to_hide1 = ",`" . join("`,`", $fields_to_hide) . "`";
    }
    if ($all_fields) {
        $fields = "*";
    } else {
        $fields = "`" . join("`,`", $fields_to_display) . "`";
        if (!is_array($fields_to_hide)) {
            $fields_to_hide = array();
        }
        if (!in_array($primary_key_field, $fields_to_display) and !in_array($primary_key_field, $fields_to_hide)) {
            # primary key wasnt found in the lists
            $fields_to_hide1 .= ",`{$primary_key_field}`";
        }
    }
    if (!$form_properties['single_page']) {
        $php_code .= "   \$table_structure = mysql_table_structure( \$mysql_connect_id, \$table_name );\r\n";
        //$php_code .= "   \$primary_key_field = mysql_primary_key_field( \$table_structure );\r\n\r\n";
        $php_code .= "   \$filter_field_names = array_keys( \$table_structure );\r\n";
        $php_code .= "   \$sql_field_names = \"{$fields}{$fields_to_hide1}\";\r\n";
        $php_code .= "   #\$sql_field_names = array_keys( \$table_structure );\r\n";
        $php_code .= "   \$primary_key_field = \"{$primary_key_field}\";\r\n\r\n";
    }
    $php_code .= "   if ( \$FORM['submit'] ) {\r\n";
    $php_code .= "      if ( \$FORM['f'] == \"add\" ) {\r\n";
    $php_code .= "         foreach ( \$FORM['{$form_field_group_name}'] as \$field_name => \$value ) {\r\n";
    $php_code .= "            if ( is_array(\$value) ) {\r\n";
    $php_code .= "               \$add_fields[\$field_name] = join( \",\", \$value );\r\n";
    $php_code .= "            } else {\r\n";
    $php_code .= "               #if ( trim(\$value) ) {\r\n";
    $php_code .= "                  \$add_fields[\$field_name] = trim(\$value);\r\n";
    $php_code .= "               #}\r\n";
    $php_code .= "            }\r\n";
    $php_code .= "         }\r\n\r\n";
    $php_code .= "         \$query_result = mysql_add_record( \"\", \$table_name, \$add_fields );\r\n\r\n";
    $php_code .= "         if ( !\$query_result ) {\r\n";
    $php_code .= "            print \"Error Adding Record\";\r\n";
    $php_code .= "            print mysql_info();\r\n";
    $php_code .= "            print mysql_error();\r\n";
    $php_code .= "            exit;\r\n";
    $php_code .= "         }\r\n";
    $php_code .= "      } else if ( \$FORM['f'] == \"edit\" ) {\r\n";
    $php_code .= "         foreach ( \$FORM['{$form_field_group_name}'] as \$field_name => \$value ) {\r\n";
    $php_code .= "            if ( is_array(\$value) ) {\r\n";
    $php_code .= "               \$update_fields[\$field_name] = join( \",\", \$value );\r\n";
    $php_code .= "            } else {\r\n";
    $php_code .= "               #if ( trim(\$value) ) {\r\n";
    $php_code .= "                  \$update_fields[\$field_name] = trim(\$value);\r\n";
    $php_code .= "               #}\r\n";
    $php_code .= "            }\r\n";
    $php_code .= "         }\r\n";
    if (!$form_properties['single_page']) {
        $php_code .= "         if ( \$FORM['submit'] == \"Save\" ) {\r\n";
        $php_code .= "            mysql_upd_record( \"\", \$table_name, \$update_fields, array( \$primary_key_field => \$FORM['pri_key'] ) );\r\n";
        #$php_code .= "            mysql_upd_record( \"\", \$table_name, \$update_fields, array( \"$primary_key_field\" => \$FORM['pri_key'] ) );\r\n";
        $php_code .= "         } else if ( \$FORM['submit'] == \"Delete\" ) {\r\n";
        $php_code .= "            mysql_del_record( \"\", \$table_name, array( \$primary_key_field => \$FORM['pri_key'] ) );\r\n";
        $php_code .= "         }\r\n";
    } else {
        $php_code .= "         mysql_upd_record( \"\", \$table_name, \$update_fields, array( 'id' => \$FORM['id'] ) );\r\n";
    }
    $php_code .= "      }\r\n";
    if (!$form_properties['single_page']) {
        if ($form_properties['popup_save']) {
            $php_code .= "      close_page();\r\n";
        } else {
            $php_code .= "      header( \"location: \$FORM[ref_url]\" );\r\n";
        }
        $php_code .= "      exit;\r\n";
        $php_code .= "      \$FORM['submit'] = \"\";\r\n";
    } else {
        $php_code .= "      header( \"location: index.php\" );\r\n";
        $php_code .= "      exit;\r\n";
    }
    $php_code .= "   }\r\n\r\n";
    //      $php_code .= "   \$FORM['start'] = ( \$FORM['start'] == \"\" OR \$FORM['start'] < 0 ) ? \"0\" : \$FORM['start'];\r\n";
    //      $php_code .= "   \$edit_record = mysql_extract_records_where( \"\", \$table_name, \"\", \"*\", \"\", \"\$FORM[start],1\" );\r\n";
    //      $php_code .= "   \$FORM['$form_field_group_name'] = \$edit_record[1];\r\n\r\n";
    if (!$form_properties['single_page']) {
        $php_code .= "   \$filter_operators = array( '=' => '', '!=' => '', '<' => '', '>' => '', 'regexp' => '~' );\r\n";
        $php_code .= "   \$total_records = mysql_count_query_records( \"\", \$table_name, \"\" );\r\n";
        $php_code .= "   if ( \$FORM['f'] == \"add\" OR \$total_records == 0 ) {\r\n";
    } else {
        $php_code .= "   if ( \$FORM['f'] == \"add\" ) {\r\n";
    }
    # loads the default entries from db into form
    foreach ($table_structure as $key => $array) {
        if ($array['default']) {
            #$FORM['fieldz'][$key] = $array['default'];
            $php_code .= "      \$FORM['{$form_field_group_name}']['{$key}'] = \"{$array['default']}\";\r\n";
        }
    }
    if (!$form_properties['single_page']) {
        $php_code .= "\r\n";
        $php_code .= "      if ( \$total_records ) {\r\n";
        $php_code .= "         \$FORM['start'] = \$total_records;\r\n";
        $php_code .= "         \$total_records = \$FORM['start'] + 1;\r\n";
        $php_code .= "      }\r\n";
        $php_code .= "      \$save_type = \"add\";\r\n";
        $php_code .= "   } else {\r\n";
        $php_code .= "      if ( \$FORM['where_data'] ) {\r\n";
        $php_code .= "         \$where_clause = \$FORM['where_data'];\r\n";
        $php_code .= "\t\t\t\$recount_total_records = 1;\r\n";
        $php_code .= "      } else if ( \$FORM['filter_field'] ) {\r\n";
        $php_code .= "         \$FORM['filter_data'] = mysql_real_escape_string( \$FORM['filter_data'] );\r\n";
        $php_code .= "         \$where_clause[\"`\$FORM[filter_field]` \$FORM[filter_operator] '\$FORM[filter_data]'\"] = '';\r\n";
        $php_code .= "\t\t\t\$recount_total_records = 1;\r\n";
        $php_code .= "      } else if ( \$FORM['filter_operator'] AND \$FORM['filter_data'] ) {\r\n";
        $php_code .= "         foreach ( \$table_structure as \$key => \$record ) {\r\n";
        $php_code .= "            if ( \$FORM['filter_operator'] == \"=\" ) {\r\n";
        $php_code .= "               # change single slash to double in order for like to handle it properly\r\n";
        $php_code .= "               \$new_value = str_replace( chr(92), chr(92).chr(92), \$FORM['filter_data'] );\r\n";
        $php_code .= "               \$where_clause_filter[] = \"`\$key` LIKE \\\"%\" . mysql_real_escape_string( \$new_value ) . \"%\\\"\";\r\n";
        $php_code .= "            } else {\r\n";
        $php_code .= "               \$where_clause_filter[] = \"`\$key` \$FORM[filter_operator] '\" . mysql_real_escape_string( \$FORM['filter_data'] ) . \"'\";\r\n";
        $php_code .= "            }\r\n";
        $php_code .= "         }\r\n";
        $php_code .= "         \$where_clause[\"( \" . join( \" OR \", \$where_clause_filter ) . \" )\"] = '';\r\n";
        $php_code .= "\t\t\t\$recount_total_records = 1;\r\n";
        $php_code .= "      }\r\n";
        $php_code .= "      if ( \$recount_total_records ) {\r\n";
        $php_code .= "         \$total_records = mysql_count_query_records( \"\", \$table_name, \$where_clause );\r\n";
        $php_code .= "      }\r\n\r\n";
        $php_code .= "      if ( \$FORM['starts'] ) \$FORM['start'] = \$FORM['starts'] - 1;\r\n";
        $php_code .= "      \$FORM['start'] = ( \$FORM['start'] == \"\" OR \$FORM['start'] < 0 ) ? \"0\" : \$FORM['start'];\r\n";
        $php_code .= "      \$edit_record = mysql_extract_records_where( \"\", \$table_name, \$where_clause, \$sql_field_names, \"\", \"\$FORM[start],1\" );\r\n";
        $php_code .= "      if ( \$where_clause AND \$edit_record == 1 ) {\r\n";
        $php_code .= "         print \"No Records Found\";\r\n";
        $php_code .= "         exit;\r\n";
        $php_code .= "      }\r\n";
        $php_code .= "      if ( \$FORM['start'] >= \$total_records ) {\r\n";
        $php_code .= "         header( \"Location: \" . \$_SERVER['PHP_SELF'] . \"?start=\" . (\$total_records - 1) );\r\n";
        $php_code .= "         exit;\r\n";
        $php_code .= "      }\r\n";
        $php_code .= "      \$FORM['fieldz'] = \$edit_record[1];\r\n";
        $php_code .= "      \$primary_key_id = \$edit_record[1][\$primary_key_field];\r\n";
        $php_code .= "      \$save_type = \"edit\";\r\n";
        $php_code .= "   }\r\n";
    } else {
        $php_code .= "   } else {\r\n";
        $php_code .= "      \$FORM['{$form_field_group_name}'] = mysql_extract_record_id( \"\", \$table_name, array( 'id' => \$FORM['id'] ) );\r\n";
        $php_code .= "   }\r\n";
    }
    $php_code .= "\r\n";
    //      print "<pre>";
    //      print_r( $table_structure );
    //      print "</pre>";
    //      print "<pre>";
    //      print_r( $fields_to_display_properties );
    //      print "</pre>";
    foreach ($fields_to_display as $field_name) {
        $field_structure = $table_structure[$field_name];
        $field_properties = $fields_to_display_properties[$field_name];
        #$field_properties = array_merge( $field_structure, $field_properties );
        if ($field_properties['fkey']) {
            if (is_string($field_properties['fkey'])) {
                $fkey_fields = explode(",", $field_properties['fkey']);
                if (!$fkey_fields[3]) {
                    $fkey_fields[3] = $fkey_fields[2];
                }
                $field_properties['fkey'] = array($connect_id, 'DB' => $fkey_fields[0], 'TB' => $fkey_fields[1], 'FIELD_KEY' => $fkey_fields[2], 'FIELD_DISPLAY' => $fkey_fields[3], 'WHERE_CLAUSE' => $fkey_fields[4], 'ORDER_BY' => $fkey_fields[5]);
            }
            $fkey_data = $field_properties['fkey'];
            if (!preg_match("/field[\\[<]|fk(?:ey)?[\\[<]/", $fkey_data['FIELD_DISPLAY']) and strtolower($fkey_data['DB']) == strtolower($current_database)) {
                $php_code .= "   \${$field_name}" . "_list = mysql_create_associate_array( \"\", \"{$fkey_data['TB']}\", \"{$fkey_data['FIELD_KEY']},{$fkey_data['FIELD_DISPLAY']}\" );\r\n";
            } else {
                $php_code .= "   \${$field_name}" . "_list = mysql_get_foreign_key_list( \"\", \"{$fkey_data['DB']}\", \"{$fkey_data['TB']}\", \"{$fkey_data['FIELD_KEY']}\", \"{$fkey_data['FIELD_DISPLAY']}\", \"{$fkey_data['WHERE_CLAUSE']}\", \"{$fkey_data['ORDER_BY']}\" );\r\n";
            }
            $field_properties['type'] = "enum";
            $field_properties['size'] = "";
        } else {
            if ($field_properties['build_cat']) {
                if ($field_properties['build_cat']['fkey']) {
                    $field_properties['fkey'] = $field_properties['build_cat']['fkey'];
                    if (is_string($field_properties['build_cat'])) {
                        $fkey_fields = explode(",", $field_properties['fkey']);
                        if (!$fkey_fields[3]) {
                            $fkey_fields[3] = $fkey_fields[2];
                        }
                        $field_properties['fkey'] = array($connect_id, 'DB' => $fkey_fields[0], 'TB' => $fkey_fields[1], 'FIELD_KEY' => $fkey_fields[2], 'FIELD_DISPLAY' => $fkey_fields[3], 'WHERE_CLAUSE' => $fkey_fields[4], 'ORDER_BY' => $fkey_fields[5]);
                    }
                    if ($field_properties['fkey']['FIELDS']) {
                        $fields = $field_properties['fkey']['FIELDS'];
                    } else {
                        if (!$field_properties['fkey']['FIELD_DISPLAY']) {
                            $field_properties['fkey']['FIELD_DISPLAY'] = $field_properties['fkey']['FIELD_KEY'];
                        }
                        $fields = $field_properties['fkey']['FIELD_KEY'] . "," . $field_properties['fkey']['FIELD_DISPLAY'];
                        if ($fields == "id,name") {
                            $fields = "id,parent_id,name";
                        } else {
                            if ($fields == "code,name") {
                                $fields = "code,parent_code,name";
                            }
                        }
                    }
                    if ($field_properties['fkey']['OPTIONS']) {
                        $options = $field_properties['fkey']['OPTIONS'];
                    } else {
                        if ($field_properties['fkey']['FIELD_KEY'] == "code" and $field_properties['fkey']['OPTIONS']) {
                            $options = array('use_codes' => "Y");
                        }
                    }
                    $field_properties['build_cat'] = array('DB' => $field_properties['fkey']['DB'], 'TB' => $field_properties['fkey']['TB'], 'FIELDS' => $fields, 'WHERE_CLAUSE' => $field_properties['fkey']['WHERE_CLAUSE'], 'ORDER_BY' => $field_properties['fkey']['ORDER_BY'], 'SEPARATOR' => "||", 'INDENT' => 1, 'OPTIONS' => $options);
                }
                $category_data = $field_properties['build_cat'];
                if (strtolower($category_data['DB']) != strtolower($current_database) and $category_data['DB'] != "") {
                    $php_code .= "   mysql_change_db( \"\", \"{$category_data['DB']}\" );\r\n";
                }
                $php_code .= "   \${$field_name}_category_records = mysql_make_assoc_array( \"\", \"{$category_data['TB']}\", \"{$category_data['FIELDS']}\", \"{$category_data['WHERE_CLAUSE']}\", \"{$category_data['ORDER_BY']}\" );\r\n";
                $php_code .= "   \${$field_name}_list = build_category_paths( \${$field_name}_category_records, \"" . addcslashes($category_data['SEPARATOR'], "\"\\") . "\", \"{$category_data['INDENT']}\", " . preg_replace("/;\$/", "", array_to_php($category_data['OPTIONS'])) . " );\r\n";
                if (strtolower($category_data['DB']) != strtolower($current_database) and $category_data['DB'] != "") {
                    $php_code .= "   mysql_change_db( \"\", \"{$current_database}\" );\r\n";
                }
                $field_properties['type'] = "enum";
                $field_properties['size'] = "";
            } else {
                if ($field_properties['enum']) {
                    #$php_code .= "   \$$field_name" . "_list = array( '" . join( "' => \"\", '", $field_properties['enum'] ) . "' => \"\" );\r\n";
                    $php_code .= "   \${$field_name}" . "_list = " . array_to_php($field_properties['enum']) . "\r\n";
                } else {
                    if ($field_structure['type'] == "set" or $field_structure['type'] == "enum") {
                        $php_code .= "   \${$field_name}" . "_list = array( '" . join("' => \"\", '", $field_structure['size']) . "' => \"\" );\r\n";
                    }
                }
            }
        }
        if ($field_properties['multi_select'] or $field_structure['type'] == "set") {
            $php_code .= "   \$FORM['{$form_field_group_name}']['{$field_name}'] = explode( ',', \$FORM['fieldz']['{$field_name}'] );\r\n";
        }
        $field_properties['form_field_group_name'] = $form_field_group_name;
        if (!$field_properties['title']) {
            $field_display_name = convert_field_name($field_name);
        } else {
            $field_display_name = $field_properties['title'];
        }
        $field_properties['name'] = $field_name;
        if (!$form_properties['print_version']) {
            $form_field_html = mysql_generate_form_field($connect_id, $table_name, $field_name, $field_properties, "", $table_structure, 2);
        } else {
            /* $form_field_html = "<?php print \$FORM['$form_field_group_name']['$field_name'] ?>"; */
            if ($field_properties['fkey'] or $field_properties['build_cat']) {
                $form_field_html = "<?php print \${$field_name}_list[\$db_record['{$field_name}']] ?>";
            } else {
                if ($field_structure['type'] == "set") {
                    /* $form_field_html = "<?php print join( \", \", \$db_record['$field_name'] ) ?>"; */
                    $form_field_html = "<?php print str_replace( \",\", \", \", \$db_record['{$field_name}'] ) ?>";
                } else {
                    $form_field_html = "<?php print \$db_record['{$field_name}'] ?>";
                }
            }
        }
        # adds necessary code to textarea are shown correctly in both opera and firefix/ie
        /* preg_match_all( "/(<textarea name=\"[^\"]+\" cols=\"[^\"]+\" rows=\")([^\"]+)(\"[^>]*>)/", $form_field_html, $preg_results, PREG_SET_ORDER );
           foreach ( $preg_results as $array ) {
              $form_field_html = str_replace( $array[0], $array[1]."<?php if ( preg_match( \"/Opera[\\/ ]\\d+\\.\\d+/\", \$_SERVER['HTTP_USER_AGENT'] ) ) { print '$array[2]'; } else { print '" . ($array[2]-1) . "'; } ?>".$array[3], $form_field_html );
           } */
        if (isset($field_properties['print_value'])) {
            $form_field_html = "<?php if ( \$save_type == \"add\" ) { ?>{$form_field_html}<?php } else { print \$FORM['{$form_field_group_name}']['{$field_name}']; } ?>";
        }
        $html_code .= "<tr><td valign=\"top\" class=\"tb_title\"><b>{$field_display_name}</b></td><td class=\"tb_field\">{$form_field_html}</td></tr>\r\n";
        #$html_code .= "<tr><td valign=\"top\" style=\"padding: 7 0 5 5\"><b>$field_display_name</b></td><td style=\"padding: 5 5 5 0\">$form_field_html</td></tr>\r\n";
        $html_code .= '<tr><td colspan="2" bgcolor="#808080"><img src="/images/non.gif" width="1" height="1"></td></tr>' . "\r\n";
    }
    $php_code .= "?>\r\n";
    //      $submit_record_title = "Submit Record";
    //      if ( $form_properties['submit_button_title'] ) {
    //         $submit_record_title = $form_properties['submit_button_title'];
    //      }
    //      $html_code .= '<tr><td colspan="2" align="center"><input type="submit" name="submit" value="' . $submit_record_title . '">';
    //      if ( $form_properties['other_submit_buttons'] ) {
    //         $other_submit_button_texts = explode( ",", $form_properties['other_submit_buttons'] );
    //         foreach ( $other_submit_button_texts as $other_submit_button_text ) {
    //            $html_code .= ' <input type="submit" name="submit" value="' . $other_submit_button_text . '">';
    //         }
    //      }
    //      if ( !$form_properties['no_reset'] ) {
    //         $html_code .= ' <input type="reset" name="reset" value="Reset Fields"></td></tr>' . "\r\n";
    //      }
    if (!$form_properties['single_page']) {
        $html_code .= "<tr><td colspan=\"2\" align=\"center\"><table border=\"0\" cellspacing=\"10\" cellpadding=\"0\">\r\n";
        $html_code .= "   <tr>\r\n";
        $html_code .= "      <td style=\"padding-top: 5px\"><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Save\">\r\n";
        $html_code .= "      <input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Delete\">\r\n";
        $html_code .= "         <input name=\"pri_key\" type=\"hidden\" id=\"pri_key\" value=\"<?php print \$primary_key_id ?>\">\r\n";
        $html_code .= "         <input name=\"f\" type=\"hidden\" id=\"f\" value=\"<?php print \$save_type ?>\"> \r\n";
        $html_code .= "         <input type=\"reset\" name=\"Reset\" value=\"Revert\"></td>\r\n";
        $html_code .= "         </tr>\r\n";
        $html_code .= "      </table></td>\r\n";
        $html_code .= "   </tr>\r\n";
        $html_code .= "   <input name=\"ref_url\" type=\"hidden\" value=\"<?php print \$_SERVER['REQUEST_URI'] ?>\">\r\n";
    } else {
        $html_code .= "<tr style=\"padding-top: 10px\"><td colspan=\"2\" align=\"center\"><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Save\">\r\n";
        $html_code .= "   <input name=\"id\" type=\"hidden\" value=\"<?php print \$FORM['id'] ?>\">\r\n";
        $html_code .= "   <input name=\"f\" type=\"hidden\" value=\"<?php print \$FORM['f'] ?>\"></td>\r\n";
        $html_code .= "</tr>\r\n";
    }
    if ($fields_to_hide) {
        //         if ( !$form_properties['single_page'] ) {
        $fields_to_hide = "\"" . join("\", \"", $fields_to_hide) . "\"";
        $html_code .= "<?php\r\n";
        $html_code .= "      \$hidden_fields = array( {$fields_to_hide} );\r\n";
        $html_code .= "      if ( \$hidden_fields ) {\r\n";
        $html_code .= "         foreach ( \$hidden_fields as \$name ) {\r\n";
        $html_code .= "            print \"<input name=\\\"{$form_field_group_name}[\$name]\\\" type=\\\"hidden\\\" value=\\\"\" . \$FORM['fieldz'][\$name] . \"\\\">\";\r\n";
        $html_code .= "         }\r\n";
        $html_code .= "      }\r\n";
        $html_code .= "?>\r\n";
        //         } else {
        //         }
    }
    $html_code .= "</form>\r\n";
    $html_code .= "</table>\r\n";
    if (!$form_properties['single_page']) {
        $html_code .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">\r\n";
        $html_code .= "<?php\r\n";
        $html_code .= "      \$url_parse = parse_url( \$_SERVER['REQUEST_URI'] );\r\n";
        $html_code .= "      parse_str( \$url_parse['query'], \$post_fields );\r\n";
        $html_code .= "      unset( \$post_fields['f'], \$post_fields['start'], \$post_fields['starts'] );\r\n";
        $html_code .= "      \$fields = array( \"filter_field\", \"filter_operator\", \"filter_data\", \"filter_null\" );\r\n";
        $html_code .= "      if ( \$post_fields ) {\r\n";
        $html_code .= "         foreach ( \$post_fields as \$name => \$value ) {\r\n";
        $html_code .= "            \$post_fields_html .= \"<input name=\\\"\$name\\\" type=\\\"hidden\\\" value=\\\"\$value\\\">\";\r\n";
        $html_code .= "         }\r\n";
        $html_code .= "      }\r\n";
        $html_code .= "?>\r\n";
        $html_code .= "   <tr>\r\n";
        $html_code .= "      <td align=\"center\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"arial_10pt\">\r\n";
        $html_code .= "            <tr>\r\n";
        $html_code .= "               <td>Record:</td>\r\n";
        $html_code .= "               <?php if ( \$FORM['start'] != 0 ) { ?>\r\n";
        $html_code .= "               <form>\r\n";
        $html_code .= "               <?php } ?>\r\n";
        $html_code .= "                  <td><input type=\"submit\" value=\"|<\"><input name=\"start\" type=\"hidden\" id=\"start\" value=\"0\"></td>\r\n";
        $html_code .= "                  <?php print \$post_fields_html ?>\r\n";
        $html_code .= "               </form>\r\n";
        $html_code .= "               <?php if ( \$FORM['start'] != 0 ) { ?>\r\n";
        $html_code .= "               <form>\r\n";
        $html_code .= "               <?php } ?>\r\n";
        $html_code .= "                  <td><input type=\"submit\" value=\"<\"><input name=\"start\" type=\"hidden\" id=\"start\" value=\"<?php print \$FORM['start'] - 1 ?>\"></td>\r\n";
        $html_code .= "                  <?php print \$post_fields_html ?>\r\n";
        $html_code .= "               </form>\r\n";
        $html_code .= "               <?php if ( \$total_records != 0 ) { ?>\r\n";
        $html_code .= "               <form>\r\n";
        $html_code .= "               <?php } else { \$FORM['start'] = -1; } ?>\r\n";
        $html_code .= "                  <td><input name=\"starts\" type=\"text\" id=\"starts\" value=\"<?php print \$FORM['start'] + 1 ?>\" size=\"6\"></td>\r\n";
        $html_code .= "                  <?php print \$post_fields_html ?>\r\n";
        $html_code .= "               </form>\r\n";
        $html_code .= "               <?php if ( \$FORM['start'] < (\$total_records-1) ) { ?>\r\n";
        $html_code .= "               <form>\r\n";
        $html_code .= "               <?php } ?>\r\n";
        $html_code .= "                  <td><input type=\"submit\" value=\">\"><input name=\"start\" type=\"hidden\" id=\"start\" value=\"<?php print \$FORM['start'] + 1 ?>\"></td>\r\n";
        $html_code .= "                  <?php print \$post_fields_html ?>\r\n";
        $html_code .= "               </form>\r\n";
        $html_code .= "               <?php if ( \$total_records != 0 AND \$FORM['start'] < (\$total_records-1) ) { ?>\r\n";
        $html_code .= "               <form>\r\n";
        $html_code .= "               <?php } ?>\r\n";
        $html_code .= "                  <td><input type=\"submit\" value=\">|\"><input name=\"start\" type=\"hidden\" id=\"start\" value=\"<?php print \$total_records - 1 ?>\"></td>\r\n";
        $html_code .= "                  <?php print \$post_fields_html ?>\r\n";
        $html_code .= "               </form>\r\n";
        $html_code .= "               <form>\r\n";
        $html_code .= "                  <td><input type=\"submit\" value=\">*\"><input name=\"f\" type=\"hidden\" id=\"f\" value=\"add\"></td>\r\n";
        $html_code .= "               </form>\r\n";
        $html_code .= "               <td>of <?php print \$total_records ?></td>\r\n";
        $html_code .= "            </tr>\r\n";
        $html_code .= "         </table></td>\r\n";
        $html_code .= "   </tr>\r\n";
        $html_code .= "   <tr>\r\n";
        $html_code .= "      <td><img src=\"/images/non.gif\" width=\"1\" height=\"10\"></td>\r\n";
        $html_code .= "   </tr>\r\n";
        $html_code .= "</table>\r\n";
        $html_code .= "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"arial_10pt\">\r\n";
        $html_code .= "   <tr> \r\n";
        $html_code .= "      <td colspan=\"2\" bgcolor=\"#808080\"><img src=\"../images/non.gif\" width=\"1\" height=\"1\"></td>\r\n";
        $html_code .= "   </tr>\r\n";
        $html_code .= "   <tr> \r\n";
        $html_code .= "      <td colspan=\"2\"><img src=\"../images/non.gif\" width=\"1\" height=\"10\"></td>\r\n";
        $html_code .= "   </tr>\r\n";
        $html_code .= "   <tr> \r\n";
        $html_code .= "      <form>\r\n";
        $html_code .= "         <td style=\"padding-left: 10px\">Quick Filter \r\n";
        $html_code .= "            <?php if ( \$FORM['filter_operator'] ) { ?>\r\n";
        $html_code .= "            <span class=\"arial_11px\">[<a href=\"<?php print \$_SERVER['PHP_SELF']; ?>?filter_data=<?php print \$FORM['filter_data'] ?>\">Clear Filter</a>]</span>\r\n";
        $html_code .= "            <?php } ?>\r\n";
        $html_code .= "            <br> <select name=\"filter_field\">\r\n";
        $html_code .= "               <option value=\"\">Field Name</option>\r\n";
        $html_code .= "               <?php print array_to_html_options( \$filter_field_names, \$FORM['filter_field'], \"values\" ) ?> </select> <select name=\"filter_operator\" id=\"filter_operator\">\r\n";
        $html_code .= "               <?php print array_to_html_options( \$filter_operators, \$FORM['filter_operator'] ) ?> </select> <input name=\"filter_data\" type=\"text\" id=\"filter_data\" size=\"15\" value=\"<?php print \$FORM['filter_data'] ?>\"> \r\n";
        $html_code .= "            <input type=\"submit\" value=\"Go\"></td>\r\n";
        $html_code .= "      </form>\r\n";
        $html_code .= "      <form>\r\n";
        $html_code .= "         <td align=\"right\" style=\"padding-right: 10px\">Where Statement<br> <input name=\"where_data\" type=\"text\" id=\"where_data\" value=\"<?php print htmlspecialchars( \$FORM['where_data'] ) ?>\"> <input type=\"submit\" value=\"Go\"></td>\r\n";
        $html_code .= "      </form>\r\n";
        $html_code .= "   </tr>\r\n";
        $html_code .= "</table>\r\n";
    }
    $table_width = $form_properties['table_width'] ? $form_properties['table_width'] : "98%";
    $table_class = $form_properties['table_class'] ? "class='" . $form_properties['table_class'] . "'" : "";
    $css_code .= "<style type=\"text/css\">\r\n";
    $css_code .= "<!--\r\n";
    if (!$form_properties['single_page']) {
        $css_code .= "   .arial_11px { font-family: Arial; font-size: 11px; line-height: normal; }\r\n";
        $css_code .= "   .arial_10pt { font-family: Arial; font-size: 10pt; line-height: normal; }\r\n";
        $css_code .= "   .verdana_10px { font-family: Verdana; font-size: 10px; }\r\n";
        $css_code .= "   .verdana_09px { font-family: Verdana; font-size: 9px; }\r\n";
    }
    $css_code .= "   .tb_title { padding: 7px 0 5px 5px }\r\n";
    $css_code .= "   .tb_field { padding: 5px 5px 5px 0 }\r\n";
    $css_code .= "-->\r\n";
    $css_code .= "</style>\r\n";
    $result = '<table width="' . $table_width . '" border="0" cellspacing="0" cellpadding="0" align="center" style="font-family: Arial; font-size: 10pt;" ' . $table_class . '>' . "\r\n";
    if ($form_properties['popup_save']) {
        $result .= '<form method="post" target="_blank" action="<?php print $_SERVER[\'PHP_SELF\'] ?>">' . "\r\n";
    } else {
        $result .= '<form method="post" action="<?php print $_SERVER[\'PHP_SELF\'] ?>">' . "\r\n";
    }
    $result .= '<tr><td colspan="2"><img src="/images/non.gif" width="1" height="5"></td></tr><tr></tr>' . "\r\n";
    $result .= $html_code;
    #$result .= '<tr><td colspan="2"><img src="/images/non.gif" width="1" height="5"></td></tr><tr></tr>' . "\r\n";
    #$result .= '</table>';
    #$result = '<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">' . $html_code . '</table>';
    $html_start = '<html>' . "\r\n";
    $html_start .= '<head>' . "\r\n";
    $html_start .= "<title>Add/Edit {$table_name} : {$connection_parameters['database_name']}</title>\r\n";
    $html_start .= '</head>' . "\r\n";
    $html_start .= '<body>' . "\r\n";
    $html_end = '</body>' . "\r\n";
    $html_end .= '</html>' . "\r\n";
    $output_code = $php_code . $html_start . $css_code . $result . $html_end;
    if ($show_output_code) {
        header("Content-type: text/html");
        $output_code = str_replace(" include( \"", " #include( \"", $output_code);
        $temp_file = tempnam("/tmp", gmdate("Y-m-d_H:i:s") . "_" . rand(0, 100000));
        $handle = fopen($temp_file, "w");
        fwrite($handle, $output_code);
        fclose($handle);
        if (!function_exists(array_to_html_options)) {
            function array_to_html_options($associate_array, $selected_item = array())
            {
                return associate_array_to_html_options($associate_array, $selected_item);
            }
        }
        include $temp_file;
        exit;
    }
    return $output_code;
}