Перейти к содержанию

Скрипт саппорта


Sanasol

Рекомендуемые сообщения

Вопрос задают НПЦу. Отвечает админ через админку на сайте.

1. NPC:

prontera,164,167,5	script	Support service	89,{

mes "Hi, I can answer any question!";
mes "Enter your question and within days you will necessarily answer.";
switch(select("Ask a question","^FF0000Show Answer^000000","Cancel")){
case 1:
next;
mes "Enter your question";
input .@question$;
if(.@question$=="") { mes "You must enter a question"; close;
} else {
query_sql("INSERT INTO `questions` (`account_id`, `question`, `read`) VALUES ('"+getcharid(3)+"', '"+.@question$+"', '0')");
next;
mes "Question posted!";
mes "Come back later and select the menu item 'Show Answer '";
close;
}
break;

case 2:
query_sql("select id,question from `questions` where `account_id`='"+getcharid(3)+"' and `read`='1' order by `id` desc", @id, @question$);
if (@id[0] == 0) { next; mes "Your question is not answered or you did not ask the question"; close; } else {
mes "Your questions:";
mes @id[0]+" "+@question$[0];
if (@id[1] != 0){mes @id[1]+" "+@question$[1];}
if (@id[2] != 0){mes @id[2]+" "+@question$[2];}
if (@id[3] != 0){mes @id[3]+" "+@question$[3];}
if (@id[4] != 0){mes @id[4]+" "+@question$[4];}
next;
mes "Enter the question number to which you wish to receive a response.";
input @idq;
query_sql("select question,answer,author from `questions` where `id`='"+@idq+"' and `read`='1'", @question$, @answer$, @auth$);
mes "Question: "+@question$[0]+"";
mes "Answer: "+@answer$[0]+"";
mes "Answered by: "+@auth$[0]+"";
close;
}
break;

case 3:
close;
break;
}
}

2. Table

-- ----------------------------
-- Table structure for `questions`
-- ----------------------------
DROP TABLE IF EXISTS `questions`;
CREATE TABLE `questions` (
`id` int(5) NOT NULL auto_increment,
`account_id` int(11) NOT NULL,
`question` varchar(300) collate utf8_bin NOT NULL,
`answer` varchar(500) collate utf8_bin NOT NULL,
`read` int(1) NOT NULL,
`author` varchar(15) collate utf8_bin NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=220 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

3. Web part

<?
$db = mysql_connect ("localhost","root","vertrigo");
mysql_select_db("ragnarok",$db);
$id = $_GET['id'];
if(!isset($id))
{

$result = mysql_query("SELECT `account_id`,`question`,`id` FROM `questions` where `read`='0'");
$myrow = mysql_fetch_array($result);
mysql_query("SET SESSION CHARACTER SET cp1251");
mysql_query("SET NAMES cp1251");
do
{
printf ("<div align='center'><p> %s || <a href='index.php?id=%s'>%s</a></p></div>", $myrow['account_id'], $myrow['id'], $myrow['question']);
}
while($myrow = mysql_fetch_array($result));

}
else
{

$id = $_GET['id'];
$result = mysql_query("SELECT `account_id`,`question` FROM `questions` where `id`='$id'");
$myrow = mysql_fetch_array($result);
mysql_query("SET SESSION CHARACTER SET cp1251");
mysql_query("SET NAMES cp1251");

?>
<div align="center">
<?
echo "Account ID: ".$myrow['account_id']."<br />";
echo "Question: ".$myrow['question'];
?>
<form action="index.php?do=enter_answer" method="post" target="_top">
Текст ответа:<br><textarea name="answer" cols="30" rows="10" id="answer"></textarea><br>
<br>
<input name="id" type="hidden" value="<? echo $id; ?>">
Автор:<br><input name="author" type="text" cols="30" value=" "><br>
<input name="submit" type="submit" value="Reply">
</form>
</div>

<?
}



if($_GET['do'] == "enter_answer")
{
$answer = trim($_POST["answer"]);
$author = trim($_POST["author"]);
$id = trim($_POST["id"]);

$db = mysql_connect ("localhost","root","vertrigo");
mysql_select_db("ragnarok",$db);

$result = mysql_query("UPDATE `questions` SET `answer`='$answer', `author`='$author', `read`='1' WHERE `id`='$id'");
if($result == 'true')
{
echo "<div align='center'>"."<font color='#0066FF'>"."You have successfully answered!"."</font>"."</div>";
echo '<head>
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=index.php">
</head>';
}
else
{
echo "<div align='center'>"."<font color='#FF0000'>"."FAIL!"."</font>"."</div>";
echo '<head>
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=index.php">
</head>';
}
}

?>

Questions list:

listque.jpg

Answer:

answe.jpg

  • Upvote 3
Ссылка на комментарий
Поделиться на другие сайты

×
×
  • Создать...
Яндекс.Метрика