//------------------------
// 資料庫主機設定
公告版位
目前分類:php常用函數 (44)
- May 24 Wed 2017 17:17
[php]pdo專用的mysql_real_escape_string取代函數
- May 12 Fri 2017 16:43
[php]處理XSS與ckeditor編輯器的html code欄位輸出問題
- Mar 20 Mon 2017 11:56
[php]移除html文章中的style屬性
function remove_style($str)
{
- Mar 17 Fri 2017 14:08
[php]將西元日期轉成農曆日期
<?php
class Lunar {
- Jan 04 Wed 2017 10:35
[php]IP與長整數互轉(ipv6)
- Dec 29 Thu 2016 14:10
[php]檢查web server是否存活函數
- Dec 13 Tue 2016 11:12
[php]用於UTF字符的西里爾字母到拉丁字母的翻譯(批次字串替代)
- Dec 02 Fri 2016 17:25
[php]簡單備份mysql工具(使用mysqli)
- Aug 10 Wed 2016 10:43
[php]自動縮圖 , 插入文字 , 插入浮水印
function ecstart_convert_jpeg(
$src_file,$dst_file,$text_type,$text_image,$watermark_type,$watermark_image,$pic_width,
$pic_height){
//$src_file 來源圖片路徑
//$dst_file 存檔圖片路徑
//$text_type 是否插入文字
//$text_image 插入的文字內容
//$watermark_type 是否插入浮水印
//$watermark_image 圖水印圖片路徑
//$pic_width 存檔圖片寬度
//$pic_height 存檔圖片高度
$image = imagecreatefromjpeg($src_file) ;
$s_width = imagesx($image);
$s_height = imagesy($image);
// 縮圖大小
$thumb = imagecreatetruecolor($pic_width, $pic_height);
// 自動縮圖
imagecopyresized($thumb, $image, 0, 0, 0, 0, $pic_width, $pic_height, $s_width, $s_height);
//imagejpeg($thumb,"/tmp/tmpfile.jpg","100");
//$thumbimage = imagecreatefromjpeg("/tmp/tmpfile.jpg") ;
// 取得寬度
$i_width = imagesx($thumb);
$i_height = imagesy($thumb);
//imagejpeg($image,"/home/www/ecstart.com/public_html/cart/test.jpg","100");
//imagejpeg($image);
// 計算 插入文字出現位置
$ywpos = $i_height - 35 ;
// 設定 插入文字
$textcolor = imagecolorallocate($thumb, 250, 250, 250);
// 插入文字
if($text_type == "Y"){
imagestring($thumb, 5, 25, $ywpos, $text_image, $textcolor);
}
// 載入浮水印圖
$w_image = imagecreatefromjpeg($watermark_image) ;
// 取出浮水印圖 寬 與 高
$w_width = imagesx($w_image);
$w_height = imagesy($w_image);
// 計算 浮水印出現位置
$xpos = $i_width - $w_width -20 ;
$ypos = $i_height - $w_height-20 ;
//結合浮水印
if($watermark_type == "Y"){
imagecopy($thumb,$w_image,$xpos,$ypos,0,0,$w_width,$w_height);
}
imagejpeg($thumb,$dst_file,"100");
imagedestroy($thumb);
imagedestroy($image);
imagedestroy($w_image);
}
- Jul 29 Fri 2016 11:09
[php]取得使用者,使用那一種瀏覽器函數
<?php
function get_browser_name($user_agent)
- Jul 20 Wed 2016 17:38
[php]刪除HTML字串中圖片的寬度與高度屬性
$content="<img src='' width='500' height='300'>
<img src='' width=\"500\" height=\"300\">
- Jul 18 Mon 2016 09:09
[php]mt_rand_str 返回隨機字串(自訂字串,會重複)
function mt_rand_str ($l, $c = 'abcdefghijklmnopqrstuvwxyz1234567890') {
for ($s = '', $cl = strlen($c)-1, $i = 0; $i < $l; $s .= $c[mt_rand(0, $cl)], ++$i);
- Jul 15 Fri 2016 10:39
[php]將色碼轉成RGB函數
- Jul 14 Thu 2016 14:32
[php]將RGB轉成色碼函數
- Jul 14 Thu 2016 14:06
[php]無條件進位(可設定小數後幾位)
- Jun 29 Wed 2016 14:53
[php]顯示檔案權限函數
function file_perms($file, $octal = false)
{
- Jun 29 Wed 2016 10:56
Undefined index 報錯 _GET函數取代$_GET
- Jun 27 Mon 2016 11:20
PHP 刪除目錄(含檔案與子目錄)比ftp刪除還快
<?php
SureRemoveDir($_SERVER['DOCUMENT_ROOT']."/test3", false); //false: 保留目前資料夾
- Jun 27 Mon 2016 11:13
模擬xcopy的函數
<?php
/*************************************
- Jun 24 Fri 2016 12:00
[php]取出URL的檔名(帶參數URL)
<?php