php读取mac地址

1. 2. 3. class GetMacAddress { 4. var $return_array = array(); 5. var $mac_addr; 6. 7. function _construct($os_type) { 8. switch (strtolower($os_type)) { 9. case "linux": 10. $this->forLinux(); 11. break; 12. default: 13. $this->forWindows(); 14. break; 15. } 16. 17. $temp_array = array(); 18. foreach ($this->return_array as $value) { 19. if (preg_match(”/[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f][:-]” 20. .”[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f][:-]“.”[0-9a-f][0-9a-f]/i”, $value, $temp_array)) { 21. $this->mac_addr = $temp_array[0]; 22. break; 23. } 24. } 25. 26. unset($temp_array); 27. return $this->mac_addr; 28. } 29. 30. function forWindows() { 31. @exec(”ipconfig /all”, $this->return_array); 32. 33. if ($this->return_array) { 34. return $this->return_array; 35. } else { 36. $ipconfig = $_SERVER["SystemRoot"].”\system32\ipconfig.exe”; 37. if (is_file($ipconfig)) { 38. @exec($ipconfig.” /all”, $this->return_array); 39. } else { 40. @exec($_SERVER["WINDIR"].”\system\ipconfig.exe /all”, $this->return_array); 41. } 42. return $this->return_array; 43. } 44. } 45. 46. function forLinux() { 47. @exec(”ifconfig -a”, $this->return_array); 48. return $this->return_array; 49. } 50. } 51. 52. $mac = new GetMacAddress(null); 53. echo $mac->mac_addr; 54. 55. ?>

2010-01-25 · 1 min · 153 words · kevin

网站负载测试工具webbench

webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便。 1、适用系统:Linux 2、编译安装: wget http://blog.s135.com/soft/linux/webbench/webbench-1.5.tar.gz tar zxvf webbench-1.5.tar.gz cd webbench-1.5 make && make install 3、使用: webbench -c 500 -t 30 http://127.0.0.1/test.jpg 参数说明:-c表示并发数,-t表示时间(秒) 4、测试结果示例: Webbench - Simple Web Benchmark 1.5 Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software. Benchmarking: GET http://127.0.0.1/test.jpg 500 clients, running 30 sec. Speed=3230 pages/min, 11614212 bytes/sec. Requests: 1615 susceed, 0 failed. 转载于:http://blog.s135.com/post/288/

2010-01-22 · 1 min · 56 words · kevin

关于MySQL的show status解详

Aborted_clients 由于客户没有正确关闭连接已经死掉,已经放弃的连接数量。 Aborted_connects 尝试已经失败的MySQL服务器的连接的次数。 Connections 试图连接MySQL服务器的次数。 Created_tmp_tables 当执行语句时,已经被创造了的隐含临时表的数量。 Delayed_insert_threads 正在使用的延迟插入处理器线程的数量。 Delayed_writes 用INSERT DELAYED写入的行数。 Delayed_errors 用INSERT DELAYED写入的发生某些错误(可能重复键值)的行数。 Flush_commands 执行FLUSH命令的次数。 Handler_delete 请求从一张表中删除行的次数。 Handler_read_first 请求读入表中第一行的次数。 Handler_read_key 请求数字基于键读行。 Handler_read_next 请求读入基于一个键的一行的次数。 Handler_read_rnd 请求读入基于一个固定位置的一行的次数。 Handler_update 请求更新表中一行的次数。 Handler_write 请求向表中插入一行的次数。 Key_blocks_used 用于关键字缓存的块的数量。 Key_read_requests 请求从缓存读入一个键值的次数。 Key_reads 从磁盘物理读入一个键值的次数。 Key_write_requests 请求将一个关键字块写入缓存次数。 Key_writes 将一个键值块物理写入磁盘的次数。 Max_used_connections 同时使用的连接的最大数目。 Not_flushed_key_blocks 在键缓存中已经改变但是还没被清空到磁盘上的键块。 Not_flushed_delayed_rows 在INSERT DELAY队列中等待写入的行的数量。 Open_tables 打开表的数量。 Open_files 打开文件的数量。 Open_streams 打开流的数量(主要用于日志记载) Opened_tables 已经打开的表的数量。 Questions 发往服务器的查询的数量。 Slow_queries 要花超过long_query_time时间的查询数量。 Threads_connected 当前打开的连接的数量。 Threads_running 不在睡眠的线程数量。 Uptime 服务器工作了多少秒

