หน้าเว็บ

วันจันทร์ที่ 30 ตุลาคม พ.ศ. 2560

Qnap : Problem maintaining CIFS mount from Ubuntu Virtual Machin Error Host is down

update Qnap To Version 4.3.3.0210 แล้วมีปัญหา Mount to ubuntu error Host is down

When it comes to the max SMB version - the control has not made it to the UI of the CAT1 systems, you need to call the readily available smb[N|NN]enable, and check the current settings using smb2status form the NAS shell:

Up to QTS 4.2.x, SMB 2.1 is the max available:

[~] # smb21enable
...

QTS 4.3.x will bring SMB up to the 3.0 subset available in SAMBA 4.4 to all QNAP Marvell Kirkwood NAS.

[~] # smb3enable
...

Check status:

[~] # smb2status

smbd (samba daemon) Version 4.4.9
smbd (samba daemon) is running.
max protocol SMB 3.0 enabled.

[~] # smb<TAB>
smb21enable smb2disable smb2enable smb2status smb3enable smbtools

reboot Qnap and mount again.

https://forum.qnap.com/viewtopic.php?t=132166

และเวลา Mount ต้องใส่ Version 3 ด้วย
  1. sudo mount -t cifs -o username=xxx,password=xxx  vers=3.0 //192.168.0.218/backup /BACKUP/BackupToQnap/


https://forum.qnap.com/viewtopic.php?t=132166

PHP : PHP ดึง rate จาก Web กสิกรใหม่มาแสดงใน Internet

ดยใช้วิธีดึงค่าจาก aspx ของ ธนาคารเลย
https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx

https://stackoverflow.com/questions/24134886/get-html-code-from-aspx-page-with-php
  1. <?php
  2. include_once("simple_html_dom.php");
  3. $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx';
  4. $contents = htmlentities(file_get_contents($url));
  5. echo $contents;
  6.  
  7. ?>


สามารถส่งวันที่ เข้าไปได้ ก็จะได้ค่าเช่นกัน

  1. <?php
  2. include_once("simple_html_dom.php");
  3. $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx?d=19&m=05&y=2017&r=0';
  4. $contents = htmlentities(file_get_contents($url));
  5. echo $contents;
  6.  
  7. ?>



เอาค่ามาใช้งานโดย ใช้ explode <div> เอา
https://stackoverflow.com/questions/20446598/get-div-content-from-external-website

  1. <?php
  2. include_once("simple_html_dom.php");
  3. $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx';
  4. //$contents = htmlentities(file_get_contents($url));
  5. //$contents  = file_get_contents($url);
  6. //echo $contents;
  7. //exit;
  8.  
  9. // FIND THE DESIRED DIV
  10. $htm = file_get_contents($url);
  11. echo htmlentities($htm);
  12.  
  13. $strDate = '<div id="divRate"';
  14. $arrDate = explode($strDate, $htm);
  15. $arrDate = explode('</div', $arrDate[1]);
  16.  
  17. // RECONSTRUCT THE DIV WITH HTML TAGS
  18. $new = $strDate . $arrDate[0] .'</div>';
  19.  
  20. echo htmlentities($new);
  21.  
  22. ?>


