顯示具有 php 標籤的文章。 顯示所有文章
顯示具有 php 標籤的文章。 顯示所有文章

2020-04-16

ubuntu 18.4 上使用 php7 透過 FreeTDS , ODBC 連 mssql 2000

1.安裝 FreeTDS ,ODBC
sudo apt-get install freetds-bin freetds-common tdsodbc odbcinst unixodbc unixodbc-dev
sudo mv /etc/odbcinst.ini /etc/odbcinst.ini.bak
sudo cp /usr/share/tdsodbc/odbcinst.ini /etc/
2.測試 是否可連 mssql
tsql -H my_server_host -p 1433 -U my_user -P my_password -D my_database
3.安裝 php7.x odbc 如 7.2 時
sudo apt-get install php7.2-odbc
4. php 上測試
try {

//connection params
$dbCon = new PDO('odbc:Driver=FreeTDS; Server=my_server_host; Port=1433; Database=my_database; TDS_Version=8.0; ClientCharset=UTF-8', 'my_login', 'my_pass');

//test query
$result = $dbCon->query('SELECT TOP 10 * FROM dbo.my_table');

//show the results
foreach ($result as $row)
{
print_r( $row );
}

//close the connection
$dbCon = null;

} catch (PDOException $e) {

//show exception
echo $e->getMessage();
}
其它問題: 如有 SQLSTATE[01000] SQLDriverConnect: 0 [unixODBC][Driver Manager]Can't open cursor lib '/etc/libodbccr.so' : file not found
cd /usr/lib/x86_64-linux-gnu
sudo ln -s libodbccr.so.2 libodbccr.so

2017-12-06

php curl ssl https 錯誤的 排除

curl 抓 https 時會出現以下的錯誤
Failed: Error Number: 60. Reason: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
原因是 ssl 無法驗証成功
解決方法一:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
解決方法二:
先用火狐或ie開啟連結,下載其 crt 檔,放到自已站中
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/path/download.crt");
缺點要自行注意到期日,重下新的 crt檔


參考連結:http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

2017-04-07

ajax 跨網域授權問題

//a.com.tw 用 ajax 抓 b.com.tw 的php 時, 
//b 站的php 要用 header("Access-Control-Allow-Origin: http://a.com.tw");
//授權給 http://a.com.tw 連入的ajax使用

//底下為 b.com.tw 的php 開頭語法
$http_origin = $_SERVER['HTTP_ORIGIN'];
$allow_origins = array();
//連入的站名
$allow_origins[] = "a.com.tw";
//有沒有 www 為不同來源
$allow_origins[] = "www.a.com.tw";
//要授權給多個須一一輸入
$allow_origins[] = "server1.com";
$allow_origins[] = "server2.com";
$allow_origins[] = "server3.com";
$allow_origins[] = "server4.com";
$allow_origins[] = "www.server1.com";
$allow_origins[] = "www.server2.com";
$allow_origins[] = "www.server3.com";
$allow_origins[] = "www.server4.com";
//如是用區域ip或實體ip 連入時
$allow_origins[] = "192.168.0.2";
$allow_origins[] = "10.0.0.3";
$allow_origins[] = "168.95.1.1";
foreach($allow_origins as $allow_origin){
if( $http_origin == "http://".$allow_origin || $http_origin == "https://".$allow_origin ){
header("Access-Control-Allow-Origin: ".$http_origin);
break;
}
}

?>

2014-03-26

win7 上apache php 用com去開word 2013 另存時,字型沒換的問題

win7 上apache php 用com去開word 2013 時,字型沒換的問題

在win7上 的 apache 要在服務的登入選項中 打勾 允許與桌面互動,才能開word


但要用word另存pdf時,字型沒換,目前決解的方案是
控制台>系統管理工具>元件服務 ,
中的 元件服務 > 電腦 > 我的電腦 > DCOM設定 > mICROSOFT wORD 97-2003的文件
內容 > 識別身分 用 互動式使用者

但使用時一定要有使用登入到桌面,無法在純service下進行,也就是說
開機要用自動登入某使用者,且不能登出。

沒有字型問題就不須要改元件服務了。


2014-01-15

