未指定檔案路徑及名稱!"); } elseif ( ! file_exists( $file ) ) { die("找不到檔案 [$file]!"); }; // 讀取記錄檔 $stat = array(); $oFileSize = filesize($oFile); if ( ($fp = fopen($oFile, "r")) ) { flock($fp, LOCK_EX); // do an exclusive lock $toread = fread($fp, $oFileSize); flock($fp, LOCK_UN); // release the lock fclose($fp); $stat = unserialize($toread); } else { die("無法開啟記錄檔 $oFile"); } // 該記錄 +1 if ( $stat[$name] > 0 ) { $stat[$name] += 1 ; // 寫入記錄檔 $towrite = serialize($stat); if ( $fp = fopen($oFile, 'w') ) { flock($fp, LOCK_EX); // do an exclusive lock fwrite($fp, $towrite); flock($fp, LOCK_UN); // release the lock fclose($fp); } else { die("無法寫入記錄檔 $oFile"); } } // 導到目的網頁 $url = $web_url . $file ; #echo $url; header("Location: $url"); ?>