-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathajax.php
73 lines (61 loc) · 1.45 KB
/
ajax.php
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
<?PHP
class Data_manager
{
function __construct($source)
{
$this->xml = simplexml_load_file($source);
}
function get_item($i)
{
$x=$this->xml;
$counter=1;
foreach ($x->step as $step)
{
foreach ($step->item as $item)
{
if($i==$counter)
{
return $item;
}
else
{
++$counter;
}
}
}
echo "fail";
}
function get_item_title($i)
{
$item=$this->get_item($i);
return $item['title'];
}
function get_item_content($i)
{
$toreturn="";
$item=$this->get_item($i);
$instruction=$item->instruction;
foreach ( $instruction->row as $row)
{
if($row->intend)
{
$toreturn .= " ";
}
if($row->text)
{
$toreturn .= $row->text;
$toreturn .= "</br>";
}
}
return $toreturn;
}
private $xml;
}
if (isset($_POST['step_item']))
{
$docname='ARIZ.xml';
$dmanager=new Data_manager($docname);
$count=$_POST['step_item'];
echo "Шаг ".$count.". ".$dmanager->get_item_title($count)."</br>".$dmanager->get_item_content($count);
}
?>