標籤

BAT (38) shell (34) Virtual Machine (33) Xubuntu (29) acfs (25) PHP (24) CentOS (21) Virtul Box (20) 編輯器 (17) 資料庫 (15) lubuntu (13) windows (13) CPP (12) ubuntu (12) chrome (11) laravel (10) Docker (9) Python (9) 5A88 (7) VMware (6) 資料結構 (6) Javascript (5) Node (5) Proxmox VE (5) 公告系統 (5) 程式積木 (5) Android Studio (4) ANN (3) OB2D2016x64 (3) Xoops (3) clonezilla (3) samba (3) 公文 (3) 其他 (3) 硬體 (3) API (2) Android (2) AppInvent2 (2) Html (2) Hyper-V (2) Nas (2) botnet (2) mbot (2) swift (2) wordpress (2) 樣板 (2) 防火牆 (2) AD的應用 (1) Ansible (1) Arduino (1) CSS (1) GitLab (1) HA Proxy (1) LegoEV3 (1) PowerShell (1) Scratch (1) VM (1) XenServer (1) kotlin (1) linuxmint (1) lxc (1)

2019年9月30日 星期一

讓網頁自動判斷並導向一般網頁還是手機版網頁

老實說,在自適應網頁的時代裡,竟然還要做這項工具?!
在過去的時代裡,常常用PhotoShop裁切圖片並轉成網頁。
美工人員只要專心畫圖(分成一般版與手機版),並將圖片交由網頁人員。
網頁人員利用PhotoShop裁切圖片並轉成網頁即可做出美美的網頁(分成一般版與手機版)

注意事項:
裁切成網頁時,會出現小小的細邊。該如何處理?
設定底圖顏色跟出現細邊的圖片顏色一致,就看不出來了。資料來源3的色碼轉換器

那我們要如何讓程式判斷該往一般版還是手機版
假定
伺服器IP:192.168.199.54
一般版網頁檔名 general.html
手機版網頁檔名 mobile.html
程式碼:
<html>
<head>
<title>AuotOrientate</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function AuotOrientate(){
         if (screen.width >= screen.height ) {
        document.location.href="http://192.168.199.54/general.html";
     } else {
document.location.href="http://192.168.199.54/mobile.html";
}   
}
</script>
</head>
<body onload="AuotOrientate()">
</body>
</html>

或是

<html>
<head>
<title>Changhua</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
window.onload=function AuotOrientate(){
         if (screen.width >= screen.height ) {
        document.location.href="http://192.168.199.54/general.html";
     } else {
document.location.href="http://192.168.199.54/mobile.html"; 
     }    
}
</script>
</head>
<body>
</body>
</html>

資料來源:
1.網頁自動轉址/重新導向/URL重定向方法(HTML/Javascript/PHP的轉址)
2.js判斷螢幕解析度的程式碼
3.色碼轉換器
4.如何利用PHP語法來偵測是不是使用手機瀏覽網頁,新增手機用戶的客製選單
5.js判斷滑鼠是否停止移動Script
6.PHP Mobile Device Detection,簡單地用 PHP 判斷訪客的上網裝置

2019年9月25日 星期三

在Windows 7,用 BAT 一鍵安裝彰縣公文系統

下一篇  在 Windows10,使用BAT快速安裝彰化縣公文系統

20200815
        有伙伴在20200813研習時提出,希望在windows 7,使用用 BAT 一鍵安裝縣公文系統。
因此,重新修改程式碼,去符合學校的需求。
        然而,問題卻出在Windows 7的IE 預設為IE8,需升級到IE11。重開機後,才能繼續地處理接下來的安裝。因此,需再寫一個BAT專門處理IE8升級到IE11與相關套件。整個安裝包的容量會高到170多M。
以下為完整升級整合包

20200815程式下載,解壓密碼demo1234

快速處理IE8升級到IE11與相關套件程式碼:在下列網址

一鍵安裝彰縣公文系統的程式碼:
檔名:02公文系統與相關程式安裝.BAT
內容為
@echo off
REM ----------------以下為設定檔-可修改-----------------
REM -以下為讀卡機驅動程式,修改的是%~dp0AutoInstall\後---
set driver01_86=%~dp0AutoInstall\EZ100_Driver_32bit.exe
set driver01_64=%~dp0AutoInstall\EZ100_Driver_64bit.exe
REM ---以下為筆硯公文系統,修改的是%~dp0AutoInstall\後---
set driver02=%~dp0AutoInstall\docNinstall.msi
set driver03=%~dp0AutoInstall\docNcomp42@0_13a42.msi
REM ----以下為內政部HiCOS卡片管理工具ver3.0.3.62814----
set driver04=%~dp0AutoInstall\HiCOS_Client.exe
REM ----------------以下為IE啟動網頁-------------------
set homepage01=http://gdms.chcg.gov.tw/
set homepage02=https://edit.chcg.gov.tw/kw/\0
set homepage03=http://172.20.3.50/httpweb/admin/public/login.asp\0
REM ----------------以下為程式碼-不可修改----------------

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win10有32跟64位元的判斷