ตัวอย่าง Rate ข้อเสนอแนะคุณพเยาว์
https://intranet.scivalve.com/sci/AF/rate_bank.php
  1.  
  2. <?php
  3. error_reporting(E_ERROR);
  4. define('IN_PHPBB', true);
  5. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../../';
  6. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  7. include($phpbb_root_path . 'common.' . $phpEx);
  8.  
  9. include($phpbb_root_path ."sci/include/config.php");
  10. //include($phpbb_root_path ."sci/include/db.php");
  11. include($phpbb_root_path ."sci/include/functions.php");
  12. //include($phpbb_root_path ."sci/include/db2.php");
  13.  
  14. include_once("simple_html_dom.php");
  15.  
  16. //$url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx?d=19&m=05&y=2017&r=0';
  17. $url = 'https://www.kasikornbank.com/TH/Rate/Pages/Foreign-Exchange.aspx';
  18. //$contents = htmlentities(file_get_contents($url));
  19. //$contents  = file_get_contents($url);
  20. //echo $contents;
  21. //exit;
  22.  
  23. // FIND THE DESIRED DIV
  24. $htm = file_get_contents($url);
  25. echo htmlentities($htm);
  26. /*
  27. $strDate = '<div id="divRate"';
  28. $arrDate = explode($strDate, $htm);
  29. $arrDate = explode('</div', $arrDate[1]);
  30.  
  31. // RECONSTRUCT THE DIV WITH HTML TAGS
  32. $new = $strDate . $arrDate[0] .'</div>';
  33.  
  34. echo htmlentities($new);
  35. */
  36.  
  37. //########### USD ############//
  38. $strDiv = '<div id="divLastRate"';
  39. $arrDiv = explode($strDiv, $htm);
  40.  
  41. $arrDiv = explode('</div>', $arrDiv[1]);
  42.  
  43. // RECONSTRUCT THE DIV WITH HTML TAGS
  44. $newDiv = $strDiv . $arrDiv[0] .'</div>';
  45.  
  46. //echo htmlentities($newDiv);
  47.  
  48. // Explode Data For Show Buying.
  49. $strBuyUSD = 'data-BuyTelex="';
  50. $arrBuyUSD = explode($strBuyUSD, $newDiv);
  51. $arrBuyUSD = explode('"', $arrBuyUSD[1]);
  52. $newBuyUSD = $arrBuyUSD[0];
  53.  
  54. //echo $newBuyUSD;
  55.  
  56. // Explode Data For Show Selling.
  57. $strSellUSD = 'data-SellChq="';
  58. $arrSellUSD = explode($strSellUSD, $newDiv);
  59. $arrSellUSD = explode('"', $arrSellUSD[1]);
  60. $newSellUSD = $arrSellUSD[0];
  61.  
  62. //echo $newSellUSD;
  63. //########### USD ############//
  64.  
  65. //########### CNY ############//
  66. $strDiv = '<div id="divLastRate"';
  67. $arrDiv = explode($strDiv, $htm);
  68. $arrDiv = explode('</div>', $arrDiv[1]);
  69.  
  70. // RECONSTRUCT THE DIV WITH HTML TAGS
  71. $newDiv = $strDiv . $arrDiv[10] .'</div>';
  72.  
  73. //echo htmlentities($newDiv);
  74.  
  75. // Explode Data For Show Buying.
  76. $strBuyCNY = 'data-BuyTelex="';
  77. $arrBuyCNY = explode($strBuyCNY, $newDiv);
  78. $arrBuyCNY = explode('"', $arrBuyCNY[1]);
  79. $newBuyCNY = $arrBuyCNY[0];
  80.  
  81. //echo $newBuyCNY;
  82.  
  83. // Explode Data For Show Selling.
  84. $strSellCNY = 'data-SellChq="';
  85. $arrSellCNY = explode($strSellCNY, $newDiv);
  86. $arrSellCNY = explode('"', $arrSellCNY[1]);
  87. $newSellCNY = $arrSellCNY[0];
  88.  
  89. //echo $newSellCNY;
  90. //########### CNY ############//
  91.  
  92. //########### EUR ############//
  93. $strDiv = '<div id="divLastRate"';
  94. $arrDiv = explode($strDiv, $htm);
  95. $arrDiv = explode('</div>', $arrDiv[1]);
  96.  
  97. // RECONSTRUCT THE DIV WITH HTML TAGS
  98. $newDiv = $strDiv . $arrDiv[12] .'</div>';
  99.  
  100. //echo htmlentities($newDiv);
  101.  
  102. // Explode Data For Show Buying.
  103. $strBuyEUR = 'data-BuyTelex="';
  104. $arrBuyEUR = explode($strBuyEUR, $newDiv);
  105. $arrBuyEUR = explode('"', $arrBuyEUR[1]);
  106. $newBuyEUR = $arrBuyEUR[0];
  107.  
  108. //echo $newBuyEUR;
  109.  
  110. // Explode Data For Show Selling.
  111. $strSellEUR = 'data-SellChq="';
  112. $arrSellEUR = explode($strSellEUR, $newDiv);
  113. $arrSellEUR = explode('"', $arrSellEUR[1]);
  114. $newSellEUR = $arrSellEUR[0];
  115.  
  116. //echo $newSellEUR;
  117. //########### EUR ############//
  118.  
  119. //########### GBP ############//
  120. $strDiv = '<div id="divLastRate"';
  121. $arrDiv = explode($strDiv, $htm);
  122. $arrDiv = explode('</div>', $arrDiv[1]);
  123.  
  124. // RECONSTRUCT THE DIV WITH HTML TAGS
  125. $newDiv = $strDiv . $arrDiv[13] .'</div>';
  126.  
  127. //echo htmlentities($newDiv);
  128.  
  129. // Explode Data For Show Buying.
  130. $strBuyGBP = 'data-BuyTelex="';
  131. $arrBuyGBP = explode($strBuyGBP, $newDiv);
  132. $arrBuyGBP = explode('"', $arrBuyGBP[1]);
  133. $newBuyGBP = $arrBuyGBP[0];
  134.  
  135. //echo $newBuyGBP;
  136.  
  137. // Explode Data For Show Selling.
  138. $strSellGBP = 'data-SellChq="';
  139. $arrSellGBP = explode($strSellGBP, $newDiv);
  140. $arrSellGBP = explode('"', $arrSellGBP[1]);
  141. $newSellGBP = $arrSellGBP[0];
  142.  
  143. //echo $newSellGBP;
  144. //########### GBP ############//
  145.  
  146. //########### HKD ############//
  147. $strDiv = '<div id="divLastRate"';
  148. $arrDiv = explode($strDiv, $htm);
  149. $arrDiv = explode('</div>', $arrDiv[1]);
  150.  
  151. // RECONSTRUCT THE DIV WITH HTML TAGS
  152. $newDiv = $strDiv . $arrDiv[14] .'</div>';
  153.  
  154. //echo htmlentities($newDiv);
  155.  
  156. // Explode Data For Show Buying.
  157. $strBuyHKD = 'data-BuyTelex="';
  158. $arrBuyHKD = explode($strBuyHKD, $newDiv);
  159. $arrBuyHKD = explode('"', $arrBuyHKD[1]);
  160. $newBuyHKD = $arrBuyHKD[0];
  161.  
  162. //echo $newBuyHKD;
  163.  
  164. // Explode Data For Show Selling.
  165. $strSellHKD = 'data-SellChq="';
  166. $arrSellHKD = explode($strSellHKD, $newDiv);
  167. $arrSellHKD = explode('"', $arrSellHKD[1]);
  168. $newSellHKD = $arrSellHKD[0];
  169.  
  170. //echo $newSellHKD;
  171. //########### HKD ############//
  172.  
  173. //########### JPY ############//
  174. $strDiv = '<div id="divLastRate"';
  175. $arrDiv = explode($strDiv, $htm);
  176. $arrDiv = explode('</div>', $arrDiv[1]);
  177.  
  178. // RECONSTRUCT THE DIV WITH HTML TAGS
  179. $newDiv = $strDiv . $arrDiv[18] .'</div>';
  180.  
  181. //echo htmlentities($newDiv);
  182.  
  183. // Explode Data For Show Buying.
  184. $strBuyJPY = 'data-BuyTelex="';
  185. $arrBuyJPY = explode($strBuyHKD, $newDiv);
  186. $arrBuyJPY = explode('"', $arrBuyHKD[1]);
  187. $newBuyJPY = $arrBuyHKD[0];
  188.  
  189. //echo $newBuyJPY;
  190.  
  191. // Explode Data For Show Selling.
  192. $strSellJPY = 'data-SellChq="';
  193. $arrSellJPY = explode($strSellJPY, $newDiv);
  194. $arrSellJPY = explode('"', $arrSellJPY[1]);
  195. $newSellJPY = $arrSellJPY[0];
  196.  
  197. //echo $newSellJPY;
  198. //########### JPY ############//
  199.  
  200. //########### MYR ############//
  201. $strDiv = '<div id="divLastRate"';
  202. $arrDiv = explode($strDiv, $htm);
  203. $arrDiv = explode('</div>', $arrDiv[1]);
  204.  
  205. // RECONSTRUCT THE DIV WITH HTML TAGS
  206. $newDiv = $strDiv . $arrDiv[24] .'</div>';
  207.  
  208. //echo htmlentities($newDiv);
  209.  
  210. // Explode Data For Show Buying.
  211. $strBuyMYR = 'data-BuyTelex="';
  212. $arrBuyMYR = explode($strBuyHKD, $newDiv);
  213. $arrBuyMYR = explode('"', $arrBuyMYR[1]);
  214. $newBuyMYR = $arrBuyMYR[0];
  215.  
  216. //echo $newBuyMYR;
  217.  
  218. // Explode Data For Show Selling.
  219. $strSellMYR = 'data-SellChq="';
  220. $arrSellMYR = explode($strSellMYR, $newDiv);
  221. $arrSellMYR = explode('"', $arrSellMYR[1]);
  222. $newSellMYR = $arrSellMYR[0];
  223.  
  224. //echo $newSellMYR;
  225. //########### MYR ############//
  226.  
  227. //########### SGD ############//
  228. $strDiv = '<div id="divLastRate"';
  229. $arrDiv = explode($strDiv, $htm);
  230. $arrDiv = explode('</div>', $arrDiv[1]);
  231.  
  232. // RECONSTRUCT THE DIV WITH HTML TAGS
  233. $newDiv = $strDiv . $arrDiv[24] .'</div>';
  234.  
  235. //echo htmlentities($newDiv);
  236.  
  237. // Explode Data For Show Buying.
  238. $strBuySGD = 'data-BuyTelex="';
  239. $arrBuySGD = explode($strBuySGD, $newDiv);
  240. $arrBuySGD = explode('"', $arrBuySGD[1]);
  241. $newBuySGD = $arrBuySGD[0];
  242.  
  243. //echo $newBuySGD;
  244.  
  245. // Explode Data For Show Selling.
  246. $strSellSGD = 'data-SellChq="';
  247. $arrSellSGD = explode($strSellSGD, $newDiv);
  248. $arrSellSGD = explode('"', $arrSellSGD[1]);
  249. $newSellSGD = $arrSellSGD[0];
  250.  
  251. //echo $newSellSGD;
  252. //########### SGD ############//
  253.  
  254. ?>
  255.  