2010-01-22 · 1 min · 67 words · kevin

MySQL优化建议

1. key_buffer_size(VARIABLES)是针对Key_reads(STATUS)太大(Key_reads/Key_read_requests比率要尽量小,一般在1/1000以下);table_cache(VARIABLES)是针对Opened_tables(STATUS)太大,Opened_tables太大说明很多打开表的操作(访问一个表时,mysql将先打开这个表)必须在关闭其它表的状态下进行,所以必须增大table_cache的值 2. thread_created(STATUS)值比较大,而max_connections(VARIABLES)为300及max_used_connections(STATUS)不到300,可以考虑将thread_cache_size设为300,目的就是为了使thread_created/Connections比值尽量小!即增加thread的重用性!(手册上讲的很详细) 3. 为使Created_tmp_disk_tables(STATUS)尽量变为0,可以再适当增加tmp_table_size,这是为了尽量使临时表在内存中操作!同时也可以考虑增大max_tmp_tables(VARIABLES)的值! Handler_read_rnd(STATUS)以及Handler_read_rnd_next(STATUS)很大,表明使用很多需要遍历表的查询或者没有很好的使用索引!解决这个问题需要优化你的SQL语句!同样,Slow_queries很大也表明了类似的问题!(Slow_queries是指超过long_query_time(VARIABLES)设定的秒数的SQL语句执行数量) 5. Key_blocks(STATUS)相对太小,说明关键缓存使用率很低,这也说明了Key_buffer_size太小! 6. Sort_scan(STATUS)比较大,说明使用了比较多的表扫描排序,也即没有很好的使用索引(后面的判断是个人所见,呵呵) 7. Talbe_locks_waited很大,说明有很多表锁定操作没有立即执行,这也需要通过优化表结构和SQL语句来避免,当然,在应用层也可以考虑更有效的使用表锁定(锁表与解锁之间的操作尽量不要有耗时的SQL操作)

2010-01-22 · 1 min · 13 words · kevin

windows下自动切换ip小脚本

从办公到家庭环境,或者从会议室到办公工位上的IP切换. 1. 切换成自动获取IP @echo off netsh interface ip set address name=“local” source=dhcp netsh interface ip set dns name=“local” source=dhcp 2. 切换成固定IP @echo off netsh interface ip set address local static 192.168.0.100 255.255.255.0 192.168.0.1 netsh interface ip set dns local 192.168.0.1 netsh interface ip add dns local 8.8.8.8 index=2 “local” 是你的本地网卡名称,也可能是 “本地连接”,需要自己替换下。如果是2个固定IP间的来回切换,把第2个脚本自己改改吧 dns设置中,第一个是set,表示设置,后面两个则是添加,自己替换成当地的dns server。 本文转自: E点废墟

2010-01-21 · 1 min · 55 words · kevin

100个句子等于7000个单词

1. Typical of the grassland dwellers of the continent is the American antelope, or pronghorn. 1.美洲羚羊,或称叉角羚,是该大陆典型的草原动物。 2. Of the millions who saw Haley’s comet in 1986, how many people will live long enough to see it return in the twenty-first century. 2. 1986年看见哈雷慧星的千百万人当中,有多少人能够长寿到足以目睹它在二十一世纪的回归呢? 3. Anthropologists have discovered that fear, happiness, sadness, and surprise are universally reflected in facial expressions. 3.人类学家们已经发现,恐惧,快乐,悲伤和惊奇都会行之于色,这在全人类是共通的。 4. Because of its irritating effect on humans, the use of phenol as a general antiseptic has been largely discontinued. ...

