/[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.5 - (show annotations)
Thu Dec 21 15:05:43 2000 UTC (23 years, 3 months ago) by dpavlin
Branch: MAIN
Changes since 1.4: +1 -1 lines
oh, stupid typo which prevented new from working

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

  ViewVC Help
Powered by ViewVC 1.1.26