} if (empty($tags)) { return; } foreach ($tags as $post_id => $tags) { $yaml = YAML::dump(parseTags($tags["unclean"], $tags["clean"])); echo _f("Relocating tags for post #%d...", array($post_id), "tags"); echo test($insert = $sql->replace("post_attributes", array("name" => "tags", "value" => $yaml, "post_id" => $post_id)), _f("Backup written to %s.", array("./_tags.bak.txt"))); if (!$insert) { return file_put_contents("./_tags.bak.txt", var_export($tags, true)); } } echo __("Removing old post attributes...", "tags") . test($sql->delete("post_attributes", array("name" => array("unclean_tags", "clean_tags")))); } # This task just updates all of the attributes in the database # so they are in sync with the current YAML lib's quoting convention. function fix_quotes() { $sql = SQL::current(); if (!($tags = $sql->select("post_attributes", array("post_id", "value"), array("name" => "tags")))) { return; } foreach ($tags->fetchAll() as $attr) { $sql->replace("post_attributes", array("post_id" => $attr["post_id"], "name" => "tags", "value" => YAML::dump(YAML::load($attr["value"])))); } } update_tags_structure(); move_to_post_attributes(); move_to_yaml(); fix_quotes();
$param_array = array('user_id' => $_SESSION['user']['id'], 'category_name' => $_POST['category_name'], 'created' => time(), 'changed' => time()); $Links->set_params($param_array); $Links->save_category(); $set_net = TRUE; $error_array[] = "Category added successfully"; } catch (PAException $e) { $error_array[] = $e->message; } } } } } } else { if (@$_POST['btn_save_link']) { $_POST['title'] = fix_quotes($_POST['title']); $_POST['url'] = fix_quotes($_POST['url']); if (empty($_POST['link_categories'])) { $error_array[] = "Please select a category"; } if (empty($_POST['title'])) { $error_array[] = "Please enter a title for the link"; } if (empty($_POST['url'])) { $error_array[] = "Please enter the URL for the link"; } $_POST['url'] = validate_url($_POST['url']); if (!Validation::isValidURL($_POST['url'])) { $error_array[] = "Please enter a valid URL for the link"; } if (count($error_array) == 0) { //$tmp_array = explode(':', $_POST['link_categories']);
function editArticle() { // Check if session contains variables from previous entry attempt if (isset($_SESSION['save_attempted'])) { $formContents = buildArticleArray($_SESSION); } else { $temp = getAnyArticle($_REQUEST['articleid']); $formContents = buildArticleArray($temp[0]); } if ($formContents['comment_to'] == "NULL") { h3("Rediger artikkel"); } else { h3("Rediger kommentar"); } table_open(); form_start_post(); tr_open(); td_open(1); echo "Tittel"; td_close(); td_open(1); form_textfield("title", fix_quotes($formContents['title'])); td_close(); tr_close(); if ($formContents['comment_to'] == "NULL") { tr_open(); td_open(1); echo "Publiseringsdato"; td_close(); td_open(1); form_datewidget($formContents['date_posted']); td_close(); tr_close(); tr_open(); td_open(1); echo "Publiseringstidspunkt"; td_close(); td_open(1); form_timewidget($formContents['time_posted']); td_close(); tr_close(); tr_open(); td_open(1); echo "Bare lagre, ikke publiser"; td_close(); td_open(1); if ($formContents['is_draft'] == "1") { form_checkbox("is_draft", "1", "1"); } else { form_checkbox("is_draft", "1", "0"); } td_close(); tr_close(); tr_open(); td_open(1); echo "Språk"; td_close(); td_open(1); form_dropdown("language", getAllLanguageIds(), getAllLanguageNames(), $formContents['language']); td_close(); tr_close(); } tr_open(); td_open(2); echo "Tekst"; td_close(); tr_close(); tr_open(); td_open(2); form_textarea("body", stripslashes($formContents['body']), 50, 20); td_close(); tr_close(); tr_open(); td_open(1); form_submit("submit", "Legg opp"); form_submit("submit", "Forhåndsvis"); form_submit("submit", "Avbryt"); td_close(); td_open(1); td_close(); tr_close(); form_hidden("author", $formContents['author']); form_hidden("category", "0"); form_hidden("m_c", "addArticleGUI"); br(); form_hidden("articleid", $formContents['articleid']); form_hidden("comment_to", $formContents['comment_to']); form_hidden("author_username", $formContents['author_username']); form_end(); table_close(); }
function module_admininput() { // adminpage, stop here if not logged in/right access-level if (!isValidAdmin()) { echo getString("not_valid_admin", "Administratorside, du må logge inn for å få tilgang her"); return; } $inputaction = $_REQUEST['inputaction']; if ($inputaction == "addarticle") { save_form_article(); $title = $_REQUEST['title']; $author = $_REQUEST['author']; $author_username = $_REQUEST['author_username']; $date_posted = $_REQUEST['year'] . "-" . $_REQUEST['month'] . "-" . $_REQUEST['day']; $time_posted = $_REQUEST['hours'] . ":" . $_REQUEST['minutes']; $comment_to = $_REQUEST['comment_to']; $is_draft = $_REQUEST['is_draft']; $body = $_REQUEST['body']; if ($is_draft == "ON") { $is_draft = 1; $log_description .= "savedraft,"; } else { $is_draft = 'NULL'; } if (strlen($comment_to) < 1) { $comment_to = "NULL"; $log_description .= "savenewarticle,"; } else { $log_description .= "savenewcomment,"; } $query = "INSERT INTO articles (title, author, author_username, body, date_posted, time_posted, comment_to, is_draft, view_count) VALUES(\"{$title}\", \"{$author}\", \"{$author_username}\", \"{$body}\", \"{$date_posted}\", \"{$time_posted}\", {$comment_to},{$is_draft},0);"; echo $query; $result = DB_insert($query); global $logtype; if ($result) { echo "Artikkel lagt inn med id: " . mysql_insert_id(); unset_form_article(); if ($comment_to != "NULL") { $log_description .= "commentadded!,"; write_log_entry(mysql_insert_id(), $logtype['comment'], $log_description); } else { $log_description .= "articleadded!,"; write_log_entry(mysql_insert_id(), $logtype['article'], $log_description); } } else { echo "Oops: " . mysql_error(); } } else { form_start_post(); echo '<table class="default_table">'; echo '<tr><td>Forfatter</td><td>'; form_textfield("author", stripslashes($_SESSION['author'])); echo '</td></tr>'; echo '<tr><td>Forfatter_brukernavn</td><td>'; form_textfield("author_username", stripslashes($_SESSION['author'])); echo '</td></tr>'; echo '<tr><td>Tittel</td><td class="form_article_title">'; form_textfield("title", stripslashes(fix_quotes($_SESSION['title']))); echo '</td></tr>'; echo '<tr><td>Dato</td><td>'; form_datewidget($_SESSION['date_posted']); echo '</td></tr>'; echo '<tr><td>Tidspunkt</td><td>'; form_timewidget($_SESSION['time_posted']); echo '</td></tr>'; echo '<tr><td>Kommentar til</td><td>'; form_textfield("comment_to", $_SESSION['comment_to']); echo '</td></tr>'; if ($_SESSION['is_draft'] == "ON") { echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "1"); echo '</td></tr>'; } else { echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "0"); echo '</td></tr>'; } echo '<tr><td colspan=2 class="form_article_text">'; form_textarea("body", stripslashes($_SESSION['body']), 30, 10); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("Button", "Lagre artikkelen"); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("preview", "Forhåndsvis artikkel"); echo '</td></tr>'; form_hidden("m_c", "module_admininput"); form_hidden("inputaction", "addarticle"); form_hidden("articleid", $_SESSION['articleid']); if (isset($edit)) { form_hidden("editarticle", "editarticle"); } echo '</table>'; form_end(); } }
function form_article() { $edit = $_REQUEST['edit']; // Set if edit requested on an article $re_edit = $_SESSION['editarticle']; // Set if user got an error on first attempt to edit if (isset($re_edit)) { echo '<table class="default_table">'; form_start_post(); echo '<tr><td>Forfatter</td><td>'; form_textfield("author", stripslashes($_SESSION['author'])); echo '</td></tr>'; echo '<tr><td>Tittel</td><td class="form_article_title">'; form_textfield("title", stripslashes(fix_quotes($_SESSION['title']))); echo '</td></tr>'; echo '<tr><td>Dato</td><td>'; form_datewidget($_SESSION['date_posted']); echo '</td></tr>'; echo '<tr><td>Tidspunkt</td><td>'; form_timewidget($_SESSION['time_posted']); echo '</td></tr>'; if ($_SESSION['is_draft'] == "ON") { echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "1"); echo '</td></tr>'; } else { echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "0"); echo '</td></tr>'; } echo '<tr><td colspan=2 class="form_article_text">'; form_textarea("body", stripslashes($_SESSION['body']), 30, 10); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("Button", "Lagre artikkelen"); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("preview", "Forhåndsvis artikkel"); echo '</td></tr>'; form_hidden("m_c", "module_add_article"); form_hidden("articleid", $_SESSION['articleid']); if (isset($edit)) { form_hidden("editarticle", "editarticle"); } echo '</table>'; form_end(); } else { if (isset($edit)) { $articleid = $_REQUEST['articleid']; $query = "SELECT * FROM articles WHERE articleid = " . $_REQUEST['articleid'] . ";"; $row = DB_search($query); form_start_post(); echo '<tr><td>Forfatter</td><td>'; form_textfield("author", $row['author']); echo '</td></tr>'; echo '<tr><td>Tittel</td><td class="form_article_title">'; form_textfield("title", stripslashes(fix_quotes($row['title']))); echo '</td></tr>'; echo '<tr><td>Dato</td><td>'; form_datewidget($row['date_posted']); echo '</td></tr>'; echo '<tr><td>Tidspunkt</td><td>'; form_timewidget($row['time_posted']); echo '</td></tr>'; if (isset($row['is_draft']) && $row['is_draft'] == 1) { echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "1"); echo '</td></tr>'; } else { echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "0"); echo '</td></tr>'; } echo '<tr><td colspan=2 class="form_article_text">'; form_textarea("body", stripslashes($row['body']), 30, 10); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("Button", "Lagre endringene"); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("preview", "Forhåndsvis artikkel"); echo '</td></tr>'; form_hidden("editarticle", "true"); form_hidden("m_c", "module_add_article"); form_hidden("articleid", $row['articleid']); echo '</table>'; form_end(); } else { form_start_post(); echo '<tr><td>Forfatter</td><td>'; form_textfield("author", $_SESSION['user_firstname']); echo '</td></tr>'; echo '<tr><td>Tittel</td><td class="form_article_title">'; form_textfield("title", ""); echo '</td></tr>'; echo '<tr><td>Dato</td><td>'; form_datewidget(date("Y-m-d")); echo '</td></tr>'; echo '<tr><td>Tidspunkt</td><td>'; form_timewidget(date("H:i")); echo '</td></tr>'; echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>'; form_checkbox("is_draft", "ON", "0"); echo '</td></tr>'; echo '<tr><td colspan=2 class="form_article_text">'; form_textarea("body", "", 30, 10); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("Button", "Lagre artikkelen"); echo '</td></tr>'; echo '<tr><td colspan=2>'; form_submit("preview", "Forhåndsvis artikkel"); echo '</td></tr>'; form_hidden("m_c", "module_add_article"); echo '</table>'; form_end(); } } }