<?php include '../include/header.php'; $key = clean_input($_REQUEST['key']); $thetime = clean_input($_REQUEST['time']); if ($_POST['action'] == "save") { if (!validcode($key, $thetime)) { print "Error in submission."; } else { $datafilehandle = fopen($datafile, "w"); fwrite($datafilehandle, unescape_quotes($_POST['text'])); fclose($datafilehandle); header('Location: ' . $deliciousroot . "admin"); } } print "<html><head>"; print "<title>Edit Bookmarks</title>"; print "<style>textarea { width:100%; height:75%; }</style>"; print "</head><body>"; print "<h1>Edit Bookmarks</h1>"; print "<form method='post'>"; print "<textarea name='text' cols='100' rows='40'>"; $datafilehandle = fopen($datafile, "r"); while (true) { $line = fgets($datafilehandle); if (strlen($line) == 0) { break; } clean_output($line); } fclose($datafilehandle);
function clean_input($input_string) { return remove_tab_and_newline(unescape_quotes($input_string)); }
// Check data } elseif (!(isset($data) && strlen($data) > 0)) { // Warning echo "Warning: the file is empty or can't read contents\n"; echo $path . "\n\n"; // Data ok } else { // Tag context $do_preg_replace = true; // Replace serialized string values $data = preg_replace_callback('!s:(\\d+):([\\\\]?"[\\\\]?"|[\\\\]?"((.*?)[^\\\\])[\\\\]?");!', function ($m) { if (empty($m[3])) { return $m[0]; } //dont change anything when no string has 0 chars return 's:' . strlen(unescape_mysql($m[3])) . ':"' . unescape_quotes($m[3]) . '";'; }, $data); } // Close file fclose($fp); // Check data if (!(isset($data) && strlen($data) > 0)) { // Check origin if ($do_preg_replace) { // Error echo "Error: preg_replace returns nothing\n"; if (function_exists('preg_last_error')) { echo "preg_last_error() = " . preg_last_error() . "\n"; } echo $path . "\n\n"; }