<?php
require('PHPAGI/phpagi-asmanager.php');
$callid = 'Somebody';
$asm = new AGI_AsteriskManager();
if($asm->connect())
{
$call = $asm->send_request('Originate',
array('Channel'=>"LOCAL/17165555555 at voicepulse",
'Context'=>'called_party_context',
'Exten'=>'899',
'Timeout' => '1000',
'Async'=>'1',
'MaxRetries' => '5',
'RetryTime' => '5',
'Priority'=>1,
'Callerid'=>$callid));
$asm->disconnect();
}
$channel = 'Local/[EMAIL PROTECTED]/1';
$exten = '';
$context = '';
$priority = '';
$application = 'Meetme';
$data = '500|qt|1234';
$timeout = '20000';
$callerid = '';
$variable = 'minutes=5';
$account = '';
$async = true;
$actionid = rand();
$asm->Originate($channel, $exten, $context, $priority, $application, $data,
$timeout, $callerid, $variable, $account, $async, $actionid);
?>
jQuery Object Accessors
| จากตัวอย่างนี้ จะเป็นการวน loop ตามจำนวน ที่ selector คือ $(“div”) ทั้งหมด จะสังเกตุเห็นว่า จะมี alert บอกว่ากำลังทำงานกับ tag div ตัวไหนอยู่ และ parameter i ก็จะเป็นตัวบอก รอบที่อยู่ใน loop เริ่มจาก 0
<script language=”javascript”> $(document).ready(function(){ $( document.body ).click( function () { $(”div”).each( function(i) { alert( (i+1) + “. Working in Tag =” + this.innerHTML); if (this.style.color !=”blue”) { this.style.color=”blue”; }else{ this.style.color=””; } } ); } ); }); </script> <style type=”text/css”> div { color:red; text-align:center; cursor:pointer; font-weight:bolder; width:300px; } </style> มี Tag div อยู่ 3 ตัวซึ่งเราจะมองว่า Tag div แต่ละตัวคือ element แต่ละ element <div>Click here</div> <div>to iterate through</div> <div>these divs.</div> |
| <script language=”javascript”>
$(document).ready(function(){ // ปุ่ม Insert $(”#btnIn”).click(function () { var txtnum=$(”.trcolor”).length+1; $(”#tblData”).append($(”<tr class=\”trcolor\”> ” + “ <td>”+txtnum+”</td>” + “ <td><input type=\”text\”></td>”+ “ <td><input type=\”text\”></td>”+ “ <td><input type=\”text\”></td>”+ ” </tr>”)); getMsg(); }); // ปุ่ม Delete $(”#btnDel”).click(function (){ $(”.trcolor:last”).remove(); getMsg(); }); // function บอกจำนวนแถว โดยใช้ method length function getMsg(){ var n=$(”.trcolor”).length; $(”#lblMsg”).text(”There are ” + n + ” Rows.”); } }); </script> <style type=”text/css”> .trcolor { background:#F2F2F2; } </style> <button id=”btnIn”>RUN</button> | <button id=”btnDel”>Del</button> <div id=”lblMsg”></div> <table id=”tblData” width=”600″ border=”0″ cellpadding=”1″ cellspacing=”1″ bgcolor=”#CCCCCC”> <tr> <td width=”12%”><strong>Number</strong></td> <td width=”24%”><strong> Name</strong></td> <td width=”22%”><strong>Surname</strong></td> <td width=”42%”><strong>Tel</strong></td> </tr> </table> |
Argument position คือการใส่ Number Index ลงไป
การใช้ eq สำหรับระบุ ไปยัง Index ของ element แบบเฉพาะเจาะจงลงไปในตัวใดตัวหนึ่ง จะอธิบายด้วยตัวอย่างนี้นะครับ
| <script language=”javascript”>
$(document).ready(function(){ /* initial function */ $(”#btnRun”).click(function (){ $(”div”).eq(2).css(”background”,”#CCFFFF”); }); }); </script> จากตัวอย่างนี้จะเป็นการ เลือก selector ที่ element Div และกำหนด eq ที่ 2 คือตำแหน่ง index ที่ 2 จากข้อมูลชุดด้านล่างนี้ เพื่อทำการ ใส่สี่ background <button id=”btnRun”>RUN</button> <div><a href=”#”>Data 01</a> < — index 0 , first element </div> <div><a href=”#”>Data 02</a> < — index 1</div> <div><a href=”#”>Data 03</a> < — index 2</div> <div><a href=”#”>Data 04</a> < — index 3 , last element</div> |
การใช้ get เป็นการรับ element จาก selector ซึ่งค่าที่ได้จะเป็นลักษณะ array
| <script language=”javascript”>
$(document).ready(function(){ $(”#btnRun”).click(function (){ var objDiv= $(”div”).get(); // ใช้ get ใส่ตัวแปร objDiv var txt=[]; // ประกาศตัวแปร Array for (var i =0;i<objDiv.length;i++){ txt.push(objDiv[i].innerHTML); // push คือ method ของ Javascript เพื่อ ใส่ข้อมูลใน ตัวแปร Array } $(”span”).text(txt.join(” , “)); // join คือ method ของ Javascript เพื่อ เชื่อมสมาชิกแต่ละตัว ใน Array ซึ่ง Argument ของ join คือตัวคั่นระหว่าง สมาชิกแต่ละตัว }); }); </script> <button id=”btnRun”>RUN</button><br> Data Divs Join : <span style=”color:#FF0000″></span> <hr> <div>One</div> <div>Two</div> <div>Three</div> <div>Four</div> |
เป็นการรับ element จาก selector แต่ระบุ index เข้าไปเพื่อชี้เฉพาะเจาะจง ลงไป ว่าจะเลือกตัวไหน ยกตัวอย่าง จาก ตัวอย่างด้านบน
$(”div”).get(2).innerHTML หากกำหนด get(2) จะได้ค่า กลับมาเป็น Three เนื่องจากจะไปจับ elements Index ที่ 2 นับจาก 0 ซึ่งก็คือ แทก <div> ที่ข้อความว่า Three
Subject คือ element ที่จะระบุใน Index
เรื่อง index จะเป็นเรื่องการหาค่า index ใน element ว่าอยู่ตำแหน่งที่เท่าไหร่ ซึ่ง subject จะเป็นตัวระบุ current ของ index ที่ถูกกระทำ หาก ยังไม่ได้ถูกกระทำ จะ คืนค่า -1 กลับมา
จากตัวอย่างนี้ เมื่อ click ไปที่ Tag div แต่ละตัว จะแสดง alert current Index ของตัวนั้นออกมา
| <script language=”javascript”>
$(document).ready(function(){ $(”div”).click(function (){ var txt=”Index is : ” + $(”div”).index(this); alert(txt); }); }); </script> <div>One</div> <div>Two</div> <div>Three</div> <div>Four</div> |
# aptitude update
# aptitude install apache2 apache2-doc apache2-mpm-prefork apache2-utils apache2.2-common
# aptitude install php5 php5-cgi php5-commonphp5-curlphp5-gd php5-mcrypt php5-mysql php5-odbc php5-pgsql php5-xmlrpc
# aptitude install libapache2-mod-php5
ช่วงนี้ aptitude ของ etch เป็นอะไรไม่รู้ ชอบติดตั้งไฟล์ไม่ครบ
(อาจเป็นที่ apt-proxy)
แก้ไขแพกเกจติดตั้งไฟล์ไม่ครบ โดยการแตกไฟล์โดยไม่ติดตั้ง ไปยัง /
# dpkg-deb -x /var/cache/apt/archives/apache2.2-common_2.2.3-3.1_i386.deb /
# aptitude install mysql-client-5.0 mysql-common mysql-server-5.0 phpmyadmin
บันทึกการเปิดโมดูลแบบน้อยสุด module-minimal
# a2enmod actions
# a2enmod alias
# a2enmod authz_host
# a2enmod cgi
# a2enmod dir
# a2enmod mime
# a2enmod php5
# a2enmod rewrite
# a2enmod status
# /etc/init.d/apache2 restart
บันทึกการเปิดใช้โมดูลแบบปกติ module-normal
# a2enmod alias
# a2enmod auth_basic
# a2enmod authn_file
# a2enmod authz_default
# a2enmod authz_groupfile
# a2enmod authz_host
# a2enmod authz_user
# a2enmod autoindex
# a2enmod cgi
# a2enmod dir
# a2enmod env
# a2enmod mime
# a2enmod mod_python
# a2enmod negotiation
# a2enmod php5
# a2enmod setenv
# a2enmod status
# /etc/init.d/apache2 restart
เอา php.ini จากตัวอย่างแบบ recommended มาใช้
# cp /usr/share/doc/php5/examples/php.ini-recommended /etc/php5/apache2/php.ini
แก้จะให้ใช้ได้กับ drupal
# vi /etc/php5/apache2/php.ini
... ; หน่วยความจำที่ยอมให้สคริปต์รันได้ ; เก่าเป็น 8M drupal แนะนำ 12M เราใช้ 16M กันเหนียว memory_limit = 16M ; Maximum amount of memory a script may consume (8MB) ... ; ตัวแปรเป็น global อัตโนมัติ ; อันนี้ก็กันเหนียว ตอนเขียนโค๊ดเรี่ยราดไว้หลายที่ เก่าเป็น Off เราแก้เป็น On register_globals = On ... ; ขนาดไฟล์ใหญ่สุด ที่ post ได้ ; อันนี้จำได้แม่น หน้าแตกเพราะเอา Bon Echo เข้าไม่ได้ เก่าเป็น 8M แก้เป็น 20M post_max_size = 20M ... ; adodb ไม่ต้องก็ได้ include_path = ".:/usr/share/php5:/usr/share/php4:/usr/share/php/adodb" ... ; ค่าแนะนำของ drupal session.save_handler = user ... ; ค่าแนะนำของ drupal session.cache_limiter = none ...
ส่วนของไซต์ ถ้ามีหลายไซท์ ควรแยกไฟล์ออกมาวางไว้ที่ /etc/apache2/site-available
เวลาจะเปิดใช้งานก็ใช้คำสั่ง a2ensite
เช่นไซต์ example.com
# vi /etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName www.example.com
DocumentRoot /var/www/www.example.com/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /swww2/var/www/www.thaitux.info/>
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.html index.php
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</VirtualHost>
เปิดใช้งานด้วยคำสั่ง
# a2ensite example.com
# /etc/init.d/apache2 restart
This brief introduction for configuring sites and modules in Debian’s Apache 2 package explains how to add and remove sites using the supplied tools, along with adding and removing modules.
The main source of confusiong comes from the various directories stored beneath /etc/apache2:
Now - several discussions on #debian IRC channel on freenode recently have had people advising others to either copy files from the available to the enabled directories or to manually symlink them. The user has, however, a better option - the four commands a2ensite, a2dissite, a2enmod and a2dismod
We covered these this new layout briefly when discussing the upgrade from Apache 1.x to 2.x, and again when dicussing how to enable mod_rewrite for Apache.
Statistics