顯示具有 PHP 標籤的文章。 顯示所有文章
顯示具有 PHP 標籤的文章。 顯示所有文章

4月 29, 2024

在 GitHub Codespaces 中運行 CodeIgniter v4.5

因為 CodeIgniter v4.5 需要 PHP 8.1 及 PHP-intl 元件才能運作,原生 GitHub Codespaces 運作 Ubuntu 20.04 LTS 版本,快速解法是直接透過 Personal Package Archives(PPA) 補齊新版套件,並把環境鏈結刪除(current),最後再用 composer 把 CodeIgniter 裝起來。

[啟用第三方套件庫]
# add-apt-repository ppa:ondrej/php
# apt install php8.3-{cli,intl,curl,mbstring,mysql,sqlite3,gd} phpunit

[確定當前PHP呼叫路徑]
# which php
# 可能是 /home/codespace/.php/current/bin/php
# 或者是 /usr/local/php/current/bin/php

[重新建立鏈結(current),最新版位於 /usr/bin/php8.3]
# rm /home/codespace/.php/current
# rm /usr/local/php/current
# ln -s /usr /home/codespace/.php/current
# ln -s /usr /usr/local/php/current
# 執行 php --ini 或 php -m 驗證環境

[安裝資料庫]
# apt install mariadb-server
# /etc/init.d/mysql start
# mysql_secure_installation

4月 18, 2022

PHPExcel 快速入門

一個已停止開發的專案PHPExcel(後繼者為 PhpSpreadsheet),尚能應付基本 Excel 讀寫操作(測試環境 PHP 7.2.9)。
require_once('PHPExcel-1.8/Classes/PHPExcel/IOFactory.php');

/* Write file */
$xlsWriter = new PHPExcel();
$xlsWriter->setActiveSheetIndex(0);
$xlsWriter->getActiveSheet()->SetCellValue('A1', '_VALUE_');
$xlsWriter->getActiveSheet()->SetCellValue('B1', '_VALUE_');
$writerObj = PHPExcel_IOFactory::createWriter($xlsWriter, 'Excel2007');
$writerObj->save("output.xlsx");

/* Read file, dump sheet into array, also see rangeToArray() */
$xlsReader = PHPExcel_IOFactory::createReader('Excel2007');
$xlsReader->setReadDataOnly(true);
$readerObj = $xlsReader->load("example.xlsx");
$sheetAry  = $readerObj->getActiveSheet()->toArray(null,true,true,true);
echo print_r($sheetAry,true);   // show array formatted

/** toArray() definition
 * @param  $nullValue          Value returned if a cell doesn't exist
 * @param  $calculateFormulas  Should formulas be calculated?
 * @param  $formatData         Should formatting be applied to cell values?
 * @param  $returnCellRef      True, Return rows and columns indexed(A1,B1,C1...)
*/

5月 22, 2018

使用 PHP 整合 Windows Active Directory(AD) 進行身份認證

首先安裝 PHP-LDAP 套件:
# apt-get install php-ldap

之後是示範程式碼:
<?php
  $ADserver = "xx.xx.xx.xx";
  $domain   = "example.com.tw";
  $baseDN   = "dc=example,dc=com,dc=tw";
            
  $user     = 'Jack';
  $pass     = 'Password_here';  
  
  /* Format should like Jack@example.com.tw */
  $ldapDN   = $user . '@' . $domain;
  
  $ldapConn = ldap_connect( $ADserver ) or die("Connect fail");
  
  /* IMPORTANT */
  ldap_set_option($ldapConn, LDAP_OPT_PROTOCOL_VERSION, 3);
  ldap_set_option($ldapConn, LDAP_OPT_REFERRALS, 0);

  if ($ldapConn) 
  { 
    $ldapbind = ldap_bind($ldapConn, $ldapDN, $pass);   
    if ($ldapbind) 
    {
      $filter = "(sAMAccountName=$user)";
      $result = @ldap_search($ldapConn, $baseDN, $filter);
      
      if($result == false) 
      {
        /* empty search result */
      }
      else
      {
        $row       = ldap_get_entries( $ldapConn, $result );   
        $loginName = $row[0]['displayname'][0];     // display name
        $loginID   = $row[0]['samaccountname'][0];  // AD account
      }    
    } 
    else 
    {         
      die("User,Pass do not match");
    } 
  }
  ldap_close($ldapConn);  
