線上書籍

Home

[1012]PHP進階開發及TadTools工具應用

一、 select選單切換
  1. 先製作選項 $sql = "select `sn`,`name` from `".$xoopsDB->prefix("contact")."` "; $result = $xoopsDB->query($sql); $option=""; while(list($sn,$name)=$xoopsDB->fetchRow($result)){ $selected=($sn==$_GET['sn'])?"selected":""; $option.="<option value='$sn' $selected>$name</option>"; }

     

  2. 然後加入切換選單 <select onChange=\"location.href='data.php?op={$_GET['op']}&sn='+this.value\">$option </select>

     

二、 JAVA上傳(http://jupload.sourceforge.net/
  1. 新增jupload.php頁面,獨立一個頁面比較不會出問題。 <?php include_once "header.php"; include_once XOOPS_ROOT_PATH."/modules/tadtools/jupload/jupload.php"; if(!$xoopsUser) die('無上傳權限'); if($_GET['op']=='import'){ if ($dh = opendir(XOOPS_ROOT_PATH."/uploads/contact/video")) { while (($file = readdir($dh)) !== false) { if(strlen($file)<=2)continue; $f=explode(".",$file); $ext=strtolower($f[1]); rename(XOOPS_ROOT_PATH."/uploads/contact/video/{$file}",XOOPS_ROOT_PATH."/uploads/contact/{$_GET['sn']}.{$ext}"); die("請點擊「影片」以觀看之"); } } }else{ $appletParameters = array( 'maxFileSize' => '2G', 'postURL' => XOOPS_URL.'/modules/contact/jupload.php', 'archive' => XOOPS_URL.'/modules/tadtools/jupload/wjhk.jupload.jar', 'afterUploadURL' => XOOPS_URL."/modules/contact/index.php?sn={$_GET['sn']}&op=import", 'allowedFileExtensions' => 'flv/mp4', 'sendMD5Sum' => 'true', 'showLogWindow' => 'false', 'debugLevel' => 99 ); $classParameters = array( 'demo_mode' => false, 'allow_subdirs' => true, 'destdir' => XOOPS_ROOT_PATH."/uploads/contact/video" ); $juploadPhpSupportClass = new JUpload($appletParameters, $classParameters); echo "<!--JUPLOAD_APPLET-->"; } ?>

     

三、 影片播放(http://www.longtailvideo.com/jw-player/about/
  1. 新增play.php頁面,檔名部份一律規範為「編號.mp4」格式(比較簡易)。 <?php include_once "header.php"; include_once XOOPS_ROOT_PATH."/modules/tadtools/jwplayer.php"; $jw=new JwPlayer("play" , XOOPS_URL."/uploads/contact/{$_GET['sn']}.mp4" , $image  , $width , $height , $skin , $mode , $display , $backcolor , $frontcolor , $lightcolor , $screencolor); $player=$jw->render(); echo $player; ?>

     

四、 影片下載(https://addons.mozilla.org/zh-tw/firefox/addon/video-downloadhelper/
  1. 請安裝firefox,接著安裝附加元件「DownloadHelper」即可下載各式影片檔。