/
add.php
59 lines (48 loc) · 1.31 KB
/
add.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
<?PHP
//submit a link for processing
if ($_POST['submit'] AND $_POST['link']){
//extract info from link
$content = file_get_contents($_POST['link']);
$title = explode('<title>', $content);
$title = explode('</title>', $title[1]);
$title = $title[0];
$description = "";
$link = $_POST['link'];
//add to feed
$xml = '
<item>
<title>'.xml_entities($title).'</title>
<description>'.xml_entities($description).'</description>
<link>'.xml_entities($link).'</link>
</item>
';
if ($title AND $link){
$query = $db->connection->prepare("
INSERT INTO items (user, time, title, description, link)
VALUES(:user, :time, :title, :description, :link);
")->execute(array(
':user' => $_SESSION['user_id'],
':time' => time(),
':title' => $title,
':description' => $description,
':link' => $link
));
echo "<p>Added <b>$title</b></p>";
}
else{
echo '
<p class="error">
Could not retrieve link. <br><br>
'.print_r($content, true).'
</p>';
}
}
$code = $_SESSION['rss_key'];
?>
<form method="post">
<input type="text" name="link">
<input type="submit" name="submit" value="submit">
</form>
<?PHP
echo "<p>Your XML File: <div class=\"xmllink\">http://egobomb.com/rss/xml/$code</div></p>";
?>