?>

1月 17, 2018

使用 PHP 連接 Microsoft SQL Server 資料庫

依不同的 PHP 版本而定...

PHP 5.x

上古時代想連接 SQL Server 則要透過 FreeTDS 開源套件,說明如下:
FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases.
; 安裝所需套件
# apt-get install freetds-common freetds-bin unixodbc php5-sybase

其中 php5-sybase 就包括 mssql.so 函式庫,所以基本上一行指令可以搞定所有事;之後更改 FreeTDS 相關參數(TDS連線協定版本)與連線編碼(UTF8支援中文字):

設定 /etc/freetds/freetds.conf:
[global]
# TDS protocol version
tds version = 8.0
client charset = UTF-8

連線測試可用下列指令:
tsql -S DBserver -p 1433 -U dbadmin -P dbpass
1> SELECT  @@servername
2> GO
3> SELECT @@servicename
4> GO

在 PHP 程式中使用下列指令進行連線/查詢 (PHP7中捨棄):
  • mssql_connect()
  • mssql_query()
  • mssql_fetch_array()

 PHP 7.x

微軟針對這個PHP版本所開發延伸套件:Microsoft Drivers for PHP for SQL Server(專案網址)
; 在 /etc/apt/sources.list 加入 APT 套件庫
deb https://packages.microsoft.com/debian/8/prod jessie main

; 安裝套件
# apt-get install php-pear msodbcsql mssql-tools unixodbc-dev
# pecl install sqlsrv
# pecl install pdo_sqlsrv

; 掛載函式庫
extension=sqlsrv.so
extension=pdo_sqlsrv.so

在 PHP 程式中使用下列指令進行連線/查詢:
  • sqlsrv_connect()
  • sqlsrv_query()
  • sqlsrv_fetch_array()

8月 03, 2017

Laravel course #1

Route::get('/', function(){
  $name = 'Jack';
  $age  = 30;
  //return view('welcome')->with('name', 'Jack'); 傳入變數
  //return view('welcome', ['name' => 'Jack']); 傳入陣列
  return view('welcome', compact('name','age'));
});

compact內接的變數要用引號,並且沒有$字號

常用 DB Migrate 指令
$ php artisan make:migration create_tasks_table ;建立 migration 檔案

$ php artisan migrate          依照 migration 檔案進行 DB 架構異動
$ php artisan migrate:install  Create the migration repository            
$ php artisan migrate:refresh  Reset and re-run all migrations            
$ php artisan migrate:reset    Rollback all database migrations           
$ php artisan migrate:rollback Rollback the last database migration       
$ php artisan migrate:status   Show the status of each migration          
建立 Model 存取資料庫
$ php artisan make:model Task

產生檔案 app/Task.php 繼承 Model 類別、命名空間為 App 如下:

namespace App;

use Illuminate\Database\Eloquent\Model;

class Task extends Model
{
    ...
}

呼叫語法範例
App\Task::all();  回傳所有資料
App\Task::pluck('body');  回傳所有資料的 body 欄位

建立 Model 時,順便連 Migration檔、Controller 檔都一起建立
$ php artisan make:model Task -m -c

建立三個檔案:app\Task.php 與 
\database\migrations\2017_08_08_060314_create_tasks_table.php 與
\app\Http\Controllers\TasksController.php
Blade 模板使用方式

  1. 骨架(layout)部份 include "nav-bar" 與 "footer" 檔案進來,中間挖個洞用 yield 宣告 "content" 讓其他檔案填充這塊。
  2. 主頁(index)部份 extends 使用 layout 這個骨架,並用 section 宣告 "content" 範圍區間

整合後的 index.blade.php 全貌

有關 Laravel 命名規則
  1. Model:必定使用單數(如Post),系統預設複數型為Table使用(如Posts)
  2. Table:複數,遵循 Model 規則
  3. Controller:複數,如 PostsController
  4. Migration:動詞+表格名,如 create_posts_table;系統產生類別 CreatePostsTable

3月 23, 2016

Cloud IDE

幾個熱門的雲端開發平台(Cloud IDE):
  • Koding
  • Cloud9
  • Codeanywhere
  • Codenvy

