query.php

来自「ajax php wiki source code」· PHP 代码 · 共 41 行

PHP
41
字号
<?php

function latest_content() {
	$files = glob("data/*.html");
	if (count($files) == 0)
		return '';

	rsort ($files, SORT_STRING);
	return file_get_contents($files[0]);
}

$action = $_REQUEST["action"];

if (!$action || $action == "latest") {

	echo latest_content();

} else if ($action == "draft") {
	if (file_exists("data/.draft.html")) {
		echo file_get_contents("data/.draft.html");
	} else {
		echo latest_content();
	}
} else if ($action == "history") {
	$files = glob("data/*.html");
	rsort($files, SORT_STRING);
	foreach ($files as $f) {
		if ($f != ".draft.html") {
			printf ("%s\n", $f);
		}
	}
} else if ($action == "file") {
	$fname = $_REQUEST['filename'];
	if (file_exists($fname)) {
		$content = file_get_contents($fname);
		echo $content;
	}
} 

?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?