การติดตั้ง Open Source Self Check Part 2

ากบทความที่แล้ว เรื่อง การติดตั้ง Open Source Self Check Part I หวังว่าผู้อ่านคงจะศึกษาและเตรียมข้อมูลต่างๆ พร้อมแล้ว ถ้าพร้อมแล้วก็มาลุยกันต่อเลยครับ

เริ่มติดตั้ง

แบบที่ 1. การติดตั้ง Open Source Self Check กรณีบน Server

จากกรณีนี้ จะหมายถึง หากหน่วยงานของท่านเองมี Server ที่รองรับภาษา PHP อยู่แล้วก็ไม่มีความจำเป็นที่จะต้องทำอะไรมากเพียงแต่ประสานกับผู้ดูแลเครื่องแม่ข่าย ว่าต้องการติดตั้ง Open Source Self Check แต่ทั้งนี้ให้ตรวจสอบว่า ได้เปิด extension socket ใน PHP ไว้หรือไม่ โดยการตรวจสอบ ไฟล์ php.ini ว่า ได้ Uncomment บรรทัด ;extension=php_sockets.dll หรือยังสำหรับระบบปฏิบัติการ Windows แล้วทำตามขั้นตอนดังนี้

ฝั่ง Server

1. Download Open Source Self Check หรือหากต้องการ Version ที่ผมและทีมต่อยอดแต่ยังไม่ได้ปล่อยให้ Load ก็ติดต่อมาได้ครับ

2. แตกไฟล์ที่ Download มาใน Folder  ที่ให้บริการเว็บ เช่น htdocs (กรุณาสอบถามจากผู้ดูแลระบบ)

3. แก้ไข File ชื่อ config.php ด้วย text editor ดังนี้ (กด + expand source ด้านล่างเพื่อดู Code ที่ย่อไว้) แล้วบันทึก

Config.php เดิม
/**
* Self Check
*
* This application provides a method of checking out and renewing materials via a web interface using 3M's SIP2 standard
* Thanks to John Wohlers for his sip2 class -this application would not have come about without it
*
* If you make additions or other customizations that improve or extend the self check's
* functionality I would love to hear about them.
*
* @author Eric Melton <ericmelton@gmail.com>
* @licence http://opensource.org/licenses/gpl-3.0.html
* @copyright Eric Melton <ericmelton@gmail.com>
* @version 1.2
*/
 
//========================== SIP2 =================================
$sip_hostname = '127.0.0.1';
$sip_port = "1";
$sip_login=''; //if your SIP2 server does not require a username and password leave these empty
$sip_password='';
 
//========================== Site Rules ==============================
$sc_location='';//enter a name for the self-check's location (e.g. 'East Branch') to track transactions in your SIP2 logs (in Polaris this is required and is the numeric organization ID)
$allow_manual_userid_entry=false;
$show_fines=true;
$show_available_holds=true;
$allow_email_receipts=false;
$display_php_errors='on'; //off or on
$hide_cursor_pointer=false; //hides default cursor pointer -should probably set to true on live self check
 
//========================== Logging =================================
/*
 use the query below to setup the mysql table (if you change the table name set
 the variable $log_table_name below equal to that new table name)
 
 CREATE TABLE `self_check_stats`
 (`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
 `location` varchar( 50 ) DEFAULT NULL ,
 `count` int( 11 ) NOT NULL DEFAULT '0',
 `sessions` int( 11 ) NOT NULL DEFAULT '0',
 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
 PRIMARY KEY ( `id` ));
 
*/
//====================================================================
$use_mysql_logging=false; /* log your selfcheck checkout count by month?
 use the query above to set up the table */
$log_table_name='self_check_stats';
 
//mysql connection info (ignore this if you're not using mysql logging)
$dbhostname = "localhost:3306";
$database = "";
$dbusername = "";
$dbpassword = "";
 
//====================== SIP2 Responses ==============
/*
 GET YOUR SYSTEM'S RESPONSE MESSAGES BY ENTERING YOUR SIP2 CONNECTION INFO ABOVE THEN OPENING responses.php
 IN YOUR BROWSER-THEY MUST BE KEPT UP TO DATE!
 These are case INsensitive.
*/
//====================================================================
$already_ckdout_to_you='Item already charged to this user'; //item already out to this borrower response
 
