Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

txtForum v.0.5 - forum zasnovan na txt fajlu

[es] :: PHP :: txtForum v.0.5 - forum zasnovan na txt fajlu

[ Pregleda: 2262 | Odgovora: 10 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Zoran Rašković
Serbia

Član broj: 95
Poruke: 1350
*.vis.clearwire-dns.net.

Sajt: www.yespenisenlargement.c..


Profil

icon txtForum v.0.5 - forum zasnovan na txt fajlu07.04.2002. u 22:08

E juche sam uradio ovaj txtForum.

Posto je ES bio down, nisam pre mogao da postujem.

Dakle, pogledajte http://zoki.ath.cx/txtForum . Slobodno postujte nesto, testirajte ga.

Forum se sastoji od jednog index.php fajla i jednog txt fajla i to je sve.

Forum ce biti vrlo brzo dostupan za download a ako zelite, mogu da pastujem ceo index.php ovde, posto je malko duzi ali ako hocete uradicu to pa da analiziramo code :)

Ocekujem krutike i sugestije

Pozdrav

Zoki
Did you know that one of the best weight loss pills is Proactol? Well, in my experience it is certainly one of the top diet pills on the market.
07.04.2002. u 22:08 

Toni
Dorćol, Beograd

SuperModerator
Član broj: 15
Poruke: 630
*.verat.net

Jabber: toni@elitesecurity.org
ICQ: 16451419
Sajt: www.netizen.co.yu


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu07.04.2002. u 22:14
a fino fino bash lepo :)

to ono kada ti treba za neki site chisto da ima ;)
Jel potpis treba pisanim ili štampanim slovima?
_________________________________________
www.dizajnzona.com - www.netizenfaction.com
07.04.2002. u 22:14 

t3chX
Srđan Rajčević
Thessaloniki

Član broj: 2509
Poruke: 101
*.access.acn.gr

Jabber: techx@elitesecurity.org


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu07.04.2002. u 22:37
Fin je forum .. ako moze code da pastujesh ?

If you want to get anywhere in your life, don't break the rules - make them !
07.04.2002. u 22:37 

Zoran Rašković
Serbia

Član broj: 95
Poruke: 1350
*.vis.clearwire-dns.net.

Sajt: www.yespenisenlargement.c..


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu07.04.2002. u 22:47
OK evo koda:

Code:


<html>
<head>
<title>txtForum</title>
</head>
<body>
<center>
<?
//////////////////////////////////////////////////////////////////////
//                                                                 //
//    txtForum v.0.5                                              //
//    author: Zoran Raskovic                                     //
//            techno_zoki@sendmail.ru                           //
//            techno_zoki@yahoo.com                             //
//              icq: 46742125                                     //
//    date: April 6, 2002                                       //
//                                                              //
//           You need to set $posts, $httpindex,                //
//              $row1_color and $row2_color                     //
//                                                              //
//  Please drop me a line or two if you find txtForum useful.   //
//   Also, send me your url where you are using my forum :)     // 
//   Questions, comments and suggestions are welcomed as well.  //
//                                                              //
//     Special thanks to Ted Suzman for fixing up some code     //
//       and Verdana for the banner.                            // 
//                                                              //
//////////////////////////////////////////////////////////////////
//$posts - path to your posts.txt file
$posts = 'C:/web/zoki/txtforum/posts.txt';

//$httpindex - url where your index.php is
$httpindex = 'http://zoki.ath.cx/txtForum/index.php';

//$row1_color - color of alternating row one
$row1_color="#ffffff";

//$row2_color - color of alternating row two
$row2_color="#BCD8E2";


////////////////////////DO NOT EDIT BEYOND THIS POINT UNLESS YOU KNOW WHAT YOU ARE DOING!!!!/////////////////////////////

//top part
$topics=0;
$msgs=0;
$fp = fopen ($posts, "rb");
while (!feof ($fp))
    {
        $buff = fgets($fp, 4096);
        if(substr($buff, 0, 10 )=="[new_post]") {
            $p=explode('|||^^^|||', "$buff");
            if ($p[2]==0) {
                $topics++;
                $msgs++;
            }
            else {
                $msgs++;
            }
            
        }

    }
fclose($fp);


$now=date("M-d-Y, H:i:s");
$timezone=date("O");
echo "<table border='0' width='80%'><tr><td align='left'><img src='forum.jpg'><td valign='bottom' align='right'></td></tr><tr><td>$topics topics and $msgs messages<td align='right'>$now $timezone</td></tr></table>";