Windows 10 : Widows 10 Share Driver To Windows 7 Or Windows XP

Windows 10 : Widows 10 Share Driver To Windows 7 Or Windows XP

1. สำคัญมากถ้าเครื่อง Windows 10 ต่อ Printer และเป็นเครื่องที่จะ Share ให้เครื่องอื่น
ห้ามใช้ Driver ที่ update ผ่าน Windows มาใช้ เพราะจะ Share ไม่ได้
ต้องติดตั้ง Driver จากแผ่นหรือ Download มาติดตั้ง เท่านั้น ถึงจะ Share ให้เครื่องอื่นได้

2. Windows 10 ต้องเปิด Network and Sharing Center ในหัวข้อ File and printer sharing ทำการเลือก Turn on ให้เปิด
Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings


Link : https://www.windowssiam.com/add-printer-windows10/

3. Windows 7 สามารถเข้าไปที่เครื่องแล้วคลิก ที่ Printer ได้เลย
ส่วน Windows XP ต้องใช้วิธี Add Printer ผ่าน Local Port เอา คลิ๊ก ที่ชื่อเครื่อง ตรง ๆ ไม่ได้ จะให้ใส่รหัส และ error Operation could not be completed. Access is denied.
โดย
3.1 On a computer running Windows XP, open Control Panel-> Printers and Faxes and start Add Printer Wizard (Add printer)

