Location: PHPKode > projects > MyOWNSpace > MyOWNspace_v8.2/www/showmyownguestbook.php
<?php
$cryptinstall="./classes/crypt/cryptographp.fct.php";
include $cryptinstall;  
require("./classes/guestbook.class.php");
$code_gb="";


/*
CONFIGURE COMMENT db
*/
$db_using = "FLAT"; // choose FLAT DB
if ($db_using == "FLAT") {
	$fields_array = array("author", "comment", "date");
	$db_info = "./myownguestbook/guestbook.".$owner.$_GET['go'].".xml";
}
else	die();
set_magic_quotes_runtime(0);
$gb = new Guestbook($fields_array);
$gb->gbConfig($db_info);
/*
  CAPTCHA control condition...
  Re-Generating variables for html form...
*/

$form_comment='<form method="post" action="'.$PHP_SELF.'#gb">
<table width=200 cellpadding=10 cellspacing=0 border=0>
<tr><td align=center colspan=2>
<hr size="1" color="#FF0000">
<b>Sign this guestbook</b><br>
Name:<br>
<input type="text" name="author" size="25"><br>
Comment: <a id="mylink9" href="$mycomment?width=300" class="betterTip" title="Tips for your comment">?</a><br>
<textarea name="comment" cols="25" rows="6"></textarea><br>
<input type=hidden name="act" value="sign">';

////DELETE

if($_GET['act']=="delete"&&isset($_GET['id'])){
$gb->deleteRecord($_GET['id']);
}
////// UPDATE if $_POST

if ( isset ( $_POST [ 'go' ] ) && chk_crypt($_POST['code']) ) {

		$passed = true;
		if ($_POST['act'] == "sign") 
    { // sign guestbook
		$date = time();
		$data_array = array($_POST['author'], $_POST['comment'], $date);
		$gb->putIntoDB($data_array);	
		$message="<b>Your comment has been added :)</b>";
///CONFIRMATION EMAIL
include "config.php";
$go=$_GET['go'];
$comment=$_POST['comment'];
$author=$_POST['author'];
$artist=$myspace[$go]['artiste'];
$message_content="Hi ".$artist." -- You have a new comment !\r\n
\r\n http://myownspace.fr/".$go." \r\n From: ".$author." \r\n Message: ".$comment."\r\n\r\n ======================\r\n";
$to      = $myspace[$go]['contact'];
$subject = 'Someone has signed your guestbook!';
$from = '"MyOwnSpace"<'.$admin_mail.'>';
$headers = 'From: '.$from . "\r\n" .
     'Reply-To: '.$from. "\r\n" .
     'Bcc: '.$from . "\r\n" .
     'X-Mailer: myOwnSpace/';
mail($to, $subject, $message_content, $headers);
    }     
}	else {
		$passed = false;
		$message="";
     	}
	
//////////// SHOW ALL COMMENTS

$records_total = $gb->getRecordsTotal();
if ( $records_total > 0 ) {
echo'<table align="center" bgcolor="#ffffff" border="0" bordercolor="#000000" cellpadding="0" cellspacing="3" width="435">
<tbody><tr>
 <td><a href="gb"></a><b>Comments : <span class="redtext"> '.$records_total.' </span>.&nbsp;</b></td>
</tr><tr><td bordercolor="ff9933" bgcolor="#ffcccc">
                 <table border="1" bordercolor="#ffffff" cellpadding="3" cellspacing="0" width="100%">
                 <tbody>';
	$records = array_reverse($gb->getRecords("date"));
	foreach ($records as $k => $row) {
	$code_gb.='<tr><td style="" align="center" bgcolor="#ff9933" valign="top" width="150">'
                                .$row['author'].'
                                    <br><br>
                                </td>
                                <td style="" align="left" bgcolor="#f9d6b4" valign="top" width="260">
<span class="blacktext10">'
                                        .date("d/m/Y - H:i:s", $row['date']).
                                    '</span>
																	<br><br>
                                    '.nl2br($row['comment']);
	
	
	
	  
  if( checkauth() && $owner==$rawuser) { 
  $code_gb.="<a href='" . $PHP_SELF . "?act=delete&id=" . $row['id'] . "'>[Delete this comment]</a>";
  }
  $code_gb.="</td></tr>";
  
	}
}
else {
	$code_gb.="<h3>Not any comment yet.</h3>";
}

echo $code_gb.$message.'</td></tr></tbody></table></td> </tr> <tr><td align="center">'
.$form_comment.'<span class="str"><b>Pass the test to sign this guestbook...</b></span></td></tr><tr>
				<td align=center class="td_0" colspan=2><input type=text name="code" size=25></td></tr><tr>
				<td align=center class="td_0" colspan=2>';
dsp_crypt(0,1);   
echo '</td></tr><tr>
				<td colspan=2 align=center><input type=submit name="go" value="Sign"></td></tr></table>
	</form></td>

        </tr>
        </tbody></table>';


?>
Return current item: MyOWNSpace