<?php
require '../header.php';
require '../connect.php';
print $top.'
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card title="Donw"><p>';
if($_POST['truncate'])
{
if(mysql_query('TRUNCATE TABLE `questions`'))
{print 'Вопросы Очищены';}
else
{print 'Ошибка При Очистке Таблицы';}
}
elseif($_POST['insert'])
{
$file = file($_POST['insert']);
$count = sizeof($file)-1;
$true = 0;
$i = 0;
do
{
$ex = explode('::',$file[$i]);
$tran = strtr(trim($ex[1]),array('а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d','е'=>'e','ё'=>'e','ж'=>'j','з'=>'z','и'=>'i','й'=>'i','к'=>'k','л'=>'l','м'=>'m','н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u','ф'=>'f','х'=>'h','ш'=>'w','щ'=>'w','ц'=>'c','ч'=>'4','ь'=>'.','ъ'=>'.','ы'=>'y','э'=>'e','ю'=>'yu','я'=>'ya','А'=>'A','Б'=>'B','В'=>'V','Г'=>'G','Д'=>'D','Е'=>'E','Ё'=>'E','Ж'=>'J','З'=>'Z','И'=>'I','Й'=>'I','К'=>'K','Л'=>'L','М'=>'M','Н'=>'N','О'=>'O','П'=>'P','Р'=>'R','С'=>'S','Т'=>'T','У'=>'U','Ф'=>'F','Х'=>'H','Ш'=>'W','Щ'=>'W','Ц'=>'C','Ч'=>'4','Ь'=>'.','Ъ'=>'.','Ы'=>'Y','Э'=>'E','Ю'=>'Yu','Я'=>'Ya'));
if(mysql_query('INSERT INTO `questions` SET number=0, vopros=\''.trim($ex[0]).'\', answer=\''.trim($ex[1]).'\', tran=\''.$tran.'\''))
{$true = $true+1;}
}
while(++$i <= $count);
print 'Добавлено '.$true.' вопросов из '.($count+1);
}
else
{
print 'Файл с Вопросами<br/><select name="insert">';
$f = opendir(dirname(__FILE__));
while($fo = readdir($f))
{
if($fo[0]!='.' && $fo!='index.php')
{print '<option value="'.$fo.'">'.$fo.'</option>';}
}
print '</select><br/>
<anchor>
Залить Вопросы в БД
<go href="?" method="post">
<postfield name="insert" value="$(insert)"/>
</go>
</anchor><br/>
---<br/>
<anchor>
Очистить Таблицу с Вопросами
<go href="?" method="post">
<postfield name="truncate" value="1"/>
</go>
</anchor>';
}
print '</p></card></wml>';
?>