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
 /**
  * Return a form object based on the Variables in the current object.
  * @return \Form
  */
 public function pullForm()
 {
     $vars = $this->getVars();
     $form = new \Form();
     foreach ($vars as $parameter) {
         if ($parameter instanceof \Variable) {
             if ($parameter->getVarname() == 'id') {
                 $input = $parameter->getInput();
                 $input->setId('resource-id');
                 $form->plugInput($input);
             } else {
                 $form->addVariable($parameter);
             }
         }
     }
     return $form;
 }
Example #4
0
 function lostPasswordChangeAction()
 {
     if (($user = core::$sql->row('id, password', DB . 'user', 'id=' . core::$sql->i(request_int('id', true)) . ' and id<>' . core::$sql->i(User::ANONIMOUS) . ' and is_disabled=0')) === false) {
         out();
     }
     if (($hash = core::$user->getHash(core::$config['user']['lost_password_salt'], $user['password'])) != request_str('code', true)) {
         out();
     }
     $html = '';
     $errors = array();
     $is_posted = request_int('is_posted');
     $jump_to = 'lost_password_change_password';
     if ($is_posted) {
         // $captcha_code = request_str('captcha_code');
         if (!count($errors) && !request_str('password')) {
             $errors[] = s('Пожалуйста, укажите пароль.');
         }
         if (!count($errors) && request_str('password') != request_str('password2')) {
             $errors[] = s('Введенные пароли не совпадают. Пожалуйста, попробуйте еще раз.');
         }
         // if(captcha_compare(request_str('captcha_code'))) {
         //	captcha_close();
         if (!count($errors)) {
             $password_hash = core::$user->getHash(core::$config['user']['password_salt'], request_str('password'));
             core::$sql->update(array('password' => core::$sql->s($password_hash)), DB . 'user', 'id=' . core::$sql->i($user['id']));
             core::$user->logout();
             go(core::$config['http_home'] . 'lost_password/changed/');
         }
         // }
         // else
         //	$errors []= 'Неверный код подтверждения';
     }
     $page = new PageCommon(s('Смена пароля'));
     $html .= $page->start();
     $html .= '<div class="row"><div class="span4 offset4"><h2>' . s('Смена пароля') . '</h2>';
     if (count($errors)) {
         $html .= '<div class="alert alert-danger"><p>' . escape($errors[0]) . '</p></div>';
     }
     $form = new Form('lost_password_change', false, 'post');
     $html .= '<div class="well">' . $form->start() . $form->addVariable('is_posted', 1) . $form->addVariable('id', request_int('id')) . $form->addVariable('code', request_str('code')) . $form->addPassword('password', s('Пароль'), '', array('is_required' => true)) . $form->addPassword('password2', s('Подтверждение пароля'), '', 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 #5
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;
    }