:x86
echo "作業系統是x86"
echo 安裝MOICA內政部憑證管理程式所在路徑為 %driver04%
"%driver04%" /quiet /norestart
echo "安裝MOICA內政部憑證管理程式 OK"
set IEpath=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
echo 設置首頁索引標籤
@reg add "%IEpath%" /v "Start Page" /t REG_SZ /d "%homepage01%" /f
@reg add "%IEpath%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "%homepage02%%homepage03%" /f
echo 設置首頁索引標籤 OK
echo "設定安全區域ActiveX控制項...."
set bl=2
set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
echo 正在進行ActiveX的配置,請稍候...
@reg add "%regpath%" /v "1001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1206" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1207" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1208" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1209" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120B" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "120C" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1402" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1405" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1406" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1407" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1408" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1409" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "140A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "140C" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1601" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1604" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1605" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1606" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1607" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1608" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1609" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "160A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "160B" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1802" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1803" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1804" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1806" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1809" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1812" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A00" /d "131072" /t REG_DWORD /f
@reg add "%regpath%" /v "1A02" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A03" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A04" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1A05" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1A06" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A10" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1C00" /d "65536" /t REG_DWORD /f
@reg add "%regpath%" /v "2000" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2005" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2007" /d "65536" /t REG_DWORD /f
@reg add "%regpath%" /v "2100" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2101" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2102" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2103" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2104" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2105" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2106" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2107" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2108" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2200" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2300" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "2301" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2302" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2400" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2401" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2402" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2500" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2600" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2700" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2701" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2702" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2703" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2704" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2707" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2708" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2709" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "270B" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "270C" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "270D" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "CurrentLevel" /d "0" /t REG_DWORD /f
@reg add "HKCU\Software\Microsoft\Internet Explorer\New Windows" /v "PopupMgr" /t REG_DWORD /d "0" /f
@reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "SyncMode5" /t REG_DWORD /d "3" /f
echo "設定安全區域ActiveX控制項OK!!"
@echo 設定信任網站清單
regedit.exe /s "%~dp0AutoInstall\信任網站清單.reg"
@echo -------------------------------------------------------------------------------
@echo 設定完成
@echo 複製捷徑到桌面
@echo -------------------------------------------------------------------------------
copy "%~dp0AutoInstall\公文整合資訊系統.url" "%USERPROFILE%\desktop"
@echo 捷徑複製完成
echo 安裝讀卡機驅動程式所在路徑為 %driver01_86%
start /wait %driver01_86% /S /v/qn
echo "安裝讀卡機驅動程式 OK"
echo 安裝筆硯安裝程式所在路徑為 %driver02%
msiexec /package %driver02% /quiet /norestart
echo 安裝筆硯安裝程式所在路徑為 %driver03%
msiexec /package %driver03% /quiet /norestart
echo "安裝筆硯安裝程式 OK"
echo "請重新開機,完成所有設定"
pause
shutdown /r /f /t 0
exit

:x64
echo "作業系統是x64"
echo 安裝MOICA內政部憑證管理程式所在路徑為 %driver04%
"%driver04%" /quiet /norestart
echo "安裝MOICA內政部憑證管理程式 OK"
set IEpath=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
echo 設置首頁索引標籤
@reg add "%IEpath%" /v "Start Page" /t REG_SZ /d "%homepage01%" /f
@reg add "%IEpath%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "%homepage02%%homepage03%" /f
echo 設置首頁索引標籤 OK
echo "設定安全區域ActiveX控制項...."
set bl=2
set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
echo 正在進行ActiveX的配置,請稍候...
@reg add "%regpath%" /v "1001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1206" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1207" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1208" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1209" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120B" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "120C" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1402" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1405" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1406" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1407" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1408" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1409" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "140A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "140C" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1601" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1604" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1605" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1606" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1607" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1608" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1609" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "160A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "160B" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1802" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1803" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1804" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1806" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1809" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1812" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A00" /d "131072" /t REG_DWORD /f
@reg add "%regpath%" /v "1A02" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A03" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A04" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1A05" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1A06" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1A10" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "1C00" /d "65536" /t REG_DWORD /f
@reg add "%regpath%" /v "2000" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2005" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2007" /d "65536" /t REG_DWORD /f
@reg add "%regpath%" /v "2100" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2101" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2102" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2103" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2104" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2105" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2106" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2107" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2108" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2200" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2300" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "2301" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2302" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2400" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2401" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2402" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2500" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2600" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2700" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2701" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2702" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2703" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2704" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2707" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "2708" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "2709" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "270B" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "270C" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "270D" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "CurrentLevel" /d "0" /t REG_DWORD /f
@reg add "HKCU\Software\Microsoft\Internet Explorer\New Windows" /v "PopupMgr" /t REG_DWORD /d "0" /f
@reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "SyncMode5" /t REG_DWORD /d "3" /f
echo "設定安全區域ActiveX控制項OK!!"
@echo 設定信任網站清單
regedit.exe /s "%~dp0AutoInstall\信任網站清單.reg"
@echo -------------------------------------------------------------------------------
@echo 設定完成
@echo 複製捷徑到桌面
@echo -------------------------------------------------------------------------------
copy "%~dp0AutoInstall\公文整合資訊系統.url" "%USERPROFILE%\desktop"
@echo 捷徑複製完成
echo 安裝讀卡機驅動程式所在路徑為 %driver01_64%
start /wait %driver01_64% /S /v/qn
echo "安裝讀卡機驅動程式 OK"
echo 安裝筆硯安裝程式所在路徑為 %driver02%
msiexec /package %driver02% /quiet /norestart
echo 安裝筆硯安裝程式所在路徑為 %driver03%
msiexec /package %driver03% /quiet /norestart
echo "安裝筆硯安裝程式 OK"
echo "請重新開機,完成所有設定"
pause
shutdown /r /f /t 0
exit






20190925
自從用了一鍵安裝印表機後。覺得批次檔很有趣,接下來想要試試一鍵安裝軟體,特別是學校的公文軟體。想要一鍵就完成,試試看有沒有辦法!!
找了很多資料,發現有點麻煩。
現在先將目前測試OK的,先寫下來。
檔名為 09公文系統與相關程式安裝.BAT,其內容如下:

@echo off

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win7有32跟64位元的判斷

