/[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

Annotation of /inc/newsEdit.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Wed Sep 19 12:23:57 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.6: +204 -51 lines
Added thefilez/med/ (PLIVAmed site). Other major changes...

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

  ViewVC Help
Powered by ViewVC 1.1.26