Browse Source

fixed a bug in use of themes

Victor De la Rocha 16 years ago
parent
commit
d19c735430
2 changed files with 333 additions and 332 deletions
  1. 326 325
      index.php
  2. 7 7
      themes/tumblr/index.htm

+ 326 - 325
index.php View File

@@ -1,325 +1,326 @@
1
-<?php
2
-if(!defined('entry'))define('entry', true);
3
- /* ===========================
4
-
5
-  gelato CMS - A PHP based tumblelog CMS
6
-  development version
7
-  http://www.gelatocms.com/
8
-
9
-  gelato CMS is a free software licensed under the GPL 2.0
10
-  Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
11
-
12
-  =========================== */
13
-?>
14
-<?php
15
-
16
-// Received a valid request, better start setting globals we'll need throughout the app in entry.php
17
-require_once('entry.php');
18
-global $user, $tumble, $conf;
19
-
20
-$theme = new themes;
21
-        // My approach to MVC
22
-
23
-        if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']);
24
-
25
-        if (isset($_GET["post"])) {
26
-                $id_post = $_GET["post"];
27
-                if (!is_numeric($id_post) || $id_post < 1 ){
28
-                	header("Location: index.php");
29
-                }
30
-        } else {
31
-                if (isset($param_url[1]) && $param_url[1]=="post") {
32
-                        $id_post = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
33
-                } else {
34
-                        $id_post = NULL;
35
-                }
36
-        }
37
-
38
-        $theme->set('id_post',$id_post);
39
-
40
-        if (isset($_GET["page"])) {
41
-                $page_num = $_GET["page"];
42
-        } else {
43
-                if (isset($param_url[1]) && $param_url[1]=="page") {
44
-                        $page_num = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
45
-                } else {
46
-                        $page_num = NULL;
47
-                }
48
-        }
49
-
50
-        $gelato_includes = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n";
51
-        $gelato_includes .= "\t<meta name=\"generator\" content=\"gelato  ".codeName()." (".version().")\" />\n";
52
-        $gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />\n";
53
-        $gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato.($conf->urlFriendly?"/rss/":"/rss.php")."\"/>\n";
54
-        $gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/themes/".$conf->template."/style.css\"/>\n";
55
-        $gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/lightbox.css\" />\n";
56
-        $gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/jquery.js\"></script>\n";
57
-        $gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/lightbox.js\"></script>";
58
-
59
-		$page_title = $conf->title;
60
-		$page_title_divisor = " &raquo; "; // it should be set in configuration
61
-		$page_title_len = 50; // it should be set in configuration
62
-		if ($id_post) {
63
-			$register = $tumble->getPost($id_post);
64
-			$textile = new Textile();
65
-			if (empty($register["title"])) {
66
-				if (!empty($register["description"])) {
67
-					if (strlen($register["description"]) > $page_title_len) {
68
-						$page_title_data = substr($register["description"], 0, $page_title_len)."...";
69
-					}
70
-				}
71
-			} else {
72
-				$page_title_data = $register["title"];
73
-			}
74
-			$page_title_data = strip_tags($textile->TextileThis($page_title_data));
75
-			if (!empty($page_title_data)) {
76
-				$page_title .= $page_title_divisor.stripslashes($page_title_data);
77
-			}
78
-		}
79
-
80
-		$theme->set('Gelato_includes',$gelato_includes);
81
-		$theme->set('Title',$conf->title);
82
-		$theme->set('Page_Title',$page_title);
83
-		$theme->set('Description',$conf->description);
84
-		$theme->set('URL_Tumble',$conf->urlGelato);
85
-		$theme->set('Template_name',$conf->template);
86
-
87
-		$theme->set('isAuthenticated',$user->isAuthenticated());
88
-        if($user->isAuthenticated()){
89
-			$theme->set('User',$_SESSION["user_login"]);
90
-			$theme->set('URL_Tumble',$conf->urlGelato);
91
-        }
92
-
93
-		$rows = array();
94
-        if(!$id_post){
95
-                $limit=$conf->postLimit;
96
-
97
-                if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric?
98
-                        $from = (($page_num-1) * $limit);
99
-                } else {
100
-                        $from = 0;
101
-                }
102
-
103
-                $rs = $tumble->getPosts($limit, $from);
104
-
105
-                if ($tumble->contarRegistros()>0) {
106
-                        $dateTmp = null;
107
-                        while($register = mysql_fetch_assoc($rs)) {
108
-								$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
109
-                                if ( $dateTmp != null && $formatedDate == $dateTmp ) { $formatedDate = ""; } else { $dateTmp = $formatedDate; }
110
-								$strEnd=($conf->urlFriendly) ? "/" : "";
111
-								$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
112
-
113
-								$conversation = $register["description"];
114
-
115
-								$register["description"] = $register["description"];
116
-
117
-                                $register["title"] = stripslashes($register["title"]);
118
-                                $register["description"] = stripslashes($register["description"]);
119
-
120
-								$postType = $tumble->getType($register["id_post"]);
121
-
122
-								$row['Date_Added'] = $formatedDate;
123
-								$row['Permalink'] = $permalink;
124
-								$theme->set('postType',$postType);
125
-
126
-                                switch ($postType){
127
-                                        case "1":
128
-                                        		$row['Title'] = $register["title"];
129
-                                        		$row['Body'] = $register["description"];
130
-                                                break;
131
-                                        case "2":
132
-                                                $fileName = "uploads/".getFileName($register["url"]);
133
-
134
-                                                $x = @getimagesize($fileName);
135
-                                                if ($x[0] > 500) {
136
-													$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
137
-                                                } else {
138
-													$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
139
-                                                }
140
-
141
-												$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
142
-
143
-												$row['PhotoURL'] = $photoPath;
144
-												$row['PhotoAlt'] = strip_tags($register["description"]);
145
-												$row['Caption'] = $register["description"];
146
-												$row['Effect'] = $effect;
147
-                                                break;
148
-                                        case "3":
149
-                                        		$row['Quote'] = $register["description"];
150
-                                        		$row['Source'] = $register["title"];
151
-                                                break;
152
-                                        case "4":
153
-                                                if($conf->shorten_links){
154
-													$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
155
-												}
156
-												$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
157
-
158
-												$row['URL'] = $register["url"];
159
-												$row['Name'] = $register["title"];
160
-												$row['Description'] = $register["description"];
161
-                                                break;
162
-                                        case "5":
163
-                                        		$row['Title'] = $register["title"];
164
-                                        		$row['Conversation'] = $tumble->formatConversation($conversation);
165
-                                                break;
166
-                                        case "6":
167
-                                        		$row['Video'] = $tumble->getVideoPlayer($register["url"]);
168
-                                        		$row['Caption'] = $register["description"];
169
-                                                break;
170
-                                        case "7":
171
-                                        		$row['Mp3'] = $tumble->getMp3Player($register["url"]);
172
-                                        		$row['Caption'] = $register["description"];
173
-                                                break;
174
-                                }
175
-
176
-								$comment = new comments();
177
-								$noComments = $comment->countComments($register["id_post"]);
178
-
179
-								$user = new user();
180
-								$username = $user->getUserByID($register["id_user"]);
181
-
182
-								$row['User'] = $username["name"];
183
-								$row['Comments_Number'] = $noComments;
184
-
185
-								$rows[] = $row;
186
-                        }
187
-
188
-						$theme->set('rows',$rows);
189
-
190
-                        $p = new pagination;
191
-                        $p->Items($tumble->getPostsNumber());
192
-                        $p->limit($limit);
193
-						if($conf->urlFriendly){
194
-								$p->urlFriendly('[...]');
195
-								$p->target($conf->urlGelato."/page/[...]");
196
-							}else
197
-								$p->target($conf->urlGelato);
198
-
199
-                        $p->currentPage(isset($page_num) ? $page_num : 1);
200
-
201
-                        $theme->set('pagination',$p->getPagination());
202
-                } else {
203
-                        $theme->set('error','No posts in this tumblelog.');
204
-                }
205
-        } else {
206
-                $register = $tumble->getPost($id_post);
207
-
208
-				$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
209
-				$strEnd=($conf->urlFriendly) ? "/" : "";
210
-				$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
211
-
212
-				$conversation = $register["description"];
213
-
214
-				$register["description"] = $register["description"];
215
-
216
-				$register["title"] = stripslashes($register["title"]);
217
-                $register["description"] = stripslashes($register["description"]);
218
-
219
-				$row['Date_Added'] = $formatedDate;
220
-				$row['Permalink'] = $permalink;
221
-				$postType = $tumble->getType($register["id_post"]);
222
-				$theme->set('postType',$postType);
223
-                switch ($postType) {
224
-                        case "1":
225
-								$row['Title'] = $register["title"];
226
-								$row['Body'] = $register["description"];
227
-                                break;
228
-                        case "2":
229
-                                $fileName = "uploads/".getFileName($register["url"]);
230
-
231
-                                $x = @getimagesize($fileName);
232
-                                if ($x[0] > 500) {
233
-                                        $photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
234
-                                } else {
235
-										$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
236
-                                }
237
-
238
-								$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
239
-
240
-								$row['PhotoURL'] = $photoPath;
241
-								$row['PhotoAlt'] = strip_tags($register["description"]);
242
-								$row['Caption'] = $register["description"];
243
-								$row['Effect'] = $effect;
244
-                                break;
245
-                        case "3":
246
-								$row['Quote'] = $register["description"];
247
-                                $row['Source'] = $register["title"];
248
-                                break;
249
-                        case "4":
250
-                                if($conf->shorten_links){
251
-									$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
252
-								}
253
-								$row['URL'] = $register["url"];
254
-								$row['Name'] = $register["title"];
255
-								$row['Description'] = $register["description"];
256
-                                break;
257
-                        case "5":
258
-								$row['Title'] = $register["title"];
259
-								$row['Conversation'] = $tumble->formatConversation($conversation);
260
-								break;
261
-						case "6":
262
-								$row['Video'] = $tumble->getVideoPlayer($register["url"]);
263
-								$row['Caption'] = $register["description"];
264
-								break;
265
-						case "7":
266
-								$row['Mp3'] = $tumble->getMp3Player($register["url"]);
267
-								$row['Caption'] = $register["description"];
268
-								break;
269
-                }
270
-
271
-				if ($conf->allowComments) {
272
-
273
-					$comment = new comments();
274
-					$rsComments = $comment->getComments($register["id_post"]);
275
-
276
-					$user = new user();
277
-					$username = $user->getUserByID($register["id_user"]);
278
-
279
-					$row['User'] = $username["name"];
280
-
281
-					$textile = new Textile();
282
-					if (empty($register["title"])) {
283
-						if (!empty($register["description"])) {
284
-							if (strlen($register["description"]) > 30) {
285
-								$postTitle = substr($register["description"], 0, 30)."...";
286
-							}
287
-						}
288
-					} else {
289
-						$postTitle = $register["title"];
290
-					}
291
-					$postTitle = strip_tags($textile->TextileThis($postTitle));
292
-
293
-					$row['Post_Title'] = $postTitle;
294
-					$row['Comments_Number'] = $comment->countComments($register["id_post"]);
295
-
296
-					$rows[] = $row;
297
-					$theme->set('rows',$rows);
298
-
299
-					$comments = array();
300
-					while($rowComment = mysql_fetch_assoc($rsComments)) {
301
-						$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a>";
302
-
303
-						$answers['Id_Comment'] = $rowComment["id_comment"];
304
-						$answers['Comment_Author'] = $commentAuthor;
305
-						$answers['Date'] = gmdate("d.m.y", strtotime($rowComment["comment_date"])+transform_offset($conf->offsetTime));
306
-						$answers['Comment'] = $rowComment["content"];
307
-
308
-						$comments[] = $answers;
309
-					}
310
-					$theme->set('comments',$comments);
311
-
312
-					$whois['User_Cookie'] = isset($_COOKIE['cookie_gel_user'])?$_COOKIE['cookie_gel_user']:'';
313
-					$whois['Email_Cookie'] = isset($_COOKIE['cookie_gel_email'])?$_COOKIE['cookie_gel_email']:'';
314
-					$whois['Web_Cookie'] = isset($_COOKIE['cookie_gel_web'])?$_COOKIE['cookie_gel_web']:'';
315
-					$whois['Id_Post'] = $register["id_post"];
316
-
317
-					$theme->set('Date_Added',gmmktime());
318
-					$theme->set('Form_Action',$conf->urlGelato."/admin/comments.php");
319
-					$theme->set('whois',$whois);
320
-				}
321
-        }
322
-
323
-        $theme->set('URL_Tumble',$conf->urlGelato);
324
-		$theme->display(Absolute_Path.'themes/'.$conf->template.'/index.htm');
325
-?>
1
+<?php
2
+if(!defined('entry'))define('entry', true);
3
+ /* ===========================
4
+
5
+  gelato CMS - A PHP based tumblelog CMS
6
+  development version
7
+  http://www.gelatocms.com/
8
+
9
+  gelato CMS is a free software licensed under the GPL 2.0
10
+  Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
11
+
12
+  =========================== */
13
+?>
14
+<?php
15
+
16
+// Received a valid request, better start setting globals we'll need throughout the app in entry.php
17
+require_once('entry.php');
18
+global $user, $tumble, $conf;
19
+
20
+$theme = new themes;
21
+        // My approach to MVC
22
+
23
+        if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']);
24
+
25
+        if (isset($_GET["post"])) {
26
+                $id_post = $_GET["post"];
27
+                if (!is_numeric($id_post) || $id_post < 1 ){
28
+                	header("Location: index.php");
29
+                }
30
+        } else {
31
+                if (isset($param_url[1]) && $param_url[1]=="post") {
32
+                        $id_post = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
33
+                } else {
34
+                        $id_post = NULL;
35
+                }
36
+        }
37
+
38
+        $theme->set('id_post',$id_post);
39
+	$theme->set('error','');
40
+
41
+        if (isset($_GET["page"])) {
42
+                $page_num = $_GET["page"];
43
+        } else {
44
+                if (isset($param_url[1]) && $param_url[1]=="page") {
45
+                        $page_num = (isset($param_url[2])) ? ((is_numeric($param_url[2])) ? $param_url[2] : NULL) : NULL;
46
+                } else {
47
+                        $page_num = NULL;
48
+                }
49
+        }
50
+
51
+        $gelato_includes = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n";
52
+        $gelato_includes .= "\t<meta name=\"generator\" content=\"gelato  ".codeName()." (".version().")\" />\n";
53
+        $gelato_includes .= "\t<link rel=\"shortcut icon\" href=\"".$conf->urlGelato."/images/favicon.ico\" />\n";
54
+        $gelato_includes .= "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"".$conf->urlGelato.($conf->urlFriendly?"/rss/":"/rss.php")."\"/>\n";
55
+        $gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/themes/".$conf->template."/style.css\"/>\n";
56
+        $gelato_includes .= "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".$conf->urlGelato."/admin/css/lightbox.css\" />\n";
57
+        $gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/jquery.js\"></script>\n";
58
+        $gelato_includes .= "\t<script language=\"javascript\" type=\"text/javascript\" src=\"".$conf->urlGelato."/admin/scripts/lightbox.js\"></script>";
59
+
60
+		$page_title = $conf->title;
61
+		$page_title_divisor = " &raquo; "; // it should be set in configuration
62
+		$page_title_len = 50; // it should be set in configuration
63
+		if ($id_post) {
64
+			$register = $tumble->getPost($id_post);
65
+			$textile = new Textile();
66
+			if (empty($register["title"])) {
67
+				if (!empty($register["description"])) {
68
+					if (strlen($register["description"]) > $page_title_len) {
69
+						$page_title_data = substr($register["description"], 0, $page_title_len)."...";
70
+					}
71
+				}
72
+			} else {
73
+				$page_title_data = $register["title"];
74
+			}
75
+			$page_title_data = strip_tags($textile->TextileThis($page_title_data));
76
+			if (!empty($page_title_data)) {
77
+				$page_title .= $page_title_divisor.stripslashes($page_title_data);
78
+			}
79
+		}
80
+
81
+		$theme->set('Gelato_includes',$gelato_includes);
82
+		$theme->set('Title',$conf->title);
83
+		$theme->set('Page_Title',$page_title);
84
+		$theme->set('Description',$conf->description);
85
+		$theme->set('URL_Tumble',$conf->urlGelato);
86
+		$theme->set('Template_name',$conf->template);
87
+
88
+		$theme->set('isAuthenticated',$user->isAuthenticated());
89
+        if($user->isAuthenticated()){
90
+			$theme->set('User',$_SESSION["user_login"]);
91
+			$theme->set('URL_Tumble',$conf->urlGelato);
92
+        }
93
+
94
+		$rows = array();
95
+        if(!$id_post){
96
+                $limit=$conf->postLimit;
97
+
98
+                if(isset($page_num) && is_numeric($page_num) && $page_num>0) { // Is defined the page and is numeric?
99
+                        $from = (($page_num-1) * $limit);
100
+                } else {
101
+                        $from = 0;
102
+                }
103
+
104
+                $rs = $tumble->getPosts($limit, $from);
105
+
106
+                if ($tumble->contarRegistros()>0) {
107
+                        $dateTmp = null;
108
+                        while($register = mysql_fetch_assoc($rs)) {
109
+								$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
110
+                                if ( $dateTmp != null && $formatedDate == $dateTmp ) { $formatedDate = ""; } else { $dateTmp = $formatedDate; }
111
+								$strEnd=($conf->urlFriendly) ? "/" : "";
112
+								$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
113
+
114
+								$conversation = $register["description"];
115
+
116
+								$register["description"] = $register["description"];
117
+
118
+                                $register["title"] = stripslashes($register["title"]);
119
+                                $register["description"] = stripslashes($register["description"]);
120
+
121
+								$postType = $tumble->getType($register["id_post"]);
122
+
123
+								$row['Date_Added'] = $formatedDate;
124
+								$row['Permalink'] = $permalink;
125
+								$row['postType'] = $postType;
126
+
127
+                                switch ($postType){
128
+                                        case "1":
129
+                                        		$row['Title'] = $register["title"];
130
+                                        		$row['Body'] = $register["description"];
131
+                                                break;
132
+                                        case "2":
133
+                                                $fileName = "uploads/".getFileName($register["url"]);
134
+
135
+                                                $x = @getimagesize($fileName);
136
+                                                if ($x[0] > 500) {
137
+													$photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
138
+                                                } else {
139
+													$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
140
+                                                }
141
+
142
+												$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
143
+
144
+												$row['PhotoURL'] = $photoPath;
145
+												$row['PhotoAlt'] = strip_tags($register["description"]);
146
+												$row['Caption'] = $register["description"];
147
+												$row['Effect'] = $effect;
148
+                                                break;
149
+                                        case "3":
150
+                                        		$row['Quote'] = $register["description"];
151
+                                        		$row['Source'] = $register["title"];
152
+                                                break;
153
+                                        case "4":
154
+                                                if($conf->shorten_links){
155
+													$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
156
+												}
157
+												$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
158
+
159
+												$row['URL'] = $register["url"];
160
+												$row['Name'] = $register["title"];
161
+												$row['Description'] = $register["description"];
162
+                                                break;
163
+                                        case "5":
164
+                                        		$row['Title'] = $register["title"];
165
+                                        		$row['Conversation'] = $tumble->formatConversation($conversation);
166
+                                                break;
167
+                                        case "6":
168
+                                        		$row['Video'] = $tumble->getVideoPlayer($register["url"]);
169
+                                        		$row['Caption'] = $register["description"];
170
+                                                break;
171
+                                        case "7":
172
+                                        		$row['Mp3'] = $tumble->getMp3Player($register["url"]);
173
+                                        		$row['Caption'] = $register["description"];
174
+                                                break;
175
+                                }
176
+
177
+								$comment = new comments();
178
+								$noComments = $comment->countComments($register["id_post"]);
179
+
180
+								$user = new user();
181
+								$username = $user->getUserByID($register["id_user"]);
182
+
183
+								$row['User'] = $username["name"];
184
+								$row['Comments_Number'] = $noComments;
185
+
186
+								$rows[] = $row;
187
+                        }
188
+
189
+						$theme->set('rows',$rows);
190
+
191
+                        $p = new pagination;
192
+                        $p->Items($tumble->getPostsNumber());
193
+                        $p->limit($limit);
194
+						if($conf->urlFriendly){
195
+								$p->urlFriendly('[...]');
196
+								$p->target($conf->urlGelato."/page/[...]");
197
+							}else
198
+								$p->target($conf->urlGelato);
199
+
200
+                        $p->currentPage(isset($page_num) ? $page_num : 1);
201
+
202
+                        $theme->set('pagination',$p->getPagination());
203
+                } else {
204
+                        $theme->set('error','No posts in this tumblelog.');
205
+                }
206
+        } else {
207
+                $register = $tumble->getPost($id_post);
208
+
209
+				$formatedDate = gmdate("M d", strtotime($register["date"])+transform_offset($conf->offsetTime));
210
+				$strEnd=($conf->urlFriendly) ? "/" : "";
211
+				$permalink = $conf->urlGelato.($conf->urlFriendly?"/post/":"/index.php?post=").$register["id_post"].$strEnd;
212
+
213
+				$conversation = $register["description"];
214
+
215
+				$register["description"] = $register["description"];
216
+
217
+				$register["title"] = stripslashes($register["title"]);
218
+                $register["description"] = stripslashes($register["description"]);
219
+
220
+				$row['Date_Added'] = $formatedDate;
221
+				$row['Permalink'] = $permalink;
222
+				$postType = $tumble->getType($register["id_post"]);
223
+				$theme->set('postType',$postType);
224
+                switch ($postType) {
225
+                        case "1":
226
+								$row['Title'] = $register["title"];
227
+								$row['Body'] = $register["description"];
228
+                                break;
229
+                        case "2":
230
+                                $fileName = "uploads/".getFileName($register["url"]);
231
+
232
+                                $x = @getimagesize($fileName);
233
+                                if ($x[0] > 500) {
234
+                                        $photoPath = $conf->urlGelato."/classes/imgsize.php?w=500&img=".$register["url"];
235
+                                } else {
236
+										$photoPath = str_replace("../", $conf->urlGelato."/", $register["url"]);
237
+                                }
238
+
239
+								$effect = " href=\"".str_replace("../", $conf->urlGelato."/", $register["url"])."\" rel=\"lightbox\"";
240
+
241
+								$row['PhotoURL'] = $photoPath;
242
+								$row['PhotoAlt'] = strip_tags($register["description"]);
243
+								$row['Caption'] = $register["description"];
244
+								$row['Effect'] = $effect;
245
+                                break;
246
+                        case "3":
247
+								$row['Quote'] = $register["description"];
248
+                                $row['Source'] = $register["title"];
249
+                                break;
250
+                        case "4":
251
+                                if($conf->shorten_links){
252
+									$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
253
+								}
254
+								$row['URL'] = $register["url"];
255
+								$row['Name'] = $register["title"];
256
+								$row['Description'] = $register["description"];
257
+                                break;
258
+                        case "5":
259
+								$row['Title'] = $register["title"];
260
+								$row['Conversation'] = $tumble->formatConversation($conversation);
261
+								break;
262
+						case "6":
263
+								$row['Video'] = $tumble->getVideoPlayer($register["url"]);
264
+								$row['Caption'] = $register["description"];
265
+								break;
266
+						case "7":
267
+								$row['Mp3'] = $tumble->getMp3Player($register["url"]);
268
+								$row['Caption'] = $register["description"];
269
+								break;
270
+                }
271
+
272
+				if ($conf->allowComments) {
273
+
274
+					$comment = new comments();
275
+					$rsComments = $comment->getComments($register["id_post"]);
276
+
277
+					$user = new user();
278
+					$username = $user->getUserByID($register["id_user"]);
279
+
280
+					$row['User'] = $username["name"];
281
+
282
+					$textile = new Textile();
283
+					if (empty($register["title"])) {
284
+						if (!empty($register["description"])) {
285
+							if (strlen($register["description"]) > 30) {
286
+								$postTitle = substr($register["description"], 0, 30)."...";
287
+							}
288
+						}
289
+					} else {
290
+						$postTitle = $register["title"];
291
+					}
292
+					$postTitle = strip_tags($textile->TextileThis($postTitle));
293
+
294
+					$row['Post_Title'] = $postTitle;
295
+					$row['Comments_Number'] = $comment->countComments($register["id_post"]);
296
+
297
+					$rows[] = $row;
298
+					$theme->set('rows',$rows);
299
+
300
+					$comments = array();
301
+					while($rowComment = mysql_fetch_assoc($rsComments)) {
302
+						$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a>";
303
+
304
+						$answers['Id_Comment'] = $rowComment["id_comment"];
305
+						$answers['Comment_Author'] = $commentAuthor;
306
+						$answers['Date'] = gmdate("d.m.y", strtotime($rowComment["comment_date"])+transform_offset($conf->offsetTime));
307
+						$answers['Comment'] = $rowComment["content"];
308
+
309
+						$comments[] = $answers;
310
+					}
311
+					$theme->set('comments',$comments);
312
+
313
+					$whois['User_Cookie'] = isset($_COOKIE['cookie_gel_user'])?$_COOKIE['cookie_gel_user']:'';
314
+					$whois['Email_Cookie'] = isset($_COOKIE['cookie_gel_email'])?$_COOKIE['cookie_gel_email']:'';
315
+					$whois['Web_Cookie'] = isset($_COOKIE['cookie_gel_web'])?$_COOKIE['cookie_gel_web']:'';
316
+					$whois['Id_Post'] = $register["id_post"];
317
+
318
+					$theme->set('Date_Added',gmmktime());
319
+					$theme->set('Form_Action',$conf->urlGelato."/admin/comments.php");
320
+					$theme->set('whois',$whois);
321
+				}
322
+        }
323
+
324
+        $theme->set('URL_Tumble',$conf->urlGelato);
325
+		$theme->display(Absolute_Path.'themes/'.$conf->template.'/index.htm');
326
+?>

