#!/usr/bin/perl

#---初期設定ここから----------------------------------------

# ユーザーディレクトリ設定ファイルへのパスを指定
require './dir.pl';

# データベース設定ファイルへのパスを指定
require $root_to_kanri.'/dbpass/param.pl';

# 専用設定ファイルへのパスを指定
require $root_to_kanri.'/kanri/contents.pl';

# 本スクリプト名を指定。
$self='contents.cgi';

#Jcode.pmへのパスを指定
require $root_to_kanri.'/common/Jcode.pm';

#top_layout.plへのパスを指定1
require $root_to_kanri.'/common/top_layout.pl';

&top_layout;

#header_footer.plへのパスを指定1
require $root_to_kanri.'/common/header_footer.pl';

&header_footer;


# library.plへのパスを指定。
require $root_to_kanri.'/common/library.pl';

# 基本設定読み込み
&config;


#---初期設定ここまで----------------------------------------

use POSIX;
use CGI;
use DBI;

# デコード
&decode;

$code = $in{'code'};
$contents_id = $in{'contents_id'};

# DBに接続
&db_connect;	
	
# SQL
$qcontents_id=$contents_id;
$qcontents_id=$db->quote($qcontents_id);
	
$sql = "select * from $table_01 where contents_id = $qcontents_id and hyouji like 'yes'";
	
$sth = $db->prepare($sql);
if(!$sth->execute){print "データの取得に失敗しました(2)<br />\n";exit;}

@rec = $sth->fetchrow_array;

$page_title=$rec[2];
$cate_id=$rec[4];

#カテゴリー名の取得
$sql_catename = "select * from $table_01 where category = '$cate_id'";
$sth_catename = $db->prepare($sql_catename);
if(!$sth_catename->execute){print "データの取得に失敗しました(2)<br />\n";exit;}
@rec_catename = $sth_catename->fetchrow_array;
$category_name=$rec_catename[1]; #カテゴリー名
$sth_catename->finish;


if($rec[48]){$title=$rec[48];}else{$title=$title." | ".$page_title;}
if($rec[49]){$keywords=$rec[49];}else{$keywords=$keywords.",".$page_title;}
if($rec[50]){$description=$rec[50];}else{$description=$description." ".$page_title;}


# HTML
&header($title);

&head_lines;

#&menu_top;

#&menu;

#&menu_end;

&box_top;

print <<"EOF";
$rec[41]
EOF

&sns_box;

# ステートメントハンドルクリア
$sth->finish;
			
if($contents_id == 22){&recommend_item;}

# DB切断
&db_connect_off;

	
&box_end;

&footer3;

exit;
