米薩克
  • 首頁
  • KBtalKing Pro
  • 關於作者
  • 鍵盤
  • 滑鼠
  • 工具
  • 網站連結
  • 首頁
  • KBtalKing Pro
  • 關於作者
  • 鍵盤
  • 滑鼠
  • 工具
  • 網站連結
米薩克

Mesak 敗家、筆記、生活

分類:

PHP

PHP

PHP

[PHP] XOOPS 加入外部檔案驗證

by Mesak 2010-09-08
written by Mesak

XOOPS 寫模組有個問題….

假設模組需要用到 Jquery檔案,要載入

一般寫在 HEADER 下面就行了

$xoopsTpl->assign("xoops_module_header", '');

但是,XOOPS也是有佈景檔的,當佈景檔已經載入 JQUERY.JS 這時候就會發生小小衝突

寫了一個 函式,由PHP 判斷 ‘jquery/jquery.js’ 這隻程式是否被載入

繼續閱讀
2010-09-08 0 comment
0 FacebookTwitterPinterestTumblrRedditLINEEmail
PHP

[PHP] JSON PHP 5.2.0以前的支援

by Mesak 2010-04-21
written by Mesak
if(!function_exists('json_decode')){
include("json.php");
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
function json_decode($arr){
global $json;
return $json->decode($arr);
}
function json_encode($arr){
global $json;
return $json->encodeUnsafe($arr);
}
}

JSON Class 的名稱為 Services_JSON

* @category
* @package     Services_JSON
* @author &nbsp; &nbsp; &nbsp;Michal Migurski <mike-json@teczno.com>
* @author &nbsp; &nbsp; &nbsp;Matt Knapp <mdknapp[at]gmail[dot]com>
* @author &nbsp; &nbsp; &nbsp;Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright &nbsp; 2005 Michal Migurski
* @version &nbsp; &nbsp; CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license &nbsp; &nbsp; http://www.opensource.org/licenses/bsd-license.php
* @link &nbsp; &nbsp; &nbsp; &nbsp;http://pear.php.net/pepr/pepr-proposal-show.php?id=198
繼續閱讀
2010-04-21 0 comment
0 FacebookTwitterPinterestTumblrRedditLINEEmail
PHP

[PHP] 上傳與下載

by Mesak 2010-04-16
written by Mesak

下載 function ,google 搜尋到的 修正 IE 中文檔名會錯誤的問題

使用用法,檔名可不加,不加即為路徑檔名

dl_file("路徑","檔名")
function &nbsp;dl_file($file,$fname=""){
//First, see if the file exists
if (!is_file($file)) { die("<strong>404 File not found!</strong>"); }
//Gather relevent info about file
$filename = ($fname)? $fname:basename($file);
if(strpos($_SERVER['HTTP_USER_AGENT'] ,"MSIE")){
$filename = urlencode ($filename);
}
//Gather relevent info about file
$len = filesize($file);
$file_extension = strtolower(getExtension($file));

//This will set the Content-Type to the appropriate setting for the file
switch( $file_extension ) {
case "pdf": $ctype="application/pdf"; break;
case "exe": $ctype="application/octet-stream"; break;
case "zip": $ctype="application/zip"; break;
case "doc": $ctype="application/msword"; break;
case "xls": $ctype="application/vnd.ms-excel"; break;
case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
case "mp3": $ctype="audio/mpeg"; break;
case "wav": $ctype="audio/x-wav"; break;
case "mpeg":
case "mpg":
case "mpe": $ctype="video/mpeg"; break;
case "mov": $ctype="video/quicktime"; break;
case "avi": $ctype="video/x-msvideo"; break;
//The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files)
case "php":
case "htm":
case "html":
case "txt": $ctype="application/octet-stream"; break;
default: $ctype="application/force-download";
}
//Use the switch-generated Content-Type
 &nbsp; //Force the download
header('Pragma: public');
header('Expires: 0');
header('Last-Modified: ' . gmdate('D, d M Y H:i ') . ' GMT');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Cache-Control: public");
header("Content-Type: $ctype");
header("Content-Description: File Transfer");
header('Content-Disposition: attachment; Filename="'.$filename.'"');
header('Content-Transfer-Encoding: binary');
header("Content-Length: ".$len);
@readfile($file);
exit;
}
繼續閱讀
2010-04-16 1 comment
0 FacebookTwitterPinterestTumblrRedditLINEEmail
PHP

