Showing posts with label phpbb3. Show all posts
Showing posts with label phpbb3. Show all posts

10/03/2024

PHP : Code get all supervisor to Checkbox.

 PHP : Code get all supervisor to Checkbox.

$SQL="SELECT EmpEmail, PositionCalled FROM sci._employees ";
$SQL.=" LEFT JOIN sci._positions ON _positions.PositionCode=_employees.PositionCode";
$SQL.=" LEFT JOIN sci._sections ON _sections.SectionId=_positions.SectionId";
$SQL.=" LEFT JOIN sci._departs ON _departs.DepartId=_sections.DepartId";
$SQL.=" WHERE _employees.isEnabled = 'Y'";
$SQL.=" AND sci._employees.LevelPriority ='6'";
$SQL.=" ORDER BY _departs.DepartId,EmpId";
$NumRows=$myDB->Query($SQL);
 
$SupervisorSelect ="<b>หน.งาน</b><br><table border='0' width='100%'><tr>";
$i = 0;
$mod = 0;
while($row=$myDB->GetRow()){
    $mod = $i % 8; //### แบ่งแถวล่ะกี่ Checkbox
    if($mod == 0 && $i>0){
        $SupervisorSelect.="</tr><tr>";
    }
    $SupervisorSelect.="<td><input type='checkbox' name='SupervisorList[]' value='".$row["EmpEmail"]."'>".tis2utf8($row["PositionCalled"])."</td>";
    $i++;
}
$SupervisorSelect.="</table>";

5/09/2020

Code PHPBB3 Post Reply Topic.

Code PHPBB3 Post Reply Topic.
ถ้า Submit Post Action ไปไฟล์อื่น ต้องใส่ enctype="multipart/form-data" ด้วย
แต่กรณีนี้จะส่งผ่าน Java ไม่ต้อง Reload หน้า Web Code ดังนี้
HTML
  1. <div id="dialog-edit-upload" title="Upload รายงานความคืบหน้า Project หรือ PMC" style="display:none;">
  2.     <form method="POST" enctype="multipart/form-data" id="myform">
  3.         <div>Upload pdf ไฟล์ เพื่อแนบรายงานความคืบหน้าแต่ละเดือน</div>
  4.         <table width='100%' border='0'>
  5.         <tr>
  6.             <td nowrap>ประจำเดือน : </td>
  7.             <td><input name='P_Month' id='P_Month_field' size='3' readonly="readonly"><input type="hidden" name='PHPBBID' id='PHPBBID_field'></td>
  8.         </tr>      
  9.         <tr>
  10.             <td nowrap>Upload PDF ไฟล์ : </td>
  11.             <td align='left' class='default'><input type="file" name="P_FILE_MONTH" id="P_FILE_MONTH_ID"></td>
  12.         </tr>                                                  
  13.         </table>   
  14.     </form>
  15. </div>


Java
  1. function editUpload(ACTION){
  2.     var str = ACTION;
  3.     var ActionArray = str.split(',');
  4.    
  5.     $('#P_Month_field').val('');
  6.     $('#P_FILE_MONTH_ID').val('');
  7.     $('#PHPBBID_field').val('');
  8.    
  9.     $('#PHPBBID_field').val(ActionArray[0]);
  10.     $('#P_Month_field').val(ActionArray[1]);
  11.    
  12.     //var target = "project_upload.php?ACTION=" + ActionArray[0] + ',' + ActionArray[1];
  13.     var target = "project_upload.php";
  14.     $( "#dialog-edit-upload" ).dialog({
  15.         resizable: false,
  16.         width:420,
  17.         height:250,
  18.         modal: true,   
  19.         buttons: {
  20.             "Yes": function() {            
  21.             //$('#PHPBBID_field').val() ;
  22.             // Get form
  23.             var form = $('#myform')[0];
  24.      
  25.            // Create an FormData object
  26.             var data = new FormData(form);
  27.      
  28.            // If you want to add an extra field for the FormData
  29.            //data.append("CustomField", "This is some extra data, testing");
  30.      
  31.            // disabled the submit button
  32.             //$("#btnSubmit").prop("disabled", true);
  33.      
  34.             $.ajax({
  35.                 type: "POST",
  36.                 enctype: 'multipart/form-data',
  37.                 url: target,
  38.                 data: data,
  39.                 processData: false,
  40.                 contentType: false,
  41.                 cache: false,
  42.                 timeout: 800000,
  43.                     success: function(ret) {
  44.                         //alert("บันทึกข้อมูลสำเร็จ !");
  45.                         if(ret == 'OK'){
  46.                             alert("บันทึกข้อมูลสำเร็จ ");                      
  47.                         } else {
  48.                             alert("บันทึกข้อมูลไม่สำเร็จ กรุณาตรวจสอบ ! ");   
  49.                         }
  50.                         $('#P_Month_field').val('');
  51.                         $('#P_FILE_MONTH_ID').val('');
  52.                         $('#PHPBBID_field').val('');
  53.                     },
  54.                 });
  55.                 $( this ).dialog( "close" );
  56.           },
  57.             Cancel: function() {
  58.                 $( this ).dialog( "close" );
  59.             }
  60.         }   
  61.     });
  62. }


