วันอาทิตย์ที่ 31 พฤษภาคม พ.ศ. 2563

Raspberry Pi 2 php5.6

If you have a Raspberry Pi 2 you will be have PHP 5.4 installed.
If you want to upgrade to PHP 5.6 or whatever is the latest version, you will have to download the source files, and compile the application.
This is not as difficult as it may sound.
In your Raspberry Pi SSH Terminal:
# Check the PHP version using the following command
php -v
# Get the PHP source
# First find the latest version number from the PHP download page: http://php.net/downloads.php
# Download the latest version either by downloading to your PC and then using ftp to save it back to the Raspberry Pi
# wget http://uk1.php.net/distributions/php-5.6.14.tar.bz2
# where 'uk1.php.net' is your to your nearest mirror. Find the mirror list here: http://php.net/mirrors.php.
# Once on the Raspberry Pi (the location does not really matter as you will delete the source files anyway) unpack using:
tar -xvjf php-5.6.14.tar.bz2
# Change directory to the source folder
cd php-5.6.14
# Find any updates
sudo apt-get update
# Get and install libxml2-dev which is a library that is used to manipulate xml files
sudo apt-get install libxml2-dev
# Do a configure
./configure
# If on the Raspberry Pi 2
make -j4
# Otherwise
make
# The process of compiling does take a long time on a Raspberry Pi - at least an hour for me.
# Install the application
sudo make install
# Reboot to make sure changes are effective
sudo shutdown - r now
# Check PHP version
php -v

# Delete the downloaded source files

วันพุธที่ 18 มีนาคม พ.ศ. 2563

์node JS to 443

ocation / {
          proxy_pass http://localhost:3000;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;

    }


cd /home/admin/conf/web/
nano domain.nginx.ssl.conf
nano domain.nginx.conf

วันพุธที่ 12 กุมภาพันธ์ พ.ศ. 2563

ประโยชน์จาก LINEBOT และ Google Apps Script

ใช้ประโยชน์จาก LINEBOT

ประโยชน์จาก LINEBOT และ Google Apps Script

ให้ Linebot ตอบคำถามแก้ไขปัญหาเบื้องต้น พร้อมบันทึก LogUserID ลดงานฝ่าย Support ลงได้
1.) เตรียมข้อมูลใน Sheet ( Faq ) พร้อมคำตอบลงในแผ่นงาน


2.) เตรียมข้อมูลใน Sheet ( Maybe ) พร้อมคำตอบลงในแผ่นงาน

3.) เตรียมแผ่นงาน ( LogUserID ) เพื่อใช้สำหรับบันทึกข้อมูลการใช้งานผู้ใช้ Line

4.) เมื่อเตรียมข้อมูลแล้วไปที่ "เครื่องมือ" เลือก "<>โปรแกรมแก้ไขสคริปต์"

5.) Copy Code ด้านล่างโดยแก้ไข Token และ Sheet เป็นของตัวเอง


// Copy เฉพาะ ID ของ Sheet
var SHEET_ID = 'ID Sheet';
// ชื่อ Sheet 1
var SHEET_NAME = 'Faq';
// ชื่อ Sheet 2
var SHEET_NAME_MAYBE = 'Maybe';

