/[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.14 by ravilov, Fri Oct 12 09:22:02 2001 UTC revision 1.17 by ravilov, Tue Oct 23 16:13:59 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 ORDER BY title";
96    sql($sql);
97                    $sth = $dbh->prepare($sql);
98                    if (!$sth) error("Cannot prepare query: \"$sql\"");
99                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
100                    while ($row = $sth->fetchrow_array()) {
101                            $txt = $row[1];
102                            if (strlen($txt) > 55) $txt = substr($txt, 0, 55)."...";
103                            array_push($newsi, array("id" => $row[0], "txt" => $txt));
104                    }
105                    $sth->finish();
106                    usort($newsi, "my_cmp");
107                    // -----
108                  $specs = array();                  $specs = array();
109                  $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)";
110  sql($sql);  sql($sql);
# Line 79  sql($sql); Line 114  sql($sql);
114                  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]));
115                  $sth->finish();                  $sth->finish();
116                  usort($specs, "my_cmp");                  usort($specs, "my_cmp");
117                    array_unshift($specs, array("id" => 0, "txt" => "HOME"));
118                  // -----                  // -----
119                  $levels = array();                  $levels = array();
120                  $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 118  sql($sql); Line 154  sql($sql);
154                                  global $ed_title, $ed_lead, $ed_titlepic_alt,                                  global $ed_title, $ed_lead, $ed_titlepic_alt,
155                                          $ed_titlepic_pos, $ed_more, $ed_more_title,                                          $ed_titlepic_pos, $ed_more, $ed_more_title,
156                                          $ed_cat, $ed_author_alt, $ed_author_info,                                          $ed_cat, $ed_author_alt, $ed_author_info,
157                                          $ed_author_ime, $ed_prikazi;                                          $ed_author_ime, $ed_author_cv, $ed_prikazi;
158                                  $ed_title = MyQuote($ed_title);                                  $ed_title = MyQuote($ed_title);
159                                  $ed_lead = MyQuote($ed_lead);                                  $ed_lead = MyQuote($ed_lead);
160                                  $ed_author_nm = urldecode(MyQuote(basename($author_name)));                                  $ed_author_nm = urldecode(MyQuote(basename($author_name)));
# Line 130  sql($sql); Line 166  sql($sql);
166                                  $ed_more = MyQuote($ed_more);                                  $ed_more = MyQuote($ed_more);
167                                  $ed_more_title = MyQuote($ed_more_title);                                  $ed_more_title = MyQuote($ed_more_title);
168                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;
169                                    if (!$ed_author_cv) $ed_author_cv = 0;
170                                  if ($ed_id > 0) {                                  if ($ed_id > 0) {
171                                          $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, 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)";                                          $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, 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)";
172  sql($sql);  sql($sql);
173                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
174                                  } else {                                  } else {
175                                          $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, author_pic, author_alt, author_info, author_name, 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_more, $ed_more_title, ".($isMed?"true":"false").", ".($ed_prikazi?"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, 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_more, $ed_more_title, ".($isMed?"true":"false").", ".($ed_prikazi?"true":"false").", NOW(), NOW())";
176  sql($sql);  sql($sql);
177                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
178                                          $sql = "SELECT currval('news_news_id_seq')::text";                                          $sql = "SELECT currval('news_news_id_seq')::text";
# Line 161  sql($sql); Line 198  sql($sql);
198                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
199                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i},                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i},
200                                                  ${"ed_textpic_exp_".$i};                                                  ${"ed_textpic_exp_".$i};
201                                          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(
202                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i},                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i}, ${"ed_text_".$i},
203                                                  ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i},                                                  ${"textpic_url2_".$i}, ${"textpic_name_".$i}, ${"textpic_full2_".$i},
204                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"textpic_fname_".$i}, ${"ed_textpic_alt_".$i},
205                                                  ${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i},                                                  ${"ed_textpic_pos_".$i}, ${"del_".$i}, ${"ed_text_level_".$i},
206                                                  ${"ed_textpic_exp_".$i});                                                  ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i});
207                                          if ($lev != $last_level) {                                          if ($lev != $last_level) {
208                                                  if ($last_level) {                                                  if ($last_level) {
209                                                          if ($last_level < $lev) array_push($parents, $id);                                                          if ($last_level < $lev) array_push($parents, $id);
# Line 182  sql($sql); Line 219  sql($sql);
219                                          $hl = MyQuote($hl);                                          $hl = MyQuote($hl);
220                                          $orig = basename($orig);                                          $orig = basename($orig);
221                                          $org = MyQuote($orig);                                          $org = MyQuote($orig);
222                                            $forig = basename($forig);
223                                            $forg = MyQuote($forig);
224                                          $alt = MyQuote($alt);                                          $alt = MyQuote($alt);
225                                          if (!$pos) $pos = 0;                                          if (!$pos) $pos = 0;
226                                          if ($id && $id > 0) {                                          if ($id && $id > 0) {
# Line 197  sql($sql); Line 236  sql($sql);
236                                                          }                                                          }
237                                                          $sth->finish();                                                          $sth->finish();
238                                                  }                                                  }
239                                                    if ($del || !$forig) {
240                                                            $sql = "SELECT full_pic FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
241    sql($sql);
242                                                            $sth = $dbh->prepare($sql);
243                                                            if (!$sth) error("Cannot prepare query: \"$sql\"");
244                                                            if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
245                                                            while ($row = $sth->fetchrow_array()) {
246                                                                    list($pic) = $row;
247                                                                    MyDelete($syspicdir."/".$pic);
248                                                            }
249                                                            $sth->finish();
250                                                    }
251                                                  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)";
252                                                          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)";
253  sql($sql);  sql($sql);
254                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
255                                          } else if (!$del) {                                          } else if (!$del) {
256                                                  $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)";
257  sql($sql);  sql($sql);
258                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
259                                                  $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";                                                  $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";
# Line 216  sql($sql); Line 267  sql($sql);
267                                                  $last_id = $id = $row;                                                  $last_id = $id = $row;
268                                          }                                          }
269                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");
270                                            if ($full) MyMove("$syspicdir/$full", "$syspicdir/$forig");
271                                          $i++;                                          $i++;
272                                  }                                  }
273                                  if ($ed_id) {                                  if ($ed_id) {
# Line 223  sql($sql); Line 275  sql($sql);
275  sql($sql);  sql($sql);
276                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
277                                          for ($k = 0; $k < count($specs); $k++) {                                          for ($k = 0; $k < count($specs); $k++) {
278                                                  $var = "ed_spec_".$specs[$k]["id"]; global $$var;                                                  $var = "ed_spec_".$specs[$k]["id"];
279                                                    global $$var;
280                                                  if (!$$var) continue;                                                  if (!$$var) continue;
281                                                  $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"].")";
282  sql($sql);  sql($sql);
283                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
284                                          }                                          }
285                                            $sql = "DELETE FROM related WHERE (news_id = $ed_id)";
286    sql($sql);
287                                            $dbh->dbh_do($sql);
288                                            $x = 1;
289                                            $foo = array();
290                                            while (true) {
291                                                    $var = "ed_related_".$x;
292                                                    $x++;
293                                                    global $$var;
294                                                    if (!isset($$var)) break;
295                                                    if (!$$var) continue;
296                                                    if ($foo[$$var]) continue;
297                                                    $foo[$$var] = true;
298                                                    $sql = "INSERT INTO related (news_id, rel_id) VALUES ($ed_id, ".$$var.")";
299    sql($sql);
300                                                    $dbh->dbh_do($sql);
301                                            }
302                                          $sql = "DELETE FROM cat_news WHERE (news_id = $ed_id)";                                          $sql = "DELETE FROM cat_news WHERE (news_id = $ed_id)";
303  sql($sql);  sql($sql);
304                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
# Line 249  sql($sql); Line 319  sql($sql);
319                                  while (isset(${"ed_textpic_id_".$i})) {                                  while (isset(${"ed_textpic_id_".$i})) {
320                                          $tmp = ${"textpic_url2_".$i};                                          $tmp = ${"textpic_url2_".$i};
321                                          if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);                                          if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
322                                            $tmp = ${"textpic_full2_".$i};
323                                            if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
324                                          $i++;                                          $i++;
325                                  }                                  }
326                          }                          }
# Line 291  sql($sql); Line 363  sql($sql);
363                                  $u = ${"textpic_url2_".$n};                                  $u = ${"textpic_url2_".$n};
364                                  if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);                                  if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);
365                                  unset(${"clear_".$n}, ${"clr_".$n});                                  unset(${"clear_".$n}, ${"clr_".$n});
366                            } else if (ereg("^ed_textpic_full_([1-9][0-9]*)$", $key, $regs)) {
367                                    move_uploaded_file($tname, $syspicdir."/".$nm.$ext);
368                                    $n = $regs[1];
369                                    ${"textpic_full_".$n} = $nm.$ext;
370                                    ${"textpic_fname_".$n} = $name;
371                                    $u = ${"textpic_full2_".$n};
372                                    if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u2);
373                                    unset(${"fclear_".$n}, ${"fclr_".$n});
374                          } else {                          } else {
375                                  // [?!?]                                  // ?!?
376                          }                          }
377                  }                  }
378                  // -----                  // -----
379                  $tp = new Smarty();                  $tp = new Smarty();
380                  $tp->assign("levels", $levels);                  $tp->assign("levels", $levels);
381                    $tp->assign("autori", $autori);
382                    $tp->assign("newsi", $newsi);
383                  // -----                  // -----
384                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,
385                          $ed_titlepic_alt, $ed_cat, $ed_more,                          $ed_titlepic_alt, $ed_cat, $ed_more,
# Line 318  sql($sql); Line 400  sql($sql);
400                  $ed_warning = 0;                  $ed_warning = 0;
401                  $nspecs = array();                  $nspecs = array();
402                  $ncats = array();                  $ncats = array();
403                    $related = array();
404                  // Transfer data                  // Transfer data
405                  if ($ed_edit || $ed_preview || $add || $delete || $clear) {                  if ($ed_edit || $ed_preview || $add || $delete || $clear) {
406                          for ($i = 0; $i < count($specs); $i++) {                          for ($i = 0; $i < count($specs); $i++) {
407                                  $var = "ed_spec_".$specs[$i]["id"];                                  $var = "ed_spec_".$specs[$i]["id"];
408                                  global $$var;                                  global $$var;
409                                  $nspecs[$specs[$i]["id"]] = $$var ? true : false;                                  $foo = isset($$var) ? $$var : ($spec && $spec == $specs[$i]["id"]);
410                                    $nspecs[$specs[$i]["id"]] = $foo ? true : false;
411                          }                          }
412                          for ($i = 0; $i < count($categories); $i++) {                          for ($i = 0; $i < count($categories); $i++) {
413                                  $var = "ed_cat_".$categories[$i]["id"];                                  $var = "ed_cat_".$categories[$i]["id"];
# Line 331  sql($sql); Line 415  sql($sql);
415                                  $ncats[$categories[$i]["id"]] = $$var ? true : false;                                  $ncats[$categories[$i]["id"]] = $$var ? true : false;
416                          }                          }
417                          global $ed_title, $ed_lead, $ed_titlepic_pos,                          global $ed_title, $ed_lead, $ed_titlepic_pos,
418                                  $ed_titlepic_alt, $ed_cat, $ed_more,                                  $ed_titlepic_alt, $ed_cat, $ed_more, $ed_more_title,
419                                  $ed_more_title, $ed_author_url,                                  $ed_author_url, $ed_author_alt, $ed_author_info,
420                                  $ed_author_alt, $ed_author_info,                                  $ed_author_ime, $ed_author_cv, $ed_prikazi;
                                 $ed_author_ime, $ed_prikazi;  
421                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";
422                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;
423                          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 344  sql($sql); Line 427  sql($sql);
427                          global $ed_title_force;                          global $ed_title_force;
428                          if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;                          if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2;
429                          $i = 1;                          $i = 1;
430                            while (true) {
431                                    $var = "ed_related_".$i;
432                                    global $$var;
433                                    if (!isset($$var)) break;
434                                    array_push($related, $$var);
435                                    $i++;
436                            }
437                            $i = 1;
438                          while (isset(${"ed_text_id_".$i})) {                          while (isset(${"ed_text_id_".$i})) {
439                                  $id = ${"ed_text_id_".$i};                                  $id = ${"ed_text_id_".$i};
440                                  global ${"ed_text_".$i}, ${"ed_text_title_".$i},                                  global ${"ed_text_".$i}, ${"ed_text_title_".$i},
# Line 353  sql($sql); Line 444  sql($sql);
444                                  $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?                                  $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ?
445                                          ${"textpic_url_".$i} : "";                                          ${"textpic_url_".$i} : "";
446                                  if (!$pic_url) $pic_url = ${"textpic_url2_".$i};                                  if (!$pic_url) $pic_url = ${"textpic_url2_".$i};
447                                    $full_url = ($HTTP_POST_FILES["ed_textpic_full_".$i]["name"]) ?
448                                            ${"textpic_full_".$i} : "";
449                                    if (!$full_url) $full_url = ${"textpic_full2_".$i};
450                                  $tmp = "";                                  $tmp = "";
451                                  for ($j = 0; $j < count($art["text"]); $j++)                                  for ($j = 0; $j < count($art["text"]); $j++)
452                                          if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"];                                          if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"];
453                                  if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp;                                  if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp;
454                                    $tmp = "";
455                                    for ($j = 0; $j < count($art["text"]); $j++)
456                                            if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["full"];
457                                    if (!$full_url && $tmp && !(${"fclear_".$i} || ${"fclr_".$i})) $full_url = $tmp;
458                                  $level = ${"ed_text_level_".$i};                                  $level = ${"ed_text_level_".$i};
459                                  list($w, $h) = PicSize($pic_url);                                  list($w, $h) = PicSize($pic_url);
460                                    list($w2, $h2) = PicSize($full_url);
461                                  array_push($ed_pgfs, array($id,                                  array_push($ed_pgfs, array($id,
462                                          ${"ed_text_".$i}, ${"ed_text_title_".$i},                                          ${"ed_text_".$i}, ${"ed_text_title_".$i},
463                                          $level, $pic_url, ${"textpic_name_".$i},                                          $level, $pic_url, ${"textpic_name_".$i},
464                                            $full_url, ${"textpic_fname_".$i},
465                                          ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                          ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
466                                          $w, $h, ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i}, false));                                          $w, $h, $w2, $h2, ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i}, false));
467                                  $i++;                                  $i++;
468                          }                          }
469                  } else {                  } else {
# Line 382  sql($sql); Line 482  sql($sql);
482                                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
483                                  while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;                                  while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;
484                                  $sth->finish();                                  $sth->finish();
485                          } else $art["show"] = true;                                  $sql = "SELECT rel_id FROM related WHERE (news_id = $ed_id)";
486    sql($sql);
487                                    $sth = $dbh->prepare($sql);
488                                    if (!$sth) error("Cannot prepare query: \"$sql\"");
489                                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
490                                    while ($row = $sth->fetchrow_array()) {
491                                            list($id) = $row;
492                                            array_push($related, $id);
493                                    }
494                                    $sth->finish();
495                            } else {
496                                    $art["show"] = true;
497                                    for ($j = 0; $j < count($specs); $j++)
498                                            $nspecs[$specs[$j]["id"]] = ($specs[$j]["id"] == $spec) ? true : false;
499                            }
500                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,
501                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,
502                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,
503                                  $author_url, $author_url2, $author_name,                                  $author_url, $author_url2, $author_name,
504                                  $ed_author_alt, $ed_author_info, $width2, $height2,                                  $ed_author_alt, $ed_author_info, $width2, $height2,
505                                  $ed_author_ime, $ed_prikazi) = array($art["title"], $art["lead"],                                  $ed_author_ime, $ed_author_cv, $ed_prikazi) = array($art["title"],
506                                  $art["pic_pos"], $art["pic_url"], $art["pic_url"],                                  $art["lead"], $art["pic_pos"], $art["pic_url"], $art["pic_url"],
507                                  urldecode($art["pic_url"]), $art["pic_alt"], $art["category"],                                  urldecode($art["pic_url"]), $art["pic_alt"], $art["category"],
508                                  $art["more"], $art["more_title"], $art["pic_w"], $art["pic_h"],                                  $art["more"], $art["more_title"], $art["pic_w"], $art["pic_h"],
509                                  $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),                                  $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),
510                                  $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"],                                  $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"],
511                                  $art["au_name"], $art["show"]);                                  $art["au_name"], $art["au_cv"], $art["show"]);
512                          if ($art["text"]) reset($art["text"]);                          if ($art["text"]) reset($art["text"]);
513                          while ($art["text"] && list($id, $val) = each($art["text"])) {                          while ($art["text"] && list($id, $val) = each($art["text"])) {
514                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],
515                                          $val["level"], urldecode($val["pic"]),                                          $val["level"], urldecode($val["pic"]),
516                                          urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"],                                          urldecode($val["pic"]), urldecode($val["full"]), urldecode($val["full"]),
517                                          $val["h"], $val["hl"], $val["exp"], false));                                          $val["alt"], $val["pos"], $val["w"], $val["h"], $val["fw"], $val["fh"],
518                                            $val["hl"], $val["exp"], false));
519                          }                          }
520                          $ed_id = $art["id"];                          $ed_id = $art["id"];
521                          if (!$ed_id) $ed_id = -1;                          if (!$ed_id) $ed_id = -1;
522                  }                  }
523                    for ($i = count($related); $i < 10; $i++) array_push($related, 0);
524                    $tp->assign("related", $related);
525                  $ncats[$ed_cat] = true;                  $ncats[$ed_cat] = true;
526                  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"]];
527                  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 417  sql($sql); Line 534  sql($sql);
534                  if ($add) {                  if ($add) {
535                          global $add_num;                          global $add_num;
536                          for ($i = 0; $i < intval($add_num); $i++)                          for ($i = 0; $i < intval($add_num); $i++)
537                                  array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", 0, 0, 0, "", "", true));                                  array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", "", 0, 0, 0, 0, 0, "", "", true));
538                  }                  }
539                  $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;
540                  $ed_text = array();                  $ed_text = array();
# Line 425  sql($sql); Line 542  sql($sql);
542                  $ed_warnings = ($ed_warning ? true : false);                  $ed_warnings = ($ed_warning ? true : false);
543                  $i = 1;                  $i = 1;
544                  while (list($key, $val) = each($ed_pgfs)) {                  while (list($key, $val) = each($ed_pgfs)) {
545                          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;
546                          $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);                          $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false);
547                          array_push($ed_records, array("val" => $del, "id" => $id));                          array_push($ed_records, array("val" => $del, "id" => $id));
548                          if ($del) { $i++; continue; }                          if ($del) { $i++; continue; }
549                          $picurl = ${"textpic_url_".$id};                          $picurl = ${"textpic_url_".$id};
550                          if (!$picurl) $picurl = $pic;                          if (!$picurl) $picurl = $pic;
551                            $fullurl = ${"textpic_full_".$id};
552                            if (!$fullurl) $fullurl = $fpic;
553                          $class = "";                          $class = "";
554                          reset($levels);                          reset($levels);
555                          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 440  sql($sql); Line 559  sql($sql);
559                                  $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";                                  $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = "";
560                          }                          }
561                          if (!$name) $name = $picurl;                          if (!$name) $name = $picurl;
562                          $txt = MyEscape(convert_html($txt), false);                          if ((${"fclear_".$i} || ${"fclr_".$i}) && $ed_preview && (${"textpic_full_".$i} != ${"textpic_full2_".$i})) {
563                          $txt2 = ParseNewline($txt, true);                                  $tmp = ${"textpic_full2_".$i};
564                          $txt3 = str_replace("&", "&amp;", MyEscape(convert_html($txt), true));                                  if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp);
565                          $txt3 = str_replace("\"", "&quot;", $txt3);                                  $fullurl = ${"textpic_full_".$i} = ${"textpic_full2_".$i} = $fname = "";
566                          $txt3 = str_replace("<", "&lt;", $txt3);                          }
567                          $txt3 = str_replace(">", "&gt;", $txt3);                          if (!$fname) $fname = $fullurl;
568                          $hl = MyEscape(convert_html($hl), false);                          // ----
569                          $hl2 = ParseNewline($hl, true);                          $txt3 = MyEscape(convert_html($txt), true);
570                          if ($hl2) $hl2 = GetHighlight($hl2);                          $txt = str_replace("&", "&amp;", MyEscape(convert_html($txt), false));
571                          $hl3 = str_replace("&", "&amp;", MyEscape(convert_html($hl), true));                          $txt2 = $ed_preview ? ParseNewline($txt, true) : $txt3;
572                          $hl3 = str_replace("\"", "&quot;", $hl3);                          // ----
573                          $hl3 = str_replace("<", "&lt;", $hl3);                          $hl3 = MyEscape(convert_html($hl), true);
574                          $hl3 = str_replace(">", "&gt;", $hl3);                          $hl = str_replace("&", "&amp;", MyEscape(convert_html($hl), false));
575                            $hl2 = $ed_preview ? ParseNewline($hl, true) : $hl3;
576                            if ($hl) $hl = GetHighlight($hl);
577                            // ----
578                          global ${"ed_text_force_".$i};                          global ${"ed_text_force_".$i};
579                          $force = ${"ed_text_force_".$i};                          $force = ${"ed_text_force_".$i};
580                          $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);                          $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false);
# Line 475  sql($sql); Line 597  sql($sql);
597                                  "class" => MyEscape(convert_html($class)),                                  "class" => MyEscape(convert_html($class)),
598                                  "url" => MyEscape(convert_html($picurl)),                                  "url" => MyEscape(convert_html($picurl)),
599                                  "name" => MyEscape(convert_html($name)),                                  "name" => MyEscape(convert_html($name)),
600                                    "full" => MyEscape(convert_html($fullurl)),
601                                    "fname" => MyEscape(convert_html($fname)),
602                                  "alt" => MyEscape(convert_html($alt)),                                  "alt" => MyEscape(convert_html($alt)),
603                                  "w" => $w,                                  "w" => $w,
604                                  "h" => $h,                                  "h" => $h,
605                                    "fw" => $fw,
606                                    "fh" => $fh,
607                                  "pos" => $pos,                                  "pos" => $pos,
608                                  "exp" => MyEscape(convert_html($exp)),                                  "exp" => MyEscape(convert_html($exp)),
609                                  "warning" => $warning,                                  "warning" => $warning,
610                                  "clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false                                  "clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false,
611                                    "fclr" => (${"fclear_".$i} || ${"fclr_".$i} || !$fullurl) ? true : false
612                          ));                          ));
613                          $i++;                          $i++;
614                  }                  }
# Line 512  sql($sql); Line 639  sql($sql);
639                  $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);                  $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);
640                  $tp->assign("ed_more_title", MyEscape($ed_more_title));                  $tp->assign("ed_more_title", MyEscape($ed_more_title));
641                  $tp->assign("ed_prikazi", $ed_prikazi);                  $tp->assign("ed_prikazi", $ed_prikazi);
642                    $tp->assign("ed_author_cv", $ed_author_cv);
643                  $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);
644                  $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);
645                  $tp->assign("ed_text", $ed_text);                  $tp->assign("ed_text", $ed_text);
# Line 526  sql($sql); Line 654  sql($sql);
654                          $tp->assign("AUTHOR", GetAuthor(MyEscape(convert_html($author_url)),                          $tp->assign("AUTHOR", GetAuthor(MyEscape(convert_html($author_url)),
655                                  MyEscape(convert_html($ed_author_alt)),                                  MyEscape(convert_html($ed_author_alt)),
656                                  MyEscape(convert_html($ed_author_info)),                                  MyEscape(convert_html($ed_author_info)),
657                                  $width2, $height2));                                  $width2, $height2, $ed_author_cv));
658                  }                  }
659                  $tp->assign("med", $isMed ? true : false);                  $tp->assign("med", $isMed ? true : false);
660                  $params = array();                  $params = array();

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.26