//====================== Wording, SMTP, & Other Variables ==============
$currency_symbol='$';
$due_date_format='n/j/Y'; //see http://php.net/manual/en/function.date.php for information on formatting dates
$inactivity_timeout=40000; //time of inactivity before showing inactive prompt (in milliseconds)
$account_check_timeout=15000; //time of inactivity after patron card scan before showing out of order page (in milliseconds)
$patron_id_length=; //length of patron barcode or other id (leave empty if this varies)
$online_catalog_url='http://publiclibrary.gov'; /*leave blank if you don't have one or if your catalog does
 not allow renewals (this is for printing on the paper receipt and
 sending in the email receipt info about renewing online)*/
 
//smtp (for emailing receipts)
$smtp_host="";
$smtp_authentication=false;
$smtp_username='';
$smtp_pwd='';
 
//wording
$library_name= "Public Library";
$module_name='Self-Checkout Station'; //shows on pages/home.php and pages/checkout.php
$email_from_name=""; //library's email name
$email_from_address=""; //library's email address
$admin_emails=''; //comma delimted list of email addresses that should be notified should the self-check go out of order
$email_subject='Public Library Self-Checkout Receipt'; //subject of email receipt
$intro_screen_text="Scan your library card's barcode to begin"; //shown on pages/home.php
$welcome_screen_text="Scan an item's barcode to continue"; //shown on includes/welcome.php
$welcome_screen_subtext="(most barcodes are inside items' front covers)";
$renewal_prompt_text='is already checked out to your account.<br />Would you like to try to renew it?';
$out_of_order_head='Out of Service'; //shown on pages/out_of_order.php
$out_of_order_text='We are working to fix the problem'; //shown on pages/out_of_order.php
 
//====================== Paper & Email Receipts ==============
/* add elements to or remove elements from the header & footer arrays below to manipulate that piece of the receipt.
the elements will appear on separate lines of the receipt in the order that you place them below */
$receipt_header[]='Checkout Receipt';
$receipt_header[]=$library_name;
$receipt_footer[]='Renew your items online:';
$receipt_footer[]=$online_catalog_url;
 
/*place the following in the order you want the elements to appear in the item list on the
paper and email receipts. remove (or comment out) any elements you don't want included.
element options include item_barcode, title, due_date, and call_number */
$receipt_item_list_elements[]='title';
$receipt_item_list_elements[]='call_number';
$receipt_item_list_elements[]='item_barcode';
$receipt_item_list_elements[]='due_date';
 
//========================= Sounds & Images ==========================
 //sounds
$error_sound="sounds/error.mp3";
$welcome_sound="sounds/welcome.mp3";
$note_sound="sounds/note.mp3";
 
 //images (you need to uncomment one -and only one- line from each group).
/*
 Keep in mind these are not the image files names -they are just meant to trigger the showing
 of the types of images listed here. For further customization, images are loaded in the following files:
 pages/checkout.php , pages/home.php, and includes/welcome.php
*/
 
 //======= group 1: home page images of library card =======
//$card_image='kpl';
$card_image='barcoded';
//$card_image='magnetic';
 
 //======= group 2: home and checkout page images of book ==
$item_image='barcoded';
//$item_image='nonbarcoded';
 
//======================= Action Balloons =======================
/*
 
The following settings determine what types of materials will prompt the self check to issue an
action message (a short message accompanied by a beep sound) upon checkout. You may want borrowers to unlock the cases of
or desensitize certain types of items, for example, or give a reminder that a particular type of item has a
shorter checkout period than other items like it.
 
Each item that requires an action can have its action message triggered by 1) its item type OR 2) its permanent location.
 
Each action balloon requires 2 variables set up in the following format:
 
1) $action_balloon[item type OR permanent location]['action_message']=action message;
2) $action_balloon[item type OR permanent location]['trigger']='item type' OR 'permanent location' OR 'call number prefix';
 
2 examples:
$action_balloon['CD']['action_message']='Please place your CDs inside one of the plastic bags near this station';
$action_balloon['CD']['trigger']='permanent location';
 
$action_balloon['EXPRESS DVDS']['action_message']='Express DVDs checkout for 3 days';
$action_balloon['EXPRESS DVDS']['trigger']='item type';
 
*/
//======================================================================
$action_balloon_bg_color='#f1cae1'; //background color for action balloons
//$action_balloon['CD']['action_message']='Please place your CDs inside one of the plastic bags near this station';
//$action_balloon['CD']['trigger']='permanent location';
 