// LINE Message API
var ACCESS_TOKEN = 'Token';
var PUSH = "https://api.line.me/v2/bot/message/push";
var REPLY = "https://api.line.me/v2/bot/message/reply";
var PROFILE = "https://api.line.me/v2/profile";
// Post
function doPost(e) {
  var json = JSON.parse(e.postData.contents);
  reply(json);
}
// Get
function doGet(e) {
    return ContentService.createTextOutput("Success");
}
// Reply
function reply(data) {
  var lineUserId = data.events[0].source.userId;
  var postMsg    = data.events[0].message.text;
  var replyToken = data.events[0].replyToken;
  var action    = data.events[0].message.action;
  // บันทึกคำค้นหาและ userId สำหรับการบันทึก
  // debug(postMsg, lineUserId);
  debug(action, lineUserId);
  // ค้นหาคำตอบสำหรับคำค้นหาจาก Sheet
  var answers = findResponseArray(postMsg);
  // สร้างข้อความคำตอบ
  var replyText = '「' + postMsg + '」นี่คือคำแนะนำ ลองทำตามดูก่อน';
  // คำถาม ขึ้นอยู่กับมีหรือไม่มีคำตอบ
  if (answers.length === 0) {
    // ตรวจสอบ "คำค้นหาที่คล้ายกัน"
    var mayBeWord = findMaybe(postMsg);
    if (typeof mayBeWord === "undefined") {
      // แก้ไข คำถาม / ปัญหาที่อยากหา เมื่อไม่มีคำตอบ
      sendMessage(replyToken, 'ไม่พบคำถามที่อยู่ในระบบ ลองถามคำถามใหม่');      
    } else {
      sendMayBe(replyToken, mayBeWord);
    }
  } else {
    // การสร้างข้อความเมื่อมีคำตอบ
    answers.forEach(function(answer) {
      replyText = replyText + "\n\n==↓↓==\n\nปัญหา:" + answer.key + "\n\nการแก้ไข:" + answer.value;
    });

    // ตัดคำหากเกิน 500 ตัวอักษร
    if (replyText.length > 500) {
      replyText = replyText.slice(0,500) + "……\n\n==↓↓==\n\nคำถามนั้นมากกว่าจำนวนตัวอักษรที่กำหนด โปรด จำกัด รายละเอียดคำค้นหาให้แคบลง";
    }
    // การส่งข้อความ API
    sendMessage(replyToken, replyText);
  }
}

// รับข้อมูลจาก Sheet 1
function getData() {
  var sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName(SHEET_NAME);
  var data = sheet.getDataRange().getValues();
  return data.map(function(row) { return {key: row[0], value: row[1], type: row[2]}; });
}

// รับข้อมูลจาก Sheet 2
function getMayBeData() {
  var sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName(SHEET_NAME_MAYBE);
  var data = sheet.getDataRange().getValues();
  return data.map(function(row) { return {key: row[0], value: row[1], type: row[2]}; });
}

// ส่งคืนอาร์เรย์ของคำตอบสำหรับเซลล์ที่มีคำที่ตรงกัน
function findResponseArray(word) {
  // พื้นที่การค้นหา
  word = word.replace(' ',' ');
  // แบ่งออกเป็นอาร์เรย์สำหรับแต่ละคำ
  var wordArray = word.split(' ');
  return getData().reduce(function(memo, row) {
    // ไม่ว่าจะเป็นค่ารวม
    if (row.value) {
      // และไม่ว่าจะเป็นคำทั้งหมดจะรวมอยู่ในการค้นหา
      var matchCnt = 0;
      wordArray.forEach(function(wordUnit) {
        // ถ้ามีคำตอบที่ถูกต้อง
        if (row.key.indexOf(wordUnit) > -1) {
          matchCnt = matchCnt + 1;
        }
      });
      if (wordArray.length === matchCnt) {
        memo.push(row);
      }
    }
    return memo;
  }, []) || [];
}

// ส่งคืนคำตอบ "บางครั้ง" ของเซลล์ที่จับคู่คำ
function findMaybe(word) {
  return getMayBeData().reduce(function(memo, row) { return memo || (row.key === word && row.value); }, false) || undefined;
}

// การส่ง API ในรูปแบบภาพ
function sendMessageImage(replyToken, imageUrl) {
  var postData = {
    "replyToken" : replyToken,
    "messages" : [
      {
        "type": "image",
        "originalContentUrl": imageUrl
      }
    ]
  };
  return postMessage(postData);
}

function sendMessage(replyToken, replyText) {
  var postData = {
    "replyToken" : replyToken,
    "messages" : [
      {
        "type" : "text",
        "text" : replyText
      }
    ]
  };
  return postMessage(postData);
}

function sendMayBe(replyToken, mayBeWord) {
  var postData = {
    "replyToken" : replyToken,
    "messages" : [
      {
        "type" : "template",
        "altText" : "คำถามของคุณหมายความว่า่" + mayBeWord + "」แบบนี้หรือไม่?",
        "template": {
          "type": "confirm",
          "actions": [
            {
                "type":"postback",
                "label":"Yes",
                "data":"action=detail",
            },
            {
                "type": "message",
                "label": "No",
                "text": "ไม่มันไม่ใช่"
            }
          ],
          "text": "ไม่พบคำตอบ บางทีคำค้นหาคือ「" + mayBeWord + "」แบบนี้หรือไม่?"
        }

      }
    ]
  };
  return postMessage(postData);
}