PHP
  1. if(!empty($PHPBBID)){      
  2.         include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
  3.         include($phpbb_root_path . 'includes/message_parser.' . $phpEx);
  4.                
  5.         $message_parser = new parse_message();
  6.         $message_parser->parse_attachments('P_FILE_MONTH', 'post', 139, true, false, false);
  7.         //$message_parser->parse_attachments('P_FILE_MONTH', 'post', $NumberForum, true, false, false);
  8.        
  9.         //function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false);
  10.         //$upload_parser = new parse_upload();
  11.         //$upload_parser -> upload_attachment('P_FILE_MONTH', 18429, $local = false, $local_storage = '', $is_message = false, $local_filedata = false);
  12.        
  13.         $my_subject = "รายงานความคืบหน้าเดือน $P_Month";
  14.         $my_text = "รายงานความคืบหน้าเดือน $P_Month";
  15.         $poll = $uid = $bitfield = $options = '';
  16.         generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
  17.         generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);      
  18.        
  19.         $data = array(
  20.             'forum_id'      => 139,
  21.             'topic_id'      => $PHPBBID,
  22.             //'topic_id'      => 18429,
  23.  
  24.             'icon_id'       => false,
  25.  
  26.             'enable_bbcode'     => true,
  27.             'enable_smilies'    => true,
  28.             'enable_urls'       => true,
  29.             'enable_sig'        => true,
  30.  
  31.             'message'       => $my_text,
  32.             'message_md5'   => md5($my_text),
  33.                        
  34.             'bbcode_bitfield'   => $bitfield,
  35.             'bbcode_uid'        => $uid,
  36.  
  37.             'post_edit_locked'  => 0,
  38.             'topic_title'       => $my_subject,
  39.             'notify_set'        => false,
  40.             'notify'            => false,
  41.             'post_time'         => 0,
  42.             'forum_name'        => '',
  43.             'enable_indexing'   => true,
  44.            
  45.             'attachment_data' => $message_parser->attachment_data,
  46.             'filename_data' => $message_parser->filename_data
  47.                
  48.         );
  49.        
  50.         submit_post('reply', $my_subject, '', POST_NORMAL, $poll, $data);      
  51.        
  52.         echo "OK";
  53.     } else {
  54.         echo "ERROR";   
  55.     }

11/25/2019

PHPBB3 : Install PHPBB3 V 3.0.12 On Ubuntu 18.04.3 และ Upgrade Version เป็น 3.0.14 รุ่นสุดท้าย

PHPBB3 : Install PHPBB3 V 3.0.12 On Ubuntu 18.04.3 และ Upgrade Version เป็น 3.0.14 รุ่นสุดท้าย
**** ไป Version 3.1 หรือ 3.2 ไม่ได้ เนื่องจาก ***
จาก 3.0 ไป 3.1 หรือ 3.2 ไม่ได้
1. MODs for 3.0.x are incompatible with 3.1.x and their functionality will be removed in the update process. Mod ที่จำเป็นต้องใช้ Blog Mod จะใช้ไม่ได้
2. Styles for 3.0.x cannot be installed or used on 3.1.x. Styles Template ไม่เข้ากัน
https://www.phpbb.com/community/viewtopic.php?t=2398876
https://www.phpbb.com/community/viewtopic.php?t=2402101

