}
 if (isset($_POST['acc_view_create_doit'])) {
     $s_viewdefs['source'] = trim($_POST['def_view_source']);
     $s_viewdefs['check'] = isset($_POST['def_view_check']) ? 'yes' : 'no';
     if (($vname = create_view($s_viewdefs)) == TRUE) {
         $s_tables[$vname] = array('status' => 'close', 'is_view' => TRUE);
         $s_viewdefs = array('name' => '', 'source' => '', 'check' => 'no');
         $s_tables_valid = FALSE;
     } else {
         $view_add_flag = TRUE;
     }
 }
 // the Modify button
 if (isset($_POST['acc_view_mod']) && $_POST['acc_modview_name'] != '') {
     $vname = $_POST['acc_modview_name'];
     $vsource = get_view_source($vname);
     $s_viewdefs = array('name' => $vname, 'source' => 'CREATE VIEW ' . $vname . ' (' . implode(', ', table_columns($vname)) . ")\nAS\n" . str_replace('WITH CHECK OPTION', '', $vsource), 'check' => stristr($vsource, 'WITH CHECK OPTION') !== FALSE ? 'yes' : 'no');
     $viewdefs = $s_viewdefs;
     $view_mod_flag = TRUE;
 }
 // modifying a View was canceled
 if (isset($_POST['acc_modview_cancel'])) {
     $s_viewdefs = array('name' => '', 'source' => '', 'check' => 'no');
 }
 // modify the View
 if (isset($_POST['acc_modview_doit'])) {
     $viewdefs['source'] = get_magic_quotes_gpc() ? stripslashes(trim($_POST['def_view_source'])) : $_POST['def_view_source'];
     $viewdefs['check'] = isset($_POST['def_view_check']) ? 'yes' : 'no';
     if (drop_view($s_viewdefs['name'])) {
         if (create_view($viewdefs)) {
             unset($s_tables[$s_viewdefs['name']]);
function get_opened_view($name, $title, $url)
{
    global $dbhandle, $s_fields, $tb_strings, $acc_strings, $ptitle_strings;
    $source = get_view_source($name);
    $red_triangle = get_icon_path(DATAPATH, ICON_SIZE) . 'red_triangle.png';
    $html = <<<EOT
        <nobr>
          <a href="{$url}" class="dtitle"><img src="{$red_triangle}" alt="{$ptitle_strings['Close']}" title="{$ptitle_strings['Close']}" border="0" hspace="7">{$title}</a>
        </nobr>
        <nobr>
        <table class="table table-hover">
          <tr>
            <td width="26">
            </td>
            <td valign="top">
              <table class="table table-bordered">
EOT;
    $cols = array('Name', 'Type', 'Length', 'Prec', 'Scale', 'Charset', 'Collate');
    $html .= "              <tr align=\"left\">\n";
    foreach ($cols as $idx) {
        $html .= '                <th class="detail"><nobr>' . $tb_strings[$idx] . "</nobr></th>\n";
    }
    $html .= "              </tr>\n";
    foreach ($s_fields[$name] as $field) {
        $size_str = $field['type'] == 'VARCHAR' || $field['type'] == 'CHARACTER' ? $field['size'] : '&nbsp;';
        $prec_str = isset($field['prec']) ? $field['prec'] : '&nbsp;';
        $scale_str = isset($field['scale']) ? $field['scale'] : '&nbsp;';
        $char_str = isset($field['charset']) ? $field['charset'] : '&nbsp;';
        $coll_str = isset($field['collate']) ? $field['collate'] : '&nbsp;';
        $html .= "              <tr>\n                <td class=\"detail\">{$field['name']}</td>\n\t        <td class=\"detail\">{$field['type']}</td>\n\t        <td align=\"right\" class=\"detail\">{$size_str}</td>\n\t        <td align=\"right\" class=\"detail\">{$prec_str}</td>\n\t        <td align=\"right\" class=\"detail\">{$scale_str}</td>\n    \t        <td class=\"detail\">{$char_str}</td>\n                <td class=\"detail\">{$coll_str}</td>\n              </tr>\n";
    }
    $html .= "            </table>\n          </td>\n";
    $html .= "         <td>&nbsp;</td>\n" . "          <td valign=\"top\">\n" . "            <table border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n" . "              <tr align=\"left\">\n" . '                <th class="detail">' . $acc_strings['Source'] . "</th>\n" . "              </tr>\n" . "              <tr>\n" . '                <td class="detail"><pre>' . $source . "</pre></td>\n" . "              </tr>\n" . "            </table>\n" . "          </tr>\n" . "        </td>\n" . "      </table>\n" . "    </nobr>\n";
    return $html;
}