2010-01-20 · 13 min · 2645 words · kevin

Windows Server 2008 R2 Editions 180day Evaluation Key:

windows server 2008 180天密钥 Windows Web Server 2008 R2 = KBV3Q-DJ8W7-VPB64-V88KG-82C49 Windows Server 2008 R2 Standard = 4GGC4-9947F-FWFP3-78P6F-J9HDR Windows Server 2008 R2 Enterprise = 7PJBC-63K3J-62TTK-XF46D-W3WMD Windows Server 2008 R2 Datacenter = QX7TD-2CMJR-D7WWY-KVCYC-6D2YT

2010-01-20 · 1 min · 32 words · kevin

定制自己的LiveCD,依托(centos)

1、建立自己的yum-repository或者使用官方的(考虑到你需要的软件小,所以这一步不是很必要)。 2、安装一个centos系统,修改etc/yum.repos.d/centos-livecd.repo文件内容 # Name: CentOS LiveCD repository [livecd] name = CentOS $releasever - LiveCD baseurl = http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live enabled=1 protect=0 gpgkey = http://www.nanotechnologies.qc.ca/propos/linux/RPM-GPG-KEY-PGuay 保存之后,执行以下命令: # yum install livecd-tools syslinux 这样就安装好了工具,接下来就是写自己想要的ks脚本; 3、ks脚本 名称:centos-livecd-minimal.ks(包含必须包的脚本) 内容: lang en_US.UTF-8 keyboard us timezone US/Eastern auth --useshadow --enablemd5 selinux --disabled firewall --disabled repo --name=base --baseurl=http://ftp.telus.net/pub/centos/5/os/$basearch repo --name=updates --baseurl=http://ftp.telus.net/pub/centos/5/updates/$basearch repo --name=extras --baseurl=http://ftp.telus.net/pub/centos/5/extras/$basearch #repo --name=base --baseurl=http://isoredirect.centos.org/centos/5/os/$basearch #repo --name=updates --baseurl=http://isoredirect.centos.org/centos/5/updates/$basearch #repo --name=extras --baseurl=http://isoredirect.centos.org/centos/5/extras/$basearch repo --name=live --baseurl=http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live %packages bash kernel syslinux passwd policycoreutils chkconfig authconfig rootfiles comps-extras xkeyboard-config gnome-desktop 4、生成 ...

2010-01-20 · 1 min · 86 words · kevin

Nginx整合Resin

操作系统:centos 5.4 64位 1,安装jdk,已经配置有yumrepository,直接使用。 yum install jdk 2,安装pcre,nginx运行所需perl库。 yum install pcre pcre-devel 3,安装mysql ,mysql相关配置省略。 yum install mysql mysql-server 4,安装并配置resin。 wget http://www.caucho.com/download/resin-4.0.3.tar.gz tar zxvf resin-4.0.3.tar.gz cd resin-4.0.3 ./configure --prefix=/usr/local/resin make && make install 修改配置参数 vi /usr/local/resin/conf/resin.xml 注释掉下面代码,不然会提示启动错误 www-data www-data 并添加相应配置 启动resin /usr/local/resin/bin/resin.sh start 5,安装nginx。 wget http://nginx.org/download/nginx-0.8.32.tar.gz tar zxvf nginx-0.8.32.tar.gz ./configure --prefix=/usr/local/nginx make && make install 修改配置文件 vi /usr/local/nginx/conf/proxy proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 4k; vi /usr/local/nginx/conf/nginx 修改server { … …} 为下面代码 ...

2010-01-20 · 1 min · 124 words · kevin

故乡的河

雨季 驾一叶悠悠的扁舟 我又荡如你的心怀 放飞一双尘飞的翅膀 放飞童年许你的 有无数颗小星星 作证的承诺 轻轻地 向你道一声 乡音未改的问候 你回眸 还我一串 含泪的微笑

2010-01-19 · 1 min · 13 words · kevin