-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_import.php
More file actions
80 lines (50 loc) · 1.28 KB
/
test_import.php
File metadata and controls
80 lines (50 loc) · 1.28 KB
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
<?php
ini_set('display_errors', true);
session_start();
mysql_connect('localhost','root','aidos123') or die("Not connect to MySQL");
mysql_select_db('test') or die("Not connect to DB");
mysql_set_charset('utf8');
/**
* Simle SQL execute
*@author=Aidos Kakimzhanov
*@version=1.0
*/
class SQL {
public function getOne($sql){
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
return $row;
}
public function execute($sql){
$sql = mysql_query($sql);
while ($row = mysql_fetch_assoc($sql)) {
$data[] = $row;
}
return $data;
}
}
if($_POST['test']!=''&&$_POST['name']&&$_POST['answer']){
$name = $_POST['name'];
$test = $_POST['test'];
$answer = $_POST['answer'];
$test = preg_replace('/^ +(.+)/i', '$1', $test);
$test = preg_replace('/\t+/i', ' ', $test);
$test = preg_replace('/\|+/i', ' ', $test);
$test = preg_replace("/(.+)\r\n/", '$1|', $test);
$test = preg_replace("/(\r\n)+/", "\r\n", $test);
$test = preg_replace("/(\d+)\.(.+)/", "$1|$2", $test);
$test = preg_replace("/(.+)/", "$1###", $test);
//preg_match_all("/((.+)\|.+###/", $test, $test);
}
?>
<form method=post>
Name
<input name="name">
TEST
<textarea name="test"></textarea>
Answer
<textarea name="answer"></textarea>
</form>
<pre>
<?=print_r($test) ?>
</pre>