forked from CampbellCrowley/hfeeds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepat.php
109 lines (96 loc) · 4.92 KB
/
prepat.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
* Author: Huzaib Shafi
* Author Website: http://www.shafihuzaib.com
* The MIT License
*
* Copyright 2014 Huzaib Shafi (http://www.shafihuzaib.com).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
include_once 'header.php';
$url = $_POST['url'];
if ($_POST['encoding'] == '') {
$encoding = mb_detect_encoding($content);
} else {
$encoding = $_POST['encoding'];
}
/* Function to get file contents from a given url & return content in UTF-8 */
function file_get_contents_utf8($url, $encoding) {
$content = file_get_contents($url);
return preg_replace('/[\n]+/', '<br>', str_replace(' ', ' ', mb_convert_encoding(htmlspecialchars($content), 'UTF-8', $encoding)));
}
?>
<div align="center">
<div id="raw-data">
<?php
echo $page = file_get_contents_utf8($url, $encoding);
?>
</div>
<?php
echo 'Using encoding:'.$encoding;
?>
</div>
<div class="feed-config">
<form method="POST" action="pattern.php?file=<?php echo $_GET['file']; ?>">
<pre>
<textarea placeholder="Enter global pattern 1" name="out_pattern1"></textarea><textarea placeholder="Enter repeatable pattern 1" name = "pattern1"></textarea>
<textarea placeholder="Enter global pattern 2" name="out_pattern2"></textarea><textarea placeholder="Enter repeatable pattern 2" name = "pattern2"></textarea>
<textarea placeholder="Enter global pattern 3" name="out_pattern3"></textarea><textarea placeholder="Enter repeatable pattern 3" name = "pattern3"></textarea>
<textarea placeholder="Enter global pattern 4" name="out_pattern4"></textarea><textarea placeholder="Enter repeatable pattern 4" name = "pattern4"></textarea>
<input type="hidden" value="<?php echo $url; ?>" name = "url">
<h2>Feed Configuration</h2>
<input size="80" type='text' name='feedTitle' placeholder="Title of the feed" />
<input size="80" type='text' name='feedDesc' placeholder="Description of the feed" />
<input size="80" type='text' name='feedLink' placeholder="Link of the feed" value="<?php echo $url; ?>" />
<h2>Feed Item Configuration</h2>
<input size="80" type='text' name='title' placeholder="Title of the item" />
<input size="80" type='text' name='description' placeholder="Description of the item" />
<input size="80" type='text' name='link' placeholder="Link of the item" />
<input size="80" type='text' name='date' placeholder="Publishing Date of the item - Leave Blank if not sure" />
<input type="submit" />
</pre>
</form>
</div>
<div class="feed-help">
<h2>Help is Here!</h2>
<h4>Global Pattern</h4>
This pattern decides which block to select from a given page. Represents a
unique pattern from a given page, which contains the repeatable pattern.
<br>Only one {h} variable can be used here, for example;<br>
<div id="left_content">{h}<p class='second'><br>
<strong>If not sure, enter {h}</strong> to select the whole page.
<h4>Repeatable Pattern</h4>
Pattern to define each item (inside the block defined by corresponding global pattern).
Multiples of {i} & {h} may be used. For example;
<br>
<a href="{h}"{i}title="{h}"{i}>{h}</a>
<h4>Feed Configuration</h4>
Details about the web-page this feed is being created for.
Title, Description & Source Link of the page are reflected in the
RSS XML feed.
<h4>Feed Item Configuration</h4>
Configure the items for the feed. Each Item contains a TITLE,
DESCRIPTION, a LINK & optionally the publishing DATE.
Here you have to use the variable names as {h1}, {h2}, {h3} etc.
If not sure as what should be the title, just click Submit, see the
results on the next page and come back to this page.
For example, the title may be {h3}, link may be {h1}, description may be {h2},
as per the example above.
</div>