3. พบปัญหา PHP7 ถ้าจะใช้ Version 3.0 จะใช้ไม่ได้มี Bug
ถ้าใช้ PHP7.2 ไม่รองรับ 3.0 ต้อง 3.2 ถึงจะรองรับ PHP7
https://www.phpbb.com/customise/db/exte ... pic/162021
https://www.phpbb.com/community/viewtopic.php?t=2353436
https://www.phpbb.com/community/viewtop ... &t=2316556

Blog ไม่ขึ้น เมื่อใช้ที่ Version 3.0.12
เมื่อ Update เป็น 3.0.14 Blog ขึ้นแต่มี Error preg_replace() ใช้ไม่ได้
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 496: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4760: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4763: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3887)


ติดตั้ง Ubunt 18.04 และ PHPBB3 Version 3.0.12 เพื่อ Update เป็น 3.0.14
1. install Ubuntu 18.04.3 ต่อวง 0 เพื่อให้ได้ DHCP แล้วค่อยไปแก้ Network เป็น วง 2
2. copy config เดิมไว้ก่อน
  1. cp /etc/netplan/50-cloud-init.yaml 50-cloud-init.yaml.Backup
3. แก้ Network Fix IP เป็นวง 2
  1. nano /etc/netplan/50-cloud-init.yaml

  1. network:
  2.    version: 2
  3.    renderer: networkd
  4.    ethernets:
  5.       ens160:
  6.          addresses: [192.168.2.114/24]
  7.          gateway4: 192.168.2.2
  8.          nameservers:
  9.             addresses: [8.8.8.8,8.8.4.4,192.168.2.2]

4. Run netplan apply หรือ reboot
5. แก้ apt.conf
  1. nano /etc/apt/apt.conf
Acquire::http { Proxy "http://192.168.2.106:9999"; };
บาง update ไม่ได้ไม่มี Sources ใน 2.106 ให้ปิด apt.conf ไว้ แล้ว update upgrade ใหม่

6. Up และ Set locale
  1. apt-get update
  2. apt-get upgrade
  3. locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8

7. Set time zome
  1. sudo timedatectl set-timezone Asia/Bangkok

ดู Time zone
  1. cat /etc/timezone

8. ติดตั้ง ntp
apt install ntp
nano /etc/ntp.conf
เพิ่ม
pool 192.168.2.2
  1. /etc/init.d/ntp restart
  2. ntpq -pn

ดูเวลาที่ sync มา
  1. date

9. สำคัญ ต้องติดตั้ง php5.6 เพื่อใช้งานจะได้ไม่มีปัญหา ตาม Blog
blog.php?u=3&b=1612

10. Database
  1. sudo apt-get install mysql-server


11. Creating phpBB Database and User
  1. sudo mysql -u root -p

ใส่รหัส mysql
เปลี่ยนรหัส root ถ้าจะใช้ root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxx';

หรือ สร้าง user ใหม่
Create user 'sa'@'localhost' IDENTIFIED BY 'xxxxx';
  1. flush privileges;
  2. exit;


12. ติดตั้ง Phpmyadmin
  1. apt-get install phpmyadmin

เลือก apache
จะสร้าง user phpmyadmin ให้
ใส่รหัส 2 ครั้ง
ลองเข้า
192.168.2.114/phpmyadmin

ด้วย user root ในข้อ 11 หรือ user phpmyadmin ก็ได้

13. นำไฟล์ phpbb3_3.0.12 เข้าเครื่อง download มาหรือ wget มา หรือลง ftp เอาก็ได้
ในไฟล์ไปที่ www แล้วแตกไฟล์

14. ติดตั้งตามขึ้นตอนข้อที่ 19.
https://intranet.sci.com/blog.php?u=281&b=1750

15. จะเข้า Ldap ไม่ได้ จะเป็นหน้า ขาว Bug phpbb3
ดู log จะพบ
  1. tail -f /var/log/apache2/error.log