:x86
echo "x86"
REM 設置IE首頁索引標籤
set IEpath=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
echo 設置首頁索引標籤
@reg add "%IEpath%" /v "Start Page" /t REG_SZ /d "http://gdms.chcg.gov.tw/" /f
@reg add "%IEpath%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "https://edit.chcg.gov.tw/kw/\0http://172.20.3.50/httpweb/admin/public/login.asp\0" /f
echo 設置首頁索引標籤 OK
set driver01=%~dp0AutoInstall\EZ100_Driver_32bit\setup.exe
set driver02=%~dp0AutoInstall\docNinstall.msi
set driver03=%~dp0AutoInstall\HiCOS_Client.exe
echo 安裝讀卡機驅動程式所在路徑為 %driver01%
start /wait %driver01% /S /v/qn
echo "安裝讀卡機驅動程式 OK"
echo 安裝筆硯安裝程式所在路徑為 %driver02%
msiexec /package %driver02% /quiet
echo "安裝筆硯安裝程式 OK"
echo 安裝MOICA內政部憑證管理程式所在路徑為 %driver03%
start /wait %driver03% /S /v/qn
echo "安裝MOICA內政部憑證管理程式 OK"
pause
exit

:x64
echo "x64"
REM 設置IE首頁索引標籤
set IEpath=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
echo 設置首頁索引標籤
@reg add "%IEpath%" /v "Start Page" /t REG_SZ /d "http://gdms.chcg.gov.tw/" /f
@reg add "%IEpath%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "https://edit.chcg.gov.tw/kw/\0http://172.20.3.50/httpweb/admin/public/login.asp\0" /f
echo 設置首頁索引標籤 OK
set driver01=%~dp0AutoInstall\EZ100_Driver_64bit\setup.exe
set driver02=%~dp0AutoInstall\docNinstall.msi
set driver03=%~dp0AutoInstall\HiCOS_Client.exe
echo 安裝讀卡機驅動程式所在路徑為 %driver01%
start /wait %driver01% /S /v/qn
echo "安裝讀卡機驅動程式 OK"
echo 安裝筆硯安裝程式所在路徑為 %driver02%
msiexec /package %driver02% /quiet
echo "安裝筆硯安裝程式 OK"
echo 安裝MOICA內政部憑證管理程式所在路徑為 %driver03%
start /wait %driver03% /S /v/qn
echo "安裝MOICA內政部憑證管理程式 OK"
pause
exit

設定IE,需動到 windows 的register ,先觀察一下register
以 windows 7 32位元為例,開始-> 在搜尋與程式內打上 regedit,如下圖所示
然後依
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2\ 找到,我們將完成前後,登陸檔比較圖列出
在上圖中,需要變更的是
1001  -> 0
1004  -> 0
1201  -> 0
1209  -> 0
120A -> 0
120B -> 3
1806 -> 1
2201 -> 0
所以設定檔的變更為
set bl=2
set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
echo 正在進行ActiveX的配置,請稍候...
@reg add "%regpath%" /v "1001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1209" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120B" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1806" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "2201" /d "0" /t REG_DWORD /f
set setpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range100
echo 將*.chcg.gov.tw加入信任站點
@set search=*.chcg.gov.tw
@reg add "%setpath%" /f
@reg add "%setpath%" /v http /t REG_DWORD /d 0x00000002 /f
@reg add "%setpath%" /v :Range /t REG_SZ /d %search%
@reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Flash" /v DebugDomain /t REG_SZ /d %search%
echo 將*.chcg.gov.tw加入信任站點OK

所以,整個程式為
@echo off

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win7有32跟64位元的判斷

:x86
echo "x86"
REM 設置IE首頁索引標籤
set IEpath=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
echo 設置首頁索引標籤
@reg add "%IEpath%" /v "Start Page" /t REG_SZ /d "http://gdms.chcg.gov.tw/" /f
@reg add "%IEpath%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "https://edit.chcg.gov.tw/kw/\0http://172.20.3.50/httpweb/admin/public/login.asp\0" /f
echo 設置首頁索引標籤 OK
echo "設定安全區域ActiveX控制項...."
set bl=2
set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
echo 正在進行ActiveX的配置,請稍候...
@reg add "%regpath%" /v "1001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1209" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120B" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1806" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "2201" /d "0" /t REG_DWORD /f
echo "設定安全區域ActiveX控制項OK!!"
set setpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range100
echo 將*.chcg.gov.tw加入信任站點
@set search=*.chcg.gov.tw
@reg add "%setpath%" /f
@reg add "%setpath%" /v http /t REG_DWORD /d 0x00000002 /f
@reg add "%setpath%" /v :Range /t REG_SZ /d %search%
@reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Flash" /v DebugDomain /t REG_SZ /d %search%
echo 將*.chcg.gov.tw加入信任站點OK
set driver01=%~dp0AutoInstall\EZ100_Driver_32bit.exe
set driver02=%~dp0AutoInstall\docNinstall.msi
set driver03=%~dp0AutoInstall\HiCOS_Client.exe
echo 安裝讀卡機驅動程式所在路徑為 %driver01%
start /wait %driver01% /S /v/qn
echo "安裝讀卡機驅動程式 OK"
echo 安裝筆硯安裝程式所在路徑為 %driver02%
msiexec /package %driver02% /quiet
echo "安裝筆硯安裝程式 OK"
echo 安裝MOICA內政部憑證管理程式所在路徑為 %driver03%
start /wait %driver03% /S /v/qn
echo "安裝MOICA內政部憑證管理程式 OK"
pause
exit