php 把 HTML-ENTITIES HTML code (&#xxxxx;) 轉 utf8

function htmlentities2utf8($str){
$str = preg_replace_callback(
'/&#[0-9]+;/ismU'
,"____htmlentities2utf8"
,$str);
return $str;
}
function ____htmlentities2utf8($m){
return mb_convert_encoding($m[0], 'UTF-8', 'HTML-ENTITIES');
}

//下行要測試時 把 & 和 # 中的空格刪掉
echo htmlentities2utf8("何冠& #39053;") ;

2012-05-29

php 多只能上傳20個檔案 的 php.ini 解決方案

 php 5.2.12 及以上的版本,有個限制是一次最多只能上傳20個檔案而已

該參數 在 php.ini 裡沒有的,也就是 max_file_uploads , 預設值是 20
解決的方法就是在 php.ini  新增 
max_file_uploads = 9999

2012-03-12

當 php 的 gd.so 載入失敗時 libt1.so.5: cannot open shared .....

當 php 的 gd.so 載入失敗時
查看 apache2/error.log
出現
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/gd.so' - libt1.so.5: cannot open shared object file: No such file or directory in Unknown on line 0


請安裝
sudo apt-get install t1lib-bin
或使用
dpkg -s t1lib-bin

2010-12-03

在ubuntu安設定openoffice 的service 給 php用

參考:http://code.google.com/p/openmeetings/wiki/OpenOfficeConverter

Install Open Office Service on Debian/(K)Ubuntu (versions > 2.3)

  1. Install OpenOffice-Headless as root (through su, sudo, etc.):
    sudo apt-get install openoffice.org-headless
  2. Create and edit a file named openoffice.sh (for example) with you favorite editor over /etc/init.d:
    vi /etc/init.d/openoffice.sh
    #!/bin/bash
    # openoffice.org  headless server script
    #
    # chkconfig: 2345 80 30
    # description: headless openoffice server script
    # processname: openoffice
    # 
    # Author: Vic Vijayakumar
    # Modified by Federico Ch. Tomasczik
    #
    OOo_HOME=/usr/bin
    SOFFICE_PATH=$OOo_HOME/soffice
    PIDFILE=/var/run/openoffice-server.pid
    
    set -e
    
    case "$1" in
     start)
    
     if [ -f $PIDFILE ]; then
    
      echo "OpenOffice headless server has already started."
      sleep 5
      exit
     fi
      echo "Starting OpenOffice headless server"
      $SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1
      touch $PIDFILE
     ;;
     stop)
     if [ -f $PIDFILE ]; then
      echo "Stopping OpenOffice headless server."
      killall -9 soffice && killall -9 soffice.bin
      rm -f $PIDFILE
      exit
     fi
      echo "Openoffice headless server is not running."
      exit
     ;;
     *)
     echo "Usage: $0 {start|stop}"
     exit 1
    esac
    exit 0
  3. Change the permssions to this file:
    chmod 0755 /etc/init.d/openoffice.sh
  4. Install openoffice.sh init script links:
    update-rc.d openoffice.sh defaults
  5. Start the service:
    /etc/init.d/./openoffice.sh start
  6. You can see if openofice is running with this command:
    netstat -nap | grep office
You should get something like this:
tcp        0      0 127.0.0.1:8100          0.0.0.0:* 
LISTEN     2467/soffice.bin 

2010-10-14

mu 移站的備忘

因為mu的系統,把主站網址都存成資料庫了,所以要用REPLACE 去更新mysql中的訊息



$dbs = array("bsblogs"=>array("http://the.src.site.dns/pathto/","http://the.new.site.dns/","the.src.site.dns","the.new.site.dns","/pathto/","/"));
foreach ( $dbs as $dbname => $fixv ){
$fix_wp_db->setQuery("USE the_database_name;");
$fix_wp_db->query();
$fix_wp_db->setQuery("SHOW TABLES;");
$tables = $fix_wp_db->loadObjectList();
//print_r($fix_wp_db);
foreach($tables as $tb){
if( preg_match('/[0-9+]_options$/',$tb->Tables_in_the_database_name) ){
echo $tb->Tables_in_the_database_name."
";
$fix_wp_db->setQuery("UPDATE $tb->Tables_in_the_database_name SET option_value = REPLACE( `option_value` , '$fixv[0]', '$fixv[1]' ) ;");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}

if( preg_match('/[0-9+]_posts$/',$tb->Tables_in_the_database_name) ){
echo $tb->Tables_in_the_database_name."
";
$fix_wp_db->setQuery("UPDATE $tb->Tables_in_the_database_name SET post_content = REPLACE( `post_content` , '$fixv[0]', '$fixv[1]' ) ;");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}


}
$fix_wp_db->setQuery("UPDATE wp_site SET domain = REPLACE( `domain` , '$fixv[2]', '$fixv[3]' ) , path = REPLACE( `path` , '$fixv[4]', '$fixv[5]' );");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
$fix_wp_db->setQuery("UPDATE wp_blogs SET domain = REPLACE( `domain` , '$fixv[2]', '$fixv[3]' ) , path = REPLACE( `path` , '$fixv[4]', '$fixv[5]' );");
$tables = $fix_wp_db->query();
if(!$fix_wp_db->_errorMsg)echo $fix_wp_db->getQuery()."
";
else echo $fix_wp_db->_errorMsg."
";
}


