Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / userinfo.php
Created August 1, 2014 20:35
[concrete5] add expiry time to user registration validation hash (~5.6.x)
<?php
defined('C5_EXECUTE') or die("Access Denied.");
class UserInfo extends Concrete5_Model_UserInfo {
public static function getByValidationHash($uHash, $unredeemedHashesOnly = true, $passtimestamp = 604800) {
$uDateGenerated = time() - $passtimestamp;
$db = Loader::db();
@hissy
hissy / gist:998062e126322e11e3b3
Last active August 29, 2015 14:04
[WordPress] 次の営業日を取得する
<?php
$holidays = array('08-13', '08-14', '08-15'); // 休日の定義
$weekend = array('Sun', 'Sat'); // 土日の定義
$date = new DateTime(); // 現在時刻の取得
$dateList = array(); // 日付を格納する空の配列を定義
$i = 0;
while ($i < 7) { // 直近7日間を取得
$date->add(DateInterval::createFromDateString('1 day')); // 1日送る
@hissy
hissy / gist:3739da85b8e2761aae28
Created August 18, 2014 10:23
フォームの回答から抽選するスクリプト、toolsに設置
<?php
defined('C5_EXECUTE') or die("Access Denied.");
// Formブロックをロード
Loader::block('form');
// ヘルパーのロード
$valn = Loader::helper('validation/numbers');
// フォームの結果を見れる権限があるかのチェック
@hissy
hissy / site.php
Last active August 29, 2015 14:06
[concrete5] Force SSL when user is logged in
<?php
// Add below codes into config/site.php
// If User is logged in
if (isset($_SESSION['uID']) && $_SESSION['uID'] > 0 && isset($_SESSION['uName']) && $_SESSION['uName'] != '') {
define('BASE_URL', 'https://example.com');
} else {
define('BASE_URL', 'http://example.com');
}
<?php
/*
Plugin Name: Really Simple CSV Importer add-on: Comma
Version: 0.1
*/
class rscsvimporter_comma {
// singleton instance
private static $instance;
@hissy
hissy / site_post.php
Last active August 29, 2015 14:10
concrete5で、特定のディレクトリだけ英語サイトにする(Internationalizationアドオンを使わない簡易版)(〜5.6.x)
<?php
// config/site_post.php
defined('C5_EXECUTE') or die("Access Denied.");
$req = Request::get();
$reqPath = $req->getRequestPath();
if ( strpos($reqPath, 'en/') !== false ) {
Localization::changeLocale('en_US');
}
@hissy
hissy / gist:72827af7d2893450cb95
Last active August 29, 2015 14:11
#concrete5 オートナビテンプレートで第1階層だけulから外れるパターン
<?php defined('C5_EXECUTE') or die("Access Denied.");
$navItems = $controller->getNavItems();
?>
<div class="menu">
<?php
// サブメニューが開いているかどうかのフラグ
$subMenuIsOpen = false;
@hissy
hissy / gist:7e690f20f2cb2f440c10
Created December 18, 2014 10:29
#concrete5 #autonav "Exclude from breadcrumb" attribute
<?php defined('C5_EXECUTE') or die("Access Denied.");
$navItems = $controller->getNavItems(true);
echo '<ul class="clearfix">'; //opens the top-level menu
foreach ($navItems as $ni) {
echo '<li>'; //opens a nav item
@hissy
hissy / app.php
Last active August 29, 2015 14:11
#concrete5 #5.7 How to generate Global Areas for each language section, for multilingual site.
<?php
// application/config/app.php
return array(
'aliases' => array(
'GlobalArea' => '\Application\Src\Area\GlobalArea'
)
);
@hissy
hissy / backlog-deploy.php
Created January 4, 2015 17:00
Automated git deployments from Backlog
<?php
// Original: http://jonathannicol.com/blog/2013/11/19/automated-git-deployments-from-bitbucket/
$repo_dir = '/home/<username>/<repo-name>.git';
$web_root_dir = '/home/<username>/public_html';
// Full path to git binary is required if git is not in your PHP user's path. Otherwise just use 'git'.
$git_bin_path = 'git';
$update = false;