public function onDisable() { yaml_emit_file($this->getDataFolder() . "/chatblock.yml", $this->chatBlock); yaml_emit_file($this->getDataFolder() . "/commandcapture.yml", $this->commandCapture); yaml_emit_file($this->getDataFolder() . "/denycommand.yml", $this->denyCommand); yaml_emit_file($this->getDataFolder() . "/movelock.yml", $this->moveLock); }
/** * @Route("/admin/", name="admin_index") * @Template() */ public function indexAction(Request $request) { $file = yaml_parse_file(__DIR__ . '/../../../../../../app/config/globals.yml'); if ($request->getMethod() == 'POST') { // print_r ($request); foreach ($file['twig']['globals'] as $place => $vars) { foreach ($vars as $name => $val) { if (count($val) > 1) { foreach ($val as $name1 => $val1) { if ($request->get($place . '_' . $name . '_' . $name1, false)) { $file['twig']['globals'][$place][$name][$name1] = true; } else { $file['twig']['globals'][$place][$name][$name1] = false; } } } else { if ($request->get($place . '_' . $name, false)) { $file['twig']['globals'][$place][$name] = true; } else { $file['twig']['globals'][$place][$name] = false; } } } } yaml_emit_file(__DIR__ . '/../../../../../app/config/globals.yml', $file); } // $form = $this->createForm(new BannerType(), $entity, array( // 'action' => $this->generateUrl('manager_banner_update', array('id' => $entity->getId())), // 'method' => 'PUT', // )); // $form->add('submit', 'submit', array('label' => 'Update')); $em = $this->getDoctrine()->getManager(); $banners = $em->getRepository('CMSBundle:Banner')->findAll(); return array('banners' => $banners, 'globals' => $file['twig']['globals']); }
public function dump(Definition $definition, string $filepath) { $file = new SplFileInfo($filepath); if ($file->isDir() || !$file->isWritable()) { throw new RuntimeException("Given file {$filepath} is directory or is unwritable"); } $definitionHydrator = new DefinitionHydrator(); return yaml_emit_file($file->getPathname(), $definitionHydrator->extract($definition)); }
/** * Write the config array to a yaml file. * * @param string The yaml file. * * @return bool True, if successfully written, else False. */ public static function write($file, array $array) { // prefer yaml, then syck, else use Spyc - faster one first if (extension_loaded('yaml')) { return yaml_emit_file($file, $array); } elseif (extension_loaded('syck')) { $yaml = syck_dump($array); } elseif (class_exists('Spyc')) { $spyc = new Spyc(); $yaml = $spyc->dump($array); } else { throw new \Koch\Exception\Exception('No YAML Parser available. Get Spyc or Syck!'); } return (bool) file_put_contents($file, $yaml, LOCK_EX); }
public function __construct($filename = 'vortex_config.yml') { $vortexFile = $filename; try { if (file_exists($filename)) { $settings = yaml_parse_file($filename); } else { $settings = new _vortex_settings(); $settings->SchemaName = "default"; $settings->DatabaseUser = "******"; $settings->DatabasePassword = null; $settings->DatabaseServerIP = "127.0.0.1"; yaml_emit_file($filename, $settings); } } catch (Exception $e) { error_log($e->getMessage()) . "\n"; } }
/** * */ private function buildConf() { $etcDir = $this->config->dev->path->etcDir; $localeDir = $this->config->path->localeDir; $devDir = $this->config->dev->path->devDir; $distDir = $this->config->dev->path->distDir; $config1 = yaml_parse_file("{$etcDir}/dist_defaults.yml"); $config2 = yaml_parse_file("{$etcDir}/dist.yml"); $localeConfig = yaml_parse_file("{$localeDir}/config.yml"); $localeConfig['supported'] = $this->getDI()->getLocale()->getSupportedLocales(); $config3 = ['locale' => $localeConfig]; // Merge the custom settings over the defaults $configMerged = array_replace_recursive($config1, $config2, $config3); // Write the merged settings to the dist directory yaml_emit_file("{$distDir}/etc/config.yml", $configMerged); }
private function saveArenas() { $save = []; foreach ($this->arenas as $arena) { $str = $arena->getStructureManager(); $spawn = $str->getSpawn(); $save[] = ["name" => $arena->getName(), "pos1" => ["x" => $str->getPos1()["x"], "z" => $str->getPos1()["z"]], "pos2" => ["x" => $str->getPos2()["x"], "z" => $str->getPos2()["z"]], "floors" => $str->getFloors(), "levelName" => $str->getLevelName(), "spawn" => ["x" => $spawn->x, "y" => $spawn->y, "z" => $spawn->z]]; } yaml_emit_file($this->getDataFolder() . "arenas.yml", $save); }
public function playerVlockTouchHandle($data, $event) { //$this->debug_print("touch"); $tile = $this->api->tile->get(new Position($data['target']->x, $data['target']->y, $data['target']->z, $data['target']->level)); if ($tile === false) { return; } $class = $tile->class; $this->config = $this->api->plugin->readYAML($this->path . "config.yml"); if ($class == TILE_CHEST) { //$this->debug_print("chest"); if (isset($this->config[$data['target']->x][$data['target']->y][$data['target']->z])) { //$this->debug_print("config est'"); if ($this->config[$data['target']->x][$data['target']->y][$data['target']->z] !== $data['player']->username) { $this->api->chat->sendTo(false, "This chest is protected by {$this->config[$data['target']->x][$data['target']->y][$data['target']->z]}.", $data['player']->username); return false; } else { if ($data['item'] instanceof StickItem) { //$this->debug_print("stick reset"); unset($this->config[$data['target']->x][$data['target']->y][$data['target']->z]); $this->api->plugin->writeYAML($this->path . "config.yml", $this->config); $this->api->chat->sendTo(false, "Chest released", $data['player']->username); return false; } } } else { if ($data['item'] instanceof StickItem) { //$this->debug_print("stick set"); $this->config[$data['target']->x][$data['target']->y][$data['target']->z] = $data['player']->username; //$this->debug_print(print_r($this->config, true)); yaml_emit_file($this->path . "config.yml", $this->config); //$this->api->plugin->writeYAML($this->path . "config.yml", $this->config); $this->api->chat->sendTo(false, "Chest protected", $data['player']->username); return false; } } } }
public function save() { return yaml_emit_file($this->path, $this->configs); }
/** * Encode data and store it to $fileName. * * @param mixed $data * @param string $fileName */ public function encodeFile($data, string $fileName) { yaml_emit_file($fileName, $data, $this->getEncoding(), $this->getLinebreak(), $this->getEncodeCallbacks()); }
public function actionLogin($args) { if (count($args) > 0) { $username = trim($args[0]); } else { $username = readline('User: '******'Password: '******'username' => $username]; try { $uri = self::_serverUri(); $rpc = new \Gini\RPC(rtrim($uri, '/') . '/api'); $config['token'] = $rpc->createToken($username, $password); if (isset($config['token'])) { yaml_emit_file(self::_configFile(), $config, YAML_UTF8_ENCODING); echo "You've successfully logged in as {$username}.\n"; } else { echo "Access denied!\n"; } } catch (\Gini\RPC\Exception $e) { echo 'Server Error: ' . $e->getMessage() . "\n"; } }
/** * @param array $config */ public static function saveCollectionConfig($config) { $folder = self::$outputDir . '/Config'; yaml_emit_file($folder . '/collections.yaml', $config); }
} $entry['group'] = htmlspecialchars($xgroups[$i]); $entry['valve'] = htmlspecialchars($xvalves[$i]); $entry['days'] = htmlspecialchars($xdays[$i]); $entry['start_time'] = htmlspecialchars($xstart_time[$i]); $entry['run_time'] = htmlspecialchars($xrun_time[$i]); $entry['start_time'] = format_time($entry['start_time']); $entry['run_time'] = format_time($entry['run_time']); array_push($entries, $entry); } $sched['entries'] = $entries; $sel_sched = $sched['id']; if (!$err) { if (isset($_POST['apply'])) { $file = "{$sched_dir}/" . $sched['id']; if (yaml_emit_file($file, $sched)) { # success } else { exit("yaml emit failed, are permissions for '{$file}' correct?"); } } else { if (isset($_POST['run_once'])) { foreach ($entries as $entry) { $group = $entry['group']; $queue_file = "{$spkpi_dir}/queue/group-" . $group; $valve = $entry['valve']; $run_time_fmt = $entry['run_time']; list($min, $_sec) = sscanf($run_time_fmt, "%02d:%02d"); $run_time = $min * 60 + $_sec; $cmd = "echo \"{$valve} {$run_time}\" >> {$queue_file}"; $status = '';
if (!($key == "page" || $key == "submit" || $key == "keys" || $key == "GOOGLE_SPEECH")) { $ymlArr[$key] = $value; } else { if ($key = "keys") { if (is_array($value)) { foreach ($value as $subvalue) { if (!($subvalue == "page" || $subvalue == "submit")) { $ymlArr['keys']['GOOGLE_SPEECH'] = $subvalue; } } } } } } // Write to YAML file yaml_emit_file($config['profile'], $ymlArr); } $ymlArr = yaml_parse_file($config['profile'], 0); echo "\t<form method='post' action='index.php?page=configuration'>\n\t<input type='hidden' name='page' value='configuration'>\n\t<input type='hidden' name='submit' value='true'>\n\t<table>"; foreach ($ymlArr as $key => $value) { echo '<tr>'; if (is_array($value)) { foreach ($value as $subkey => $subvalue) { echo '<tr><td><input type="hidden" name="' . $key . '" value="' . $key . '"></td></tr>'; echo '<tr><td>' . $subkey . '</td><td><input type="text" name="' . $subkey . '" value="' . $subvalue . '"></td></tr>'; } } else { echo '<td>' . $key . '</td><td><input type="text" name="' . $key . '" value="' . $value . '"></td></tr>'; } } echo "\n\t</table>\n\t<input type='submit' value='Opslaan'>\n\t</form>\n\t";
//Check if the first line is empty, if is it remove this one /*if (empty($_POST["Series_information"]["Contributor"][0])){ array_shift($_POST["Series_information"]["Contributor"]); } if (empty($_POST["Samples_information"]["Sample_name"][0])){ foreach ($_POST["Samples_information"] as $key => $value) { array_shift($value); }*/ /*foreach ($_POST["Samples_information"] as $tab){ array_shift($tab); Not run }*/ //} //Part for write all information in a YAML file. $filename = $_SESSION["path_project"] . "/data" . "/description.yml"; $res = yaml_emit_file($filename, $_POST, $encoding = YAML_UTF8_ENCODING); //Part for write 3 tables in the database project. $db = new SQLite3($_SESSION["path_project"] . "/" . $_SESSION["project"] . ".db"); //open database project //Table Serie_descriptions = $_POST["Series_information"] $db->exec('DROP TABLE IF EXISTS serie_descriptions'); //remove old table $db->exec('CREATE TABLE serie_descriptions (feature STRING, value STRING)'); foreach ($_POST["Series_information"] as $key => $value) { if (is_array($value)) { // if is array we have to insert all value contained by this array foreach ($value as $key2 => $value2) { if (empty($value2)) { //skip the empty line continue; } else {
if ($hasRes = is_dir($resDir = $dir . "resources/")) { console("Resources directory detected."); } $manifest = yaml_parse_file($pluginYml); $version = $manifest["version"]; $last3 = substr($version, -3); if (!is_numeric($last3)) { $last3 = 0; $version .= "_#"; } else { $version = substr($version, 0, -3); } $last3 = (int) $last3 + 1; $version .= str_pad((string) $last3, 3, "0", STR_PAD_LEFT); $manifest["version"] = $version; yaml_emit_file($pluginYml, $manifest); console("New {$input} version: {$version}"); $path = $dir . "bin/" . $input . ".phar"; if (is_file($path)) { console("Older phar detected, deleting..."); unlink($path); } console("Creating phar at {$path}..."); $phar = new Phar($path); $phar->setStub('<?php __HALT_COMPILER();'); $phar->setSignatureAlgorithm(Phar::SHA1); $phar->startBuffering(); console("Adding files into phar..."); console("Adding plugin.yml..."); $phar->addFile($pluginYml, "plugin.yml"); clearLine();
public function onDisable() { yaml_emit_file($this->getDataFolder() . "cheaters.yml", $this->cheaters); yaml_emit_file($this->getDataFolder() . "money.yml", $this->money); yaml_emit_file($this->getDataFolder() . "stats.yml", $this->stats); }
public function emitFile($file, $data) { yaml_emit_file($file, $data, YAML_UTF8_ENCODING); }
/** * Saves $this->settings to $this->yaml_file * @access public */ private function saveSettings() { yaml_emit_file($this->settingsFile, $this->settings); }
echo "Set phar.readonly to 0 with -dphar.readonly=0\n"; exit(1); } $opts["make"] = "..\\..\\"; $plugin_yml = realpath($opts["make"] . "plugin.yml"); $ymlData = yaml_parse_file($plugin_yml); $version = $ymlData["version"]; $v = ltrim(substr($version, -3), "0"); $v = intval($v) + 1; $v = "{$v}"; while (strlen($v) < 3) { $v = "0" . $v; } $ymlData["version"] = substr($version, 0, -3) . $v; echo "New version! " . $ymlData["version"] . PHP_EOL; yaml_emit_file($plugin_yml, $ymlData); exec("git add {$plugin_yml}"); $folderPath = rtrim(str_replace("\\", "/", realpath($opts["make"])), "/") . "/"; $relativePath = isset($opts["relative"]) ? rtrim(str_replace("\\", "/", realpath($opts["relative"])), "/") . "/" : $folderPath; $pharName = "..\\CommandSelectors_dev_build.phar"; if (is_file($pharName)) { unlink($pharName); } if (!is_dir($folderPath)) { echo $folderPath . " is not a folder\n"; exit(1); } echo "\nCreating " . $pharName . "...\n"; $phar = new \Phar($pharName); if (isset($opts["entry"]) and $opts["entry"] != null) { $entry = addslashes(str_replace("\\", "/", $opts["entry"]));
public function generate_tags($tags) { $file = public_path() . "/feeds/tags.yaml"; yaml_emit_file($file, $tags); }
public function onDisable() { $d = array("id" => $this->id); yaml_emit_file($this->getDataFolder() . "/config.yml", $d); }