[Sat Nov 23 10:03:57.894290 2019] [:error] [pid 4332] [client 192.168.0.244:49572] PHP Fatal error: Cannot redeclare ldap_escape() in /var/www/html/includes/auth/auth_ldap.php on line 300, referer: http://192.168.2.114/adm/index.php?sid= ... 215f59d847

วิธีแก้

แก้ไฟล์ auth_ldap.php อยู่ใน Floder includes
/**
* Escapes an LDAP AttributeValue
*/
if (!function_exists('ldap_escape'))
{
function ldap_escape($string)
{
return str_replace(array('*', '\\', '(', ')'), array('\\*', '\\\\', '\\(', '\\)'), $string);
}
}

https://www.phpbb.com/community/viewtopic.php?t=2263381

16. ใส่ข้อมูล ldap แล้วไม่ผ่าน Error
Information
Could not find a login identity for admin.
ชื่ออื่นจะไม่ผ่าน login admin ต้องใช้ user administrator เท่านั้น
Information
The specified e-mail attribute does not exist.
ใส่ mail ไม่ผ่าน ไม่ต้องใส่ ถึงจะผ่าน
17. ทดลอง login user domain
18. นำ Database เก่ามา restore database sci_phpbb
จะเอาเข้าไม่ได้เพราะ file ใหญ่
ต้องแก้
  1. nano /etc/php/5.6/apache2/php.ini
แก้ 3 ค่า
upload_max_filesize = 50M
post_max_size = 50M
max_file_uploads = 50
restart apache
  1. /etc/init.d/apache2 restart
สร้าง database sci_phpbb แล้วนำ database เก่ามา Restore

19. ทดลอง copy file จากเครื่องเดิม ยกเว้น sci, file, _install_ ทดลองก่อนยังไม่ต้องเอามาเพราะไฟล์พวกนี้ใหญ่และเยอะ
copy inculde ต้องแก้ auth_ldap.php ตามด้านบนข้อ 15 ด้วย ไม่งั่นจะจอขาว
เอาไฟล์จากเครื่องจริงมาทับ

20. ทดลองเข้าดูจะต้องเข้าได้ก่อน และ Login ได้ แต่เมนูด้านข้างจะไม่มี
ต้อง เข้า ACP ไป Restart Template และ Teme ก่อน ข้อมูลต่าง ๆ Menu Link Blog ก็จะกลับมา พร้อมใช้งาน
ถ้ามีหน้าขาวว่างปล่างต้องดู log ว่ามี Error อะไร

21. Step Upgrade 3.0.12 --> 3.0.14
1. แตกไฟล์ 3.0.14 full ที่ Download มา https://download.phpbb.com/pub/release/3.0/3.0.14/
2. นำ Floder install ไปว่างไว้ใน /var/www/html (หรือ Floder อื่น Root ของ Apache และกำหนด สิทธ์ www-data และ 775)
3. เข้า 192.168.2.114/install/database_update.php
4. ลบหรือเปลี่ยนชื่อ install folder

21. สร้าง Database และนำ Database มา restore database sci และ อื่นๆ ที่จะใช้ แล้วค่อยทดลอง copy ใน Folder sci มาจะนาน
และ copy file มาด้วย
เสร็จขึ้นตอนการ Update ทดลอง ดู Menu ต่าง ๆ อาจจะมี Error ค่อยแก้



PHPBB3 : Install PHPBB3 V3.2.8 On Ubuntu 18.04.3

PHPBB3 : Install PHPBB3 V3.2.8 On Ubuntu 18.04.3
1. install Ubuntu 18.04.3 ต่อวง 0 เพื่อให้ได้ DHCP แล้วค่อยไปแก้ Network เป็น วง 2
2. copy config เดิมไว้ก่อน
  1. cp /etc/netplan/50-cloud-init.yaml 50-cloud-init.yaml.Backup
3. แก้ Network Fix IP เป็นวง 2
  1. nano /etc/netplan/50-cloud-init.yaml
  1. network:
  2.    version: 2
  3.    renderer: networkd
  4.    ethernets:
  5.       ens160:
  6.          addresses: [192.168.2.113/24]
  7.          gateway4: 192.168.2.2
  8.          nameservers:
  9.             addresses: [8.8.8.8,8.8.4.4,192.168.2.2]

