Community (php & amp; mysql) 2 function sdatetime ($ str ){
$ Str = ereg_replace ("-", "/", $ str );
$ Str = substr ($ str, 5, strlen ($ str)-8 );
Return $ str;
}
Function reAnum ($ sid) {//
$ DROOT = getenv ('document _ root ');
Include ("SQL. php3 ");
$ Db = mysql_connect ($ SQL ['host'], $ SQL ['user'], $ SQL ['passwd']);
$ Qsql = "SELECT id from bbs_docs where sid = '$ sid '";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
Return mysql_num_rows ($ rs );
}
Function pagebar ($ pages ){
Global $ pgno;
// Global $ pages;
Global $ PHP_SELF;
Global $ aid;
Global $ OPEN_LIST;
Echo"
";Echo"
";
If ($ pgno! = 0 ){
$ Pu = $ pgno-1;
Echo "[]";
}
If ($ pgno <$ pages ){
$ Pd = $ pgno + 1;
Echo "[]";
}
For ($ I = 0; $ I <= $ pages; $ I ++ ){
If ($ pgno = $ I ){
Echo"";
Echo "[". ($ I + 1). "]";
Echo"";
} Else {
Echo "";
Echo "[". ($ I + 1). "]";
Echo "";
}
}
Echo" | ";Echo"
";
Echo "";
Echo "[restricted]";
Echo "";
// Echo" | ";// Echo"
";
If ($ OPEN_LIST ){
Echo "";
Echo "[too many parallel bars]";
Echo "";
} Else {
Echo "";
Echo "[parallel bars]";
Echo "";
}
Echo" | ";Echo"
";
}
// ================================================ ========================================================== =
Function openlist ($ sid ){
Global $ aid;
Global $ PHP_SELF;
$ DROOT = getenv ('document _ root ');
Include ("SQL. php3 ");
$ Db = mysql_connect ($ SQL ['host'], $ SQL ['user'], $ SQL ['passwd']);
$ Qsql = "SELECT * from bbs_docs where sid = '$ sid' order by wdate ";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
// If (mysql_num_rows ($ rs) = 0) return;
// Echo mysql_num_rows ($ rs );
While ($ row = mysql_fetch_array ($ rs )){
$ Id = $ row ['id'];
$ Banner = $ row ['banner '];
$ Poster = $ row ['poster'];
$ Views = $ row ['views'];
$ Wdate = sdatetime ($ row ['wdate']);
Echo"";
Echo"";
Echo "";
Echo "$ banner ";
Echo "";
// Echo "banner is $ banner ";
Echo"";
Echo"";
Echo $ poster;
Echo"";
Echo"";
Echo "";
Echo"";
Echo"";
Echo $ views;
Echo"";
Echo"";
Echo $ wdate;
Echo"";
Echo"";
}
}
// ================================================ ========================================
Function area (){
Global $ PHP_SELF;
Global $ aid, $ sid, $ pgno;
Global $ OPEN_LIST;
$ Showitems = 20;
$ DROOT = getenv ('document _ root ');
Include ("SQL. php3 ");
$ Db = mysql_connect ($ SQL ['host'], $ SQL ['user'], $ SQL ['passwd']);
// ================================================ ======================================
If (! $ Aid ){
$ Qsql = "SELECT id from bbs_area ";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
$ Row = mysql_fetch_array ($ rs );
$ Aid = $ row ['id'];
}
If (! $ Sid ){
$ Qsql = "SELECT id from bbs_subj where aid = $ aid order by wdate DESC ";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
$ Row = mysql_fetch_array ($ rs );
$ Sid = $ row ['id'];
}
If (! $ Pgno) {// counter
// $ Pgno = 0;
$ Items = 0;
$ Qsql = "SELECT id from bbs_subj where aid = $ aid order by wdate DESC ";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
While ($ row = mysql_fetch_array ($ rs )){
$ Id = $ row ['id'];
If ($ id = $ sid) break;
$ Items ++;
}
$ Pgno = (INT) ($ items/$ showitems );
}
// ================================================ ======================================
$ Qsql = "SELECT * from bbs_area where id = $ aid ";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
$ Row = mysql_fetch_array ($ rs );
$ Banner = $ row ['banner '];
$ Body = $ row ['body'];
$ Master = $ row ['master'];
Echo"
$ Banner ";
Echo "";
$ Qsql = "SELECT * from bbs_subj where aid = $ aid order by wdate DESC ";
$ Rs = mysql_db_query ($ SQL ['DB'], $ qsql );
$ All = mysql_num_rows ($ rs); // how rows
$ Pages = (INT) ($ all/$ showitems); // how pages
$ Pgcount = $ pgno * $ showitems;
If ($ pgcount> $ all ){
$ Pgno = $ pages-1; // Page point over all pages
$ Pgcount = $ pgno * $ showitems;
}
Mysql_data_seek ($ rs, $ pgcount );
$ Cnt = 0;
Pagebar ($ pages );
Echo"
";Echo"
";
Echo"
";Echo"
";Echo"
| Clip | ";Echo"
Only accept | ";Echo"
Lai | ";Echo"
| ";Echo"
Timestamp | ";Echo"
";While ($ row = mysql_fetch_array ($ rs )){If (++ $ cnt> $ showitems) break;$ Id = $ row ['id'];$ Banner = $ row ['banner '];$ Poster = $ row ['poster'];$ Views = $ row ['views'];$ Wdate = sdatetime ($ row ['wdate']);$ Docs = reAnum ($ id );Echo"
";Echo"
";
Echo "";
If ($ sid = $ id) echo "<$ banner ";
Else echo $ banner;
Echo "";
Echo" | ";Echo"
";
Echo $ poster;
Echo" | ";Echo"
";
Echo $ docs;
Echo" | ";Echo"
";
Echo $ views;
Echo" | ";Echo"
";
Echo $ wdate;
Echo" | ";Echo"
";If ($ OPEN_LIST) openlist ($ id );}Echo"
";
Echo" |
";
Pagebar ($ pages );
}
To be Continued ........