Skip to content

Instantly share code, notes, and snippets.

View katzueno's full-sized avatar

Katz Ueno katzueno

View GitHub Profile
@katzueno
katzueno / bulk_change_page_template.php
Created January 9, 2021 09:24 — forked from hissy/bulk_change_page_template.php
#concrete5 c5:exec command to bulk change page type & template
<?php
/**
* Usage:
* concrete/bin/concrete5 c5:exec bulk_change_page_template.php old_page_template_handle /parent-page-path new_page_template_handle
*/
$filterPageTemplateHandle = $args[0];
$filterPagePath = $args[1];
$changePageTemplateHandle = $args[2];
@katzueno
katzueno / aws-s3-mass-undelete.sh
Created September 23, 2020 06:27 — forked from crazycodr/aws-s3-mass-undelete.sh
Batch restore deleted s3 objects by accident
# Set the bucket name and date limit that you want to scan for...
#
# For example, if you deleted everything at 9'ish, set the DATE_LIMIT for a
# few minutes before to ensure you find only the stuff you deleted by error
#
BUCKET_NAME="..."
DATE_LIMIT="0000-00-00T00:00:00.000Z"
aws s3api list-object-versions --bucket "${BUCKET_NAME}" > objects.json
cat objects.json | jq --arg DATE_LIMIT "${DATE_LIMIT}" '[ .DeleteMarkers[] | select(.LastModified > $DATE_LIMIT and .IsLatest) | { file: .Key, version: .VersionId } ]' > markers-to-delete.json
@katzueno
katzueno / StatusCodeCheck.php
Created June 26, 2018 11:02 — forked from hissy/StatusCodeCheck.php
#concrete5 Status Code Check Command
<?php
// application/src/Console/Command/StatusCodeCheck.php
namespace Application\Console\Command;
use Concrete\Core\Console\Command;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Http\Client\Client;
use Concrete\Core\Page\Page;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Url\Url;
@katzueno
katzueno / StatusCodeCheck.php
Created June 26, 2018 11:02 — forked from hissy/StatusCodeCheck.php
#concrete5 Status Code Check Command
<?php
// application/src/Console/Command/StatusCodeCheck.php
namespace Application\Console\Command;
use Concrete\Core\Console\Command;
use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Http\Client\Client;
use Concrete\Core\Page\Page;
use Concrete\Core\Support\Facade\Application;
use Concrete\Core\Url\Url;
@katzueno
katzueno / .htaccess
Last active January 30, 2018 00:27 — forked from hissy/.htaccess
Whitelisting IP for concrete5 dashboard / IP アドレス制限
## -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Change RewriteBase path if this concrete5 is installed on subdirectory / concrete5 がサブディレクトリにインストールされていたら、RewriteBase の変更が必要です。
# IP address restriction starts here / IP アドレス制限、アクセス許可するのIPの設定
RewriteCond %{REMOTE_ADDR} !123\.4\.56\.789
RewriteCond %{REMOTE_ADDR} !123\.123\.123\.123
# Add more lines is you have more IP / もっとIPがある場合は、行を追加してください
@katzueno
katzueno / ManualNavPublisher.php
Created December 25, 2017 08:11 — forked from hissy/ManualNavPublisher.php
[concrete5][V8][MigrationTool] Example of creating custom publisher
<?php
// application/src/Concrete/MigrationTool/Publisher/Block/ManualNavPublisher.php
namespace Application\Concrete\MigrationTool\Publisher\Block;
use Concrete\Core\Block\Block;
use Concrete\Core\Page\Page;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\BlockValue\BlockValue;
use PortlandLabs\Concrete5\MigrationTool\Publisher\Block\PublisherInterface;
@katzueno
katzueno / app.php
Last active May 25, 2017 07:21 — forked from hissy/app.php
concrete5 header tester
// application/bootstrap/app.php
Route::register('/ccm/request', function() {
header("Pragma: no-cache");
header("Pragma: no-cache");
echo '<dl>';
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
?><dt>Application environment:</dt><dd><?php echo ($app->environment()) ? $app->environment() : 'default'; ?></dd><?php
$request = \Concrete\Core\Http\Request::getInstance();
?><dt>Client IP:</dt><dd><?php echo $request->getClientIp(); ?></dd><?php
?><dt>Host:</dt><dd><?php echo $request->getHost(); ?></dd><?php
@katzueno
katzueno / GenerateTestContents.php
Created May 24, 2017 06:15 — forked from hissy/GenerateTestContents.php
ダミーコンテンツ大量生成
<?php
// application/src/Concrete/Console/Command/GenerateTestContents.php
namespace Application\Concrete\Console\Command;
use Concrete\Core\Block\BlockType\BlockType;
use Concrete\Core\Cache\CacheClearer;
use Concrete\Core\Console\Command;
use Concrete\Core\File\Importer;
use Concrete\Core\Page\Page;
@katzueno
katzueno / controller.php
Created April 19, 2017 02:17 — forked from kanetei/controller.php
【concrete5】特定のエクスプレスオブジェクトで、属性(チェックボックス)にチェックがない時に項目を表示するカスタマイズ
<?php
namespace Application\Block\ExpressEntryList;
use Concrete\Core\Express\Entry\Search\Result\Result;
use Concrete\Core\Express\EntryList;
class Controller extends \Concrete\Block\ExpressEntryList\Controller
{
public function view()
@katzueno
katzueno / app.php
Created April 17, 2017 13:26 — forked from hissy/app.php
[concrete5] [V8] Add password validation rule
<?php
// application/bootstrap/app.php
/** @var \Concrete\Core\Validator\ValidatorManagerInterface $passwordValidator */
$passwordValidator = Core::make('validator/password');
/** @var \Concrete\Core\Validator\String\RegexValidator $regexValidator */
$regexValidator = Core::make(
\Concrete\Core\Validator\String\RegexValidator::class,
['/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/']
);