.htaccess 也要改

2010-09-27

ubuntu 10.04 要使用freetds 才能連入 mssql

因為我用 php 5.2.x 版的
所以先重裝一次 http://z-win.blogspot.com/2010/05/ubuntu-php-52x.html
最後加上
sudo apt-get install freetds-bin
sudo aptitude install -t karmic php5-sybase
#改freetds 設定(這是我自已要用的)
sudo vim /etc/freetds/freetds.conf
#在[global]加上
text size = 104857600 #大小能到100b
client charset = UTF-8 #預設utf-8
#改mssql_connect的語言
sudo vim /etc/php5/apache2/php.ini
#加入
mssql.charset = "UTF-8"
sudo /etc/init.d/apache2 restart
#test方法
tsql -H mssql.ip -p 1433 -U username
#輸入password後出現 1> 就成功了
#php



#也可以用 匿名主機 方式連入,但mssql 要sp4以上
sudo vim /etc/freetds/freetds.conf
#加入
[mssql_con1]
host = this.con1.server
port = 1433
tds version = 8.0

#test方法
tsql -S mssql_con1 -U username
#輸入password後出現 1> 就成功了

#php測試
<?php
echo mssql_connect('mssql_con1', 'username', 'password') 
? 'success' 
: 'failure';
?> 
當mssql的資料是 uniqueidentifier 在LINUX上的FREETDS 要用  mssql_guid_string 或 在SQL 用 cast(欄位名 as varchar(36)) 轉換字元, 在windows用com 時會自動轉
uniqueidentifier  的說明:
http://technet.microsoft.com/zh-tw/library/ms190215.aspx
php的其它解法可以看:
http://uk.php.net/manual/en/function.mssql-guid-string.php


如果發生:
Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.
請使用底下語法:

SET ANSI_WARNINGS ON
SET ANSI_NULLS ON

參考:
http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/1d501b57-fc58-4fbe-9bec-6c38ad158a62

2010-08-19

有設open_basedir時 phpMyAdmin上載sql問題

當有設open_basedir時,phpMyAdmin,會自動把檔案移動到 自已底下的tmp 資料夾,所以有二個問題要注意
1.tmp要能讀寫
2.php.ini中的upload_tmp_dir不能跟phpMyAdmin/tmp 是同一個

2010-05-17

ubuntu 如何安裝 php 5.2.x 的版本

