-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
78 lines (65 loc) · 2.62 KB
/
index.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
<?php
include_once("functions.php");
ini_set('max_execution_time', 300); // 300 seconds = 5 minutes - running this code may take a long time.
$path = 'dnd_compendium_html/Power';
$xml_path = 'dnd_compendium_xml/Power';
if (!file_exists($path)){
die('Error: source dir ' . $path . ' does not exist. Please point $path var at DnD Compendium Power dir.');
}
if (!file_exists($xml_path)) {
if (!mkdir($xml_path, 0755, TRUE)) {
die('Error: unable create dir ' . $xml_path);
}
}
$files = listdir($path);
//$files = array('DnD-Insider-Compendium/Power/416.html');
//$test = scrape_power('DnD-Insider-Compendium/Power/416.html');
//echo '<pre>'; print_r($test); exit;
//echo "this might take a while... Please be patient...";
foreach ($files as $file) {
$filename = str_replace($path.'/', '', $file);
$filename = str_replace('.html', '', $filename);
//echo $filename .'<br />';
if ($filename[0] != '.' && $filename != '') {
$powers[$filename]['filename'] = $filename;
$powers[$filename]['fields'] = scrape_power($file);
$powers[$filename]['fields']['power_dndinsider_id'] = $filename;
}
}
//echo '<pre>'; print_r($powers); echo '</pre>'; exit;
// // header("Content-Type:text/plain");
// header('Content-Type: text/html; charset=utf-8');
// echo '<link rel="stylesheet" href="css/style.css" type="text/css">';
// // Compendium Styles
// echo '<link rel="stylesheet" href="css/detail.css" type="text/css">';
// echo '<link rel="stylesheet" href="css/mobile.css" type="text/css">';
// echo '<link rel="stylesheet" href="css/print.css" type="text/css">';
// echo '<link rel="stylesheet" href="css/reset.css" type="text/css">';
// echo '<link rel="stylesheet" href="css/site.css" type="text/css">';
// foreach ($powers as $power) {
// echo file_get_contents($power['file']) . '<br />';
// echo output_html($power['fields']) . '<br />';
// echo '<pre>'; print_r($power['fields']); echo '</pre>';
// }
// exit;
//echo '<pre>'; print_r($powers[1]); echo '</pre>';
foreach ($powers as $power) {
$xml = new SimpleXMLElement("<?xml version=\"1.0\"?><Power></Power>");
array_to_xml($power['fields'], $xml);
//saving generated xml file
$xml->formatOutput = true;
$file = $xml_path .'/' . $power['filename'] . '.xml';
//die($file);
$xml->asXML($file);
// header("Content-Type:text/plain");
// echo $xml->saveXML();
// exit;
//$xml_string = $xml->saveXML();
//$xml_string = $xml->saveXML();
}
echo "OK, we're done! Please check $xml_path";
//header ("Content-Type:text/xml");
//header('Content-type: application/xml');
// header('Content-Type: text/html; charset=utf-8');
//header("Content-Type:text/plain");
//echo $xml_string;