/[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.3 - (show annotations)
Fri Dec 8 08:38:09 2000 UTC (18 years, 3 months ago) by dpavlin
Branch: MAIN
Changes since 1.2: +1 -0 lines
ispis da je korisnik u solution room-u.

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

  ViewVC Help
Powered by ViewVC 1.1.26