<commit_before><?php
/**
 * $Id: record.edit.php,v 1.74 2007-05-01 11:23:47 thorstenr Exp $
 *
 * @author      <NAME> <<EMAIL>>
 * @since       2003-02-23
 * @license     Mozilla Public License 1.1
 * @copyright   (c) 2003-2007 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

// Re-evaluate $user
$user = PMF_CurrentUser::getFromSession($faqconfig->get('main.ipCheck'));

if ($permission["editbt"] && !emptyTable(SQLPREFIX."faqcategories")) {
    $category = new PMF_Category($LANGCODE);
    $category->buildTree();

    $current_category   = '';
    $categories         = array();
    $faqData = array(
        'id'            => 0,
        'lang'          => $LANGCODE,
        'revision_id'   => 0,
        'title'         => '');
    $tagging = new PMF_Tags($db, $LANGCODE);

    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "takequestion") {
        $question_id = intval( $_REQUEST['id']);
        $question = $faq->getQuestion($question_id);
        $current_category = $question['category'];
        $faqData['title'] = $question['question'];
        $categories = array(
            'category_id'   => $current_category,
            'category_lang' => $faqData['lang']);
    }

    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "editpreview") {

        if (isset($_REQUEST["id"]) && $_REQUEST["id"] != "") {
            $faqData['id'] = (int)$_REQUEST["id"];
            $url_variables = 'saveentry&amp;id='.$faqData['id'];
        } else {
            $url_variables = 'insertentry';
        }
        $faqData['lang'] = $_REQUEST["lang"];
        $current_category = isset($_POST['rubrik']) ? $_POST['rubrik'] : null;
        if (is_array($current_category)) {
            foreach ($current_category as $cats) {
                $categories[] = array('category_id' => $cats, 'category_lang' => $faqData['lang']);
            }
        }
        $faqData['active']      = $_REQUEST["active"];
        $faqData['keywords']    = $_REQUEST["keywords"];
        $faqData['title']       = $_REQUEST["thema"];
        $faqData['content']     = $_REQUEST["content"];
        $faqData['author']      = $_REQUEST["author"];
        $faqData['email']       = $_REQUEST["email"];
        $faqData['comment']     = $_REQUEST["comment"];
        $faqData['solution_id'] = (int)$_REQUEST['solution_id'];
        $faqData['revision_id'] = isset($_REQUEST['revision_id']) ? (int)$_REQUEST['revision_id'] : 0;
        $tags                   = $_REQUEST["tags"];
        $changed                = $_REQUEST["changed"];
        if (isset($_REQUEST['dateStart'])) {
            $faqData['dateStart'] = $_REQUEST['dateStart'];
        }
        if (isset($_REQUEST['dateEnd'])) {
            $faqData['dateEnd'] = $_REQUEST['dateEnd'];
        }

    } elseif (isset($_REQUEST["action"]) && $_REQUEST["action"] == "editentry") {

        if ((!isset($current_category) && !isset($faqData['title'])) || (isset($_GET['id']) && $_GET['id'] != '')) {
            adminlog("Beitragedit, ".$_GET['id']);
            $faqData['id']      = (int)$_GET['id'];
            $faqData['lang']    = $_GET["lang"];
            $faq->language      = $faqData['lang'];
            $categories         = $category->getCategoryRelationsFromArticle($faqData['id'], $faqData['lang']);
            $faq->getRecord($faqData['id'], null, true);
            $faqData = $faq->faqRecord;
            $tags = implode(', ', $tagging->getAllTagsById($faqData['id']));
            $url_variables = 'saveentry&amp;id='.$_REQUEST['id'];
        } else {
            $url_variables = 'insertentry';
        }

    } else {
        adminlog('Beitragcreate');
        $url_variables = 'insertentry';
        if (!is_array($categories)) {
            $categories = array();
        }
    }

    // Revisions
    if (isset($_REQUEST['revisionid_selected'])){
        $revisionid_selected = $_REQUEST['revisionid_selected'];
    } elseif (isset($faqData['revision_id'])) {
        $revisionid_selected = $faqData['revision_id'];
    }

    // Permissions
    $user_permission = $faq->getPermission('user', $faqData['id']);
    if ($user_permission[0] == -1) {
        $all_users = true;
        $restricted_users = false;
    } else {
        $all_users = false;
        $restricted_users = true;
    }

    $group_permission = $faq->getPermission('group', $faqData['id']);
    if ($group_permission[0] == -1) {
        $all_groups = true;
        $restricted_groups = false;
    } else {
        $all_groups = false;
        $restricted_groups = true;
    }

    print '<h2>'.$PMF_LANG["ad_entry_edit_1"];
    if (0 != $faqData['id']) {
        print ' <span style="color: Red;">'.$faqData['id'].' ('.$PMF_LANG['ad_entry_revision'].' 1.'.$revisionid_selected.') </span> ';
    }
    print ' '.$PMF_LANG["ad_entry_edit_2"].'</h2>';

    if ($permission["changebtrevs"]){

        $revisions = $faq->getRevisionIds($faqData['id'], $faqData['lang']);
        if (count($revisions)) {
?>
    <form id="selectRevision" name="selectRevision" action="?action=editentry&amp;id=<?php print $faqData['id']; ?>&amp;lang=<?php print $faqData['lang']; ?>" method="post" />
    <fieldset>
    <legend><?php print $PMF_LANG['ad_changerev']; ?></legend>
        <select name="revisionid_selected" onChange="selectRevision.submit();" />
            <option value="<?php print $faqData['revision_id']; ?>"><?php print $PMF_LANG['ad_changerev']; ?></option>
<?php foreach ($revisions as $_revision_id => $_revision_data) { ?>
            <option value="<?php print $_revision_data['revision_id']; ?>" <?php if ($revisionid_selected == $_revision_data['revision_id']) { print 'selected="selected"'; } ?> ><?php print $PMF_LANG['ad_entry_revision'].' 1.'.$_revision_data['revision_id'].': '.makeDate($_revision_data['datum'])." - ".$_revision_data['author']; ?></option>
<?php } ?>
        </select>
    </fieldset>
    </form>
    <br />
<?php
        }
        if (isset($revisionid_selected) && isset($faqData['revision_id']) && $revisionid_selected != $faqData['revision_id']) {
            $faq->language = $faqData['lang'];
            $faq->getRecord($faqData['id'], $revisionid_selected, true);
            $faqData = $faq->faqRecord;
            $tags = implode(', ', $tagging->getAllTagsById($faqData['id']));
        }
    }
?>

    <form style="float: left;" action="?action=<?php print $url_variables; ?>" method="post">
    <input type="hidden" name="revision_id" id="revision_id" value="<?php print $faqData['revision_id']; ?>" />
    <input type="hidden" name="record_id" id="record_id" value="<?php print $faqData['id']; ?>" />

    <fieldset class="fullwidth">
    <legend><?php print $PMF_LANG['ad_entry_faq_record']; ?></legend>

    <label class="lefteditor" for="rubrik"><?php print $PMF_LANG["ad_entry_category"]; ?></label>
    <select name="rubrik[]" id="rubrik" size="5" multiple="multiple">
<?php print $category->printCategoryOptions($categories); ?>
    </select><br />

    <label class="lefteditor" for="thema"><?php print $PMF_LANG["ad_entry_theme"]; ?></label>
    <textarea name="thema" id="thema" style="width: 390px; height: 50px;" cols="2" rows="50"><?php if (isset($faqData['title'])) { print $faqData['title']; } ?></textarea><br />

    <label for="content"><?php print $PMF_LANG["ad_entry_content"]; ?></label>
    <noscript>Please enable JavaScript to use the WYSIWYG editor!</noscript><textarea id="content" name="content" cols="84" rows="10"><?php if (isset($faqData['content'])) { print trim(htmlspecialchars($faqData['content'])); } ?></textarea><br /><commit_msg>Removed wrong whitespace between tags<commit_after><?php
/**
 * $Id: record.edit.php,v 1.75 2007-05-02 17:51:28 thorstenr Exp $
 *
 * @author      <NAME> <<EMAIL>>
 * @since       2003-02-23
 * @license     Mozilla Public License 1.1
 * @copyright   (c) 2003-2007 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) {
    header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']));
    exit();
}

// Re-evaluate $user
$user = PMF_CurrentUser::getFromSession($faqconfig->get('main.ipCheck'));

if ($permission["editbt"] && !emptyTable(SQLPREFIX."faqcategories")) {
    $category = new PMF_Category($LANGCODE);
    $category->buildTree();

    $current_category   = '';
    $categories         = array();
    $faqData = array(
        'id'            => 0,
        'lang'          => $LANGCODE,
        'revision_id'   => 0,
        'title'         => '');
    $tagging = new PMF_Tags($db, $LANGCODE);

    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "takequestion") {
        $question_id = intval( $_REQUEST['id']);
        $question = $faq->getQuestion($question_id);
        $current_category = $question['category'];
        $faqData['title'] = $question['question'];
        $categories = array(
            'category_id'   => $current_category,
            'category_lang' => $faqData['lang']);
    }

    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "editpreview") {

        if (isset($_REQUEST["id"]) && $_REQUEST["id"] != "") {
            $faqData['id'] = (int)$_REQUEST["id"];
            $url_variables = 'saveentry&amp;id='.$faqData['id'];
        } else {
            $url_variables = 'insertentry';
        }
        $faqData['lang'] = $_REQUEST["lang"];
        $current_category = isset($_POST['rubrik']) ? $_POST['rubrik'] : null;
        if (is_array($current_category)) {
            foreach ($current_category as $cats) {
                $categories[] = array('category_id' => $cats, 'category_lang' => $faqData['lang']);
            }
        }
        $faqData['active']      = $_REQUEST["active"];
        $faqData['keywords']    = $_REQUEST["keywords"];
        $faqData['title']       = $_REQUEST["thema"];
        $faqData['content']     = $_REQUEST["content"];
        $faqData['author']      = $_REQUEST["author"];
        $faqData['email']       = $_REQUEST["email"];
        $faqData['comment']     = $_REQUEST["comment"];
        $faqData['solution_id'] = (int)$_REQUEST['solution_id'];
        $faqData['revision_id'] = isset($_REQUEST['revision_id']) ? (int)$_REQUEST['revision_id'] : 0;
        $tags                   = $_REQUEST["tags"];
        $changed                = $_REQUEST["changed"];
        if (isset($_REQUEST['dateStart'])) {
            $faqData['dateStart'] = $_REQUEST['dateStart'];
        }
        if (isset($_REQUEST['dateEnd'])) {
            $faqData['dateEnd'] = $_REQUEST['dateEnd'];
        }

    } elseif (isset($_REQUEST["action"]) && $_REQUEST["action"] == "editentry") {

        if ((!isset($current_category) && !isset($faqData['title'])) || (isset($_GET['id']) && $_GET['id'] != '')) {
            adminlog("Beitragedit, ".$_GET['id']);
            $faqData['id']      = (int)$_GET['id'];
            $faqData['lang']    = $_GET["lang"];
            $faq->language      = $faqData['lang'];
            $categories         = $category->getCategoryRelationsFromArticle($faqData['id'], $faqData['lang']);
            $faq->getRecord($faqData['id'], null, true);
            $faqData = $faq->faqRecord;
            $tags = implode(',', $tagging->getAllTagsById($faqData['id']));
            $url_variables = 'saveentry&amp;id='.$_REQUEST['id'];
        } else {
            $url_variables = 'insertentry';
        }

    } else {
        adminlog('Beitragcreate');
        $url_variables = 'insertentry';
        if (!is_array($categories)) {
            $categories = array();
        }
    }

    // Revisions
    if (isset($_REQUEST['revisionid_selected'])){
        $revisionid_selected = $_REQUEST['revisionid_selected'];
    } elseif (isset($faqData['revision_id'])) {
        $revisionid_selected = $faqData['revision_id'];
    }

    // Permissions
    $user_permission = $faq->getPermission('user', $faqData['id']);
    if ($user_permission[0] == -1) {
        $all_users = true;
        $restricted_users = false;
    } else {
        $all_users = false;
        $restricted_users = true;
    }

    $group_permission = $faq->getPermission('group', $faqData['id']);
    if ($group_permission[0] == -1) {
        $all_groups = true;
        $restricted_groups = false;
    } else {
        $all_groups = false;
        $restricted_groups = true;
    }

    print '<h2>'.$PMF_LANG["ad_entry_edit_1"];
    if (0 != $faqData['id']) {
        print ' <span style="color: Red;">'.$faqData['id'].' ('.$PMF_LANG['ad_entry_revision'].' 1.'.$revisionid_selected.') </span> ';
    }
    print ' '.$PMF_LANG["ad_entry_edit_2"].'</h2>';

    if ($permission["changebtrevs"]){

        $revisions = $faq->getRevisionIds($faqData['id'], $faqData['lang']);
        if (count($revisions)) {
?>
    <form id="selectRevision" name="selectRevision" action="?action=editentry&amp;id=<?php print $faqData['id']; ?>&amp;lang=<?php print $faqData['lang']; ?>" method="post" />
    <fieldset>
    <legend><?php print $PMF_LANG['ad_changerev']; ?></legend>
        <select name="revisionid_selected" onChange="selectRevision.submit();" />
            <option value="<?php print $faqData['revision_id']; ?>"><?php print $PMF_LANG['ad_changerev']; ?></option>
<?php foreach ($revisions as $_revision_id => $_revision_data) { ?>
            <option value="<?php print $_revision_data['revision_id']; ?>" <?php if ($revisionid_selected == $_revision_data['revision_id']) { print 'selected="selected"'; } ?> ><?php print $PMF_LANG['ad_entry_revision'].' 1.'.$_revision_data['revision_id'].': '.makeDate($_revision_data['datum'])." - ".$_revision_data['author']; ?></option>
<?php } ?>
        </select>
    </fieldset>
    </form>
    <br />
<?php
        }
        if (isset($revisionid_selected) && isset($faqData['revision_id']) && $revisionid_selected != $faqData['revision_id']) {
            $faq->language = $faqData['lang'];
            $faq->getRecord($faqData['id'], $revisionid_selected, true);
            $faqData = $faq->faqRecord;
            $tags = implode(',', $tagging->getAllTagsById($faqData['id']));
        }
    }
?>

    <form style="float: left;" action="?action=<?php print $url_variables; ?>" method="post">
    <input type="hidden" name="revision_id" id="revision_id" value="<?php print $faqData['revision_id']; ?>" />
    <input type="hidden" name="record_id" id="record_id" value="<?php print $faqData['id']; ?>" />

    <fieldset class="fullwidth">
    <legend><?php print $PMF_LANG['ad_entry_faq_record']; ?></legend>

    <label class="lefteditor" for="rubrik"><?php print $PMF_LANG["ad_entry_category"]; ?></label>
    <select name="rubrik[]" id="rubrik" size="5" multiple="multiple">
<?php print $category->printCategoryOptions($categories); ?>
    </select><br />

    <label class="lefteditor" for="thema"><?php print $PMF_LANG["ad_entry_theme"]; ?></label>
    <textarea name="thema" id="thema" style="width: 390px; height: 50px;" cols="2" rows="50"><?php if (isset($faqData['title'])) { print $faqData['title']; } ?></textarea><br />

    <label for="content"><?php print $PMF_LANG["ad_entry_content"]; ?></label>
    <noscript>Please enable JavaScript to use the WYSIWYG editor!</noscript><textarea id="content" name="content" cols="84" rows="10"><?php if (isset($faqData['content'])) { print trim(htmlspecialchars($faqData['content'])); } ?></textarea><br />
{'fraction_non_alphanumeric': 0.19946190534425828, 'fraction_numerical': 0.007826831356243121, 'mean_word_length': 3.2513646997660515, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 0, '>': 183, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5875629', 'n_tokens_mistral': 5333, 'n_tokens_neox': 5181, 'n_words': 936}