Skip to content

Instantly share code, notes, and snippets.

@atsu666
Last active March 28, 2019 07:18
Show Gist options
  • Save atsu666/571d02a04d436fd2fb5edc71c4f277ee to your computer and use it in GitHub Desktop.
Save atsu666/571d02a04d436fd2fb5edc71c4f277ee to your computer and use it in GitHub Desktop.
a-blog cmsのサービスを外部から動かす。
<?php
define('REQUEST_TIME', time());
define('START_TIME', microtime(true));
define('UNLIMITED_NUMBER_OF_USERS', 5);
set_time_limit(0);
/**
* config.server.php
*/
if (!is_file(dirname(__FILE__) . '/../config.server.php')) {
echo('config.server.php is missing');
exit(1);
}
require_once dirname(__FILE__) . '/../config.server.php';
require_once dirname(__FILE__) . '/../php/config/app.php';
require_once dirname(__FILE__) . '/../php/config/polyfill.php';
/**
* path
*/
setPath(realpath(dirname(__FILE__) . '/../index.php'));
/**
* autoload
*/
require_once LIB_DIR . 'vendor/autoload.php';
spl_autoload_register('autoload');
try {
/**
* Application env
*/
$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['HTTP_HOST'] = null;
$_SERVER['REQUEST_URI'] = null;
$_SERVER['QUERY_STRING'] = null;
define('BID', 1);
define('DATE', null);
define('IS_DEVELOPMENT', null);
define('SEARCH_ENGINE_KEYWORD', null);
define('SUID', null);
define('SBID', null);
define('EID', null);
define('CID', null);
define('UID', null);
define('VIEW', null);
define('AID', null);
define('SESSION_NEXT_ID', null);
define('RBID', null);
define('SESSION_USE_COOKIE', null);
define('TBID', null);
define('CMID', null);
define('UTID', null);
define('ACMS_SID', null);
define('RID', null);
define('ADMIN', null);
define('ORDER', null);
define('PAGE', null);
define('END', null);
define('START', null);
define('FIELD', null);
define('TAG', null);
define('KEYWORD', null);
define('RVID', null);
define('LICENSE_OPTION_OEM', null);
define('SYSTEM_GENERATED_DATETIME', null);
/**
* application
*/
$config = appConfig();
$acms_application = new Acms\Application();
$acms_application->init($config['aliases'], $config['providers']);
/**
* ToDo: 行いたい処理をここに実装します。a-blog cmsのサービスを呼び出せます。
*
* 例: DB::singleton(dsn());
*/
$acms_application->checkException();
exit(0);
} catch (Exception $e) {
$stderr = fopen('php://stderr', 'w');
foreach ($result->errorMessages as $message) {
fwrite($stderr, "$date [Error] " . $e->getMessage() . "\n");
}
fclose($stderr);
exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment