/[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

Annotation of /index.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Thu Dec 7 17:01:39 2000 UTC (23 years, 4 months ago) by dpavlin
Branch: DbP
CVS Tags: r0
Changes since 1.1: +0 -0 lines
first, semi-working version

1 dpavlin 1.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]="flase";
114     }
115     }
116    
117     fix_checkbox("analitical");
118     fix_checkbox("solution");
119    
120     $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)"));
121    
122     $sth=$dbh->prepare("select currval('poruke_id_seq') as id");
123     $sth->execute();
124    
125     if ($row=$sth->fetchrow_hash()) {
126     $p=$row[id]; // poruka_id for later
127     }
128    
129     } elseif (isset($insert_newtopic)) {
130    
131     //---- insert new topic into database
132    
133     if (isset($osoba_id)) {
134     $dbh->dbh_do(fixsql("insert into poruke (thread_id,osoba_id,sadrzaj) values (0,$osoba_id,'$sadrzaj')"));
135     $sth=$dbh->prepare("select currval('poruke_id_seq') as id");
136     $sth->execute();
137     if ($row=$sth->fetchrow_hash()) {
138     $t=$row[id]; // topic for later
139     $dbh->dbh_do(fixsql("insert into topics (id,title) values ($t,'$title')"));
140     }
141     }
142     }
143    
144     //----- end of inserts/updates...
145    
146     if ($what=="reply" && isset($t)) {
147     $sql_where=" and topics.id=$t";
148     }
149    
150     $sth = $dbh->prepare("select topics.id as topic_id,title,sadrzaj,full_name,poruke.datum as datum
151     from topics,poruke,osobe
152     where poruke.thread_id=0 and poruke.id=topics.id and poruke.osoba_id=osobe.id $sql_where $sql_poruke_where
153     order by datum asc
154     ");
155     $sth->execute();
156     $topics="";
157     while ($row=$sth->fetchrow_hash()) {
158     $tpl->assign( array(
159     TITLE => $row[title],
160     AUTHOR => $row[full_name],
161     DATE => $row[datum],
162     SADRZAJ => $row[sadrzaj],
163     COMMENTS => "<a href=\"$PHP_SELF?what=reply&t=$row[topic_id]\">comments&gt;&gt;</a>",
164     PHP_SELF => $PHP_SELF
165     ));
166     $tpl->parse(ROWS,".theader");
167    
168     if (isset($t) && $t==$row[topic_id]) {
169     $sth2 = $dbh->prepare("
170     select poruke.id as id,sadrzaj as topic,level,thread_id,reply_id,full_name,poruke.datum as datum,poruke.analitical as poruka_analitical
171     from poruke,osobe
172     where (thread_id=$t or poruke.id=$t) and poruke.osoba_id=osobe.id $sql_poruke_where
173     order by pos
174     ");
175     $sth2->execute();
176    
177     while ($row2=$sth2->fetchrow_hash()) {
178     $l_ul=$r_ul="";
179     for ($i=0; $i<$row2[level]; $i++) {
180     $l_ul.="<ul>";
181     $r_ul.="</ul>";
182     }
183     $tpl->assign( array(
184     L_INDENT => $l_ul,
185     R_INDENT => $r_ul
186     ));
187     $topic=trim(strip_tags($row2[topic]));
188     if (isset($p) && $p == $row2[id]) {
189     $topic="<font color=red>$topic...</font>";
190     $tpl->assign( array( P => $p ));
191     $tpl->parse(CHECKBOXES, ".checkboxes");
192     $tpl->parse(REPLY, ".reply");
193     } else {
194     if (!isset($p)) { $p=$t; }
195     $tmp_t=$row2[thread_id];
196     if ($tmp_t == 0) { $tmp_t=$row2[id]; }
197     $tpl->assign( array(
198     REPLY => "<a href=\"$PHP_SELF?what=reply&p=$row2[id]&t=$tmp_t\">reply</a>"
199     ));
200     }
201     $this.="<br>";
202    
203     if ($row2[poruka_analitical] == "t") {
204     $topic="<i>$topic</i>";
205     }
206    
207     $tpl->assign( array(
208     AUTHOR => $row2[full_name],
209     DATE => $row2[datum],
210     SADRZAJ => $topic
211     ));
212     # $tpl->parse(ROWS,".theader");
213     $tpl->parse(ROWS,".trow");
214     }
215     } else {
216     // non-unroll topics
217     $tpl->assign( array(
218     SADRZAJ => $row[sadrzaj],
219     COMMENTS => "<a href=\"$PHP_SELF?what=reply&t=$row[topic_id]\">comments&gt;&gt;</a>"
220     ));
221     # $tpl->parse(ROWS,".theader");
222     $tpl->parse(ROWS,".trow");
223     }
224    
225     }
226     $tpl->parse(TOPIC_LIST, "ttable");
227    
228     $tpl->assign( array(
229     PHP_SELF => $PHP_SELF,
230     TITLE => "List of topics"
231     ) );
232    
233     if ($what != "new") {
234     $tpl->parse(START_NEW_TOPIC, "startnew");
235     }
236     $tpl->parse(MAIN, "listall");
237     if ($what == "new") {
238     $tpl->parse(MAIN, ".newtopic");
239     $tpl->assign(array( TITLE => "Start of new topic" ));
240     } elseif ($what == "reply") {
241     $tpl->assign(array(
242     TITLE => "Reply to selected article",
243     P => $p
244     ));
245     # $tpl->parse(MAIN, ".reply");
246     }
247     $tpl->parse(MAIN, "main");
248    
249     $tpl->FastPrint();
250    
251     #include("debug.inc");
252    
253     ?>

  ViewVC Help
Powered by ViewVC 1.1.26