Board bez podpory MySQL - ukázka zdrojového kódu zdrojový kód

<-- chat.php -->
               
<HTML>
  <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html;windows-1250">
    <TITLE>Main</TITLE>
  </HEAD>
<BODY bgcolor=#999999 text=Silver LINK="Blue" ALINK="#0000BB" VLINK="Blue">


 <?php

    
// open message file
    
$message_array file"messages.txt" );
    
$number_of_threads=0;
    
// store the last entry to avoid duplica
    //     tes
    
list( $fnumber$fsubject$fname$femail$fdate$ftext$flinkurl$flinktitle, ) = split("::"$message_array[0] );
    
// if something has been entered and it 
    //     is not the same as the last one
    
if( $name!="" && $subject!="" && $message!="" && ( $name!=$fname || $subject!=$fsubject ) ){
    
// load all old messages
    
for( $counter=0$counter<100$counter++ ){
    
// split message field up
    
if( $message_array[$counter] ){
    list( 
$pnumber$psubject$pname$pemail$pdate$ptext$plinkurl$plinktitle ) = split("::"$message_array[$counter] );
    
// check for vality should be as all mes
    //     sages are valid when entered
    
if( $pnumber && $psubject && $ptext && $pname ){
    
// count the number of messages
    
if( $pnumber $number_of_threads ){
    
$number_of_threads=intval($pnumber);
    }
    
// add all the old messages into old_mes
    //     sages string
    
$old_messages .= $message_array[$counter];
    }
    }
    }
    
// create new message...
    // add date in format hh:mm:ss dd/mm/yy
    
$date=date("H:i:s d/m/y");
    
// replace newlines with <br>'s
    
$message=ereg_replace"\n""<br>"$message );
    
// format the new message
    
$new_message = ($number_of_threads+1)."::$subject::$name::$email::$date::$message";
    
//strip html chars
    
$new_message htmlspecialchars$new_message );
    if( 
$linkurl && !(ereg"^http:\/\/"$linkurl )) ){
    
$linkurl "http://".$linkurl;
    }
    
$new_message .= "::$linkurl::$linktitle\n";
    
// open message file
    
$open_file fopen"messages.txt""w");
    
// add message and old messages to file
    // new message will be at the top of the
    //     board
    
fputs($open_filestripslashes$new_message ));
    
fputs($open_file$old_messages);
    
fclose($open_file);
    }
    
// indent is used to align are the messa
    //     ge threads
    
$indent=0;
    
// open message file
    
$message_array file"messages.txt" );
    
// loop through message file lines
    
for( $counter=0$counter<100$counter++ ){
    
// split the message field
    
list( $pnumber$psubject$pname$pemail$pdate$ptext ) = split("::"$message_array[$counter] );
    
// check that it is valid, should be due
    //     to validy check on message post
    
if( $pnumber && $psubject && $ptext && $pname ){
    
// indent if message is a reply
    
if( intval($pnumber)!=$pnumber && $indent==0){
    
$print_titles .= "<ul>\n";
    
$indent=1;
    }
    if( 
intval($pnumber)==$pnumber && $indent==1){
    
$print_titles .= "</ul>\n";
    
$indent=0;
    }
    
// add the titles to the print_titles st
    //     ring
    
$print_titles .= "<li><a href=\"thread.php#$pnumber?thread=$pnumber\">$psubject</a> ";
    
// if an email address is supplied link 
    //     to it
    
if( $pemail ){
    
$print_titles .= "- <a href=\"mailto:$pemail\">$pname</a> $pdate\n";
    } else {
    
$print_titles .= "- $pname $pdate\n";
    } 
    }
    }
    
// print the title array
    
echo( "<ul>\n" );
    echo( 
$print_titles );
    echo( 
"</ul>\n" );
    
// check that there are no lists open
    
if( $indent==){
    echo( 
"</ul>\n" );
    }
    
?>
    <hr>
    <form action="chat.php" method="post">
    <table border="0">
    <tr>
    <td>Name : </td>
    <td><input size="50" type="text" name="name"></td>
    </tr>
    <tr>
    <td>Email (Optional) : </td>
    <td><input size="50" type="text" name="email"></td>
    </tr>
    <tr>
    <td>Subject : </td>
    <td><input size="50" type="text" name="subject"></td>
    </tr>
    <tr>
    <td>Message : </td>
    <td><textarea cols=55 rows=10 name="message" wrap="virtual"></textarea></td>
    </tr>
    <tr>
    <td>Link URL (Optional) : </td>
    <td><input size="50" type="text" name="linkurl"></td>
    </tr>
    <tr>
    <td>Link Title (Optional) : </td>
    <td><input size="50" type="text" name="linktitle"></td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" value="Post new message"><input type="reset"></td>
    </tr>
    </table>
</BODY>
</HTML>


<-- threat.php -->

 <?php

    
// open message file
    
$message_array file"messages.txt" );
    
$threadnumber=0;
    