:x64
echo "x64"
REM 設置IE首頁索引標籤
set IEpath=HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
echo 設置首頁索引標籤
@reg add "%IEpath%" /v "Start Page" /t REG_SZ /d "http://gdms.chcg.gov.tw/" /f
@reg add "%IEpath%" /v "Secondary Start Pages" /t REG_MULTI_SZ /d "https://edit.chcg.gov.tw/kw/\0http://172.20.3.50/httpweb/admin/public/login.asp\0" /f
echo 設置首頁索引標籤 OK
echo "設定安全區域ActiveX控制項...."
set bl=2
set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
echo 正在進行ActiveX的配置,請稍候...
@reg add "%regpath%" /v "1001" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1004" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "1209" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120A" /d "0" /t REG_DWORD /f
@reg add "%regpath%" /v "120B" /d "3" /t REG_DWORD /f
@reg add "%regpath%" /v "1806" /d "1" /t REG_DWORD /f
@reg add "%regpath%" /v "2201" /d "0" /t REG_DWORD /f
echo "設定安全區域ActiveX控制項OK!!"
set setpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range100
REM @echo 請輸入需加入信任站點的IP地址:
REM @set/p IP地址= >nul
REM @set IP地址|findstr "\\<%search%\\>" >nul
REM @set search=%IP地址% >nul
echo 將*.chcg.gov.tw加入信任站點
@set search=*.chcg.gov.tw
@reg add "%setpath%" /f
@reg add "%setpath%" /v http /t REG_DWORD /d 0x00000002 /f
@reg add "%setpath%" /v :Range /t REG_SZ /d %search%
@reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Flash" /v DebugDomain /t REG_SZ /d %search%
echo 將*.chcg.gov.tw加入信任站點OK
set driver01=%~dp0AutoInstall\EZ100_Driver_64bit.exe
set driver02=%~dp0AutoInstall\docNinstall.msi
set driver03=%~dp0AutoInstall\HiCOS_Client.exe
echo 安裝讀卡機驅動程式所在路徑為 %driver01%
start /wait %driver01% /S /v/qn
echo "安裝讀卡機驅動程式 OK"
echo 安裝筆硯安裝程式所在路徑為 %driver02%
REM start /wait %driver02% /S /v/qn
msiexec /package %driver02% /quiet
echo "安裝筆硯安裝程式 OK"
echo 安裝MOICA內政部憑證管理程式所在路徑為 %driver03%
start /wait %driver03% /S /v/qn
echo "安裝MOICA內政部憑證管理程式 OK"
pause
exit

程式
使用方法
1.下載程式
2.解壓縮公文系統自動安裝.rar
3.以系統管理員執行09公文系統與相關程式安裝.BAT
4.重開機後,請開啟IE,其設定如下:




後記:後來廠商也開發出一鍵安裝BAT,很開心!!!這樣又學到一招
20200324廠商版本

資料來源:
1.bat指令碼批量靜默安裝程式
2.BAT批處理全自動(靜默)安裝軟體的方法(包含4種常見安裝包格式)
3.用bat自動執行安裝軟體,不用手動按下一步
4.自動安裝軟體 批次檔問題 ! !
5.#MIS事件簿-bat檔自動安裝
6.常用軟體快速安裝批次檔
7.軟體自動安裝參數說明-2
8.應用程序的全自動安裝——GUIRunOnce參數詳解
9.(免費)AutoIt(自動化.MIS.安裝軟體)
10.cmd - 如何在bat文件中調用另一個bat文件
11.用批次檔 解除/移除軟體安裝
12.使用vbs或者bat指令碼修改IE瀏覽器安全級別和選項
13.EasyFlow .NET 系統IE 瀏覽器詳細設定值
14.進階使用者的 Internet Explorer 安全性區域登錄項目
15.重要:EasyFlow首次使用需知 --> IE 瀏覽器詳細設定值
16.政府組態基準GCB_Windows設定對照表_V1.3
17.Bat 設定IE首頁及設定信任網站
18.How to set multiple homepage for ie and chrome with batch file?
19.允許主動式內容透過受限制的通訊協定來存取我的電腦
20.即使簽章無效也允許執行或安裝軟體
21.如何在Windows 10中關閉和禁用UAC
22.新增、修改、刪除登錄值的批次語法

2019年9月14日 星期六

在 Xubuntu 18.04.3 用shell安裝 Django

1.xubuntu 套件更新
sudo apt-get update

2.安裝 python3-pip
sudo apt-get install -y python3-pip

3.安裝 python3-venv
sudo apt-get install -y python3-venv

4.建立目錄 mydjango,並進入目錄內
mkdir ~/mydjango
cd ~/mydjango

5.命名虛擬環境my_venv
python3 -m venv my_venv

6.啟動虛擬環境my_venv
source my_venv/bin/activate

7.用pip安裝django
pip install django

8.驗證
django-admin --version

9.停用虛擬環境my_venv
deactivate

10.產生第一個網站框架
sudo apt-get install -y tree
cd ~/mydjango
source my_venv/bin/activate
django-admin startproject mblog
cd mblog
python manage.py startapp mainsite
cd ..
tree mblog

cd mblog
python manage.py runserver 192.168.32.194:8000

此時網頁資訊會出現
要按下 Ctrl +C 離開
此時需要到~/mydjango/mblog/mblog 修改 settings.py
pico ~/mydjango/mblog/mblog/settings.py
將 ALLOWED_HOSTS = []
改成 ALLOWED_HOSTS = ['192.168.32.194','localhost','127.0.0.1']
改完之後儲存,下指令 
cd ..
python manage.py runserver 192.168.32.194:8000
此時網頁資訊會出現