1月 28, 2016

PHP-Based Webmail

幾個以 PHP 為運作環境的 Webmail:

11月 18, 2014

透過網路傳送簡訊(SMS)及電話撥打

兩個發送 SMS 簡訊的網路服務(收費)

1. Twilio
  • API 支援 PHP、C#、JAVA、XML(透過curl)
  • 說明文件完整
  • 收費較便宜 $0.01USD
2. Nexmo(Vonage 收購)
  • 歐元計費:簡訊每則 0.03 、語音每分鐘 0.076
  • 單純送 SMS 簡訊:文字內容要用 URL Encode 編過,並且指定 type 為 unicode 才不會亂碼
  •  支援語音 TTS(Text To Speech) 功能:這個超強!可以在電話中念出你指定的中文字
  • 詳細參數請見:簡訊 API 手冊語音 TTS 手冊
簡訊發送範例
https://rest.nexmo.com/sms/json?api_key=XXX&api_secret=XXX&
from=XXX&to=886956XXXXXX&type=unicode&text=Msg+in+URL+Encode

語音撥打範例
https://rest.nexmo.com/tts/json?api_key=XXX&api_secret=XXX&
to=886956XXXXXX&text=語音測試&lg=zh-cn&repeat=3&voice=male
透過 PHP cURL 呼叫範例:
<?php

 $ch = curl_init();

 $URL = "https://rest.nexmo.com/..." ;
 curl_setopt($ch, CURLOPT_URL, $URL );
 curl_setopt($ch, CURLOPT_HEADER, false);

 /* disable SSL verify */
 curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
 curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);

 curl_exec($ch);
 curl_close($ch);
?> 

9月 20, 2014

透過 PHP 連線 Oracle 資料庫

先談比較容易處理的 PHP 語法


在 Oracle 資料庫系統中,連線方式有兩種區別:Service Name 與 SID,不要弄錯了。手上的開發環境以 Service Name 為例。
  • 語法範例 (Oracle 11g 資料庫):
  • $db_id = "ORACLE-USER";
    $db_pwd = "ORACLE-PASSWORD";
    $oracle_db = "(DESCRIPTION = (ADDRESS_LIST = 
      (ADDRESS = (PROTOCOL = TCP)(HOST=10.1.1.1)(PORT=1521) ) )
      (CONNECT_DATA = (SERVICE_NAME=LODA) ) )";
    
    /* Go, Using UTF-8 Encoding */
    $conn = oci_connect($db_id, $db_pwd, $oracle_db, 'utf8');  
    $sql = "SELECT X,Y,Z FROM TABLE";
    
    if( !$conn ) { print_r (oci_error()); /* ErrCode */ }
    else
    {
     try
     {
      $stid=oci_parse($conn, $sql);
      oci_execute($stid);  /* Do Query */
      while( $row = oci_fetch_array($stid, OCI_BOTH) )
      { 
       $X = $row['X']; /* Fetch result, encoding to BIG5 */ 
       $Y_big5 = mb_convert_encoding ($row['Y'],"big5","utf-8");
      }
     }
     catch (Exception $err) { echo $err->getMessage(); }
    }
    /* Connection release */
    if($stid){ oci_free_statement($stid); }
    if($conn){ oci_close($conn); }
    
  • 指令不難,但在編碼的地方卡了一下,因為 Client 端只收 Big5 編碼。後來翻到函式 mb_convert_encoding($str, newEncode, oriEnconde) 用來轉換,所以順利解決。

再來是卡關好幾次的環境設定


因為在 Windows 環境下使用了 Uniform Server 作為開發平臺,原以為只要在控制面板內啟用 php_oci8.dll 與 php_pdo_oci.dll 兩項延伸模組就大公告成,沒想到整臺炸掉了!關於連線 Oracle 資料庫所需的函式套件:
  • 取得 Oracle Instant Client Package (例:instantclient-basic-nt-11.2.0.3.0.zip)
  • 解壓縮後將:oci.dll、ociw32.dll、orannzsbb11.dll、oraociei11.dll 丟到 C:\Windows\System32 目錄下
  • 啟用 php_oci8_11g.dll 與 php_pdo_oci.dll 兩項延伸模組
  • 重新啟動 Apache 應該沒問題了