switch($a)
{
//if there's a reply..
CASE "reply":
    //open txt file for reading and writing
    $fp = fopen ($posts, "rb");
    //get the next post_id
    $id=fgets($fp, 4096);
    $new_id=$id+1;
    //echo "id=$id, new_id=$new_id<p>$contents<p>";
    //close file
    fclose($fp);
    $fp = fopen ($posts, "r+b");
    //memorize this id
    fwrite($fp, $new_id);
    //close file 
    fclose($fp);
    $fp = fopen ($posts, "ab");
    fwrite($fp, "\r\n");
    //close file 
    fclose($fp);
    
    //do we have all required info?
    if (!$name or !$subject or !$msg) {
        header("Location: $httpindex");
    }
    else {
    //write new post in file
    $name=htmlspecialchars($name);
    $subject=htmlspecialchars($subject);
    $msg=htmlspecialchars($msg);
    $msg = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$msg);
    $datum=date("m-d-Y @ h:i:s");
    $fp = fopen ($posts, "ab");
    fwrite($fp, "[new_post]|||^^^|||$new_id|||^^^|||$tid|||^^^|||$name|||^^^|||$subject|||^^^|||$datum|||^^^|||$msg|||^^^|||");
    //close file 
    fclose($fp);
    }
    //forward user to the thread they just posted to
    header("Location: {$httpindex}?a=view_thread&tid=$tid");
BREAK;

//are we viewing a thread?

CASE "view_thread":
    $fp = fopen ($posts, "rb");
    //show the first message

    echo "<table border='0' bordercolor='#e2e2e2' width='80%' cellspacing='1' cellpadding='2' bgcolor='#000000'><tr bgcolor='$row2_color' border='1' bordercolor='1'><td width='20%'>Author<td width='80%'>Message</td></tr>";
    
    while(!feof ($fp))
    {
    
        $buffer = fgets($fp, 4096);
        if (substr($buffer, 0, 10 )=="[new_post]")
        {
            $p=explode('|||^^^|||', "$buffer");
            if ($p[1]==$tid)
            {
                $subject=$p[4];
                $msg1=nl2br($p[6]);
                $msg1 = str_replace('[b]', '<b>', $msg1);
                $msg1 = str_replace('[/b]', '</b>', $msg1);
                $msg1 = str_replace('[i]', '<i>', $msg1);
                $msg1 = str_replace('[/i]', '</i>', $msg1);
                $msg1 = str_replace('[u]', '<u>', $msg1);
                $msg1 = str_replace('[/u]', '</u>', $msg1);
                $msg1 = str_replace('[red]', '<font color=red>', $msg1);
                $msg1 = str_replace('[/red]', '</font>', $msg1);


                $msg1 = str_replace('[link=&amp;quot;javascript', '[link=&amp;quot; javascript', $msg1);
        //    $msg1 = preg_replace('\[link=&amp;quot;([[:graph:]]+)&amp;quot;\]', '&lt;a href="\1">', $msg1);
                $msg1 = str_replace('[/link]', '&lt;/a>', $msg1);      


                echo "<tr bgcolor='$row1_color' border='1' bordercolor='1'><td valign='top'>$p[3]<td>$p[4]<p>$msg1</td></tr><tr bgcolor='$row1_color' border='1' bordercolor='#ffffff'><td>$p[5]<td></td></tr>";    
            }
        }
    }
    fclose($fp);
    //list all messages that have a thread id = $tid
    $fp = fopen ($posts, "rb");
    
    $color=0;
    while (!feof ($fp))
    {
        $buffer = fgets($fp, 4096);
        if(substr($buffer, 0, 10 )=="[new_post]")
        {
            $p=explode('|||^^^|||', "$buffer");
            if ($p[2]==$tid)
            {
                $subject=$p[4];
                $msg1=nl2br($p[6]);
                $msg1 = str_replace('[b]', '<b>', $msg1);
                $msg1 = str_replace('[/b]', '</b>', $msg1);
                $msg1 = str_replace('[i]', '<i>', $msg1);
                $msg1 = str_replace('[/i]', '</i>', $msg1);
                $msg1 = str_replace('[u]', '<u>', $msg1);
                $msg1 = str_replace('[/u]', '</u>', $msg1);
                $msg1 = str_replace('[red]', '<font color=red>', $msg1);
                $msg1 = str_replace('[/red]', '</font>', $msg1);

                $msg1 = str_replace('[link=&amp;quot;javascript', '[link=&amp;quot; javascript', $msg1);
        //        $msg1 = preg_replace('\[link=&amp;quot;([[:graph:]]+)&amp;quot;\]', '&lt;a href="\1">', $msg1);
                $msg1 = str_replace('[/link]', '&lt;/a>', $msg1);     

                if ($color==0) {
                echo "<tr bgcolor='$row2_color' border='1' bordercolor='1'><td valign='top'>$p[3]<td>Re: $p[4]<p>$msg1</td><tr bgcolor='$row2_color' border='1' bordercolor='#ffffff'><td>$p[5]<td></td></tr>";
                $color=1;
                }
                else {
                echo "<tr bgcolor='$row1_color' border='1' bordercolor='1'><td valign='top'>$p[3]<td>Re: $p[4]<p>$msg1</td><tr bgcolor='$row1_color' border='1' bordercolor='#ffffff'><td>$p[5]<td></td></tr>";
                $color=0;
                }
            }
        }
    }
    fclose($fp);
    echo "</table><p><A HREF='index.php'>Back to list</A>";