function postMessage(postData) {
  var headers = {
    "Content-Type" : "application/json; charset=UTF-8",
    "Authorization" : "Bearer " + ACCESS_TOKEN
  };
  var options = {
    "method" : "POST",
    "headers" : headers,
    "payload" : JSON.stringify(postData)
  };
  return UrlFetchApp.fetch(REPLY, options);    
}

function getUserDisplayName(userId) {
  var url = 'https://api.line.me/v2/bot/profile/' + userId;
  var userProfile = UrlFetchApp.fetch(url,{
    'headers': {
      'Authorization' :  'Bearer ' + ACCESS_TOKEN,
    },
  })
  return JSON.parse(userProfile).displayName;
}

// userId
function lineUserId(userId) {
  var sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName('userId');
  sheet.appendRow([userId]);
}

// debug
function debug(text, userId) {
  var sheet = SpreadsheetApp.openById(SHEET_ID).getSheetByName('LogUserID');
  var date = new Date();
  var userName = getUserDisplayName(userId);
  sheet.appendRow([userId, userName, text, Utilities.formatDate( date, 'Asia/Bangkok', 'yyyy-MM-dd HH:mm:ss')]);
}
 

6.) เมื่อทำการ Save และ Allow Permissions เสร็จเรียบร้อยแล้ว มาลองคุยกับบอท

วันพฤหัสบดีที่ 14 พฤศจิกายน พ.ศ. 2562

Tocono Hotel Lock

การสำรองฐานข้อมูลและการติดตั้งโปรแกรม Tocono Hotel Lock

ทางบริษัทฯ ขอแนะนำให้ลูกค้าทำการสำรองข้อมูลเป็นประจำ โดยไฟล์ฐานข้อมูลและไฟล์ที่เกี่ยวข้องมี 2 ไฟล์ที่สำคัญคือ CardLock.mdb และ System.ini
ในกรณีที่คอมพิวเตอร์เกิดความเสียหาย ลูกค้าสามารถที่จะติดตั้งโปรแกรมได้ใหม่และสามารถที่จะนำฐานข้อมูลเดิมมาใช้ได้ต่อเนื่อง
วิธีการสำรองฐานข้อมูล
  1. ลูกค้าเปิด Hidden Files ก่อน เพราะไฟล์ทั้ง 2 จะถูกซ่อนไว้เพื่อป้องกันการลบโดยบังเอิญ
  2. ไปที่โฟลเดอร์ C:\User\Computer Name\App Data\Local\Virtual Store\Program Files (x86)\Tocono Hotel Lock\ หรือ C:\Program Files (x86)\Tocono Hotel Lock\ ซึ่งไฟล์ทั้ง 2 จะอยู่ที่โฟลเดอร์ใดโฟลเดอร์หนึ่ง
การติดตั้งโปรแกรม
  1. รัน Setup.exe แล้วทำตามขั้นตอนการติดตั้งโปรแกรมจนเสร็จ
  2. เปิดโปรแกรม Tocono Hotel Lock 1 ครั้งหลังจากติดตั้งเสร็จเรียบร้อยแล้ว
  3. ปิดโปรแกรม Tocono Hotel Lock
  4. คัดลอกไฟล์ CardLock.mdb และ System.ini, แล้วนำไปวางไว้ที่โฟลเดอร์ C:\User\Computer Name\App Data\Local\Virtual Store\Program Files (x86)\Tocono Hotel Lock\ หรือ C:\Program Files (x86)\Tocono Hotel Lock\
  5. เสร็จขั้นตอน

วันอังคารที่ 29 ตุลาคม พ.ศ. 2562

วิธีการติดตั้ง SSL Certificate บน Xampp Apache

วิธีการติดตั้ง SSL Certificate บน Xampp Apache Window Server

วิธีการทำ Redirect HTTP to HTTPS โดย .htaccess หรือ php

วิธีการทำ Redirect HTTP to HTTPS โดย .htaccess หรือ php


วันอาทิตย์ที่ 15 กันยายน พ.ศ. 2562

router cat internet

user= admin@tec
pass= adminXXXX   ( XXXX คือ 4 ตัวท้ายของ mac address ของเราเตอร์ดูได้จากหลังอุปกรณ์ *ถ้ามีภาษาอังกฤษให้เป็นพิมพ์ใหญ่ทั้งหมด* )