改用deb來安裝
cd /tmp mkdir php52 cd php52 wget -r -np -nH -nd -R index.html http://archives.dotdeb.org/dists/lenny/php5/5.2.17/binary-amd64/ wget -r -np -nH -nd -R index.html http://archives.dotdeb.org/dists/lenny/php5-pecl/5.2.17/binary-amd64/ wget http://archive.debian.org/debian/pool/main/m/mysql-dfsg-5.0/libmysqlclient15off_5.0.51a-24+lenny5_amd64.deb wget http://archive.debian.org/debian/pool/main/libt/libtool/libltdl3_1.5.22-4+etch1_amd64.deb curl -k https://gist.github.com/nvogel/2971772/raw/4e82f220f61a7a534d94a7114e180d3eb131747b/etc-apt-preferences.d-php5 > /etc/apt/preferences.d/php5 apt-get update
#先安裝
apt-get install curl apache2-mpm-prefork 
#相依套件 apt-get install libdb4.6 wget http://ftp.br.debian.org/debian/pool/main/k/krb5/libkrb53_1.8.3+dfsg-4squeeze6_all.deb dpkg -i libkrb53_1.8.3+dfsg-4squeeze6_all.deb apt-get install libreadline5 wget ftp://ftp.uwsg.indiana.edu/linux/ubuntu/pool/main/libt/libtool/libltdl3_1.5.26-1ubuntu1_amd64.deb dpkg -i libapache2-mod-php5_5.2.17-0.dotdeb.0_amd64.deb \ php5-mysql_5.2.17-0.dotdeb.0_amd64.deb \ php5-cli_5.2.17-0.dotdeb.0_amd64.deb \ php5_5.2.17-0.dotdeb.0_all.deb \ php5-curl_5.2.17-0.dotdeb.0_amd64.deb \ php5-common_5.2.17-0.dotdeb.0_amd64.deb \ libmysqlclient15off_5.0.51a-24+lenny5_amd64.deb # pear #dpkg -i php-pear_5.2.17-0.dotdeb.0_all.deb # suhosin #dpkg -i php5-suhosin_5.2.17-0.dotdeb.0_amd64.deb # cgi # dpkg -i php5-cgi_5.2.17-0.dotdeb.0_amd64.deb # ming # wget http://archive.debian.org/debian/pool/main/m/ming/libming0_0.3.0-14_amd64.deb # dpkg -i libming0_0.3.0-14_amd64.deb # dpkg -i php5-ming_5.2.17-0.dotdeb.0_amd64.deb # imap # apt-get install mlock # wget http://archive.debian.org/debian/pool/main/u/uw-imap/libc-client2007b_2007b~dfsg-4+lenny3_amd64.deb # dpkg -i "libc-client2007b_2007b~dfsg-4+lenny3_amd64.deb" # dpkg -i php5-imap_5.2.17-0.dotdeb.0_amd64.deb # imagick # wget http://archive.debian.org/debian-archive/debian/pool/main/g/graphviz/libgraphviz4_2.20.2-3_amd64.deb # wget http://archive.debian.org/debian-archive/debian/pool/main/i/imagemagick/libmagick10_6.3.7.9.dfsg2-1~lenny4_amd64.deb # dpkg -i libgraphviz4_2.20.2-3_amd64.deb libmagick10_6.3.7.9.dfsg2-1~lenny4_amd64.deb # dpkg -i "php5-imagick_5.2.17-0.dotdeb.0_amd64.deb" # ldap # dpkg -i php5-ldap_5.2.17-0.dotdeb.0_amd64.deb # snmp # dpkg -i php5-snmp_5.2.17-0.dotdeb.0_amd64.deb # spplus # dpkg -i php5-spplus_5.2.17-0.dotdeb.0_amd64.deb # xcache # dpkg -i php5-xcache_5.2.17-0.dotdeb.0_amd64.deb # mcrypt # apt-get install libmcrypt4 # dpkg -i libltdl3_1.5.26-1ubuntu1_amd64.deb # dpkg -i php5-mcrypt_5.2.17-0.dotdeb.0_amd64.deb # apc # dpkg -i php5-apc_5.2.17-0.dotdeb.0_amd64.deb # gd # apt-get install libt1-5 # dpkg -i php5-gd_5.2.17-0.dotdeb.0_amd64.deb # memcache # dpkg -i php5-memcache_5.2.17-0.dotdeb.0_amd64.deb # mhash # apt-get install libmhash2 # dpkg -i php5-mhash_5.2.17-0.dotdeb.0_amd64.deb # xsl # dpkg -i php5-xsl_5.2.17-0.dotdeb.0_amd64.deb apt-get -f install
參考來源:https://gist.github.com/nvogel/2971772#file-install-php5-2-squeeze-sh
底下是以前的舊資料,不一定能用

# remove all php packge
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
# use karmiс for php pakage
# pin-params: a (archive), c (components), v (version), o (origin) and l (label).
echo -e "Package: php5\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee /etc/apt/preferences.d/php > /dev/null
apt-cache search php5-|grep php5-|awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'|sudo tee -a /etc/apt/preferences.d/php > /dev/null
apt-cache search -n libapache2-mod-php5 |awk '{print "Package:", $1,"\nPin: release a=karmic\nPin-Priority: 991\n"}'| sudo tee -a /etc/apt/preferences.d/php > /dev/null
echo -e "Package: php-pear\nPin: release a=karmic\nPin-Priority: 991\n" | sudo tee -a /etc/apt/preferences.d/php > /dev/null
# add karmic to source list
grep 'main restricted' /etc/apt/sources.list|grep -v "#"| sed s/lucid/karmic/g | sudo tee /etc/apt/sources.list.d/karmic.list > /dev/null
# update package database (use apt-get if aptitude crash)
sudo apt-get update
# install php
sudo aptitude install -t karmic php5-cli php5-cgi
# or (and) sudo apt-get install -t karmic libapache2-mod-php5
sudo aptitude hold `dpkg -l | grep php5| awk '{print $2}' |tr "\n" " "`
#done
#底下是我自行加裝

