public static function load($file, $cache = 3600) { if ($cache > 0 && RUN_MODE == 'deploy') { import('system/bin/cache'); $cache_instance = CacheBackend::get_instance(); $cache_id = 'yaml_' . str_replace(array('/', '.'), '_', $file); if ($cache_instance->is_cached($cache_id)) { return $cache_instance->get($cache_id); } else { if (!is_file($file)) { $file = Package::get_file($file); if (!is_file($file)) { return array(); } } import('system/vendors/spyc/spyc'); $info = spyc_load_file($file); $cache_instance->set($cache_id, $info); return $info; } } if (!is_file($file)) { $file = Package::get_file($file); if (!is_file($file)) { return array(); } } import('system/vendors/spyc/spyc'); $info = spyc_load_file($file); return $info; }
function parseConfigFile($name, $loadDefaults, $disableDefaults = false) { global $magicDefaultsFolder; global $magicRootFolder; $baseFile = "{$magicDefaultsFolder}/{$name}.defaults.yml"; $overrideFile = "{$magicRootFolder}/{$name}.yml"; if ($loadDefaults) { $config = spyc_load_file($baseFile); if (file_exists($overrideFile)) { $override = spyc_load_file($overrideFile); if ($disableDefaults) { foreach ($config as $key => &$spell) { $spell['enabled'] = false; } } $config = array_replace_recursive($config, $override); } } else { $config = spyc_load_file($overrideFile); } if (count($config) == 1 && $config[0] == 0) { $config = array(); } return $config; }
/** * Get * Get Value based on Key * @param string $dataKey * @return mixed */ public function get($dataKey, $default = '[RAMLDataObject]') { if (!isset($this->data[$dataKey])) { $dataKey = strtoupper($dataKey); } if (!isset($this->data[$dataKey])) { if ($default != '[RAMLDataObject]') { return $default; } return new RAMLDataObject(); // shoudl return false } elseif (is_array($this->data[$dataKey])) { $t = new RAMLDataObject($this->data[$dataKey]); $t->setMaster($this->master); return $t; // convert to preg_match_all } elseif (is_string($this->data[$dataKey]) && preg_match('/^\\!include ([a-z_\\.\\/]+)/i', $this->data[$dataKey], $matches)) { $ext = array_pop(explode('.', $matches[1])); if (in_array($ext, array('yaml', 'raml'))) { $t = new RAMLDataObject(spyc_load_file($matches[1])); $t->setMaster($this); return $t; } return file_get_contents($matches[1]); } elseif ($dataKey == 'schema') { $this->data[$dataKey] = $this->master->handleSchema($this->data[$dataKey]); } return $this->master->handlePlaceHolders($this->data[$dataKey]); }
public function parse($fname) { $filename = ROOT_PATH . "/" . Makiavelo::MAPPINGS_FOLDER . "/" . $fname; if ($filename) { return spyc_load_file($filename); } }
/** * 判断用户权限 */ protected function is_authentic() { if (!isset($_SESSION["admin_id"]) || $_SESSION["admin_id"] < 1) { $this->redirect("/login"); } $ADMINSTRATOR = in_array($_SESSION['admin_id'], explode(",", C('ADMINSTRATOR'))) ? true : false; if ($ADMINSTRATOR) { return true; } $role = spyc_load_file("./Conf/role.yml"); $role_id = isset($_SESSION['role_id']) ? "role_" . $_SESSION['role_id'] : "role_4"; if (!isset($role[$role_id]) || $role[$role_id]["status"] != 1) { $this->show("你所属的角色已禁用或已删除!"); exit; } $roles = explode(",", $role[$role_id]["action"]); $ModuleAction = MODULE_NAME . "/" . ACTION_NAME; $user_role = true; if (in_array($ModuleAction, $roles)) { $user_role = false; } if ($role[$role_id]["status"] != 1) { $user_role = false; } if (!$user_role) { $this->show("操作失败,权限不足"); exit; } }
public function generateModel($yaml_file, $dir) { $schema = spyc_load_file($yaml_file); $this->dir = $dir; foreach ($schema as $entity_name => $entity_definition) { $this->generateClass($dir . '/' . $entity_name . '.class.php', $entity_name, $entity_definition); } }
public function loadYaml($filename) { if (file_exists($filename)) { return spyc_load_file($filename); } else { return null; } }
/** * Loads a YAML file into an array. First checks the child tempate's file, then the framework's */ function gp_load_yaml($filename) { $file = locate_template($filename, false, false); if ($file) { return gp_process_yaml_array(spyc_load_file($file)); } else { return false; } }
public function createSchema($yaml_file) { $schema = spyc_load_file($yaml_file); foreach ($schema as $entity_name => $entity_definition) { $this->createTable($entity_name, $entity_definition); if ($entity_definition['relations']['many-to-many']) { $this->createManyToManyRelations($entity_definition['relations']['many-to-many'], $entity_name); } } }
/** * Config constructor. * @param string $pathToConfigFile * @throws ConfigParseException */ public function __construct($pathToConfigFile) { $pathToConfigFile = trim($pathToConfigFile); if (!file_exists($pathToConfigFile) || !is_readable($pathToConfigFile)) { throw new \InvalidArgumentException("The config file at path: '{$pathToConfigFile}' was not found and/or is not readable"); } try { $this->config = spyc_load_file($pathToConfigFile); } catch (\Exception $e) { throw new ConfigParseException("There was an error parsing the config file at path: '{$pathToConfigFile}'." . " Error Message: '{$e->getMessage()}'"); } }
private function load_file($file) { if (!file_exists($file)) { die("Failute at yaml config parse. '{$file}' doesnt exsist"); } if (function_exists('yaml_parse_file')) { return yaml_parse_file($file); } if (function_exists('spyc_load_file')) { return spyc_load_file($file); } die('Failure at yaml config parse. No tool available to reach this goal'); }
private function getPluginUpdates($pluginDir) { $plugin_conf = spyc_load_file($this->pluginsDir . '/' . $pluginDir . "/plugin.yaml"); if (!isset($plugin_conf['update_url'])) { return; } if (!isset($plugin_conf['version'])) { return; } $update_url = $plugin_conf['update_url']; $version = $plugin_conf['version']; $updates = json_decode(file_get_contents($update_url . '?version=' . $version)); return $updates; }
public function get_left_admin_nav($ADMINSTRATOR, $role_id, $array_id, $now_id = 0) { if ($this->nav_arr_model === null) { $nav_arr = spyc_load_file("./Conf/nav.yml"); $nav = $this->nav_arr_model = new ArrayModel($nav_arr); } else { $nav = $this->nav_arr_model; } $where["pid"] = array("eq", $now_id); $left_nav = $nav->where($where)->order("sort asc")->select(); if (!$left_nav) { return ''; } $item = ""; foreach ($left_nav as $v) { if ($v["enable"] != 1 || $v["show"] != 1) { continue; //如果此节点已停用或者不显示在导航栏,进入下一次循环 } if (in_array($v["id"], $array_id) && !$ADMINSTRATOR) { continue; //如果无此节点权限,进入下一次循环 } $url = $v["url"] == "#" || $v["url"] == "" ? "javascript:void();" : U($v["url"]); $item .= "<dl id=\"nav_{$v['id']}\">\n"; $item .= "<dt>{$v['names']}</dt>"; $map["pid"] = array("eq", $v['id']); $left_nav_list = $nav->where($map)->order("sort asc")->select(); foreach ($left_nav_list as $list) { if ($list["enable"] != 1 || $list["show"] != 1) { continue; //如果此节点已停用或者不显示在导航栏,进入下一次循环 } if (in_array($list["id"], $array_id) && !$ADMINSTRATOR) { continue; //如果无此节点权限,进入下一次循环 } $list_url = $list["url"] == "#" || $list["url"] == "" ? "javascript:void();" : U($list["url"]); $item .= "<dd id=\"nav_{$list['id']}\">\r\n <span onclick=\"javascript:gourl('{$list['id']}','{$list_url}')\"><a href=\"{$list_url}\" target=\"main\">{$list['names']}</a></span>\n"; $item .= $this->get_left_admin_nav($ADMINSTRATOR, $role_id, $array_id, $list['id']); $item .= "</dd>"; } $item .= "</dl>"; } if ($now_id == 0) { F("admin_left_nav_" . $role_id, $item); } return $item; }
static function load($template) { $blueprint = c::get('root.site') . '/' . c::get('panel.folder') . '/blueprints/' . $template . '.php'; // custom default if ($template != 'default' && !file_exists($blueprint)) { $blueprint = c::get('root.site') . '/' . c::get('panel.folder') . '/blueprints/default.php'; } // default fallback if (!file_exists($blueprint)) { $blueprint = c::get('root.panel') . '/defaults/blueprints/default.php'; } $params = spyc_load_file($blueprint); // add the default fields $params = self::defaultFields($params); return $params; }
/** * Read database connection parameters from local.xml file * * @return array * @throws Exception */ protected function _getDatabaseConnectionParameters() { // Get Yml Reader if not already present if (!class_exists('Spyc')) { $currentPath = __DIR__; $vendorPos = strpos(strtolower($currentPath), 'vendor'); if (!$vendorPos) { throw new Exception("Composer Vendor Directory not found in current Path, needed to require Spyc."); } $include = substr($currentPath, 0, $vendorPos) . 'vendor/mustangostang/spyc/Spyc.php'; require_once $include; } $localYmlFile = 'app/config/parameters.yml'; if (!is_file($localYmlFile)) { throw new Exception(sprintf('File "%s" not found', $localYmlFile)); } $config = spyc_load_file($localYmlFile); if ($config === false) { throw new Exception(sprintf('Could not load yml file "%s"', $localYmlFile)); } return array('host' => (string) $config['parameters']['database_host'], 'database' => (string) $config['parameters']['database_name'], 'username' => (string) $config['parameters']['database_user'], 'password' => (string) $config['parameters']['database_password']); }
private function addGroup($line, $group) { if ($group[0] == '&') { $this->_containsGroupAnchor = substr($group, 1); } if ($group[0] == '*') { $this->_containsGroupAlias = substr($group, 1); } //print_r ($this->path); } private function stripGroup($line, $group) { $line = trim(str_replace($group, '', $line)); return $line; } } // Enable use of Spyc from command line // The syntax is the following: php Spyc.php spyc.yaml do { if (PHP_SAPI != 'cli') { break; } if (empty($_SERVER['argc']) || $_SERVER['argc'] < 2) { break; } if (empty($_SERVER['PHP_SELF']) || FALSE === strpos($_SERVER['PHP_SELF'], 'Spyc.php')) { break; } $file = $argv[1]; echo json_encode(spyc_load_file($file)); } while (0);
return false; } curl_close($ch); return true; } // Save backup of original skin $originalSkin = 'original_skin.png'; if (!file_exists($originalSkin)) { echo "Saving original skin to {$originalSkin}\n"; $skinURL = getCurrentSkin(); $skinFile = file_get_contents($skinURL); file_put_contents($originalSkin, $skinFile); echo "Waiting 2 minutes to start\n"; sleep(2 * 60); } $images = spyc_load_file($mapFile); $dir = new DirectoryIterator($inputFolder); foreach ($dir as $fileinfo) { $inputImage = $fileinfo->getFilename(); if ($fileinfo->isDot() || startsWith($inputImage, '.')) { continue; } $url = $inputImage; if (isset($images[$url])) { echo " Skipping {$inputImage}, already mapped\n"; continue; } $lastURL = getCurrentSkin(); echo "Current skin URL: {$lastURL}\n"; echo "Uploading {$inputImage}\n"; $inputFile = $inputFolder . '/' . $inputImage;
/** * Initialize Avane. * * @return Main */ private function initialize() { $this->setSetting('compiled', $this->mainPath . 'compiled/')->setSetting('script', $this->mainPath . 'scripts/')->setSetting('style', $this->mainPath . 'styles/')->setSetting('coffee', $this->mainPath . 'coffees/')->setSetting('sass', $this->mainPath . 'sass/')->setSetting('tpl', $this->mainPath . 'tpls/')->setSetting('config', $this->mainPath . 'config.yml')->setSetting('enableCoffee', false)->setSetting('enableSass', false)->setSetting('enableSassc', false)->setSetting('sassc', 'sassc')->setSetting('coffeeExtension', '.coffee')->setSetting('sassExtension', '.sass')->setSetting('extension', '.jade')->setSetting('titleVariable', 'title')->setSetting('pjaxHeader', 'HTTP_X_PJAX'); /** Load the configures and store to the variable */ $this->config = spyc_load_file($this->configPath); /** Apply the common configures */ if (isset($this->config['configs'])) { foreach ($this->config['configs'] as $name => $value) { $this->setSetting($name, $value); } } /** Load the functions file */ if (file_exists($this->mainPath . 'functions.php')) { require $this->mainPath . 'functions.php'; } /** Create the folders if do not exist */ if (!is_dir($this->compiledPath)) { mkdir($this->compiledPath, 0755, true); } if (!is_dir($this->scriptPath)) { mkdir($this->scriptPath, 0755, true); } if (!is_dir($this->stylePath)) { mkdir($this->stylePath, 0755, true); } if (!is_dir($this->coffeePath)) { mkdir($this->coffeePath, 0755, true); } if (!is_dir($this->sassPath)) { mkdir($this->sassPath, 0755, true); } if (!is_dir($this->tplPath)) { mkdir($this->tplPath, 0755, true); } return $this; }
if ($group[0] == '&') { $this->_containsGroupAnchor = substr($group, 1); } if ($group[0] == '*') { $this->_containsGroupAlias = substr($group, 1); } //print_r ($this->path); } private function stripGroup($line, $group) { $line = trim(str_replace($group, '', $line)); return $line; } } // Enable use of Spyc from command line // The syntax is the following: php spyc.php spyc.yaml define('SPYC_FROM_COMMAND_LINE', false); do { if (!SPYC_FROM_COMMAND_LINE) { break; } if (empty($_SERVER['argc']) || $_SERVER['argc'] < 2) { break; } if (empty($_SERVER['PHP_SELF']) || $_SERVER['PHP_SELF'] != 'spyc.php') { break; } $file = $argv[1]; printf("Spyc loading file: %s\n", $file); print_r(spyc_load_file($file)); } while (0);
protected function setUp() { $this->yaml = spyc_load_file('../spyc.yaml'); }
private static function _buildMenu() { $app = KX_CURRENT_APP; if (KX_CURRENT_APP == 'core' && !isset(kxEnv::$request['module']) && !isset(kxEnv::$request['app'])) { $modules = array(array('module_file' => 'index')); } else { $modules = kxDB::getinstance()->select("modules", "", array('fetch' => PDO::FETCH_ASSOC))->fields("modules", array("module_name", "module_file"))->condition("module_application", $app)->condition("module_manage", 1)->orderBy("module_position")->execute()->fetchAll(); } //print_r($modules); foreach ($modules as $module) { $_file = kxFunc::getAppDir($app) . "/modules/manage/" . $module['module_file'] . '/menu.yml'; //echo "<p>Getting menu from {$_file}</p>"; if (file_exists($_file)) { if (function_exists("syck_load")) { $menu[$module['module_file']] = syck_load(file_get_contents($_file)); } else { $menu[$module['module_file']] = spyc_load_file($_file); } self::assign('menu', $menu); self::assign('module', $module['module_file']); } } }
function page($lang, $id = null) { $this->preset($lang); $this->load->library('spyc'); $page_type = spyc_load_file(getcwd() . "/page_type.yml"); $page = $this->general_model->get_page_detail($id); if (!allowed_theme_page($page["page_type"], $page_type)) { show_404(); } $order_by = "created_date"; $sort = "DESC"; if (check_extension_order_preview($page["page_type"], $page_type)) { $order_by = "extension_order"; $sort = "ASC"; } if (isset($page_type[$page["page_type"]]["dynamic"])) { $page["body"] = $this->general_model->get_extensions_by_page_id($id, $order_by, $sort, 10, isset($_GET["offset"]) && is_numeric($_GET["offset"]) ? $_GET["offset"] : 0); } else { $page["body"] = $this->general_model->get_extensions_by_page_id($id, $order_by, $sort); } $this->data['data'] = $page; $this->data['title'] = $page['title_caption']; if (isset($_GET["ajax"]) && allowed_theme_page_ajax($page["page_type"], $page_type)) { echo $this->load->view('flatlab/' . get_theme_page_ajax($page["page_type"], $page_type), $this->data, true); } else { $this->data['content'] = get_theme_page($page["page_type"], $page_type); $this->load->view('flatlab', $this->data, ''); } }
public function testKaiList() { $Expected = array('-item', '-item', '-item'); $Actual = spyc_load_file('indent_1.yaml'); $this->assertEquals($Expected, $Actual['kai_list_of_items']); }
/** * Load values from a YAML file. */ private static function load_yml($yml_file) { if (!$yml_file) { return array(); } $config = spyc_load_file($yml_file); // Make sure config-file-relative paths are made absolute. $yml_file_dir = dirname($yml_file); if (isset($config['path'])) { self::absolutize($config['path'], $yml_file_dir); } if (isset($config['require'])) { self::arrayify($config['require']); foreach ($config['require'] as &$path) { self::absolutize($path, $yml_file_dir); } } return $config; }
<?php // Basic paths for the rest of the program to use define('ROOT', realpath(dirname(__FILE__) . '/../')); define('DICTIONARY', ROOT . '/config/dictionary.yml'); define('TEMPLATES_ROOT', ROOT . '/templates'); // Common includes require_once ROOT . '/lib/spyc.php'; require_once ROOT . '/lib/functions.php'; // Globals -- mind the Caps $Dictionary = spyc_load_file(DICTIONARY); $Templates = load_templates(); $RenderFlags = array();
function judge($row) { global $EXITCODES, $myhost, $options, $workdirpath; // Set configuration variables for called programs putenv('USE_CHROOT=' . (USE_CHROOT ? '1' : '')); putenv('SCRIPTTIMELIMIT=' . dbconfig_get_rest('script_timelimit')); putenv('SCRIPTMEMLIMIT=' . dbconfig_get_rest('script_memory_limit')); putenv('SCRIPTFILELIMIT=' . dbconfig_get_rest('script_filesize_limit')); putenv('MEMLIMIT=' . $row['memlimit']); putenv('FILELIMIT=' . $row['outputlimit']); putenv('PROCLIMIT=' . dbconfig_get_rest('process_limit')); $cpuset_opt = ""; if (isset($options['daemonid'])) { $cpuset_opt = "-n {$options['daemonid']}"; } // create workdir for judging $workdir = "{$workdirpath}/c{$row['cid']}-s{$row['submitid']}-j{$row['judgingid']}"; logmsg(LOG_INFO, "Working directory: {$workdir}"); // If a database gets reset without removing the judging // directories, we might hit an old directory: rename it. if (file_exists($workdir)) { $oldworkdir = $workdir . '-old-' . getmypid() . '-' . strftime('%Y-%m-%d_%H:%M'); if (!rename($workdir, $oldworkdir)) { error("Could not rename stale working directory to '{$oldworkdir}'"); } @chmod($oldworkdir, 0700); warning("Found stale working directory; renamed to '{$oldworkdir}'"); } system("mkdir -p '{$workdir}/compile'", $retval); if ($retval != 0) { error("Could not create '{$workdir}/compile'"); } // Make sure the workdir is accessible for the domjudge-run user. // Will be revoked again after this run finished. chmod($workdir, 0755); if (!chdir($workdir)) { error("Could not chdir to '{$workdir}'"); } // Get the source code from the DB and store in local file(s) $sources = request('submission_files', 'GET', 'id=' . urlencode($row['submitid'])); $sources = dj_json_decode($sources); $files = array(); foreach ($sources as $source) { $srcfile = "{$workdir}/compile/{$source['filename']}"; $files[] = "'{$source['filename']}'"; if (file_put_contents($srcfile, base64_decode($source['content'])) === FALSE) { error("Could not create {$srcfile}"); } } if (empty($row['compile_script'])) { error("No compile script specified for language " . $row['langid'] . "."); } $execrunpath = fetch_executable($workdirpath, $row['compile_script'], $row['compile_script_md5sum']); // Compile the program. system(LIBJUDGEDIR . "/compile.sh {$cpuset_opt} '{$execrunpath}' '{$workdir}' " . implode(' ', $files), $retval); // what does the exitcode mean? if (!isset($EXITCODES[$retval])) { alert('error'); error("Unknown exitcode from compile.sh for s{$row['submitid']}: {$retval}"); } $compile_success = $EXITCODES[$retval] != 'compiler-error'; // pop the compilation result back into the judging table request('judgings/' . urlencode($row['judgingid']), 'PUT', 'judgehost=' . urlencode($myhost) . '&compile_success=' . $compile_success . '&output_compile=' . rest_encode_file($workdir . '/compile.out')); // compile error: our job here is done if (!$compile_success) { // revoke readablity for domjudge-run user to this workdir chmod($workdir, 0700); logmsg(LOG_NOTICE, "Judging s{$row['submitid']}/j{$row['judgingid']}: compile error"); return; } // Optionally create chroot environment if (USE_CHROOT && CHROOT_SCRIPT) { logmsg(LOG_INFO, "executing chroot script: '" . CHROOT_SCRIPT . " start'"); system(LIBJUDGEDIR . '/' . CHROOT_SCRIPT . ' start', $retval); if ($retval != 0) { error("chroot script exited with exitcode {$retval}"); } } $totalcases = 0; while (TRUE) { // get the next testcase $testcase = request('testcases', 'GET', 'judgingid=' . urlencode($row['judgingid'])); $tc = dj_json_decode($testcase); // empty means: no more testcases for this judging. if (empty($tc)) { break; } $totalcases++; logmsg(LOG_DEBUG, "Running testcase {$tc['rank']}..."); $testcasedir = $workdir . "/testcase" . sprintf('%03d', $tc['rank']); // Get both in- and output files, only if we didn't have them already. $tcfile = array(); $fetched = array(); foreach (array('input', 'output') as $inout) { $tcfile[$inout] = "{$workdirpath}/testcase/testcase.{$tc['probid']}.{$tc['rank']}." . $tc['md5sum_' . $inout] . "." . substr($inout, 0, -3); if (!file_exists($tcfile[$inout])) { $content = request('testcase_files', 'GET', 'testcaseid=' . urlencode($tc['testcaseid']) . '&' . $inout); $content = base64_decode(dj_json_decode($content)); if (file_put_contents($tcfile[$inout] . ".new", $content) === FALSE) { error("Could not create {$tcfile[$inout]}.new"); } unset($content); if (md5_file("{$tcfile[$inout]}.new") === $tc['md5sum_' . $inout]) { rename("{$tcfile[$inout]}.new", $tcfile[$inout]); } else { error("File corrupted during download."); } $fetched[] = $inout; } // sanity check (NOTE: performance impact is negligible with 5 // testcases and total 3.3 MB of data) if (md5_file($tcfile[$inout]) !== $tc['md5sum_' . $inout]) { error("File corrupted: md5sum mismatch: " . $tcfile[$inout]); } } // Only log downloading input and/or output testdata once. if (count($fetched) > 0) { logmsg(LOG_INFO, "Fetched new " . implode($fetched, ',') . " testcase {$tc['rank']} for problem p{$tc['probid']}"); } // Copy program with all possible additional files to testcase // dir. Use hardlinks to preserve space with big executables. $programdir = $testcasedir . '/execdir'; system("mkdir -p '{$programdir}'", $retval); if ($retval != 0) { error("Could not create directory '{$programdir}'"); } system("cp -PR '{$workdir}'/compile/* '{$programdir}'", $retval); if ($retval != 0) { error("Could not copy program to '{$programdir}'"); } // do the actual test-run $hardtimelimit = $row['maxruntime'] + overshoot_time($row['maxruntime'], dbconfig_get_rest('timelimit_overshoot')); $compare_runpath = fetch_executable($workdirpath, $row['compare'], $row['compare_md5sum']); $run_runpath = fetch_executable($workdirpath, $row['run'], $row['run_md5sum']); system(LIBJUDGEDIR . "/testcase_run.sh {$cpuset_opt} {$tcfile['input']} {$tcfile['output']} " . "{$row['maxruntime']}:{$hardtimelimit} '{$testcasedir}' " . "'{$run_runpath}' '{$compare_runpath}' '{$row['compare_args']}'", $retval); // what does the exitcode mean? if (!isset($EXITCODES[$retval])) { alert('error'); error("Unknown exitcode from testcase_run.sh for s{$row['submitid']}, " . "testcase {$tc['rank']}: {$retval}"); } $result = $EXITCODES[$retval]; // Try to read metadata from file $runtime = NULL; if (is_readable($testcasedir . '/program.meta')) { $metadata = spyc_load_file($testcasedir . '/program.meta'); if (isset($metadata['time-used'])) { $runtime = @$metadata[$metadata['time-used']]; } } request('judging_runs', 'POST', 'judgingid=' . urlencode($row['judgingid']) . '&testcaseid=' . urlencode($tc['testcaseid']) . '&runresult=' . urlencode($result) . '&runtime=' . urlencode($runtime) . '&judgehost=' . urlencode($myhost) . '&output_run=' . rest_encode_file($testcasedir . '/program.out', FALSE) . '&output_error=' . rest_encode_file($testcasedir . '/program.err') . '&output_system=' . rest_encode_file($testcasedir . '/system.out') . '&output_diff=' . rest_encode_file($testcasedir . '/feedback/judgemessage.txt')); logmsg(LOG_DEBUG, "Testcase {$tc['rank']} done, result: " . $result); } // end: for each testcase // revoke readablity for domjudge-run user to this workdir chmod($workdir, 0700); // Optionally destroy chroot environment if (USE_CHROOT && CHROOT_SCRIPT) { logmsg(LOG_INFO, "executing chroot script: '" . CHROOT_SCRIPT . " stop'"); system(LIBJUDGEDIR . '/' . CHROOT_SCRIPT . ' stop', $retval); if ($retval != 0) { error("chroot script exited with exitcode {$retval}"); } } // Sanity check: need to have had at least one testcase if ($totalcases == 0) { logmsg(LOG_WARNING, "No testcases judged for s{$row['submitid']}/j{$row['judgingid']}!"); } // done! logmsg(LOG_NOTICE, "Judging s{$row['submitid']}/j{$row['judgingid']} finished"); }
/** * Handle Includes * Handles the Includes within the Array * @param array $array * @return array */ public function handleIncludes($array) { foreach ($array as $key => $value) { if (is_array($value)) { $array[$key] = $this->handleIncludes($value); } elseif (is_string($value) && preg_match('/^\\!include ([a-z0-9_\\.\\/\\-]+)/i', $value, $matches)) { $ext_t = explode('.', $matches[1]); $ext = strtolower(array_pop($ext_t)); if (in_array($ext, array('yaml', 'raml'))) { $t = spyc_load_file($this->includePath . $matches[1]); $array = array_merge($t, $array); unset($array[$key]); } else { $array[$key] = file_get_contents($this->includePath . $matches[1]); } } } return $array; }
public function getModels() { $moddir = $this->extdir . '/models'; $matchs = null; $tables = array(); foreach (scandir($moddir) as $modfile) { if (preg_match('`^(.*)\\.yml$`', $modfile, $matchs)) { $def = spyc_load_file($moddir . '/' . $modfile); $def['file'] = $modfile; $def['mod'] = $this->defs['sysdir']; $tables[$def['name']] = $def; } } return $tables; }
function editgallery($id = '', $data_type = null, $relation_id = null) { if ($id != 0) { $this->data['data'] = $this->general_model->get_gallery_detail($id); if ($this->data['data'] == null) { redirect("cpanel/gallery"); } if (isset($this->data['data']["data_type"]) && $this->data['data']["data_type"] != "") { $this->data['data_type'] = $this->data['data']["data_type"]; } if (isset($this->data['data']["relation_id"]) && $this->data['data']["relation_id"] != 0) { $this->data['relation_id'] = $this->data['data']["relation_id"]; } } else { if ($data_type != null) { $this->data['data_type'] = $data_type; } if ($relation_id != null) { $this->data['relation_id'] = $relation_id; } } $this->load->library('spyc'); if ($data_type == "page" && $relation_id != null) { $page = $this->general_model->get_page_detail($relation_id); $options = spyc_load_file(getcwd() . "/page_type.yml"); if (isset($options[$page["page_type"]]["gallerys_fields"])) { $this->data['fields'] = $options[$page["page_type"]]["gallerys_fields"]; } } else { $this->data['fields'] = array("icon", "image", "description", "full_description"); } $icons = spyc_load_file(getcwd() . "/icons.yml"); $this->data['faicons'] = $icons["fa"]; $this->data['languages'] = $this->general_model->get_all_language(); $this->data['title'] = _l("gallery", $this); $this->data['page'] = "gallery"; $this->data['content'] = $this->load->view('flatlab/gallery_edit', $this->data, true); $this->load->view('flatlab', $this->data); }
// Get the Base class include_once BASE_PATH . '/system/classes/base.php'; // Prepare for Routes include_once BASE_PATH . '/system/classes/routes.php'; // Load spyc ( yaml to array) include_once LIBRARIES . '/spyc.php'; // ActiveRecord include_once LIBRARIES . '/activerecord/ActiveRecord.php'; // Setup for configurations include_once BASE_PATH . '/config/config.php'; // Get the Application Base include_once BASE_PATH . '/system/classes/ApplicationBase.php'; // Get the Helper Base include_once BASE_PATH . '/system/classes/HelperBase.php'; // Load database information $db_info = spyc_load_file(BASE_PATH . '/config/database.yml'); if (isset($db_info['default'])) { if (isset($db_info[ENVIRONMENT])) { $db_info[ENVIRONMENT] = array_merge($db_info['default'], $db_info[ENVIRONMENT]); } unset($db_info['default']); } $config[ENVIRONMENT]['DB_HOST'] = $db_info[ENVIRONMENT]['host']; $config[ENVIRONMENT]['DB_USER'] = $db_info[ENVIRONMENT]['user']; $config[ENVIRONMENT]['DB_PASS'] = $db_info[ENVIRONMENT]['password']; $config[ENVIRONMENT]['DB_NAME'] = $db_info[ENVIRONMENT]['database_name']; unset($db_info); // Done loading database info and putting it into $config array // Connect to the database ActiveRecord\Config::initialize(function ($cfg) { $cfg->set_model_directory(APP_PATH . '/models');