-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversor.php
73 lines (61 loc) · 1.45 KB
/
conversor.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
<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<title>HTML2Doku</title>
<link href="bootstrap.min.css" rel="stylesheet">
<link href="main.css" rel="stylesheet">
</head>
</body>
<div id="contenedorResultado">
<?php
include('simple_html_dom.php');
header('Content-Type: text/html; charset=UTF-8');
/*function file_get_contents_utf8($fn) {
$content = file_get_html($fn);
return mb_convert_encoding($content, 'UTF-8',
mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
}*/
$url = $_POST["url"];
$id = $_POST["id"];
$class = $_POST["class"];
if($url != null){
$html = file_get_html($url);
}
else{
$html = str_get_html($_POST["html"]);
}
if($id != null ){
$id = "#".$id;
foreach ($html->find($id) as $element){
file_put_contents('files/src.html',$element);
exec('html2wiki --dialect=DokuWiki files/src.html',$output);
foreach($output as $line){
echo "$line";
echo "<br/>";
}
}
}
else if($class != null ){
$class = ".".$class;
foreach ($html->find($class) as $element){
file_put_contents('files/src.html',$element);
exec('html2wiki --dialect=DokuWiki files/src.html',$output);
foreach($output as $line){
echo "$line";
echo "<br/>";
}
}
}
else{
file_put_contents('files/src.html',$html);
exec('html2wiki --dialect=DokuWiki files/src.html',$output);
foreach($output as $line){
echo "$line";
echo "<br/>";
}
}
?>
</div>
</body>
</html>