Файл: archive/www/musimka.ru/games/million/install.php
Строк: 49
<?php
require '../../sid.php';
require '../../config.php';
$link = connect_db();
list($user, $id, $ps) = check_login($link);
include '../../head.php';
/***************************/
if (mysql_query("DROP TABLE IF EXISTS `million_q`;")
&&
mysql_query("
CREATE TABLE `million_q` (
`id` INT(11) NOT NULL auto_increment,
`text` CHAR(255) NOT NULL,
`step` CHAR(16) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
")) echo 'million_q INSTALLED!<br/>';
else echo mysql_error();
if (mysql_query("DROP TABLE IF EXISTS `million_ans`;")
&&
mysql_query("
CREATE TABLE `million_ans` (
`id` INT(11) NOT NULL auto_increment,
`ans` CHAR(255) NOT NULL,
`write` CHAR(2) NOT NULL,
`id_q` INT(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
")) echo 'million_ans INSTALLED!<br/>';
else echo mysql_error();
function damp_q($step)
{
global $qc;
$qs = file('installer/' . $step . '.SVP');
for($i = 0; $qst = $qs[$i]; ++$i) {
$qst = trim($qst);
$qst = iconv('cp1251', 'utf-8', $qst);
if (substr($qst, 0, 1) == '^') {
$qc++;
$vop = trim(htmlspecialchars(substr($qst, 1, strlen($qst) - 1)));
mysql_query("INSERT INTO `million_q` (`text`, `step`) VALUES ('$vop', '$step')");
$id_q = mysql_insert_id();
$i++;
$qst = trim($qs[$i]);
$qst = iconv('cp1251', 'utf-8', $qst);
$wr = substr($qst, 0, 1);
$qst = substr($qst, 1, strlen($qst) - 1);
mysql_query("INSERT INTO `million_ans` (`ans`, `id_q`, `write`) VALUES ('$qst', '$id_q', '$wr')");
$i++;
$qst = trim($qs[$i]);
$qst = iconv('cp1251', 'utf-8', $qst);
$wr = substr($qst, 0, 1);
$qst = substr($qst, 1, strlen($qst) - 1);
mysql_query("INSERT INTO `million_ans` (`ans`, `id_q`, `write`) VALUES ('$qst', '$id_q', '$wr')");
$i++;
$qst = trim($qs[$i]);
$qst = iconv('cp1251', 'utf-8', $qst);
$wr = substr($qst, 0, 1);
$qst = substr($qst, 1, strlen($qst) - 1);
mysql_query("INSERT INTO `million_ans` (`ans`, `id_q`, `write`) VALUES ('$qst', '$id_q', '$wr')");
$i++;
$qst = trim($qs[$i]);
$qst = iconv('cp1251', 'utf-8', $qst);
$wr = substr($qst, 0, 1);
$qst = substr($qst, 1, strlen($qst) - 1);
mysql_query("INSERT INTO `million_ans` (`ans`, `id_q`, `write`) VALUES ('$qst', '$id_q', '$wr')");
}
}
}
$qc = 0;
damp_q(100);
damp_q(1000);
damp_q(1000000);
damp_q(125000);
damp_q(16000);
damp_q(200);
damp_q(2000);
damp_q(250000);
damp_q(300);
damp_q(32000);
damp_q(4000);
damp_q(500);
damp_q(500000);
damp_q(64000);
damp_q(8000);
echo 'Записано вопросов: ' . $qc;
/*************************/
exit();
?>