Exemplo n.º 1
0
 function authentication_user($password)
 {
     try {
         log_message('debug', "AUTHENTICATION");
         $this->load->model('dto/DtoUser');
         $this->load->model('dao/DaoUser');
         $user = new DtoUser();
         $userDao = new DaoUser();
         $user->setUsername($this->input->post('username', TRUE));
         $user->setPassword(md5($this->input->post('password', TRUE)));
         $result = $userDao->login($user);
         if ($result) {
             foreach ($result as $row) {
                 $user->setUsername($row->username);
                 $user->setUserid($row->userid);
                 $user->setUsertype($row->usertype);
                 $this->session->set_userdata('logged_in', $user);
                 $this->session->set_userdata('username', $this->encryption->encrypt($user->getUsername()));
                 $this->session->set_userdata('userid', $this->encryption->encrypt($user->getUserid()));
                 $this->session->set_userdata('usertype', $user->getUsertype());
                 return TRUE;
             }
         } else {
             $this->form_validation->set_message('authentication_user', 'Invalid username or password. Please try again.');
             return false;
         }
     } catch (Exception $ex) {
         log_message('debug', $ex->getMessage());
     }
 }
Exemplo n.º 2
0
 public function preform()
 {
     $DaoUser = new DaoUser();
     $result = $DaoUser->getUserInfoByUserId($this->params['safe']['uid']);
     $this->result['data'] = $result;
     //print_r($result);
 }
Exemplo n.º 3
0
 public function action()
 {
     //页面展示
     $AdminAjaxModel = new AdminAjaxModel();
     $result = $AdminAjaxModel->getResult();
     $type = $result['params']['safe']['type'];
     if ($type == 'user') {
         $DaoUser = new DaoUser();
         $result = $DaoUser->getUserInfoByUsername($result['params']['safe']['userName']);
         if ($result) {
             echo '1';
         } else {
             echo '0';
         }
     } else {
         if ($type == 'fenlei') {
             $DaoFenlei = new DaoFenlei();
             $result = $DaoFenlei->getFenleiInfoByName($result['params']['safe']['fenleiName']);
             if ($result) {
                 echo '1';
             } else {
                 echo '0';
             }
         }
     }
 }
Exemplo n.º 4
0
 public function preform()
 {
     $DaoUser = new DaoUser();
     $ret = $DaoUser->getUserInfoByUsernameAndPassWord($this->params['safe']['user_name'], $this->params['safe']['user_password']);
     if (empty($ret)) {
         throw new Exception('error_login', 1);
     }
     $this->result['data'] = $ret[0];
 }
Exemplo n.º 5
0
 public function checkUserName($data)
 {
     $DaoUser = new DaoUser();
     if ($DaoUser->getUserInfoByUsername($data['user_name']) == '0') {
         echo "0";
     } else {
         echo "1";
     }
 }
Exemplo n.º 6
0
 public function preform()
 {
     //        echo "WebSiteSittingModel.class.php";
     $DaoUser = new DaoUser();
     $result = $DaoUser->getUser();
     $limit = 7;
     $pageInfo = Tools::_pageInfo($this->params['safe']['page'], count($result), $limit);
     if (is_array($result)) {
         $result = array_slice($result, $pageInfo['start'], $pageInfo['limit']);
         //10
     }
     $this->result['data']['list'] = $result;
     $this->result['count'] = $DaoUser->getUserCount() / $limit;
     $this->result['page'] = $this->params['safe']['page'];
 }
Exemplo n.º 7
0
 public function preform()
 {
     $DaoUser = new DaoUser();
     //检测用户是否存在
     $data['user_name'] = $this->params['safe']['user_name'];
     $data['user_password'] = md5($this->params['safe']['user_password']);
     $data['user_nickname'] = $this->params['safe']['user_nickname'];
     $data['user_qm'] = "这家伙很懒还没有签名!";
     $data['user_inTime'] = time();
     if ($DaoUser->getUserInfoByUsername($data['user_name']) == '0') {
         $ret = $DaoUser->addUser($data);
         $this->result['code'] = $ret == 0 ? 1 : 0;
     } else {
         $this->result['code'] = 1;
     }
 }
