-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.php
75 lines (71 loc) · 2.39 KB
/
page.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
74
75
<?php
/**
* Created by PhpStorm.
* User: jason.wang
* Date: 27/10/2014
* Time: 10:14
*/
//include 'save.php';
//$del = 'delete from page ';
//mysql_select_db('page', $con);
//mysql_query($del);
//mysql_query('default-character-set=utf8');
$dom=new DOMDocument('1.0');
$meta=new DOMDocument('1.0');
$dom->load('data/page.xml');
$meta->load('data/meta.xml');
$roles=$dom->documentElement;
$metas=$meta->documentElement;
$a = $dom->getElementsByTagName('items')->item(0);
$a->parentNode->removeChild($a);
$new = $dom->createElement("items");
$x = $dom->getElementsByTagName("data")->item(0);
$x->appendChild($new);
$data = $_POST['data'];
$page_id = 1;
foreach($data as $key => $item){
if($key != 0)
{
$count = count($item);
if($item[0]!="")
{
$newrole = $dom->createElement("item");
$newrole->setAttribute('p1', $item[0]);
$child = $dom->createElement("list");
for($i=1;$i<$count;$i++){
$m = $metas->getElementsByTagName('meta')->item($i);
// if( $m->getAttribute("option")=='文本'){
// $sql = "insert into page values($page_id,'".$item[$i]."')";
// $result = mysql_query($sql);
// $child->setAttribute('p'.($i+1), $page_id++);
//// $child->setAttribute('p'.($i+1), $item[$i]);
// $page_id++;
// }
// else
$child->setAttribute('p'.($i+1), $item[$i]);
}
$newrole->appendChild($child);
$new->appendChild($newrole);
$parrole = $newrole;
}
else{
$child = $dom->createElement("list");
for($i=1;$i<$count;$i++){
$m = $metas->getElementsByTagName('meta')->item($i);
// if( $m->getAttribute("option")=='文本'){
// $sql = "insert into page values($page_id,'".$item[$i]."')";
// $result = mysql_query($sql);
// $child->setAttribute('p'.($i+1), $page_id++);
//// $child->setAttribute('p'.($i+1), $item[$i]);
// $page_id++;
// }
// else
$child->setAttribute('p'.($i+1), $item[$i]);
}
$parrole->appendChild($child);
}
}
}
$dom->save('data/page.xml');
//echo $_POST['pwd'];
echo '操作成功';