Rev 621 | Rev 924 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/bin/php<?php/*QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2024 Min-Jhin,ChenThis file is part of QBPWCF.QBPWCF is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.QBPWCF is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with QBPWCF. If not, see <http://www.gnu.org/licenses/>.*//*安裝方式:將該檔案移動到 /usr/bin/ 底下描述:將特定路徑底下的 qcow2 映象轉換與壓縮,以便節省空間。*/#使用命名空間qbpwcfnamespace qbpwcf;#以該檔案的實際位置的 lib path 為 include path 首位exec("cd ".pathinfo(__FILE__)["dirname"]."/../../;pwd;",$output,$status);set_include_path($output[0].PATH_SEPARATOR.get_include_path());#匯入外部套件include("allInOne.php");#如果參數只有1個if($_SERVER["argc"]===1){#函式說明:#印出多行文字,結尾自動換行.#回傳的結果:#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.#$result["function"],當前執行的函數名稱.#$result["error"],錯誤訊息陣列.#必填的參數:#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.$conf["outputStringArray"][]="Description: convent and compress qcow2 image(s) in searched path.";$conf["outputStringArray"][]="Usage: ".$_SERVER["PHP_SELF"]." [search path]";$echoMultiLine=cmd::echoMultiLine($conf);unset($conf);#如果解析內容失敗if($echoMultiLine["status"]==="false"){#印出結果var_dump($echoMultiLine);#結束程式exit;}#if end#結束程式exit;}#if end#涵式說明:#尋找指定路徑下的虛擬硬碟,將之重新轉換與壓縮,再取掉代原有的檔案.#回傳結果:#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.#$result["error"],錯誤訊息.#$result["function"],當前執行的函數名稱.#$result["argu"],所使用的參數.#$result["found"],是否有找到可以轉換的檔案,"true"代表有;"false"代表沒有.#$result["content"],有改變的虛擬硬碟位置字串陣列.#必填參數:#$conf["path"],字串,虛擬硬碟檔案的搜尋路徑.$conf["path"]=$_SERVER["argv"][1];#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑#$conf["fileArgu"]=$_SERVER["PWD"]."/".basename(__FILE__);$conf["fileArgu"]=__FILE__;#備註:#目前只支援qcow2格式的虛擬硬碟$imgConvert=qemu::imgConvert($conf);unset($conf);#如果轉換失敗if($imgConvert["status"]==="false"){#印出結果var_dump($imgConvert);#結束程式exit;}#if end#函式說明:#印出多行文字,結尾自動換行.#回傳的結果:#$result["status"],執行是否成功,"true"代表成功,"false"代表失敗.#$result["function"],當前執行的函數名稱.#$result["error"],錯誤訊息陣列.#必填的參數:#$conf["outputStringArray"],字串陣列,每行要印出的文字內容.$conf["outputStringArray"][]="Complete convert and compress qcow2 image(s) in searched path: ".$_SERVER["argv"][1];$echoMultiLine=cmd::echoMultiLine($conf);unset($conf);#如果解析內容失敗if($echoMultiLine["status"]==="false"){#印出結果var_dump($echoMultiLine);#結束程式exit;}#if end?>