<?
//參數設定
$changelog = "utf8.log";
$dir_do = "source";
$dir_utf8 = "/var/www/html/target/";
//讀取上次轉換時間
$fp1 = fopen($changelog,"r+");
$modtime = fread($fp1,filesize($changelog));
fclose($fp1);
//轉檔函數
function phpfileedit($file){
global $dir_gb,$dir_utf8,$dir_utf81;
echo "source:$file<br>\n";
$fp = fopen("$file","r");
$old = fread($fp,filesize($file));
$old = str_replace('big5','UTF-8',$old);
$new1 = iconv("BIG5","UTF-8", $old);
fclose($fp);
//if($old<>$new1){
//寫入 UTF8
echo "utf8:$dir_utf8$file<br>\n";
$fp1 = fopen("$dir_utf8$file","w+");
fwrite($fp1,$new1);
fclose($fp1);
//}
}
//讀檔函數
function ListDir($dir){
global $modtime;
echo "<UL>\n";
$handle = opendir($dir);
while ($sdir=readdir($handle)){
if(is_dir("$dir/$sdir") and $sdir<> "." and $sdir<ListDir>$modtime){
echo "$sdir";
echo filemtime("$dir/$sdir");
echo "<br>\n";
if(substr($sdir,-3,3)=="php" or substr($sdir,-4,4)=="php3"){
phpfileedit("$dir/$sdir");
}
if(substr($sdir,-3,3)=="htm" or substr($sdir,-4,4)=="html"){
phpfileedit("$dir/$sdir");
}
if(substr($sdir,-3,3)=="ccs"){
phpfileedit("$dir/$sdir");
}
}
}
}
closedir($handle);
echo "</UL>";
}
//處理目錄
ListDir($dir_do);
//寫入完成時間
$fp1 = fopen($changelog,"w+");
fwrite($fp1,time());
fclose($fp1);
?>
用php做Big5轉Utf8 的檔案
前往
- Software
- ↳ CodeCharge Studio
- ↳ CodeCharge
- ↳ DemoCharge
- ↳ SuperPDF
- ↳ 551einv
- ↳ E3進銷存
- 程式語言
- ↳ PHP
- ↳ CodeLobster PHP Edition
- ↳ Yii
- ↳ CodeIgniter
- ↳ Phalcon
- ↳ Symfony
- ↳ FuelPHP
- ↳ Zend Framework 2
- ↳ laravel
- ↳ WordPress
- ↳ ASP.NET/C#
- ↳ ASP/VBScript
- ↳ JSP
- ↳ Java Servlets
- ↳ ColdFusion
- ↳ Perl
- ↳ Java Script
- ↳ jQuery
- ↳ HTML + CSS
- ↳ jQuery
- ↳ nodejs
- ↳ VB6
- ↳ Git
- ↳ App Inventor 2
- ↳ bash
- ↳ C++/ VC/ OpenCV
- ↳ OpenCV
- ↳ go
- ↳ cordova
- ↳ python
- ↳ Xamarin
- ↳ Assembly
- 資料庫
- ↳ MySQL
- ↳ PostgreSQL
- ↳ ORACLE
- ↳ Access
- ↳ SQL Server
- ↳ SQLite
- ↳ MariaDB
- ↳ Mongodb
- 作業系統
- ↳ Linux
- ↳ Ubuntu
- ↳ CentOS
- ↳ Mint
- ↳ Mandriva
- ↳ Debian
- ↳ Red Hat Enterprise Linux
- ↳ Oracle Linux
- ↳ Fedora
- ↳ Kali Linux
- ↳ OpenSUSE
- ↳ Elementary OS
- ↳ Microsoft
- ↳ Server 2008 R2
- ↳ Server 2012 R2
- ↳ Server 2012
- ↳ 8
- ↳ 10
- ↳ System Center 2016
- ↳ NOVELL
- ↳ FreeBSD
- ↳ VMware
- ↳ VirtualBox
- ↳ Mac OS X
- ↳ Solaris
- ↳ iOS
- ↳ Android
- ↳ Cloud
- ↳ OpenStack
- ↳ Docker
- ↳ Proxmox VE
- ↳ CloudReady
- ↳ chrome
- 網頁伺服器
- ↳ apache
- ↳ tomcat
- ↳ nginx
- ↳ IIS
- ↳ JBoss
- ↳ weblogic
- ↳ WebHosting
- 硬體
- ↳ 硬體及週邊
- ↳ RouterOS
- ↳ LEGO NXT
- ↳ Arduino
- ↳ MSP430
- ↳ Raspberry Pi
- ↳ OpenERP
- ↳ Storage
- ↳ Server
- ↳ Brocade
- ↳ MODELS
- ↳ FortiGate
- 軟體
- ↳ sublime
- ↳ LibreNMS