Example #1
0
 function add($id_user, $login_name)
 {
     $akey = sha256(make_code() . $login_name);
     $c = new Query();
     $c->value('user_id', $id_user);
     $c->value('akey', $akey);
     $this->insert($c);
     return $akey;
 }
Example #2
0
 public function find_pwd()
 {
     $res = $this->Members->find_id($_REQUEST);
     if ($res) {
         $new_pw = make_code();
         $this->Members->edit_pwd_by_mail($res["id"], $new_pw);
         $m = new TF_mailer($this->settings);
         $m->mailto = $res["email"];
         $m->subject = "[D.CAMP] 비밀번호 확인 메일입니다.";
         $m->tpl_name = "pw_renew";
         $m->assigns["userid"] = $res["ids"];
         $m->assigns["new_pw"] = $new_pw;
         $m->assigns["main_service_url"] = $this->globals->my_host;
         $m->assigns["main_service_domain"] = $_SERVER['SERVER_NAME'];
         $m->send();
     }
     $this->assigns["res"] = $res;
 }
Example #3
0
$code = isset($_POST['code']) ? $_POST['code'] : '';
if (!($uid > 0) || !$code) {
    exit_with('error', 'invalid user or code');
}
$data = C::t(TB)->fetch_all($uid)[$uid];
if (!$data || !$data['key']) {
    exit_with('error', 'invalid key');
}
$fail_count = $data['fail_count'];
$ban_until = $data['fail_ban_until'];
if (time() < $ban_until) {
    exit_with('error', 'failed too many times');
}
$key = $data['key'];
$tick = floor(time() / CODE_INTERVAL);
for ($i = 0; $i < CODE_LIFE; $i++) {
    if (make_code($key, $tick - $i + 1) === $code) {
        if ($fail_count > 0) {
            C::t(TB)->update($uid, array('fail_count' => 0));
        }
        C::t(LOG)->insert(array('uid' => $uid, 'action' => 'login', 'result' => 'ok'));
        exit_with('ok', user_login($uid));
    }
}
if (++$fail_count > MAX_FAIL_TIMES) {
    $ban_until = time() + FAIL_BAN_TIME;
    $fail_count = 0;
}
C::t(TB)->update($uid, array('fail_count' => $fail_count, 'fail_ban_until' => $ban_until));
C::t(LOG)->insert(array('uid' => $uid, 'action' => 'login', 'result' => 'fail * ' . $fail_count));
exit_with('error', 'login failed');
Example #4
0
 function add($_arr)
 {
     // $this->debug();
     $c = new Query();
     if ($_arr["utype"]) {
         $c->value("utype", $_arr["utype"]);
     }
     if ($_arr["ids"]) {
         $c->value("ids", $_arr["ids"]);
     }
     if ($_arr["name"]) {
         $c->value("name", $_arr["name"]);
     }
     if ($_arr["pwd"]) {
         $c->value("pwd", sha256($_arr["pwd"]));
     }
     if ($_arr["email"]) {
         $c->value("email", $_arr["email"]);
     }
     if ($_arr["birth"]) {
         $c->value("birth", $_arr["birth"]);
     }
     if ($_arr["gender"]) {
         $c->value("gender", $_arr["gender"]);
     }
     $c->value("education", $_arr["education"]);
     $c->value("education_sp", $_arr["education_sp"]);
     $c->value("education_st", $_arr["education_st"]);
     if ($_arr["company"]) {
         $c->value("company", $_arr["company"]);
     }
     if ($_arr["company_role"]) {
         $c->value("company_role", $_arr["company_role"]);
     }
     if ($_arr["bio"]) {
         $c->value("bio", $_arr["bio"]);
     }
     if ($_arr["tel"]) {
         $c->value("tel", $_arr["tel"]);
     }
     $c->value("email_rec", $_arr["email_rec"]);
     $c->value("sms_rec", $_arr["sms_rec"]);
     if (array_key_exists('grade', $_arr)) {
         $c->value("grade", $_arr["grade"]);
     }
     if (array_key_exists('state', $_arr)) {
         $c->value("state", $_arr["state"]);
     }
     if ($_arr["state_des"]) {
         $c->value("state_des", $_arr["state_des"]);
     }
     if ($_arr["admin_des"]) {
         $c->value("admin_des", $_arr["admin_des"]);
     }
     if ($_arr["last_edit"]) {
         $c->value("last_edit", $_arr["last_edit"]);
     }
     if (array_key_exists('wanted', $_arr)) {
         $c->value("wanted", $_arr["wanted"]);
     }
     if (array_key_exists('homepage', $_arr)) {
         $c->value("homepage", $_arr["homepage"]);
     }
     if (array_key_exists('blog', $_arr)) {
         $c->value("blog", $_arr["blog"]);
     }
     if (array_key_exists('linkedin', $_arr)) {
         $c->value("linkedin", $_arr["linkedin"]);
     }
     $c->value("public_act", $_arr["public_act"]);
     $c->value("date_edited", "now()", 1);
     if ($_arr["id"]) {
         if ($_arr["picture"]) {
             $c->value("picture", $_arr["picture"]);
         }
         $c->where_eq("id", $_arr["id"]);
         $this->update($c);
         return $_arr["id"];
     } else {
         if (!$_arr["id"] && $_arr["ids"]) {
             if ($_arr["picture"]) {
                 $c->value("picture", $_arr["picture"]);
             } else {
                 $c->value("picture", '/img/default-img-member.png');
             }
             $confirm_key = sha256(make_code() . $_arr["ids"]);
             $c->value("confirm_key", $confirm_key);
             $c->value("date_created", "now()", 1);
             $this->insert($c);
             return $res = $this->last_id();
         }
     }
 }
