<commit_before><?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Spage extends MY_Controller
{

    protected $isEnabled;

    function __construct()
    {
        parent::__construct();
        $this->load->helper('form');
        $this->load->library(array('form_validation','table','j_auth'));
        $t = $this->config->item('pageeditor');
        $this->isEnabled = TRUE;
        if ($t === FALSE)
        {
           $this->isEnabled = FALSE;
        }
    }

    public function showall()
    {
        if (!$this->j_auth->logged_in())
        {
            redirect('auth/login', 'location');
        }
        $isAdmin = $this->j_auth->isAdministrator();
        if (!$isAdmin)
        {
            show_error('Permission denied', 403);
            return;
        }
        $data['addbtn'] = $this->isEnabled;
        $articles = $this->em->getRepository("models\Staticpage")->findAll();
        $rows = array();
        $yes = lang('rr_yes');
        $no = lang('rr_no');
        $data['titlepage'] = lang('title_listspages');
        $data['rowsHeading'] = array(lang('rr_title'), lang('rr_category'), lang('rr_enabled'), lang('lbl_spageanonaccess'), lang('rr_pagecode'), '');
        $frontpage = false;
        foreach ($articles as $a)
        {
            if ($a->getPublic())
            {
                $p = $yes;
            }
            else
            {
                $p = $no;
            }
            if ($a->getEnabled())
            {
                $e = $yes;
            }
            else
            {
                $e = $no;
            }
            if ($this->isEnabled)
            {
                $editlink = '<a href="' . base_url() . 'manage/spage/editarticle/' . $a->getName() . '" class="button tiny">' . lang('rr_edit') . '</a>';
            }
            else
            {
                $editlink = '';
            }
            $code = $a->getName();
            if(strcasecmp($code, 'front_page')==0)
            {
                $frontpage = true;
            }
            $stitle = $a->getTitle();
            if(empty($stitle))
            {
                $stitle = lang('rr_notitle');
            }
            $rows[] = array(
                '<a href="'.base_url().'p/page/'.$a->getName().'">'.$stitle.'</a>', $a->getCategory(), $e, $p, $a->getName(), $editlink
            );
        }
        $data['rows'] = &$rows;     
        if(!$frontpage)
        {
            $data['msg1'] = lang('missingfrontpage');
            $data['msg2'] = lang('createpcode');    
        }
        $data['content_view'] = 'manage/spageshowall_view';
        $this->load->view('page', $data);
    }

    public function editArticle($pcode)
    {
        $pcode = trim($pcode);
        $loggedin = $this->j_auth->logged_in();
        if (!$loggedin)
        {
            redirect('auth/login', 'location');
        }
        $isAdmin = $this->j_auth->isAdministrator();
        if (!$isAdmin)
        {
            show_error('Permission denied', 403);
            return;
        }
        if (!$this->isEnabled)
        {
            show_error('Feature is not enabled', 403);
            return;
        }
        $newArticle = false;
        if (strcmp($pcode, 'new') != 0)
        {
            $article = $this->em->getRepository("models\Staticpage")->findOneBy(array('pcode' => $pcode));
            if (empty($article))
            {
                show_error('Not found', 404);
                return;
            }
        }
        else
        {
            $newArticle = true;
        }

        if ($this->submitValidate($pcode))
        {
            if ($newArticle)
            {
                $article = new models\Staticpage;
                $article->setName($this->input->post('acode'));
            }
            $content = strip_tags($this->input->post('acontent'),'<p><img><a><b><i><strong><table><tbody><th><tr><td><h1><h2><h3><h4><h5><h6><em><s><ol><ul><li><blockquote><pre><hr><div><span>');
            $contentTitle = $this->input->post('atitle');
            $isEnabled = $this->input->post('aenabled');
            $category = $this->input->post('acategory');
            if (!empty($isEnabled) && strcmp($isEnabled, '1') == 0)
            {
                $article->setEnabled(true);
            }
            else
            {
                $article->setEnabled(false);
            }<commit_msg>add br to allowed tags<commit_after><?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Spage extends MY_Controller
{

    protected $isEnabled;

    function __construct()
    {
        parent::__construct();
        $this->load->helper('form');
        $this->load->library(array('form_validation','table','j_auth'));
        $t = $this->config->item('pageeditor');
        $this->isEnabled = TRUE;
        if ($t === FALSE)
        {
           $this->isEnabled = FALSE;
        }
    }

    public function showall()
    {
        if (!$this->j_auth->logged_in())
        {
            redirect('auth/login', 'location');
        }
        $isAdmin = $this->j_auth->isAdministrator();
        if (!$isAdmin)
        {
            show_error('Permission denied', 403);
            return;
        }
        $data['addbtn'] = $this->isEnabled;
        $articles = $this->em->getRepository("models\Staticpage")->findAll();
        $rows = array();
        $yes = lang('rr_yes');
        $no = lang('rr_no');
        $data['titlepage'] = lang('title_listspages');
        $data['rowsHeading'] = array(lang('rr_title'), lang('rr_category'), lang('rr_enabled'), lang('lbl_spageanonaccess'), lang('rr_pagecode'), '');
        $frontpage = false;
        foreach ($articles as $a)
        {
            if ($a->getPublic())
            {
                $p = $yes;
            }
            else
            {
                $p = $no;
            }
            if ($a->getEnabled())
            {
                $e = $yes;
            }
            else
            {
                $e = $no;
            }
            if ($this->isEnabled)
            {
                $editlink = '<a href="' . base_url() . 'manage/spage/editarticle/' . $a->getName() . '" class="button tiny">' . lang('rr_edit') . '</a>';
            }
            else
            {
                $editlink = '';
            }
            $code = $a->getName();
            if(strcasecmp($code, 'front_page')==0)
            {
                $frontpage = true;
            }
            $stitle = $a->getTitle();
            if(empty($stitle))
            {
                $stitle = lang('rr_notitle');
            }
            $rows[] = array(
                '<a href="'.base_url().'p/page/'.$a->getName().'">'.$stitle.'</a>', $a->getCategory(), $e, $p, $a->getName(), $editlink
            );
        }
        $data['rows'] = &$rows;     
        if(!$frontpage)
        {
            $data['msg1'] = lang('missingfrontpage');
            $data['msg2'] = lang('createpcode');    
        }
        $data['content_view'] = 'manage/spageshowall_view';
        $this->load->view('page', $data);
    }

    public function editArticle($pcode)
    {
        $pcode = trim($pcode);
        $loggedin = $this->j_auth->logged_in();
        if (!$loggedin)
        {
            redirect('auth/login', 'location');
        }
        $isAdmin = $this->j_auth->isAdministrator();
        if (!$isAdmin)
        {
            show_error('Permission denied', 403);
            return;
        }
        if (!$this->isEnabled)
        {
            show_error('Feature is not enabled', 403);
            return;
        }
        $newArticle = false;
        if (strcmp($pcode, 'new') != 0)
        {
            $article = $this->em->getRepository("models\Staticpage")->findOneBy(array('pcode' => $pcode));
            if (empty($article))
            {
                show_error('Not found', 404);
                return;
            }
        }
        else
        {
            $newArticle = true;
        }

        if ($this->submitValidate($pcode))
        {
            if ($newArticle)
            {
                $article = new models\Staticpage;
                $article->setName($this->input->post('acode'));
            }
            $content = strip_tags($this->input->post('acontent'),'<p><img><a><b><i><strong><table><tbody><th><tr><td><h1><h2><h3><h4><h5><h6><em><s><ol><ul><li><blockquote><pre><hr><div><span><br>');
            $contentTitle = $this->input->post('atitle');
            $isEnabled = $this->input->post('aenabled');
            $category = $this->input->post('acategory');
            if (!empty($isEnabled) && strcmp($isEnabled, '1') == 0)
            {
                $article->setEnabled(true);
            }
            else
            {
                $article->setEnabled(false);
            }
{'fraction_non_alphanumeric': 0.17978543195934502, 'fraction_numerical': 0.005420666290231507, 'mean_word_length': 1.4967578235128278, 'pattern_counts': {'":': 0, '<': 68, '<?xml version=': 0, '>': 166, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3818905', 'n_tokens_mistral': 2657, 'n_tokens_neox': 2587, 'n_words': 394}