//==================================== Allowed IPs =======================
/*
 list each allowed ip on a new line as $allowed_ip[]='IP';
 example: $allowed_ip[]='192.168.0.2';
 $allowed_ip[]='192.168.0.4';
*/
$allowed_ip[]=''; //leave empty if you've already limited access to the self check via your server (Apache, IIS, etc.)
 
//==================================== Don't edit below this line =======================
if (!in_array($_SERVER['REMOTE_ADDR'],$allowed_ip) && !empty($allowed_ip[0])){
 exit;
}
ini_set('display_errors', $display_php_errors);
?>
Config.php ที่แก้ไขแล้ว สังเกตว่าที่จะต้องมีการแก้ไขจะเป็นภาษาไทย (อาจมีแตกต่างกับต้นฉบับบ้างเล็กน้อย)
/**
* Self Check
*
* This application provides a method of checking out and renewing materials via a web interface using 3M's SIP2 standard
* Thanks to John Wohlers for his sip2 class -this application would not have come about without it
*
* If you make additions or other customizations that improve or extend the self check's
* functionality I would love to hear about them.
*
* @author Eric Melton <ericmelton@gmail.com>
* @licence http://opensource.org/licenses/gpl-3.0.html
* @copyright Eric Melton <ericmelton@gmail.com>
* @version 1.2
*/
 
//========================== SIP2 =================================
$sip_hostname = 'ใส่หมายเลข IP หรือ Hostname ของ SIP2 Server';
$sip_port = 'ใส่หมายเลขพอร์ตในการเชื่อมต่อกับ SIP2 Server';
$sip_login= 'ใส่ Usernameในการเชื่อมต่อกับ SIP2 Server(ถ้ามี)'; //if your SIP2 server does not require a username and password leave these empty
$sip_password = 'ใส่ Usernameในการเชื่อมต่อกับ SIP2 Server(ถ้ามี)';
 
//========================== Site Rules ==============================
$sc_location = 'ใส่ ชื่อเครื่องหรือพื่นที่ที่ติดตั้งเครื่อง self check';//enter a name for the self-check's location (e.g. 'East Branch') to track transactions in your SIP2 logs (in Polaris this is required and is the numeric organization ID) CL park, Self Access Center 5 - 6, Library Floor 1 - 4 etc.
$allow_manual_userid_entry = true; //ใส่ true หากต้องการให้ป้อน username ของผู้ใช้เองโดยไม่ต้องอ่านบัตร
$show_fines = true;
$show_available_holds = true;
$allow_email_receipts = true;
$display_php_errors = 'on'; //off or on
$hide_cursor_pointer = false; //hides default cursor pointer -should probably set to true on live self check
 
//========================== Logging =================================
/*
 use the query below to setup the mysql table (if you change the table name set
 the variable $log_table_name below equal to that new table name)
 
 CREATE TABLE `self_check_stats`
 (`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
 `location` varchar( 50 ) DEFAULT NULL ,
 `count` int( 11 ) NOT NULL DEFAULT '0',
 `sessions` int( 11 ) NOT NULL DEFAULT '0',
 `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
 PRIMARY KEY ( `id` ));
 
*/
//====================================================================
$use_mysql_logging = true; /* log your selfcheck checkout count by month? use the query above to set up the table */
$log_table_name = 'self_check_stats';
 
//mysql connection info (ignore this if you're not using mysql logging)
$dbhostname = "";
$database = "";
$dbusername = "";
$dbpassword = "";
 
//====================== SIP2 Responses ==============
/*
 GET YOUR SYSTEM'S RESPONSE MESSAGES BY ENTERING YOUR SIP2 CONNECTION INFO ABOVE THEN OPENING responses.php
 IN YOUR BROWSER-THEY MUST BE KEPT UP TO DATE!
 These are case INsensitive.
*/
//====================================================================
//$already_ckdout_to_you='Item already charged to this user'; //item already out to this borrower response
$already_ckdout_to_you = 'PASS[Check out item succeeded.]'; //item already out to this borrower response
 
