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

Diff of /inc/newsEdit.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by ravilov, Thu Aug 30 16:35:36 2001 UTC revision 1.7 by ravilov, Wed Sep 19 12:23:57 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2            set_magic_quotes_runtime(false);
3          # ---KLUDGE-BEGIN---          # ---KLUDGE-BEGIN---
4          function ss(&$i, $k) {          function ss(&$i, $k) {
5                  if (is_array($i)) array_walk($i, "ss");                  if (is_array($i)) array_walk($i, "ss");
# Line 11  Line 12 
12          # ---KLUDGE-END---          # ---KLUDGE-END---
13          $phptmp = "^php";          $phptmp = "^php";
14          function sql($sql) {          function sql($sql) {
15                  # echo "<TT><B>[SQL]</B> $sql<BR>\n";                  #echo "<TT><B>[SQL]</B> $sql<BR>\n";
16          }          }
17          function newsEdit($art, $trigger = "") {          function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); }
18                  global $phptmp, $picdir, $syspicdir, $section, $dbh, $tpl;          function newsEdit($art, $trigger = "", $isVijest = false) {
19                  global $ed_id, $ed_cat;                  global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $section, $section_menu, $dbh, $tpl;
20                    global $ed_id, $ed_cat, $isMed;
21                  $i = 1;                  $i = 1;
22                  global $ed_delete_main, $ed_del_main;                  global $ed_delete_main, $ed_del_main;
23                  $delete_main = $ed_delete_main;                  $delete_main = $ed_delete_main;
24                  $del_main = $ed_del_main;                  $del_main = $ed_del_main;
25                  global $ed_clear_main, $ed_clr_main;                  global $ed_clear_main, $ed_clr_main;
26                    global $ed_clear_author, $ed_clr_author;
27                  $clear_main = $ed_clear_main;                  $clear_main = $ed_clear_main;
28                  $clr_main = $ed_clr_main;                  $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;                  global $ed_titlepic_url, $ed_titlepic_url2, $ed_titlepic_name;
32                  $titlepic_url = $ed_titlepic_url;                  $titlepic_url = $ed_titlepic_url;
33                  $titlepic_url2 = $ed_titlepic_url2;                  $titlepic_url2 = $ed_titlepic_url2;
34                  $titlepic_name = $ed_titlepic_name;                  $titlepic_name = urldecode($ed_titlepic_name);
35                    # Fix for M$IE
36                  if ($titlepic_url == "none") $titlepic_url = "";                  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) {                  while (true) {
44                          global ${"ed_text_id_".$i};                          global ${"ed_text_id_".$i};
45                          if (!isset(${"ed_text_id_".$i})) break;                          if (!isset(${"ed_text_id_".$i})) break;
# Line 37  Line 49 
49                          global ${"ed_clear_".$i}, ${"ed_clr_".$i};                          global ${"ed_clear_".$i}, ${"ed_clr_".$i};
50                          ${"clear_".$i} = ${"ed_clear_".$i};                          ${"clear_".$i} = ${"ed_clear_".$i};
51                          ${"clr_".$i} = ${"ed_clr_".$i};                          ${"clr_".$i} = ${"ed_clr_".$i};
52                          global ${"ed_textpic_url_".$i},                          global ${"ed_textpic_url_".$i}, ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i};
                                 ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i};  
53                          ${"textpic_url_".$i} = ${"ed_textpic_url_".$i};                          ${"textpic_url_".$i} = ${"ed_textpic_url_".$i};
54                          ${"textpic_url2_".$i} = ${"ed_textpic_url2_".$i};                          ${"textpic_url2_".$i} = ${"ed_textpic_url2_".$i};
55                          ${"textpic_name_".$i} = ${"ed_textpic_name_".$i};                          ${"textpic_name_".$i} = urldecode(${"ed_textpic_name_".$i});
56                            # Fix for M$IE
57                          if (${"textpic_url_".$i} == "none") ${"textpic_url_".$i} = "";                          if (${"textpic_url_".$i} == "none") ${"textpic_url_".$i} = "";
58                          $i++;                          $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 (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                  global $cancel, $save;                  global $cancel, $save;
83                  if ($cancel || $save) {                  if ($cancel || $save) {
84                          if ($save) {                          if ($save) {
# Line 60  sql($sql); Line 94  sql($sql);
94                                          $row = array_shift($row);                                          $row = array_shift($row);
95                                          if ($row) MyDelete($syspicdir."/".$row);                                          if ($row) MyDelete($syspicdir."/".$row);
96                                  }                                  }
97                                    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                                  global $ed_title, $ed_lead, $ed_titlepic_alt,                                  global $ed_title, $ed_lead, $ed_titlepic_alt,
109                                          $ed_titlepic_pos, $ed_more, $ed_cat;                                          $ed_titlepic_pos, $ed_more, $ed_more_title,
110                                            $ed_cat, $ed_author_alt, $ed_author_info;
111                                  $ed_title = MyQuote($ed_title);                                  $ed_title = MyQuote($ed_title);
112                                  $ed_lead = MyQuote($ed_lead);                                  $ed_lead = MyQuote($ed_lead);
113                                  $ed_titlepic_nm = MyQuote(basename($titlepic_name));                                  $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                                  $ed_titlepic_alt = MyQuote($ed_titlepic_alt);                                  $ed_titlepic_alt = MyQuote($ed_titlepic_alt);
118                                  $ed_more = MyQuote($ed_more);                                  $ed_more = MyQuote($ed_more);
119                                    $ed_more_title = MyQuote($ed_more_title);
120                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;
121                                  if ($ed_id > 0) {                                  if ($ed_id > 0) {
122                                          $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, url = $ed_more, date = CURRENT_TIMESTAMP WHERE (news_id = $ed_id)";                                          $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  sql($sql);  sql($sql);
124                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
125                                  } else {                                  } else {
126                                          $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, url, date) VALUES ('$ed_cat', $ed_title, $ed_lead, $ed_titlepic_nm, $ed_titlepic_alt, $ed_titlepic_pos, $ed_more, CURRENT_TIMESTAMP)";                                          $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  sql($sql);  sql($sql);
128                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
129                                          $sql = "SELECT news_id FROM news WHERE (title = $ed_title)";                                          $sql = "SELECT news_id FROM news WHERE (title = $ed_title)";
# Line 88  sql($sql); Line 138  sql($sql);
138                                          if (is_array($row)) $row = array_shift($row);                                          if (is_array($row)) $row = array_shift($row);
139                                          if ($row) $ed_id = $row;                                          if ($row) $ed_id = $row;
140                                  }                                  }
141                                  if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", "$syspicdir/$titlepic_name");                                  if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", urldecode("$syspicdir/$titlepic_name"));
142                                    if ($author_url2) MyMove("$sysaupicdir/$author_url2", urldecode("$sysaupicdir/$author_name"));
143                                  $i = 1;                                  $i = 1;
144                                  while ($ed_id > 0 && isset(${"ed_text_id_".$i})) {                                  while ($ed_id > 0 && isset(${"ed_text_id_".$i})) {
145                                          global ${"ed_text_title_".$i}, ${"ed_text_".$i},                                          global ${"ed_text_title_".$i}, ${"ed_text_".$i},
146                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
147                                                  ${"ed_text_level_".$i};                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i};
148                                          list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev) = array(                                          list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev, $hl) = array(
149                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i},                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i},
150                                                  ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i},                                                  ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i},
151                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
152                                                  ${"del_".$i}, ${"ed_text_level_".$i});                                                  ${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i});
153                                          $tit = MyQuote($tit);                                          $tit = MyQuote($tit);
154                                          $txt = MyQuote($txt);                                          $txt = MyQuote($txt);
155                                            $hl = MyQuote($hl);
156                                          $orig = basename($orig);                                          $orig = basename($orig);
157                                          $org = MyQuote($orig);                                          $org = MyQuote($orig);
158                                          $alt = MyQuote($alt);                                          $alt = MyQuote($alt);
# Line 119  sql($sql); Line 171  sql($sql);
171                                                          $sth->finish();                                                          $sth->finish();
172                                                  }                                                  }
173                                                  if ($del) $sql = "DELETE FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";                                                  if ($del) $sql = "DELETE FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
174                                                          else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, pic = $org, alt = $alt, pos = $pos WHERE (news_id = $ed_id) AND (paragraph_id = $id)";                                                          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  sql($sql);  sql($sql);
176                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
177                                          } else if (!$del) {                                          } else if (!$del) {
178                                                  $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos)";                                                  $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos, hl) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos, $hl)";
179  sql($sql);  sql($sql);
180                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
181                                                  $sql = "SELECT paragraph_id FROM paragraphs WHERE (text = $txt)";                                                  $sql = "SELECT paragraph_id FROM paragraphs WHERE (text = $txt)";
# Line 141  sql($sql); Line 193  sql($sql);
193                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");
194                                          $i++;                                          $i++;
195                                  }                                  }
196                                    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                          } else {                          } else {
220                                  // Delete temp pics.                                  // Delete temp pics.
221                                  if (ereg("$phptmp", $titlepic_url2))                                  if (ereg("$phptmp", $titlepic_url2)) MyDelete($syspicdir."/".$titlepic_url2);
222                                          MyDelete($syspicdir."/".$titlepic_url2);                                  if (ereg("$phptmp", $author_url2)) MyDelete($sysaupicdir."/".$author_url2);
223                                  $i = 1;                                  $i = 1;
224                                  while (isset(${"ed_textpic_id_".$i})) {                                  while (isset(${"ed_textpic_id_".$i})) {
225                                          $tmp = ${"textpic_url2_".$i};                                          $tmp = ${"textpic_url2_".$i};
# Line 168  sql($sql); Line 243  sql($sql);
243                          if ($tname == "none") continue;                          if ($tname == "none") continue;
244                          $nm = basename($tname);                          $nm = basename($tname);
245                          $ext = ereg_replace('^.*(\..+)$', '\1', $name);                          $ext = ereg_replace('^.*(\..+)$', '\1', $name);
                         move_uploaded_file($tname, $syspicdir."/".$nm.$ext);  
246                          if ($key == "ed_titlepic_url") {                          if ($key == "ed_titlepic_url") {
247                                    move_uploaded_file($tname, $syspicdir."/".$nm.$ext);
248                                  $titlepic_url = $nm.$ext;                                  $titlepic_url = $nm.$ext;
249                                  $titlepic_name = $name;                                  $titlepic_name = $name;
250                                  $u = $titlepic_url2;                                  $u = $titlepic_url2;
251                                  if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u);                                  if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u);
252                                  unset($clear_main, $clr_main);                                  unset($clear_main, $clr_main);
253                            } 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                          } else if (ereg("^ed_textpic_url_([1-9][0-9]*)$", $key, $regs)) {                          } else if (ereg("^ed_textpic_url_([1-9][0-9]*)$", $key, $regs)) {
261                                    move_uploaded_file($tname, $syspicdir."/".$nm.$ext);
262                                  $n = $regs[1];                                  $n = $regs[1];
263                                  ${"textpic_url_".$n} = $nm.$ext;                                  ${"textpic_url_".$n} = $nm.$ext;
264                                  ${"textpic_name_".$n} = $name;                                  ${"textpic_name_".$n} = $name;
# Line 189  sql($sql); Line 272  sql($sql);
272                  // -----                  // -----
273                  $tp = new Smarty();                  $tp = new Smarty();
274                  // -----                  // -----
                 $categories = array();  
                 $sql = "SELECT cat_id, text FROM news_categories ORDER BY text";  
 sql($sql);  
                 $sth = $dbh->prepare($sql);  
                 if (!$sth) error("Cannot prepare query: \"$sql\"");  
                 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");  
                 while ($row = $sth->fetchrow_array()) array_push($categories, array("id" => $row[0], "txt" => $row[1]));  
                 $sth->finish();  
                 $tp->assign("categories", $categories);  
                 // -----  
275                  $levels = array();                  $levels = array();
276                  $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";                  $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";
277  sql($sql);  sql($sql);
# Line 210  sql($sql); Line 283  sql($sql);
283                  $tp->assign("levels", $levels);                  $tp->assign("levels", $levels);
284                  // -----                  // -----
285                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,
286                          $ed_titlepic_alt, $ed_cat, $ed_more;                          $ed_titlepic_alt, $ed_cat, $ed_more,
287                            $ed_more_title, $ed_author_url, $ed_author_alt,
288                            $ed_author_info;
289                  global $ed_edit, $ed_preview, $preview, $add;                  global $ed_edit, $ed_preview, $preview, $add;
290                  if (!$ed_preview) $ed_preview = ($preview ? true : false);                  if (!$ed_preview) $ed_preview = ($preview ? true : false);
291                  if ($ed_edit) $ed_preview = false;                  if ($ed_edit) $ed_preview = false;
# Line 218  sql($sql); Line 293  sql($sql);
293                  $delete = count(preg_grep('/^ed_delete_[0-9]+$/',                  $delete = count(preg_grep('/^ed_delete_[0-9]+$/',
294                          array_keys(array_merge($HTTP_GET_VARS,                          array_keys(array_merge($HTTP_GET_VARS,
295                          $HTTP_POST_VARS)))) > 0;                          $HTTP_POST_VARS)))) > 0;
296                  $clear = (count(preg_grep('/^ed_clear_(main|[0-9]+)$/',                  global $ed_clear_author;
297                    $clear = (count(preg_grep('/^ed_clear_(main|author|[0-9]+)$/',
298                          array_keys(array_merge($HTTP_GET_VARS,                          array_keys(array_merge($HTTP_GET_VARS,
299                          $HTTP_POST_VARS)))) > 0);                          $HTTP_POST_VARS)))) > 0);
300                  $ed_pgfs = array();                  $ed_pgfs = array();
301                  $ed_warning = 0;                  $ed_warning = 0;
302                    $nspecs = array();
303                    $ncats = array();
304                    // Transfer data
305                  if ($ed_edit || $ed_preview || $add || $delete || $clear) {                  if ($ed_edit || $ed_preview || $add || $delete || $clear) {
306                            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                          global $ed_title, $ed_lead, $ed_titlepic_pos,                          global $ed_title, $ed_lead, $ed_titlepic_pos,
317                                  $ed_titlepic_alt, $ed_cat, $ed_more;                                  $ed_titlepic_alt, $ed_cat, $ed_more,
318                                    $ed_more_title, $ed_author_url,
319                                    $ed_author_alt, $ed_author_info;
320                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";
321                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;
322                          if (!$titlepic_url && !($clear_main || $clr_main))                          if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"];
323                                  $titlepic_url = $art["pic_url"];                          if (!$author_url && !($clear_author || $clr_author)) $author_url = $art["au_pic"];
324                          list($width, $height) = PicSize($titlepic_url);                          list($width, $height) = PicSize($titlepic_url);
325                            list($width2, $height2) = PicSize($author_url, $sysaupicdir);
326                          global $ed_title_force;                          global $ed_title_force;
327                          if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;                          if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;
328                          $i = 1;                          $i = 1;
# Line 238  sql($sql); Line 330  sql($sql);
330                                  $id = ${"ed_text_id_".$i};                                  $id = ${"ed_text_id_".$i};
331                                  global ${"ed_text_".$i}, ${"ed_text_title_".$i},                                  global ${"ed_text_".$i}, ${"ed_text_title_".$i},
332                                          ${"ed_text_level_".$i}, ${"ed_textpic_alt_".$i},                                          ${"ed_text_level_".$i}, ${"ed_textpic_alt_".$i},
333                                          ${"ed_textpic_pos_".$i};                                          ${"ed_textpic_pos_".$i}, ${"ed_hl_".$i};
334                                  $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?                                  $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?
335                                          ${"textpic_url_".$i} : "";                                          ${"textpic_url_".$i} : "";
336                                  if (!$pic_url) $pic_url = ${"textpic_url2_".$i};                                  if (!$pic_url) $pic_url = ${"textpic_url2_".$i};
# Line 254  sql($sql); Line 346  sql($sql);
346                                          ${"ed_text_".$i}, ${"ed_text_title_".$i},                                          ${"ed_text_".$i}, ${"ed_text_title_".$i},
347                                          $level, $class, $pic_url, ${"textpic_name_".$i},                                          $level, $class, $pic_url, ${"textpic_name_".$i},
348                                          ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                          ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
349                                          false));                                          0, 0, ${"ed_hl_".$i}, false));
350                                  $i++;                                  $i++;
351                          }                          }
352                  } else {                  } else {
353                            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                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,
370                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,
371                                  $ed_cat, $ed_more, $width, $height) = array($art["title"],                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,
372                                  $art["lead"], $art["pic_pos"], $art["pic_url"],                                  $author_url, $author_url2, $author_name,
373                                  $art["pic_url"], $art["pic_url"], $art["pic_alt"],                                  $ed_author_alt, $ed_author_info, $width2, $height2) =
374                                  $art["category"], $art["more"], $art["pic_w"], $art["pic_h"]);                                  array($art["title"], $art["lead"], $art["pic_pos"],
375                                    $art["pic_url"], $art["pic_url"], urldecode($art["pic_url"]),
376                                    $art["pic_alt"], $art["category"], $art["more"],
377                                    $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                          while ($art["text"] && list($id, $val) = each($art["text"])) {                          while ($art["text"] && list($id, $val) = each($art["text"])) {
381                                  list($id, $txt, $title, $lev, $cls, $pic, $alt, $pos, $w, $h) = array(                                  list($id, $txt, $title, $lev, $cls, $pic, $alt, $pos, $w, $h) = array(
382                                          $val["id"], $val["text"], $val["title"], $val["level"],                                          $val["id"], $val["text"], $val["title"], $val["level"],
383                                          $val["class"], $val["pic"], $val["alt"], $val["pos"],                                          $val["class"], urldecode($val["pic"]), $val["alt"], $val["pos"],
384                                          $val["w"], $val["h"]);                                          $val["w"], $val["h"]);
385                                  array_push($ed_pgfs, array($id, $txt, $title, $lev, $cls, $pic, $pic, $alt,                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],
386                                          $pos, $w, $h, false));                                          $val["level"], $val["class"], urldecode($val["pic"]),
387                                            urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"],
388                                            $val["h"], $val["hl"], false));
389                          }                          }
390                          $ed_id = $art["id"];                          $ed_id = $art["id"];
391                          if (!$ed_id) $ed_id = -1;                          if (!$ed_id) $ed_id = -1;
392                  }                  }
393                    $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                  if ($add) {                  if ($add) {
403                          global $add_num;                          global $add_num;
404                          for ($i = 0; $i < intval($add_num); $i++)                          for ($i = 0; $i < intval($add_num); $i++)
405                                  array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", 0, 0, 0, true));                                  array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", 0, 0, 0, "", true));
406                  }                  }
407                  $ed_empty = ($ed_title || $ed_lead || $ed_titlepic_pos || $ed_more) ? false : true;                  $ed_empty = ($ed_title || $ed_lead || $ed_titlepic_pos || $ed_more) ? false : true;
408                  $ed_text = array();                  $ed_text = array();
# Line 286  sql($sql); Line 410  sql($sql);
410                  $ed_warnings = ($ed_warning ? true : false);                  $ed_warnings = ($ed_warning ? true : false);
411                  $i = 1;                  $i = 1;
412                  while (list($key, $val) = each($ed_pgfs)) {                  while (list($key, $val) = each($ed_pgfs)) {
413                          list($id, $txt, $tit, $lev, $cls, $pic, $name, $alt, $pos, $w, $h, $new) = $val;                          list($id, $txt, $tit, $lev, $cls, $pic, $name, $alt, $pos, $w, $h, $hl, $new) = $val;
414                          $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);                          $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);
415                          array_push($ed_records, array("val" => $del, "id" => $id));                          array_push($ed_records, array("val" => $del, "id" => $id));
416                          if ($del) { $i++; continue; }                          if ($del) { $i++; continue; }
417                          $picurl = ${"textpic_url_".$id};                          $picurl = ${"textpic_url_".$id};
418                          if (!$picurl) $picurl = $pic;                          if (!$picurl) $picurl = $pic;
419                          $class = "";                          $class = "";
420                          while (list($key, $val) = each($levels))                          while (list($key, $val) = each($levels)) if ($val["id"] == $lev) $class = $val["class"];
                                 if ($val["id"] == $lev) $class = $val["class"];  
