Esempio n. 1
0
 public function add()
 {
     $target = $this->pre_process();
     $errors = array();
     if (generate_form_token('thanks' . $this->pid . $this->uid) == $this->token) {
         $ret = $this->add_voice($errors, $target);
         if (App::$is_ajax) {
             if (empty($errors)) {
                 App::send_json(array('message' => App::$lang['Redirect Message'], 'uid' => $this->uid, 'pid' => $this->pid));
             } else {
                 App::send_json(array('code' => -1, 'message' => implode('<br />', $errors)));
             }
         } elseif ($ret) {
             App::$forum_flash->add_info(App::$lang['Redirect Message']);
             redirect(forum_link(App::$forum_url['post'], $this->pid), App::$lang['Redirect Message']);
         }
     } else {
         echo $this->token . '|' . generate_form_token('thanks' . $this->uid . $this->pid) . '|' . generate_form_token('thanks' . $this->pid . $this->uid);
     }
 }
Esempio n. 2
0
 private function do_action($action)
 {
     $target = $this->pre_process($action);
     $errors = array();
     if (isset($_POST['form_sent'])) {
         if ($this->add_voice($errors, $target, $action)) {
             App::$forum_flash->add_info(App::$lang['Redirect Message']);
             redirect(forum_link(App::$forum_url['post'], $this->pid), App::$lang['Redirect Message']);
         }
     }
     App::$forum_page['form_action'] = forum_link(App::$forum_url['reputation_' . $action], array($this->pid, $this->uid));
     if (App::$is_ajax) {
         if (empty($errors)) {
             App::send_json(array('csrf_token' => generate_form_token(App::$forum_page['form_action']), 'title' => App::$lang['Reputation'], 'description' => sprintf(App::$lang[ucfirst($action)], forum_htmlencode($target['username'])), 'user' => $target['username'], 'cancel' => forum_htmlencode(App::$lang_common['Cancel']), 'submit' => forum_htmlencode(App::$lang_common['Submit'])));
         } else {
             App::send_json(array('error' => implode('<br />', $errors)));
         }
     }
     View::$instance = View::factory($this->view . 'form', array('heading' => sprintf(App::$lang[ucfirst($action)], forum_htmlencode($target['username']))));
     View::$instance->errors = View::factory($this->view . 'errors', array('errors' => $errors, 'head' => App::$lang['Errors']));
 }