forked from pecesama/GelatoCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
109 lines (94 loc) · 3.75 KB
/
api.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
if(!defined('entry')) define('entry',true);
/* ===========================
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under the GPL 2.0
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
=========================== */
?>
<?php
$isFeed = true;
require('entry.php');
global $user, $conf, $tumble;
$f = new feeds();
$theme = new themes;
if (isset($_GET["action"]) && $_GET["action"] == "read") {
if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
if (isset($_GET["total"])) { $total = $_GET["total"]; } else { $total = 20; }
if (isset($_GET["type"])) { $hasType = true; } else { $hasType = false; }
if ($total > 50) { $total = 50; }
$user = new user();
$userData = $user->getUserByID(1);
$username = ($userData["name"] == "") ? "gelato" : $userData["name"];
$theme->set("username",$username);
$theme->set("conf",array(
"offsetCity"=>$conf->offsetCity,
"title"=>$conf->title,
"description"=>$conf->description
));
$feeds = array();
$actual_feeds = $f->getFeedList();
foreach($actual_feeds as $feed){
$error_text = ($feed["error"]>0) ? "false" : "true";
$feed['url'] = htmlspecialchars($feed['url']);
$feed['type'] = util::type2Text($feed['type']);
$feed['getNextUpdate'] = $f->getNextUpdate($feed['id_feed']);
$feed['title'] = htmlspecialchars($feed['title']);
$feed['error_text'] = $error_text;
$feeds[] = $feed;
}
$theme->set("feeds",$feeds);
if ($hasType) {
$postType = type2Number($_GET["type"]);
}
$rs = $tumble->getPosts($total, $start);
$totalRegistros = $db->contarRegistros();
$theme->set("totalRegistros",$totalRegistros);
if ($totalRegistros>0) {
$theme->set("start",$start);
$theme->set("total",$total);
while($post = mysql_fetch_assoc($rs)){
$post['desc'] = util::trimString($post["description"]);
$strEnd = ($conf->urlFriendly) ? "/" : "";
$post['url'] = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$post["id_post"].$strEnd;
$post['formatedDate'] = gmdate("D, d M Y H:i:s", strtotime($post["date"]) + util::transform_offset($conf->offsetTime));
$post["type"] = util::type2Text($post["type"]);
switch ($post["type"]) {
case "post":
$post['tit'] = (empty($post["title"])) ? $post['desc'] : strip_tags($post["title"]);
break;
case "photo":
$post['photoPath'] = str_replace("../", $conf->urlGelato."/", $post["url"]);
$post['tit'] = stripslashes(((empty($post["description"])) ? "Photo" : $post['desc']));
break;
case "quote":
$post['title'] = strip_tags($post["title"]);
break;
case "url":
$post['tit'] = (empty($post["title"])) ? $post["url"] : strip_tags($post["title"]);
break;
case "conversation":
$lines = explode("\n", $post['desc']);
$line = $lines[0];
$post['tit'] = (empty($post["title"])) ? util::trimString($line) : $post["title"];
$post['desc'] = $tumble->formatConversation($post['desc']);
$post['descAPIFormat'] = $tumble->formatConversation($post['desc']);
break;
case "video":
$post['tit'] = (empty($post["description"])) ? "Video" : $post['desc'];
$post['desc'] = htmlspecialchars($tumble->getVideoPlayer($post["url"]));
break;
case "mp3":
$post['tit'] = (empty($post["description"])) ? "Audio" : $post['desc'];
$post['desc'] = htmlspecialchars($tumble->getMp3Player($post["url"]));
break;
}
$posts[] = $post;
}
$theme->set("posts",$posts);
}
$theme->display(Absolute_Path.'admin/themes/admin/api.xml');
}
?>