// store the last entry to avoid duplica
    //     tes
    
list( $fnumber$fsubject$fname$femail$fdate$ftext$flinkurl$flinktitle ) = split("::"$message_array[0] );
    
// if something has been entered and it 
    //     is not the same as the last one
    
if( $name!="" && $subject!="" && $message!="" && ( $name!=$fname || $subject!=$fsubject ) ){
    
// loop through all old messages
    
for( $counter=0$counter<100$counter++ ){
    
// check message line exists
    
if( $message_array[$counter] ){
    
// split message field up
    
list( $pnumber$psubject$pname$pemail$pdate$ptext$flinkurl$flinktitle ) = split("::"$message_array[$counter] );
    
// check for validy of message field. Sh
    //     ould be valid as messages entered are va
    //     lidated
    
if( $pnumber && $psubject && $ptext && $pname ){
    
// find out where to put the new message
    //     
    
if( intval($pnumber) < $thread ){
    
$old_messages .= $message_array[$counter];
    }
    if( 
intval($pnumber) == $thread ){
    
$messages_after .= $message_array[$counter];
    
$threadnumber=$pnumber+0.01;
    }
    if( 
intval($pnumber) > $thread ){
    
$messages_after .= $message_array[$counter];
    }
    }
    }
    }
    
// create new message
    
$date=date("H:i:s d/m/y");
    
$message=ereg_replace"\n""<br>"$message );
    
$new_message "$threadnumber::$subject::$name::$email::$date::$message";
    
// strip html chars
    
$new_message htmlspecialchars$new_message );
    if( 
$linkurl && !(ereg"^http:\/\/"$linkurl )) ){
    
$linkurl "http://".$linkurl;
    } 
    
$new_message .= "::$linkurl::$linktitle\n";
    
// open message file
    
$open_file fopen"messages.txt""w");
    
// strip html stuff and add message to f
    //     ile
    
fputs($open_file$messages_after);
    
fputs($open_filestripslashes$new_message ));
    
fputs($open_file$old_messages);
    
fclose($open_file);
    }
    
// loop through all messages copying the
    //     title and messages into separate arrays
    
$message_array file"messages.txt" );
    for( 
$counter=0$counter<100$counter++ ){
    
// split the message field
    
list( $pnumber$psubject$pname$pemail$pdate$ptext$plinkurl$plinktitle ) = split("::"$message_array[$counter] );
    
// check that it is valid although it sh
    //     ould be due to earlier validity checks
    // also check to see if the message is t
    //     he thread (or followup) that we want
    
if( intval($pnumber)==intval($thread) && $psubject && $ptext && $pname ){
    
// add the message to print_messages str
    //     ing
    
$print_messages .= "<h3><a name=$pnumber>$psubject</a></h3>\n";
    
// if an email address is supplied link 
    //     to it
    
if( $pemail ){
    
$print_messages .= "<p>Posted by <a href=\"mailto:$pemail\">$pname</a> on $pdate</p>\n<p>$ptext</p>";
    } else {
    
$print_messages .= "<p>Posted by $pname on $pdate</p>\n<p>$ptext</p>";
    }
    
// if a url has been submitted draw it u
    //     p
    
if( $plinkurl && $plinktitle ){
    
$print_messages .= "<p><a href=\"$plinkurl\" target=\"_blank\">$plinktitle</a></p>\n";
    } else {
    
$print_messages .= "\n";
    }
    }
    }
    
// print the messages
    
echo( $print_messages );
    
?>
    <hr>
    <form action="thread.php" method="post">
    <?php
    
// pass the thread value when submitted
    
echo( "<input type=\"hidden\" name=\"thread\" value=\"$thread\">\n" ); 
    
?>
    <table border="0">
    <tr>
    <td>Name : </td>
    <td><input size="50" type="text" name="name"></td>
    </tr>
    <tr>
    <td>Email (Optional) : </td>
    <td><input size="50" type="text" name="email"></td>
    </tr>
    <tr>
    <td>Subject : </td>
    <td><input size="50" type="text" name="subject"></td>
    </tr>
    <tr>
    <td>Message : </td>
    <td><textarea cols=55 rows=10 name="message" wrap="virtual"></textarea></td>
    </tr>
    <tr>
    <td>Link URL (Optional) : </td>
    <td><input size="50" type="text" name="linkurl"></td>
    </tr>
    <tr>
    <td>Link Title (Optional) : </td>
    <td><input size="50" type="text" name="linktitle"></td>
    </tr>
    <tr>
    <td colspan="2"><input type="submit" value="Post Followup"><input type="reset"></td>
    </tr>
    </table>
    <hr>
    <center>
    [ <a href="chat.php">Main Board</a> ]
    </center>
    <hr>
Vložil/Poslal/Autor: Admin
Funkčnost: běží na straně serveru, nemělo by záležet na typu prohlížeče
zavřít okno | jít na hlavní stránku JakNaWeb.com