接下來,我們將上述步驟做成shell,希望能夠一鍵完成,直接到第10步驟的網頁
但由於權限的關係,我們第一個shell,需要下sudo並產生第二個shell。第二個shell 用一般使用者即可執行。在此篇,我們設一般使用者帳號為 webadmin,其家目錄為 /home/webadmin/
#!/bin/sh
VAR="ens33"
HOST_IP=$(ifconfig $VAR | grep "inet " | awk '{ print $2}')
apt-get update
apt-get install -y python3-pip
apt-get install -y python3-venv
apt-get install -y tree
cd  /home/webadmin/
mkdir mydjango
cd mydjango
touch djangoinstall.sh
echo "#!/bin/sh" > djangoinstall.sh
echo "cd ~/mydjango" >> djangoinstall.sh
echo "python3 -m venv my_venv" >> djangoinstall.sh
echo "source my_venv/bin/activate" >> djangoinstall.sh
echo "pip install django" >> djangoinstall.sh
echo "django-admin startproject mblog" >> djangoinstall.sh
echo "cd ~/mydjango/mblog/" >> djangoinstall.sh
echo "python manage.py startapp mainsite" >> djangoinstall.sh
echo "cd ~/mydjango/" >> djangoinstall.sh
echo "tree mblog" >> djangoinstall.sh
echo "sed -i \"s/ALLOWED_HOSTS = \[/ALLOWED_HOSTS = \['$HOST_IP','localhost','127.0.0.1'/g\" /home/webadmin/mydjango/mblog/mblog/settings.py" >> djangoinstall.sh
echo "x-www-browser 'http://$HOST_IP:8000'" >> djangoinstall.sh
echo "cd ~/mydjango/mblog/" >> djangoinstall.sh
echo "python manage.py runserver $HOST_IP:8000" >> djangoinstall.sh
chown webadmin.webadmin /home/webadmin/mydjango -R
chmod 755 /home/webadmin/mydjango -R

接下來,我們就來看實際安裝情況,影片如下:

附註:
getip.sh 其內容為
#!/bin/sh
VAR="ens33"
HOST_IP=$(ifconfig $VAR | grep "inet " | awk '{ print $2}')
echo $HOST_IP

資料來源:
1.安裝 Django
2.Python新手使用Django架站技術實作:活用Django 2.0 Web Framework建構動態網站的16堂課
3.Python網頁篇:Django- 初始環境
4.Django起步走:環境安裝與建立專案
5.Invalid http_host header
6.SHELL - shell 腳本獲取本機ip並將ip複製給變量待用

2019年9月10日 星期二

在 xubuntu 16.04 實作 用 shell 為每個站點設定不同的php 版本

自從網頁主機集中,想要留舊網頁資料,提供查詢。
但又要建立新網頁,因應安全性需做更新。
以往的作法是在學校架新主機、新LAMP、xoops 新版本。
現在則是要在原有主機上,為每個站點設定不同php版本,以因應新的xoops版本。
看到網路資料,想實作看看。

1.安裝 apache2
sudo apt-get install -y apache2

2.安裝 mysql
sudo apt install -y mysql-server mysql-client libmysqlclient-dev mysql-workbench

3.安裝 php5.6
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php5.6-common php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-gd php5.6-curl php5.6-json php5.6-fpm php5.6-zip php5.6-mcrypt libapache2-mod-php5.6

4.安裝:php7.0
sudo apt-get install -y php7.0-common php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-gd php7.0-curl php7.0-json php7.0-fpm php7.0-zip php7.0-mcrypt libapache2-mod-php7.0

5.安裝:php7.1
sudo apt-get install -y php7.1-common php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-xml php7.1-gd php7.1-curl php7.1-json php7.1-fpm php7.1-zip php7.1-mcrypt libapache2-mod-php7.1

6.開啟重寫轉向
sudo a2enmod rewrite
sudo a2enmod headers

7.重啟 apache2
sudo service apache2 restart

8.編輯bashrc 加入自定義命令,方便在不同php版本間切換
sudo vi .bashrc

寫入.bashrc, 其內容為
alias php56='sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2enmod php5.6 && sudo service apache2 restart'
alias php70='sudo a2dismod php5.6 && sudo a2dismod php7.1 && sudo a2enmod php7.0 && sudo service apache2 restart'
alias php71='sudo a2dismod php5.6 && sudo a2dismod php7.0 && sudo a2enmod php7.1 && sudo service apache2 restart'

安裝完成後,重啟電腦,預設是執行5.6版本的php
但命令列下php-v 是顯示最高版本7.1
在/etc/php目錄下有對應版本號的資料夾,

編輯相應的php.ini可配置相應的php版本,
命令列下php56可切換到php5.6版本
命令列下php70可切換到php7.0版本
命令列下php71可切換到php7.1版本

9.備份/etc/apache2/site-available/000-default.conf後修改,其指令為
cd /etc/apache2/site-available/
sudo cp 000-default.conf 000-default.conf.bk
sudo pico 000-default.conf 
其內容如下:
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        <Directory "/var/www/html/php56">
         Options FollowSymLinks
         AllowOverride All
         #Require all denied
         Require all granted
         <FilesMatch \.php$>
            SetHandler "proxy:unix:/run/php/php5.6-fpm.sock|fcgi://localhost"
         </FilesMatch>
        </Directory>
        <Directory "/var/www/html/php70">
         Options FollowSymLinks
         AllowOverride All
         #Require all denied
         Require all granted
         <FilesMatch \.php$>
            SetHandler "proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost"
         </FilesMatch>
        </Directory>
        <Directory "/var/www/html/php71">
         Options FollowSymLinks
         AllowOverride All
         #Require all denied
         Require all granted
         <FilesMatch \.php$>
            SetHandler "proxy:unix:/run/php/php7.1-fpm.sock|fcgi://localhost"
         </FilesMatch>
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

啟用Apache2 模組 proxy proxy_fcgi 
sudo a2enmod proxy proxy_fcgi

