Issues (1796)

public/main/help/faq.php (1 issue)

Labels
Severity
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
/**
5
 * This script displays a help window.
6
 */
7
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
8
9
require_once __DIR__.'/../inc/global.inc.php';
10
$help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null;
11
12
Display::display_header(get_lang('Frequently Asked Question'));
13
14
if (api_is_platform_admin()) {
15
    echo '&nbsp;<a href="faq.php?edit=true">'.Display::getMdiIcon(ActionIcon::EDIT, 'ch-tool-icon', null, ICON_SIZE_SMALL).'</a>';
16
}
17
18
echo Display::page_header(get_lang('Frequently Asked Question'));
19
20
$faq_file = 'faq.html';
21
if (!empty($_GET['edit']) && 'true' == $_GET['edit'] && api_is_platform_admin()) {
22
    $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
23
    $form->addHtmlEditor(
24
        'faq_content',
25
        null,
26
        false,
27
        false,
28
        ['ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300']
29
    );
30
    $form->addButtonSave(get_lang('Validate'), 'faq_submit');
31
    $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH).'home/faq.html');
0 ignored issues
show
The constant SYS_APP_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
32
    $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
33
    $form->setDefaults(['faq_content' => $faq_content]);
34
    if ($form->validate()) {
35
        $content = $form->getSubmitValue('faq_content');
36
        $fpath = api_get_path(SYS_APP_PATH).'home/'.$faq_file;
37
        if (is_file($fpath) && is_writeable($fpath)) {
38
            $fp = fopen(api_get_path(SYS_APP_PATH).'home/'.$faq_file, 'w');
39
            fwrite($fp, $content);
40
            fclose($fp);
41
        } else {
42
            echo Display::return_message(get_lang('File not writeable'), 'warning');
43
        }
44
        echo $content;
45
    } else {
46
        $form->display();
47
    }
48
} else {
49
    $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH).'home/'.$faq_file);
50
    $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
51
    echo $faq_content;
52
}
53
54
Display::display_footer();
55