Example #1
0
    function defaultAction()
    {
        $subjects = array(1 => array('id' => 1, 'title' => s('General question')), 2 => array('id' => 2, 'title' => s('Bug report')), 3 => array('id' => 3, 'title' => s('Collaboration or partership')), 4 => array('id' => 4, 'title' => s('Idea')), 5 => array('id' => 5, 'title' => s('Other')));
        $html = '';
        $errors = array();
        $is_posted = request_int('is_posted');
        $jump_to = 'feedback_name';
        if ($is_posted) {
            if (!count($errors) && !request_str('email')) {
                $errors[] = s('Please, enter your email');
                $jump_to = 'feedback_email';
            }
            if (!count($errors) && request_str('email') && !filter_var(request_str('email'), FILTER_VALIDATE_EMAIL)) {
                $errors[] = s('Please, provide correct email address. For example: john@gmail.com');
                $jump_to = 'feedback_email';
            }
            if (!count($errors) && !request_str('message')) {
                $errors[] = s('Enter the message.');
                $jump_to = 'feedback_password';
            }
            if (!count($errors)) {
                $data = array('{name}' => request_str('name'), '{email}' => request_str('email'), '{subject}' => $subjects[request_int('subject_id')]['title'], '{message}' => request_str('message'));
                $message = str_replace(array_keys($data), array_values($data), 'Name: {name}
Email: {email}

Subject: {subject}

{message}


' . $_SERVER['REMOTE_ADDR'] . ' ' . date('r'));
                core::$sql->insert(array('message' => core::$sql->s($message), 'insert_stamp' => core::$sql->i(time())), DB . 'feedback');
                require_once '../mod/lib.mail.php';
                foreach (array('*****@*****.**') as $email) {
                    mail_send(request_str('name'), request_str('email'), $email, 'Metro4all.org - ' . $subjects[request_int('subject_id')]['title'], $message, false);
                }
                go(Core::$config['http_home'] . 'feedback/?action=ok');
            }
        }
        $page = new PageCommon(s('Feedback'));
        $html .= $page->start();
        $html .= '<div class="row"><div class="col-md-offset-2 col-md-8"><h2>' . s('Feedback') . '</h2>';
        if (count($errors)) {
            $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>';
        }
        $form = new Form('feedback', false, 'post');
        $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('name', s('Name'), $is_posted ? request_str('name') : '') . $form->addString('email', s('E-mail'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->addSelect('subject_id', s('Subject'), $is_posted ? request_int('subject_id') : 1, array('data' => $subjects)) . $form->addText('message', s('Message'), $is_posted ? request_str('message') : '', array('is_required' => true, 'style' => 'height:200px')) . $form->submit(s('Send')) . '</div>';
        $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>';
        $html .= '</div></div>';
        $html .= $page->stop();
        return $html;
    }
 function defaultAction()
 {
     $html = '';
     $errors = array();
     $is_posted = request_int('is_posted');
     $jump_to = 'subscription_email';
     if ($is_posted) {
         // $captcha_code = request_str('captcha_code');
         if (!count($errors) && !request_str('email')) {
             $errors[] = s('Please, enter your email');
             $jump_to = 'register_email';
         }
         if (!count($errors) && request_str('email') && !filter_var(request_str('email'), FILTER_VALIDATE_EMAIL)) {
             $errors[] = s('Please, provide correct email address. For example: john@gmail.com');
             $jump_to = 'register_email';
         }
         // if(captcha_compare(request_str('captcha_code'))) {
         //	captcha_close();
         if (!count($errors)) {
             // file_put_contents('data/subscription.txt', "\r\n" . request_str('email'), FILE_APPEND | LOCK_EX);
             core::$sql->insert(array('email' => core::$sql->s(request_str('email')), 'insert_stamp' => core::$sql->i(time())), DB . 'subscription');
             /*
             			        switch (request_int('language_id')) {
             			        	case 1: mail('*****@*****.**', 'subscribe gisconf '.request_str('email'), '*password: Oov4eeph', 'From: news@gisconf.ru'); break;
             			        	case 2: mail('*****@*****.**', 'subscribe gisconf-en '.request_str('email'), '*password: Oov4eeph', 'From: news-en@gisconf.ru'); break;
             			        }
             */
             go(core::$config['http_home'] . 'subscription/?action=ok');
         }
         // }
         // else
         //	$errors []= 'Неверный код подтверждения';
     }
     $page = new PageCommon(s('Newsletter'));
     $html .= $page->start();
     $html .= '<div class="row"><div class="col-md-offset-1 col-md-6"><h1>' . s('Newsletter') . '</h1>';
     if (count($errors)) {
         $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>';
     }
     $form = new Form('subscription', false, 'post');
     $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('email', s('E-mail'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->submit(s('Subscribe')) . '</div>';
     $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>';
     $html .= '</div></div>';
     $html .= $page->stop();
     return $html;
 }
Example #3
0
    function lostPasswordAction()
    {
        $html = '';
        $errors = array();
        $is_posted = request_int('is_posted');
        $jump_to = 'lost_password_email';
        if ($is_posted) {
            // $captcha_code = request_str('captcha_code');
            if (!count($errors) && !request_str('email')) {
                $errors[] = s('Пожалуйста, укажите e-mail.');
            }
            $email = request_str('email');
            if (!count($errors)) {
                if (($user = core::$sql->row('id, password', DB . 'user', 'email=' . core::$sql->s($email) . ' and id<>' . core::$sql->i(User::ANONIMOUS) . ' and is_disabled=0')) === false) {
                    $errors[] = s('Пользователь с таким e-mail адресом не зарегистрирован.');
                }
            }
            // if(captcha_compare(request_str('captcha_code'))) {
            //	captcha_close();
            if (!count($errors)) {
                $hash = core::$user->getHash(core::$config['user']['lost_password_salt'], $user['password']);
                $template_vars = array('{site_url}' => core::$config['site']['url'], '{site_title}' => core::$config['site']['title'], '{site_email}' => core::$config['site']['email'], '{change_password_url}' => 'http://' . core::$config['http_domain'] . '/' . core::$config['current_language'] . '/lost_password/change/?id=' . $user['id'] . '&code=' . $hash);
                $message = str_replace(array_keys($template_vars), array_values($template_vars), s('Здравствуйте!

Ваш адрес был указан при запросе смены пароля на сайте {site_url}

Если вы не делали такой запрос проигнорируйте это письмо.

Для смены пароля перейдите по ссылке:
{change_password_url}

C уважением,
Администрация сайта
{site_title}
{site_email}
'));
                mail_send(core::$config['site']['email_title'], core::$config['site']['email'], $email, s('Смена пароля'), $message);
                go(core::$config['http_home'] . 'lost_password/sent/');
            }
            // }
            // else
            //	$errors []= 'Неверный код подтверждения';
        }
        $page = new PageCommon(s('Забыли пароль?'));
        $html .= $page->start();
        $html .= '<div class="row"><div class="col-md-offset-4 col-md-4"><h2>' . s('Забыли пароль?') . '</h2>';
        if (count($errors)) {
            $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>';
        }
        $form = new Form('lost_password', false, 'post');
        $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addString('email', s('E-mail'), $is_posted ? request_str('email') : '', array('is_required' => true)) . $form->submit(s('Восстановить пароль')) . '</div>';
        /*
        $html .= '<ul>
        		<li><a href="'.core::$config['http_home'].'login/">'.s('Вход для зарегистрированных').'</a></li>
        	</ul>';
        */
        $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>';
        $html .= '</div></div>';
        $html .= $page->stop();
        return $html;
    }
Example #4
0
    function updateAction()
    {
        if (!$this->is_admin) {
            go(core::$config['http_home'] . 'faq/');
        }
        if (($item = $this->getQa(request_int('id'))) === false) {
            go(core::$config['http_home']);
        }
        $html = '';
        $errors = array();
        $is_posted = request_int('is_posted');
        $jump_to = 'update_qa_title';
        if ($is_posted) {
            if (!count($errors) && !request_str('title')) {
                $errors[] = s('Пожалуйста, укажите вопрос.');
                $jump_to = 'update_qa_title';
            }
            if (!count($errors) && !request_str('group_title')) {
                $errors[] = s('Пожалуйста, укажите группу.');
                $jump_to = 'insert_qa_group_title';
            }
            if (!count($errors)) {
                $fields = array();
                foreach (Core::$config['languages'] as $url => $languages) {
                    $fields['title_' . $url] = core::$sql->s(request_str('title_' . $url));
                    $fields['group_title_' . $url] = core::$sql->s(request_str('group_title_' . $url));
                    $fields['description_' . $url] = core::$sql->s(request_str('description_' . $url));
                }
                core::$sql->update($fields, DB . 'qa', 'id=' . core::$sql->i($item['id']));
                go(core::$config['http_home'] . 'faq/');
            }
        }
        $page = new PageCommon(s('Изменить вопрос'));
        $html .= $page->start();
        $html .= '<p><a href="./">' . s('Q&A') . '</a> &rarr;</p>
				<h2>' . s('Изменить вопрос') . '</h2>';
        if (count($errors)) {
            $html .= '<div class="alert alert-error"><p>' . escape($errors[0]) . '</p></div>';
        }
        $form = new Form('update_qa', false, 'post');
        $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addVariable('action', 'update');
        foreach (Core::$config['languages'] as $url => $language) {
            $html .= $form->addString('title_' . $url, s('Вопрос') . ' ' . $language['title'], $is_posted ? request_str('title_' . $url) : $item['title_' . $url], array('class' => 'span7'));
        }
        foreach (Core::$config['languages'] as $url => $language) {
            $html .= $form->addString('group_title_' . $url, s('Группа') . ' ' . $language['title'], $is_posted ? request_str('group_title_' . $url) : $item['group_title_' . $url], array('class' => 'span7'));
        }
        foreach (Core::$config['languages'] as $url => $language) {
            $html .= $form->addString('description_' . $url, s('Ответ') . ' ' . $language['title'], $is_posted ? request_str('description_' . $url) : $item['description_' . $url], array('class' => 'span7', 'style' => 'height:250px;'));
        }
        $html .= $form->submit(s('Update')) . '</div>';
        $html .= '<script> $(document).ready(function() { $("#' . $jump_to . '").focus(); }); </script>';
        $html .= $page->stop();
        return $html;
    }