Example #5
0
 public function login()
 {
     if ($_SESSION["s"]) {
         header("Location: /member/" . $_SESSION["s"]["ids"]);
     }
     if ($_REQUEST["ids"]) {
         $check = $this->Members->login($_REQUEST);
         //            print_r($check); exit(1);
         if ($check == "error_9") {
             $this->assigns["ids"] = $_REQUEST["ids"];
             $this->assigns_layout["msg"] = "비밀번호를 확인해주세요.";
         } else {
             if ($check == "error_404") {
                 $this->assigns_layout["msg"] = "아이디를 확인해주세요.";
             } else {
                 if ($check == "error_300") {
                     $this->assigns_layout["msg"] = "회원 인증이 완료되지 않았습니다.<br />인증메일을 확인해주세요.";
                 } else {
                     if ($check == "error_200") {
                         $u = $this->Members->get_by_ids($_REQUEST["ids"]);
                         $new_pw = make_code();
                         $this->Members->edit_pwd_by_mail($u["id"], $new_pw);
                         $m = new TF_mailer($this->settings);
                         $m->mailto = $u["email"];
                         $m->subject = "[D.CAMP] 비밀번호 찾기 메일입니다.";
                         $m->tpl_name = "pw_renew";
                         $m->assigns["userid"] = $u["ids"];
                         $m->assigns["new_pw"] = $new_pw;
                         $m->assigns["main_service_url"] = $this->globals->my_host;
                         $m->assigns["main_service_domain"] = $_SERVER['SERVER_NAME'];
                         $m->send();
                         $this->assigns_layout["msg"] = "안녕하세요. D.CAMP입니다.<br />D.CAMP의 새로운 홈페이지에 오신 것을 환영합니다.<br />홈페이지 이전과 함께 기존 가입자의 경우 등록하신 메일(" . $u["email"] . ")로 새로운 임시 비밀번호를 발송해드렸습니다.<br />메일을 확인하시고 임시 비밀번호로 로그인해주세요. (멤버십 등 기존에 이용하시던 데이터는 이전 후에도 계속 유지됩니다)";
                     } else {
                         $_SESSION["s"] = $this->Members->get($check);
                         if (!$_SESSION["s"]["picture"]) {
                             $_SESSION["s"]["picture"] = '/img/default-img-member.png';
                         }
                         $_SESSION["s"]["acnt"] = $this->Activity->get_a_cnt(1, $_SESSION["s"]["id"], '0');
                         $_SESSION["s"]["fb"] = $this->Member_ext->get_by_user_id_type($_SESSION["s"]["id"], 1);
                         $_SESSION["s"]["tw"] = $this->Member_ext->get_by_user_id_type($_SESSION["s"]["id"], 2);
                         // auto_login
                         if (array_key_exists("auto_login", $_REQUEST) && $_REQUEST["auto_login"] == "1") {
                             $auto_login = $_REQUEST['auto_login'];
                             $auto_login = remove_tags($auto_login);
                             //자동로그인 업데이트
                             $this->Members->update_by_key('auto_login', 1, $_SESSION["s"]["id"]);
                             $akey = $this->Member_auto->add($_SESSION["s"]['id'], $_SESSION["s"]['ids']);
                             $_SESSION["s"]["auto_login"] = 1;
                             setcookie("dcamp_id_save", $_SESSION["s"]['id'], time() + 1209600, "/");
                             setcookie("dcamp_akey", $akey, time() + 1209600, "/");
                             $_SESSION["msg"] = "현재 &#039;로그인 유지&#039; 기능을 이용중입니다. 다른 이용자들과 함께 사용하는 PC인 경우 이용 후 반드시 로그아웃을 해 주세요!";
                         }
                         $con = $this->Content_category->get_cat_by_user($_SESSION["s"]["id"], 'cc.hidden = 0');
                         if (sizeof($con) > 0) {
                             $_SESSION["s"]["con"] = $con;
                         }
                         $mt = $this->Office_mento->cnt("user_id = " . $_SESSION["s"]["id"]);
                         if ($mt > 0) {
                             $_SESSION["s"]["mento"] = true;
                         }
                         $_SESSION["s"]["rep1"] = $this->Code->check('rep1', $_SESSION["s"]["id"]);
                         $_SESSION["s"]["rep2"] = $this->Code->check('rep2', $_SESSION["s"]["id"]);
                         $return_url = remove_tags($_REQUEST['returl_url']);
                         if ($return_url) {
                             header("Location: " . $return_url);
                         } else {
                             header("Location: /");
                         }
                     }
                 }
             }
         }
     }
     if (array_key_exists('url_next', $_GET)) {
         $next = $_GET['url_next'];
         $next = remove_tags($next);
     }
     if ($next) {
         $this->assigns['returl_url'] = $next;
     } else {
         $this->assigns['returl_url'] = get_return_url($_SERVER['HTTP_REFERER'], remove_tags($_REQUEST['returl_url']));
     }
     if ($_REQUEST["next"]) {
         $this->assigns["next"] = $_REQUEST["next"];
     }
     if ($_SESSION["error"]) {
         if ($_SESSION["error"] == "no_fb") {
             unset($_SESSION["error"]);
             $this->assigns_layout["msg"] = "연동된 페이스북 계정이 없습니다.";
         }
     }
 }