if (isset($_GET['where'])) {
        $where = $_GET['where'];
        $where_url = '&where=' . SafeDB($_GET['where'], 255, str);
    }
    $edit = true;
    $index = SafeEnv($_GET['index'], 255, int);
    $rows = System::database()->Select($table, $where);
    $row = $rows[$index];
}
$i = 0;
foreach ($columns as $col) {
    if ($edit) {
        $val = HtmlChars($row[$columns[$i]['name']]);
        $cap = 'Сохранить';
        $title = 'Редактирование записи';
    } else {
        $val = '';
        $cap = 'Добавить';
        $title = 'Добавление записи';
    }
    if (strtolower($col['type']) != 'text') {
        FormRow('<font color="#0000FF">' . (isset($col['auto_increment']) && $col['auto_increment'] == true ? '<u>' . $col['name'] . '</u>' : $col['name']) . '</font>' . '<br /><font color="#666666">' . $col['type'] . (isset($col['length']) ? '(' . $col['length'] . ')</font>' : '</font>'), System::admin()->Edit($col['name'], $val, false, 'style="width: 400px;"' . ($i == 0 ? ' class="autofocus"' : '')));
    } else {
        FormRow('<font color="#0000FF">' . $col['name'] . '</font>', System::admin()->TextArea($col['name'], $val, 'style="width: 400px; height: 200px;"' . ($i == 0 ? ' class="autofocus"' : '')));
    }
    $i++;
}
AddCenterBox($title);
AddForm('<form action="' . ADMIN_FILE . '?exe=dbadmin&a=' . ($edit ? 'editsave' : 'insertsave') . '&name=' . $table . ($edit ? '&index=' . $index : '') . $where_url . $back . '" method="post">', ($edit ? System::site()->Button('Отмена', 'onclick="history.go(-1)"') : '') . System::admin()->Submit($cap));
AdminFdbAdminGenTableMenu($table);
<?php

/*
 * LinkorCMS 1.4
 * © 2012 LinkorCMS Development Group
 */
if (!defined('VALID_RUN')) {
    header("HTTP/1.1 404 Not Found");
    exit;
}
$table = SafeEnv($_GET['name'], 255, str);
$index = SafeEnv($_GET['index'], 11, int);
$where = '';
if (isset($_GET['where'])) {
    $where = $_GET['where'];
}
$rows = System::database()->Select($table, $where);
$row = $rows[$index];
$row2 = array();
$columns = System::database()->GetTableColumns($table);
foreach ($columns as $col) {
    $row2[] = $row[$col['name']];
}
$row2 = SafeEnv($row2, 0, str);
$code_vals = Values($row2);
$install_code = "System::database()->Insert('{$table}',\"{$code_vals}\");" . EOL;
System::admin()->AddCenterBox('PHP код вставки');
System::admin()->FormRow('Установка', $site->TextArea('code', $install_code, 'style="width: 800px; height: 200px;" class="autofocus selectall"'));
System::admin()->AddForm('', $site->Button('Назад', 'onclick="history.go(-1);"'));
AdminFdbAdminGenTableMenu(SafeDB($table, 255, str));
        $col['default'] = '';
    }
    if (!isset($col['attributes'])) {
        $col['attributes'] = '';
    }
    if (!isset($col['auto_increment'])) {
        $col['auto_increment'] = false;
    }
    $func = '';
    $func .= SpeedButton('Просмотреть информацию для установки', ADMIN_FILE . '?exe=dbadmin&a=viewcollinfo&name=' . $name . '&collid=' . $i, 'images/admin/info.png');
    $func .= System::admin()->SpeedConfirm('Удалить колонку', ADMIN_FILE . '?exe=dbadmin&a=deletecoll&name=' . $name . '&collid=' . $i, 'images/admin/delete.png', 'Удалить колонку?');
    $text .= '<tr>
	<td>' . $i . '</td>
	<td>' . SafeDB($col['name'], 255, str) . '</td>
	<td>' . SafeDB($col['type'], 255, str) . (isset($col['length']) ? '(' . SafeDB($col['length'], 11, int) . ')' : '') . '</td>
	<td>' . SafeDB($col['attributes'], 255, str) . '</td>
	<td>' . ($col['notnull'] ? '<font color="#0000FF">Нет</font>' : '<font color="#FF0000">Да</font>') . '</td>
	<td>' . SafeDB($col['default'], 255, str) . '</td>
	<td>' . ($col['auto_increment'] ? '<font color="#FF0000">Да</font>' : '<font color="0000FF">Нет</a>') . '</td>
	<td>' . $func . '</td>';
    System::site()->DataAdd($selcoldata, $i, SafeDB($col['name'], 255, str), $i == $colcount);
    $i++;
}
$text .= '</table><br />';
AddCenterBox('Структура таблицы "' . $name . '"');
AddText($text);
System::admin()->FormTitleRow('Вставить колонку');
FormRow('После', System::site()->Select('toindex', $selcoldata));
AddForm('<form action="' . ADMIN_FILE . '?exe=dbadmin&a=newcoll&name=' . $name . '" method="post">', $site->Submit('Далее', 'title="Перейти к след. шагу добавления колонки."'));
AdminFdbAdminGenTableMenu($name);