ผลต่างระหว่างรุ่นของ "คู่มือการพัฒนาซอฟต์แวร์บนเว็บบราวซ์เซอร์ให้รองรับ UA ด้วยภาษา PHP/en"

จาก Wiki_EAI
ไปยังการนำทาง ไปยังการค้นหา
FuzzyBot (คุย | ส่วนร่วม)
กำลังอัพเดตเพื่อทำให้ตรงกันกับรุ่นปรับปรุงใหม่ของหน้่าโค้ดหลัก
FuzzyBot (คุย | ส่วนร่วม)
กำลังอัพเดตเพื่อทำให้ตรงกันกับรุ่นปรับปรุงใหม่ของหน้่าโค้ดหลัก
บรรทัดที่ 8: บรรทัดที่ 8:
  # user: userX
  # user: userX
  # pass: eaiuserX
  # pass: eaiuserX
User/Pass สำหรับเข้าเซิร์ฟเวอร์ใน workshop  [[https://คน.ไทย/วิกิ/list-user-ws.jpg User]]
# HOST: https://ws.kon.in.th
# DB: https://ws.kon.in.th/phpmyadmin/
# user: userX
# pass: eaiuserX
-->


== Preparing to Support UA in PHP ==
== Preparing to Support UA in PHP ==
บรรทัดที่ 35: บรรทัดที่ 43:
== Developing Applications to Support UA in PHP ==
== Developing Applications to Support UA in PHP ==


<div class="mw-translate-fuzzy">
=== [[Cereate database that could handle IDN and EAI]] ===
=== [[Cereate database that could handle IDN and EAI]] ===
  '''# CREATE TABLE IF NOT EXISTS accounts ( '''
  '''# CREATE TABLE IF NOT EXISTS accounts ( '''
บรรทัดที่ 44: บรรทัดที่ 53:
  '''  PRIMARY KEY (`id`)
  '''  PRIMARY KEY (`id`)
  ''' ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;'''
  ''' ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;'''
</div>


<div class="mw-translate-fuzzy">
=== [[modify the registration system to be able to accept EAI email address]] ===
=== [[modify the registration system to be able to accept EAI email address]] ===
modify register.html fronm
modify register.html fronm
  '''# <input type=&quot;email&quot; name=&quot;email&quot; placeholder=&quot;Email&quot; id=&quot;email&quot; required>
  '''# <input type=&quot;email&quot; name=&quot;email&quot; placeholder=&quot;Email&quot; id=&quot;email&quot; required>
</div>


<div class="mw-translate-fuzzy">
to
to
  '''# <input type=[[&quot;text&quot;]] name=&quot;email&quot; placeholder=&quot;Email&quot; id=&quot;email&quot; required>
  '''# <input type=[[&quot;text&quot;]] name=&quot;email&quot; placeholder=&quot;Email&quot; id=&quot;email&quot; required>
</div>


<div class="mw-translate-fuzzy">
=== [[modifythe registration system to be able to validate EAI email address]] ===
=== [[modifythe registration system to be able to validate EAI email address]] ===
modify register.php from  
modify register.php from  
บรรทัดที่ 57: บรรทัดที่ 72:
  '''
      exit(&apos;Email is not valid!&apos;);
  
  '''
      exit(&apos;Email is not valid!&apos;);
  
  '''  }
  '''  }
</div>


<div class="mw-translate-fuzzy">
to
to
  '''# if (preg_match(&apos;/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u&apos;, $_POST[&apos;email&apos;]) == 0) {
  '''# if (preg_match(&apos;/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u&apos;, $_POST[&apos;email&apos;]) == 0) {
  '''      exit(&apos;Email is not valid!&apos;);
  
  '''      exit(&apos;Email is not valid!&apos;);
  
  ''' }
  ''' }
</div>


<div class="mw-translate-fuzzy">
=== [[modify the registration system to be able to send EAI email with PHPMailer]] ===
=== [[modify the registration system to be able to send EAI email with PHPMailer]] ===
modify PHPMailer/src/PHPMailer.php from
modify PHPMailer/src/PHPMailer.php from
บรรทัดที่ 68: บรรทัดที่ 87:
  '''  default:
  '''  default:
  '''  return filter_var($address, FILTER_VALIDATE_EMAIL) !== false;
  '''  return filter_var($address, FILTER_VALIDATE_EMAIL) !== false;
</div>


<div class="mw-translate-fuzzy">
to
to
  '''# case &apos;php&apos;:  
  '''# case &apos;php&apos;:  
  '''  default:  
  '''  default:  
  '''  return (bool) preg_match(&quot;/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u&quot;, $address);
  '''  return (bool) preg_match(&quot;/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u&quot;, $address);
</div>
<div class="mw-translate-fuzzy">
[[Category: EAI]]
</div>


<div lang="th" dir="ltr" class="mw-content-ltr">
[[Category: EAI]]
[[Category: EAI]]
</div>

รุ่นแก้ไขเมื่อ 02:23, 3 สิงหาคม 2564

<languages/> This manual is a guideline for UA web application development using PHP. The application will be able to accept, validate and process Thai IDN and Thai EAI correctly.


User/Pass for accessing server in the workshop [User]

# HOST: https://ws.kon.in.th
# DB: https://ws.kon.in.th/phpmyadmin/
# user: userX
# pass: eaiuserX

User/Pass สำหรับเข้าเซิร์ฟเวอร์ใน workshop [User]

# HOST: https://ws.kon.in.th
# DB: https://ws.kon.in.th/phpmyadmin/
# user: userX
# pass: eaiuserX

-->

Preparing to Support UA in PHP

  1. Database system
    • MySQL
    • PHPMyAdmin
  2. Web application
    • Registration system
    • Login system
    • User profile system
  3. Email system
    • PHPMailer

To be used software

  1. Filezilla [Win] [Mac]
  2. Web Browser e.g. Firefox, Chrome, Safari
  3. Text Editor (Code Editor) e.g. Notepad, Atom

Application Architecture

Developing Applications to Support UA in PHP

# CREATE TABLE IF NOT EXISTS accounts ( 
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `username` varchar(50) NOT NULL,
   `password` varchar(255) NOT NULL,
   `email` varchar(100) NOT NULL,
   `activation_code` varchar(50) DEFAULT '',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

modify register.html fronm

# <input type="email" name="email" placeholder="Email" id="email" required>

to

# <input type="text" name="email" placeholder="Email" id="email" required>

modify register.php from

# if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { 

      exit('Email is not valid!');
 
  }

to

# if (preg_match('/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u', $_POST['email']) == 0) {
      exit('Email is not valid!');
 
 }

modify PHPMailer/src/PHPMailer.php from

# case 'php': 
  default:
  return filter_var($address, FILTER_VALIDATE_EMAIL) !== false;

to

# case 'php': 
  default: 
  return (bool) preg_match("/^[ก-๙a-zA-Z0-9_+&*-]+(?:\.[ก-๙a-zA-Z0-9_+&*-]+)*@(?:[ก-๙a-zA-Z0-9-]+\.)+[ก-๙a-zA-Z]{2,16}$/u", $address);