[PHP] 逐行讀入替換掉無法替換的 Enter

by Mesak 2008-07-04
written by Mesak

PHP 有個說明文件非常方便,想查什麼函式只要記得一點點就可以查找出來

前兩天我用了 逐行讀入的 程式,查找的是 file()

程式如下

$lines = file('http://www.example.com/');

// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #{$line_num} : " . htmlspecialchars($line) . "
";
}

但是讀出了之後,我想把換行刪除掉卻一直也刪不掉….

用了 str_replace() 取代  “\n”,卻一直無法取代

還用了 n2br,也無法取代掉…..

繼續閱讀
2008-07-04 0 comment
0 FacebookTwitterPinterestTumblrRedditLINEEmail
較新文章
較舊文章

米薩克

米薩克

近期文章

  • [程式] Vibe Coding 實作小專案 LinkEveryWord
  • [教學] 利用 n8n 建立 LINE 聊天機器人
  • [開箱] IROCKS K103R 熱插拔無線機械式鍵盤
  • [開箱] IROCKS-K85R 無線機械鍵盤
  • [開箱] IROCKS K75M 銀色上蓋機械式鍵盤

彙整

  • 2025 年 9 月
  • 2025 年 6 月
  • 2025 年 3 月
  • 2024 年 4 月
  • 2023 年 10 月
  • 2023 年 9 月
  • 2023 年 8 月
  • 2023 年 2 月
  • 2023 年 1 月
  • 2022 年 11 月
  • 2022 年 7 月
  • 2022 年 5 月
  • 2022 年 3 月
  • 2022 年 2 月
  • 2021 年 12 月
  • 2021 年 11 月
  • 2021 年 10 月
  • 2021 年 7 月
  • 2021 年 6 月
  • 2021 年 4 月
  • 2021 年 3 月
  • 2021 年 2 月
  • 2020 年 12 月
  • 2020 年 11 月
  • 2020 年 10 月
  • 2020 年 9 月
  • 2020 年 8 月
  • 2020 年 7 月
  • 2020 年 6 月
  • 2020 年 5 月
  • 2020 年 4 月
  • 2020 年 3 月
  • 2020 年 2 月
  • 2020 年 1 月
  • 2019 年 12 月
  • 2019 年 11 月
  • 2019 年 10 月
  • 2019 年 9 月
  • 2019 年 8 月
  • 2019 年 7 月
  • 2019 年 6 月
  • 2019 年 5 月
  • 2019 年 4 月
  • 2019 年 3 月
  • 2019 年 2 月
  • 2019 年 1 月
  • 2018 年 12 月
  • 2018 年 11 月
  • 2018 年 9 月
  • 2018 年 8 月
  • 2018 年 7 月
  • 2018 年 6 月
  • 2018 年 5 月
  • 2018 年 4 月
  • 2018 年 3 月
  • 2018 年 2 月
  • 2018 年 1 月
  • 2017 年 12 月
  • 2017 年 11 月
  • 2017 年 10 月
  • 2017 年 9 月
  • 2017 年 8 月
  • 2017 年 6 月
  • 2017 年 4 月
  • 2017 年 3 月
  • 2017 年 2 月
  • 2017 年 1 月
  • 2016 年 12 月
  • 2016 年 11 月
  • 2016 年 10 月
  • 2016 年 9 月
  • 2016 年 8 月
  • 2016 年 7 月
  • 2016 年 6 月
  • 2016 年 5 月
  • 2016 年 4 月
  • 2016 年 3 月
  • 2016 年 1 月
  • 2015 年 12 月
  • 2015 年 11 月
  • 2015 年 10 月
  • 2015 年 9 月
  • 2015 年 8 月
  • 2015 年 7 月
  • 2015 年 6 月
  • 2015 年 5 月
  • 2015 年 4 月
  • 2015 年 3 月
  • 2015 年 2 月
  • 2015 年 1 月
  • 2014 年 12 月
  • 2014 年 11 月
  • 2014 年 10 月
  • 2014 年 9 月
  • 2014 年 8 月
  • 2014 年 7 月
  • 2014 年 6 月
  • 2014 年 5 月
  • 2014 年 4 月
  • 2014 年 3 月
  • 2014 年 2 月
  • 2014 年 1 月
  • 2013 年 12 月
  • 2013 年 11 月
  • 2013 年 9 月
  • 2013 年 8 月
  • 2013 年 7 月
  • 2013 年 6 月
  • 2013 年 5 月
  • 2013 年 4 月
  • 2013 年 3 月
  • 2013 年 2 月
  • 2013 年 1 月
  • 2012 年 12 月
  • 2012 年 11 月
  • 2012 年 10 月
  • 2012 年 9 月
  • 2012 年 8 月
  • 2012 年 7 月
  • 2012 年 6 月
  • 2012 年 5 月
  • 2012 年 4 月
  • 2012 年 3 月
  • 2012 年 2 月
  • 2012 年 1 月
  • 2011 年 12 月
  • 2011 年 11 月
  • 2011 年 10 月
  • 2011 年 9 月
  • 2011 年 8 月
  • 2011 年 7 月
  • 2011 年 6 月
  • 2011 年 5 月
  • 2011 年 4 月
  • 2011 年 3 月
  • 2011 年 2 月
  • 2010 年 11 月
  • 2010 年 10 月
  • 2010 年 9 月
  • 2010 年 7 月
  • 2010 年 4 月
  • 2010 年 3 月
  • 2009 年 11 月
  • 2008 年 12 月
  • 2008 年 10 月
  • 2008 年 9 月
  • 2008 年 8 月
  • 2008 年 7 月
  • 2008 年 6 月
  • 2008 年 4 月
  • 2008 年 3 月
  • 2008 年 2 月
  • 2008 年 1 月
  • 2007 年 12 月
  • 2007 年 11 月
  • 2007 年 10 月
  • 2007 年 9 月
  • 2007 年 8 月
  • 2007 年 7 月
  • 2007 年 6 月
  • 2007 年 5 月
  • 2007 年 4 月
  • 2007 年 3 月
  • 2007 年 2 月
  • 2007 年 1 月
  • 2006 年 12 月
  • 2006 年 11 月
  • 2006 年 10 月
  • 2006 年 9 月
  • 2006 年 8 月
  • 2006 年 7 月
  • 2006 年 6 月
  • 2006 年 5 月
  • 2006 年 3 月
  • 2006 年 2 月
  • 2006 年 1 月
  • 2005 年 12 月
  • 2005 年 11 月
  • 2005 年 10 月
  • 2005 年 9 月
  • 2005 年 8 月

分類

  • 個人配件
  • 咖啡
  • 家用主機
  • 居家
    • 家具
    • 家電
  • 工具
    • 文具
  • 影音
  • 玩具
  • 硬體
    • 3D Printer
    • 其他周邊
    • 喇叭
    • 手把
    • 手機
    • 滑鼠
    • 相機
    • 耳機
    • 鍵盤
    • 電源
  • 碎碎念念
  • 程式
    • Chrome extensions
    • JavaScript
    • PHP
    • Python
    • Vue
    • WordPress
  • 網路資訊
  • 美食
  • 軟體
  • 遊戲
  • 遊玩
  • 運動

書籤

  • 歡迎交換連結

About

Mesak

mesak

http://about.me/mesak

Contact:

Mesak Gmail

Histats:

Online:

2025 年 9 月
一二三四五六日
1234567
891011121314
15161718192021
22232425262728
2930 
« 6 月    
  • Facebook
  • Twitter

@2020- All Right Reserved. Designed and Developed by PenciDesign


Back To Top
米薩克
  • 首頁
  • KBtalKing Pro
  • 關於作者
  • 鍵盤
  • 滑鼠
  • 工具
  • 網站連結
@2020- All Right Reserved. Designed and Developed by PenciDesign