Skip to content

Instantly share code, notes, and snippets.

View geek01's full-sized avatar
🎯
Focusing

Chiung-Hung Lai geek01

🎯
Focusing
View GitHub Profile
@geek01
geek01 / sec2time.js
Created April 16, 2020 06:47 — forked from vankasteelj/sec2time.js
Javascript - Seconds to Time (hh:mm:ss,ms) -> sec2time(593.685038) becomes 00:09:53,685
function sec2time(timeInSeconds) {
var pad = function(num, size) { return ('000' + num).slice(size * -1); },
time = parseFloat(timeInSeconds).toFixed(3),
hours = Math.floor(time / 60 / 60),
minutes = Math.floor(time / 60) % 60,
seconds = Math.floor(time - minutes * 60),
milliseconds = time.slice(-3);
return pad(hours, 2) + ':' + pad(minutes, 2) + ':' + pad(seconds, 2) + ',' + pad(milliseconds, 3);
}
@geek01
geek01 / theme_change.php
Created August 19, 2019 08:15
Xoops強制變更佈景
<?php
$theme = 'THEME NAME';
$GLOBALS['xoopsConfig']['theme_set'] = $theme;
$GLOBALS['xoopsConfig']['theme_set_allowed'][] = $theme;
@geek01
geek01 / laypage.js
Created March 7, 2019 13:55
laypage.js轉換正體中文編碼
/** layui-v2.4.5 MIT License By https://www.layui.com */
;layui.define(function(e){"use strict";var a=document,t="getElementById",n="getElementsByTagName",i="laypage",r="layui-disabled",u=function(e){var a=this;a.config=e||{},a.config.index=++s.index,a.render(!0)};u.prototype.type=function(){var e=this.config;if("object"==typeof e.elem)return void 0===e.elem.length?2:3},u.prototype.view=function(){var e=this,a=e.config,t=a.groups="groups"in a?0|a.groups:5;a.layout="object"==typeof a.layout?a.layout:["prev","page","next"],a.count=0|a.count,a.curr=0|a.curr||1,a.limits="object"==typeof a.limits?a.limits:[10,20,30,40,50],a.limit=0|a.limit||10,a.pages=Math.ceil(a.count/a.limit)||1,a.curr>a.pages&&(a.curr=a.pages),t<0?t=1:t>a.pages&&(t=a.pages),a.prev="prev"in a?a.prev:"&#x4e0a;&#x4e00;&#x9801;",a.next="next"in a?a.next:"&#x4e0b;&#x4e00;&#x9801;";var n=a.pages>t?Math.ceil((a.curr+(t>1?1:0))/(t>0?t:1)):1,i={prev:function(){return a.prev?'<a href="javascript:;" class="layui-laypage-prev'+(1==a.curr?" "+r:"")+'" data
@geek01
geek01 / layer.js
Created January 30, 2019 06:16
layer.js轉換正體中文編碼
/** layui-v2.4.5 MIT License By https://www.layui.com */
;!function(e,t){"use strict";var i,n,a=e.layui&&layui.define,o={getPath:function(){var e=document.currentScript?document.currentScript.src:function(){for(var e,t=document.scripts,i=t.length-1,n=i;n>0;n--)if("interactive"===t[n].readyState){e=t[n].src;break}return e||t[i].src}();return e.substring(0,e.lastIndexOf("/")+1)}(),config:{},end:{},minIndex:0,minLeft:[],btn:["&#x78ba;&#x5b9a;","&#x53d6;&#x6d88;"],type:["dialog","page","iframe","loading","tips"],getStyle:function(t,i){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](i)},link:function(t,i,n){if(r.path){var a=document.getElementsByTagName("head")[0],s=document.createElement("link");"string"==typeof i&&(n=i);var l=(n||t).replace(/\.|\//g,""),f="layuicss-"+l,c=0;s.rel="stylesheet",s.href=r.path+t,s.id=f,document.getElementById(f)||a.appendChild(s),"function"==typeof i&&!function u(){return++c>80?e.console&&console.error("la
@geek01
geek01 / Xoops_htmlSpecialChars_note
Last active December 28, 2018 01:38
Xoops過濾函數htmlSpecialChars問題
Xoops內過濾函數htmlSpecialChars效果與php函數htmlspecialchars差異:不會將 & 轉換為 &amp;
使用phpword輸出內容時,必須將&符號進行轉換
function htmlSpecialChars($text, $quote_style = ENT_QUOTES, $charset = null, $double_encode = true)
{
if (version_compare(phpversion(), '5.2.3', '>=')) {
$text = htmlspecialchars($text, $quote_style, $charset ? $charset : (defined('_CHARSET') ? _CHARSET : 'UTF-8'), $double_encode);
} else {
$text = htmlspecialchars($text, $quote_style);
}
@geek01
geek01 / xoops_jgrowl_notify.php
Created December 13, 2018 08:09
xoops 轉場效果 jquery.jgrowl 改用 bootstrap-notify
<?php
/*
modules/system/preloads/core.php
*/
$GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js');
$GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/plugins/bootstrap-notify.min.js');
$GLOBALS['xoTheme']->addScript('', array('type' => 'text/javascript'), '
$(document).ready(function(){
$.notify({
@geek01
geek01 / tadtools_sweet_alert_add_csrf.php
Last active December 17, 2018 02:36
tadtools刪除js加入防範csrf
<?php
//刪除確認的JS
if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php")) {
redirect_header("index.php", 3, _MD_NEED_TADTOOLS);
}
include_once XOOPS_ROOT_PATH . "/modules/tadtools/sweet_alert.php";
$sweet_alert_obj = new sweet_alert();
//產生token
$token = new XoopsSecurity();
$render_token = $token->createToken(0, 'csrf_token');
@geek01
geek01 / index.php
Last active April 2, 2018 08:08
tadgallery加入相片分頁
<?php
//列出所有照片
function list_photos($csn = "", $uid = "")
{
global $xoopsModuleConfig, $xoopsTpl, $tadgallery, $xoopsDB;
if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/fancybox.php")) {
redirect_header("index.php", 3, _MA_NEED_TADTOOLS);
}
@geek01
geek01 / TadUpFiles.php
Last active March 5, 2018 16:10
TadUpFiles加入MIME types篩選
<?php
/*
//加入上傳檔案MIME types篩選
//新增ext2mime函數,可將副檔名轉換為MIME types,提供給$file_handle->allowed使用
//$allow = "doc;docx;pdf",利用分號;區分允許上傳的檔案類型
$TadUpFiles->upload_file($upname,$width,$thumb_width,$files_sn,$desc,$safe_name=false,$hash=false,$return_col,$allow);
//上傳表單(enctype='multipart/form-data')
include_once XOOPS_ROOT_PATH."/modules/tadtools/TadUpFiles.php" ;
$TadUpFiles=new TadUpFiles("模組名稱",$subdir,$file="/file",$image="/image",$thumbs="/image/.thumbs");
@geek01
geek01 / html_form
Created March 29, 2017 07:02 — forked from zvineyard/html_form
PHP: Upload and Rename File
<form action="" enctype="multipart/form-data" method="post">
<input id="file" name="file" type="file" />
<input id="Submit" name="submit" type="submit" value="Submit" />
</form>