3.2 Then select Local printer attached to this computer -> Create a new port -> Local Port

3.3 As a port name, specify the UNC address of the printer like this: \\Win10-PC1\SharedPrinterName (in our example it is \\192.168.1.22\HPLaserJet)
http://woshub.com/unable-to-connect-windows-10-shared-printer-to-windows-xp/

Axapta : Axapta Tab Active Code.

Axapta : Axapta Tab Active Code.

On Method Tab Use pageActivated for run code when click Tab.

public void pageActivated()
{
    ;
    print "555";
    super();
}

วันพฤหัสบดีที่ 25 พฤษภาคม พ.ศ. 2560

PHP : Export Data To Libreoffice Calc .ods

PHP : Export Data To Libreoffice Calc .ods
1. download และติดตั้ง tbs
http://www.tinybutstrong.com/download.php

2. download plugins และติดตั้ง
http://www.tinybutstrong.com/plugins.php

ไฟล์สำเร็จนำไปแตกไฟล์เรียกใช้ได้เลย


หลักการคือ
ทำ Template และใส่ชื่อ Block ไว้
แล้ว Select ข้อมูลเป็น Array ไปใส่

ตัวอย่าง Code ทำรายงาน
http://www.tinybutstrong.com/opentbs.php?demo
http://www.tinybutstrong.com/examples.php

Example :
  1. include_once('../tbs/tbs_class.php'); // Load the TinyButStrong template engine
  2. include_once('../tbs/plugins/tbs_plugin_opentbs.php'); // Load the OpenTBS plugin
  3.  
  4. // Initialize the TBS instance
  5. $TBS = new clsTinyButStrong; // new instance of TBS
  6. $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin
  7.  
  8. $DATA1 = array();
  9.  
  10. $template = 'Report_Template.ods';
  11. $TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document).
  12. // Merge data in the Workbook (all sheets)
  13. $TBS->MergeBlock('blk1', $DATA1);
  14.  
  15. // -----------------
  16. // Output the result
  17. // -----------------
  18. // Define the name of the output file
  19. $output_file_name = str_replace('.', '_'.date('Y-m-d').'.', $template);
  20.  
  21. // Output the result as a downloadable file (only streaming, no data saved in the server)
  22. $TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields.
  23. exit();
  24.  
  25.  

