Skip to content

Instantly share code, notes, and snippets.

View katzueno's full-sized avatar

Katz Ueno katzueno

View GitHub Profile
@katzueno
katzueno / login.php
Created December 22, 2016 00:14 — forked from hissy/login.php
#concrete5 [v7] Hide login page by ip address
<?php
namespace Application\Controller\SinglePage;
use Concrete\Core\Http\Request;
use Concrete\Core\Http\Response;
use Core;
class Login extends \Concrete\Controller\SinglePage\Login
{
public function on_start()
@katzueno
katzueno / scan_duplicate_file_name.php
Created April 11, 2017 06:02 — forked from hissy/scan_duplicate_file_name.php
[concrete5][Legacy] Find duplicate file name and change it
<?php
class ScanDuplicateFileName extends QueueableJob
{
public $jNotUninstallable=0;
public $jSupportsQueue = true;
public function getJobName()
{
return t('Scan Duplicate File Name');
@katzueno
katzueno / import_files.php
Created April 14, 2017 06:37 — forked from hissy/import_files.php
[concrete5][V8] Search all files from legacy databas, then import files to modern concrete5
<?php
namespace Application\Job;
use Concrete\Core\File\Importer;
use Concrete\Core\Job\QueueableJob;
use ZendQueue\Message as ZendQueueMessage;
use ZendQueue\Queue as ZendQueue;
class ImportFiles extends QueueableJob
{
@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).+$/']
);
@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 / 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 / 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 / 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 / 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