<?php
require_once(dirname(__FILE__)."/../inc/common.php");
/*******************************************************************************************
' Software name: DJCMS Content Management System
' Version:3.0
' Web: http://www.djcms.net
' Author: 心情(qq:1130731)
' Copyright (C) 2009-2010 DJCMS官方 版权所有
' 法律申明：DJCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/
if (paramset==0 || runMode=="forgedStatic"){
	$id = replaceStr(QUERY_STRING, fileSuffix, "");
}else{
	$id = getForm(paramid,"both");
}

if (empty($id)) {
	echoSaveStr("null");exit();
} else {
	if(!is_numeric($id)) { echoSaveStr("safe");exit(); } else { $id=intval($id); }
}
echoContent($id);

function echoContent($vId) {
	global $t1;
	$row = DB::fetch_first("SELECT m_id,m_type,m_name,m_state,m_pic,m_hit,m_actor,m_des,m_topic,m_color,m_addtime,m_publishyear,m_publisharea,m_commend,m_note,m_keyword ,m_digg,m_tread,m_playdata,m_downdata,m_enname,m_datetime,m_director,m_lang,m_score FROM ".DB::table('data')." WHERE m_recycle=0 AND m_id='$vId'");
	if (!is_array($row)) { OutNotFound("content");}
	$vType = $row['m_type'];$venname = $row['m_enname'];$vdatetime = $row['m_datetime'];
	$y = explode(",",getTypeNameTemplateArrayOnCache($vType));
	$z = ifthen(empty($y[4]),"content.html",$y[4]);$x = DJCMS_TEMPLATE.$z;
	if (strpos(" ,".getHideTypeIDS().",",",".$vType.",") > 0) { OutNotFound("content");}
	$contentLink = getContentLink($vType,$vId,$venname,$vdatetime,"link");
	$typeText = getTypeTextOnCache($vType);
	djcms::$currentTypeId = $vType;
	$typeFlag = "parse_content_" ;
	$cacheName = $typeFlag.$vType;
	if (cacheStart == 1) {
		if (!djcms::$content = memory('get', $cacheName)) {
            parseContentPart($x);memory('set', $cacheName, djcms::$content);
        }
	} else {
		parseContentPart($x);
	}
	djcms::paresPreNextVideo($vId, "content", $vType);
	djcms::parseVideo($row);
	$content = replaceStr(djcms::$content,"{playpage:id}",$row['m_id']);
	$content = replaceStr($content,"{playpage:desktopurl}","/".sitePath."desktop.php?name={playpage:encodename}&url=".urlencode($contentLink));
	$content = replaceStr($content,"{playpage:encodename}",urlencode($row['m_name']));
	$content = replaceStr($content,"{playpage:lang}",$row['m_lang']);
	$content = replaceStr($content,"{playpage:nolinkkeywords}",$row['m_keyword']);
	if (isExistStr($content,"{playpage:keywords}")) $content = replaceStr($content,"{playpage:keywords}",getKeywordsList($row['m_keyword'],"&nbsp;&nbsp;"));
	if (!empty($row['m_pic'])) {
		if (strpos($row['m_pic'], '://') > 0) {
		    $content = replaceStr($content,"{playpage:pic}",$row['m_pic']);
		} else {
		    $content = replaceStr($content,"{playpage:pic}","/".sitePath.$row['m_pic']);
		}
	} else {
		$content = replaceStr($content,"{playpage:pic}","/".sitePath."pic/nopic.gif");
	}
	$content = replaceStr($content,"{playpage:director}",getKeywordsList($row['m_director'],"&nbsp;&nbsp;"));
	$content = replaceStr($content,"{playpage:publishtime}",$row['m_publishyear']);
	$content = replaceStr($content,"{playpage:publisharea}",$row['m_publisharea']);
	$content = replaceStr($content,"{playpage:state}",$row['m_state']);
	$content = replaceStr($content,"{playpage:diggnum}",$row['m_digg']);
	$content = replaceStr($content,"{playpage:treadnum}",$row['m_tread']);
	$content = replaceStr($content,"{playpage:scorenum}",$row['m_score']);
	$content = replaceStr($content,"{playpage:commend}",$row['m_commend']);
	$content = replaceStr($content,"{playpage:link}",$contentLink);
	$content = replaceStr($content,"{playpage:url}","http://".siteUrl.$contentLink);
	djcms::$content = replaceStr($content,"{playpage:textlink}",$typeText."&nbsp;&nbsp;&raquo;&nbsp;&nbsp;".$row['m_name']);
	djcms::parsePlayList($vType,$vId,$venname,$vdatetime,$row['m_playdata'],"play");
	djcms::parsePlayList($vType,$vId,$venname,$vdatetime,$row['m_downdata'],"down");
	djcms::parseIf();
	echo replaceStr(djcms::$content,"{djcms:runinfo}",getRunTime($t1)) ;
}

function parseContentPart($x) {
	djcms::$content=loadFile($x);
	djcms::parsePlayPageSpecial();
	djcms::parseTopAndFoot();
	djcms::parseSelf();
	djcms::parseGlobal();
	$typename = explode(",", getTypeNameTemplateArrayOnCache(intval(djcms::$currentTypeId)));
	djcms::$content = replaceStr(replaceStr(djcms::$content,"{djcms:currenttypeid}",djcms::$currentTypeId),"{playpage:typeid}",djcms::$currentTypeId);
	if (isExistStr(djcms::$content,"{playpage:typename}")) djcms::$content = replaceStr(djcms::$content,"{playpage:typename}",$typename[0]);
    if (isExistStr(djcms::$content,"{playpage:typelink}")) djcms::$content = replaceStr(djcms::$content,"{playpage:typelink}",getTypeLink(djcms::$currentTypeId));
	if (isExistStr(djcms::$content,"{playpage:upid}")) djcms::$content = replaceStr(djcms::$content,"{playpage:upid}",getTypeUpid(djcms::$currentTypeId));
	djcms::parseMenuList("");
	djcms::parseNewsList();
	djcms::parseAreaList();
	djcms::parseVideoList();
	djcms::parseTopicList();
}
?>