重啟 Apache2
sudo service apache2 restart

10.在/var/www/html/,新增三個資料夾,分別為 php56 php70 php71
在這三個資料夾,新增index.php,其內容為 <?php  phpinfo(); ?>
變更 這三個資料夾及其內容 的權限。其指令如下:
cd /var/www/html/
sudo mkdir php56 php70 php71
sudo touch index.php
sudo echo "<?php  phpinfo(); ?>" > index.php
sudo cp index.php /var/www/html/php56/
sudo cp index.php /var/www/html/php70/
sudo mv index.php /var/www/html/php71/
sudo chmod 755 php56 php70 php71 -R

11.打開瀏覽器,並在其網址列,打上 http://IP/php56、http://IP/php70、http://IP/php71
可以看到如下
目前伺服器位址為:192.168.32.199


或是在linux 命令列
x-www-browser 'http://192.168.32.199/php56'
x-www-browser 'http://192.168.32.199/php70'
x-www-browser 'http://192.168.32.199/php71'


現在我們將上述步驟1~步驟10寫成shell,其檔名為lampmulti.sh
其內容如下:
#!/bin/sh
apt-get install -y apache2
apt install -y mysql-server mysql-client libmysqlclient-dev mysql-workbench
add-apt-repository ppa:ondrej/php -y
apt-get update
apt-get install -y php5.6-common php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-gd php5.6-curl php5.6-json php5.6-fpm php5.6-zip php5.6-mcrypt libapache2-mod-php5.6
apt-get install -y php7.0-common php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-xml php7.0-gd php7.0-curl php7.0-json php7.0-fpm php7.0-zip php7.0-mcrypt libapache2-mod-php7.0
apt-get install -y php7.1-common php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-xml php7.1-gd php7.1-curl php7.1-json php7.1-fpm php7.1-zip php7.1-mcrypt libapache2-mod-php7.1
a2enmod rewrite
a2enmod headers
service apache2 restart
echo "alias php56='sudo a2dismod php7.0 && sudo a2dismod php7.1 && sudo a2enmod php5.6 && sudo service apache2 restart'" >> .bashrc
echo "alias php70='sudo a2dismod php5.6 && sudo a2dismod php7.1 && sudo a2enmod php7.0 && sudo service apache2 restart'" >> .bashrc
echo "alias php71='sudo a2dismod php5.6 && sudo a2dismod php7.0 && sudo a2enmod php7.1 && sudo service apache2 restart'" >> .bashrc
cd /etc/apache2/sites-available/
cp 000-default.conf 000-default.conf.bk
echo "<VirtualHost *:80>" > 000-default.conf
echo "  ServerAdmin webmaster@localhost" >> 000-default.conf
echo "  DocumentRoot /var/www/html" >> 000-default.conf
echo "    <Directory \"/var/www/html/php56\">" >> 000-default.conf
echo "           Options FollowSymLinks" >> 000-default.conf
echo "           AllowOverride All" >> 000-default.conf
echo "           #Require all denied" >> 000-default.conf
echo "           Require all granted" >> 000-default.conf
echo "           <FilesMatch \.php$>" >> 000-default.conf
echo "              SetHandler \"proxy:unix:/run/php/php5.6-fpm.sock|fcgi://localhost\"" >> 000-default.conf
echo "           </FilesMatch>" >> 000-default.conf
echo "    </Directory>" >> 000-default.conf
echo "    <Directory \"/var/www/html/php70\">" >> 000-default.conf
echo "           Options FollowSymLinks" >> 000-default.conf
echo "           AllowOverride All" >> 000-default.conf
echo "           #Require all denied" >> 000-default.conf
echo "           Require all granted" >> 000-default.conf
echo "           <FilesMatch \.php$>" >> 000-default.conf
echo "              SetHandler \"proxy:unix:/run/php/php7.0-fpm.sock|fcgi://localhost\"" >> 000-default.conf
echo "           </FilesMatch>" >> 000-default.conf
echo "    </Directory>" >> 000-default.conf
echo "    <Directory \"/var/www/html/php71\">" >> 000-default.conf
echo "           Options FollowSymLinks" >> 000-default.conf
echo "           AllowOverride All" >> 000-default.conf
echo "           #Require all denied" >> 000-default.conf
echo "           Require all granted" >> 000-default.conf
echo "           <FilesMatch \.php$>" >> 000-default.conf
echo "              SetHandler \"proxy:unix:/run/php/php7.1-fpm.sock|fcgi://localhost\"" >> 000-default.conf
echo "           </FilesMatch>" >> 000-default.conf
echo "           </Directory>" >> 000-default.conf
echo "           ErrorLog ${APACHE_LOG_DIR}/error.log" >> 000-default.conf
echo "           CustomLog ${APACHE_LOG_DIR}/access.log combined" >> 000-default.conf
echo "</VirtualHost>" >> 000-default.conf
a2enmod proxy proxy_fcgi
service apache2 restart
cd /var/www/html/
mkdir php56 php70 php71
touch index.php
echo "<?php  phpinfo(); ?>" > index.php
cp index.php /var/www/html/php56/
cp index.php /var/www/html/php70/
mv index.php /var/www/html/php71/
chmod 755 php56 php70 php71 -R
service apache2 restart

直接用 SSH 連接到Server,
用 sudo pico lampmulti.sh,將上面紅色字貼到lampmulti.sh
接下來,將lampmulti.sh權限改為可執行,其指令為 sudo chmod +x lampmulti.sh
執行lampmulti.sh,其指令為 sudo sh lampmulti.sh

注意事項:
1.有些時候會無法完整安裝,這時要下指令要加--fix-missing
   意即 sudo sh lampmulti --fix-missing
   才能夠針對缺項進行完整安裝

