--- index.php 2000/12/07 17:01:39 1.1.1.1 +++ index.php 2001/02/12 07:13:26 1.8 @@ -1,5 +1,7 @@ "startnew.html", ttable => "topics-table.html", theader => "topics-header.html", + tlheader => "topics-list-header.html", trow => "topics-row.html", + tlrow => "topics-list-row.html", reply => "reply.html", checkboxes => "checkboxes.html" ) @@ -27,7 +31,7 @@ if ($row=$sth->fetchrow_hash()) { if ($row && $row[passwd] == $PHP_AUTH_PW) { $md5user=md5($PHP_AUTH_USER.$PHP_AUTH_PW); - $osoba_id=$row[id]; + $osoba_id=$row[id]; if ($row[analitical] == "t") { $analitical_room=1; $tpl->assign(array( ROOM => "You are member of analitical room" )); @@ -37,6 +41,7 @@ if ($row[solution] == "t") { $solution_room=1; $sql_poruke_where.="and poruke.solution is true"; + $tpl->assign(array( ROOM => "You are in solution room" )); } $tpl->assign(array( FULL_NAME => $row[full_name], @@ -44,12 +49,11 @@ )); } } else { // try to verify user via pop3 - include("class.POP3.php3"); + include("auth_pop3.php"); $pop3 = new POP3(); if($pop3->connect("intranet.pliva.hr")) { - $Count = $pop3->login($PHP_AUTH_USER,$PHP_AUTH_PW); - if ( $Count != -1 ) { + if ($pop3->checklogin($PHP_AUTH_USER,$PHP_AUTH_PW)) { $pop3->quit(); // o.k., user exists now insert it in db! include("finger.inc"); @@ -61,7 +65,7 @@ $md5user=md5($PHP_AUTH_USER.$PHP_AUTH_PW); $osoba_id=$row[id]; $tpl->assign(array( - FULL_NAME => $row[full_name], + FULL_NAME => $full_name, RELOGIN => "$PHP_SELF?relogin=$md5user" )); } @@ -75,6 +79,8 @@ $tpl->parse(MAIN, "main"); $tpl->FastPrint(); exit ; +} else { + $dbh->dbh_do("update osobe set last_login=now() where login='$PHP_AUTH_USER'"); } //---- insert reply into database @@ -110,14 +116,15 @@ if (isset($GLOBALS[$what])) { $GLOBALS[$what]="true"; } else { - $GLOBALS[$what]="flase"; + $GLOBALS[$what]="false"; } } fix_checkbox("analitical"); fix_checkbox("solution"); - $dbh->dbh_do(fixsql("insert into poruke (thread_id,reply_id,osoba_id,sadrzaj,level,pos,analitical,solution) values ($thread_id,$reply_id,$osoba_id,'$sadrzaj',$level,'$pos',$analitical,$solution)")); + $sadrzaj=trim($sadrzaj); + $dbh->dbh_do(fixsql("insert into poruke (thread_id,reply_id,osoba_id,sadrzaj,level,pos,analitical,solution) values ($thread_id,$p,$osoba_id,'$sadrzaj',$level,'$pos',$analitical,$solution)")); $sth=$dbh->prepare("select currval('poruke_id_seq') as id"); $sth->execute(); @@ -125,6 +132,7 @@ if ($row=$sth->fetchrow_hash()) { $p=$row[id]; // poruka_id for later } + $what="show"; } elseif (isset($insert_newtopic)) { @@ -136,6 +144,7 @@ $sth->execute(); if ($row=$sth->fetchrow_hash()) { $t=$row[id]; // topic for later + $title=trim($title); $dbh->dbh_do(fixsql("insert into topics (id,title) values ($t,'$title')")); } } @@ -143,15 +152,24 @@ //----- end of inserts/updates... -if ($what=="reply" && isset($t)) { +if (($what=="reply" || $what=="show") && isset($t)) { $sql_where=" and topics.id=$t"; } +if ($solution_room == 1) { + // don't limit just to topics starts + $sql_where.=" and poruke.thread_id=topics.id and poruke.thread_id!=0"; +} else { + // limit just to topics start + $sql_where.=" and poruke.id=topics.id and poruke.thread_id=0"; +} + $sth = $dbh->prepare("select topics.id as topic_id,title,sadrzaj,full_name,poruke.datum as datum from topics,poruke,osobe - where poruke.thread_id=0 and poruke.id=topics.id and poruke.osoba_id=osobe.id $sql_where $sql_poruke_where + where poruke.osoba_id=osobe.id $sql_where $sql_poruke_where order by datum asc "); + $sth->execute(); $topics=""; while ($row=$sth->fetchrow_hash()) { @@ -160,12 +178,12 @@ AUTHOR => $row[full_name], DATE => $row[datum], SADRZAJ => $row[sadrzaj], - COMMENTS => "comments>>", + COMMENTS => "comments>>", PHP_SELF => $PHP_SELF )); - $tpl->parse(ROWS,".theader"); if (isset($t) && $t==$row[topic_id]) { + $tpl->parse(ROWS,".theader"); $sth2 = $dbh->prepare(" select poruke.id as id,sadrzaj as topic,level,thread_id,reply_id,full_name,poruke.datum as datum,poruke.analitical as poruka_analitical from poruke,osobe @@ -180,16 +198,23 @@ $l_ul.=""; } + // don't indent in solution room + if ($solution_room == 1) { $l_ul=$r_ul=""; } $tpl->assign( array( L_INDENT => $l_ul, R_INDENT => $r_ul )); $topic=trim(strip_tags($row2[topic])); - if (isset($p) && $p == $row2[id]) { + if (isset($p) && $p == $row2[id] && $what=="reply") { $topic="$topic..."; - $tpl->assign( array( P => $p )); - $tpl->parse(CHECKBOXES, ".checkboxes"); + $tpl->assign( array( P => $p, T => $t )); + if ($analitical_room == 1) { + $tpl->parse(CHECKBOXES, ".checkboxes"); + } $tpl->parse(REPLY, ".reply"); + } elseif (isset($p) && $p == $row2[id]) { + $topic="$topic..."; + $tpl->assign( array( P => $p, T => $t )); } else { if (!isset($p)) { $p=$t; } $tmp_t=$row2[thread_id]; @@ -209,17 +234,16 @@ DATE => $row2[datum], SADRZAJ => $topic )); -# $tpl->parse(ROWS,".theader"); $tpl->parse(ROWS,".trow"); } } else { - // non-unroll topics + // non-unroll topics (list) $tpl->assign( array( SADRZAJ => $row[sadrzaj], - COMMENTS => "comments>>" + COMMENTS => "comments>>" )); -# $tpl->parse(ROWS,".theader"); - $tpl->parse(ROWS,".trow"); + $tpl->parse(ROWS,".tlheader"); + $tpl->parse(ROWS,".tlrow"); } } @@ -237,12 +261,16 @@ if ($what == "new") { $tpl->parse(MAIN, ".newtopic"); $tpl->assign(array( TITLE => "Start of new topic" )); +} elseif ($what == "show") { + $tpl->assign(array( + TITLE => "Select article for reply", + P => $p + )); } elseif ($what == "reply") { $tpl->assign(array( TITLE => "Reply to selected article", P => $p )); -# $tpl->parse(MAIN, ".reply"); } $tpl->parse(MAIN, "main");