/[inncomm]/index.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

Contents of /index.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Dec 8 08:27:32 2000 UTC (23 years, 3 months ago) by dpavlin
Branch: MAIN
Changes since 1.1: +33 -10 lines
radi solution room
reply povratak na korektno mjesto

1 <?
2
3 include("inc/class.FastTemplate.pinc");
4 include("inc/conn.inc");
5 include("inc/fixsql.inc");
6
7 $tpl = new FastTemplate("./html");
8
9 $tpl->define(
10 array(
11 main => "main.html",
12 nologin => "nologin.html",
13 listall => "list.html",
14 newtopic => "new.html",
15 startnew => "startnew.html",
16 ttable => "topics-table.html",
17 theader => "topics-header.html",
18 trow => "topics-row.html",
19 reply => "reply.html",
20 checkboxes => "checkboxes.html"
21 )
22 );
23
24 if (isset($PHP_AUTH_USER)) {
25 $sth = $dbh->prepare("select id,login,passwd,full_name,analitical,solution from osobe where login like '$PHP_AUTH_USER'");
26 $sth->execute();
27 if ($row=$sth->fetchrow_hash()) {
28 if ($row && $row[passwd] == $PHP_AUTH_PW) {
29 $md5user=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
30 $osoba_id=$row[id];
31 if ($row[analitical] == "t") {
32 $analitical_room=1;
33 $tpl->assign(array( ROOM => "You are member of analitical room" ));
34 } else {
35 $sql_poruke_where.="and poruke.analitical is false";
36 }
37 if ($row[solution] == "t") {
38 $solution_room=1;
39 $sql_poruke_where.="and poruke.solution is true";
40 }
41 $tpl->assign(array(
42 FULL_NAME => $row[full_name],
43 RELOGIN => "$PHP_SELF?relogin=$md5user"
44 ));
45 }
46 } else { // try to verify user via pop3
47 include("class.POP3.php3");
48 $pop3 = new POP3();
49
50 if($pop3->connect("intranet.pliva.hr")) {
51 $Count = $pop3->login($PHP_AUTH_USER,$PHP_AUTH_PW);
52 if ( $Count != -1 ) {
53 $pop3->quit();
54 // o.k., user exists now insert it in db!
55 include("finger.inc");
56 $full_name=finger($PHP_AUTH_USER);
57 $dbh->dbh_do("insert into osobe (login,full_name,email,passwd) values ('$PHP_AUTH_USER','$full_name','$PHP_AUTH_USER@pliva.hr','$PHP_AUTH_PW')");
58 $sth = $dbh->prepare("select last_value as id from osobe_id_seq");
59 $sth->execute();
60 $row=$sth->fetchrow_hash();
61 $md5user=md5($PHP_AUTH_USER.$PHP_AUTH_PW);
62 $osoba_id=$row[id];
63 $tpl->assign(array(
64 FULL_NAME => $row[full_name],
65 RELOGIN => "$PHP_SELF?relogin=$md5user"
66 ));
67 }
68 }
69 }
70 }
71 if (md5($PHP_AUTH_USER.$PHP_AUTH_PW) != $md5user || isset($relogin) && $md5user == $relogin ) {
72 header("WWW-authenticate: basic realm=\"Innovation Commitie\"") ;
73 header("HTTP/1.0 401 Unauthorized") ;
74 $tpl->parse(MAIN, "nologin");
75 $tpl->parse(MAIN, "main");
76 $tpl->FastPrint();
77 exit ;
78 }
79
80 //---- insert reply into database
81
82 if (isset($insert_reply) && isset($p)) {
83 $sth=$dbh->prepare("select sadrzaj,level,thread_id,pos from poruke where id=$p");
84 $sth->execute();
85 $row=$sth->fetchrow_hash();
86
87 $thread_id=$row[thread_id];
88 if ($thread_id == 0) $thread_id=$p; // reply to top level topic
89
90 $level=$row[level] + 1;
91 $pos=$row[pos];
92
93 while(strlen($pos) < $level) $pos.="a";
94 $sth=$dbh->prepare("select pos from poruke where pos like '$pos'");
95 $sth->execute();
96 if ($row=$sth->fetchrow_hash()) {
97 for($i=0; $i<$level; $i++) $mask.="_";
98 $sth=$dbh->prepare("select pos from poruke where thread_id=$thread_id and pos like '$mask' order by pos desc limit 1");
99 $sth->execute();
100 if ($row=$sth->fetchrow_hash()) {
101 $pos=$row[pos];
102 $pos_l=substr($pos,0,strlen($pos)-1);
103 $pos_r=substr($pos,strlen($pos)-1,1);
104 $pos_r++;
105 $pos=$pos_l.$pos_r;
106 }
107 }
108
109 function fix_checkbox($what) {
110 if (isset($GLOBALS[$what])) {
111 $GLOBALS[$what]="true";
112 } else {
113 $GLOBALS[$what]="false";
114 }
115 }
116
117 fix_checkbox("analitical");
118 fix_checkbox("solution");
119
120 $sadrzaj=trim($sadrzaj);
121 $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)"));
122
123 $sth=$dbh->prepare("select currval('poruke_id_seq') as id");
124 $sth->execute();
125
126 if ($row=$sth->fetchrow_hash()) {
127 $p=$row[id]; // poruka_id for later
128 }
129 $what="show";
130
131 } elseif (isset($insert_newtopic)) {
132
133 //---- insert new topic into database
134
135 if (isset($osoba_id)) {
136 $dbh->dbh_do(fixsql("insert into poruke (thread_id,osoba_id,sadrzaj) values (0,$osoba_id,'$sadrzaj')"));
137 $sth=$dbh->prepare("select currval('poruke_id_seq') as id");
138 $sth->execute();
139 if ($row=$sth->fetchrow_hash()) {
140 $t=$row[id]; // topic for later
141 $title=trim($title);
142 $dbh->dbh_do(fixsql("insert into topics (id,title) values ($t,'$title')"));
143 }
144 }
145 }
146
147 //----- end of inserts/updates...
148
149 if (($what=="reply" || $what="show") && isset($t)) {
150 $sql_where=" and topics.id=$t";
151 }
152
153 if ($solution_room == 1) {
154 // don't limit just to topics starts
155 $sql_where.=" and poruke.thread_id=topics.id and poruke.thread_id!=0";
156 } else {
157 // limit just to topics start
158 $sql_where.=" and poruke.id=topics.id and poruke.thread_id=0";
159 }
160
161 $sth = $dbh->prepare("select topics.id as topic_id,title,sadrzaj,full_name,poruke.datum as datum
162 from topics,poruke,osobe
163 where poruke.osoba_id=osobe.id $sql_where $sql_poruke_where
164 order by datum asc
165 ");
166
167 $sth->execute();
168 $topics="";
169 while ($row=$sth->fetchrow_hash()) {
170 $tpl->assign( array(
171 TITLE => $row[title],
172 AUTHOR => $row[full_name],
173 DATE => $row[datum],
174 SADRZAJ => $row[sadrzaj],
175 COMMENTS => "<a href=\"$PHP_SELF?what=show&t=$row[topic_id]\">comments&gt;&gt;</a>",
176 PHP_SELF => $PHP_SELF
177 ));
178 $tpl->parse(ROWS,".theader");
179
180 if (isset($t) && $t==$row[topic_id]) {
181 $sth2 = $dbh->prepare("
182 select poruke.id as id,sadrzaj as topic,level,thread_id,reply_id,full_name,poruke.datum as datum,poruke.analitical as poruka_analitical
183 from poruke,osobe
184 where (thread_id=$t or poruke.id=$t) and poruke.osoba_id=osobe.id $sql_poruke_where
185 order by pos
186 ");
187 $sth2->execute();
188
189 while ($row2=$sth2->fetchrow_hash()) {
190 $l_ul=$r_ul="";
191 for ($i=0; $i<$row2[level]; $i++) {
192 $l_ul.="<ul>";
193 $r_ul.="</ul>";
194 }
195 // don't indent in solution room
196 if ($solution_room == 1) { $l_ul=$r_ul=""; }
197 $tpl->assign( array(
198 L_INDENT => $l_ul,
199 R_INDENT => $r_ul
200 ));
201 $topic=trim(strip_tags($row2[topic]));
202 if (isset($p) && $p == $row2[id] && $what=="reply") {
203 $topic="<font color=red>$topic...</font>";
204 $tpl->assign( array( P => $p, T => $t ));
205 if ($analitical_room == 1) {
206 $tpl->parse(CHECKBOXES, ".checkboxes");
207 }
208 $tpl->parse(REPLY, ".reply");
209 } elseif (isset($p) && $p == $row2[id]) {
210 $topic="<font color=red>$topic...</font>";
211 $tpl->assign( array( P => $p, T => $t ));
212 } else {
213 if (!isset($p)) { $p=$t; }
214 $tmp_t=$row2[thread_id];
215 if ($tmp_t == 0) { $tmp_t=$row2[id]; }
216 $tpl->assign( array(
217 REPLY => "<a href=\"$PHP_SELF?what=reply&p=$row2[id]&t=$tmp_t\">reply</a>"
218 ));
219 }
220 $this.="<br>";
221
222 if ($row2[poruka_analitical] == "t") {
223 $topic="<i>$topic</i>";
224 }
225
226 $tpl->assign( array(
227 AUTHOR => $row2[full_name],
228 DATE => $row2[datum],
229 SADRZAJ => $topic
230 ));
231 # $tpl->parse(ROWS,".theader");
232 $tpl->parse(ROWS,".trow");
233 }
234 } else {
235 // non-unroll topics
236 $tpl->assign( array(
237 SADRZAJ => $row[sadrzaj],
238 COMMENTS => "<a href=\"$PHP_SELF?what=show&t=$row[topic_id]\">comments&gt;&gt;</a>"
239 ));
240 # $tpl->parse(ROWS,".theader");
241 $tpl->parse(ROWS,".trow");
242 }
243
244 }
245 $tpl->parse(TOPIC_LIST, "ttable");
246
247 $tpl->assign( array(
248 PHP_SELF => $PHP_SELF,
249 TITLE => "List of topics"
250 ) );
251
252 if ($what != "new") {
253 $tpl->parse(START_NEW_TOPIC, "startnew");
254 }
255 $tpl->parse(MAIN, "listall");
256 if ($what == "new") {
257 $tpl->parse(MAIN, ".newtopic");
258 $tpl->assign(array( TITLE => "Start of new topic" ));
259 } elseif ($what == "show") {
260 $tpl->assign(array(
261 TITLE => "Select article for reply",
262 P => $p
263 ));
264 } elseif ($what == "reply") {
265 $tpl->assign(array(
266 TITLE => "Reply to selected article",
267 P => $p
268 ));
269 }
270 $tpl->parse(MAIN, "main");
271
272 $tpl->FastPrint();
273
274 #include("debug.inc");
275
276 ?>

  ViewVC Help
Powered by ViewVC 1.1.26