利用 AlphaImageLoader 解決 IE6 對 png 圖檔的透明問題

September 7th, 2011

根據 http://jquery.andreaseberhard.de/pngFix/

都是利用使用AlphaImageLoader解決 IE6 對 png 圖檔的透明問題

從而找到有關資料

http://jax-work-archive.blogspot.com/2009/07/alphaimageloader-ie6-png.html

CSS :

#ContainerWrapper{
background: transparent url(/images/border_bg.png) repeat-y;
width:982px;
margin:0 auto;

/*IE6 PNG 檔透明修正設定*/
_background: transparent;
_filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=’/images/border_bg.png’, sizingMethod=’scale’);
}

#ContainerWrapper #Container{
/*修正 AlphaImageLoader 造成的連結失效問題*/
_position:relative;
}

HTML:

<div id=”ContainerWrapper”>
<div id=”Container”>
</div>
</div>

Javascript, Program ,

php – 防止訪問

July 2nd, 2011

在一些header設定

define(‘ROOT’, TRUE);

在include file設定

<?php if(!defined(‘ROOT‘)) { exit(‘Access Denied‘); }

如果打開了allow_url_include, 這個方法就可以防止訪問, “ROOT” 可以更改你喜歡的變量, 如果有人利用你一些config file,也需要時間猜你的變量

 

PHP, Program ,

CSS – print next page

June 16th, 2011

page-break-before: always;

CSS, Style ,

PHP – sort different

June 13th, 2011

<?php
$a = array(2,    "a",  "11", 2);
$b = array(2,    "11", "a",  2);
sort($a);
var_dump($a);
sort($b);
var_dump($b);


/*

Output:

array(4) {
  [0]=>
  string(2) "11"
  [1]=>
  string(1) "a"
  [2]=>
  int(2)
  [3]=>
  int(2)
}
array(4) {
  [0]=>
  int(2)
  [1]=>
  int(2)
  [2]=>
  string(2) "11"
  [3]=>
  string(1) "a"
}

 

*/

?>

PHP , ,

過濾用戶提交過來的GLOBALS信息

June 6th, 2011

if (isset($_REQUEST[‘GLOBALS’]) OR isset($_FILES[‘GLOBALS’])) {
exit(‘Request tainting attempted.’);
}

眾所周知,當php.ini裡面的register_globals=on時,各種變量都被注入代碼,例如來自HTML 表單的請求變量。再加上PHP 在使用變量之前是無需進行初始化的。那麼就有可能導致不安全,假如有人惡意發出這麼一個get請求”http://yourdomain /unsafe.php?GLOBALS=”,那麼就會清除$GLOBALS變量的值而導致不安全。所以我們可以這樣子寫

PHP, Program , , , ,

PHP – Sudoku Solver

June 5th, 2011

自制program – 數獨破解器

訓練program 結構

PHP, Program , ,

CSS – 區別IE6、IE7、IE8、Firefox

June 4th, 2011

以下內容是從 http://sofree.cc/ie6-ie7-ie8-firefox-css-hack/ 轉載

區別IE和Firefox

【辨識符號】:「\9

【範例練習】:

#tip {

background:blue; /*Firefox 背景變藍色*/

background:red \9; /*IE6、IE7、IE8背景變紅色*/

}

【說明】:因為IE瀏覽器看得懂「\9」,但是非IE的瀏覽器一律看不懂,因此就可以用這個語法來區分IE和 Firefox(非IE瀏覽器,像是Opera、Google Chrome、Safari等),因此以上CSS範例中,非IE瀏覽器是顯示藍色背景,IE系列瀏覽器是顯示紅色背景。 Read more…

CSS, Style , ,

PHP – Random

June 4th, 2011

function random($length = 10)
{
/*
* Random the key a to Z and 0 – 9
*/
$key = array(“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”, “t”, “u”, “v”, “w”, “x”, “y”, “z”,
“A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”, “N”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z”,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
$maxLength = sizeof($key);
$output = “”;
if($length > 0) {
for($i = 0; $i <$length; $i++) {
$output .= $key[rand(0,$maxLength-1)];
}
}

return $output;
}

PHP, Program ,

PHP – Get ip

June 4th, 2011

/*
* Return the real IP address
*/
function getRealIP() {
if ( isset($_SERVER[“REMOTE_ADDR”]) )    {
$myip = $_SERVER[“REMOTE_ADDR”] . ‘ ‘;
} else if ( isset($_SERVER[“HTTP_X_FORWARDED_FOR”]) )    {
$myip = $_SERVER[“HTTP_X_FORWARDED_FOR”] . ‘ ‘;
} else if ( isset($_SERVER[“HTTP_CLIENT_IP”]) )    {
$myip = $_SERVER[“HTTP_CLIENT_IP”] . ‘ ‘;
}
return $myip;
}

PHP, Program ,

Object Relational Mapping

June 4th, 2011
ORM (Object Relational Mapping) systems are useful in getting you started with a project. They help you to quickly create objects that model your Data Source, letting you interact with the data in a simple and intuative manner.
While ORM is extremely useful, especially in smaller projects, this usefulness comes at a price. ORM becomes a problem in long-term maintenance as you are committed to the ORM you initially select, whether its LINQ, SubSonic, NHibernate, or any other ORM Software Factory system that generates class based on the targeted data source you will need to select one and, in most cases, will be married to it throughout the development (and product) life cycle.

While this may not seem to be a deal breaker it is not until later, during the longer-term maintenance phase, that the price is paid. Developers who inherit the project from you will be forced to continue to use the ORM you selected, even if its no longer available. And if the ORM system is open-source, with its source code available for you to modify, upgrades (or downgrades) to a different version can cause major headaches which often result in the development team refusing to make changes to the ORM for fear of crashing the application (or even worse would be to cause lots of runtime errors that are only discovered after the upgrade).

Another disadvantage is that if the data source schema is changed the application is not shielded from the change. The relational schema of the data is hard coded into the application via the generated classes. If the data model changes the ORM object won’t know until they are regenerated by the ORM software.
The moral of this story is to use caution when working with ORM systems. Anticipating and addressing these kinds of issues beforehand can help to avoid having your hands tied later down the line.

Program