最後是 PHP-CLI 環境參數


透過瀏覽器檢索,資料可從 Oracle 中讀出並在網頁中顯示。但此次開發最終要丟進排程執行,所以直覺把 PHP script 餵給 PHP-CLI(即php.exe) 處理應該就行了...。沒想到 PHP-CLI 使用另組環境參數運作(炸),暗雷何其多。舉凡任何 oci_* 語法均是未定義:
Fatal error: Call to undefined function oci_connect()
查詢 PHP-CLI 使用的環境參數並進行修正(此例為 php-cli.ini):
C:\UniServerZ\core\php54>php --ini
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File:         C:\UniServerZ\core\php54\php-cli.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)
這邊很明顯,只要在設定內把 extension 補上去就沒問題了。

8月 26, 2014

設定 Uniform Server 環境參數

Uniform Server Zero(UniServerZ) 是Windows環境下的 WAMP 組合,系統在設計上將所有組態檔安置在 \UniServerZ\home\us_config\ 目錄下。欲更改 Apache 所用連接埠與目錄見:us_user.ini 設定檔
[USER]
AP_PORT=8080
AP_SSL_PORT=8081
US_SERVERNAME=localhost
US_ROOTF_WWW=./www
US_ROOTF_SSL=./ssl
另個與存取相關的是:/www/.htaccess 中 Order Deny,Allow 範圍,記得把用戶IP位址加入。
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from "Client_IP"
若要調整 PHP 其他環境參數,見控制面板 [PHP]-[Edit Basic Configuration]
  • Display Errors:顯示除錯訊息
  • Memory
  • Post Size
  • Upload Size
若要啟用或停用內建模組則是 [PHP Modules Enable/Disable]
  • php_xdebug:除錯模組

8月 24, 2014

JpGraph - PHP上的繪圖函式庫

在 PHP 下的一套繪圖函式庫:JpGraph (An Object-Oriented Graph creating library)

字型參數:
  • 字型目錄定義:jpgraph.php
    預設使用函式庫路徑 /fonts 下的字型檔,備用是系統 /usr/share/fonts/truetype/
  • 字型名稱定義:jpgraph_ttf.inc.php
設定標題、X軸、Y軸字型大小:
$graph = new Graph(800,600);
$graph->title->SetFont(FF_ARIAL,FS_BOLD,24);
$graph->xaxis->SetFont(FF_ARIAL,FS_BOLD,14);
$graph->yaxis->SetFont(FF_ARIAL,FS_BOLD,14);
設定Y軸邊界(參考Graph類別手冊):
/* SetMargin($lef, $right, $top, $bottom) */
$graph->SetMargin(40,20,60,20);
配合讀入 csv 畫圖:
$dataArray = array();
$_gData = array();
$csvfile = fopen("diskusage.csv", "r");
while ( !feof($csvfile) )
{
  array_push( $dataArray, fgetcsv($csvfile) );
  $count++;
}
fclose( $csvfile );

for ($i=0; $i < $count-1; $i++)
{
  /* 取出橫列第5元素 存入一維陣列 */
  array_push( $_gData, round($dataArray[$i][4],2) );
}

/* setup the graph */  
$graph = new Graph(800,600);
$p1 = new LinePlot($_gData);
$graph->Add($p1);

/* Go */
$graph->Stroke();

8月 19, 2014

PHP 的 Session 使用方法

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>

  <body>
    <?php
    
      /*   Table           Field
         +--------------+----------+
         |counter       |pageview  |
         +--------------+----------+-----+
         |sessionTablew |sessionID |time |
         +--------------+----------+-----+
      */
    
      $dbuser = "xxxx";
      $dbpass = "xxxx";
      $dbname = "counter";
      
      $conn = mysql_connect( "localhost", $dbuser, $dbpass);
      if (!$conn)
        die ("connect fail");
      mysql_query("SET NAMES 'utf8'");
      mysql_select_db($dbname, $conn);
      
           
      session_start();
      $_sessionID = session_id();

      $queryString = "SELECT * from sessionTable where sessionID='{$_sessionID}'" ;
      $rowCount = mysql_num_rows( mysql_query($queryString, $conn) );
      
      if ( $rowCount == 0 )  /* here comes new visitor */
      {        
        $datetime = date("Y-m-d, H:i:s");
        
        $queryString ="insert into sessionTable values ('{$_sessionID}', '{$datetime}')";
        mysql_query($queryString, $conn);
        
        $queryString = "SELECT * FROM counter ORDER BY pageview DESC";       
        $row = mysql_fetch_array( mysql_query($queryString, $conn) );
        
        $ori = $row['pageview'] ;
        $ori_plus = $ori +1 ;
        
        $queryString ="update counter set pageview='{$ori_plus}' where pageview='{$ori}'";
        mysql_query($queryString, $conn);
        echo "visitor:".$ori_plus;
      }
     
    ?>  
  </body>