//display form for replying
    echo "
    <form action='index.php?a=reply' method='post'>
    <table border='0'>
    <tr><td><B>Name</B>: </td><td><INPUT TYPE='text' NAME='name' size='30'></td></tr>
    <tr><td><B>Subject</B>: <td>$subject</td></tr>
    <tr><td><B>Message</B>: <td><TEXTAREA NAME='msg' ROWS='8' COLS='40'></TEXTAREA></td></tr></table>
    <table>
    <tr><td>
    <INPUT TYPE='hidden' name='tid' value='$tid'>
    
    <input type='hidden' name='subject' value=\"$subject\">
    <INPUT TYPE='submit' name='submit_new' value='Reply'></td></tr>
    </table>
    </form>";
BREAK;

//are we posting a new topic?
CASE "post_new":
    //open txt file for reading and writing
    $fp = fopen ($posts, "rb");
    //get the next post_id
    $id=fgets($fp, 4096);
    $new_id=$id+1;
    //close file
    fclose($fp);
    $fp = fopen ($posts, "r+b");
    //memorize this id
    fwrite($fp, $new_id);
    //close file 
    fclose($fp);
    $fp = fopen ($posts, "ab");
    fwrite($fp, "\r\n");
    //close file 
    fclose($fp);
    
    //do we have all required info?
    if (!$name or !$subject or !$msg) {
        header("Location: $httpindex");
    }
    else {
    //write new post in file
    $name=htmlspecialchars($name);
    $subject=htmlspecialchars($subject);
    $msg=htmlspecialchars($msg);
    $msg = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$msg);
    $datum=date("m-d-Y @ h:i:s");
    $fp = fopen ($posts, "ab");
    fwrite($fp, "[new_post]|||^^^|||$new_id|||^^^|||0|||^^^|||$name|||^^^|||$subject|||^^^|||$datum|||^^^|||$msg|||^^^|||");
    //close file 
    fclose($fp);
    }
    //forward user to the topic listing
    header("Location: $httpindex");
BREAK;


//if nothing else, list all threads here

DEFAULT:
    echo "<table border='0' bordercolor='#e2e2e2' width='80%' cellspacing='1' cellpadding='2' bgcolor='#000000'><tr bgcolor='$row2_color' border='1' bordercolor='1' align='center'><td width='60%'>Subject<td width='20%'>Author<td>Replies<td width='20%'>Date</td></tr>";
    $fp = fopen ($posts, "rb");
    while (!feof ($fp))
    {
        $buffer = fgets($fp, 4096);
        if(substr($buffer, 0, 10 )=="[new_post]")
        {
            $p=explode('|||^^^|||', "$buffer");
            //echo sizeof($p);
            if ($p[2]==0)
            {
            //get number of replies for this thread
            $fp1 = fopen ($posts, "rb");
            $replies=0;
            while (!feof ($fp1))
                {
                $buffer1 = fgets($fp1, 4096);
                
                if(substr($buffer1, 0, 10 )=="[new_post]")
                {
                    
                    $p1=explode('|||^^^|||', "$buffer1");
                    if ($p1[2]==$p[1]) {
                        $replies++;
                    }
    
            }
            }
            fclose($fp1);

            echo "<tr bgcolor='#ffffff' border='1' bordercolor='1'><td><A HREF='index.php?a=view_thread&tid=$p[1]'>$p[4]</A><td>$p[3]<td align='center'>$replies<td>$p[5]</td></tr>";
            }
            //echo "<p>";
        }
    }
    fclose ($fp);
    echo "</table><p>";
    // display form for posting a new topic
    echo "Post a new topic
    <form action='index.php?a=post_new' method='post'>
        <table border='0'>
        <tr><td><B>Name</B>: </td><td><INPUT TYPE='text' NAME='name' size='30'></td></tr>
        <tr><td><B>Subject</B>: <td><INPUT TYPE='text' NAME='subject' size='30'></td></tr>
        <tr><td><B>Message</B>: <td><TEXTAREA NAME='msg' ROWS='8' COLS='40'></TEXTAREA></td></tr></table>
        <table>
        <tr><td><INPUT TYPE='submit' name='submit_new' value='Post new topic'></td></tr>
        </table>
    </form>";
    BREAK;
}
echo "&nbsp;<p><small>powered by <A HREF='http://zoki.ath.cx/txtForum'>txtForum v.0.5</A></small>";
?>
</center>
</body>
</html>