2.網頁編碼的問題,可加上
<?php
header("Content-Type:text/html; charset=utf-8");
?>
1.在 xubuntu 16.04中
需先檢查/etc/apache2/conf-available/chartset.conf
AddDefaultCharset UTF-8 前面是否加上 # ,即#AddDefaultCharset UTF-8

2.在 xubuntu 16.04中
需先檢查/etc/php/5.6/apahe2/php.ini 中的default_charset = "UTF-8" 前面要加;,即;default_charset = "UTF-8"
需先檢查/etc/php/7.0/apahe2/php.ini 中的default_charset = "UTF-8" 前面要加;,即;default_charset = "UTF-8"
需先檢查/etc/php/7.1/apahe2/php.ini 中的default_charset = "UTF-8" 前面要加;,即;default_charset = "UTF-8"

目前實驗在此伺服器中,安裝sfs3,其目錄在php56/sfs3。
登入後,會出現錯誤


3.使用adminer 作為MySQL資料庫管理工具

資料來源:
1.ubuntu php多版本共存切換,為每個站點設定不同的php版本
2.詳解Ubuntu/CentOS下Apache多站點配置
3.Shell echo命令
4.Mac/Linux/Windows通過命令調用瀏覽器打開某網頁
5.網頁(UTF-8) 於 瀏覽器 出現亂碼解法
6.強迫網頁預設編碼語系 
7.Adminer羽量級MySQL資料庫管理工具,可完全取代phpMyAdmin,且無檔案匯入大小限制

2019年9月9日 星期一

在Xubuntu16.04 用 shell 安裝 Flask

1.檢查python 3 版本
python3 -V

2.安裝 venv 環境
sudo apt install python3-venv -y

3.建立虛擬環境
cd ~
mkdir my_flask_app
cd my_flask_app
python3 -m venv venv

4.啟動venv
source venv/bin/activate

5.安裝Flask
pip install Flask

6.檢查 Flask 版本
python -m Flask --version

7.建立 hello.py
cd ~/my_flask_app/
touch hello.py
echo "from flask import Flask" > hello.py
echo "app = Flask(__name__)" >> hello.py
echo  -e "\n" >> hello.py
echo "@app.route('/')" >> hello.py
echo "def hello_world():" >> hello.py
echo "    return 'Hello World!'" >> hello.py

8.測試
export FLASK_APP=hello
flask run

那我們將上述步驟1~步驟8 寫成 shell,檔名為flaskInstall.sh,其內容為
#!/bin/sh
python3 -V
sudo apt install python3-venv -y
cd ~
mkdir my_flask_app
cd my_flask_app
python3 -m venv venv
source venv/bin/activate
pip install Flask
python -m Flask --version
cd ~/my_flask_app/
touch hello.py
echo "from flask import Flask" > hello.py
echo "app = Flask(__name__)" >> hello.py
echo  "" >> hello.py
echo "@app.route('/')" >> hello.py
echo "def hello_world():" >> hello.py
echo "    return 'Hello World!'" >> hello.py
export FLASK_APP=hello
flask run

接下來以一般帳號(有sudo 權限)登入
新增一個檔案 flaskInstall.sh,並將上面紅色文字複製貼到flaskInstall.sh
touch flaskinstall.sh
pico flaskInstall.sh
對 flaskInstall.sh 變更權限
chmod 777 flaskInstall.sh
啟動 flaskinstall.sh
source flaskinstall.sh

9.停用虛擬環境
deactivate

資料來源:
1.如何在 Ubuntu 18.04 上安装 Flask

2019年9月7日 星期六

利用 BAT 一鍵完成印表機安裝驅動


使用說明:
20200825
感恩頂番國小李清展老師的協助。
有的印表機需要設定列印喜好設定,希望能夠在安裝過程中設定。
現在讓其在安裝過程中出現,而不要安裝完再自行找路徑做設定。
其中的語句如下:

rundll32 printui.dll,PrintUIEntry /e /n %printer_name2%_%printer_name%


BAT範例下載,解壓密碼demo1234
@echo off
set printer_ip=172.20.3.94
echo "要連接印表機用的ip為%printer_ip%"
set printer_name2="專任室印表機"
echo "機器顯示的名稱為%printer_name2%"
set printer_86_driver="%~dp0AutoInstall\x86\KOAYTJ__.INF"
REM "x86的驅動程式%printer_86_driver%"
set printer_64_driver="%~dp0AutoInstall\x64\KOAYTJ__.INF"
REM "x64的驅動程式%printer_64_driver%"
set printer_name="KONICA MINOLTA C554 PCL Mono"
echo "印表機型號%printer_name%"

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win7有32跟64位元的判斷

:x86
echo "作業系統為x86"
echo "x86的驅動程式%printer_86_driver%"
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
REM 新增ip連接port,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_86_driver% /b %printer_name2%_%printer_name% /m %printer_name%
REM 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 請設定印表機喜好設定
rundll32 printui.dll,PrintUIEntry /e /n %printer_name2%_%printer_name%
echo 印表機喜好設定OK
echo 列表機安裝完成...請按任意鍵結束..
pause

:x64
echo "作業系統為x64"
echo "x64的驅動程式%printer_64_driver%"
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
REM 新增ip連接阜,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_64_driver% /b %printer_name2%_%printer_name% /m %printer_name%
REM 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 請設定印表機喜好設定
rundll32 printui.dll,PrintUIEntry /e /n %printer_name2%_%printer_name%
echo 印表機喜好設定OK
echo 列表機安裝完成...請按任意鍵結束..
pause


20200811
現在再修正,將設定的部分移前。並提供範例下載。
BAT範例,解壓密碼demo1234

