<?php include_once '../global/ranvier.php'; function removeQuotes($str) { return str_replace(array('"', "'"), '', $str); } $attr = $_POST['attr']; $attrStr = "self.attributes = {\n"; $attFmt = "\t\t'%s': %s, // type: %s\n"; foreach ($attr as $a) { $t = $a['type']; if ($t == 'enum') { $t .= '[' . implode(',', $a['extra']) . ']'; } if (!is_numeric($a['default'])) { $a['default'] = "'" . $a['default'] . "'"; } $attrStr .= sprintf($attFmt, $a['field'], $a['default'], $t); } $attrStr .= "\t};"; $js = readRanvierFile('/src/player.js'); $js = preg_replace('/self.attributes = \\{.*?\\};/s', $attrStr, $js); saveRanvierFile('/src/player.js', $js); ?> OK
<?php include_once '../global/ranvier.php'; include_once '../global/yaml/spyc.php'; $area = $_POST['area']; $room = $_POST['room']; $settings = loadSettings(); $foundTheRoom = false; $array = readRanvierFile('/entities/areas/' . $area . '/rooms.yml', IS_YAML); for ($x = 0; $x < count($array); $x++) { if ($array[$x]['location'] == $room['location']) { $foundTheRoom = true; if (ranvierFileExists('/scripts/rooms/' . $room['location'] . '.js')) { $room['script'] = $room['location'] . '.js'; } else { unset($room['script']); } $array[$x] = $room; $x = count($array); } } if (!$foundTheRoom) { $array[] = $room; } $yaml = Spyc::YAMLDump($array, 4, 60); saveRanvierFile('/entities/areas/' . $area . '/rooms.yml', $yaml);
<?php include_once '../global/ranvier.php'; $types = array('npcs' => 'MOB', 'objects' => 'OBJECT'); $file = str_replace(' ', '', ucwords(strtolower($_POST['behavior']))); saveRanvierFile('scripts/behaviors/' . $_POST['type'] . '/' . $file . '.js', ''); echo $types[$_POST['type']];
<?php include_once '../global/ranvier.php'; $motd = $_POST['motd']; if (saveRanvierFile('/data/motd', $motd)) { echo json_encode(array('status' => 'OK')); } else { echo json_encode(array('status' => 'FAILED')); }
<?php include_once 'ranvier.php'; $settings = loadSettings(); $filepath = $_POST['file']; $script = $_POST['script']; //$script = file_get_contents($setting['base_game'] . '/' . $filepath); if (trim($script) != '') { echo 'OK'; saveRanvierFile($filepath, $script); } else { echo 'DEL'; @unlink($setting['base_game'] . '/' . $filepath); }