FrontPage
editcomment.phpのソースコード
<?
require("MySmarty.class.php");
require('Settings.class.php');
require('Categories.class.php');
require('Comment.class.php');
$smarty = new MySmarty();
$settings = new Settings;
$categories = new Categories;
$com = new Comment;
session_start();
$id = $_SESSION['id'];
$pass = $_SESSION['pass'];
// ユーザチェック
if( ( $id == '' ) || ( !$settings->isValidUser ($id,$pass) ) ){
header("Location: login.php" );
exit;
}
$settings->loadSettings();
$smarty->assign( "maintitle", $settings->maintitle );
if( $_SERVER['REQUEST_METHOD'] == 'GET' ){
if( !isset( $_GET['comid'] ) || ( $_GET ['comid'] == 0 ) ) {
header("Location: commentlist.php" );
exit;
} else {
$err = $com->loadComment( $_GET ['comid'] );
$err_msg = $topic->errorm;
$smarty->assign( "comid", $com->comid );
$smarty->assign( "topicid", $com- >topicid );
$smarty->assign( "comname" , $com->comname );
$smarty->assign( "mailaddr" , $com->mailaddr );
$smarty->assign( "title" , $com->title );
$smarty->assign( "body" , $com->body );
}
} else {
$smarty->assign('comid', $_POST['comid']);
$smarty->assign('topicid', $_POST['topicid']);
$smarty->assign('comname', $_POST['comname']);
$smarty->assign('mailaddr', $_POST['mailaddr']);
$smarty->assign('title', $_POST['title']);
$smarty->assign('body', $_POST['body']);
if( $_POST['submit'] != '' ){
// 入力チェックを挿入
// $err_msg = check_input();
if( $err_msg == '' ){
$com->comid = $_POST['comid'];
$com->topicid = $_POST['topicid'];
$com->comname = $_POST['comname'];
$com->mailaddr = $_POST ['mailaddr'];
$com->title = $_POST['title'];
$com->body = $_POST['body'];
$com->saveComment();
$err_msg = $topic->errorm;
}
if( $err_msg == '' ){
$gen_msg = "コメント書き込み完了しました。";
}
}
}
$smarty->assign('error_message', $err_msg);
$smarty->assign('general_message', $gen_msg);
$smarty->display( "editcomment.html" );
?>