v0.1.4

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<html>
<head>
<title>Testing startup</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h3><center>_Melchiors suffer page! /ver 0.1.4/</center></h3><br>
<center><div id = 'cent'><div id = 'postblock'> <center>
<form method="post" action="index.php">
<textarea name="txtName" cols="30" rows="4" wrap="Virtual"></textarea>
<br><input type="submit" value="Отправить">
</form></div></div></center><br><br></center>
<?php
$debug_mode = 1;
function _mesg($message){
//if ($debug_mode != 0) {
//echo "<b>debug info:</b> <i>".$message."</i><br>";
//}
}
_mesg("there start script");
_mesg("excuse for debug messages, it's for me, yeah /chagirov loh azaza/");
_mesg("connect to MySQL db");
$host = ""; $user = ""; $pass = "";
$database = ''; $table = '';
$link = mysql_connect($host, $user, $pass) or die(_mesg(mysql_error()));
mysql_select_db($database) or die(_mesg(mysql_error()));
_mesg("all right");
_mesg("start processing POST-method data");
$text = strip_tags($_POST['txtName']);
if (strlen($text) > 0 && $text != "there") {
_mesg($text);
// Обрабатываем и пишем в ДБ
$repeat = 0;
$q = mysql_query("SELECT * FROM ".$table);
$l = mysql_num_rows($q);
for ($i=$l; $i > 0; $i = $i - 1) {
$f = mysql_fetch_array($q);
if ($text == $f[TEXT]) { $repeat = 1; }
}
if ($repeat == 0) {
$l += 1;
mysql_query('INSERT INTO '.$table.' (ID, TEXT)
VALUES ("'.$l.'","'.$text.'")') or die(_mesg(mysql_error()));
} else { _mesg("error : repeated message"); }
} else {
_mesg("error : empty message or example message");
// Выводим все ошибачки
}
_mesg("outputing messages");
$q = mysql_query("SELECT * FROM ".$table);
$l = mysql_num_rows($q);
for ($i=$l; $i > 0; $i = $i - 1) {
$f = mysql_fetch_array($q);
$out = "<div id = 'postarea'><div id = 'postblock'><span class='name'>Guest</span> №";
$out1 = $f[ID]."<pre>".strip_tags($f[TEXT])."</pre></div></div><br><br>";
echo $out.$out1;
}
_mesg("close connection with DB");
mysql_close();
?>
</body>
</head>