コード例 #1
0
ファイル: savefile.php プロジェクト: josheb/questedit
<?php

include "quests.php";
$fn = $_POST['filename'];
$zone = $_POST['zone'];
$content = $_POST['file'];
$savefile = $qdir . $zone . "/" . $fn;
if (!quest_dir($savefile)) {
    die("ERROR|Bad filename!");
}
$fh = fopen($savefile, "w");
if (!$fh) {
    die("ERROR|Unable to open file: {$savefile}");
}
fwrite($fh, $content);
fclose($fh);
$ret = array();
$ret['filename'] = $fn;
$ret['zone'] = $zone;
print "SAVED|" . json_encode($ret);
コード例 #2
0
ファイル: createfile.php プロジェクト: josheb/questedit
<?php

include "quests.php";
$fn = $_POST['filename'];
$zone = $_POST['zone'];
$fpath = $qdir . $zone . "/";
$test = dirname($fpath . $fn);
if (strtolower(substr($fn, -3)) == "lua") {
    $cmt = "--";
} else {
    $cmt = "#";
}
if (!quest_dir($test)) {
    die("ERROR|Invalid Filename: {$fpath}{$fn}");
}
if (file_exists($fpath . $fn)) {
    die("ERROR|File Exists!");
}
$fh = fopen($fpath . $fn, 'w');
fwrite($fh, "{$cmt} {$zone} - {$fn}\n");
fclose($fh);
$nf = array();
$nf['zone'] = $zone;
$nf['filename'] = $fn;
print "NEWFILE|" . json_encode($nf);
コード例 #3
0
ファイル: loadfile.php プロジェクト: josheb/questedit
<?php

include "quests.php";
//$src = $qdir.$_POST['src'];
$src = $qdir . $_POST['zone'] . "/" . $_POST['filename'];
if (strtolower(substr($src, -3)) == "lua") {
    $mode = "lua";
} else {
    $mode = "perl";
}
if (!quest_dir($src)) {
    die("ERROR|Invalid input file.");
}
//The file contents are hard to transport through json.  We could probably escape everything, but this works too.
$ret = array();
$ret['zone'] = $_POST['zone'];
$ret['filename'] = $_POST['filename'];
$ret['mode'] = $mode;
print "LOADFILE|" . json_encode($ret) . "|" . file_get_contents($src);