티스토리 뷰
이전글과 비슷하지만 패스워드를 암호화함. 그래야 나중에 조회시 사용할 수 있음.
<?php
// 1. 에러가 화면에 텍스트로 찍히면 JSON이 깨지므로 일단 끕니다.
error_reporting(0);
ini_set('display_errors', 0);
define('__XE__', true);
// 2. 경로 자동 탐색 (현재 파일 위치 기준으로 config 파일을 찾습니다)
$config_path = $_SERVER['DOCUMENT_ROOT'] . '/config/config.inc.php';
if (!file_exists($config_path)) {
// 만약 루트가 아니라면 상대 경로로 다시 시도
$config_path = dirname(__FILE__) . '/../config/config.inc.php';
}
if (!file_exists($config_path)) {
header('Content-Type: application/json');
die(json_encode(array('error' => -1, 'message' => 'Config file not found.')));
}
require_once($config_path);
$oContext = &Context::getInstance();
$oContext->init();
// 3. 입력값 받기
$title = $_POST['title'];
$content = $_POST['content'];
$nick_name = $_POST['nick_name'] ?: '비회원';
$password = $_POST['password'] ?: '1111';
$module_srl = 51;
header('Content-Type: application/json');
try {
if(!$title || !$content) throw new Exception('제목 또는 내용이 비어있습니다.');
// 4. 라이믹스 비밀번호 해싱
$memberModel = getModel('member');
if(!$memberModel) throw new Exception('Member 모델 로드 실패');
$hash_password = $memberModel->hashPassword($password);
// 5. DB 입력
$oDB = DB::getInstance();
$document_srl = getNextSequence();
$regdate = date('YmdHis');
$query = "INSERT INTO documents
(document_srl, module_srl, title, content, user_id, nick_name, password, regdate, last_update, list_order, update_order, comment_status, status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$args = array(
$document_srl, $module_srl, $title, $content,
0, $nick_name, $hash_password,
$regdate, $regdate,
$document_srl * -1, $document_srl * -1,
'ALLOW', 'SECRET'
);
$stmt = $oDB->prepare($query);
$result = $stmt->execute($args);
if($result) {
echo json_encode(array('error' => 0, 'message' => 'success'));
} else {
throw new Exception('DB Insert 실패');
}
} catch (Exception $e) {
// 에러 발생 시에도 JSON 규격에 맞춰 응답
echo json_encode(array('error' => -1, 'message' => $e->getMessage()));
}'라이믹스' 카테고리의 다른 글
| 라이믹스 입력폼 (0) | 2026.03.10 |
|---|---|
| 라이믹스 위젯으로만 메인화면 전체를 사용하여 구성하는 방법(백그라운드 색 표현 가능) (0) | 2025.12.09 |
| 라이믹스 슬라이딩 위젯 (0) | 2025.12.09 |
| 라이믹스 위젯 js,css 로딩이 잘 안될때 (0) | 2025.12.09 |
| 라이믹스 입력폼 (0) | 2025.07.31 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 스크래핑
- 이클립스
- esql
- 포인터
- JDBC
- C언어
- KG
- XE3
- 문자열
- 자바 smtp
- 인포믹스
- MySQL
- 플러터
- XE
- xe addon
- webix
- 오라클
- C
- ocjap
- proc
- 자바
- php
- 파싱
- 프로씨
- xe애드온
- EC
- ocajp
- 파이썬
- 라이믹스
- Python
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
글 보관함

