pecesama 15 years ago
parent
commit
67e1a2cd5f
1 changed files with 51 additions and 50 deletions
  1. 51 50
      api.php

+ 51 - 50
api.php View File

@@ -17,8 +17,8 @@ if(!defined('entry')) define('entry',true);
17 17
 	require('entry.php');
18 18
 	global $user, $conf, $tumble;
19 19
 	$f = new feeds();
20
-	
21
-	$theme = new themes;
20
+	
21
+	$theme = new themes;
22 22
 
23 23
 	if (isset($_GET["action"]) && $_GET["action"] == "read") {
24 24
 		if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; }
@@ -27,82 +27,83 @@ if(!defined('entry')) define('entry',true);
27 27
 		if ($total > 50) { $total = 50; }
28 28
 		$user = new user();
29 29
 		$userData = $user->getUserByID(1);
30
-		$username = ($userData["name"] == "") ? "gelato" : $userData["name"];
31
-
32
-		$theme->set("username",$username);
33
-		$theme->set("conf",array(
34
-			"offsetCity"=>$conf->offsetCity,
35
-			"title"=>$conf->title,
36
-			"description"=>$conf->description
30
+		$username = ($userData["name"] == "") ? "gelato" : $userData["name"];
31
+
32
+		$theme->set("username",$username);
33
+		$theme->set("conf",array(
34
+			"offsetCity"=>$conf->offsetCity,
35
+			"title"=>$conf->title,
36
+			"description"=>$conf->description
37 37
 		));
38
-
39
-		$feeds = array();
		$actual_feeds = $f->getFeedList();
38
+
39
+		$feeds = array();
40
+		$actual_feeds = $f->getFeedList();
40 41
 		foreach($actual_feeds as $feed){
41
-			$error_text = ($feed["error"]>0) ? "false" : "true";
42
-			$feed['url'] = htmlspecialchars($feed['url']);
43
-			$feed['type'] = util::type2Text($feed['type']);
44
-			$feed['getNextUpdate'] = $f->getNextUpdate($feed['id_feed']);
45
-			$feed['title'] = htmlspecialchars($feed['title']);
46
-			$feed['error_text'] = $error_text;
47
-			$feeds[] = $feed;
48
-		}
49
-		
42
+			$error_text = ($feed["error"]>0) ? "false" : "true";
43
+			$feed['url'] = htmlspecialchars($feed['url']);
44
+			$feed['type'] = util::type2Text($feed['type']);
45
+			$feed['getNextUpdate'] = $f->getNextUpdate($feed['id_feed']);
46
+			$feed['title'] = htmlspecialchars($feed['title']);
47
+			$feed['error_text'] = $error_text;
48
+			$feeds[] = $feed;
49
+		}
50
+		
50 51
 		$theme->set("feeds",$feeds);
51 52
 
52 53
 		if ($hasType) {
53 54
 			$postType = type2Number($_GET["type"]);
54 55
 		}
55
-		$rs = $tumble->getPosts($total, $start);
56
-
57
-		$totalRegistros = $db->contarRegistros();
58
-		$theme->set("totalRegistros",$totalRegistros);
56
+		$rs = $tumble->getPosts($total, $start);
57
+
58
+		$totalRegistros = $db->contarRegistros();
59
+		$theme->set("totalRegistros",$totalRegistros);
59 60
 
60
-		if ($db->contarRegistros()>0) {
61
-			$theme->set("start",$start);
62
-			$theme->set("total",$total);
63
-
64
-			while($post = mysql_fetch_assoc($rs)){
61
+		if ($db->contarRegistros()>0) {
62
+			$theme->set("start",$start);
63
+			$theme->set("total",$total);
64
+
65
+			while($post = mysql_fetch_assoc($rs)){
65 66
 				$post['desc'] = util::trimString($post["description"]);				
66 67
 				$strEnd = ($conf->urlFriendly) ? "/" : "";
67 68
 				$post['url'] = $conf->urlGelato.($conf->urlFriendly ? "/post/" : "/index.php?post=").$post["id_post"].$strEnd;
68 69
 				$post['formatedDate'] = gmdate("D, d M Y H:i:s", strtotime($post["date"]) + util::transform_offset($conf->offsetTime));
69
-				
70
-				$post['type'] = util::type2Text($post["type"]);
71
-
72
-				switch ($post["type"]) {
73
-					case "post":
74
-						$post['tit'] = (empty($post["title"])) ? $desc : strip_tags($post["title"]);
70
+				
71
+				$post["type"] = util::type2Text($post["type"]);
72
+				
73
+				switch ($post["type"]) {				
74
+					case "post":
75
+						$post['tit'] = (empty($post["title"])) ? $post['desc'] : strip_tags($post["title"]);
75 76
 						break;
76 77
 					case "photo":
77
-						$post['photoPath'] = str_replace("../", $conf->urlGelato."/", $post["url"]);
78
-						$post['tit'] = stripslashes(((empty($post["description"])) ? "Photo" : $post['desc']));
78
+						$post['photoPath'] = str_replace("../", $conf->urlGelato."/", $post["url"]);
79
+						$post['tit'] = stripslashes(((empty($post["description"])) ? "Photo" : $post['desc']));
79 80
 						break;
80 81
 					case "quote":
81
-						$post['title'] = strip_tags($post["title"]);
82
+						$post['title'] = strip_tags($post["title"]);
82 83
 						break;
83 84
 					case "url":
84 85
 						$post['tit'] = (empty($post["title"])) ? $post["url"] : strip_tags($post["title"]);
85 86
 						break;
86 87
 					case "conversation":
87
-						$lines = explode("\n", $desc);
88
+						$lines = explode("\n", $post['desc']);
88 89
 						$line = $lines[0];
89 90
 						$post['tit'] = (empty($post["title"])) ? trimString($line) : $post["title"];
90
-						$post['desc'] = $tumble->formatConversation($desc);
91
-						$post['descAPIFormat'] = $tumble->formatConversation($desc);
91
+						$post['desc'] = $tumble->formatConversation($post['desc']);
92
+						$post['descAPIFormat'] = $tumble->formatConversation($post['desc']);
92 93
 						break;
93 94
 					case "video":
94
-						$post['tit'] = (empty($post["description"])) ? "Video" : $desc;
95
+						$post['tit'] = (empty($post["description"])) ? "Video" : $post['desc'];
95 96
 						$post['desc'] = htmlspecialchars($tumble->getVideoPlayer($post["url"]));
96 97
 						break;
97 98
 					case "mp3":
98
-						$post['tit'] = (empty($post["description"])) ? "Audio" : $desc;
99
-						$desc = htmlspecialchars($tumble->getMp3Player($post["url"]));
99
+						$post['tit'] = (empty($post["description"])) ? "Audio" : $post['desc'];
100
+						$post['desc'] = htmlspecialchars($tumble->getMp3Player($post["url"]));
100 101
 						break;
101
-				}				
102
-				$posts[] = $post;
103
-			}
104
-			$theme->set("posts",$posts);
105
-		}
102
+				}				
103
+				$posts[] = $post;
104
+			}
105
+			$theme->set("posts",$posts);
106
+		}
106 107
 		$theme->display(Absolute_Path.'admin/themes/admin/api.xml');
107 108
 	}
108
-?>
109
+?>