/[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.9 by ravilov, Wed Sep 26 13:04:28 2001 UTC revision 1.18 by ravilov, Sat Oct 27 16:54:50 2001 UTC
# Line 15  Line 15 
15                  #echo "<TT><B>[SQL]</B> $sql<BR>\n";                  #echo "<TT><B>[SQL]</B> $sql<BR>\n";
16          }          }
17          function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); }          function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); }
18            function my_cmp_2($a, $b) { return MyCompare($a["ime"], $b["ime"]); }
19          function newsEdit($art, $trigger = "", $isVijest = false) {          function newsEdit($art, $trigger = "", $isVijest = false) {
20                  global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $dbh, $tpl;                  global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $dbh;
21                  global $section, $section_menu, $section_menu2, $spec;                  global $section, $section_menu, $section_menu2, $spec;
22                  global $ed_id, $ed_cat, $isMed;                  global $ed_id, $ed_cat, $isMed;
23                  $i = 1;                  $i = 1;
# Line 50  Line 51 
51                          global ${"ed_clear_".$i}, ${"ed_clr_".$i};                          global ${"ed_clear_".$i}, ${"ed_clr_".$i};
52                          ${"clear_".$i} = ${"ed_clear_".$i};                          ${"clear_".$i} = ${"ed_clear_".$i};
53                          ${"clr_".$i} = ${"ed_clr_".$i};                          ${"clr_".$i} = ${"ed_clr_".$i};
54                            global ${"ed_fclear_".$i}, ${"ed_fclr_".$i};
55                            ${"fclear_".$i} = ${"ed_fclear_".$i};
56                            ${"fclr_".$i} = ${"ed_fclr_".$i};
57                          global ${"ed_textpic_url_".$i}, ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i};                          global ${"ed_textpic_url_".$i}, ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i};
58                          ${"textpic_url_".$i} = ${"ed_textpic_url_".$i};                          ${"textpic_url_".$i} = ${"ed_textpic_url_".$i};
59                          ${"textpic_url2_".$i} = ${"ed_textpic_url2_".$i};                          ${"textpic_url2_".$i} = ${"ed_textpic_url2_".$i};
60                          ${"textpic_name_".$i} = urldecode(${"ed_textpic_name_".$i});                          ${"textpic_name_".$i} = urldecode(${"ed_textpic_name_".$i});
61                          # Fix for M$IE                          # Fix for M$IE
62                          if (${"textpic_url_".$i} == "none") ${"textpic_url_".$i} = "";                          if (${"textpic_url_".$i} == "none") ${"textpic_url_".$i} = "";
63                            global ${"ed_textpic_full_".$i}, ${"ed_textpic_full2_".$i}, ${"ed_textpic_fname_".$i};
64                            ${"textpic_full_".$i} = ${"ed_textpic_full_".$i};
65                            ${"textpic_full2_".$i} = ${"ed_textpic_full2_".$i};
66                            ${"textpic_fname_".$i} = urldecode(${"ed_textpic_fname_".$i});
67                            # Fix for M$IE
68                            if (${"textpic_full_".$i} == "none") ${"textpic_full_".$i} = "";
69                          $i++;                          $i++;
70                  }                  }
71                  // -----                  // -----
# Line 70  sql($sql); Line 80  sql($sql);
80                  $sth->finish();                  $sth->finish();
81                  usort($categories, "my_cmp");                  usort($categories, "my_cmp");
82                  // -----                  // -----
83                    $autori = array();
84                    $sql = "SELECT autor_id, ime FROM autori";
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($autori, array("id" => $row[0], "ime" => MyEscape($row[1], false)));
90                    $sth->finish();
91                    usort($autori, "my_cmp_2");
92                    // -----
93                    $newsi = array();
94                    #$sql = "SELECT news_id, title FROM news WHERE (".($isMed?"":"NOT ")."plivamed) ORDER BY title";
95                    $sql = "SELECT news_id, title FROM news";
96                    if ($ed_id && $ed_id > 0) $sql .= " WHERE (news_id != $ed_id)";
97                    $sql .= " ORDER BY title";
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                    while ($row = $sth->fetchrow_array()) {
103                            $txt = $row[1];
104                            if (strlen($txt) > 55) $txt = substr($txt, 0, 55)."...";
105                            array_push($newsi, array("id" => $row[0], "txt" => $txt));
106                    }
107                    $sth->finish();
108                    usort($newsi, "my_cmp");
109                    // -----
110                  $specs = array();                  $specs = array();
111                  $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)";                  $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)";
112  sql($sql);  sql($sql);
# Line 79  sql($sql); Line 116  sql($sql);
116                  while ($row = $sth->fetchrow_array()) array_push($specs, array("id" => $row[0], "txt" => $row[1]));                  while ($row = $sth->fetchrow_array()) array_push($specs, array("id" => $row[0], "txt" => $row[1]));
117                  $sth->finish();                  $sth->finish();
118                  usort($specs, "my_cmp");                  usort($specs, "my_cmp");
119                    array_unshift($specs, array("id" => 0, "txt" => "HOME"));
120                  // -----                  // -----
121                  $levels = array();                  $levels = array();
122                  $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";                  $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";
# Line 117  sql($sql); Line 155  sql($sql);
155                                  }                                  }
156                                  global $ed_title, $ed_lead, $ed_titlepic_alt,                                  global $ed_title, $ed_lead, $ed_titlepic_alt,
157                                          $ed_titlepic_pos, $ed_more, $ed_more_title,                                          $ed_titlepic_pos, $ed_more, $ed_more_title,
158                                          $ed_cat, $ed_author_alt, $ed_author_info;                                          $ed_cat, $ed_author_alt, $ed_author_info,
159                                            $ed_author_ime, $ed_author_cv, $ed_exclusive,
160                                            $ed_prikazi;
161                                  $ed_title = MyQuote($ed_title);                                  $ed_title = MyQuote($ed_title);
162                                  $ed_lead = MyQuote($ed_lead);                                  $ed_lead = MyQuote($ed_lead);
163                                  $ed_author_nm = urldecode(MyQuote(basename($author_name)));                                  $ed_author_nm = urldecode(MyQuote(basename($author_name)));
164                                  $ed_author_alt = MyQuote($ed_author_alt);                                  $ed_author_alt = MyQuote($ed_author_alt);
165                                    $ed_author_ime = MyQuote($ed_author_ime);
166                                  $ed_author_info = MyQuote($ed_author_info);                                  $ed_author_info = MyQuote($ed_author_info);
167                                  $ed_titlepic_nm = urldecode(MyQuote(basename($titlepic_name)));                                  $ed_titlepic_nm = urldecode(MyQuote(basename($titlepic_name)));
168                                  $ed_titlepic_alt = MyQuote($ed_titlepic_alt);                                  $ed_titlepic_alt = MyQuote($ed_titlepic_alt);
169                                  $ed_more = MyQuote($ed_more);                                  $ed_more = MyQuote($ed_more);
170                                  $ed_more_title = MyQuote($ed_more_title);                                  $ed_more_title = MyQuote($ed_more_title);
171                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;
172                                    if (!$ed_author_cv) $ed_author_cv = 0;
173                                    if (!isset($ed_exclusive)) $ed_exclusive = false;
174                                  if ($ed_id > 0) {                                  if ($ed_id > 0) {
175                                          $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)";                                          $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, author_name = $ed_author_ime, autor_cv = $ed_author_cv, exclusive = ".($ed_exclusive?"true":"false").", url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", prikazi = ".($ed_prikazi?"true":"false").", ord = 0, d_change = NOW() WHERE (news_id = $ed_id)";
176  sql($sql);  sql($sql);
177                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
178                                  } else {                                  } else {
179                                          $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())";                                          $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, author_pic, author_alt, author_info, author_name, autor_cv, exclusive, url, url_title, plivamed, prikazi, 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_author_ime, $ed_author_cv, ".($ed_exclusive?"true":"false").", $ed_more, $ed_more_title, ".($isMed?"true":"false").", ".($ed_prikazi?"true":"false").", NOW(), NOW())";
180  sql($sql);  sql($sql);
181                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
182                                          $sql = "SELECT news_id FROM news WHERE (title = $ed_title)";                                          $sql = "SELECT currval('news_news_id_seq')::text";
183  sql($sql);  sql($sql);
184                                          $sth = $dbh->prepare($sql);                                          $sth = $dbh->prepare($sql);
185                                          if (!$sth) error("Cannot prepare query: \"$sql\"");                                          if (!$sth) error("Cannot prepare query: \"$sql\"");
# Line 159  sql($sql); Line 202  sql($sql);
202                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
203                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i},                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i},
204                                                  ${"ed_textpic_exp_".$i};                                                  ${"ed_textpic_exp_".$i};
205                                          list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev, $hl, $exp) = array(                                          list($id, $tit, $txt, $pic, $orig,$full, $forig, $alt, $pos, $del, $lev, $hl, $exp) = array(
206                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i},                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i}, ${"ed_text_".$i},
207                                                  ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i},                                                  ${"textpic_url2_".$i}, ${"textpic_name_".$i}, ${"textpic_full2_".$i},
208                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"textpic_fname_".$i}, ${"ed_textpic_alt_".$i},
209                                                  ${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i},                                                  ${"ed_textpic_pos_".$i}, ${"del_".$i}, ${"ed_text_level_".$i},
210                                                  ${"ed_textpic_exp_".$i});                                                  ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i});
211                                          if ($lev != $last_level) {                                          if ($lev != $last_level) {
212                                                  if ($last_level) {                                                  if ($last_level) {
213                                                          if ($last_level < $lev) array_push($parents, $id);                                                          if ($last_level < $lev) array_push($parents, $id);
# Line 180  sql($sql); Line 223  sql($sql);
223                                          $hl = MyQuote($hl);                                          $hl = MyQuote($hl);
224                                          $orig = basename($orig);                                          $orig = basename($orig);
225                                          $org = MyQuote($orig);                                          $org = MyQuote($orig);
226                                            $forig = basename($forig);
227                                            $forg = MyQuote($forig);
228                                          $alt = MyQuote($alt);                                          $alt = MyQuote($alt);
229                                          if (!$pos) $pos = 0;                                          if (!$pos) $pos = 0;
230                                          if ($id && $id > 0) {                                          if ($id && $id > 0) {
# Line 190  sql($sql); Line 235  sql($sql);
235                                                          if (!$sth) error("Cannot prepare query: \"$sql\"");                                                          if (!$sth) error("Cannot prepare query: \"$sql\"");
236                                                          if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                                                          if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
237                                                          while ($row = $sth->fetchrow_array()) {                                                          while ($row = $sth->fetchrow_array()) {
238                                                                  list($pic) = $row;                                                                  list($pic2) = $row;
239                                                                  MyDelete($syspicdir."/".$pic);                                                                  MyDelete($syspicdir."/".$pic2);
240                                                            }
241                                                            $sth->finish();
242                                                    }
243                                                    if ($del || !$forig) {
244                                                            $sql = "SELECT full_pic FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
245    sql($sql);
246                                                            $sth = $dbh->prepare($sql);
247                                                            if (!$sth) error("Cannot prepare query: \"$sql\"");
248                                                            if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
249                                                            while ($row = $sth->fetchrow_array()) {
250                                                                    list($pic2) = $row;
251                                                                    MyDelete($syspicdir."/".$pic2);
252                                                          }                                                          }
253                                                          $sth->finish();                                                          $sth->finish();
254                                                  }                                                  }
255                                                  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)";
256                                                          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)";                                                          else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, hl = $hl, pic = $org, full_pic = $forg, alt = $alt, pos = $pos, pic_title = $exp WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
257  sql($sql);  sql($sql);
258                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
259                                          } else if (!$del) {                                          } else if (!$del) {
260                                                  $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)";                                                  $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, full_pic, alt, pos, hl, pic_title) VALUES ($ed_id, $tit, $lev, $txt, $org, $forg, $alt, $pos, $hl, $exp)";
261  sql($sql);  sql($sql);
262                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
263                                                  $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";                                                  $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";
# Line 214  sql($sql); Line 271  sql($sql);
271                                                  $last_id = $id = $row;                                                  $last_id = $id = $row;
272                                          }                                          }
273                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");
274                                            if ($full) MyMove("$syspicdir/$full", "$syspicdir/$forig");
275                                          $i++;                                          $i++;
276                                  }                                  }
277                                  if ($ed_id) {                                  if ($ed_id) {
# Line 221  sql($sql); Line 279  sql($sql);
279  sql($sql);  sql($sql);
280                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
281                                          for ($k = 0; $k < count($specs); $k++) {                                          for ($k = 0; $k < count($specs); $k++) {
282                                                  $var = "ed_spec_".$specs[$k]["id"]; global $$var;                                                  $var = "ed_spec_".$specs[$k]["id"];
283                                                    global $$var;
284                                                  if (!$$var) continue;                                                  if (!$$var) continue;
285                                                  $sql = "INSERT INTO spec_news (news_id, spec_id) VALUES ($ed_id, ".$specs[$k]["id"].")";                                                  $sql = "INSERT INTO spec_news (news_id, spec_id) VALUES ($ed_id, ".$specs[$k]["id"].")";
286  sql($sql);  sql($sql);
287                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
288                                          }                                          }
289                                            $sql = "DELETE FROM related WHERE (news_id = $ed_id)";
290    sql($sql);
291                                            $dbh->dbh_do($sql);
292                                            $x = 1;
293                                            $foo = array();
294                                            while (true) {
295                                                    $var = "ed_related_".$x;
296                                                    $x++;
297                                                    global $$var;
298                                                    if (!isset($$var)) break;
299                                                    if (!$$var) continue;
300                                                    if ($foo[$$var]) continue;
301                                                    $foo[$$var] = true;
302                                                    $sql = "INSERT INTO related (news_id, rel_id) VALUES ($ed_id, ".$$var.")";
303    sql($sql);
304                                                    $dbh->dbh_do($sql);
305                                            }
306                                          $sql = "DELETE FROM cat_news WHERE (news_id = $ed_id)";                                          $sql = "DELETE FROM cat_news WHERE (news_id = $ed_id)";
307  sql($sql);  sql($sql);
308                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
# Line 247  sql($sql); Line 323  sql($sql);
323                                  while (isset(${"ed_textpic_id_".$i})) {                                  while (isset(${"ed_textpic_id_".$i})) {
324                                          $tmp = ${"textpic_url2_".$i};                                          $tmp = ${"textpic_url2_".$i};
325                                          if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);                                          if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
326                                            $tmp = ${"textpic_full2_".$i};
327                                            if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
328                                          $i++;                                          $i++;
329                                  }                                  }
330                          }                          }
# Line 289  sql($sql); Line 367  sql($sql);
367                                  $u = ${"textpic_url2_".$n};                                  $u = ${"textpic_url2_".$n};
368                                  if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);                                  if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);
369                                  unset(${"clear_".$n}, ${"clr_".$n});                                  unset(${"clear_".$n}, ${"clr_".$n});
370                            } else if (ereg("^ed_textpic_full_([1-9][0-9]*)$", $key, $regs)) {
371                                    move_uploaded_file($tname, $syspicdir."/".$nm.$ext);
372                                    $n = $regs[1];
373                                    ${"textpic_full_".$n} = $nm.$ext;
374                                    ${"textpic_fname_".$n} = $name;
375                                    $u = ${"textpic_full2_".$n};
376                                    if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);
377                                    unset(${"fclear_".$n}, ${"fclr_".$n});
378                          } else {                          } else {
379                                  // [?!?]                                  // ?!?
380                          }                          }
381                  }                  }
382                  // -----                  // -----
383                  $tp = new Smarty();                  $tp = new Smarty();
                 // -----  
