Просмотр исходного кода

Read API (beta version) and fixed bug on edit photo (../uploads/img.jpg)

pecesama 17 лет назад
Родитель
Сommit
9d951de593
3 измененных файлов с 35 добавлено и 16 удалено
  1. 1 0
      admin/index.php
  2. 32 14
      api.php
  3. 2 2
      classes/functions.php

+ 1 - 0
admin/index.php Просмотреть файл

@@ -240,6 +240,7 @@ if ($user->isAdmin()) {
240 240
 									$template->mostrarPlantilla();
241 241
 									break;
242 242
 								case "photo":
243
+									$url = str_replace("../", $conf->urlGelato."/", $url);
243 244
 									$input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
244 245
 									$output = array("2", $date, $_SESSION['user_id'], $url, $body);
245 246
 									

+ 32 - 14
api.php Просмотреть файл

@@ -12,11 +12,16 @@ if(!defined('entry')) define('entry',true);
12 12
   =========================== */
13 13
 ?>
14 14
 <?php
15
-	header("Content-type: text/xml; charset=utf-8");	
16
-	
15
+	header("Content-type: text/xml; charset=utf-8");
17 16
 	$isFeed = true;
18
-	$tumble = new gelato();
17
+	
18
+	require(dirname(__FILE__)."/config.php");
19
+	
20
+	include("classes/configuration.class.php");
19 21
 	$conf = new configuration();
22
+		
23
+	include("classes/gelato.class.php");
24
+	$tumble = new gelato();	
20 25
 	
21 26
 	echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
22 27
 ?>
@@ -61,14 +66,14 @@ if(!defined('entry')) define('entry',true);
61 66
 			<posts start="<?php echo $start; ?>" total="<?php echo $total; ?>">
62 67
 <?php 
63 68
 			while($register = mysql_fetch_array($rs)) {
64
-				$desc = $register["description"];
69
+				$desc = htmlspecialchars($register["description"]);
65 70
 				$url = $conf->urlGelato."/index.php?post=".$register["id_post"];
66 71
 				$formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"])+transform_offset($conf->offsetTime));
67 72
 				
68 73
 				switch ($register["type"]) {
69 74
 					case "1":
70 75
 
71
-						$tit = ($register["title"]=="") ? $register["description"] : $register["title"];
76
+						$tit = ($register["title"]=="") ? $desc : $register["title"];
72 77
 ?>
73 78
 						
74 79
 						<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="regular" date="<?php echo $formatedDate;?>">
@@ -78,7 +83,7 @@ if(!defined('entry')) define('entry',true);
78 83
 <?php						
79 84
 						break;
80 85
 					case "2":
81
-						$tit = ($register["description"]=="") ? "Photo" : $register["description"];
86
+						$tit = ($register["description"]=="") ? "Photo" : $desc;
82 87
 ?>
83 88
 						<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="photo" date="<?php echo $formatedDate;?>">
84 89
 <?php
@@ -107,28 +112,41 @@ if(!defined('entry')) define('entry',true);
107 112
 <?php
108 113
 						break;
109 114
 					case "5":
110
-						$lines = explode("\n", $register["description"]);
115
+						$lines = explode("\n", $desc);
111 116
 						$line = $lines[0];
112 117
 						$tit = ($register["title"]=="") ? $line : $register["title"];
113
-						$desc = $tumble->formatConversation($register["description"]);
118
+						$desc = $tumble->formatConversation($desc);
114 119
 ?>
115 120
 						<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="conversation" date="<?php echo $formatedDate;?>">
116 121
                             <conversation-title><?php echo $tit; ?></conversation-title>
117
-                            <conversation-text><?php echo $register["description"]; ?></conversation-text>
118
-                            <?php echo $tumble->formatApiConversation($register["description"]); ?>
122
+                            <conversation-text><?php echo $desc; ?></conversation-text>
123
+                            <?php echo $tumble->formatApiConversation($desc); ?>
119 124
                         </post>
120 125
 <?php
121 126
 						break;
122
-/*
123 127
 					case "6":
124
-						$tit = ($register["description"]=="") ? "Video" : $register["description"];
128
+						$tit = ($register["description"]=="") ? "Video" : $desc;
125 129
 						$desc = $tumble->getVideoPlayer($register["url"]);
130
+?>
131
+						<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="video" date="<?php echo $formatedDate;?>">
132
+                            <video-caption><?php echo $tit; ?></video-caption>
133
+                            <video-source><?php echo $register["url"]; ?></video-source>
134
+                            <video-player><?php echo htmlspecialchars($desc); ?></video-player>                            
135
+                        </post>
136
+<?php
126 137
 						break;
138
+
127 139
 					case "7":
128
-						$tit = ($register["description"]=="") ? "MP3" : $register["description"];
140
+						$tit = ($register["description"]=="") ? "Audio" : $desc;
129 141
 						$desc = $tumble->getMp3Player($register["url"]);
142
+?>
143
+						<post id="<?php echo $register["id_post"]; ?>" url="<?php echo $url;?>" type="audio" date="<?php echo $formatedDate;?>">
144
+                            <audio-caption><?php echo $tit; ?></audio-caption>
145
+                            <audio-player><?php echo htmlspecialchars($desc); ?></audio-player>                            
146
+                        </post>
147
+<?php
130 148
 						break;
131
-*/
149
+
132 150
 				}
133 151
 				$url = $conf->urlGelato."/index.php/post/".$register["id_post"]."/";
134 152
 				$formatedDate = gmdate("D, d M Y H:i:s", strtotime($register["date"])+transform_offset($conf->offsetTime));

+ 2 - 2
classes/functions.php Просмотреть файл

@@ -349,14 +349,14 @@ if(!defined('entry') || !entry) die('Not a valid page');
349 349
 	}
350 350
 	
351 351
 	function removeBadTags($source) {
352
-		$validTags ='<p><ul><li><a><abbr><acronym><blockquote><code><pre><em><i><strike><s><strong><b><br><span><div><img>';
352
+		$validTags ='<p><ol><ul><li><a><abbr><acronym><blockquote><code><pre><em><i><strike><s><strong><b><br><span><div><img>';
353 353
 		$source = strip_tags($source, $validTags);
354 354
 		return preg_replace('/<(.*?)>/ie', "'<'.removeBadAtributes('\\1').'>'", $source);
355 355
 	}
356 356
 	
357 357
 	function removeBadAtributes($sourceTag)
358 358
 	{
359
-		$badAtributes = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup|class';
359
+		$badAtributes = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup';
360 360
 		$sourceTag = stripslashes($sourceTag);
361 361
 		$sourceTag = preg_replace("/$badAtributes/i", "niceTry", $sourceTag);
362 362
 		return $sourceTag;