Exemplo n.º 1
0
 public function __construct()
 {
     $this->fw = fw::i();
     if ($this->model_name) {
         $this->model = fw::model($this->model_name);
     }
 }
Exemplo n.º 2
0
 public function __construct($param_fw = null)
 {
     if (is_null($param_fw)) {
         $this->fw = fw::i();
     } else {
         $this->fw = $fw;
     }
 }
Exemplo n.º 3
0
 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");
     }
 }
Exemplo n.º 4
0
 public static function global_init()
 {
     $me_id = Utils::me();
     #permanent login support
     if (!$me_id) {
         fw::model('Users')->check_permanent_login();
         $me_id = Utils::me();
     }
     #if (!isset($_SESSION['categories'])) $_SESSION['categories']=fw::model('Categories')->ilist();
     #'also force set XSS code
     if (!isset($_SESSION['XSS'])) {
         $_SESSION['XSS'] = Utils::get_rand_str(16);
     }
 }
Exemplo n.º 5
0
 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");
     }
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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");
     }
 }
Exemplo n.º 8
0
 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");
     }
 }
Exemplo n.º 9
0
 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");
     }
 }
Exemplo n.º 10
0
 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");
     }
 }
Exemplo n.º 11
0
 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");
         }
     }
 }
Exemplo n.º 12
0
<?php

require_once dirname(__FILE__) . "/php/fw/fw.php";
$ROUTES = array('/Logoff' => '/Login/(Logoff)');
fw::run($ROUTES);
exit;
Exemplo n.º 13
0
 public static function redirect($url, $noexit = '')
 {
     $url = fw::url2abs($url);
     logger("REDIRECT to [{$url}]");
     $ps = array('url' => $url);
     parse_page("/common", "redirect_js.html", $ps);
     if (!$noexit) {
         throw new ExitException();
     }
 }
Exemplo n.º 14
0
 public function LogoffAction()
 {
     global $CONFIG;
     //delete session
     $_SESSION = array();
     session_destroy();
     $this->model->remove_perm_cookie();
     fw::redirect($CONFIG['UNLOGGED_DEFAULT_URL']);
 }
Exemplo n.º 15
0
function hfvalue($tag, &$hf)
{
    $value = NULL;
    if (!isset($tag)) {
        return $value;
    }
    $empty_val = NULL;
    if (preg_match("/\\[/", $tag)) {
        $arr = explode('[', $tag);
        if (strtoupper($arr[0]) == 'GLOBAL') {
            #was $ptr=&$GLOBALS;
            $ptr = fw::i()->G;
            array_shift($arr);
        } elseif (strtoupper($arr[0]) == 'SESSION') {
            $ptr =& $_SESSION;
            array_shift($arr);
        } else {
            $ptr =& $hf;
        }
        for ($i = 0; $i < count($arr); $i++) {
            $k = preg_replace("/\\].*?/", '', $arr[$i]);
            #remove last ]
            if (is_array($ptr) && array_key_exists($k, $ptr)) {
                $ptr =& $ptr[$k];
            } else {
                $ptr =& $empty_val;
                #looks like there are just no such key in array OR $ptr is not an array at all - so return empty value
                break;
            }
        }
        $value = $ptr;
    } else {
        if (is_array($hf) && array_key_exists($tag, $hf)) {
            $value = $hf[$tag];
        }
    }
    return $value;
}
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 17
0
 public static function write($icode, $value)
 {
     return Utils::f2date(fw::i()->set_value($icode, $value));
 }