init
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
include __DIR__."/../dbinfo.php";
|
||||
|
||||
$db = new mysqli(MYSQL_RW_HOST, ZENITH_DB_ID, ZENITH_DB_PW, ZENITH_DB_NAME);
|
||||
|
||||
$event_seqs = [];
|
||||
$start_date = "2023-12-14";
|
||||
$end_date = "2023-12-14";
|
||||
|
||||
$query = " AND `url` = 'https://event.resta.co.kr/eventleads'";
|
||||
if(count($event_seqs)) $query .= " AND event_seq IN (".implode(",",$event_seqs).")";
|
||||
if($start_date) $query .= " AND date(reg_date) >= '{$start_date}'";
|
||||
if($end_date) $query .= " AND date(reg_date) <= '{$end_date}'";
|
||||
$sql = "SELECT * FROM event_leads_interlock WHERE is_success = 0 {$query};";
|
||||
echo $sql."<br>";
|
||||
$result = $db->query($sql);
|
||||
if(!$result->num_rows) exit;
|
||||
while($row=$result->fetch_assoc()) {
|
||||
$url = $row['url'];
|
||||
$send_data = json_decode($row['send_data'], true);
|
||||
$send_data['reg_date'] = $row['reg_date'];
|
||||
$data = json_encode($send_data);
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
$response =curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$res = json_decode($response, true);
|
||||
print_r($res);
|
||||
if($res['result'] == true) {
|
||||
$db->query("UPDATE event_leads_interlock SET is_success = 1, response_data = '{$response}' WHERE event_seq = {$row['event_seq']} AND leads_seq = {$row['leads_seq']} AND is_success = 0 AND `url` = '{$row['url']}'");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
include __DIR__."/../dbinfo.php";
|
||||
|
||||
$db = new mysqli(MYSQL_RW_HOST, MYSQL_USER_ID, MYSQL_USER_PW, MYSQL_DB_NAME);
|
||||
|
||||
$advertisers = ['더스퀘어치과의원', '메이드영성형외과의원', '모아만의원', '모우림의원', '열정치과의원' ,'우리들40플란트치과병원' , '하루플란트치과의원광고주', '한나이브성형외과의원', '강남애프터치과의원', '참좋은치과의원', '보가치과의원'];
|
||||
|
||||
//$eids = [6121036];
|
||||
|
||||
$start_date = "2023-12-01";
|
||||
$end_date = "2023-12-31";
|
||||
|
||||
$query = "";
|
||||
//if(count($eids)) $query .= " AND app.eid IN (".implode(",",$eids).")";
|
||||
if($start_date) $query .= " AND date(app.reg_date) >= '{$start_date}'";
|
||||
if($end_date) $query .= " AND date(app.reg_date) <= '{$end_date}'";
|
||||
|
||||
$sql = "SELECT app.*, dec_data(app.phone) as dec_phone, ei.seq as event_seq, ei.description, adv.name as advertiser_name, adv.agent as advertiser_agent, med.media as media_name, med.target as media_target
|
||||
FROM app_subscribe AS app
|
||||
JOIN zenith.event_information AS ei ON app.event_seq = ei.seq
|
||||
JOIN zenith.event_advertiser AS adv ON ei.advertiser = adv.seq
|
||||
JOIN zenith.event_media AS med ON ei.media = med.seq
|
||||
WHERE adv.name IN ('".implode("','",$advertisers)."') {$query}";
|
||||
$result = $db->query($sql);
|
||||
|
||||
if(!$result->num_rows) exit;
|
||||
$resta_url = "https://event.resta.co.kr/eventleads";
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$resta_interlock_data = array(
|
||||
"event_seq" => $row['event_seq'],
|
||||
"advertiser_name" => $row['advertiser_name'],
|
||||
"advertiser_agent" => $row['advertiser_agent'],
|
||||
"media_name" => $row['media_name'],
|
||||
"media_target" => $row['media_target'],
|
||||
"description" => $row['description'] ?? '',
|
||||
"partner_name" => "케어랩스",
|
||||
"name" => $row['name'] ?? '',
|
||||
"age" => $row['age'] ?? '',
|
||||
"branch" => $row['branch'] ?? '',
|
||||
"email" => $row['email'] ?? '',
|
||||
"gender" => $row['gender'] ?? '',
|
||||
"phone" => $row['dec_phone'] ?? '',
|
||||
"add1" => $row['add1'] ?? '',
|
||||
"add2" => $row['add2'] ?? '',
|
||||
"add3" => $row['add3'] ?? '',
|
||||
"add4" => $row['add4'] ?? '',
|
||||
"add5" => $row['add5'] ?? '',
|
||||
"add6" => $row['add6'] ?? '',
|
||||
"add7" => $row['add7'] ?? '',
|
||||
"add8" => $row['add8'] ?? '',
|
||||
"site" => $row['site'] ?? '',
|
||||
"memo" => $row['memo'] ?? '',
|
||||
"memo3" => $row['memo3'] ?? '',
|
||||
"remote_addr" => $row['ip'] ?? '',
|
||||
"agBox" => $row['agree'],
|
||||
"reg_date" => $row['reg_date']
|
||||
);
|
||||
$data = json_encode($resta_interlock_data);
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $resta_url,
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
|
||||
$response =curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$res = json_decode($response, true);
|
||||
|
||||
if($res['result'] == true) {
|
||||
$sql = "UPDATE app_subscribe SET returnvalue = '$response', url='$resta_url', data='$data' WHERE eid = '{$row['eid']}'";
|
||||
$insert_result = $db->query($sql);
|
||||
if($insert_result){
|
||||
print_r($res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
include __DIR__ . "/zenith_db.php";
|
||||
|
||||
class UpdateMemo {
|
||||
private $db;
|
||||
|
||||
public function __construct() {
|
||||
$validate = $this->validator($_POST);
|
||||
if($validate['result'] == false){
|
||||
exit(json_encode($validate, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
$this->db = new ZenithDB();
|
||||
$this->insertMemo($_POST);
|
||||
}
|
||||
|
||||
private function insertMemo($data) {
|
||||
$memoData = [
|
||||
'seq' => $data['seq'],
|
||||
'memo' => $data['memo']
|
||||
];
|
||||
$result = $this->db->insertToMemo($memoData);
|
||||
|
||||
echo json_encode(['result' => $result]);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function validator($postData)
|
||||
{
|
||||
if (!is_array($postData)){
|
||||
return ['result' => false, 'msg' => 'POST 데이터를 전송해주십시오.'];
|
||||
}
|
||||
|
||||
if (!isset($postData['seq']) || !$postData['seq']){
|
||||
return ['result' => false, 'msg' => 'seq는 필수값입니다.'];
|
||||
}
|
||||
if (!isset($postData['memo']) || !$postData['memo']){
|
||||
return ['result' => false, 'msg' => 'memo는 필수값입니다.'];
|
||||
}
|
||||
|
||||
return ['result' => true];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
<?php
|
||||
include __DIR__ . "/zenith_interlock.php";
|
||||
|
||||
class CheckProc
|
||||
{
|
||||
private $db, $rwdb;
|
||||
private $no, $app_name, $event_seq, $post, $landing, $remote_addr, $is_our, $encryption;
|
||||
|
||||
public function __construct($event_seq, $post, $landing, $remote_addr, $is_our)
|
||||
{
|
||||
$this->no = $event_seq;
|
||||
$this->event_seq = $event_seq;
|
||||
$this->app_name = 'evt_'.$event_seq;
|
||||
$this->post = $post;
|
||||
$this->landing = $landing;
|
||||
$this->remote_addr = $remote_addr;
|
||||
$this->is_our = $is_our;
|
||||
$this->encryption = new ZenithEncryption();
|
||||
|
||||
$this->db = new ZenithDB();
|
||||
$this->rwdb = $this->db->getRWConnection();
|
||||
}
|
||||
|
||||
public function check_proc()
|
||||
{
|
||||
$return = $this->validator();
|
||||
|
||||
if ($return['result']) {
|
||||
foreach ($this->post as $k => $v){
|
||||
if (is_array($v)){
|
||||
$this->post[$k] = implode(',', $v);
|
||||
}
|
||||
}
|
||||
$age = isset($_POST['age']) ? intval($_POST['age']) : 0;
|
||||
//Injection 방지 및 따옴표 오류 방지를 위해 escape 처리
|
||||
$data = [
|
||||
'event_seq' => $this->event_seq,
|
||||
'site' => $this->rwdb->real_escape_string(trim($this->post['site'] ?? '')),
|
||||
'name' => $this->rwdb->real_escape_string(trim($this->post['name'] ?? '')),
|
||||
'phone' => $this->rwdb->real_escape_string(preg_replace("/[^0-9]/", "", $this->post["phone"] ?? '')),
|
||||
'gender' => $this->rwdb->real_escape_string(trim($this->post['gender'] ?? '')),
|
||||
'age' => $this->rwdb->real_escape_string(trim($age)),
|
||||
'branch' => $this->rwdb->real_escape_string(trim($this->post['branch'] ?? '')),
|
||||
'addr' => $this->rwdb->real_escape_string(trim($this->post['addr'] ?? '')),
|
||||
'email' => $this->rwdb->real_escape_string(trim($this->post['email'] ?? '')),
|
||||
'add1' => $this->rwdb->real_escape_string(trim($this->post['add1'] ?? '')),
|
||||
'add2' => $this->rwdb->real_escape_string(trim($this->post['add2'] ?? '')),
|
||||
'add3' => $this->rwdb->real_escape_string(trim($this->post['add3'] ?? '')),
|
||||
'add4' => $this->rwdb->real_escape_string(trim($this->post['add4'] ?? '')),
|
||||
'add5' => $this->rwdb->real_escape_string(trim($this->post['add5'] ?? '')),
|
||||
'add6' => $this->rwdb->real_escape_string(trim($this->post['add6'] ?? '')),
|
||||
'memo' => $this->rwdb->real_escape_string(trim($this->post['memo'] ?? '')),
|
||||
'memo3' => $this->rwdb->real_escape_string(trim($this->post['memo3'] ?? '')),
|
||||
'file_url' => $this->rwdb->real_escape_string(trim($this->post['file_url'] ?? '')),
|
||||
'reg_date' => $this->rwdb->real_escape_string(trim($this->post['reg_date'] ?? date('Y-m-d H:i:s'))),
|
||||
];
|
||||
|
||||
$agBox = $this->rwdb->real_escape_string(trim($this->post['agBox'] ?? ''));
|
||||
|
||||
if ($this->landing['custom']) {
|
||||
$json = json_decode(str_replace('\\', '', $this->landing['custom']), true);
|
||||
foreach ($json as $item) {
|
||||
// if(!$data[$json[$idx]['key']]) $data[$json[$idx]['key']] = $json[$idx]['val'];
|
||||
if ($item['val'] && $item['val'] != "") {
|
||||
$data[$item['key']] = $item['val'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['agree'] = $agBox ? 'Y' : 'N'; //agBox 값이 있으면 동의 체크된 값이므로 value에 상관없이 Y로 보정
|
||||
|
||||
$result = $this->db->getBlackListByPhone($data['phone']);
|
||||
if ($result->db->num_rows) { //연락처가 블랙리스트에 있을 경우 저장하지않고 thanks로 바로 넘김
|
||||
$return = ['result' => false, 'data' => 'thanks'];
|
||||
return $return;
|
||||
}
|
||||
if ($data['name'] && ($data['phone'] || $data['email'])) { //이름과 전화번호는 필수
|
||||
$result = $this->db->insertEventLead($this->event_seq, $data, $this->remote_addr);
|
||||
if ($result->insert_id) { //저장 완료 시
|
||||
foreach (['memo', 'memo3'] as $field) {
|
||||
if (!empty($data[$field])) {
|
||||
$memoData = [
|
||||
'seq' => $result->insert_id,
|
||||
'event_seq' => $this->event_seq,
|
||||
'memo' => $data[$field]
|
||||
];
|
||||
$this->db->insertToMemo($memoData);
|
||||
}
|
||||
}
|
||||
|
||||
$data['seq'] = $result->insert_id;
|
||||
$enc_param = $this->encryption->encrypt($data['seq']);
|
||||
$check = $this->checkEventLeads($data); //인정기준 처리
|
||||
$status = $check['status'];
|
||||
$done_cookie = $this->encryption->encrypt("{$this->remote_addr}_".time());
|
||||
ZenithCookie::set_cookie("Thanks_{$this->event_seq}", $done_cookie, 86400*$this->landing['duplicate_term']); //저장완료 시 고유 쿠키 생성
|
||||
$thanks_cookie = ZenithCookie::get_cookie("Thanks_{$this->event_seq}");
|
||||
if($this->landing['check_cookie'] && $thanks_cookie) { //제니스에서는 상태값 변경 메모가 저장되기 때문에 쿠키 중복을 확인할 수 있어서, return을 하지 않고 다음 체크로 넘김
|
||||
$ck = $this->encryption->decrypt($thanks_cookie);
|
||||
$ck = explode('_', $ck);
|
||||
$status = 13;
|
||||
$msg = "쿠키 중복-{$ck[0]}";
|
||||
$returnData = ['status' => $status, 'status_memo' => $msg];
|
||||
$this->db->updateStatusToEventLeads($returnData, $data);
|
||||
}
|
||||
|
||||
//AppSubscribe 처리 시작
|
||||
if(isset($this->post['local']) && $this->post['local']) $data['add9'] = $this->post['local'];
|
||||
$data['zenith_lead_seq'] = $data['seq'];
|
||||
$data['group_id'] = 'evt_'.$this->event_seq;
|
||||
$data['add7'] = $this->rwdb->real_escape_string(trim($this->post['add7'] ?? ''));
|
||||
$data['add8'] = $this->rwdb->real_escape_string(trim($this->post['add8'] ?? ''));
|
||||
$data['add9'] = $this->rwdb->real_escape_string(trim($this->post['add9'] ?? ''));
|
||||
$this->db->insertAppSubscribe($data, $this->remote_addr);
|
||||
//AppSubscribe 처리 끝
|
||||
|
||||
$interlock_result = [];
|
||||
if ($this->landing['interlock']) { //외부연동이 true 일 경우
|
||||
sleep(1);
|
||||
$seq = $data['seq'];
|
||||
$interlock_file = "./data/{$this->landing['name']}/interlock.php";
|
||||
if (file_exists($interlock_file)){ //외부연동 파일이 있으면 진행
|
||||
include $interlock_file;
|
||||
}
|
||||
}
|
||||
|
||||
$proc_file = "./data/{$this->landing['name']}/v_{$this->event_seq}_proc.php";
|
||||
if (file_exists($proc_file)){
|
||||
include $proc_file;
|
||||
}
|
||||
|
||||
if(count($interlock_result)){ //proc 에서도 interlock 이 일어나는 경우가 있어서 직전에 정리
|
||||
$data = array_merge($data, ['interlock_result' => $interlock_result]);
|
||||
|
||||
$interlockOj = new ZenithInterlock();
|
||||
$interlockOj->eventLeadsInterlock($data);
|
||||
}
|
||||
|
||||
$return = ['result' => true, 'data' => $enc_param];
|
||||
} else {
|
||||
$return = ['result' => false, 'msg' => "데이터 저장에 문제가 발생하였습니다.<br><br>문제가 계속 될 경우 jaybe@carelabs.co.kr 로 문의주세요."];
|
||||
}
|
||||
} else {
|
||||
if (preg_match('/instagram/i', $_SERVER['HTTP_USER_AGENT'])) {
|
||||
$return = ['result' => false, 'msg' => "개인정보 암호화 성공!\n\n다시 한 번 신청 버튼을 눌러주세요."];
|
||||
} else {
|
||||
$return = ['result' => false, 'msg' => "필수값이 누락되어 데이터를 저장할 수 없습니다."];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function validator()
|
||||
{
|
||||
$age = $this->post['age'] ?? null;
|
||||
$checkAgeMin = $this->landing['check_age_min'];
|
||||
$checkAgeMax = $this->landing['check_age_max'];
|
||||
|
||||
if ($age !== null && $checkAgeMin && $checkAgeMax) {
|
||||
if ($age < $checkAgeMin) {
|
||||
return ['result' => false, 'msg' => "이 이벤트는 {$checkAgeMin}세 이상만 신청 가능합니다."];
|
||||
} elseif ($age > $checkAgeMax) {
|
||||
return ['result' => false, 'msg' => "이 이벤트는 {$checkAgeMax}세 이하로 신청 가능합니다."];
|
||||
}
|
||||
}
|
||||
|
||||
/* var align */
|
||||
$name = $this->post['name'];
|
||||
$phone = $this->post['phone'];
|
||||
$encPhone = $this->encryption->encrypt($phone, false);
|
||||
$advertiserNo = $this->landing['advertiser'] ?? '';
|
||||
$mediaNo = $this->landing['med_seq'] ?? '';
|
||||
$ip = $this->remote_addr;
|
||||
|
||||
$duplicatePrecheck = $this->landing['duplicate_precheck'];
|
||||
$sql = "";
|
||||
|
||||
switch ($duplicatePrecheck) {
|
||||
case '0':/** 사전 중복 체크 **/
|
||||
return ['result' => true];
|
||||
case '1':
|
||||
// 해당 랜딩 - 이름&연락처 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND name = '$name' AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq = '{$this->event_seq}'";
|
||||
break;
|
||||
case '2':
|
||||
// 해당 광고주 - 이름&연락처 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND name = '$name' AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq IN (SELECT seq FROM event_information WHERE advertiser = '$advertiserNo' )";
|
||||
break;
|
||||
case '3':
|
||||
// 해당 광고주&매체 - 이름&연락처 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND name = '$name' AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq IN (SELECT seq FROM event_information WHERE advertiser = '$advertiserNo' AND media = '$mediaNo' )";
|
||||
break;
|
||||
case '7':
|
||||
// 해당 랜딩 - 연락처 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq = '{$this->event_seq}'";
|
||||
break;
|
||||
case '8':
|
||||
// 해당 광고주 - 연락처 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq IN (SELECT seq FROM event_information WHERE advertiser = '$advertiserNo' )";
|
||||
break;
|
||||
case '9':
|
||||
// 해당 광고주&매체 - 연락처 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq IN (SELECT seq FROM event_information WHERE advertiser = '$advertiserNo' AND media = '$mediaNo' )";
|
||||
break;
|
||||
default:
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND name = '$name' AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq = '{$this->event_seq}'";
|
||||
}
|
||||
|
||||
if (!$this->is_our && ($duplicatePrecheck == '4' || $duplicatePrecheck == '5' || $duplicatePrecheck == '6')) {
|
||||
switch ($duplicatePrecheck) {
|
||||
case '4':
|
||||
// 해당 랜딩 - IP 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND ip = '$ip'";
|
||||
$sql .= "AND event_seq = '{$this->event_seq}'";
|
||||
break;
|
||||
case '5':
|
||||
// 해당 광고주 - IP 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND ip = '$ip'";
|
||||
$sql .= "AND event_seq IN (SELECT seq FROM event_information WHERE advertiser = '$advertiserNo' )";
|
||||
break;
|
||||
case '6':
|
||||
// 해당 광고주&매체 - IP 중복
|
||||
$sql = "SELECT seq FROM event_leads WHERE is_deleted=0 AND ip = '$ip' AND (phone = '$phone' OR phone = '$encPhone') ";
|
||||
$sql .= "AND event_seq IN (SELECT seq FROM event_information WHERE advertiser = '$advertiserNo' AND media = '$mediaNo' )";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result->db->num_rows) {
|
||||
return ['result' => false, 'msg' => "이미 참가하셨습니다!"];
|
||||
}
|
||||
|
||||
return ['result' => true];
|
||||
}
|
||||
|
||||
//불량DB 처리
|
||||
public function checkEventLeads($data) {
|
||||
$status = 1;
|
||||
$msg = '';
|
||||
if ($data['gender'] && $this->landing['check_gender']) { //성별 체크
|
||||
if ($this->landing['check_gender'] == 'm' && !preg_match('/(남|m)/i', $data['gender'])) {
|
||||
$status = 3;
|
||||
$msg = '남자체크';
|
||||
} elseif ($this->landing['check_gender'] == 'f' && !preg_match('/(여|f)/i', $data['gender'])) {
|
||||
$status = 3;
|
||||
$msg = '여자체크';
|
||||
}
|
||||
if ($status != 1) {
|
||||
$return = ['status' => $status, 'status_memo' => $msg];
|
||||
$this->db->updateStatusToEventLeads($return, $data);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
if ($data['age']) {
|
||||
if ($this->landing['check_age_min'] && $data['age'] < $this->landing['check_age_min']) {
|
||||
$return = ['status' => 4, 'status_memo' => '나이조건 이하'];
|
||||
$this->db->updateStatusToEventLeads($return, $data);
|
||||
return $return;
|
||||
}
|
||||
|
||||
if ($this->landing['check_age_max'] && $data['age'] > $this->landing['check_age_max']) {
|
||||
$return = ['status' => 4, 'status_memo' => '나이조건 이상'];
|
||||
$this->db->updateStatusToEventLeads($return, $data);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['phone'] && $this->landing['check_phone']) { //전화번호 불량,중복 체크
|
||||
$number = substr($data['phone'], 3, 8);
|
||||
if (!preg_match('/^[\d]{11}$/', $data['phone'])) {
|
||||
$status = 6;
|
||||
$msg = '전화번호 길이 불량';
|
||||
} else if (in_array($number, ['00000000', '11111111', '22222222', '33333333', '44444444', '55555555', '66666666', '77777777', '88888888', '99999999'])) {
|
||||
$status = 6;
|
||||
$msg = '8자리 같은번호';
|
||||
}
|
||||
$phone = $this->encryption->encrypt($data['phone'], false);
|
||||
$sql = "SELECT seq FROM `zenith`.`event_leads` WHERE `event_seq` = '{$data['event_seq']}' AND `phone` = '{$phone}' AND `seq` <> '{$data['seq']}' AND `is_deleted` = 0 AND `status` <> 0";
|
||||
if ($this->landing['duplicate_term']) {
|
||||
$sql .= " AND `reg_date` >= DATE_SUB(NOW(), INTERVAL {$this->landing['duplicate_term']} DAY)";
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
if ($result->db->num_rows) {
|
||||
$status = 2;
|
||||
$msg = '전화번호 중복';
|
||||
}
|
||||
|
||||
if ($status != 1) {
|
||||
$return = ['status' => $status, 'status_memo' => $msg];
|
||||
$this->db->updateStatusToEventLeads($return, $data);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['name']) { //이름 불량,중복 체크
|
||||
if ($this->landing['check_name']) {
|
||||
$sql = "SELECT seq FROM `zenith`.`event_leads` WHERE `event_seq` = '{$data['event_seq']}' AND `name` = '{$data['name']}' AND `seq` <> '{$data['seq']}' AND `is_deleted` = 0 AND `status` <> 0
|
||||
";
|
||||
if ($this->landing['duplicate_term']) {
|
||||
$sql .= " AND `reg_date` >= DATE_SUB(NOW(), INTERVAL {$this->landing['duplicate_term']} DAY)";
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
if ($result->db->num_rows) {
|
||||
$status = 2;
|
||||
$msg = '이름 중복';
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/(테스트|테스트|test)/i', $data['name'])) { //테스트 체크
|
||||
$status = 7;
|
||||
$msg = '테스트';
|
||||
}
|
||||
|
||||
if ($status != 1) {
|
||||
$return = ['status' => $status, 'status_memo' => $msg];
|
||||
$this->db->updateStatusToEventLeads($return, $data);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
$return = ['status' => $status, 'status_memo' => $msg];
|
||||
$this->db->updateStatusToEventLeads($return, $data);
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class ZenithCookie
|
||||
{
|
||||
//쿠키변수 설정
|
||||
public static function set_cookie($cookie_name, $value, $expire)
|
||||
{
|
||||
if(is_null($value)) return;
|
||||
setcookie(md5($cookie_name), base64_encode($value), time() + $expire, '/', '.event.hotblood.co.kr');
|
||||
}
|
||||
|
||||
// 쿠키변수값 얻음
|
||||
public static function get_cookie($cookie_name)
|
||||
{
|
||||
$cookie = md5($cookie_name);
|
||||
if (array_key_exists($cookie, $_COOKIE))
|
||||
return base64_decode($_COOKIE[$cookie]);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,697 @@
|
||||
<?php
|
||||
/*
|
||||
* @brief hotevent 를 대체하기 위해 새롭게 개발된 신규 랜딩
|
||||
* @author Jaybe
|
||||
* @see
|
||||
* event_information - 랜딩 테이블
|
||||
* event_advertiser - 광고주 테이블
|
||||
* event_media - 매체 테이블
|
||||
* 랜딩테이블 기준으로 광고주, 매체 테이블이 인덱싱 구조로 구성되어있음
|
||||
* URL Structure : https://event.hotblood.co.kr/랜딩번호/메소드
|
||||
*/
|
||||
include __DIR__ . "/zenith_db.php";
|
||||
include __DIR__ . "/zenith_ip.php";
|
||||
include __DIR__ . "/zenith_encryption.php";
|
||||
include __DIR__ . "/zenith_cookie.php";
|
||||
include __DIR__ . "/zenith_check_proc.php";
|
||||
|
||||
class HotbloodEventZenith
|
||||
{ //Event 클래스
|
||||
private $rwdb, $rodb, $db;
|
||||
private $ip;
|
||||
private $paths, $landing;
|
||||
private $remote_addr, $visitor;
|
||||
private $our_ip = ['59.9.155.0/24', '127.0.0.1']; //사무실IP, 로컬호스트
|
||||
private $is_our = false;
|
||||
private $comments = [];
|
||||
private $counts = 0;
|
||||
private $check;
|
||||
private $encryption;
|
||||
public $no, $app_name, $method = 'view', $params;
|
||||
|
||||
public function __construct($paths = null)
|
||||
{
|
||||
if(is_null($paths)) {
|
||||
$this->db = new ZenithDB();
|
||||
$this->rwdb = $this->db->getRWConnection();
|
||||
$this->rodb = $this->db->getROConnection();
|
||||
return;
|
||||
}
|
||||
session_set_cookie_params([
|
||||
'lifetime' => 0,
|
||||
'path' => '/',
|
||||
'domain' => '.' . $_SERVER['HTTP_HOST'],
|
||||
'secure' => true,
|
||||
'httponly' => true,
|
||||
'samesite' => 'None'
|
||||
]);
|
||||
session_start();
|
||||
header('P3P: CP="NOI CURa ADMa DEVa TAIa OUR DELa BUS IND PHY ONL UNI COM NAV INT DEM PRE"');
|
||||
header('P3P: CP="ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC"');
|
||||
header('P3P: CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"');
|
||||
header('P3P: CP="CAO PSA OUR"');
|
||||
set_exception_handler(array($this, 'exception_handler'));
|
||||
if (__DEV__) { //개발모드 일 경우 error_reporting 작동
|
||||
error_reporting(E_ALL);// & ~E_NOTICE
|
||||
define("EVENT_URL", "");
|
||||
} else {
|
||||
error_reporting(0);
|
||||
define("EVENT_URL", "//event.hotblood.co.kr");
|
||||
}
|
||||
ini_set('display_errors', 'On');
|
||||
if (!preg_match('/^(local\.)?event\.hotblood\.co\.kr/', $_SERVER['HTTP_HOST'])) {
|
||||
define("ROOT_PATH", ".");
|
||||
} else {
|
||||
define("ROOT_PATH", "..");
|
||||
}
|
||||
|
||||
$this->paths = $paths;
|
||||
$this->no = $paths[1] ?? ''; //랜딩번호
|
||||
|
||||
if (isset($paths[2])){
|
||||
$this->method = $paths[2]; //method 저장
|
||||
}
|
||||
|
||||
if(isset($paths[1])){
|
||||
if (!preg_match('/[0-9]+/', $paths[1])){
|
||||
$this->method = $paths[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->no){ //랜딩번호가 없으면 exception 처리
|
||||
throw new Exception("잘못된 접근입니다.");
|
||||
}
|
||||
|
||||
//DB연결
|
||||
$this->db = new ZenithDB();
|
||||
$this->rwdb = $this->db->getRWConnection();
|
||||
$this->rodb = $this->db->getROConnection();
|
||||
|
||||
$this->ip = new ZenithIP();
|
||||
$this->remote_addr = $this->ip->getRemoteAddr(); //REMOTE_ADDR 세팅
|
||||
|
||||
if (!isset($_SESSION['browser'])){ //Browser 정보 세션으로 저장
|
||||
$_SESSION['browser'] = get_browser();
|
||||
}
|
||||
|
||||
if (preg_match('/[0-9]+/', $this->no)) {
|
||||
$result = $this->db->getLandingBySeq($this->no); //랜딩 정보 호출
|
||||
if (!$result->db->num_rows) {
|
||||
throw new Exception("존재하지 않는 랜딩입니다."); //랜딩번호가 존재하지 않을경우 Exception 처리
|
||||
}
|
||||
$this->landing = $result->db->fetch_assoc();
|
||||
$_SESSION['no'] = $this->no;
|
||||
if (isset($_GET['site'])) $_SESSION['site'] = $_GET['site'];
|
||||
if (isset($_GET['code'])) $_SESSION['code'] = $_GET['code'];
|
||||
}
|
||||
|
||||
//메가더포르테 도메인 전용
|
||||
if (preg_match('/^megatheforte\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '메가더포르테') {
|
||||
throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
}
|
||||
|
||||
//미담치과의원 도메인 전용
|
||||
//개발요청번호:22481 / 20220824 김하정 요청
|
||||
// if (preg_match('/^careevt\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '미담치과의원') {
|
||||
// throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
// }
|
||||
|
||||
//스탠다드치과의원 도메인 전용
|
||||
if (preg_match('/^heybt\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '스탠다드치과의원') {
|
||||
throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
}
|
||||
|
||||
//서울권치과의원 도메인 전용
|
||||
if (preg_match('/^cutbut\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '서울권치과의원') {
|
||||
throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
}
|
||||
|
||||
//그라클레스 도메인 전용
|
||||
if (preg_match('/^gragracules\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '그라클레스') {
|
||||
throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
}
|
||||
if (preg_match('/^smrstoremall\.shop/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '그라클레스') {
|
||||
throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
}
|
||||
if (preg_match('/^smrstoremall\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '그라클레스') {
|
||||
throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
}
|
||||
|
||||
//닥터크리미의원 도메인 전용 - 찬영님 요청 > 220705/하정님 요청으로 해제
|
||||
// if (preg_match('/^vviibbee\.co\.kr/', $_SERVER['HTTP_HOST']) && $this->landing['name'] != '닥터크리미의원') {
|
||||
// throw new Exception("존재하지 않는 이벤트입니다.");
|
||||
// }
|
||||
|
||||
$this->is_our = $this->ip->chk_ip($this->remote_addr, $this->our_ip); //내부 사용자인지 체크
|
||||
$this->landing['is_our'] = $this->is_our;
|
||||
|
||||
$this->visitor = ZenithCookie::get_cookie(md5('chainsaw'));
|
||||
$this->encryption = new ZenithEncryption();
|
||||
if (!$this->visitor) {
|
||||
$this->visitor = $this->encryption->encrypt($this->remote_addr . '/' . microtime(true) . '/' . $this->no); //사용자 고유코드 생성
|
||||
ZenithCookie::set_cookie(md5('chainsaw'), $this->visitor, 2592000); //30일 Cookie Set
|
||||
}
|
||||
|
||||
if (isset($this->landing['lead']) && $this->landing['lead'] != 3){
|
||||
//외부연동일 때 외부에서 대량으로 POST를 보내야할 수도 있어서 IP Blocker를 실행하지 않음
|
||||
$this->ip->ipBlocker($this->remote_addr, $this->our_ip);
|
||||
}
|
||||
}
|
||||
|
||||
//잘못된 메소드 호출은 예외처리
|
||||
public function __call($method, $params)
|
||||
{
|
||||
throw new Exception("잘못된 호출입니다.");
|
||||
}
|
||||
|
||||
public function copy()
|
||||
{
|
||||
$old_seq = $this->paths[2] ?? '';
|
||||
$new_seq = $this->paths[3] ?? '';
|
||||
$res = $this->rwdb->query("SELECT MAX(seq) AS seq FROM event_advertiser LIMIT 1");
|
||||
$row = $res->fetch_assoc();
|
||||
if ($row['seq'] != $new_seq) {
|
||||
exit('The event does not exist in database.');
|
||||
}
|
||||
if ($old_seq && $new_seq) {
|
||||
$res = $this->db->getAdvertiserBySeq($old_seq);
|
||||
$row = $res->db->fetch_assoc();
|
||||
copy(__DIR__ . "/data/{$row['name']}/v_{$old_seq}.php", __DIR__ . "/data/{$row['name']}/v_{$new_seq}.php");
|
||||
}
|
||||
}
|
||||
|
||||
//랜딩 페이지 호출
|
||||
public function view()
|
||||
{
|
||||
ob_start();
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET');
|
||||
ob_end_flush();
|
||||
$appendHtml = [];
|
||||
$_GET['site'] = $_GET['site'] ?? '';
|
||||
$_GET['event_id'] = $_GET['event_id'] ?? '';
|
||||
$_GET['funnel'] = $_GET['funnel'] ?? '';
|
||||
if ($this->landing['is_stop'] || $this->landing['adv_stop']) {
|
||||
$txt = '';
|
||||
if ($this->landing['is_stop']){
|
||||
$txt = '차단 중인 이벤트입니다.';
|
||||
}
|
||||
if ($this->landing['adv_stop']){
|
||||
$txt = '사용 중지된 광고주입니다.';
|
||||
}
|
||||
if ($this->is_our){
|
||||
$appendHtml['header'] = '<div class="block_msg animate__animated animate__flash animate__slow animate__repeat-2 animate__delay-1s" onclick="$(this).addClass(\'hide\');">' . $txt . '</div>';
|
||||
}else{
|
||||
throw new Exception("사용할 수 없는 이벤트입니다."); //사용중지 상태일 경우 exception 처리
|
||||
}
|
||||
}
|
||||
|
||||
$file = "./data/{$this->landing['name']}/v_{$this->no}.php";
|
||||
if (!file_exists($file)){
|
||||
throw new Exception("이벤트 파일이 존재하지 않습니다."); //랜딩파일이 없을 경우 exception 처리
|
||||
}
|
||||
if (isset($_SESSION['media'])){
|
||||
$this->landing['media'] = $_SESSION['media'];
|
||||
}
|
||||
unset($_SESSION['params']);
|
||||
if(count($_GET) > 0){
|
||||
//랜딩 접근시 parameter가 있을 시 추후 활용을 위해 세션에 저장
|
||||
$nonEmptyParams = [];
|
||||
foreach ($_GET as $key => $value) {
|
||||
if ($value !== '') {
|
||||
$nonEmptyParams[$key] = $value;
|
||||
}
|
||||
}
|
||||
if (!empty($nonEmptyParams)) {
|
||||
$_SESSION['params'] = $nonEmptyParams;
|
||||
}
|
||||
}
|
||||
// event_leads 기반 댓글
|
||||
$result = $this->db->getEventLeadByEventSeq($this->no);
|
||||
if ($result->db->num_rows) {
|
||||
while ($row = $result->db->fetch_assoc()) {
|
||||
$row['name'] = mb_substr($row['name'], 0, 1, "UTF-8") . "**";
|
||||
$row['reg_date'] = date('m-d H:i', strtotime($row['reg_date']));
|
||||
//$row['phone'] = $this->encryption->decrypt($row['phone']);
|
||||
|
||||
$row['phone'] = '010-****-**' . substr($row['phone'], -2); //이름 마스크 처리
|
||||
|
||||
$this->comments[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
// event_leads 기반 db 갯수
|
||||
$result = $this->db->getEventLeadCountByEventSeq($this->no);
|
||||
if ($result->db->num_rows) {
|
||||
while ($row = $result->db->fetch_assoc()) {
|
||||
$this->counts = $row['count'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->makePage($file, NULL, $appendHtml);
|
||||
$_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
|
||||
if ($this->landing['pixel_id']) {
|
||||
$this->FBPixel();
|
||||
}
|
||||
}
|
||||
|
||||
public function act()
|
||||
{
|
||||
$file = "./data/{$this->landing['name']}/v_{$this->no}_act.php";
|
||||
if (!file_exists($file)){
|
||||
die(json_encode(['result' => false, 'msg' => '파일이 존재하지 않습니다.']));
|
||||
}
|
||||
|
||||
include $file;
|
||||
}
|
||||
|
||||
private function FBPixel($event = 'ViewContent', $param = null)
|
||||
{
|
||||
if (!$this->landing['pixel_id'] || !$this->landing['access_token']){
|
||||
return false;
|
||||
}
|
||||
$url = "https://graph.facebook.com/v10.0/{$this->landing['pixel_id']}/events?access_token={$this->landing['access_token']}";
|
||||
$data = [
|
||||
'event_name' => $event,
|
||||
'event_id' => time() . $this->visitor,
|
||||
'event_time' => time(),
|
||||
'event_source_url' => "{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['HTTP_HOST']}" . urlencode($_SERVER['REQUEST_URI']),
|
||||
'action_source' => "website",
|
||||
'user_data' => [
|
||||
'client_ip_address' => $this->remote_addr,
|
||||
'client_user_agent' => $_SERVER['HTTP_USER_AGENT']
|
||||
]
|
||||
];
|
||||
if ($event == 'CompleteRegistration' && isset($param)) {
|
||||
$data['user_data']['fn'] = hash("sha256", $param['name']);
|
||||
$data['user_data']['ph'] = hash("sha256", $param['phone']);
|
||||
$data['custom_data']['currency'] = "KRW";
|
||||
}
|
||||
|
||||
$data = "data=[" . json_encode($data) . "]";
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
$result = curl_exec($ch);
|
||||
$info = curl_getinfo($ch);
|
||||
$result = json_decode($result, true);
|
||||
// echo json_encode($data);
|
||||
// echo '<pre>'.print_r($headers,1).'</pre>';
|
||||
// echo '<pre>'.print_r($data,1).'</pre>';
|
||||
// echo '<pre>'.print_r($info,1).'</pre>';
|
||||
// echo '<pre>'.print_r($result,1).'</pre>';
|
||||
curl_close($ch);
|
||||
if (isset($result['events_received'])) {
|
||||
echo "<!-- {$this->landing['pixel_name']}({$this->landing['pixel_id']}) / {$event} -->";
|
||||
return true;
|
||||
} else
|
||||
echo "<!-- ".json_encode($result)." -->";
|
||||
return false;
|
||||
}
|
||||
|
||||
public function send()
|
||||
{
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Headers: *");
|
||||
$this->writeLog();
|
||||
$_POST = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if(isset($_POST['no'])){ //no 변수값이 넘어오면 랜딩번호를 교체
|
||||
if(preg_match('/[0-9]+/', $_POST['no'])){
|
||||
$result = $this->db->getLandingBySeq($_POST['no']);
|
||||
if (!$result->db->num_rows) {
|
||||
throw new Exception("존재하지 않는 랜딩입니다."); //랜딩번호가 존재하지 않을경우 Exception 처리
|
||||
}
|
||||
$this->landing = $result->db->fetch_assoc();
|
||||
}
|
||||
}
|
||||
if (!isset($_POST['partner_name']) || !$_POST['partner_name']){
|
||||
exit(json_encode(['result' => false, 'msg' => '전송 업체명은 필수값입니다.'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if (!$this->landing['seq']){
|
||||
exit(json_encode(['result' => false, 'msg' => '존재하지 않는 이벤트입니다.'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($this->landing['lead'] != 3){
|
||||
exit(json_encode(['result' => false, 'msg' => '외부에서 전송 할 수 없는 이벤트입니다.'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($this->landing['is_stop']){
|
||||
exit(json_encode(['result' => false, 'msg' => '사용할 수 없는 이벤트입니다.'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if ($this->landing['adv_stop']){
|
||||
exit(json_encode(['result' => false, 'msg' => '사용할 수 없는 이벤트입니다.'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if (!is_array($_POST)){
|
||||
exit(json_encode(['result' => false, 'msg' => 'JSON 형태로 전송해주십시오. ex) {"name":"홍길동","phone":"01012345678"...}'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
if (!isset($_POST['remote_addr']) || !$_POST['remote_addr']){
|
||||
exit(json_encode(['result' => false, 'msg' => '사용자IP는 필수값입니다.'], JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
$this->remote_addr = $_POST['remote_addr'];
|
||||
$check = new CheckProc($this->no, $_POST, $this->landing, $this->remote_addr, $this->is_our);
|
||||
$result = $check->check_proc();
|
||||
// $result = array_merge($result, $_SERVER);
|
||||
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
//데이터 저장
|
||||
public function proc()
|
||||
{
|
||||
$is_ajax = $_POST['ajax']; //ajax 형태 인지
|
||||
$check = new CheckProc($this->no, $_POST, $this->landing, $this->remote_addr, $this->is_our);
|
||||
$result = $check->check_proc();
|
||||
|
||||
if ($is_ajax) {
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
} else {
|
||||
if ($result['result'] === true) {
|
||||
session_write_close();
|
||||
header("Location: " . ROOT_PATH . "/{$this->no}/thanks/{$result['data']}");
|
||||
exit; //저장이 정상적으로 처리 됐을 경우 result 페이지로 이동
|
||||
} else {
|
||||
if ($result['data'] == 'thanks') {
|
||||
session_write_close();
|
||||
header("Location: " . ROOT_PATH . "/{$this->no}/thanks");
|
||||
exit;
|
||||
} else if ($result['msg']) {
|
||||
$this->alert($result['msg']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ajax 처리용
|
||||
public function ajaxProc()
|
||||
{
|
||||
$mode = $_POST['mode'] ?? '';
|
||||
if ($mode == "getComment") { //코멘트 가져오기
|
||||
$limit = $_POST['limit'] ? $_POST['limit'] : 10;
|
||||
$query = "";
|
||||
$data = ['result' => false, 'more' => false, 'data' => null];
|
||||
if ($_POST['lastmsg']) {
|
||||
$lastmsg = $_POST['lastmsg'];
|
||||
$query = " AND seq < '$lastmsg'";
|
||||
}
|
||||
|
||||
$sql = "SELECT seq, name, phone, age, add1, reg_date FROM event_leads WHERE event_seq = '{$this->no}' AND is_deleted = 0";
|
||||
$cnt_sql = $this->db->query($sql);
|
||||
$total = $cnt_sql->db->num_rows;
|
||||
|
||||
$sql .= "{$query} ORDER BY seq DESC LIMIT $limit"; //seq 작은 값 20개 출력
|
||||
$result = $this->db->query($sql);
|
||||
if ($result->db->num_rows) {
|
||||
$data['result'] = true;
|
||||
while ($row = $result->db->fetch_assoc()) {
|
||||
$row['phone'] = $this->encryption->decrypt($row['phone']);
|
||||
$row['seq'] = $row['seq'];
|
||||
$row['name'] = mb_substr($row['name'], '0', 1) . "**"; //이름 마스크 처리
|
||||
$row['phone'] = '010-****-**' . substr($row['phone'], -2); //전화번호 마스크 처리
|
||||
$row['age'] = substr($row['age'], 0, 1) . '0대'; //전화번호 마스크 처리
|
||||
$row['reg_date'] = date('m-d H:i', strtotime($row['reg_date']));
|
||||
$row['msg'] = '신청했습니다~!';
|
||||
$data['data'][] = $row;
|
||||
}
|
||||
if ($result->db->num_rows == $limit){
|
||||
$data['more'] = true;
|
||||
}
|
||||
}
|
||||
echo json_encode($data);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//완료페이지
|
||||
public function thanks()
|
||||
{
|
||||
$seq = $this->encryption->decrypt($this->paths[3]);
|
||||
$result = $this->db->getEventLeadBySeq($seq);
|
||||
$user = [];
|
||||
if ($result->db->num_rows) {
|
||||
$user = $result->db->fetch_assoc();
|
||||
$user['dec_phone'] = $this->encryption->decrypt($user['phone']);
|
||||
$user['international_phone'] = str_replace('010', '+8210', $user['dec_phone']);
|
||||
}
|
||||
|
||||
$file = "./data/{$this->landing['name']}/v_{$this->no}_thanks.php";
|
||||
if (!file_exists($file)){
|
||||
$file = "./inc/thanks.php";
|
||||
}
|
||||
|
||||
$this->makePage($file, $user);
|
||||
if ($this->landing['pixel_id']) {
|
||||
$this->FBPixel('CompleteRegistration', $user);
|
||||
}
|
||||
}
|
||||
|
||||
public function result()
|
||||
{
|
||||
$path = '../' . $this->no;
|
||||
if ($_SESSION['params']) { //세션에 저장 된 parameter URL에 세팅
|
||||
$params = http_build_query($_SESSION['params']);
|
||||
$path .= '?' . $params;
|
||||
}
|
||||
|
||||
session_write_close();
|
||||
header("Location: {$path}");
|
||||
exit; //view 페이지를 방문한 적이 없다면 돌려보냄
|
||||
}
|
||||
|
||||
//HTML 출력
|
||||
private function html($page)
|
||||
{
|
||||
if (is_array($page)) { //page 변수가 배열일 경우
|
||||
echo $page['header'];
|
||||
echo $page['content'];
|
||||
echo $page['footer'];
|
||||
} else { //page변수가 페이지 전체일 경우
|
||||
echo $page;
|
||||
}
|
||||
}
|
||||
|
||||
//Page 생성
|
||||
private function makePage($file, $data = "", $appendHtml = [])
|
||||
{
|
||||
$GLOBALS['data'] = $data;
|
||||
$header = $this->setHeader($appendHtml['header'] ?? '');
|
||||
$content = $this->setContent($file, $data);
|
||||
$header = preg_replace_callback('/\{\{([^\}]+)\}\}/m', function ($matches) {
|
||||
return $GLOBALS["data"][$matches[1]];
|
||||
}, $header);
|
||||
$content = preg_replace_callback('/\{\{([^\}]+)\}\}/m', function ($matches) {
|
||||
return $GLOBALS["data"][$matches[1]];
|
||||
}, $content);
|
||||
$page = $this->addStyle($header, $content);
|
||||
$page['footer'] = $this->getFooter(); //Footer를 buffer로 저장
|
||||
$this->html($page); //html 출력
|
||||
}
|
||||
|
||||
//Header 호출
|
||||
private function getHeader()
|
||||
{
|
||||
ob_start();
|
||||
include "./inc/head.php";
|
||||
$header = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return $header;
|
||||
}
|
||||
|
||||
//Footer 호출
|
||||
private function getFooter()
|
||||
{
|
||||
ob_start();
|
||||
include "./inc/tail.php";
|
||||
$footer = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
return $footer;
|
||||
}
|
||||
|
||||
private function setContent($file, $data = [])
|
||||
{
|
||||
if (!file_exists($file)){
|
||||
return NULL;
|
||||
}
|
||||
ob_start();
|
||||
include $file;
|
||||
$content = ob_get_contents(); //Contents를 buffer로 저장
|
||||
ob_end_clean();
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
//Header에 스타일시트 추가
|
||||
private function addStyle($header, $content)
|
||||
{
|
||||
$content = $this->splitStyle($content);
|
||||
$page['header'] = preg_replace('#(</head>[^<]*<body[^>]*>)#', "{$content['style']}\n$1", $header); //Header에 스타일시트 추가
|
||||
$page['content'] = preg_replace('#(<style[^>]*>[^<]*<\/style>)#m', "", $content['content']); //스타일시트를 제외한 컨텐츠 재정의
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
//Header 제작
|
||||
private function setHeader($add_header = "")
|
||||
{
|
||||
$title = $this->landing['title'] ?: $this->landing['name']; //타이틀 없을 경우 광고주명으로 대체
|
||||
$header = $this->getHeader(); //Header를 buffer로 저장
|
||||
$script = "";
|
||||
switch ($this->method) {
|
||||
case 'view':
|
||||
$script = stripslashes($this->landing['view_script']);
|
||||
break;
|
||||
case 'thanks':
|
||||
$script = stripslashes($this->landing['done_script']);
|
||||
break;
|
||||
case 'result':
|
||||
$title = "이벤트";
|
||||
break;
|
||||
}
|
||||
$header = preg_replace('#(<title>)([^<]*)(<\/title>)#', "$1 {$title}$3", $header); //저장된 buffer에 title 추가
|
||||
$header = preg_replace('#(</head>[^<]*<body[^>]*>)#', "{$script}\n$1", $header); //저장된 buffer에 header 스크립트 추가
|
||||
if ($add_header){
|
||||
$header = preg_replace('#(</head>[^<]*<body[^>]*>)#', "$1\n{$add_header}\n", $header); //저장된 buffer에 header 스크립트 추가
|
||||
}
|
||||
|
||||
return $header;
|
||||
}
|
||||
|
||||
//스타일 분리
|
||||
private function splitStyle($content)
|
||||
{
|
||||
preg_match_all('#(<style>(.*?)</style>)?(.*)#is', $content, $matches, PREG_SET_ORDER); //content 파일내 스타일시트 분리
|
||||
$result['style'] = $matches[0][1];
|
||||
$result['content'] = $matches[0][3];
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
//event 파일 목록 가져오기
|
||||
public function getFiles()
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET');
|
||||
$files = [];
|
||||
$dirs = glob('data/*', GLOB_ONLYDIR);
|
||||
if (count($dirs) > 0) {
|
||||
foreach ($dirs as $d) {
|
||||
if ($file_list = array_map('basename', glob($d . '/v_*.php')))
|
||||
$files = array_merge($files, $file_list);
|
||||
}
|
||||
}
|
||||
echo json_encode($files);
|
||||
}
|
||||
|
||||
//파일체크
|
||||
public function filecheck()
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET');
|
||||
$seq = $this->paths[2];
|
||||
$this->no = $seq;
|
||||
$result = $this->getLandingBySeq($this->no);
|
||||
if (!$result->db->num_rows) {
|
||||
throw new Exception("존재하지 않는 랜딩입니다."); //랜딩번호가 존재하지 않을경우 Exception 처리
|
||||
}
|
||||
$this->landing = $result->db->fetch_assoc();
|
||||
$file = "./data/{$this->landing['name']}/v_{$this->no}.php";
|
||||
echo file_exists($file);
|
||||
}
|
||||
|
||||
// 신청자수 계산 함수
|
||||
public function applicant_num($input, $min = null, $max = null, $digit = 3)
|
||||
{
|
||||
$tmp = 0;
|
||||
if ($min < 0 || !$min) $min = 0;
|
||||
if ($max < 0 || !$max) $max = pow(10, $digit) - 1;
|
||||
|
||||
$rst = $min + ($input % ($max - $min));
|
||||
|
||||
return $rst;
|
||||
}
|
||||
|
||||
//예외처리
|
||||
public static function exception_handler($e)
|
||||
{
|
||||
//var_dump($e);
|
||||
$error = ['title' => "PAGE NOT FOUND", 'subtitle' => "죄송합니다. 요청하신 페이지를 찾을 수 없습니다.", 'description' => "<!--{$e->getMessage()}-->", 'error' => $e->getFile()." ".$e->getLine()];
|
||||
include "error/404/index.html";
|
||||
}
|
||||
|
||||
//경고처리
|
||||
public function alert($msg)
|
||||
{
|
||||
include "./inc/head.php";
|
||||
include "./inc/alert.php";
|
||||
include "./inc/tail.php";
|
||||
exit;
|
||||
}
|
||||
|
||||
private function writeLog()
|
||||
{
|
||||
$path = explode('?', $_SERVER['REQUEST_URI']);
|
||||
$php_self = array_shift($path);
|
||||
$DBdata = [
|
||||
'evt_seq' => $this->no, 'scheme' => $_SERVER['REQUEST_SCHEME'], 'host' => $_SERVER['HTTP_HOST'], 'php_self' => $php_self, 'query_string' => $_SERVER['QUERY_STRING'], 'data' => file_get_contents('php://input'), 'post_data' => http_build_query($_POST), 'remote_addr' => $this->remote_addr, 'server_addr' => $_SERVER['SERVER_ADDR'], 'content_type' => $_SERVER['CONTENT_TYPE'] ?? '', 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'datetime' => date('Y-m-d H:i:s')
|
||||
];
|
||||
$field = array();
|
||||
foreach ($DBdata as $k => $v) $field[] = "`$k` = '{$v}'";
|
||||
$fields = implode(', ', $field);
|
||||
$sql = " INSERT INTO event_logs SET {$fields} ";
|
||||
$this->db->query($sql, true);
|
||||
}
|
||||
|
||||
public function serverinfo()
|
||||
{
|
||||
if ($this->our_ip || $_GET['auth']) echo '<pre>' . print_r($_SERVER, 1) . '</pre>';
|
||||
}
|
||||
|
||||
//배열 그리딩
|
||||
public function grid($data, $link = null)
|
||||
{
|
||||
if (empty($data)) {
|
||||
echo '<p>null data</p>';
|
||||
return;
|
||||
}
|
||||
$table = '';
|
||||
foreach ($data as $row) {
|
||||
if (is_array($row)) {
|
||||
$table .= '<tr>';
|
||||
foreach ($row as $key => $var) {
|
||||
if ($link) {
|
||||
foreach ($link as $k => $v) {
|
||||
if ($k == $key) {
|
||||
$var = str_replace('{' . $k . '}', $var, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
$table .= '<td>' . (is_object($var) ? $var->load() : $var) . '</td>';
|
||||
}
|
||||
$table .= '</tr>';
|
||||
}
|
||||
}
|
||||
if (isset($row) && is_array($row)) {
|
||||
$thead = '<thead><tr>';
|
||||
foreach ($row as $key => $tmp) {
|
||||
$thead .= '<th>' . $key . '</th>';
|
||||
}
|
||||
$thead .= '</tr></thead>';
|
||||
} else {
|
||||
$thead = '<thead><tr>';
|
||||
$table = '<tr>';
|
||||
foreach ($data as $k => $v) {
|
||||
$thead .= '<th>' . $k . '</th>';
|
||||
$table .= '<td>' . $v . '</td>';
|
||||
}
|
||||
$thead .= '</tr></thead>';
|
||||
$table .= '</tr>';
|
||||
}
|
||||
echo '<table class="_dev_util_grid" border="1">' . $thead . $table . '</table>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
class ZenithEncryption
|
||||
{
|
||||
protected $key, $aes_key;
|
||||
public function __construct() {
|
||||
$env = parse_ini_file(__DIR__.'/../../.env');
|
||||
$this->key = sodium_hex2bin($env['encryption.key']);
|
||||
$this->aes_key = $env['aes.key'];
|
||||
}
|
||||
/*
|
||||
public function encrypt($data = null, $random_nonce = true) {
|
||||
if(is_null($data) || !$data || !$this->key) return null;
|
||||
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
|
||||
if($random_nonce === false) $nonce = "!++Zenith__Encryption++!";
|
||||
$data = sodium_pad($data, 16);
|
||||
$ciphertext = $nonce . sodium_crypto_secretbox($data, $nonce, $this->key);
|
||||
sodium_memzero($data);
|
||||
// sodium_memzero($this->key);
|
||||
|
||||
return sodium_bin2hex($ciphertext);
|
||||
}
|
||||
|
||||
public function decrypt($data = null) {
|
||||
if(is_null($data) || !$data || !$this->key) return null;
|
||||
$data = sodium_hex2bin($data);
|
||||
$nonce = mb_substr($data, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
|
||||
$ciphertext = mb_substr($data, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
|
||||
$data = sodium_crypto_secretbox_open($ciphertext, $nonce, $this->key);
|
||||
$data = sodium_unpad($data,16);
|
||||
|
||||
return $data;
|
||||
}
|
||||
*/
|
||||
|
||||
//암호화 함수
|
||||
public function encrypt($data)
|
||||
{
|
||||
$key = substr(hex2bin(openssl_digest($this->aes_key, 'sha512')), 0, 16);
|
||||
$enc = @openssl_encrypt($data, "AES-128-ECB", $key, true);
|
||||
return strtoupper(bin2hex($enc));
|
||||
}
|
||||
|
||||
//복호화 함수
|
||||
public function decrypt($data)
|
||||
{
|
||||
$data = hex2bin($data);
|
||||
$key = substr(hex2bin(openssl_digest($this->aes_key, 'sha512')), 0, 16);
|
||||
$dec = @openssl_decrypt($data, "AES-128-ECB", $key, true);
|
||||
return $dec;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
class ZenithInterlock
|
||||
{
|
||||
private $db, $rwdb;
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = new ZenithDB();
|
||||
$this->rwdb = $this->db->getRWConnection();
|
||||
}
|
||||
|
||||
//외부연동 처리
|
||||
public function eventLeadsInterlock($data) {
|
||||
if(!isset($data['interlock_result'])){
|
||||
return;
|
||||
}
|
||||
$interlock_failed = count($data['interlock_result']); //랜딩별 총 외부연동 갯수를 실패횟수로 정의
|
||||
foreach($data['interlock_result'] as $row) {
|
||||
//수신데이터 정리
|
||||
if (self::is_json($row['response_data'])) { //수신 데이터가 json 형태라면..
|
||||
$response = json_decode($row['response_data'], true); //json을 배열로 변형
|
||||
$row['response_data'] = json_encode($response, JSON_UNESCAPED_UNICODE); //DB에 저장하기 위해 배열로 변형한 데이터를 unicode 처리하지 않고 json으로 변환
|
||||
} else {
|
||||
$response = $row['response_data']; //수신데이터가 배열이면 그대로 지정
|
||||
}
|
||||
if(isset($response['state']))
|
||||
$response['result'] = $response['state']; //수신 데이터가 result가 아닌 state가 있어서 result로 변경
|
||||
if(isset($response['status']))
|
||||
$response['result'] = $response['status']; //수신 데이터가 result가 아닌 status가 있어서 result로 변경
|
||||
if(isset($response['result_code']) && isset($response['result_msg'])) //야호맨 result_code = '0', result_msg = 'success'
|
||||
$response = $response['result_msg'];
|
||||
$is_success = 0;
|
||||
/*
|
||||
! result 값에 따라 $is_success 를 처리할 수 있도록 모든 성공값을 처리
|
||||
? 정의된 배열 이외 성공값이 있을 경우 수식을 수정하거나 배열에 추가하여야 함
|
||||
*/
|
||||
if((isset($response['result']) //reponse가 result 배열이 존재 할 경우
|
||||
&& (in_array(strtolower($response['result']), ["ok","200","y","success","01","true","0000"]) //배열 내 result 값이 정의된 배열 안에 존재하거나
|
||||
|| $response['result'] === true)
|
||||
) //배열 내 result 가 boolean 값 true로 넘어왔거나
|
||||
|| in_array(strtolower((string)$response), ["ok","200","y","1","success"])) //response가 배열이 아닌 text값이 정의된 배열에 존재할 경우
|
||||
{
|
||||
$is_success = 1; //성공
|
||||
}
|
||||
//전송데이터 정리
|
||||
if(self::is_json($row['send_data'])) $row['send_data'] = json_decode($row['send_data'], true);
|
||||
//전송한 데이터의 문자가 변형 된 것을 UTF-8 형태로 치환
|
||||
$row['send_data'] = array_map(function($v){
|
||||
if(urlencode(urldecode($v)) === $v) $v = urldecode($v);
|
||||
return iconv(mb_detect_encoding($v, ['ASCII','UTF-8','EUC-KR']), 'UTF-8//TRANSLIT', urldecode($v));
|
||||
},$row['send_data']);
|
||||
//DB에 저장하기 위해 전송한 데이터를 unicode 처리하지 않고 json으로 변환
|
||||
$row['send_data'] = json_encode($row['send_data'], JSON_UNESCAPED_UNICODE);
|
||||
array_walk($row, function(&$string) { $string = $this->rwdb->real_escape_string($string); }); //DB저장을 위해 escape 처리
|
||||
//외부연동 내역
|
||||
$this->db->insertEventLeadInterlock($data, $row, $is_success);
|
||||
if($is_success === 1){
|
||||
$interlock_failed--; //성공할 때 마다 실패횟수 차감
|
||||
}else { //외부연동 실패 할 때 마다
|
||||
$memoData = [
|
||||
'seq' => $data['seq']
|
||||
,'event_seq' => $data['event_seq']
|
||||
,'memo' => "외부연동을 실패하였습니다."
|
||||
];
|
||||
if(isset($response['msg']) || isset($response['message']) || isset($response['result_msg'])) {
|
||||
if(isset($response['msg']))
|
||||
$msg = $response['msg'];
|
||||
if(isset($response['message']))
|
||||
$msg = $response['message'];
|
||||
if(isset($response['code_message']))
|
||||
$msg = $response['code_message'];
|
||||
if(isset($response['result_msg']))
|
||||
$msg = $response['result_msg'];
|
||||
$memoData['memo'] .= "[메세지:{$msg}]";
|
||||
}
|
||||
$this->db->insertToMemo($memoData);
|
||||
}
|
||||
}
|
||||
|
||||
if($interlock_failed === 0) { //외부연동 모두 성공 했을 때
|
||||
//외부연동 결과 처리
|
||||
$this->db->updateEventLeadInterlock($data['seq']);
|
||||
}
|
||||
}
|
||||
|
||||
//외부연동
|
||||
public function zenithInterlock() {
|
||||
$sql = "SELECT ea.name AS advertiser_name, el.*, `zenith`.dec_data(el.phone) AS phone
|
||||
FROM `zenith`.`event_leads` AS el
|
||||
LEFT JOIN `zenith`.`event_information` AS ei ON el.event_seq = ei.seq
|
||||
LEFT JOIN `zenith`.`event_advertiser` AS ea ON ei.advertiser = ea.seq
|
||||
WHERE el.interlock_success = 0
|
||||
AND el.status = 1
|
||||
AND ei.interlock = 1
|
||||
AND ea.interlock_url <> ''
|
||||
AND el.reg_date >= DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
|
||||
$result = $this->db->query($sql);
|
||||
while($row = $result->db->fetch_assoc()) {
|
||||
$this->db->getLandingBySeq($row['event_seq']);
|
||||
$data = array_map('addslashes', $row);
|
||||
$interlock_file = __DIR__."/data/{$row['advertiser_name']}/interlock.php";
|
||||
echo '<br>'.$row['advertiser_name'].'/';
|
||||
var_dump(file_exists($interlock_file));
|
||||
echo '<pre>'.print_r($data,1).'</pre>';
|
||||
continue;
|
||||
if(file_exists($interlock_file)) //외부연동 파일이 있으면 진행
|
||||
include $interlock_file;
|
||||
$this->eventLeadsInterlock($data);
|
||||
}
|
||||
}
|
||||
|
||||
private function is_json($string = null)
|
||||
{
|
||||
$ret = true;
|
||||
if (!is_string($string) || null === json_decode($string)) {
|
||||
$ret = false;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
class ZenithIP
|
||||
{
|
||||
private $db;
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = new ZenithDB();
|
||||
}
|
||||
public function chk_ip($remote_addr, $list=[])
|
||||
{
|
||||
$is_ip_chk = false;
|
||||
foreach($list as &$ip) {
|
||||
$ip = trim($ip);
|
||||
|
||||
if(strpos($ip, "/") !== false) {
|
||||
if($this->_ip_match($ip, $remote_addr) == true) {
|
||||
$is_ip_chk = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(in_array($remote_addr, $list) === false && $is_ip_chk === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function _ip_match($network, $remote_addr)
|
||||
{
|
||||
$ip_arr = explode("/", $network);
|
||||
|
||||
$network_long = ip2long($ip_arr[0]);
|
||||
|
||||
$mask_long = pow(2,32)-pow(2,(32-$ip_arr[1]));
|
||||
$ip_long = ip2long($remote_addr);
|
||||
if(($ip_long & $mask_long) == $network_long) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ipBlocker($remote_addr, $is_our)
|
||||
{
|
||||
/*
|
||||
$mobile_ip = [
|
||||
'203.226.0.0/16' // SKT 3G
|
||||
,'211.234.0.0/16' // SKT 3G
|
||||
,'223.32.0.0/11' // SKT 4G, 5G
|
||||
//,'2001:2d8::/32' // SKT 4G, 5G IPv6
|
||||
,'39.7.0.0/24' // KT 3G, 4G, 5G
|
||||
,'110.70.0.0/16' // KT 3G, 4G, 5G
|
||||
,'175.223.0.0/16' // KT 3G, 4G
|
||||
,'211.246.0.0/16' // KT 3G
|
||||
,'118.235.0.0/16' // KT 4G, 5G
|
||||
,'211.246.0.0/16' // KT 4G
|
||||
//,'2001:e60::/32' // KT 4G, 5G IPv6
|
||||
,'61.43.0.0/16' // LG 3G
|
||||
,'211.234.0.0/16' // LG 3G
|
||||
,'106.102.0.0/16' // LG 4G
|
||||
,'117.111.0.0/16' // LG 4G
|
||||
,'211.36.0.0/16' // LG 4G
|
||||
,'106.101.0.0/16' // LG 5G
|
||||
//,'2001:4430::/32' // LG 5G IPv6
|
||||
];
|
||||
*/
|
||||
|
||||
$result = $this->db->getIpBlockerByIp($remote_addr);
|
||||
$blocked = $result->db->num_rows;
|
||||
if ($blocked) {
|
||||
$block = $result->db->fetch_assoc();
|
||||
if (strtotime($block['term']) >= time()) {
|
||||
throw new Exception("부정접속으로 확인되어 1시간동안 접속이 차단됩니다.");
|
||||
} elseif ($block['forever'] == 1) {
|
||||
throw new Exception("지속적인 부정접속으로 확인되어 사이트 접속이 차단됩니다.");
|
||||
}
|
||||
}
|
||||
|
||||
//session 으로 분당 접속 카운트
|
||||
if(isset($_SESSION['visit'])){
|
||||
if ($_SESSION['visit']['datetime'] && strtotime($_SESSION['visit']['datetime'] . ' +1 minute') >= time()) {
|
||||
$_SESSION['visit']['count']++;
|
||||
} else {
|
||||
$_SESSION['visit']['datetime'] = date('Y-m-d H:i:s');
|
||||
$_SESSION['visit']['count'] = 1;
|
||||
}
|
||||
//카운트 분당 30회 이상일 경우 블럭처리
|
||||
if ($_SESSION['visit']['count'] >= 30 && !$is_our) {
|
||||
$this->db->setIpBlocker($remote_addr);
|
||||
unset($_SESSION['visit']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//IP정보 가져오기
|
||||
public static function getRemoteAddr()
|
||||
{
|
||||
$ipaddress = '';
|
||||
if (getenv('HTTP_CLIENT_IP'))
|
||||
$ipaddress = getenv('HTTP_CLIENT_IP');
|
||||
else if (getenv('HTTP_X_FORWARDED_FOR'))
|
||||
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
|
||||
else if (getenv('HTTP_X_FORWARDED'))
|
||||
$ipaddress = getenv('HTTP_X_FORWARDED');
|
||||
else if (getenv('HTTP_FORWARDED_FOR'))
|
||||
$ipaddress = getenv('HTTP_FORWARDED_FOR');
|
||||
else if (getenv('HTTP_FORWARDED'))
|
||||
$ipaddress = getenv('HTTP_FORWARDED');
|
||||
else if (getenv('REMOTE_ADDR'))
|
||||
$ipaddress = getenv('REMOTE_ADDR');
|
||||
else
|
||||
$ipaddress = 'UNKNOWN';
|
||||
|
||||
return $ipaddress;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
include __DIR__ . "/zenith_ip.php";
|
||||
|
||||
$addr = ZenithIP::getRemoteAddr();
|
||||
$jsonData = [
|
||||
'name' => $_POST['name'],
|
||||
'phone' => $_POST['phone'],
|
||||
'remote_addr' => $addr,
|
||||
'age' => $_POST['age'] ?? '',
|
||||
'branch' => $_POST['branch'] ?? '',
|
||||
'add1' => $_POST['add1'] ?? '',
|
||||
'add2' => $_POST['add2'] ?? '',
|
||||
'add3' => $_POST['add3'] ?? '',
|
||||
'add4' => $_POST['add4'] ?? '',
|
||||
'add5' => $_POST['add5'] ?? '',
|
||||
'add6' => $_POST['add6'] ?? '',
|
||||
];
|
||||
|
||||
$url = 'http://local.event.hotblood.co.kr/zenith_index.php/1/send/';
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json'
|
||||
),
|
||||
CURLOPT_POSTFIELDS => json_encode($jsonData),
|
||||
CURLOPT_AUTOREFERER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_VERBOSE => true,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_POST => true,
|
||||
));
|
||||
|
||||
$response =curl_exec($ch);
|
||||
curl_close($ch);
|
||||
print_r(curl_getinfo($ch));
|
||||
var_dump($response);
|
||||
$result = json_decode($response);
|
||||
if ($response !== null) {
|
||||
echo "결과값:\n";
|
||||
echo "result: " . ($result->result ? 'true' : 'false') . "\n";
|
||||
echo "data: " . $result->data . "\n";
|
||||
} else {
|
||||
echo "JSON 파싱 오류 또는 빈 응답\n";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>테스트</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>제니스 테스트</h1>
|
||||
<form id="jsonForm" action="./zenith_test.php" method="POST">
|
||||
<label for="no">*이벤트 번호:</label>
|
||||
<input type="text" id="no" name="no" value="" required><br>
|
||||
<label for="name">*이름:</label>
|
||||
<input type="text" id="name" name="name" value="" required><br>
|
||||
<label for="phone">*전화번호:</label>
|
||||
<input type="text" id="phone" name="phone" value="" required><br>
|
||||
<label for="age">나이:</label>
|
||||
<input type="text" id="age" name="age" value=""><br>
|
||||
<label for="branch">지점:</label>
|
||||
<input type="text" id="branch" name="branch" value=""><br>
|
||||
<label for="add1">add1:</label>
|
||||
<input type="text" id="add1" name="add1" value=""><br>
|
||||
<label for="add2">add2:</label>
|
||||
<input type="text" id="add2" name="add2" value=""><br>
|
||||
<label for="add3">add3:</label>
|
||||
<input type="text" id="add3" name="add3" value=""><br>
|
||||
<label for="add4">add4:</label>
|
||||
<input type="text" id="add4" name="add4" value=""><br>
|
||||
<label for="add5">add5:</label>
|
||||
<input type="text" id="add5" name="add5" value=""><br>
|
||||
<label for="add6">add6:</label>
|
||||
<input type="text" id="add6" name="add6" value=""><br>
|
||||
<input type="submit" value="테스트 전송">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user