Obratite paznju da code nije sto posto chist i gotov ali prilicno je doteran.
Did you know that one of the best weight loss pills is Proactol? Well, in my experience it is certainly one of the top diet pills on the market.
07.04.2002. u 22:47 

Zoran Rašković
Serbia

Član broj: 95
Poruke: 1350
*.vis.clearwire-dns.net.

Sajt: www.yespenisenlargement.c..


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu08.04.2002. u 00:01
forum je zeznuo kod na nekim mestima

takodje sada sam dodao da pre svakog fwrite-a ide flock($fp, 2) sto zakljucava fajl

a posle svakog fwrite-a ide flock($fp, 3) sto ga otkljucava

ovo je potrebno jer je mogu ce da se desi da vise korisnika u isto vreme postuju, tj txt fajl ce se otvoriti vise puta u isto vreme tako da moze doci do korupcije.
Did you know that one of the best weight loss pills is Proactol? Well, in my experience it is certainly one of the top diet pills on the market.
08.04.2002. u 00:01 

RAZZLEDAZZLER
Tora Bora

Član broj: 27
Poruke: 523
*.ppp-bg.sezampro.yu



Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu08.04.2002. u 11:33
Mislim da nemash potrebu da stavljash varijablu $httpindex da korisnik definishe. Moze to i sam php ... izmedju ostalog ...npr
$httpindex = $HTTP_HOST . $PHP_SELF;
08.04.2002. u 11:33 

Zoran Rašković
Serbia

Član broj: 95
Poruke: 1350
*.ftl.fdn.com

Sajt: www.yespenisenlargement.c..


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu08.04.2002. u 15:26
Moram reci da je gornji kod dosta izmenjen u verziji foruma koja je dostupna za download, a ne vredi da postujem taj code jer ce opet zeznuti output.

Naime, morao sam da izmenim da se pre svakog Location headera NE ispisuje nista, jer u protivnom ne bi radilo.

Verzija 0.5 je dostupna za download na sajtu na gornjem linku.
Did you know that one of the best weight loss pills is Proactol? Well, in my experience it is certainly one of the top diet pills on the market.
08.04.2002. u 15:26 

Divine
Miloš Šaković
Yugoslavia

Član broj: 883
Poruke: 108
195.66.182.*

ICQ: 16044064
Sajt: www.divine.cg.yu


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu08.04.2002. u 16:29
Super izgleda :)
I see dead people...
08.04.2002. u 16:29 

Serbian Fighter
Ivan Minic
Decko koji obecava.
Permanently Offline

Član broj: 2583
Poruke: 2316
*.beotel.net

ICQ: 83773127
Sajt: www.Burek.co.yu


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu22.04.2002. u 00:37
Jednostavno
Lepo
Funkcionalno ...
sve u svemu
SASVIM DOBRO!
Nista kao vruc Burek...
22.04.2002. u 00:37 

Mihailo
Mihailo Đorić

Član broj: 1016
Poruke: 2871
*.verat.net



Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu22.04.2002. u 14:20
Predlažem da ubuduće kad šaljete više linija koda sačuvate isti u text fajl i zakačite za poruku - tako neće biti greški, a kod će moći da se lako preuzme i koristi. Trudite se da koristite Unicode standard.
22.04.2002. u 14:20 

ctpaba
Robert IVKOVIC
System admin, network admin, webmaster.......
Paris

Član broj: 597
Poruke: 304
*.w80-14.abo.wanadoo.fr

ICQ: 230666231
Sajt: www.ctpaba.org


Profil

icon Re: txtForum v.0.5 - forum zasnovan na txt fajlu26.05.2002. u 15:15
forum je super odavno sam trazio nesto slicno
ako moze malo sugestija jednog laika.

posle par dana koristenja foruma primetio sam da bi bilo zgodno staviti
rubriku za eMail i ograniciti broj slova u subject, name i email.

bilo bi zgodno ako bi postojala mogucnost online editovanja txt fajla sto bi zamenilo moderatorske funkcije i omogucilo izbacivanje nezeljenog texta bez downloadovanja fajla.

i licno mislim da bi varijanta sa cetiri strabe bilo bolje gde bi bilo jedna strana sa topicima, jedna sa odgovorima i po jedna za reply i new post.

e da i strana sa demo i daunodovanjen je AOS.
tnx
CTPABA uber alles
www.ctpaba.org
26.05.2002. u 15:15 

[es] :: PHP :: txtForum v.0.5 - forum zasnovan na txt fajlu

[ Pregleda: 2262 | Odgovora: 10 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.