/[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.16 by ravilov, Tue Oct 16 13:07:03 2001 UTC revision 1.18 by ravilov, Sat Oct 27 16:54:50 2001 UTC
# Line 90  sql($sql); Line 90  sql($sql);
90                  $sth->finish();                  $sth->finish();
91                  usort($autori, "my_cmp_2");                  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 139  sql($sql); Line 156  sql($sql);
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_prikazi;                                          $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)));
# Line 152  sql($sql); Line 170  sql($sql);
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;                                  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, 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)";                                          $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, 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())";                                          $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 currval('news_news_id_seq')::text";                                          $sql = "SELECT currval('news_news_id_seq')::text";
# Line 216  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();                                                          $sth->finish();
242                                                  }                                                  }
# Line 228  sql($sql); Line 247  sql($sql);
247                                                          if (!$sth) error("Cannot prepare query: \"$sql\"");                                                          if (!$sth) error("Cannot prepare query: \"$sql\"");
248                                                          if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                                                          if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
249                                                          while ($row = $sth->fetchrow_array()) {                                                          while ($row = $sth->fetchrow_array()) {
250                                                                  list($pic) = $row;                                                                  list($pic2) = $row;
251                                                                  MyDelete($syspicdir."/".$pic);                                                                  MyDelete($syspicdir."/".$pic2);
252                                                          }                                                          }
253                                                          $sth->finish();                                                          $sth->finish();
254                                                  }                                                  }
# Line 267  sql($sql); Line 286  sql($sql);
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 347  sql($sql); Line 383  sql($sql);
383                  $tp = new Smarty();                  $tp = new Smarty();
384                  $tp->assign("levels", $levels);                  $tp->assign("levels", $levels);
385                  $tp->assign("autori", $autori);                  $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,
# Line 367  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++) {
# Line 381  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;
                                 $ed_author_ime, $ed_author_cv,  
                                 $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 395  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 442  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 {                          } else {
500                                  $art["show"] = true;                                  $art["show"] = false;
501                                  for ($j = 0; $j < count($specs); $j++)                                  for ($j = 0; $j < count($specs); $j++)
502                                          $nspecs[$specs[$j]["id"]] = ($specs[$j]["id"] == $spec) ? true : false;                                          $nspecs[$specs[$j]["id"]] = ($specs[$j]["id"] == $spec) ? true : false;
503                          }                          }
# Line 452  sql($sql); Line 506  sql($sql);
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                                  $ed_author_ime, $ed_author_cv, $ed_prikazi) = array($art["title"],                                  $ed_author_ime, $ed_author_cv, $ed_exclusive, $ed_prikazi) =
510                                  $art["lead"], $art["pic_pos"], $art["pic_url"], $art["pic_url"],                                  array($art["title"], $art["lead"], $art["pic_pos"], $art["pic_url"],
511                                  urldecode($art["pic_url"]), $art["pic_alt"], $art["category"],                                  $art["pic_url"], urldecode($art["pic_url"]), $art["pic_alt"],
512                                  $art["more"], $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["show"]);                                  $art["au_name"], $art["au_cv"], $art["ex"], $art["show"]);
516                          if ($art["text"]) reset($art["text"]);                          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"],
# Line 470  sql($sql); Line 524  sql($sql);
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 513  sql($sql); Line 569  sql($sql);
569                                  $fullurl = ${"textpic_full_".$i} = ${"textpic_full2_".$i} = $fname = "";                                  $fullurl = ${"textpic_full_".$i} = ${"textpic_full2_".$i} = $fname = "";
570                          }                          }
571                          if (!$fname) $fname = $fullurl;                          if (!$fname) $fname = $fullurl;
572                          $txt = MyEscape(convert_html($txt), false);                          // ----
573                          $txt2 = ParseNewline($txt, true);                          $txt3 = MyEscape(convert_html($txt), true);
574                          $txt3 = str_replace("&", "&amp;", MyEscape(convert_html($txt), true));                          $txt = str_replace("&", "&amp;", MyEscape(convert_html($txt), false));
575                          $txt3 = str_replace("\"", "&quot;", $txt3);                          $txt2 = $ed_preview ? ParseNewline($txt, true) : $txt3;
576                          $txt3 = str_replace("<", "&lt;", $txt3);                          // ----
577                          $txt3 = str_replace(">", "&gt;", $txt3);                          $hl3 = MyEscape(convert_html($hl), true);
578                          $hl = MyEscape(convert_html($hl), false);                          $hl = str_replace("&", "&amp;", MyEscape(convert_html($hl), false));
579                          $hl2 = ParseNewline($hl, true);                          $hl2 = $ed_preview ? ParseNewline($hl, true) : $hl3;
580                          if ($hl2) $hl2 = GetHighlight($hl2);                          if ($hl) $hl = GetHighlight($hl);
581                          $hl3 = str_replace("&", "&amp;", MyEscape(convert_html($hl), true));                          // ----
                         $hl3 = str_replace("\"", "&quot;", $hl3);  
                         $hl3 = str_replace("<", "&lt;", $hl3);  
                         $hl3 = str_replace(">", "&gt;", $hl3);  
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 591  sql($sql); Line 644  sql($sql);
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);                  $tp->assign("ed_prikazi", $ed_prikazi);
646                  $tp->assign("ed_author_cv", $ed_author_cv);                  $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 605  sql($sql); Line 659  sql($sql);
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.16  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.26