//====================== Wording, SMTP, & Other Variables ==============
//$currency_symbol='฿';
$currency_symbol = NULL;
$due_date_format = 'j/n/Y'; //see http://php.net/manual/en/function.date.php for information on formatting dates
$inactivity_timeout = 40000; //time of inactivity before showing inactive prompt (in milliseconds)
$account_check_timeout = 20000; //time of inactivity after patron card scan before showing out of order page (in milliseconds)
 
//$patron_id_length=NULL; //length of patron barcode or other id (leave empty if this varies)
$patron_id_length = 14;
$enable_patron_password = true; //Enable Patron Password Check
 
$online_catalog_url = 'http://owpac.rmuti.ac.th'; /ใส่ URL ของ OPAC *leave blank if you don't have one or if your catalog does
 not allow renewals (this is for printing on the paper receipt and
 sending in the email receipt info about renewing online)*/
 
//smtp (for emailing receipts)
$smtp_host = '';
$smtp_authentication = false;
$smtp_username = '';
$smtp_pwd = '';
 
//wording
$library_name = 'แผนกงานห้องสมุด ฝ่ายวิทยบริการ';
$module_name = 'เครื่องยืมทรัพยากรสารสนเทศอัตโนมัติ'; //shows on pages/home.php and pages/checkout.php
$email_from_name = 'แผนกงานห้องสมุด'; //library's email name
$email_from_address = 'แผนกงานห้องสมุด ฝ่ายวิทยบริการ สำนักวิทยบริการและเทคโนโลยีสารสนเทศ'; //library's email address
$admin_emails = ''; //comma delimted list of email addresses that should be notified should the self-check go out of order
$email_subject = 'รายการยืมทรัพยากรสารสนเทศ เครื่องยืมทรัพยากรสารสนเทศอัตโนมัติ'; //subject of email receipt
$intro_screen_text = "ป้อนรหัสบาร์โค๊ดสมาชิก เพื่อเริ่มใช้งานระบบ !"; //shown on pages/home.php
$welcome_screen_text = 'สแกนบาร์โค๊ดทรัพยากรสารสนเทศ ที่ต้องการยืม'; //shown on includes/welcome.php
$welcome_screen_subtext = "(บาร์โค๊ดอาจอยู่ด้านในแผ่นทรัพยากรสารสนเทศ)";
$renewal_prompt_text = 'รายการทรัพยากรสารสนเทศนี้ถูกยืมแล้ว<br /> ต้องการยืมซ้ำหรือไม่ ?';
$out_of_order_head = 'ระบบขัดข้อง !'; //shown on pages/out_of_order.php
$out_of_order_text = 'กำลังดำเนินการแก้ใข กรุณาเข้าสู่ระบบใหม่ภายหลัง'; //shown on pages/out_of_order.php
 
//====================== Paper & Email Receipts ==============
/* add elements to or remove elements from the header & footer arrays below to manipulate that piece of the receipt.
the elements will appear on separate lines of the receipt in the order that you place them below */
$receipt_header[] = 'Checkout Receipt';
$receipt_header[] = $library_name;
$receipt_footer[] = 'Renew your items online:';
$receipt_footer[] = $online_catalog_url;
 
/*place the following in the order you want the elements to appear in the item list on the
paper and email receipts. remove (or comment out) any elements you don't want included.
element options include item_barcode, title, due_date, and call_number */
$receipt_item_list_elements[] = 'title';
$receipt_item_list_elements[] = 'call_number';
$receipt_item_list_elements[] = 'item_barcode';
$receipt_item_list_elements[] = 'due_date';
 
//========================= Sounds & Images ==========================
 //sounds
$error_sound = "sounds/error.mp3";
$welcome_sound = "sounds/welcome.mp3";
$note_sound = "sounds/note.mp3";
 
 //images (you need to uncomment one -and only one- line from each group).
/*
 Keep in mind these are not the image files names -they are just meant to trigger the showing
 of the types of images listed here. For further customization, images are loaded in the following files:
 pages/checkout.php , pages/home.php, and includes/welcome.php
*/
 
 //======= group 1: home page images of library card =======
