/[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.9 - (hide annotations)
Wed Sep 26 13:04:28 2001 UTC (17 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.8: +5 -3 lines
Added some missing files, and some missing features...

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

  ViewVC Help
Powered by ViewVC 1.1.26