コード例 #1
0
ファイル: lms-cashimport.php プロジェクト: prezeskk/lms
require_once LIB_DIR . DIRECTORY_SEPARATOR . 'common.php';
require_once LIB_DIR . DIRECTORY_SEPARATOR . 'language.php';
include_once LIB_DIR . DIRECTORY_SEPARATOR . 'definitions.php';
require_once LIB_DIR . DIRECTORY_SEPARATOR . 'unstrip.php';
$SYSLOG = SYSLOG::getInstance();
// Initialize Session, Auth and LMS classes
$AUTH = NULL;
$LMS = new LMS($DB, $AUTH, $SYSLOG);
$LMS->ui_lang = $_ui_language;
$LMS->lang = $_language;
$plugin_manager = new LMSPluginManager();
$LMS->setPluginManager($plugin_manager);
if (array_key_exists('import-file', $options)) {
    $import_file = $options['import-file'];
    $import_filename = basename($import_file);
} else {
    $import_file = 'php://stdin';
    $import_filename = strftime('%Y%m%d%H%M%S.csv');
}
@(include ConfigHelper::getConfig('phpui.import_config', 'cashimportcfg.php'));
if (!isset($patterns) || !is_array($patterns)) {
    die(trans("Configuration error. Patterns array not found!") . PHP_EOL);
}
if ($import_file != 'php://stdin' && !is_readable($import_file)) {
    die("Couldn't read contents from {$import_file} file!" . PHP_EOL);
}
$contents = file_get_contents($import_file);
$LMS->CashImportParseFile($import_filename, $contents, $patterns, $quiet);
if (ConfigHelper::checkConfig('cashimport.autocommit')) {
    $LMS->CashImportCommit();
}