Kaynağa Gözat

Added the feeds to the read api

pecesama 17 yıl önce
ebeveyn
işleme
fdfc498647
2 değiştirilmiş dosya ile 78 ekleme ve 33 silme
  1. 20 30
      api.php
  2. 58 3
      classes/functions.php

+ 20 - 30
api.php Dosyayı Görüntüle

@@ -15,13 +15,9 @@ if(!defined('entry')) define('entry',true);
15 15
 	header("Content-type: text/xml; charset=utf-8");
16 16
 	$isFeed = true;
17 17
 	
18
-	require(dirname(__FILE__)."/config.php");
19
-	
20
-	include("classes/configuration.class.php");
21
-	$conf = new configuration();
22
-		
23
-	include("classes/gelato.class.php");
24
-	$tumble = new gelato();	
18
+	require('entry.php');
19
+	global $user, $conf, $tumble;
20
+	$f = new feeds();
25 21
 	
26 22
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
27 23
 ?>
@@ -34,31 +30,25 @@ if(!defined('entry')) define('entry',true);
34 30
 		if (isset($_GET["type"])) { $hasType = true; } else { $hasType = false; }
35 31
 		if ($total > 50) { $total = 50; }		
36 32
 ?>		
37
-		<tumblelog name="<?php echo $_SESSION["user_login"];?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>"><?php echo $conf->description;?></tumblelog>	
33
+		<tumblelog name="<?php echo $_SESSION["user_login"];?>" timezone="<?php echo $conf->offsetCity;?>" title="<?php echo $conf->title;?>"><?php 	
34
+		echo "\n\t".$conf->description."\n";
35
+?>
36
+			<feeds>
37
+<?php
38
+				$actual_feeds = $f->getFeedList();
39
+				foreach($actual_feeds as $feed){
40
+					$error_text = ($feed["error"]>0) ? "false" : "true";
41
+?>
42
+					<feed id="<?php echo $feed["id_feed"];?>" url="<?php echo htmlspecialchars($feed["url"]);?>" import-type="<?php echo type2Text($feed["type"]);?>" next-update-in-seconds="<? echo $f->getNextUpdate($feed["id_feed"]);?>" title="<?php echo htmlspecialchars($feed["title"]);?>" error-text="<? echo $error_text;?>"/>
43
+<?php
44
+				}
45
+?>
46
+            </feeds>
47
+        </tumblelog>	
38 48
 
39 49
 <?php
40
-		switch ($hasType) {
41
-			case "post":
42
-				$_GET["type"] = "1";
43
-				break;
44
-			case "photo":
45
-				$_GET["type"] = "2";							   
46
-				break;
47
-			case "quote":
48
-				$_GET["type"] = "3";
49
-				break;
50
-			case "url":
51
-				$_GET["type"] = "4";
52
-				break;
53
-			case "conversation":
54
-				$_GET["type"] = "5";
55
-				break;
56
-			case "video":
57
-				$_GET["type"] = "6";
58
-				break;
59
-			case "mp3":
60
-				$_GET["type"] = "7";
61
-				break;								
50
+		if ($hasType) {
51
+			$postType = type2Number($_GET["type"]);
62 52
 		}
63 53
 		$rs = $tumble->getPosts($total, $start);
64 54
 		if ($tumble->contarRegistros()>0) {

+ 58 - 3
classes/functions.php Dosyayı Görüntüle

@@ -13,7 +13,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
13 13
 ?>
14 14
 <?php
15 15
 	function version() {
16
-		return "0.95";
16
+		return "1.0";
17 17
 	}
18 18
 	
19 19
 	function codeName() {
@@ -354,11 +354,66 @@ if(!defined('entry') || !entry) die('Not a valid page');
354 354
 		return preg_replace('/<(.*?)>/ie', "'<'.removeBadAtributes('\\1').'>'", $source);
355 355
 	}
356 356
 	
357
-	function removeBadAtributes($sourceTag)
358
-	{
357
+	function removeBadAtributes($sourceTag) {
359 358
 		$badAtributes = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup';
360 359
 		$sourceTag = stripslashes($sourceTag);
361 360
 		$sourceTag = preg_replace("/$badAtributes/i", "niceTry", $sourceTag);
362 361
 		return $sourceTag;
363 362
 	}
363
+	
364
+	function type2Text($number) {
365
+		$tmpStr = "";
366
+		switch ($number) {
367
+			case "1":
368
+				$tmpStr = "post";
369
+				break;
370
+			case "2":
371
+				$tmpStr = "photo";							   
372
+				break;
373
+			case "3":
374
+				$tmpStr = "quote";
375
+				break;
376
+			case "4":
377
+				$tmpStr = "url";
378
+				break;
379
+			case "5":
380
+				$tmpStr = "conversation";
381
+				break;
382
+			case "6":
383
+				$tmpStr = "video";
384
+				break;
385
+			case "7":
386
+				$tmpStr = "mp3";
387
+				break;								
388
+		}
389
+		return $tmpStr;
390
+	}
391
+	
392
+	function type2Number($string) {
393
+		$tmpStr = "";
394
+		switch ($string) {
395
+			case "post":
396
+				$tmpStr = "1";
397
+				break;
398
+			case "photo":
399
+				$tmpStr = "2";							   
400
+				break;
401
+			case "quote":
402
+				$tmpStr = "3";
403
+				break;
404
+			case "url":
405
+				$tmpStr = "4";
406
+				break;
407
+			case "conversation":
408
+				$tmpStr = "5";
409
+				break;
410
+			case "video":
411
+				$tmpStr = "6";
412
+				break;
413
+			case "mp3":
414
+				$tmpStr = "7";
415
+				break;								
416
+		}
417
+		return $tmpStr;
418
+	}
364 419
 ?>