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 / birthday_select2.html
Last active August 29, 2015 14:14
birthday select jQuery
<script type='text/javascript' src='class/aj-birthday.js'></script>
<script type='text/javascript'>
$(function() {
$('.birthday-zone-$fname').ajbirthday();
$('#bi_all_$fname').val('');
bi_auto_com_$fname();
});
function bi_auto_com_$fname() {
$('.day').change(function() {
@geek01
geek01 / getPageBar.php
Last active January 12, 2016 07:34
tad_function 分頁工具 for boostrap3
<?php
//取得分頁工具
if(!function_exists('getPageBar_bs')){
function getPageBar_bs($sql="",$show_num=20,$page_list=10,$to_page="",$url_other=""){
global $xoopsDB;
if(empty($show_num))$show_num=20;
if(empty($page_list))$page_list=10;
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],10, mysql_error()."<br>$sql");
$total=$xoopsDB->getRowsNum($result);
@geek01
geek01 / ckeditor.html
Created February 10, 2015 02:22
在樣板使用tadtools ckeditor
/*
後端必須加入
$dirname = basename(dirname(__FILE__));
$_SESSION['xoops_mod_name']=$dirname;
讓elfinder作用
*/
<link rel='stylesheet' type='text/css' href='<{$xoops_url}>/modules/tadtools/ckeditor/mathquill.css' />
<script src='<{$xoops_url}>/modules/tadtools/ckeditor/mathquill.js'></script>
<script type='text/javascript' src='<{$xoops_url}>/modules/tadtools/ckeditor/ckeditor.js'></script>
@geek01
geek01 / xss_clean.php
Last active January 12, 2016 07:34 — forked from mbijon/xss_clean.php
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
<?php
/*
* XSS filter
*
* This was built from numerous sources
* (thanks all, sorry I didn't track to credit you)
*
* It was tested against *most* exploits here: http://ha.ckers.org/xss.html
* WARNING: Some weren't tested!!!
* Those include the Actionscript and SSI samples, or any newer than Jan 2011
@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>
@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 / 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 / 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 / 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 / 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);
}