<?php
// configuration
$url = 'http://[domain]/editor.php';
$dir = '/[path to file]/';
$nama = 'index.php';
// check nama, call: [$url]?nama=[file to edit]
if (isset($_GET['nama']))
{
$nama=$_GET['nama'];
}
$file = $dir.$nama;
// check if form has been submitted
if (isset($_POST['text']))
{
// save the text contents
file_put_contents($file, $_POST['text']);
// redirect to form again
header(sprintf('Location: %s', $url.'?'.'nama='.$nama));
printf('<a href="%s">Moved</a>.', htmlspecialchars($url));
exit();
}
// read the textfile
$text = file_get_contents($file);
?>
<!-- HTML form -->
<form action="" method="post">
<input name="nama" value="<?php echo $nama; ?>"/>
<textarea name="text" style="width: 100%; height:80%;"><?php echo htmlspecialchars($text) ?></textarea>
</br>
<input type="submit" />
<input type="reset" />
</form>
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts
Sunday, August 9, 2015
PHP Online edit file
Labels:
online edit,
PHP
Thursday, September 13, 2012
PHP Performance
Tips:
1. Pakai echo daripada print
2. Echo dg koma daripada titik, agar tidak ada proses tambahan.
3. Looping dihitung dulu, hindari count(*)
4. Pakai include dan require daripada include_once, require_once, agar tidak ada proses pengindexan.
5. Pakai full path saat include() agar tidak ada proses tambahan.
6. Pakai sebisanya fungsi asli php.
7. Hindari sebisanya copy variable, agar tdk ada proses tambahan.
8. Parsing ke fungsi juga dg pointer contoh: fungsi(&$a)
9. Turn off error reporting bila selesai
10. Pakai single quote utk proses string.
11. Operator identikal (===) lebih cepat daripada (==)
catatan:
1=='1' return true
1==='1' return false
1. Pakai echo daripada print
2. Echo dg koma daripada titik, agar tidak ada proses tambahan.
3. Looping dihitung dulu, hindari count(*)
4. Pakai include dan require daripada include_once, require_once, agar tidak ada proses pengindexan.
5. Pakai full path saat include() agar tidak ada proses tambahan.
6. Pakai sebisanya fungsi asli php.
7. Hindari sebisanya copy variable, agar tdk ada proses tambahan.
8. Parsing ke fungsi juga dg pointer contoh: fungsi(&$a)
9. Turn off error reporting bila selesai
10. Pakai single quote utk proses string.
11. Operator identikal (===) lebih cepat daripada (==)
catatan:
1=='1' return true
1==='1' return false
Labels:
PHP
Subscribe to:
Posts (Atom)