Exemplo n.º 8
0
 public function preform()
 {
     $DaoBlog = new DaoArticle();
     $list = $DaoBlog->getBlogList();
     $pageInfo = Tools::_pageInfo($this->params['safe']['page'], count($list), $limit = 10);
     //=============
     if (is_array($list)) {
         $list = array_slice($list, $pageInfo['start'], $pageInfo['limit']);
         //10
     }
     $DaoUser = new DaoUser();
     $hot_user = $DaoUser->getUser();
     $this->result['hot_user'] = $hot_user;
     $this->result['data']['list'] = $list;
     $this->result['pageInfo'] = $pageInfo;
 }
Exemplo n.º 9
0
 public function authenticate()
 {
     log_message('debug', "AUTHENTICATION");
     $this->load->model('dto/DtoUser');
     $this->load->model('dao/DaoUser');
     $user = new DtoUser();
     $userDao = new DaoUser();
     $this->load->library('form_validation');
     $this->form_validation->set_rules('username', 'Username', 'required');
     $this->form_validation->set_rules('password', 'Password', 'required');
     if ($this->form_validation->run() == FALSE) {
         log_message('debug', "FALSE");
         $this->load->view('admin-kh4it/index', 'refresh');
     } else {
         log_message('debug', "TRUE");
         $user->setUsername($this->input->post('username'));
         $user->setPassword(md5($this->input->post('password')));
         $result = $userDao->login($user);
         if ($result) {
             foreach ($result as $row) {
                 log_message('debug', $row->username);
                 log_message('debug', $row->userid);
                 $user->setUsername($row->username);
                 $user->setUserid($row->userid);
                 $user->setUsertype($row->usertype);
                 $this->session->set_userdata('logged_in', $user);
                 $this->session->set_userdata('username', $this->encryption->encrypt($user->getUsername()));
                 $this->session->set_userdata('userid', $this->encryption->encrypt($user->getUserid()));
                 $this->session->set_userdata('usertype', $user->getUsertype());
                 log_message("debug", $this->encryption->decrypt($user->getUserid()));
             }
             redirect("admin/dashboard");
         } else {
             $this->form_validation->set_message('check_database', 'Invalid username or password');
             $this->login();
         }
     }
 }
