<?php
//  ------------------------------------------------------------------------ //
// 本模組由 tad 製作
// 製作日期：2008-02-28
// $Id: play_code.php,v 1.1 2008/05/14 01:23:26 tad Exp $
// ------------------------------------------------------------------------- //

/*-----------引入檔案區--------------*/
include "header.php";
/*-----------function區--------------*/

play($_GET['psn']);

function play($get_psn=""){
	global $xoopsDB,$xoopsModuleConfig;

  $file=get_tad_player($get_psn);
  
  $ok_cat=chk_cate_power();
  
  if(!empty($file['pcsn']) and !in_array($file['pcsn'],$ok_cat)){
		die("document.write(\"---\");");
	}


	add_counter($get_psn);


  $width=(empty($file['width']))?$xoopsModuleConfig['width']:$file['width'];
	$height=(empty($file['height']))?$xoopsModuleConfig['height']:$file['height'];

	$type=strtolower(substr($file['location'],-3));
  if($type=="mp3" and empty($file['image'])){
    $height=20;
	}


	$all_width=$width;
	$all_height=$height;
  $media=_TAD_PLAYER_FLV_URL."{$get_psn}_{$file['location']}";

  $dl=($xoopsModuleConfig['download']=='1')?"document.write(\"s1.addVariable('showdownload','true');\");
	document.write(\"s1.addVariable('link','{$media}');\");":"";

  if(substr($file['image'],0,4)=="http"){
    $image=$file['image'];
	}else{
    $image=_TAD_PLAYER_IMG_URL.$file['image'];
	}

  $pic=(empty($file['image']))?"":"document.write(\"s1.addVariable('image','{$image}');\");";
  $width_js="document.write(\"s1.addVariable('width','{$width}');\");";
  $height_js="document.write(\"s1.addVariable('height','{$height}');\");";
  $play_list="";

  $backcolor=str_replace("#","0x",$xoopsModuleConfig['backcolor']);
  $frontcolor=str_replace("#","0x",$xoopsModuleConfig['frontcolor']);
  $lightcolor=str_replace("#","0x",$xoopsModuleConfig['lightcolor']);
  $screencolor=str_replace("#","0x",$xoopsModuleConfig['screencolor']);


	$js_code="document.write(\"<link rel='stylesheet' type='text/css' media='screen' href='".XOOPS_URL."/modules/tad_plyer/player.css' />\");";
	
	if($xoopsModuleConfig['show_border']=='1'){
	
		$js_code.="
		document.write(\"<table style='width:auto;'><tr><td>\");
		document.write(\"<div class='player_3d'>\");
		document.write(\"<b class='b1'></b><b class='b2' style='background-color:{$xoopsModuleConfig['border_color']}'></b><b class='b3' style='background-color:{$xoopsModuleConfig['border_color']}'></b><b class='b4' style='background-color:{$xoopsModuleConfig['border_color']}'></b>\");
		document.write(\"<div class='boxcontent' style='background-color:{$xoopsModuleConfig['border_color']}'>\");
		";
	}
	
	$js_code.="
	document.write(\"
  <script type='text/javascript' src='".XOOPS_URL."/modules/tad_player/class/jquery.js'></script>
	<script type='text/javascript' src='".XOOPS_URL."/modules/tad_player/class/jw_player/swfobject.js'></script>\");
	document.write(\"<div id='tad_player_container_{$get_psn}'>"._MA_TADPLAYER_REPLACED_BY_THE_SWF."。</div>\");
	document.write(\"<script type='text/javascript'>\");
	document.write(\"var s1 = new SWFObject('".XOOPS_URL."/uploads/tad_player/mediaplayer.swf','mediaplayer','{$width}','{$height}','6');\");
	document.write(\"s1.addParam('allowfullscreen','true');\");
	{$width_js}
	{$height_js}
	document.write(\"s1.addVariable('file','{$media}');\");
	$pic
	document.write(\"s1.addVariable('backcolor','{$backcolor}');\");
	document.write(\"s1.addVariable('frontcolor','{$frontcolor}');\");
	document.write(\"s1.addVariable('lightcolor','{$lightcolor}');\");
	document.write(\"s1.addVariable('screencolor','{$screencolor}');\");
	document.write(\"s1.addVariable('autostart','false');\");
	document.write(\"s1.addVariable('usefullscreen','true');\");
	$dl
	document.write(\"s1.write('tad_player_container_{$get_psn}');\");
	document.write(\"</script>\");
	document.write(\"</div>\");
	";
	
	if($xoopsModuleConfig['show_border']=='1'){
		$js_code.="
		document.write(\"<b class='b4b' style='background-color:{$xoopsModuleConfig['border_color']}'></b><b class='b3b' style='background-color:{$xoopsModuleConfig['border_color']}'></b><b class='b2b' style='background-color:{$xoopsModuleConfig['border_color']}'></b><b class='b1b'></b>\");
		document.write(\"</div>\");
		document.write(\"</td></tr></table>\");
		";
	}
	
	
	echo $js_code;

}
?>