sudo aptitude install -t karmic libapache2-mod-php5
sudo aptitude install -t karmic php5-mysql
sudo aptitude install -t karmic php5-gb
sudo aptitude install -t karmic php5-curl
sudo aptitude install -t karmic php5-ffmpeg
sudo aptitude install -t karmic php5-json
#sudo aptitude install -t karmic php5-mcrypt
sudo aptitude install -t karmic php5-mysqli
sudo aptitude install -t karmic php5-sqlite
sudo aptitude install -t karmic php5-ldap
sudo aptitude install -t karmic php5-xmlrpc
sudo aptitude install -t karmic php5-xsl
sudo aptitude install -t karmic php5-mhash
有更新一些設定
/etc/apt/sources.d/karmic.list
deb http://us.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic main restricted

deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates main restricted

deb http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic universe
deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe

deb http://us.archive.ubuntu.com/ubuntu/ karmic multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic multiverse
deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates multiverse

deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted
deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
deb http://security.ubuntu.com/ubuntu karmic-security multiverse
deb-src http://security.ubuntu.com/ubuntu karmic-security multiverse
/etc/apt/preferences.d/php
Package: php5
Pin: release a=karmic
Pin-Priority: 991

Package: php5-adodb
Pin: release a=karmic
Pin-Priority: 991

Package: php5-auth-pam
Pin: release a=karmic
Pin-Priority: 991

Package: php5-exactimage
Pin: release a=karmic
Pin-Priority: 991

Package: php5-ffmpeg
Pin: release a=karmic
Pin-Priority: 991

Package: php5-geoip
Pin: release a=karmic
Pin-Priority: 991

Package: php5-gpib
Pin: release a=karmic
Pin-Priority: 991

Package: php5-idn
Pin: release a=karmic
Pin-Priority: 991

Package: php5-imagick
Pin: release a=karmic
Pin-Priority: 991

Package: php5-imap
Pin: release a=karmic
Pin-Priority: 991

Package: php5-interbase
Pin: release a=karmic
Pin-Priority: 991

Package: php5-lasso
Pin: release a=karmic
Pin-Priority: 991

Package: php5-librdf
Pin: release a=karmic
Pin-Priority: 991

Package: php5-mapscript
Pin: release a=karmic
Pin-Priority: 991

Package: php5-mcrypt
Pin: release a=karmic
Pin-Priority: 991
Package: php5-memcache
Pin: release a=karmic
Pin-Priority: 991

Package: php5-memcached
Pin: release a=karmic
Pin-Priority: 991

Package: php5-ming
Pin: release a=karmic
Pin-Priority: 991

Package: php5-ps
Pin: release a=karmic
Pin-Priority: 991

Package: php5-radius
Pin: release a=karmic
Pin-Priority: 991

Package: php5-remctl
Pin: release a=karmic
Pin-Priority: 991

Package: php5-sasl
Pin: release a=karmic
Pin-Priority: 991

Package: php5-sqlrelay
Pin: release a=karmic
Pin-Priority: 991

Package: php5-suhosin
Pin: release a=karmic
Pin-Priority: 991

Package: php5-svn
Pin: release a=karmic
Pin-Priority: 991

Package: php5-symfony1.0
Pin: release a=karmic
Pin-Priority: 991

Package: php5-uuid
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xapian
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xcache
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xdebug
Pin: release a=karmic
Pin-Priority: 991

Package: php5-cgi
Pin: release a=karmic
Pin-Priority: 991

Package: php5-cli
Pin: release a=karmic
Pin-Priority: 991

Package: php5-common
Pin: release a=karmic
Pin-Priority: 991

Package: php5-curl
Pin: release a=karmic
Pin-Priority: 991

Package: php5-dbg
Pin: release a=karmic
Pin-Priority: 991

Package: php5-dev
Pin: release a=karmic
Pin-Priority: 991

Package: php5-gd
Pin: release a=karmic
Pin-Priority: 991

Package: php5-gmp
Pin: release a=karmic
Pin-Priority: 991

