January, 2008


20
Jan 08

Whois domain version 3.0

Nâng cấp bản 1.0 lên thành 3.0, cho phép quick check theo phần mở rộng của domain.

Một số tính năng mới:

  1. Phần mở rộng có thể tùy biến bằng cách thêm vào trong file list_ext.txt (phân cách nhau bằng ký tự Enter: \n).
  2. Lưu lại các domain đã được check vào file checked_domain.txt.
  3. Tốc độ quick check nhanh (chỉ sử dụng nslookup).

Hàm chính của version lần này chính là hàm quick_checklist_extension

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
function quick_check($domain,$ext) {if(empty($domain))
 
echo 'You must enter domain name to check.';
 
else
 
{
 
if(!eregi("^([[:alnum:]-])+$",$domain))
 
echo 'Domain name contain alphabet, number & dash character only.';
 
else
 
{
 
$data = popen("(nslookup -timeout=5 -query=ANY -nodef $domain$ext)2>&1","r");
 
$result = '';
 
while (!feof($data))
 
{
 
$result.= fgets($data, 1000);
 
}
 
$find = stripos($result, "can't find");
 
if($find=== false) {
 
echo "<span class="\">$domain$ext</span>  This domain has taken. (<a href="\">whois</a>)";
 
}
 
else
 
echo "<span class="\">$domain$ext</span>  This domain has available."; 		}
 
$fp=fopen("checked_domain.txt","a");
 
fwrite($fp, $domain.$ext."t".date("H:i:s - d/m/Y")."n");
 
fclose($fp);
 
}
 
}
 
function list_extension()
 
{
 
$filename = 'list_ext.txt';
 
$handle = fopen($filename,"r");
 
$data = fread($handle,filesize($filename));
 
$ext = explode("n",$data);
 
$list_ext = '';
 
if(count($ext)!=0) {
 
for($i=0;$i &lt; count($ext);$i++)  {
 
if($i%3==0)
 
      $list_ext.='
 
<input name="ext" type="checkbox" value="'.$ext[$i].'" />'.$ext[$i].'';
 
else
 
       $list_ext.='
 
<input name="ext" type="checkbox" value="'.$ext[$i].'" />'.$ext[$i].'';
 
}
 
return $list_ext.'
 
 
 
Check all ';
 
}
 
else {
 
return '
 
List extension not available. ';
 
}
 
}

Demo: http://donamkhanh.info/lab/ajax/whoisv3

[Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

15
Jan 08

Drag n Drop Islands

Kéo và thả nào :D

Giờ chưa có thời gian viết code cụ thể được, cứ để link demo đã, khi nào rảnh quay lại viết sau :p

http://donamkhanh.com/lab/ajax/drag_n_drop_island

[Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

4
Jan 08

Global variable in Drupal module

Ở trang php bình thường, khi muốn lấy giá trị của biến để sử dụng trong hàm chỉ đơn giản là global biến đó lên:

1
2
3
4
5
6
$_User = “user”;
function test()
{
       global $_User;
       ...
}

Nhưng trong Drupal làm vậy lại không được. Muốn sử dụng được thì phải khai báo 1 biến là global trước, sau đó mớ i gán giá trị và truy xuất được:

1
2
3
4
5
6
7
global $_User;
$_User = “user”;
 
function test() {
  global $_User;
  ..
}

Chẳng biết tại sao nữa :(

[Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]