@echo off
set printer_ip=172.20.3.94
echo "要連接印表機用的ip為%printer_ip%"
set printer_name2="專任室印表機"
echo "機器顯示的名稱為%printer_name2%"
set printer_86_driver="%~dp0AutoInstall\x86\KOAYTJ__.INF"
REM "x86的驅動程式%printer_86_driver%"
set printer_64_driver="%~dp0AutoInstall\x64\KOAYTJ__.INF"
REM "x64的驅動程式%printer_64_driver%"
set printer_name="KONICA MINOLTA C554 PCL Mono"
echo "印表機型號%printer_name%"

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win7有32跟64位元的判斷

:x86
echo "作業系統為x86"
echo "x86的驅動程式%printer_86_driver%"
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
REM 新增ip連接port,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_86_driver% /b %printer_name2%_%printer_name% /m %printer_name%
REM 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 列表機安裝完成...請按任意鍵結束..
pause

:x64
echo "作業系統為x64"
echo "x64的驅動程式%printer_64_driver%"
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
REM 新增ip連接阜,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_64_driver% /b %printer_name2%_%printer_name% /m %printer_name%
REM 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 列表機安裝完成...請按任意鍵結束..
pause


20200811以前的文章

終於成功了,可以一鍵完成建立印表機。
可建立專任室印表機.BAT,其內容如下:
紅色的部分需要依實際情況做修改,即可:

@echo off
set printer_ip=172.20.3.94
rem 要連接印表機用的ip
set printer_name2="專任室印表機"
rem 機器顯示的名稱

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win7有32跟64位元的判斷

:x86
echo "x86"
set printer_driver="%USERPROFILE%\Desktop\AutoInstall\AutoInstall\x86\KOAYTJ__.INF"
rem %USERPROFILE%\Desktop\AutoInstall\AutoInstall\x86\KOAYTJ__.INF 為桌面
set printer_name="KONICA MINOLTA C554 PCL Mono"
rem KOAYTJ__.INF 內顯示的印表機名稱
rem driver放在同目錄下,路徑用.\來作相對路徑
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
rem 新增ip連接port,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_driver% /b %printer_name2%_%printer_name% /m %printer_name%
rem 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 列表機安裝完成...請按任意鍵結束..
pause

:x64
echo "x64"
set printer_driver="%USERPROFILE%\Desktop\AutoInstall\AutoInstall\x64\KOAYTJ__.INF"
rem %USERPROFILE%\Desktop\AutoInstall\AutoInstall\x86\KOAYTJ__.INF 為桌面
set printer_name="KONICA MINOLTA C554 PCL Mono"
rem KOAYTJ__.INF 內顯示的印表機名稱
rem driver放在同目錄下,路徑用.\來作相對路徑
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
rem 新增ip連接阜,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_driver% /b %printer_name2%_%printer_name% /m %printer_name%
rem 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 列表機安裝完成...請按任意鍵結束..
pause

在學校環境下進行測試 windows 7 與 windows 10 版本,可以成功運作。



後續反應:限制只能在桌面,在桌面解壓縮。可否在任何地方解壓縮,都可以安裝。
那就需要 bat知道所在檔案的路徑
getPath.bat 其內容為
echo off
setlocal EnableDelayedExpansion
echo 路徑1.1:!cd!
pause
@echo off
echo 路徑1.2:%cd%
pause
@echo off
echo 路徑1.3:%~dp0
pause
出現的結果為

那我們用%~dp0來修改

@echo off
set printer_ip=172.20.3.94
rem 要連接印表機用的ip
set printer_name2="專任室印表機"
rem 機器顯示的名稱

if "%PROCESSOR_ARCHITECTURE%" == "x86" goto x86
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto x64
rem 針對win7有32跟64位元的判斷

:x86
echo "x86"
set printer_driver="%~dp0AutoInstall\x86\KOAYTJ__.INF"
echo 驅動程式所在路徑為 %printer_driver%
set printer_name="KONICA MINOLTA C554 PCL Mono"
rem driver放在同目錄下,路徑用.\來作相對路徑
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
rem 新增ip連接阜,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_driver% /b %printer_name2%_%printer_name% /m %printer_name%
rem 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 列表機安裝完成...請按任意鍵結束..
pause

:x64
echo "x64"
set printer_driver="%~dp0AutoInstall\x64\KOAYTJ__.INF"
echo 驅動程式所在路徑為 %printer_driver%
set printer_name="KONICA MINOLTA C554 PCL Mono"
rem driver放在同目錄下,路徑用.\來作相對路徑
C:\Windows\system32\cscript.exe C:\Windows\system32\Printing_Admin_Scripts\zh-TW\prnport.vbs -a -r IP_%printer_ip% -h %printer_ip% -o raw -n 9100
rem 新增ip連接阜,已經存在也沒差
rundll32 printui.dll,PrintUIEntry /if /r IP_%printer_ip% /f %printer_driver% /b %printer_name2%_%printer_name% /m %printer_name%
rem 新增印表機,如果已經有同樣名字的也會新增,名字後面會多(複本1)
echo 列表機安裝完成...請按任意鍵結束..
pause


資料來源:
1.(教學)windows批次檔安裝設定印表機(bat.自動化.驅動.網路)
2.bat安裝印表機 win7
3.自動安裝網路印表機
4.自動安裝印表機
5.在cmd/bat腳本中獲取當前腳本文件所在目錄
6.windows 批處理文件bat中當前目錄。

在 Windows 10 x64 1909版,使用BAT快速安裝公文系統與人事服務網(自然人憑證)版

相關內容移往 https://skjhcreator.blogspot.com/2021/02/windows-10-x64-1909bat.html