* * /form/form-id */ $id = isset($this->params[0]) ? $this->params[0] : (isset($data['id']) ? $data['id'] : false); if (!$id) { // no form specified @error_log('no form specified'); return; } $f = new form\Form((int) $id); if ($f->error) { // form not found @error_log('form not found'); return; } if ($f->submit()) { // handle form submission // unset csrf prevention token unset($_POST['_token_']); // save the results $r = new form\Results(array('form_id' => $id, 'ts' => gmdate('Y-m-d H:i:s'), 'ip' => $_SERVER['REMOTE_ADDR'])); $r->results = $_POST; $r->put(); // call any custom hooks $this->hook('form/submitted', array('form' => $id, 'values' => $_POST)); foreach ($_POST as $k => $v) { if (is_array($v)) { $_POST[$k] = join(', ', $v); } } // if there's a redirect, we wait to exit after