<commit_before><?php defined('SYSPATH') or die('No direct script access.');

class Controller_Admin_Settings extends Controller_Admin_Base
{

    public function action_index()
    {
        $setting = new Model_Settings();

        $data = array(
            'telephone_1' => $setting->get('tel1'),
            'telephone_2' => $setting->get('tel2'),
            'email' => $setting->get('email'),
            'title' => $setting->get('title'),
            'address' => $setting->get('address'),
        );

        $post = $this->request->post();

        if (Security::is_token($post['csrf']) && $this->request->method() === Request::POST)
        {
            $post = array_map('Security::xss_clean', $post);

            switch ($post['type'])
            {
                case 'tel' :

                    if (Valid::phone($post['telephone_1'], 11) && Valid::phone($post['telephone_2'], 11))
                    {
                        $setting->set('tel1', $post['telephone_1']);
                        $setting->set('tel2', $post['telephone_2']);

                        $data = $post;
                        $success = 'Номер(а) изменены.';
                    }
                    else
                    {
                        $data = $post;
                        $error = 'Введите оба телефона правильно';
                    }

                break;

                case 'email' :

                    if (Valid::email($post['email']))
                    {
                        $setting->set('email', $post['email']);
                        $data = $post;
                        $success = 'Email изменен.';
                    }
                    else
                    {
                        $data = $post;
                        $error = 'Введите email правильно';
                    }

                break;

                case 'general' :

                    $setting->set('title', $post['title']);
                    $setting->set('address', $post['address']);

                    $data = $post;
                    $success = 'Основные данные изменены.';

                break;
            }
        }

        $this->template->content = View::factory('admin/settings/index', compact('data', 'error', 'success'));
    }

    public function action_smtp()
    {
        $data = Kohana::$config->load('settings.smtp');
        if (!empty($data))
            $data = unserialize($data);

        $csrf = $this->request->post('csrf');
        if (Security::is_token($csrf) && $this->request->method() === Request::POST)
        {
            $data= $this->request->post();
            unset($data['csrf']);
            $values = array_filter($data);
            if (!empty($values))<commit_msg>fixed settings<commit_after><?php defined('SYSPATH') or die('No direct script access.');

class Controller_Admin_Settings extends Controller_Admin_Base
{

    public function action_index()
    {
        $setting = new Model_Settings();

        $data = array(
            'telephone_1' => $setting->get('tel1'),
            'telephone_2' => $setting->get('tel2'),
            'email' => $setting->get('email'),
            'title' => $setting->get('title'),
            'address' => $setting->get('address'),
        );

        $post = $this->request->post();

        if (Security::is_token($post['csrf']) && $this->request->method() === Request::POST)
        {
            $post = array_map('Security::xss_clean', $post);

            switch ($post['type'])
            {
                case 'tel' :

                    if (Valid::phone($post['telephone_1'], 11) && Valid::phone($post['telephone_2'], 11))
                    {
                        $setting->set('tel1', $post['telephone_1']);
                        $setting->set('tel2', $post['telephone_2']);

                        $data = array_merge($post, $data);
                        $success = 'Номер(а) изменены.';
                    }
                    else
                    {
                        $data = array_merge($post, $data);
                        $error = 'Введите оба телефона правильно';
                    }

                break;

                case 'email' :

                    if (Valid::email($post['email']))
                    {
                        $setting->set('email', $post['email']);
                        $data = array_merge($post, $data);
                        $success = 'Email изменен.';
                    }
                    else
                    {
                        $data = array_merge($post, $data);
                        $error = 'Введите email правильно';
                    }

                break;

                case 'general' :

                    $setting->set('title', $post['title']);
                    $setting->set('address', $post['address']);

                    $data = array_merge($post, $data);
                    $success = 'Основные данные изменены.';

                break;
            }
        }

        $this->template->content = View::factory('admin/settings/index', compact('data', 'error', 'success'));
    }

    public function action_smtp()
    {
        $data = Kohana::$config->load('settings.smtp');
        if (!empty($data))
            $data = unserialize($data);

        $csrf = $this->request->post('csrf');
        if (Security::is_token($csrf) && $this->request->method() === Request::POST)
        {
            $data= $this->request->post();
            unset($data['csrf']);
            $values = array_filter($data);
            if (!empty($values))
{'fraction_non_alphanumeric': 0.16080042880114348, 'fraction_numerical': 0.005002680007146686, 'mean_word_length': 1.3373695198329854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, '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': '6341377', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1441, 'n_words': 253}