Файл: api_manager/db.users.edit.php
Строк: 249
<?php
if (empty($_GET['elid'])) {
if (empty($_POST['submit'])) {
echo '<div class=content><img src="images/t-new.png" alt="." /> Создание пользователя базы данных ' . htmlentities($_GET['plid'], ENT_QUOTES, 'UTF-8') . '</div>';
echo '<form action="?func=db.users.edit&plid=' . urlencode($_GET['plid']) . '" method="post">';
echo '<div class=subhead>Имя пользователя: ';
echo ' <input name="dbusername" /></div>';
echo '<div class=subhead>Пароль: ';
echo ' <input name="dbpassword" type="password" /></div>';
echo '<div class=subhead>Подтверждение: ';
echo ' <input name="dbconfirm" type="password" /></div>';
echo '<div class=subhead><input type="checkbox" name="dbuserhost" value="on" /> Удаленный доступ</div>';
echo '<div class=subhead>Доступ к данным:</div>';
echo '<div class=subhead><input type="checkbox" name="select_priv" value="on" checked="checked" /> select</div>';
echo '<div class=subhead><input type="checkbox" name="delete_priv" value="on" checked="checked" /> delete</div>';
echo '<div class=subhead><input type="checkbox" name="insert_priv" value="on" checked="checked" /> insert</div>';
echo '<div class=subhead><input type="checkbox" name="update_priv" value="on" checked="checked" /> update</div>';
echo '<div class=subhead>Доступ к структуре:</div>';
echo '<div class=subhead><input type="checkbox" name="create_priv" value="on" /> create</div>';
echo '<div class=subhead><input type="checkbox" name="drop_priv" value="on" /> drop</div>';
echo '<div class=subhead><input type="checkbox" name="alter_priv" value="on" /> alter</div>';
echo '<div class=subhead><input type="checkbox" name="index_priv" value="on" /> index</div>';
echo '<div class=subhead>Другое:</div>';
echo '<div class=subhead><input type="checkbox" name="grant_priv" value="on" /> grant</div>';
echo '<div class=subhead><input type="checkbox" name="refer_priv" value="on" /> refer</div>';
echo '<div class=subhead><input type="checkbox" name="lock_priv" value="on" /> lock</div>';
echo '<div class=subhead><input name="submit" type="submit" value="Создать" /></div>';
echo '</form>';
} else {
if ($_POST['dbpassword'] <> $_POST['dbconfirm'] or $_POST['dbpassword'] == '') {
echo '<div class=erors>Ошибка при создании пользователя базы данных! ';
echo 'Пароль не подтвержден.</div>';
echo '<a class=subhead href="?func=db.users&elid=' . urlencode($_GET['plid']) . '"><img src=images/r_s.png> Продолжить</a>';
} else {
$dbuserhost = isset($_POST['dbuserhost'])?'on':'';
$select_priv = isset($_POST['select_priv'])?'on':'';
$delete_priv = isset($_POST['delete_priv'])?'on':'';
$insert_priv = isset($_POST['insert_priv'])?'on':'';
$update_priv = isset($_POST['update_priv'])?'on':'';
$create_priv = isset($_POST['create_priv'])?'on':'';
$drop_priv = isset($_POST['drop_priv'])?'on':'';
$alter_priv = isset($_POST['alter_priv'])?'on':'';
$index_priv = isset($_POST['index_priv'])?'on':'';
$grant_priv = isset($_POST['grant_priv'])?'on':'';
$refer_priv = isset($_POST['refer_priv'])?'on':'';
$lock_priv = isset($_POST['lock_priv'])?'on':'';
$content = api_query('https://' . $server . '/manager/ispmgr?func=db.users.edit&plid=' . urlencode($_GET['plid']) . '&select_priv=' . $select_priv . '&delete_priv=' . $delete_priv . '&insert_priv=' . $insert_priv . '&update_priv=' . $update_priv . '&create_priv=' . $create_priv . '&drop_priv=' . $drop_priv . '&alter_priv=' . $alter_priv . '&index_priv=' . $index_priv . '&grant_priv=' . $grant_priv . '&refer_priv=' . $refer_priv . '&lock_priv=' . $lock_priv . '&dbuserhost=' . $dbuserhost . '&dbconfirm=' . urlencode($_POST['dbconfirm']) . '&dbpassword=' . urlencode($_POST['dbpassword']) . '&dbusername=' . urlencode($_POST['dbusername']) . '&dbuser=newuser&sok=ok&out=xml&authinfo=' . $user['isp_login'] . ':' . $user['isp_paswd']);
$parse_xml = simplexml_load_string($content);
if (isset($parse_xml->ok)) {
echo '<div class=erors>Пользователь бызы данных успешно создан!</div>';
echo '<a class=subhead href="?func=db.users&elid=' . urlencode($_GET['plid']) . '"><img src=images/r_s.png> Продолжить</a>';
} else {
echo '<div class=erors>Ошибка при создании пользователя базы данных! Возможно такой пользователь уже существует.</div>';
echo '<a class=subhead href="?func=db.users&elid=' . urlencode($_GET['plid']) . '"><img src=images/r_s.png> Продолжить</a>';
}
}
}
} else {
$content = api_query('https://' . $server . '/manager/ispmgr?func=db.users.edit&elid=' . urlencode($_GET['elid']) . '&plid=' . urlencode($_GET['plid']) . '&out=xml&authinfo=' . $user['isp_login'] . ':' . $user['isp_paswd']);
$parse_xml = simplexml_load_string($content);
if (empty($_POST['submit'])) {
echo '<div class=content><img src="images/t-edit.png" alt="." /> Изменение пользователя базы данных ' . htmlentities($_GET['plid'], ENT_QUOTES, 'UTF-8') . '</div>';
echo '<form action="?func=db.users.edit&elid=' . urlencode($_GET['elid']) . '&plid=' . urlencode($_GET['plid']) . '" method="post">';
echo '<div class=subhead>Имя пользователя: ';
echo '<input name="dbusername" value="' . htmlentities((string)$parse_xml->dbusername, ENT_QUOTES, 'UTF-8') . '" /></div>';
echo '<div class=subhead>Пароль: ';
echo '<input name="dbpassword" type="password" /></div>';
echo '<div class=subhead>Подтверждение: ';
echo '<input name="dbconfirm" type="password" /></div>';
echo '<div class=subhead><input type="checkbox" name="dbuserhost" value="on"';
if (isset($parse_xml->dbuserhost)) {
echo ' checked="checked"';
}
echo ' /> Удаленный доступ</div>';
echo '<div class=subhead>Доступ к данным:</div>';
echo '<div class=subhead><input type="checkbox" name="select_priv" value="on"';
if (isset($parse_xml->select_priv)) {
echo ' checked="checked"';
}
echo ' /> select</div>';
echo '<div class=subhead><input type="checkbox" name="delete_priv" value="on"';
if (isset($parse_xml->delete_priv)) {
echo ' checked="checked"';
}
echo ' /> delete</div>';
echo '<div class=subhead><input type="checkbox" name="insert_priv" value="on"';
if (isset($parse_xml->insert_priv)) {
echo ' checked="checked"';
}
echo ' /> insert</div>';
echo '<div class=subhead><input type="checkbox" name="update_priv" value="on"';
if (isset($parse_xml->update_priv)) {
echo ' checked="checked"';
}
echo ' /> update</div>';
echo '<div class=subhead>Доступ к структуре:</div>';
echo '<div class=subhead><input type="checkbox" name="create_priv" value="on"';
if (isset($parse_xml->create_priv)) {
echo ' checked="checked"';
}
echo ' /> create</div>';
echo '<div class=subhead><input type="checkbox" name="drop_priv" value="on"';
if (isset($parse_xml->drop_priv)) {
echo ' checked="checked"';
}
echo ' /> drop</div>';
echo '<div class=subhead><input type="checkbox" name="alter_priv" value="on"';
if (isset($parse_xml->alter_priv)) {
echo ' checked="checked"';
}
echo ' /> alter</div>';
echo '<div class=subhead><input type="checkbox" name="index_priv" value="on"';
if (isset($parse_xml->index_priv)) {
echo ' checked="checked"';
}
echo ' /> index</div>';
echo '<div class=subhead>Другое:</div>';
echo '<div class=subhead><input type="checkbox" name="grant_priv" value="on"';
if (isset($parse_xml->grant_priv)) {
echo ' checked="checked"';
}
echo ' /> grant</div>';
echo '<div class=subhead><input type="checkbox" name="references_priv" value="on"';
if (isset($parse_xml->references_priv)) {
echo ' checked="checked"';
}
echo ' /> refer</div>';
echo '<div class=subhead><input type="checkbox" name="lock_priv" value="on"';
if (isset($parse_xml->lock_priv)) {
echo ' checked="checked"';
}
echo ' /> lock</div>';
echo '<div class=subhead><input name="submit" type="submit" value="Изменить" /></div>';
echo '</form>';
} else {
if ($_POST['dbpassword'] <> $_POST['dbconfirm'] or $_POST['dbpassword'] == '') {
echo '<div class=erors>Ошибка при изменении пользователя базы данных! ';
echo 'Пароль не подтвержден.</div>';
echo '<a class=subhead href="?func=db.users&elid=' . urlencode($_GET['plid']) . '"><img src=images/r_s.png> Продолжить</a>';
} else {
$dbuserhost = isset($_POST['dbuserhost'])?'on':'';
$select_priv = isset($_POST['select_priv'])?'on':'';
$delete_priv = isset($_POST['delete_priv'])?'on':'';
$insert_priv = isset($_POST['insert_priv'])?'on':'';
$update_priv = isset($_POST['update_priv'])?'on':'';
$create_priv = isset($_POST['create_priv'])?'on':'';
$drop_priv = isset($_POST['drop_priv'])?'on':'';
$alter_priv = isset($_POST['alter_priv'])?'on':'';
$index_priv = isset($_POST['index_priv'])?'on':'';
$grant_priv = isset($_POST['grant_priv'])?'on':'';
$references_priv = isset($_POST['references_priv'])?'on':'';
$lock_priv = isset($_POST['lock_priv'])?'on':'';
$content = api_query('https://' . $server . '/manager/ispmgr?func=db.users.edit&plid=' . urlencode($_GET['plid']) . '&select_priv=' . $select_priv . '&delete_priv=' . $delete_priv . '&insert_priv=' . $insert_priv . '&update_priv=' . $update_priv . '&create_priv=' . $create_priv . '&drop_priv=' . $drop_priv . '&alter_priv=' . $alter_priv . '&index_priv=' . $index_priv . '&grant_priv=' . $grant_priv . '&references_priv=' . $references_priv . '&lock_priv=' . $lock_priv . '&dbuserhost=' . $dbuserhost . '&dbconfirm=' . urlencode($_POST['dbconfirm']) . '&dbpassword=' . urlencode($_POST['dbpassword']) . '&dbusername=' . urlencode($_POST['dbusername']) . '&dbuser=' . urlencode($parse_xml->dbusername) . '&sok=ok&out=xml&authinfo=' . $user['isp_login'] . ':' . $user['isp_paswd']);
$parse_xml = simplexml_load_string($content);
if (isset($parse_xml->ok)) {
echo '<div class=erors>Пользователь бызы данных успешно изменен!</div>';
echo '<a class=subhead href="?func=db.users&elid=' . urlencode($_GET['plid']) . '"><img src=images/r_s.png> Продолжить</a>';
} else {
echo '<div class=erors><div class=erors>Ошибка при изменении пользователя базы данных!</div>';
echo '<a class=subhead href="?func=db.users&elid=' . urlencode($_GET['plid']) . '"><img src=images/r_s.png> Продолжить</a>';
}
}
}
}
?>