header_html(THEMETITLE);//ヘッダー
if(!isset($_SESSION["session_id"])){
html::error("ログインできていないようです。
ログインフォームよりログインしてください。");
}
switch($_POST['mode']):
case 'theme_add': // 書き込み処理
$add = new theme_add();
$add->add_main();
break;
case 'theme_cor': // 編集処理
$cor = new theme_cor();
$cor->cor_main();
break;
case 'theme_del_h': // 削除確認
$del = new theme_del();
$del->del_html();
break;
case 'theme_del': // 削除処理
$del = new theme_del();
$del->del_main();
break;
case 'view': // 個別表示
$view = new theme_view();
$view->no_view();
break;
default: // 一覧表示
$view = new theme_view();
$view->view();
break;
endswitch;
$h->footer_html(); //フッター
exit();
//================================================//
//■テーマ追加 //
//================================================//
class theme_add{
var $id;
var $tno;
var $tname;
//================================================//
//□コンストラクタ
//================================================//
function __construct(){
$this->tname = $_POST['tname'];
$this->tno = $_GET['no'];
$this->id = $_SESSION["session_id"];
}
//================================================//
//□追加処理
//================================================//
function add_main(){
global $my_url,$th;
$th_no = $th['no'];
//文字チェック
$this->check();
//上限までに戻す
if($th['row'] >99){
$th['row'] = 99;
}
//Mysqlへ接続
$con_id = sql_init::connect();
//整列して読み込み
$insert ="SELECT * FROM {$th['colum']} "
."WHERE {$th['id']}='$this->id'"
."ORDER BY {$th['no']}";
//SQL文送信
$sql = mysql_query($insert,$con_id);
//配列として受け取る(MYSQL_ASSOCはカラム名で受け取るやつ)$lines[themeName]とかできる
$con =0;
while($lines = mysql_fetch_array($sql,MYSQL_ASSOC)){
// echo"{$con}個目: {$lines[$th_no]}
";
//件数が超えてないかチェック
if($con > $th['row']){
html::error("これ以上増やせません");
}
//一致しなければループぬける
if($lines[$th_no] !=$con){
break;
}
$con++;
}
//No決定
$tno = $con;
//登録内容
$insert ="INSERT INTO {$th['colum']}({$th['id']},{$th['no']},{$th['name']})"
."VALUES('$this->id','$tno','$this->tname')";
//データベースへ登録
if(mysql_query($insert,$con_id)){
echo"登録しました。";
}else {
html::error("登録できませんでした。");
}
//sql接続切る
mysql_close($con_id);
//管理トップに戻す。
html::back_html($my_url);
}
//================================================//
//□文字チェック
//================================================//
function check(){
//文字チェック
$error = $this->write_check();
if($error != ""){
//書き込み画面へ
theme_view::view($error);
//フッター
html::footer_html();
exit();
}
}
//================================================//
//□check処理部
//================================================//
function write_check(){
$error="";
//文字数チェック
if(strlen($this->tname) > 40){
$error .="20文字以内にしてください
";
}elseif($this->tname == ""){
$error .="入力されていません
";
}
return $error;
}
}
//================================================//
//■テーマ編集 //
//================================================//
class theme_cor extends theme_add{
//================================================//
//□編集処理
//================================================//
function cor_main(){
global $my_url,$th;
//文字チェック
$this->check();
//Mysqlへ接続
$con_id = sql_init::connect();
//登録内容
$insert ="UPDATE {$th['colum']} SET "
."{$th['name']} = '$this->tname' "
."WHERE {$th['id']}='$this->id' AND {$th['no']}='$this->tno'";
//データベースへ登録
if(mysql_query($insert,$con_id)){
echo"変更しました。";
}else {
html::error("変更できませんでした。");
}
//sql接続切る
mysql_close($con_id);
//管理トップに戻す。
html::back_html($my_url);
}
//================================================//
//□文字チェック
//================================================//
function check(){
//文字チェック
$error = $this->write_check();
if($error != ""){
//書き込み画面へ
theme_view::no_view($error);
//フッター
html::footer_html();
exit();
}
}
}
//================================================//
//■削除・表示部共通部
//================================================//
class theme_func{
var $id;
var $tno;
//================================================//
//□コンストラクタ
//================================================//
function __construct(){
$this->id = $_SESSION["session_id"];
$this->tno = $_GET['no'];
}
//================================================//
//□テーマ使用記事表示
//================================================//
function kiji_view($con_id){
global $ki;
$ki_day = $ki['day'];
$ki_title = $ki['title'];
//記事表示
$insert ="SELECT * FROM {$ki['colum']} "
."WHERE {$ki['id']}='$this->id' AND {$ki['tno']}='$this->tno' ORDER BY {$ki['day']} DESC";
//sql実行
$sql = mysql_query($insert,$con_id);
//表示
echo"