Package: php5-ldap
Pin: release a=karmic
Pin-Priority: 991

Package: php5-mysql
Pin: release a=karmic
Pin-Priority: 991

Package: php5-odbc
Pin: release a=karmic
Pin-Priority: 991

Package: php5-pgsql
Pin: release a=karmic
Pin-Priority: 991

Package: php5-pspell
Pin: release a=karmic
Pin-Priority: 991

Package: php5-recode
Pin: release a=karmic
Pin-Priority: 991

Package: php5-snmp
Pin: release a=karmic
Pin-Priority: 991

Package: php5-sqlite
Pin: release a=karmic
Pin-Priority: 991

Package: php5-sybase
Pin: release a=karmic
Pin-Priority: 991

Package: php5-tidy
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xmlrpc
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xsl
Pin: release a=karmic
Pin-Priority: 991

Package: php5-enchant
Pin: release a=karmic
Pin-Priority: 991

Package: php5-intl
Pin: release a=karmic
Pin-Priority: 991

Package: libapache2-mod-php5
Pin: release a=karmic
Pin-Priority: 991

Package: libapache2-mod-php5filter
Pin: release a=karmic
Pin-Priority: 991

Package: php-pear
Pin: release a=karmic
Pin-Priority: 991

參考來源:http://mrkandy.wordpress.com/2010/04/16/install-php-5-2-x-in-ubuntu-10-04-lucid/

2009-10-07

主要幾個信用卡(Mastercard,Visa …)通用的驗証正規法

主要幾個信用卡(Mastercard,Visa …)通用的驗証正規法

'/^(?:4[0-9]{12}(?:[0-9]{3})?5[1-5][0-9]{14}6011[0-9]{12}622((12[6-9]1[3-9][0-9])([2-8][0-9][0-9])(9(([0-1][0-9])(2[0-5]))))[0-9]{10}64[4-9][0-9]{13}65[0-9]{14}3(?:0[0-5][68][0-9])[0-9]{11}3[47][0-9]{13})*$/'



參考來源:37 Tested PHP, Perl, and JavaScript Regular Expressions

2009-06-11

php 取得 swf 大小


$swfinfo = getimagesize("C:/wwwroot/mainstar.swf");
print_r($swfinfo);

/*
Array(
[0] => 188
[1] => 220
[2] => 13
[3] => width="188" height="220"
[mime] => application/x-shockwave-flash
)
*/

2009-05-13

動態輸出的swf,不能被 flash player 10 載入?

原來是 flash player 10 在搞鬼 ,當header 有 Content-Disposition: attachment 時,flash player將放棄載入。我的用法如下:

//php

if ( !$_SERVER["HTTP_X_FLASH_VERSION"] ){
header('Content-disposition: attachment; filename='.basename($openswf));
}


'asp

IF Request.ServerVariables("HTTP_X_FLASH_VERSION") = "" THEN
Response.AddHeader "content-disposition", "attachment; filename="&filename
END IF



參考連結:Understanding the security changes in Flash Player 10 Adobe Developer Connection

2009-02-03

mailto 於utf-8的亂碼問題解決方案

先將中文轉為big5,在用rawurlencode轉為rawurl code就能正常顯示了
但是特殊字如:喆,堃等還是會變成 ?(問號)

<a href="mailto:xxx@gmail.com?subject=<?php echo rawurlencode(mb_convert_encoding('utf-8中文標題修正', 'big5', 'utf-8'))?>">
email
</a>




<a href="mailto:xxx@gmail.com?subject=<?php echo rawurlencode(mb_convert_encoding('utf-8中文標題修正', 'big5', 'utf-8'))?>&body=<?php echo rawurlencode(mb_convert_encoding("utf-8內容內容內容內容\n\n\n內容內容\n內容內容\n內容內容", 'big5', 'utf-8'))?>">
email含內文
</a>





參考:Ian 懶惰蟲筆記: mailto 應用 subject 參數中文編碼問題

2008-12-24

PHP preg_match 多行match的用法

用[\s\S]*來完成多行

<?php

$test = "/**

123中文endsadf#!$%#!46i90-t9-9-0

*/";


preg_match('/\\/\\*\\*[\s\S]*/m',$test,$m);

print_r($m);

?>


結果

Array
(
[0] => /**
123中文endsadf#!$%#!46i90-t9-9-0
*/
)




參考:PHP正则表达式匹配多行 - PHP - ◇王者之剑◇-Albert Song's Blog