<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
only_level(4);

$set['title']='MySQL запрос';
include_once '../sys/inc/thead.php';
title();
if (!isset($access['mysql_query'])){header("Location: index.php?".SID);exit;}
if (isset($_GET['set']) && $_GET['set']=='set' && isset($_POST['qwerty']))
{
$sql=trim(str_replace("\'","'",$_POST['qwerty']));



if (@$conf['phpversion']==5)
{
include_once H.'sys/inc/sql_parser.php';
$sql=SQLParser::getQueries($sql);
}
else
{
$sql=split(";(\n|\r)*",$sql);
}




$k_z=0; $k_z_ok=0;
for ($i=0;$i<count($sql);$i++)
{
if ($sql[$i]!=''){
$k_z++;
if(mysql_query($sql[$i]))
{
$k_z_ok++;
}}}
if ($k_z_ok>0)
{
if ($k_z_ok==1 && $k_z=1)
msg("Запрос успешно выполнен");
else
msg("Выполнено $k_z_ok запросов из $k_z");
}
}

err();
aut();

echo "<form method=\"post\" action=\"mysql.php?set=set\">\n";
echo "<textarea cols=\"75\" rows=\"20\" name=\"qwerty\" ></textarea><br />\n";
echo "<input value=\"Выполнить\" type=\"submit\" />\n";
echo "</form>\n";
echo "<div class='foot'>\n";
echo ">><a href='/adm_panel/m.php'>Примеры запросов</a><br />\n";
echo "&laquo;<a href='/adm_panel/'>В админку</a><br />\n";
echo "</div>\n";

include_once '../sys/inc/tfoot.php';
?>