function edit_note($id) { if ((string) (int) $id != $id) { _die("Invalid ID"); } include "lib/tags.php"; $post_data =& $_POST; foreach (array('ID', 'title', 'contents', 'tags', 'time', 'slug') as $key) { $post_data[$key] = pg_escape_string(@$post_data[$key]); } $post_data['tags'] = clean_tags($post_data['tags']); if (trim($post_data['slug']) == '') { $post_data['slug'] = make_slug($post_data['title']); } if (!($time = strtotime(@$post_data['time']))) { $time = date("Y-m-d H:i:s O", time()); } else { $time = date("Y-m-d H:i:s O", $time); } $result = db("UPDATE public.\"notes\" SET \"title\" = '{$post_data['title']}',\n\t\t\t\"contents\" ='{$post_data['contents']}', \"tags\" = '{$post_data['tags']}',\n\t\t\t\"slug\" ='{$post_data['slug']}'\n\t\t\tWHERE \"ID\" = " . pg_escape_string($id)); if ($result) { if (!rebuild_tags()) { _die("There was an error rebuilding the tag cloud data.\n\t\t\t\t<a href=\"" . _l("/edit/{$id}") . "\">Go back →"); } _die("Edit successfull. <a href=\"" . _l("/edit/{$id}") . "\">continue editing →"); } else { _die("There was an unexpected error."); } }
function delete_note($id) { if ((string) (int) $id != $id) { _die("Invalid ID"); } require_once "lib/tags.php"; $result = db("DELETE FROM public.\"notes\" WHERE \"ID\" = " . pg_escape_string($id)); if ($result) { if (rebuild_tags()) { _die("Note was purged successfully."); } else { _die("There was an error building the tag cloud data. Please run make_tags.php to fix this."); } } else { _die("There was an unexpected error."); } }
<?php /* * This script should be run once in a while to make sure that * tag cloud cache is intact. */ error_reporting(E_ALL); ini_set('display_errors', 1); require_once 'conf.php'; require_once 'templates.php'; require_once 'lib/tags.php'; if (rebuild_tags()) { echo "Done."; } else { echo "Fail."; }