Zimbra : Zimbra sync USER เวลเปลี่ยน Diseplay Name

Zimbra : Zimbra sync USER เวลเปลี่ยน Diseplay Name เช่นกรณีเปลี่ยนตำแหน่ง
  1. su - zimbra
  1. zmgsautil forceSync -a galsync.zxqk9lahef@sci.com -n InternalGAL


เสร็จแล้วที่แต่ละ User กดลืม ชื่อเดิมออก

Ubuntu : คำสั่งดูขนานไฟล์ ใน Usb Box Backup

Ubuntu : คำสั่งดูขนานไฟล์ ใน Usb Box Backup
ดูขนาดไฟล์ทั้งหมด ใน Box cd เข้า Usb Box ก่อน
  1. ls -lah
-rwxrwxrwx 1 root root 28M Mar 27 17:50 DataServer_20170327.full.0.BlankForm.tar.gz
-rwxrwxrwx 1 root root 3.2G Mar 27 22:57 DataServer_20170327.full.0.CEOs.tar.gz
-rwxrwxrwx 1 root root 44G Mar 27 19:00 DataServer_20170327.full.1.Team.tar.gz
-rwxrwxrwx 1 root root 28G Mar 27 19:33 DataServer_20170327.full.2.Quality.tar.gz
-rwxrwxrwx 1 root root 36G Mar 27 20:35 DataServer_20170327.full.3.SS.tar.gz
-rwxrwxrwx 1 root root 101G Mar 27 22:51 DataServer_20170327.full.4.e-document.tar.gz


ดูขนาดไฟล์รวมทั้งหมด
  1. cd -ch

root@ha1:/mnt/USB/20170327_Full# du -ch
74M ./DataServerSnap
643G .
643G total

ดูขาดไฟล์เฉพาะที่มีชื่อ ตรงกัน เช่น Department
  1. du -ch *Department*
root@ha1:/mnt/USB/20170327_Full# du -ch *Department*
8.7G DataServer_20170327.full.5.Department.00-Public.tar.gz
25G DataServer_20170327.full.5.Department.01-ฝข.1.tar.gz
3.5G DataServer_20170327.full.5.Department.01-งขต.1.tar.gz
1.6G DataServer_20170327.full.5.Department.01-งขต.2.tar.gz
86M DataServer_20170327.full.5.Department.01-งสข.tar.gz
202M DataServer_20170327.full.5.Department.01-งซต.tar.gz
1.5G DataServer_20170327.full.5.Department.02-งอบ.1.tar.gz
13G DataServer_20170327.full.5.Department.02-งอบ.2.tar.gz
3.9G DataServer_20170327.full.5.Department.02-ฝอบ.tar.gz
4.5G DataServer_20170327.full.5.Department.03-ฝจห.tar.gz
1.8G DataServer_20170327.full.5.Department.03-งจล.tar.gz
21G DataServer_20170327.full.5.Department.03-งจซ.tar.gz
8.2G DataServer_20170327.full.5.Department.04-ฝปค.tar.gz
20G DataServer_20170327.full.5.Department.05-รง.1.tar.gz
1.4G DataServer_20170327.full.5.Department.05-รง.2.tar.gz
89G DataServer_20170327.full.5.Department.05-ฝผล.tar.gz
91G DataServer_20170327.full.5.Department.06-ฝซร.tar.gz
2.8G DataServer_20170327.full.5.Department.06-งบก.tar.gz
8.7G DataServer_20170327.full.5.Department.06-งซร.tar.gz
7.7G DataServer_20170327.full.5.Department.07-ฝทง.tar.gz
35G DataServer_20170327.full.5.Department.07-งบง.tar.gz
5.1G DataServer_20170327.full.5.Department.07-งทส.tar.gz
19G DataServer_20170327.full.5.Department.08-ฝพอ.tar.gz
4.4G DataServer_20170327.full.5.Department.08-งสส.tar.gz
12G DataServer_20170327.full.5.Department.08-งสป.tar.gz
30G DataServer_20170327.full.5.Department.08-งพม.tar.gz
5.3G DataServer_20170327.full.5.Department.09-ฝข.2.tar.gz
481M DataServer_20170327.full.5.Department.10-ฝคส.tar.gz
4.6G DataServer_20170327.full.5.Department.10-งวผ.tar.gz
8.3G DataServer_20170327.full.5.Department.10-งคส.tar.gz
432G total