Exemplo n.º 10
0
 public function preform()
 {
     $uploadFile = new FileUpload();
     $uploadFile->set("maxsize", 2000000);
     $uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
     $uploadFile->set("israndname", true);
     if ($this->params['safe']['type'] == "addArticle") {
         $path = "../uploadfile/article/" . $this->params['safe']['fenlei_id'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fm_img')) {
             $data = array('uid' => 1, 'title' => $this->params['safe']['title'], 'contents' => $this->params['safe']['contents'], 'fenlei_id' => $this->params['safe']['fenlei_id'], 'fm_img' => $path . $uploadFile->getFileName(), 'time' => time());
             $DaoArticle = new DaoArticle();
             $DaoArticle->insertArticle($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addUser") {
         $path = "../uploadfile/user_img/" . $this->params['safe']['user_name'] . "/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('user_img')) {
             $data = array('user_name' => $this->params['safe']['user_name'], 'user_nickname' => $this->params['safe']['user_nickname'], 'user_password' => md5($this->params['safe']['password']), 'user_qm' => "这家伙还没写签名呢!", 'user_img' => $path . $uploadFile->getFileName(), 'user_inTime' => time());
             $DaoUser = new DaoUser();
             $DaoUser->addUser($data);
         } else {
             //获取上传失败以后的错误提示
             throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
         }
     } elseif ($this->params['safe']['type'] == "addfenlei") {
         $path = "../uploadfile/Fenlei/";
         $uploadFile->set("path", $path);
         if ($uploadFile->upload('fenlei_img')) {
             $data = array('name' => $this->params['safe']['name'], 'time' => time(), 'fenlei_img' => $path . $uploadFile->getFileName());
             $DaoFenlei = new DaoFenlei();
             $DaoFenlei->addFenlei($data);
         }
     }
 }
Exemplo n.º 11
0
 public static function formartBlogList($list)
 {
     if (empty($list)) {
         return false;
     }
     $blog_type = array(1 => "历史迷雾", 2 => '个人心路', 3 => '技术控', 4 => '学习心得');
     $DaoUser = new DaoUser();
     $DaoComment = new DaoComment();
     foreach ($list as $key => $value) {
         $list[$key]['create_time'] = date("Y-m-d H:i:s", $value['create_time']);
         $content = strip_tags($value['blog']);
         //经典的汉字截断方法
         if (mb_strlen($content, "UTF-8") > 200) {
             $content = mb_substr($content, 0, 200, 'UTF-8') . "...";
         }
         $list[$key]['blog_type_name'] = $blog_type[$value['blog_type']];
         $list[$key]['blog'] = $content;
         $user_info = $DaoUser->getUserInfoByUserId($value['user_id']);
         $list[$key]['user_info'] = $user_info[0];
         $total = $DaoComment->getTotalCommentByBlogId($value['id']);
         $list[$key]['comment_total'] = $total;
     }
     return $list;
 }
Exemplo n.º 12
0
{
    $months = date("n") + 4;
    if (date("n") == 12) {
        $months = 4;
    }
    $data = date("j / {$months} / Y");
    $status = "valido";
    $dados = array($data, $status);
    return $dados;
}
$dados = status();
$pessoa = new Pessoa($_POST["nome"], $_POST["filiacao"], $_POST["nascionalidade"], $_POST["naturalidade"], $_POST["nascimento"], $_POST["sexo"], $_POST["cpf"], $_POST["rg"], $_POST["orgaoemissor"], $_POST["expedicao"], $dados[0], $dados[1]);
$instituicao = new Instituicao($_POST["fi"], $_POST["uf3"], $_POST["carreira"], $_POST["ac"], $_POST["localtrabalho"], $_POST["endereco"], $_POST["cidade"], $_POST["cep"], $_POST["telres"], $_POST["celular"], $_POST["email"]);
$login = new Login($_POST["login"], $_POST["senha"]);
$daoPessoa = new DaoPessoa($pessoa, $conecta);
$daoUser = new DaoUser($user, $conecta);
$daoInstituicao = new DaoInstituicao($instituicao, $conecta);
$daoLogin = new DaoLogin($login, $conecta);
if ($daoPessoa->inserir()) {
    print "ok";
}
if ($daoUser->inserir()) {
    print "ok";
}
if ($daoInstituicao->inserir()) {
    print "ok";
}
if ($daoLogin->inserir()) {
    print "ok";
}
/*
Exemplo n.º 13
0
<?php

$conecta->getConexao()->commit();
$daoPessoa = new DaoPessoa($pessoa, $conecta);
$daoPessoa->inserir();
$uidpessoa = $daoPessoa->recuperaId();
$uidpessoa = $uidpessoa[0];
$user->setUidpessoa($uidpessoa);
$daoUser = new DaoUser($user, $conecta);
$daoUser->inserir();
$instituicao->setUidpessoa($uidpessoa);
$daoInstituicao = new DaoInstituicao($instituicao, $conecta);
$daoInstituicao->inserir();
$login->setUidpessoa($uidpessoa);
$daoLogin = new DaoLogin($login, $conecta);
$daoLogin->inserir();
$profissional->setUidpessoa($uidpessoa);
$daoProfissional = new DaoProfissional($profissional, $conecta);
$daoProfissional->inserir();
$conecta->getConexao()->rollback();
Exemplo n.º 14
0
 public function updateUserStatusPro()
 {
     $this->load->model("dao/DaoUser");
     $this->load->model("dto/DtoUser");
     $user = new DtoUser();
     $userDao = new DaoUser();
     $user->setUserid($this->input->post('userid'));
     $user->setActive($this->input->post("status"));
     if ($userDao->update_status($user)) {
         $data["ERROR"] = false;
     } else {
         $data["ERROR"] = true;
         $data["ERR_MSG"] = "Your user cannot update.";
     }
     echo json_encode($data);
 }