Browse Source

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

pecesama 17 years ago
parent
commit
9d951de593
3 changed files with 35 additions and 16 deletions
  1. 1 0
      admin/index.php
  2. 32 14
      api.php
  3. 2 2
      classes/functions.php

+ 1 - 0
admin/index.php View File

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

+ 32 - 14
api.php View File

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

+ 2 - 2
classes/functions.php View File

349
 	}
349
 	}
350
 	
350
 	
351
 	function removeBadTags($source) {
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
 		$source = strip_tags($source, $validTags);
353
 		$source = strip_tags($source, $validTags);
354
 		return preg_replace('/<(.*?)>/ie', "'<'.removeBadAtributes('\\1').'>'", $source);
354
 		return preg_replace('/<(.*?)>/ie', "'<'.removeBadAtributes('\\1').'>'", $source);
355
 	}
355
 	}
356
 	
356
 	
357
 	function removeBadAtributes($sourceTag)
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
 		$sourceTag = stripslashes($sourceTag);
360
 		$sourceTag = stripslashes($sourceTag);
361
 		$sourceTag = preg_replace("/$badAtributes/i", "niceTry", $sourceTag);
361
 		$sourceTag = preg_replace("/$badAtributes/i", "niceTry", $sourceTag);
362
 		return $sourceTag;
362
 		return $sourceTag;