//$card_image='kpl';
$card_image = 'barcoded'; //กรณีบัตรเป็น Barcode ให้ Uncomment ออก
//$card_image='magnetic';
 
 //======= group 2: home and checkout page images of book ==
$item_image = 'barcoded'; //กรณีบัตรเป็น Barcode ให้ Uncomment ออก
//$item_image='nonbarcoded';
 
//======= Jason Encoding File welcome.php =======
$cancle_button = 'ยกเลิก';
$thank_button = 'ขอบคุณที่ใช้บริการค่ะ';
$welcome_title = 'ยินดีต้อนรับ...';
//======================= Action Balloons =======================
/*
 
The following settings determine what types of materials will prompt the self check to issue an
action message (a short message accompanied by a beep sound) upon checkout. You may want borrowers to unlock the cases of
or desensitize certain types of items, for example, or give a reminder that a particular type of item has a
shorter checkout period than other items like it.
 
Each item that requires an action can have its action message triggered by 1) its item type OR 2) its permanent location.
 
Each action balloon requires 2 variables set up in the following format:
 
1) $action_balloon[item type OR permanent location]['action_message']=action message;
2) $action_balloon[item type OR permanent location]['trigger']='item type' OR 'permanent location' OR 'call number prefix';
 
2 examples:
$action_balloon['CD']['action_message']='Please place your CDs inside one of the plastic bags near this station';
$action_balloon['CD']['trigger']='permanent location';
 
$action_balloon['EXPRESS DVDS']['action_message']='Express DVDs checkout for 3 days';
$action_balloon['EXPRESS DVDS']['trigger']='item type';
 
*/
//======================================================================
$action_balloon_bg_color = '#f1cae1'; //background color for action balloons
//$action_balloon['CD']['action_message']='Please place your CDs inside one of the plastic bags near this station';
//$action_balloon['CD']['trigger']='permanent location';
 
//==================================== Allowed IPs =======================
/*
 list each allowed ip on a new line as $allowed_ip[]='IP';
 example: $allowed_ip[]='192.168.0.2';
 $allowed_ip[]='192.168.0.4';
*/
$allowed_ip[] = ''; //leave empty if you've already limited access to the self check via your server (Apache, IIS, etc.)
 
//==================================== Don't edit below this line =======================
if (!in_array($_SERVER['REMOTE_ADDR'],$allowed_ip) && !empty($allowed_ip[0])){
 exit;
}
ini_set('display_errors', $display_php_errors);

4.ทดสอบการเรียกใช้ ตามรูปแบบการใช้งานเว็บไซต์คือ http://servername หรือ ip address/folderที่ติดตั้ง PHP Self check/ เช่น ของผมก็คือ http://203.158.192.143/selfcheck เป็นต้น (อาจมีหน้าตาแปลกไปบ้างเพราะเป็น Code บางส่วนที่ปรับให้เข้ากับระบบและผู้ใช้ที่ผมทดสอบ) ฝั่ง Client

5. ทดสอบการใช้งานที่เครื่องลูกข่าย โดยใช้ Browser เปิดไปที่ URL ในข้อ 5 แล้วลองยืมทรัพยากร โดยการอ่านบัตรสมาชิกที่เครื่องลูกข่าย ป้อนรหัสผ่านของผู้ใช้(ถ้าระบบต้องการ) ซึ่งจะเป็น User/Password เดียวกับระบบ OPAC และลองยืมทรัพยากรตามขั้นตอนที่แนะนำบนหน้าจอสำหรับการทดลองยืม ดูได้จาก สาธิตการใช้งาน Open Source Self Check ได้เลยครับ แค่นี้ก็เรียบร้อยแล้วสำหรับการติดตั้ง Open Source Self Check กรณีบน Server

เนื่องจากบทความนี้ค่อนข้างยาว ผมขอยก การติดตั้ง แบบที่ 2. การติดตั้ง Open Source Self Check บนเครื่องคอมพิวเตอร์ลูกข่าย ไปไว้ในบทความหน้าละกันนะครับ รับรองบทความหน้า ไม่ยาวแล้วครับ