public function SaveAction() { $item = req('item'); $item['login'] = trim($item['login']); try { $this->Validate($id, $item); $user = $this->model->one_by_email($item['login']); $this->fw->send_email_tpl($user['login'], 'email_pwd.txt', $user); fw::redirect($this->base_url . '/(Sent)'); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("Index"); } }
public function SaveAction() { $id = Utils::me(); $item = req('item'); try { $this->Validate($id, $item); $vars = FormUtils::form2dbhash($item, 'email fname lname address1 address2 city state zip phone'); $this->model->update($id, $vars); $this->fw->flash("record_updated", true); fw::redirect($this->base_url); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } }
public function SaveAction() { $mail_to = $this->fw->G['SUPPORT_EMAIL']; $mail_subject = reqs('subject'); $redirect_to = reqs('redirect'); $sys_fields = Utils::qh('form_format redirect subject submit RAWURL XSS'); $msg_body = ''; foreach ($_POST as $key => $value) { if (array_key_exists($key, $sys_fields)) { continue; } $msg_body .= $key . ' = ' . $value . "\n"; } $this->fw->send_email($mail_to, $mail_subject, $msg_body); //need to add root_domain, so no one can use our redirector for bad purposes fw::redirect($this->fw->G['ROOT_DOMAIN'] . $redirect_to); }
public function SaveAction($form_id) { $id = $form_id + 0; $item = req('item'); try { $this->Validate($id, $item); #load old record if necessary #$item_old = $this->model->one($id); $itemdb = FormUtils::form2dbhash($item, $this->save_fields); #TODO - checkboxes support #FormUtils::form2dbhash_checkboxes($itemdb, $item, 'is_checkbox'); $id = $this->model->update($id, $itemdb); #TODO cleanup any caches that depends on settings #FwCache::remove("XXX"); fw::redirect($this->base_url . '/' . $id . '/edit'); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } }
public function SaveAction($form_id) { global $CONFIG; $id = $form_id + 0; $item = req('item'); try { $this->Validate($id, $item); #load old record if necessary #$item_old = $this->model->one($id); $itemdb = FormUtils::form2dbhash($item, $this->save_fields); $id = $this->model_add_or_update($id, $itemdb); #signup confirmaiton email $user = $this->model->one($id); $ps = array('user' => $user); $this->fw->send_email_tpl($user['email'], 'signup.txt', $ps); $this->model->do_login($id); fw::redirect($CONFIG['LOGGED_DEFAULT_URL']); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } }
public function SaveAction($form_id) { $id = $form_id + 0; $item = req('item'); try { $this->Validate($id, $item); #load old record if necessary #$item_old = $this->model->one($id); $itemdb = FormUtils::form2dbhash($item, $this->save_fields); if (!strlen($itemdb['pwd'])) { unset($itemdb['pwd']); } $id = $this->model_add_or_update($id, $itemdb); if ($id == Utils::me()) { $this->model->session_reload(); } fw::redirect($this->base_url . '/' . $id . '/edit'); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } }
public function SaveAction($form_id) { $id = $form_id + 0; $item = req('item'); try { $this->Validate($id, $item); #load old record if necessary #$item_old = $this->model->one($id); $itemdb = FormUtils::form2dbhash($item, $this->save_fields); FormUtils::form2dbhash_checkboxes($itemdb, $item, 'is_checkbox'); $itemdb['dict_link_auto_id'] = $this->model_related->add_or_update_quick($item['dict_link_auto_id_iname']); $itemdb['dict_link_multi'] = FormUtils::multi2ids(req('dict_link_multi')); #TODO $itemdb['fdate_combo'] = FormUtils::date4combo($item, 'fdate_combo'); $itemdb['ftime'] = DateUtils::timestr2int($item['ftime_str']); #ftime - convert from HH:MM to int (0-24h in seconds) $id = $this->model_add_or_update($id, $itemdb); fw::redirect($this->base_url . '/' . $id . '/edit'); } catch (ApplicationException $ex) { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } }
public function SaveMultiAction() { $acb = req('cb'); if (!is_array($acb)) { $acb = array(); } $is_delete = reqs('delete') > ''; $ctr = 0; foreach ($acb as $id => $value) { if ($is_delete) { $this->model->delete($id); $ctr += 1; } } $this->fw->flash("multidelete", $ctr); fw::redirect($this->base_url); }
public function LogoffAction() { global $CONFIG; //delete session $_SESSION = array(); session_destroy(); $this->model->remove_perm_cookie(); fw::redirect($CONFIG['UNLOGGED_DEFAULT_URL']); }
public function SaveAction($form_id) { $id = $form_id + 0; $item = req('item'); if (!is_array($item)) { $item = array(); } $files = UploadUtils::get_posted_files('file1'); try { $this->Validate($id, $item, $files); #load old record if necessary #$item_old = $this->model->one($id); $itemdb = FormUtils::form2dbhash($item, $this->save_fields); if (!strlen($itemdb["iname"])) { $itemdb["iname"] = 'new file upload'; } $is_add = $id == 0; $id = $this->model_add_or_update($id, $itemdb); #Proceed upload if (count($files)) { $this->model->upload($id, $files[0], $is_add); } logger($this->fw->get_response_expected_format()); if ($this->fw->get_response_expected_format() == 'json') { $item = $this->model->one($id); return array('success' => true, 'id' => $id, 'item' => $item, 'url' => $this->model->get_url_direct($item)); } else { fw::redirect($this->base_url . '/' . $id . '/edit'); } } catch (ApplicationException $ex) { logger($this->fw->get_response_expected_format()); logger($ex->getMessage()); if ($this->fw->get_response_expected_format() == 'json') { return array('success' => false, 'err_msg' => $ex->getMessage(), 'id' => $id); } else { $this->set_form_error($ex->getMessage()); $this->route_redirect("ShowForm"); } } }