+ 7 - 7
themes/tumblr/index.htm View File

@@ -37,7 +37,7 @@
37 37
 				<div class="date">
38 38
 					{$row.Date_Added}
39 39
 				</div>
40
-				{if {$postType}==1}
40
+				{if {$row.postType}==1}
41 41
 					<div class="post">
42 42
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
43 43
 
@@ -46,7 +46,7 @@
46 46
 							{$row.Body}
47 47
 						</div>
48 48
 					</div>
49
-				{elseif {$postType}==2}
49
+				{elseif {$row.postType}==2}
50 50
 					<div class="post">
51 51
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
52 52
 						<div class="photo">
@@ -54,7 +54,7 @@
54 54
 							<div class="caption">{$row.Caption}</div>
55 55
 						</div>
56 56
 					</div>
57
-				{elseif {$postType}==3}
57
+				{elseif {$row.postType}==3}
58 58
 					<div class="post">
59 59
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
60 60
 						<div class="quote">
@@ -62,7 +62,7 @@
62 62
 							<div class="source">&mdash; {$row.Source}</div>
63 63
 						</div>
64 64
 					</div>
65
-				{elseif {$postType}==4}
65
+				{elseif {$row.postType}==4}
66 66
 					<div class="post">
67 67
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
68 68
 							<div class="link">
@@ -70,7 +70,7 @@
70 70
 							<div class="description">{$row.Description}</div>
71 71
 						</div>
72 72
 					</div>
73
-				{elseif {$postType}==5}
73
+				{elseif {$row.postType}==5}
74 74
 					<div class="post">
75 75
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
76 76
 						<div class="conversation">
@@ -78,7 +78,7 @@
78 78
 							{$row.Conversation}
79 79
 						</div>
80 80
 					</div>
81
-				{elseif {$postType}==6}
81
+				{elseif {$row.postType}==6}
82 82
 					<div class="post">
83 83
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
84 84
 						<div class="video">
@@ -86,7 +86,7 @@
86 86
 							<div class="caption">{$row.Caption}</div>
87 87
 						</div>
88 88
 					</div>
89
-				{elseif {$postType}==7}
89
+				{elseif {$row.postType}==7}
90 90
 					<div class="post">
91 91
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
92 92
 						<div class="video">