421                          if ((${"clear_".$i} || ${"clr_".$i}) && $ed_preview && (${"textpic_name_".$i} != ${"textpic_url2_".$i})) {                          if ((${"clear_".$i} || ${"clr_".$i}) && $ed_preview && (${"textpic_name_".$i} != ${"textpic_url2_".$i})) {
422                                  $tmp = ${"textpic_url2_".$i};                                  $tmp = ${"textpic_url2_".$i};
423                                  if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);                                  if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
424                                  $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";                                  $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";
425                          }                          }
426                          if (!$name) $name = $picurl;                          if (!$name) $name = $picurl;
427                          $txt = MyEscape(convert_html($txt));                          $txt = MyEscape(convert_html($txt), false);
428                          $txt2 = ParseNewline($txt, true);                          $txt2 = ParseNewline($txt, true);
429                            $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                          global ${"ed_text_force_".$i};                          global ${"ed_text_force_".$i};
440                          $force = ${"ed_text_force_".$i};                          $force = ${"ed_text_force_".$i};
441                          $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);                          $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);
# Line 316  sql($sql); Line 449  sql($sql);
449                                  "n" => $i,                                  "n" => $i,
450                                  "txt" => $txt2,                                  "txt" => $txt2,
451                                  "txt2" => $txt,                                  "txt2" => $txt,
452                                    "txt3" => $txt3,
453                                    "hl" => $hl2,
454                                    "hl2" => $hl,
455                                    "hl3" => $hl3,
456                                  "title" => MyEscape(convert_html($tit)),                                  "title" => MyEscape(convert_html($tit)),
457                                  "level" => $lev,                                  "level" => $lev,
458                                  "class" => MyEscape(convert_html($class)),                                  "class" => MyEscape(convert_html($class)),
# Line 344  sql($sql); Line 481  sql($sql);
481                  $tp->assign("ed_titlepic_alt", MyEscape(convert_html($ed_titlepic_alt)));                  $tp->assign("ed_titlepic_alt", MyEscape(convert_html($ed_titlepic_alt)));
482                  $tp->assign("ed_titlepic_width", $width);                  $tp->assign("ed_titlepic_width", $width);
483                  $tp->assign("ed_titlepic_height", $height);                  $tp->assign("ed_titlepic_height", $height);
484                    $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                  $tp->assign("ed_more", MyEscape($ed_more));                  $tp->assign("ed_more", MyEscape($ed_more));
492                    $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);
493                    $tp->assign("ed_more_title", MyEscape($ed_more_title));
494                  $tp->assign("ed_clr_main", ($clear_main || $clr_main || !$titlepic_url) ? true : false);                  $tp->assign("ed_clr_main", ($clear_main || $clr_main || !$titlepic_url) ? true : false);
495                    $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false);
496                  $tp->assign("ed_text", $ed_text);                  $tp->assign("ed_text", $ed_text);
497                  $tp->assign("ed_empty", $ed_empty);                  $tp->assign("ed_empty", $ed_empty);
498                  $tp->assign("ed_warning", $ed_warning);                  $tp->assign("ed_warning", $ed_warning);
499                  $tp->assign("ed_warnings", $ed_warnings);                  $tp->assign("ed_warnings", $ed_warnings);
500                  $tp->assign("ed_records", $ed_records);                  $tp->assign("ed_records", $ed_records);
501                  $tp->assign("newspicdir", "$picdir/");                  $tp->assign("newspicdir", "$picdir/");
502                    $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                  $params = array();                  $params = array();
513                  if ($section) array_push($params, "section=$section");                  if ($section) array_push($params, "section=$section");
514                    if ($section_menu) array_push($params, "section_menu=$section_menu");
515                  if ($ed_id) array_push($params, "ed_id=$ed_id");                  if ($ed_id) array_push($params, "ed_id=$ed_id");
516                  if ($ed_preview) array_push($params, "ed_preview=$ed_preview");                  if ($ed_preview) array_push($params, "ed_preview=$ed_preview");
517                  if ($trigger) array_push($params, "$trigger=1");                  if ($trigger) array_push($params, "$trigger=1");
518                  global $PHP_SELF;                  global $PHP_SELF;
519                  $tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?".implode("&", $params)));                  $tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?".implode("&", $params)));
520                  global $onload;                  if (!$ed_preview) {
521                  $onload .= "document.forms[0].elements[0].focus();";                          global $onload;
522                            $onload .= "document.forms[0].elements[0].focus();";
523                    }
524                  return $tp->fetch("edit.tpl");                  return $tp->fetch("edit.tpl");
525          }          }
526  ?>  ?>

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26