4. Run netplan apply หรือ reboot
5. แก้ apt.conf
  1. nano /etc/apt/apt.conf
Acquire::http { Proxy "http://192.168.2.106:9999"; };
บาง update ไม่ได้ไม่มี Sources ใน 2.106 ให้ปิด apt.conf ไว้ แล้ว update upgrade ใหม่

6. Up และ Set locale
  1. apt-get update
  2. apt-get upgrade
  3. locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8

7. Set time zome
  1. sudo timedatectl set-timezone Asia/Bangkok
ดู Time zone
  1. cat /etc/timezone
8. ติดตั้ง ntp
apt install ntp
nano /etc/ntp.conf
เพิ่ม
pool 192.168.2.2
  1. /etc/init.d/ntp restart
  2. ntpq -pn
ดูเวลาที่ sync มา
  1. date
9. ติดตั้งโปรแกรมที่ต้องใช้
https://hostadvice.com/how-to/how-to-in ... ed-server/
  1. sudo apt-get update
  2. sudo apt-get install apache2

10. Database
  1. sudo apt-get install mysql-server

11. Creating phpBB Database and User
  1. sudo mysql -u root -p

ใส่รหัส mysql
เปลี่ยนรหัส root ถ้าจะใช้ root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxx';

หรือ สร้าง user ใหม่
Create user 'sa'@'localhost' IDENTIFIED BY 'xxxxx';

  1. flush privileges;
  2. exit;

12. ติดตั้ง Phpmyadmin
  1. apt-get install phpmyadmin

เลือก apache
จะสร้าง user phpmyadmin ให้
ใส่รหัส 2 ครั้ง
ลองเข้า
192.168.2.113/phpmyadmin
ด้วย user root ในข้อ 11 หรือ user phpmyadmin ก็ได้
Bug php Error สีแดง วิธีแก้
https://intranet.sci.com/blog.php?u=281&b=1751

13. ติดตั้ง PHP และโปรแกรมอื่น ๆที่จะใช้
  1. Installing PHP
  2. sudo apt-get install php
  3. sudo apt-get install libapache2-mod-php php-curl php-json php-cgi php-xml php-mysq1

14. Installing phpBB software
download เอาไฟล์ไปใส่เครื่อง
https://www.phpbb.com/downloads/
หรือ wget
15. แตกไฟล์ ย้ายไฟล์ไปไว้ที่ www
  1. cd /tmp
  2. apt-get install unzip
  3. unzip phpBB-3.2.8.zip
  4. cp -R phpBB3/* /var/www/html
  5. cd /var/www/
  6. mv index.html index.html.old
16. เปลี่ยนสิทธิ์
  1. chown -R www-data:www-data /var/www/html/
  2. chmod 660 /var/www/html/images/avatars/upload
  3. chmod 660 /var/www/html/config.php
  4. chmod 770 /var/www/html/store/
  5. chmod 770 /var/www/html/cache
  6. chmod 770 /var/www/html/files
17. ติดตั้ง php ldap
  1. apt-get install php-ldap
  2. /etc/init.d/apapche2 restart

18. สร้าง database phpbb3 ที่ phpmyadmin ในข้อ 12.
19. เข้า เริ่มติดตั้ง
http://192.168.2.113/install/










20. ลบไฟล์ install ทิ้ง หรือเปลี่ยนชื่อ
21. เข้าตั้งค่า LDAP พบ Error ไม่ผ่าน
information
LDAP extension not available admin

ตอนลงต้องใช้ชื่อ administrator เท่านั้น ชื่ออื่นจะไม่ผ่าน

information
The specified email attribute does not exist.

ไม่ต้องใส่ mail ผ่าน

22. ทดลอง login ด้วย user ใน domain
เสร็จ ติดตั้งตัว PHPBB3 V 3.2.8 On Ubuntu 18.04.3

**** นำข้อมูลไฟล์และข้อมูลเก่ามาเข้าไม่ได้ *****
- Database ไม่เหมือนกัน
- ไฟล์ต่าง ๆ Styleไม่เหมือนกัน
- Blog Modไม่รองรับ
จึงต้องใช้วิธี Update เอา
https://intranet.sci.com/blog.php?u=281&b=1753