web-editor:source
文書の過去の版を表示しています。
Web Editor(仮名)のソース
Web Editorの説明についてはWeb Editorを見てください。
<?php /** * Web Editor * @version 0.1.1 * @see http://0-oo.net/sbox/web-editor */ function array_get($arr, $key) { return (array_key_exists($key, $arr)) ? $arr[$key] : null; } function h($str) { return htmlspecialchars($str, ENT_QUOTES); } $path = $_REQUEST['path']; $errMsg = '<!-- no error -->'; if ($code = array_get($_POST, 'code')) { if (file_put_contents($path, $code) === false) { $errMsg = 'error! (not saved)'; } } else if (is_file($path)) { $code = file_get_contents($path); } if (!$fileType = array_get($_POST, 'fileType')) { if (preg_match('/\.js$/i', $path)) { $fileType = 'javascript'; } else if (preg_match('/\.css$/i', $path)) { $fileType = 'css'; } else if (preg_match('/\.(|r)htm(|l)$/i', $path)) { $fileType = 'html'; } else if (preg_match('/\.rb$/i', $path)) { $fileType = 'ruby'; } else { $fileType = 'php'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"> <head> <title>web editor - <?php echo h($path); ?></title> <script type="text/javascript"> function saveCode() { var frm = document.getElementsByTagName('form')[0]; if (window.editor) { frm.code.value = editor.getCode(); } else { frm.code.value = frm.editor.value; } frm.submit(); } </script> </head> <body> <span style="color:red;"><?php echo $errMsg; ?></span> <form action="editor.php" method="post"> <div> file type <?php $types = array('php' => 'PHP', 'ruby' => 'Ruby', 'html' => 'HTML', 'javascript' => 'JavaScript', 'css' => 'CSS'); foreach ($types as $type => $label) { echo '<label for="t-' . $type . '">'; echo '<input type="radio" id="t-' . $type . '" name="fileType" value="' . $type . '"'; if ($type == $fileType) { echo ' checked="checked"'; } echo ' />' . $label . "</label>\n"; } ?> <br /> file path <input type="text" name="path" style="width:20em;" value="<?php echo h($path); ?>" /> <input type="submit" value="Load (L)" accesskey="L" /> <input type="button" value="Editor on/off" onclick="editor.toggleEditor();" /> <?php if ($code && preg_match('/^[^\\/]/', $path)) { echo '<a href="' . $path . '" target="_blank" accesskey="O">[ Oepn "' . h($path) . '" (O) ]</a>'; } ?> <hr /> <textarea id="editor" class="codepress <?php echo h($fileType); ?>" cols="110" rows="23" ><?php echo h($code); ?></textarea> <input type="hidden" name="code" /> <input type="button" value="Save (S)" onclick="saveCode();" accesskey="S" /> </div> </form> <script type="text/javascript" src="codepress/codepress.js"></script> </body> </html>
web-editor/source.1197411288.txt.gz · 最終更新: 2007/12/12 07:14 by dgbadmin