-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan_dir.php
82 lines (60 loc) · 1.19 KB
/
scan_dir.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
76
77
78
79
80
81
82
<?php
require('simplehtmldom/simple_html_dom.php');
require('functions.php');
$dir = 'import';
$scan = preg_grep( '/^([^.])/', scandir($dir) );
$sel = array(
'p',
'table',
'td',
'th',
'tr',
'h2',
'h3',
'h4',
'h5',
'h6',
'ul',
'ol',
'dl',
'li',
'div',
'span',
'font',
'strong',
'em'
);
$content = array();
foreach($scan as $file):
$html = file_get_html($dir.'/'.$file);
foreach($sel as $node):
removeAttr($html, $node);
endforeach;
$title = $html->find('title', 0)->plaintext;
$rmTitle = $html->find('h1', 0);
$rmTitle->outertext = ' ';
$html->save();
$body = $html->find('div', 0)->innertext;
$post_content[] = array(
'title'=>$title,
'body'=>$body
);
endforeach;
foreach($post_content as $page):
echo $page['title'];
$title = $page['title'];
$body = $page['body'];
$rpcurl = 'http://dev-ppl-sandbox.pantheonsite.io/xmlrpc.php';
$username = 'ppl-devel';
$password = 'rz@e9Aet6JZJ0fA5E1';
$category = 'test';
if($title != '' && $body != ''):
$chk = post_to_wordpress($title, $body, $rpcurl, $username, $password, $category, $keywords='', $encoding='UTF-8');
endif;
if($chk) {
echo $chk;
} else {
echo 'nope';
}
endforeach;
?>