public function clearLog() { Database::update_rows('RetrieveLog', array('finished' => 1), array('finished' => 0)); $path = 'activelog.txt'; $f = fopen($path, 'w+'); fclose($f); }
} } elseif ($action == "edit") { if (isset($_POST["body"])) { // Perform mysql_real_escape_string on all values $arraytoinsert = array_map("mysql_real_escape_string", array("slug" => $page, "title" => stripslashes($_POST["title"]), "body" => stripslashes($_POST["body"]), "excerpt" => stripslashes($_POST["excerpt"]))); // Non blog posts have a last update time if (!$page_array["isblog"]) { $arraytoinsert["lastupdate"] = time(); } else { if (!$page_array["isreal"]) { $arraytoinsert["created"] = time(); } } // Update or insert depends on if page is in database. // Hope to god database hasn't changed. $result = $page_array["isreal"] ? $db->update_rows("UPDATE {$table} SET %s WHERE slug='{$page_escape}'", $arraytoinsert) : $db->insert_row("INSERT INTO {$table} %s VALUES %s", $arraytoinsert); if (!$result) { $messages[] = "<small>" . mysql_error() . "</small>"; } else { // Page has been updated/created successfull, // Add tags // Strip, explode, trim and remove empties // This makes string " tag1, tag2, , , tag3" into // array("tag1", "tag2", "tag3") $newtags = array_filter(array_map("trim", explode(",", stripslashes($_POST["tags"])))); // Use old tag array or an empty one $oldtags = $page_array["tags"] ? array_filter($page_array["tags"]) : array(); // Collect all of $newtags which aren't in $oldtags $tagstoinsert = array_diff($newtags, $oldtags); // Collect all of $oldtags which aren't in $newtags $tagstodelete = array_diff($oldtags, $newtags);