</html>

8月 11, 2014

Web-based file upload module

幾個檔案上傳的前端網頁模組,均可搭配 PHP 使用:
  1. Uploadify
  2. Plupload
  3. jQuery File Upload Plugin (開發者 blueimp)
後來選了 Uploadify 這個 Flash 外掛工具來開發系統,主要有幾個特點:
  • 手冊 API 清楚完整,常用功能均有實作
  • 範例程式簡短易讀且能正常運作
  • 支援檔案格式與檔案大小過濾功能

7月 25, 2014

Parsing X509 Certificate

臺灣發行的自然人憑證 IC 卡使用 X.509 標準格式,所以只要讓使用者讀出憑證後,丟到後端由 PHP 剖析,即可獲取卡片基本資訊。像是卡片持有人姓名、序號、發行單位(通常是內政部憑證管理中心)與身份證末四碼。

在 PHP 上有個開源專案 phpseclib 可以輕鬆完成 X.509 憑證解析(Parser)這件事。試著把自己的憑證丟進去測試,幾個比較重要的欄位都有解出來。

phpseclib: X.509 Decoder

函式的使用方法:
include('File/X509.php');
$X = new File_X509();
$cert = $X->loadX509(__CERTIFICATE-HERE__);

持卡人姓名:
$cert['tbsCertificate']['subject']
['rdnSequence'][1][0]['value']['utf8String']

發行單位名稱:
$cert['tbsCertificate']['issuer']
['rdnSequence'][2][0]['value']['utf8String']

5月 01, 2014

linux-dash 主機狀態看板

linux-dash : 在 GitHub 上的鏈結
A drop-in, low-overhead monitoring web dashboard for a linux machine.
(php 語言寫成,用來取得主機資訊)
  • A beautiful web-based dashboard for monitoring server info
  • Live, on-demand monitoring of RAM, Load, Uptime, Disk Allocation, Users and many more system stats
  • Click and drag to re-arrange widgets
需求環境:
  1. Linux (Debian, Ubuntu)
  2. php5-json
  3. Nginx / Apache2 / Lighttpd

8月 21, 2013

PHP 本身內建的 Web Server

PHP 從 5.4 版起就內建了簡易型的 web server:
Built-in web server
As of PHP 5.4.0, the CLI SAPI provides a built-in web server. This web server is designed for developmental purposes only, and should not be used in production.
啟動的方式是這樣:
(1)監聽來自任何介面的請求:php -S  0.0.0.0:80 -t <DOCUMENT_ROOT>
(2)監聽來自本機的請求:php -S  localhost:80 -t <DOCUMENT_ROOT>
至於 php 執行檔的取得應該相當容易,由官方網站下載或第三方封裝好的架站機。

為求容量精簡,特地找了一個由 Uniform Server 包裝好的版本:UniServerMicro,整個壓縮檔不到 10MB。經過測試 DokuWiki 可以該環境正常運作。

如果要讓 php 內建的 web server 在開機後在「背景」執行,可以透過下列手法達成:

建立 run_PHP.bat 內容:
php.exe -S 0.0.0.0:80 -t C:\www_root
建立 run_PHP.vbs 內容:
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "run_PHP.bat" & Chr(34), 0
Set WinScriptHost = Nothing
在開機時啟動上面的 vbs 即可。

8月 08, 2013

LimeSurvey 線上問卷系統