384                  $tp->assign("levels", $levels);                  $tp->assign("levels", $levels);
385                    $tp->assign("autori", $autori);
386                    $tp->assign("newsi", $newsi);
387                  // -----                  // -----
388                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,
389                          $ed_titlepic_alt, $ed_cat, $ed_more,                          $ed_titlepic_alt, $ed_cat, $ed_more,
390                          $ed_more_title, $ed_author_url, $ed_author_alt,                          $ed_more_title, $ed_author_url, $ed_author_alt,
391                          $ed_author_info;                          $ed_author_info, $ed_author_ime, $ed_prikazi;
392                  global $ed_edit, $ed_preview, $preview, $add;                  global $ed_edit, $ed_preview, $preview, $add;
393                  if (!$ed_preview) $ed_preview = ($preview ? true : false);                  if (!$ed_preview) $ed_preview = ($preview ? true : false);
394                  if ($ed_edit) $ed_preview = false;                  if ($ed_edit) $ed_preview = false;
# Line 317  sql($sql); Line 404  sql($sql);
404                  $ed_warning = 0;                  $ed_warning = 0;
405                  $nspecs = array();                  $nspecs = array();
406                  $ncats = array();                  $ncats = array();
407                    $related = array();
408                  // Transfer data                  // Transfer data
409                  if ($ed_edit || $ed_preview || $add || $delete || $clear) {                  if ($ed_edit || $ed_preview || $add || $delete || $clear) {
410                          for ($i = 0; $i < count($specs); $i++) {                          for ($i = 0; $i < count($specs); $i++) {
411                                  $var = "ed_spec_".$specs[$i]["id"];                                  $var = "ed_spec_".$specs[$i]["id"];
412                                  global $$var;                                  global $$var;
413                                  $nspecs[$specs[$i]["id"]] = $$var ? true : false;                                  $foo = isset($$var) ? $$var : ($spec && $spec == $specs[$i]["id"]);
414                                    $nspecs[$specs[$i]["id"]] = $foo ? true : false;
415                          }                          }
416                          for ($i = 0; $i < count($categories); $i++) {                          for ($i = 0; $i < count($categories); $i++) {
417                                  $var = "ed_cat_".$categories[$i]["id"];                                  $var = "ed_cat_".$categories[$i]["id"];
# Line 330  sql($sql); Line 419  sql($sql);
419                                  $ncats[$categories[$i]["id"]] = $$var ? true : false;                                  $ncats[$categories[$i]["id"]] = $$var ? true : false;
420                          }                          }
421                          global $ed_title, $ed_lead, $ed_titlepic_pos,                          global $ed_title, $ed_lead, $ed_titlepic_pos,
422                                  $ed_titlepic_alt, $ed_cat, $ed_more,                                  $ed_titlepic_alt, $ed_cat, $ed_more, $ed_more_title,
423                                  $ed_more_title, $ed_author_url,                                  $ed_author_url, $ed_author_alt, $ed_author_info,
424                                  $ed_author_alt, $ed_author_info;                                  $ed_author_ime, $ed_author_cv, $ed_exclusive, $ed_prikazi;
425                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";
426                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;
427                          if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"];                          if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"];
# Line 342  sql($sql); Line 431  sql($sql);
431                          global $ed_title_force;                          global $ed_title_force;
432                          if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;                          if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;
433                          $i = 1;                          $i = 1;
434                            while (true) {
435                                    $var = "ed_related_".$i;
436                                    global $$var;
437                                    if (!isset($$var)) break;
438                                    array_push($related, $$var);
439                                    $i++;
440                            }
441                            $i = 1;
442                          while (isset(${"ed_text_id_".$i})) {                          while (isset(${"ed_text_id_".$i})) {
443                                  $id = ${"ed_text_id_".$i};                                  $id = ${"ed_text_id_".$i};
444                                  global ${"ed_text_".$i}, ${"ed_text_title_".$i},                                  global ${"ed_text_".$i}, ${"ed_text_title_".$i},
# Line 351  sql($sql); Line 448  sql($sql);
448                                  $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?                                  $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?
449                                          ${"textpic_url_".$i} : "";                                          ${"textpic_url_".$i} : "";
450                                  if (!$pic_url) $pic_url = ${"textpic_url2_".$i};                                  if (!$pic_url) $pic_url = ${"textpic_url2_".$i};
451                                    $full_url = ($HTTP_POST_FILES["ed_textpic_full_".$i]["name"]) ?
452                                            ${"textpic_full_".$i} : "";
453                                    if (!$full_url) $full_url = ${"textpic_full2_".$i};
454                                  $tmp = "";                                  $tmp = "";
455                                  for ($j = 0; $j < count($art["text"]); $j++)                                  for ($j = 0; $j < count($art["text"]); $j++)
456                                          if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"];                                          if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"];
457                                  if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp;                                  if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp;
458                                    $tmp = "";
459                                    for ($j = 0; $j < count($art["text"]); $j++)
460                                            if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["full"];
461                                    if (!$full_url && $tmp && !(${"fclear_".$i} || ${"fclr_".$i})) $full_url = $tmp;
462                                  $level = ${"ed_text_level_".$i};                                  $level = ${"ed_text_level_".$i};
463                                  list($w, $h) = PicSize($pic_url);                                  list($w, $h) = PicSize($pic_url);
464                                    list($w2, $h2) = PicSize($full_url);
465                                  array_push($ed_pgfs, array($id,                                  array_push($ed_pgfs, array($id,
466                                          ${"ed_text_".$i}, ${"ed_text_title_".$i},                                          ${"ed_text_".$i}, ${"ed_text_title_".$i},
467                                          $level, $pic_url, ${"textpic_name_".$i},                                          $level, $pic_url, ${"textpic_name_".$i},
468                                            $full_url, ${"textpic_fname_".$i},
469                                          ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                          ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
470                                          $w, $h, ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i}, false));                                          $w, $h, $w2, $h2, ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i}, false));
471                                  $i++;                                  $i++;
472                          }                          }
473                  } else {                  } else {
# Line 380  sql($sql); Line 486  sql($sql);
486                                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
487                                  while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;                                  while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;
488                                  $sth->finish();                                  $sth->finish();
489                                    $sql = "SELECT rel_id FROM related WHERE (news_id = $ed_id)";
490    sql($sql);
491                                    $sth = $dbh->prepare($sql);
492                                    if (!$sth) error("Cannot prepare query: \"$sql\"");
493                                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
494                                    while ($row = $sth->fetchrow_array()) {
495                                            list($id) = $row;
496                                            array_push($related, $id);
497                                    }
498                                    $sth->finish();
499                            } else {
500                                    $art["show"] = false;
501                                    for ($j = 0; $j < count($specs); $j++)
502                                            $nspecs[$specs[$j]["id"]] = ($specs[$j]["id"] == $spec) ? true : false;
503                          }                          }
504                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,
505                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,
506                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,
507                                  $author_url, $author_url2, $author_name,                                  $author_url, $author_url2, $author_name,
508                                  $ed_author_alt, $ed_author_info, $width2, $height2) =                                  $ed_author_alt, $ed_author_info, $width2, $height2,
509                                  array($art["title"], $art["lead"], $art["pic_pos"],                                  $ed_author_ime, $ed_author_cv, $ed_exclusive, $ed_prikazi) =
510                                  $art["pic_url"], $art["pic_url"], urldecode($art["pic_url"]),                                  array($art["title"], $art["lead"], $art["pic_pos"], $art["pic_url"],
511                                  $art["pic_alt"], $art["category"], $art["more"],                                  $art["pic_url"], urldecode($art["pic_url"]), $art["pic_alt"],
512                                  $art["more_title"], $art["pic_w"], $art["pic_h"],                                  $art["category"], $art["more"], $art["more_title"], $art["pic_w"],
513                                  $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),                                  $art["pic_h"], $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),
514                                  $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"]);                                  $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"],
515                                    $art["au_name"], $art["au_cv"], $art["ex"], $art["show"]);
516                            if ($art["text"]) reset($art["text"]);
517                          while ($art["text"] && list($id, $val) = each($art["text"])) {                          while ($art["text"] && list($id, $val) = each($art["text"])) {
518                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],
519                                          $val["level"], urldecode($val["pic"]),                                          $val["level"], urldecode($val["pic"]),
520                                          urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"],                                          urldecode($val["pic"]), urldecode($val["full"]), urldecode($val["full"]),
521                                          $val["h"], $val["hl"], $val["exp"], false));                                          $val["alt"], $val["pos"], $val["w"], $val["h"], $val["fw"], $val["fh"],
522                                            $val["hl"], $val["exp"], false));
523                          }                          }
524                          $ed_id = $art["id"];                          $ed_id = $art["id"];
525                          if (!$ed_id) $ed_id = -1;                          if (!$ed_id) $ed_id = -1;
526                  }                  }
527                    for ($i = count($related); $i < 10; $i++) array_push($related, 0);
528                    $tp->assign("related", $related);
529                  $ncats[$ed_cat] = true;                  $ncats[$ed_cat] = true;
530                  for ($i = 0; $i < count($specs); $i++) $specs[$i]["check"] = $nspecs[$specs[$i]["id"]];                  for ($i = 0; $i < count($specs); $i++) $specs[$i]["check"] = $nspecs[$specs[$i]["id"]];
531                  for ($i = 0; $i < count($categories); $i++) $categories[$i]["check"] = $ncats[$categories[$i]["id"]];                  for ($i = 0; $i < count($categories); $i++) $categories[$i]["check"] = $ncats[$categories[$i]["id"]];
# Line 413  sql($sql); Line 538  sql($sql);
538                  if ($add) {                  if ($add) {
539                          global $add_num;                          global $add_num;
540                          for ($i = 0; $i < intval($add_num); $i++)                          for ($i = 0; $i < intval($add_num); $i++)
541                                  array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", 0, 0, 0, "", "", true));                                  array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", "", 0, 0, 0, 0, 0, "", "", true));
542                  }                  }
543                  $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;
544                  $ed_text = array();                  $ed_text = array();
# Line 421  sql($sql); Line 546  sql($sql);
546                  $ed_warnings = ($ed_warning ? true : false);                  $ed_warnings = ($ed_warning ? true : false);
547                  $i = 1;                  $i = 1;
548                  while (list($key, $val) = each($ed_pgfs)) {                  while (list($key, $val) = each($ed_pgfs)) {
549                          list($id, $txt, $tit, $lev, $pic, $name, $alt, $pos, $w, $h, $hl, $exp, $new) = $val;                          list($id, $txt, $tit, $lev, $pic, $name, $fpic, $fname, $alt, $pos, $w, $h, $fw, $fh, $hl, $exp, $new) = $val;
550                          $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);                          $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);
551                          array_push($ed_records, array("val" => $del, "id" => $id));                          array_push($ed_records, array("val" => $del, "id" => $id));
552                          if ($del) { $i++; continue; }                          if ($del) { $i++; continue; }
553                          $picurl = ${"textpic_url_".$id};                          $picurl = ${"textpic_url_".$id};
554                          if (!$picurl) $picurl = $pic;                          if (!$picurl) $picurl = $pic;
555                            $fullurl = ${"textpic_full_".$id};
556                            if (!$fullurl) $fullurl = $fpic;
557                          $class = "";                          $class = "";
558                          reset($levels);                          reset($levels);
559                          while (list($k, $v) = each($levels)) if ($v["id"] == $lev) $class = $v["class"];                          while (list($k, $v) = each($levels)) if ($v["id"] == $lev) $class = $v["class"];
# Line 436  sql($sql); Line 563  sql($sql);
563                                  $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";                                  $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";
564                          }                          }
565                          if (!$name) $name = $picurl;                          if (!$name) $name = $picurl;
566                          $txt = MyEscape(convert_html($txt), false);                          if ((${"fclear_".$i} || ${"fclr_".$i}) && $ed_preview && (${"textpic_full_".$i} != ${"textpic_full2_".$i})) {
567                          $txt2 = ParseNewline($txt, true);                                  $tmp = ${"textpic_full2_".$i};
568                          $txt3 = str_replace("&", "&amp;", $txt);                                  if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
569                          $txt3 = str_replace("\"", "&quot;", $txt3);                                  $fullurl = ${"textpic_full_".$i} = ${"textpic_full2_".$i} = $fname = "";
570                          $txt3 = str_replace("<", "&lt;", $txt3);                          }
571                          $txt3 = str_replace(">", "&gt;", $txt3);                          if (!$fname) $fname = $fullurl;
572                          $hl = MyEscape(convert_html($hl), false);                          // ----
573                          $hl2 = ParseNewline($hl, true);                          $txt3 = MyEscape(convert_html($txt), true);
574                          if ($hl2) $hl2 = GetHighlight($hl2);                          $txt = str_replace("&", "&amp;", MyEscape(convert_html($txt), false));
575                          $hl3 = str_replace("&", "&amp;", $hl);                          $txt2 = $ed_preview ? ParseNewline($txt, true) : $txt3;
576                          $hl3 = str_replace("\"", "&quot;", $hl3);                          // ----
577                          $hl3 = str_replace("<", "&lt;", $hl3);                          $hl3 = MyEscape(convert_html($hl), true);
578                          $hl3 = str_replace(">", "&gt;", $hl3);                          $hl = str_replace("&", "&amp;", MyEscape(convert_html($hl), false));
579                            $hl2 = $ed_preview ? ParseNewline($hl, true) : $hl3;
580                            if ($hl) $hl = GetHighlight($hl);
581                            // ----
582                          global ${"ed_text_force_".$i};                          global ${"ed_text_force_".$i};
583                          $force = ${"ed_text_force_".$i};                          $force = ${"ed_text_force_".$i};
584                          $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);                          $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);
# Line 471  sql($sql); Line 601  sql($sql);
601                                  "class" => MyEscape(convert_html($class)),                                  "class" => MyEscape(convert_html($class)),
602                                  "url" => MyEscape(convert_html($picurl)),                                  "url" => MyEscape(convert_html($picurl)),
603                                  "name" => MyEscape(convert_html($name)),                                  "name" => MyEscape(convert_html($name)),
604                                    "full" => MyEscape(convert_html($fullurl)),
605                                    "fname" => MyEscape(convert_html($fname)),
606                                  "alt" => MyEscape(convert_html($alt)),                                  "alt" => MyEscape(convert_html($alt)),
607                                  "w" => $w,                                  "w" => $w,
608                                  "h" => $h,                                  "h" => $h,
609                                    "fw" => $fw,
610                                    "fh" => $fh,
611                                  "pos" => $pos,                                  "pos" => $pos,
612                                  "exp" => MyEscape(convert_html($exp)),                                  "exp" => MyEscape(convert_html($exp)),
613                                  "warning" => $warning,                                  "warning" => $warning,
614                                  "clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false                                  "clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false,
615                                    "fclr" => (${"fclear_".$i} || ${"fclr_".$i} || !$fullurl) ? true : false
616                          ));                          ));
617                          $i++;                          $i++;
618                  }                  }
# Line 487  sql($sql); Line 622  sql($sql);
622                  $tp->assign("ed_preview", $ed_preview);                  $tp->assign("ed_preview", $ed_preview);
623                  $tp->assign("ed_trigger", $trigger);                  $tp->assign("ed_trigger", $trigger);
624                  $tp->assign("ed_title", MyEscape(convert_html($ed_title)));                  $tp->assign("ed_title", MyEscape(convert_html($ed_title)));
625                  $tp->assign("ed_lead", MyEscape(convert_html($ed_lead)));                  $tp->assign("ed_lead", MyEscape(convert_html($ed_lead), true));
626                    $tp->assign("ed_lead2", ParseNewline(MyEscape(convert_html($ed_lead), false), false));
627                  $tp->assign("ed_titlepic_pos", $ed_titlepic_pos);                  $tp->assign("ed_titlepic_pos", $ed_titlepic_pos);
628                  $tp->assign("ed_titlepic_url", MyEscape(convert_html($titlepic_url)));                  $tp->assign("ed_titlepic_url", MyEscape(convert_html($titlepic_url)));
629                  $tp->assign("ed_titlepic_url2", MyEscape(convert_html($titlepic_url2)));                  $tp->assign("ed_titlepic_url2", MyEscape(convert_html($titlepic_url2)));
# Line 500  sql($sql); Line 636  sql($sql);
636                  $tp->assign("ed_author_name", MyEscape(convert_html($author_name)));                  $tp->assign("ed_author_name", MyEscape(convert_html($author_name)));
637                  $tp->assign("ed_author_alt", MyEscape(convert_html($ed_author_alt)));                  $tp->assign("ed_author_alt", MyEscape(convert_html($ed_author_alt)));
638                  $tp->assign("ed_author_info", MyEscape(convert_html($ed_author_info)));                  $tp->assign("ed_author_info", MyEscape(convert_html($ed_author_info)));
639                    $tp->assign("ed_author_ime", MyEscape(convert_html($ed_author_ime)));
640                  $tp->assign("ed_author_width", $width2);                  $tp->assign("ed_author_width", $width2);
641                  $tp->assign("ed_author_height", $height2);                  $tp->assign("ed_author_height", $height2);
642                  $tp->assign("ed_more", MyEscape($ed_more));                  $tp->assign("ed_more", MyEscape($ed_more));
643                  $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);                  $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);
644                  $tp->assign("ed_more_title", MyEscape($ed_more_title));                  $tp->assign("ed_more_title", MyEscape($ed_more_title));
645                    $tp->assign("ed_prikazi", $ed_prikazi);
646                    $tp->assign("ed_author_cv", $ed_author_cv);
647                    $tp->assign("ed_exclusive", $ed_exclusive);
648                  $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);
649                  $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false);                  $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false);
650                  $tp->assign("ed_text", $ed_text);                  $tp->assign("ed_text", $ed_text);
# Line 516  sql($sql); Line 656  sql($sql);
656                  $tp->assign("aupicdir", "$aupicdir/");                  $tp->assign("aupicdir", "$aupicdir/");
657                  $tp->assign("vijest", $isVijest ? true : false);                  $tp->assign("vijest", $isVijest ? true : false);
658                  if ($ed_preview) {                  if ($ed_preview) {
                         include_once("author.php");  
659                          $tp->assign("AUTHOR", GetAuthor(MyEscape(convert_html($author_url)),                          $tp->assign("AUTHOR", GetAuthor(MyEscape(convert_html($author_url)),
660                                  MyEscape(convert_html($ed_author_alt)),                                  MyEscape(convert_html($ed_author_alt)),
661                                  MyEscape(convert_html($ed_author_info)),                                  MyEscape(convert_html($ed_author_info)),
662                                  $width2, $height2));                                  $width2, $height2, $ed_author_cv));
663                  }                  }
664                  $tp->assign("med", $isMed ? true : false);                  $tp->assign("med", $isMed ? true : false);
665                  $params = array();                  $params = array();

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.26