View file base.php

File size: 1.82Kb
<?
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/adm_check.php';
include_once '../sys/inc/user.php';

adm_check();

$set['title']='Your questions';
include_once '../sys/inc/thead.php';
title();
if (isset($_GET['act']) && isset($_FILES['file']['tmp_name']))
{
$sep='|';
if (isset($_POST['replace']))mysql_query('TRUNCATE `viktorina`');
$k_add=0;
$list=@file($_FILES['file']['tmp_name']);
for($i=0;$i<count($list);$i++)
{
if (substr_count($list[$i], $sep)==0)continue;
list($vopr,$otv)=explode($sep,trim($list[$i]));
list($a, $b, $c, $d, $e, $f) = explode('|', trim($list[$i]));
;
mysql_query("INSERT INTO `viktorina` (`vopros`, `otvet`, `otvet1`, `otvet2`, `otvet3`, `otvet4`) VALUES ('$b', '$a', '$c', '$d', '$e', '$f')");
$k_add++;
}
msg("Successfully added $k_add of $i issues");

}
err();
aut();


echo "Всего вопросов в базе: ".mysql_result(mysql_query("SELECT COUNT(*) FROM `viktorina`"),0)."<br />\n";
echo "<form method='post' action='?act=$passgen' enctype='multipart/form-data'>\n";

echo "<input type='file' name='file' /><br />\n";

echo "Only text files in UTF-8 encoding are supported.<br />\nEach question should be on a separate line.<br />\nAnd look like the right answer (number) | Question | Answer # 1 | Answer # 2 | Answer # 3 | Answer # 4<br />\n";
echo "<input value='Replace' name='replace' type='submit' /><br />\n";
echo "<input value='Add' name='add' type='submit' /><br />\n";
echo "</form>\n";


echo "<div class='foot'>\n";
echo "&laquo;<a href='index.php'>Back</a><br />\n";
echo "</div>\n";

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