線上問卷系統 (PHP環境)
LimeSurvey (formerly PHPSurveyor) is a free and open source on-line survey application written in PHP based on a MySQL, PostgreSQL or MSSQL database, distributed under the GNU General Public License.
幾個系統的運作邏輯要清楚:
  1. 問卷產生程序:「建立問卷→建立題組→建立題目」這是最基本的構成,最後才能啟用問卷蒐集資料。
  2. 問卷啟用時,系統會詢問是否切換成「封閉型問卷」,所謂封閉型問卷是指 Non-Anonymous Survey:受訪者需使用邀請代碼(token)通關後才能開始作答,意味要先行寄發邀請代碼給受訪者。這點務必留意。 
使用上大致沒什麼問題,除了一點…統計圖表是亂碼!直條圖、圓餅圖、折線圖內的中文字全都是□□□。因為系統沒有中文字型。

翻一下 fonts/fireflysung - Chinese.ttf.txt 這個檔案:
For package size reasons the Firefly Sung font to show Chinese characters in the statistics graphs is not included with LimeSurvey. Please download it from...
下載中文字型,改一下 /application/config/config-defaults.php 檔案:
$config['chartfontfile']='fireflysung.ttf';    //原值是auto
 然後如果圖表的字太小
$config['chartfontsize'] =12;   // 原值是10
 最後記得清掉 /tmp 目錄下的 png 快取圖檔。

10月 02, 2012

專案管理(或協同平台)軟體

幾個專案管理軟體(或協同作業平台),可以丟在網路上跑:

1. Collabtive
加強版的 TODO,多人協作、提供檔案上傳

2. ProjectPier
待評

3. phpCollab
可用來作為 bug/ticket trace 系統

4. DotProject
較適合用來作為專案進度管理系統

5. PHProjekt
基本上就是群組軟體(Groupware)系統,功能強大無所不包(40MB),兼具專案管理、團隊溝通等功能。

6. Simple Groupware
群組軟體

7月 27, 2012

Nginx 與 spawn-fcgi 的設定

設定 .php 的解析方式

這邊記得要用 Unix domain socket 的模式,比較不會有 "502 Bad Gateway" 錯誤產生。

# vim /sites-enabled/default
server {
 charset utf-8;
 location ~ \.php$ 
 {
  try_files $uri $uri/ =404;
  fastcgi_index index.php;
  include /etc/nginx/fastcgi_params;
  fastcgi_pass unix:/tmp/php-cgi.socket;
 #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;
 }
}

使用 spawn-fcgi 來管理 php-cgi 數目

spawn-fcgi 已經成為獨立套件,在 Debian 中可以透過 apt 來安裝。
# sudo apt-get install spawn-fcgi

丟個 script 到 /etc/init.d/ 目錄下,讓 php-fcgi 開機時就能自己啟動。
# vim /etc/init.d/php-fastcgi
# chmod +x php-fastcgi
# update-rc.d -f php-fastcgi defaults 2

內容如下:
#!/bin/bash
### BEGIN INIT INFO
# Provides:          php-fastcgi
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      1
# Short-Description: Run the PHP FastCGI
# Description:       PHP FastCGI environment for Nginx web server
#
### END INIT INFO

CHILDREN=1
PHP5=/usr/bin/php5-cgi
SOCKET=/tmp/php-cgi.socket
PIDFILE=/var/run/php-cgi.pid

USER=www-data
GROUP=www-data
SPAWN=/usr/bin/spawn-fcgi

OPT="-s $SOCKET -P $PIDFILE -f $PHP5  \ 
     -u $USER -g $GROUP -C $CHILDREN"

do_start() {
  start-stop-daemon --start --quiet --exec $SPAWN -- $OPT
}
do_stop() {
  start-stop-daemon --stop  --quiet --pidfile $PIDFILE
}
do_restart() {
  start-stop-daemon --stop  --quiet --pidfile $PIDFILE
  sleep 1
  start-stop-daemon --start --quiet --exec $SPAWN -- $OPT
}

case "$1" in
  start)
    do_start;;
  stop)
    do_stop;;
  restart)
    do_restart;;
  *)
    echo "Usage: php-fastcgi {start|stop|restart}" ;;
esac

7月 13, 2012

挑戰 PHP5&MySQL 程式設計樂活學

《挑戰 PHP 5 MySQL 程式設計樂活學, 2/e》



ISBN: 9789862763384
書中範例 (載點1 , 載點2)