Example #1
0
 function update($id, $data = array())
 {
     if ($data['password']) {
         $data['password'] = end_encode($data['password']);
     } else {
         unset($data['password']);
     }
     return parent::update($id, $data);
 }
Example #2
0
function end_on_after_db()
{
    if ($_GET['p'] == 'setlang' && $_GET['lang']) {
        setcookie('lang', $_GET['lang']);
    }
    if (!$_SESSION['user'] && $_COOKIE['hash'] && $_COOKIE['uid']) {
        if ($_COOKIE['hash'] == end_encode($_COOKIE['uid'])) {
            $_SESSION['user'] = model('user')->get_one($_COOKIE['uid']);
        }
    }
    if ($_SESSION['user'] && $_SESSION['user']['language']) {
        define('END_LANGUAGE', $_SESSION['user']['language']);
    } else {
        if ($_COOKIE['lang']) {
            define('END_LANGUAGE', $_COOKIE['lang']);
        } else {
            $l = strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'zh') !== false ? 'cn' : 'en';
            define('END_LANGUAGE', $l);
        }
    }
}
Example #3
0
            } else {
                ajax_exit('error');
            }
        }
    } else {
        if ($m == 'new') {
            if ($_POST) {
                if ($obj->add($_POST)) {
                    ajax_exit($db->insert_id());
                }
            }
            ajax_exit('error');
        } else {
            if ($m == 'update_password') {
                if ($id && $value) {
                    $password = end_encode($value);
                    if ($obj->update($id, array('password' => $password))) {
                        ajax_exit('success');
                    } else {
                        ajax_exit('error');
                    }
                }
            }
        }
    }
}
function ajax_exit($s)
{
    echo $s;
    die;
}