/[health_html]/inc/newsEdit.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/newsEdit.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations)
Tue Sep 25 15:38:04 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.7: +55 -42 lines
Major changes. Too numeruous to mention all here.

1 <?php
2 set_magic_quotes_runtime(false);
3 # ---KLUDGE-BEGIN---
4 function ss(&$i, $k) {
5 if (is_array($i)) array_walk($i, "ss");
6 if (!is_string($i)) return;
7 $i = stripslashes($i);
8 if ($k) { global $$k; $$k = stripslashes($$k); }
9 }
10 $ss = array("HTTP_GET_VARS", "HTTP_POST_VARS", "HTTP_POST_FILES");
11 while (list($key, $val) = each($ss)) array_walk($$val, "ss");
12 # ---KLUDGE-END---
13 $phptmp = "^php";
14 function sql($sql) {
15 #echo "<TT><B>[SQL]</B> $sql<BR>\n";
16 }
17 function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); }
18 function newsEdit($art, $trigger = "", $isVijest = false) {
19 global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $section, $section_menu, $dbh, $tpl;
20 global $ed_id, $ed_cat, $isMed;
21 $i = 1;
22 global $ed_delete_main, $ed_del_main;
23 $delete_main = $ed_delete_main;
24 $del_main = $ed_del_main;
25 global $ed_clear_main, $ed_clr_main;
26 global $ed_clear_author, $ed_clr_author;
27 $clear_main = $ed_clear_main;
28 $clr_main = $ed_clr_main;
29 $clear_author = $ed_clear_author;
30 $clr_author = $ed_clr_author;
31 global $ed_titlepic_url, $ed_titlepic_url2, $ed_titlepic_name;
32 $titlepic_url = $ed_titlepic_url;
33 $titlepic_url2 = $ed_titlepic_url2;
34 $titlepic_name = urldecode($ed_titlepic_name);
35 # Fix for M$IE
36 if ($titlepic_url == "none") $titlepic_url = "";
37 global $ed_author_url, $ed_author_url2, $ed_author_name;
38 $author_url = $ed_author_url;
39 $author_url2 = $ed_author_url2;
40 $author_name = urldecode($ed_author_name);
41 # Fix for M$IE
42 if ($author_url == "none") $author_url = "";
43 while (true) {
44 global ${"ed_text_id_".$i};
45 if (!isset(${"ed_text_id_".$i})) break;
46 global ${"ed_delete_".$i}, ${"ed_del_".$i};
47 ${"delete_".$i} = ${"ed_delete_".$i};
48 ${"del_".$i} = ${"ed_del_".$i};
49 global ${"ed_clear_".$i}, ${"ed_clr_".$i};
50 ${"clear_".$i} = ${"ed_clear_".$i};
51 ${"clr_".$i} = ${"ed_clr_".$i};
52 global ${"ed_textpic_url_".$i}, ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i};
53 ${"textpic_url_".$i} = ${"ed_textpic_url_".$i};
54 ${"textpic_url2_".$i} = ${"ed_textpic_url2_".$i};
55 ${"textpic_name_".$i} = urldecode(${"ed_textpic_name_".$i});
56 # Fix for M$IE
57 if (${"textpic_url_".$i} == "none") ${"textpic_url_".$i} = "";
58 $i++;
59 }
60 // -----
61 $categories = array();
62 $sql = "SELECT cat_id, text FROM news_categories ORDER BY text";
63 sql($sql);
64 $sth = $dbh->prepare($sql);
65 if (!$sth) error("Cannot prepare query: \"$sql\"");
66 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
67 while ($row = $sth->fetchrow_array()) array_push($categories,
68 array("id" => $row[0], "txt" => $row[1]));
69 $sth->finish();
70 usort($categories, "my_cmp");
71 // -----
72 $specs = array();
73 $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)";
74 sql($sql);
75 $sth = $dbh->prepare($sql);
76 if (!$sth) error("Cannot prepare query: \"$sql\"");
77 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
78 while ($row = $sth->fetchrow_array()) array_push($specs, array("id" => $row[0], "txt" => $row[1]));
79 $sth->finish();
80 usort($specs, "my_cmp");
81 // -----
82 $levels = array();
83 $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";
84 sql($sql);
85 $sth = $dbh->prepare($sql);
86 if (!$sth) error("Cannot prepare query: \"$sql\"");
87 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
88 while ($row = $sth->fetchrow_array()) array_push($levels, array("id" => $row[0], "class" => $row[1], "name" => $row[2]));
89 $sth->finish();
90 // -----
91 global $cancel, $save;
92 if ($cancel || $save) {
93 if ($save) {
94 // Move temp pics & save article.
95 if (ereg("$phptmp", $titlepic_url2) && $ed_id > 0 && file_exists("$syspicdir/$titlepic_url2")) {
96 $sql = "SELECT title_pic FROM news WHERE (news_id = $ed_id)";
97 sql($sql);
98 $sth = $dbh->prepare($sql);
99 if (!$sth) error("Cannot prepare query: \"$sql\"");
100 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
101 $row = $sth->fetchrow_array();
102 $sth->finish();
103 $row = array_shift($row);
104 if ($row) MyDelete($syspicdir."/".$row);
105 }
106 if (ereg("$phptmp", $author_url2) && $ed_id > 0 && file_exists("$sysaupicdir/$author_url2")) {
107 $sql = "SELECT author_pic FROM news WHERE (news_id = $ed_id)";
108 sql($sql);
109 $sth = $dbh->prepare($sql);
110 if (!$sth) error("Cannot prepare query: \"$sql\"");
111 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
112 $row = $sth->fetchrow_array();
113 $sth->finish();
114 $row = array_shift($row);
115 if ($row) MyDelete($sysaupicdir."/".$row);
116 }
117 global $ed_title, $ed_lead, $ed_titlepic_alt,
118 $ed_titlepic_pos, $ed_more, $ed_more_title,
119 $ed_cat, $ed_author_alt, $ed_author_info;
120 $ed_title = MyQuote($ed_title);
121 $ed_lead = MyQuote($ed_lead);
122 $ed_author_nm = urldecode(MyQuote(basename($author_name)));
123 $ed_author_alt = MyQuote($ed_author_alt);
124 $ed_author_info = MyQuote($ed_author_info);
125 $ed_titlepic_nm = urldecode(MyQuote(basename($titlepic_name)));
126 $ed_titlepic_alt = MyQuote($ed_titlepic_alt);
127 $ed_more = MyQuote($ed_more);
128 $ed_more_title = MyQuote($ed_more_title);
129 if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;
130 if ($ed_id > 0) {
131 $sql = "UPDATE news SET category = '$ed_cat', title = $ed_title, lead = $ed_lead, title_pic = $ed_titlepic_nm, title_alt = $ed_titlepic_alt, title_pos = $ed_titlepic_pos, author_pic = $ed_author_nm, author_alt = $ed_author_alt, author_info = $ed_author_info, url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", ord = 0, d_change = NOW() WHERE (news_id = $ed_id)";
132 sql($sql);
133 $dbh->dbh_do($sql);
134 } else {
135 $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, author_pic, author_alt, author_info, url, url_title, plivamed, d_orig, d_change) VALUES ('$ed_cat', $ed_title, $ed_lead, $ed_titlepic_nm, $ed_titlepic_alt, $ed_titlepic_pos, $ed_author_nm, $ed_author_alt, $ed_author_info, $ed_more, $ed_more_title, ".($isMed?"true":"false").", NOW(), NOW())";
136 sql($sql);
137 $dbh->dbh_do($sql);
138 $sql = "SELECT news_id FROM news WHERE (title = $ed_title)";
139 sql($sql);
140 $sth = $dbh->prepare($sql);
141 if (!$sth) error("Cannot prepare query: \"$sql\"");
142 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
143 $rows = array();
144 while ($row = $sth->fetchrow_array()) array_push($rows, $row);
145 $sth->finish();
146 $row = array_pop($rows);
147 if (is_array($row)) $row = array_shift($row);
148 if ($row) $ed_id = $row;
149 }
150 if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", urldecode("$syspicdir/$titlepic_name"));
151 if ($author_url2) MyMove("$sysaupicdir/$author_url2", urldecode("$sysaupicdir/$author_name"));
152 $i = 1;
153 $parents = array();
154 $last_level = 0;
155 $last_id = 0;
156 while ($ed_id > 0 && isset(${"ed_text_id_".$i})) {
157 global ${"ed_text_title_".$i}, ${"ed_text_".$i},
158 ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
159 ${"ed_text_level_".$i}, ${"ed_hl_".$i},
160 ${"ed_textpic_exp_".$i};
161 list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev, $hl, $exp) = array(
162 ${"ed_text_id_".$i}, ${"ed_text_title_".$i},
163 ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i},
164 ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
165 ${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i},
166 ${"ed_textpic_exp_".$i});
167 if ($lev != $last_level) {
168 if ($last_level) {
169 if ($last_level < $lev) array_push($parents, $id);
170 if ($last_level > $lev && count($parents) > 0) array_pop($parents);
171 }
172 $last_level = $lev;
173 $parent = $parents[0];
174 if ($parent < 0) $parent = $last_id;
175 }
176 $tit = MyQuote($tit);
177 $txt = MyQuote($txt);
178 $exp = MyQuote($exp);
179 $hl = MyQuote($hl);
180 $orig = basename($orig);
181 $org = MyQuote($orig);
182 $alt = MyQuote($alt);
183 if (!$pos) $pos = 0;
184 if ($id && $id > 0) {
185 if ($del || !$orig) {
186 $sql = "SELECT pic FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
187 sql($sql);
188 $sth = $dbh->prepare($sql);
189 if (!$sth) error("Cannot prepare query: \"$sql\"");
190 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
191 while ($row = $sth->fetchrow_array()) {
192 list($pic) = $row;
193 MyDelete($syspicdir."/".$pic);
194 }
195 $sth->finish();
196 }
197 if ($del) $sql = "DELETE FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
198 else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, hl = $hl, pic = $org, alt = $alt, pos = $pos, pic_title = $exp WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
199 sql($sql);
200 $dbh->dbh_do($sql);
201 } else if (!$del) {
202 $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos, hl, pic_title) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos, $hl, $exp)";
203 sql($sql);
204 $dbh->dbh_do($sql);
205 $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";
206 sql($sql);
207 $sth = $dbh->prepare($sql);
208 if (!$sth) error("Cannot prepare query: \"$sql\"");
209 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
210 $row = $sth->fetchrow_array();
211 $sth->finish();
212 $row = array_shift($row);
213 $last_id = $id = $row;
214 }
215 if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");
216 $i++;
217 }
218 if ($ed_id) {
219 $sql = "DELETE FROM spec_news WHERE (news_id = $ed_id)";
220 sql($sql);
221 $dbh->dbh_do($sql);
222 for ($k = 0; $k < count($specs); $k++) {
223 $var = "ed_spec_".$specs[$k]["id"]; global $$var;
224 if (!$$var) continue;
225 $sql = "INSERT INTO spec_news (news_id, spec_id) VALUES ($ed_id, ".$specs[$k]["id"].")";
226 sql($sql);
227 $dbh->dbh_do($sql);
228 }
229 $sql = "DELETE FROM cat_news WHERE (news_id = $ed_id)";
230 sql($sql);
231 $dbh->dbh_do($sql);
232 for ($k = 0; $k < count($categories); $k++) {
233 $var = "ed_cat_".$categories[$k]["id"];
234 global $$var;
235 if ($categories[$k]["id"] != $ed_cat && !$$var) continue;
236 $sql = "INSERT INTO cat_news (news_id, cat_id) VALUES ($ed_id, '".$categories[$k]["id"]."')";
237 sql($sql);
238 $dbh->dbh_do($sql);
239 }
240 }
241 } else {
242 // Delete temp pics.
243 if (ereg("$phptmp", $titlepic_url2)) MyDelete($syspicdir."/".$titlepic_url2);
244 if (ereg("$phptmp", $author_url2)) MyDelete($sysaupicdir."/".$author_url2);
245 $i = 1;
246 while (isset(${"ed_textpic_id_".$i})) {
247 $tmp = ${"textpic_url2_".$i};
248 if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
249 $i++;
250 }
251 }
252 if (!isset($art["limit"])) $art["limit"] = 1;
253 if (!isset($art["npar"])) $art["npar"] = 1;
254 return array_shift(newsLoad($ed_id, $ed_cat,
255 $art["limit"], $art["offset"], $art["npar"]));
256 }
257 // Handle temp pic upload.
258 global $HTTP_POST_FILES;
259 while (list($key, $val) = each($HTTP_POST_FILES)) {
260 list($name, $type, $tname, $size) = array(
261 $val["name"], $val["type"],
262 $val["tmp_name"], $val["size"]);
263 if ($size <= 0) continue;
264 if (!$name) continue;
265 if ($tname == "none") continue;
266 $name = strtr($name, "¹šðè澞©ŠÐÈÆ®Ž ", "ssdcczzSSDCCZZ_");
267 $nm = basename($tname);
268 $ext = ereg_replace('^.*(\..+)$', '\1', $name);
269 if ($key == "ed_titlepic_url") {
270 move_uploaded_file($tname, $syspicdir."/".$nm.$ext);
271 $titlepic_url = $nm.$ext;
272 $titlepic_name = $name;
273 $u = $titlepic_url2;
274 if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u);
275 unset($clear_main, $clr_main);
276 } else if ($key == "ed_author_url") {
277 move_uploaded_file($tname, $sysaupicdir."/".$nm.$ext);
278 $author_url = $nm.$ext;
279 $author_name = $name;
280 $u = $author_url2;
281 if (ereg("$phptmp", $u)) MyDelete($sysaupicdir."/".$u);
282 unset($clear_author, $clr_author);
283 } else if (ereg("^ed_textpic_url_([1-9][0-9]*)$", $key, $regs)) {
284 move_uploaded_file($tname, $syspicdir."/".$nm.$ext);
285 $n = $regs[1];
286 ${"textpic_url_".$n} = $nm.$ext;
287 ${"textpic_name_".$n} = $name;
288 $u = ${"textpic_url2_".$n};
289 if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);
290 unset(${"clear_".$n}, ${"clr_".$n});
291 } else {
292 // [?!?]
293 }
294 }
295 // -----
296 $tp = new Smarty();
297 // -----
298 $tp->assign("levels", $levels);
299 // -----
300 global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,
301 $ed_titlepic_alt, $ed_cat, $ed_more,
302 $ed_more_title, $ed_author_url, $ed_author_alt,
303 $ed_author_info;
304 global $ed_edit, $ed_preview, $preview, $add;
305 if (!$ed_preview) $ed_preview = ($preview ? true : false);
306 if ($ed_edit) $ed_preview = false;
307 global $HTTP_POST_VARS, $HTTP_GET_VARS;
308 $delete = count(preg_grep('/^ed_delete_[0-9]+$/',
309 array_keys(array_merge($HTTP_GET_VARS,
310 $HTTP_POST_VARS)))) > 0;
311 global $ed_clear_author;
312 $clear = (count(preg_grep('/^ed_clear_(main|author|[0-9]+)$/',
313 array_keys(array_merge($HTTP_GET_VARS,
314 $HTTP_POST_VARS)))) > 0);
315 $ed_pgfs = array();
316 $ed_warning = 0;
317 $nspecs = array();
318 $ncats = array();
319 // Transfer data
320 if ($ed_edit || $ed_preview || $add || $delete || $clear) {
321 for ($i = 0; $i < count($specs); $i++) {
322 $var = "ed_spec_".$specs[$i]["id"];
323 global $$var;
324 $nspecs[$specs[$i]["id"]] = $$var ? true : false;
325 }
326 for ($i = 0; $i < count($categories); $i++) {
327 $var = "ed_cat_".$categories[$i]["id"];
328 global $$var;
329 $ncats[$categories[$i]["id"]] = $$var ? true : false;
330 }
331 global $ed_title, $ed_lead, $ed_titlepic_pos,
332 $ed_titlepic_alt, $ed_cat, $ed_more,
333 $ed_more_title, $ed_author_url,
334 $ed_author_alt, $ed_author_info;
335 if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";
336 if (!$titlepic_url) $titlepic_url = $titlepic_url2;
337 if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"];
338 if (!$author_url && !($clear_author || $clr_author)) $author_url = $art["au_pic"];
339 list($width, $height) = PicSize($titlepic_url);
340 list($width2, $height2) = PicSize($author_url, $sysaupicdir);
341 global $ed_title_force;
342 if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;
343 $i = 1;
344 while (isset(${"ed_text_id_".$i})) {
345 $id = ${"ed_text_id_".$i};
346 global ${"ed_text_".$i}, ${"ed_text_title_".$i},
347 ${"ed_text_level_".$i}, ${"ed_textpic_alt_".$i},
348 ${"ed_textpic_pos_".$i}, ${"ed_hl_".$i},
349 ${"ed_textpic_exp_".$i};
350 $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?
351 ${"textpic_url_".$i} : "";
352 if (!$pic_url) $pic_url = ${"textpic_url2_".$i};
353 $tmp = "";
354 for ($j = 0; $j < count($art["text"]); $j++)
355 if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"];
356 if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp;
357 $level = ${"ed_text_level_".$i};
358 list($w, $h) = PicSize($pic_url);
359 array_push($ed_pgfs, array($id,
360 ${"ed_text_".$i}, ${"ed_text_title_".$i},
361 $level, $pic_url, ${"textpic_name_".$i},
362 ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
363 $w, $h, ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i}, false));
364 $i++;
365 }
366 } else {
367 if ($ed_id) {
368 $sql = "SELECT spec_id FROM spec_news WHERE (news_id = $ed_id)";
369 sql($sql);
370 $sth = $dbh->prepare($sql);
371 if (!$sth) error("Cannot prepare query: \"$sql\"");
372 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
373 while ($row = $sth->fetchrow_array()) $nspecs[$row[0]] = true;
374 $sth->finish();
375 $sql = "SELECT cat_id FROM cat_news WHERE (news_id = $ed_id)";
376 sql($sql);
377 $sth = $dbh->prepare($sql);
378 if (!$sth) error("Cannot prepare query: \"$sql\"");
379 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
380 while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;
381 $sth->finish();
382 }
383 list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,
384 $titlepic_url2, $titlepic_name, $ed_titlepic_alt,
385 $ed_cat, $ed_more, $ed_more_title, $width, $height,
386 $author_url, $author_url2, $author_name,
387 $ed_author_alt, $ed_author_info, $width2, $height2) =
388 array($art["title"], $art["lead"], $art["pic_pos"],
389 $art["pic_url"], $art["pic_url"], urldecode($art["pic_url"]),
390 $art["pic_alt"], $art["category"], $art["more"],
391 $art["more_title"], $art["pic_w"], $art["pic_h"],
392 $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),
393 $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"]);
394 while ($art["text"] && list($id, $val) = each($art["text"])) {
395 array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],
396 $val["level"], urldecode($val["pic"]),
397 urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"],
398 $val["h"], $val["hl"], $val["exp"], false));
399 }
400 $ed_id = $art["id"];
401 if (!$ed_id) $ed_id = -1;
402 }
403 $ncats[$ed_cat] = true;
404 for ($i = 0; $i < count($specs); $i++) $specs[$i]["check"] = $nspecs[$specs[$i]["id"]];
405 for ($i = 0; $i < count($categories); $i++) $categories[$i]["check"] = $ncats[$categories[$i]["id"]];
406 $tp->assign("specs", $specs);
407 $tp->assign("categories", $categories);
408 if ($ed_more && !strstr($ed_more, "://")) {
409 $pos = strpos($ed_more, "?");
410 if ($pos === false || $pos != 0) $ed_more = "http://".$ed_more;
411 }
412 if ($add) {
413 global $add_num;
414 for ($i = 0; $i < intval($add_num); $i++)
415 array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", 0, 0, 0, "", "", true));
416 }
417 $ed_empty = ($ed_title || $ed_lead || $ed_titlepic_pos || $ed_more) ? false : true;
418 $ed_text = array();
419 $ed_records = array();
420 $ed_warnings = ($ed_warning ? true : false);
421 $i = 1;
422 while (list($key, $val) = each($ed_pgfs)) {
423 list($id, $txt, $tit, $lev, $pic, $name, $alt, $pos, $w, $h, $hl, $exp, $new) = $val;
424 $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);
425 array_push($ed_records, array("val" => $del, "id" => $id));
426 if ($del) { $i++; continue; }
427 $picurl = ${"textpic_url_".$id};
428 if (!$picurl) $picurl = $pic;
429 $class = "";
430 reset($levels);
431 while (list($k, $v) = each($levels)) if ($v["id"] == $lev) $class = $v["class"];
432 if ((${"clear_".$i} || ${"clr_".$i}) && $ed_preview && (${"textpic_name_".$i} != ${"textpic_url2_".$i})) {
433 $tmp = ${"textpic_url2_".$i};
434 if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
435 $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";
436 }
437 if (!$name) $name = $picurl;
438 $txt = MyEscape(convert_html($txt), false);
439 $txt2 = ParseNewline($txt, true);
440 $txt3 = str_replace("&", "&amp;", $txt);
441 $txt3 = str_replace("\"", "&quot;", $txt3);
442 $txt3 = str_replace("<", "&lt;", $txt3);
443 $txt3 = str_replace(">", "&gt;", $txt3);
444 $hl = MyEscape(convert_html($hl), false);
445 $hl2 = ParseNewline($hl, true);
446 if ($hl2) $hl2 = GetHighlight($hl2);
447 $hl3 = str_replace("&", "&amp;", $hl);
448 $hl3 = str_replace("\"", "&quot;", $hl3);
449 $hl3 = str_replace("<", "&lt;", $hl3);
450 $hl3 = str_replace(">", "&gt;", $hl3);
451 global ${"ed_text_force_".$i};
452 $force = ${"ed_text_force_".$i};
453 $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);
454 $warning = 0;
455 if ($empty && !$force) $warning = 1;
456 if ($picurl && !$pos && !$force) $warning = 2;
457 $ed_empty = $ed_empty && $empty;
458 $ed_warnings = $ed_warnings || ($warning && !$force);
459 array_push($ed_text, array(
460 "id" => $id,
461 "n" => $i,
462 "txt" => $txt2,
463 "txt2" => $txt,
464 "txt3" => $txt3,
465 "hl" => $hl2,
466 "hl2" => $hl,
467 "hl3" => $hl3,
468 "title" => MyEscape(convert_html($tit)),
469 "level" => $lev,
470 "class" => MyEscape(convert_html($class)),
471 "url" => MyEscape(convert_html($picurl)),
472 "name" => MyEscape(convert_html($name)),
473 "alt" => MyEscape(convert_html($alt)),
474 "w" => $w,
475 "h" => $h,
476 "pos" => $pos,
477 "exp" => MyEscape(convert_html($exp)),
478 "warning" => $warning,
479 "clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false
480 ));
481 $i++;
482 }
483 if ($ed_warnings) $ed_preview = false;
484 $tp->assign("ed_id", $ed_id);
485 $tp->assign("ed_cat", $ed_cat);
486 $tp->assign("ed_preview", $ed_preview);
487 $tp->assign("ed_trigger", $trigger);
488 $tp->assign("ed_title", MyEscape(convert_html($ed_title)));
489 $tp->assign("ed_lead", MyEscape(convert_html($ed_lead)));
490 $tp->assign("ed_titlepic_pos", $ed_titlepic_pos);
491 $tp->assign("ed_titlepic_url", MyEscape(convert_html($titlepic_url)));
492 $tp->assign("ed_titlepic_url2", MyEscape(convert_html($titlepic_url2)));
493 $tp->assign("ed_titlepic_name", MyEscape(convert_html($titlepic_name)));
494 $tp->assign("ed_titlepic_alt", MyEscape(convert_html($ed_titlepic_alt)));
495 $tp->assign("ed_titlepic_width", $width);
496 $tp->assign("ed_titlepic_height", $height);
497 $tp->assign("ed_author_url", MyEscape(convert_html($author_url)));
498 $tp->assign("ed_author_url2", MyEscape(convert_html($author_url2)));
499 $tp->assign("ed_author_name", MyEscape(convert_html($author_name)));
500 $tp->assign("ed_author_alt", MyEscape(convert_html($ed_author_alt)));
501 $tp->assign("ed_author_info", MyEscape(convert_html($ed_author_info)));
502 $tp->assign("ed_author_width", $width2);
503 $tp->assign("ed_author_height", $height2);
504 $tp->assign("ed_more", MyEscape($ed_more));
505 $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);
506 $tp->assign("ed_more_title", MyEscape($ed_more_title));
507 $tp->assign("ed_clr_main", ($clear_main || $clr_main || !$titlepic_url) ? true : false);
508 $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false);
509 $tp->assign("ed_text", $ed_text);
510 $tp->assign("ed_empty", $ed_empty);
511 $tp->assign("ed_warning", $ed_warning);
512 $tp->assign("ed_warnings", $ed_warnings);
513 $tp->assign("ed_records", $ed_records);
514 $tp->assign("newspicdir", "$picdir/");
515 $tp->assign("aupicdir", "$aupicdir/");
516 $tp->assign("vijest", $isVijest ? true : false);
517 if ($ed_preview) {
518 include_once("author.php");
519 $tp->assign("AUTHOR", GetAuthor(MyEscape(convert_html($author_url)),
520 MyEscape(convert_html($ed_author_alt)),
521 MyEscape(convert_html($ed_author_info)),
522 $width2, $height2));
523 }
524 $tp->assign("med", $isMed ? true : false);
525 $params = array();
526 if ($section) array_push($params, "section=$section");
527 if ($section_menu) array_push($params, "section_menu=$section_menu");
528 if ($ed_id) array_push($params, "ed_id=$ed_id");
529 if ($ed_preview) array_push($params, "ed_preview=$ed_preview");
530 if ($trigger) array_push($params, "$trigger=1");
531 global $PHP_SELF;
532 $tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?".implode("&", $params)));
533 if (!$ed_preview) {
534 global $onload;
535 $onload .= "document.forms[1].elements[0].focus();";
536 }
537 return $tp->fetch("edit.tpl");
538 }
539 ?>

  ViewVC Help
Powered by ViewVC 1.1.26