"; $r = mysql_select_db(__DB_DEFAULT, $dbconn); if ($r == FALSE) echo "SELECT Error
"; return $dbconn; } /** * @brief 쿼리 실행 * @remarks 쿼리를 실행하고 그 결과를 반환한다. * @param Connection $dbconn DB 연결링크 * @param String $query 쿼리 문자열 * @return ResultSet $result 쿼리 결과 * @author 박종근 * @date 2012-05-08 */ function executeQuery($dbconn, $query) { if (!$dbconn) $dbconn = connectDB(); $result = mysql_query($query); // if ($result == FALSE) // { // $fp = fopen("/home/html/logs/" . date("Ymd") . "_db.elog", "a+"); // $time = date("Y-m-d H:i:s"); // fwrite($fp, $time . ' ' . $query . ' ' . $_SESSION['sess_userid'] . ' ' . $_SERVER['PHP_SELF'] . "\n"); // fclose($fp); // } return $result; } /** * @brief 쿼리 결과 fetch * @remarks 쿼리 결과를 fetch하여 한 Row씩 반환한다. * Object로 반환하므로 반환된 값을 이용시 $result->필드명과 같이 사용한다. * @param ResultSet $result 쿼리 결과 * @return Object $row fetch된 row object * @author 박종근 * @date 2012-05-08 */ function fetchRow($result) { $row = @mysql_fetch_object($result); return $row; } /** * @brief 쿼리 결과의 수를 구한다. * @remarks 쿼리 결과의 Row수를 반환한다. * @param ResultSet $result 쿼리 결과 * @return int $cnt 쿼리 결과의 Row * @author 박종근 * @date 2012-05-02 */ function getCount($result) { return mysql_num_rows($result); } /** * @brief 쿼리 결과의 하나의 값을 구한다. * @remarks 쿼리 결과의 첫번째 필드의 값을 반환한다. * @param Connection $result DB 연결 링크 * @param String $query 쿼리 문자열 * @return Mixed $result 쿼리 결과의 첫번째 필드 * @author 박종근 * @date 2012-05-08 */ function getOneValue($dbconn, $query) { $result = executeQuery($dbconn, $query); $result = mysql_result($result, 0); // php warning - php.net 권고 사항으로 변경할 예정 $result = mysql_fetch_assoc($result); // if ($result === false) // { // $fp = fopen("/home/html/logs/" . date("Ymd") . "_db.elog", "a+"); // $time = date("Y-m-d H:i:s"); // fwrite($fp, $time . ' ' . $query . ' ' . $_SESSION['sess_userid'] . ' ' . $_SERVER['PHP_SELF'] . "\n"); // fclose($fp); // } return $result; } /** * @brief DB 연결 해제 * @remarks DB 연결 링크를 해제한다. * @param Connect $dbconn DB 연결 링크 * @author 박종근 * @date 2012-05-08 */ function DBdisconnect($dbconn) { mysql_close($dbconn); } /** * @brief ResultSet 해제 * @remarks ResultSet을 해제한다. * @param ResultSet $result 쿼리 결과 * @author 박종근 * @date 2012-05-08 */ function freeResult($result) { mysql_free_result($result); } ?> fortunade_2012 *@author 박종근 *@date 2011-08-23 */ function JKA_VISIT_GATHER($_Type, $_Key, $_getID, $_vcCID = "", $_vcSEQ = "", $_vcMethod = "", $_vcPay = ""){ /*if(!strcmp($_Type, "MR") && !empty($_Key)){ $_resData["TYPE"] = $_Type; $_resData["V_TARGET"] = "FAW"; $_resData["V_KEY"] = $_Key; $_resData["V_DATE"] = date("Y-m-d"); $_resData["V_TIME"] = date("H:i:s"); $_resData["V_DATA"] = $_getID; // 회원 아이디 $_jsonData = json_encode($_resData); $log_file = "/home/httpd/fortunade_2012/_include/vlogs/".date("YmdH").".log"; $fp = fopen ( $log_file, "a"); $log_str = $_jsonData . "\n"; fputs($fp, $log_str); fflush($fp); fclose($fp); }else if(!strcmp($_Type, "LJ") && !empty($_Key)){ $_resData["TYPE"] = $_Type; $_resData["V_TARGET"] = "FAW"; $_resData["V_KEY"] = $_Key; $_resData["V_DATE"] = date("Y-m-d"); $_resData["V_TIME"] = date("H:i:s"); $_resData["V_DATA"] = $_getID; // 회원 아이디 $_jsonData = json_encode($_resData); $log_file = "/home/httpd/fortunade_2012/_include/vlogs/".date("YmdH").".log"; $fp = fopen ( $log_file, "a"); $log_str = $_jsonData . "\n"; fputs($fp, $log_str); fflush($fp); fclose($fp); }else if(!empty($_Key)){ //$_Type, $_Key, $_getID, $_vcType = null, $_vcCID = null, $_vcTID = null, $_vcMethod = null, $_vcPay = null){ $_resData["TYPE"] = $_Type; $_resData["V_TARGET"] = "FAW"; $_resData["V_KEY"] = $_Key; $_resData["V_DATE"] = date("Y-m-d"); $_resData["V_TIME"] = date("H:i:s"); $_resData["V_DATA"] = $_getID; // 회원 아이디 $_resData["V_CID"] = $_vcCID; // 컨텐츠 아이디 $_resData["V_SEQ"] = $_vcSEQ; // 거래 SEQ $_resData["V_METHOD"] = $_vcMethod; // 결제 방법 $_resData["V_PAY"] = $_vcPay; // 거래 금액 $_jsonData = json_encode($_resData); $log_file = "/home/httpd/fortunade_2012/_include/vlogs/".date("YmdH").".log"; $fp = fopen ( $log_file, "a"); $log_str = $_jsonData . "\n"; fputs($fp, $log_str); fflush($fp); fclose($fp); }*/ } function writeVistitLog() { if(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) $referer=$_SERVER['HTTP_REFERER']; else $referer=""; $referer = str_replace('http://', '', $referer); $referer = str_replace('www.', '', $referer); if (empty($_SESSION['refer']) && substr($referer, 0, 13) != 'fortunade.com' ) $_SESSION['refer'] = str_replace("'", "quote", $referer); $logPath = "/home/httpd/fortunade_2012/logs/"; $filename = date("Ymd") . ".vlog"; $fp = fopen($logPath . $filename, "a+"); $time = date("Ymd His"); if (date("Ymd") >= "20130117") { if (strpos($_SERVER['HTTP_USER_AGENT'], "bot") === false) fwrite($fp, $time . ' ' . $_SERVER['REMOTE_ADDR'] . ' ' . $_SERVER['REQUEST_URI'] . " '" . $_SERVER['HTTP_REFERER'] . "' '" . $_SESSION['sess_userid'] . "' '" . $_SERVER['HTTP_USER_AGENT'] . "'\n"); } else { fwrite($fp, $time . ' ' . $_SERVER['REMOTE_ADDR'] . ' ' . $_SERVER['REQUEST_URI'] . " '" . $_SERVER['HTTP_REFERER'] . "' '" . $_SESSION['sess_userid'] . "'\n"); } fclose($fp); } writeVistitLog(); /** * 검색어 저장 * @param object $id 사용자 아이디 * @param object $keyword 검색어 * @param object $agent 검색 브라우저 * @return */ function insertKeyword($id, $keyword) { $now = date("Ymd"); $time = date("His"); $agent = $_SERVER['HTTP_USER_AGENT']; $query = "INSERT INTO tb_search (regdate, regtime, id, keyword, agent, method) VALUES ('$now', '$time', '$id', '$keyword', '$agent', 0)"; executeQuery($dbconn, $query); } /** * 쿠폰 사용시 사용한 내역을 기록한다. * 2017.06.12 쿠폰사용 취소 대응 * @param object $id 사용자 아이디 * @param object $coupon 쿠폰번호 * @param object $cid 컨텐츠 아이디 * @param object $payment 금액 * @param object $seq tb_member_content seq value * @return */ function updateCoupon($id, $coupon, $cid, $payment, $seq=0){ $now = date("Ymd"); $time = date("His"); // $query = "insert into tb_member_content (id, regdate, regtime, cid, payment, coupon) values ('$id', '$now', '$time', $cid, $payment, 'Y')"; // executeQuery($dbconn, $query); //2011.04.27 rtq값 등록 추가 v if(empty($_SESSION['rtq'])){ $value_ins='NULL'; }else{ if (preg_match("/^([0-9]*)$/",$_SESSION['rtq'])){ $value_ins=(int)$_SESSION['rtq']; }else{ $value_ins='NULL'; } } //2011.04.27 rtq값 등록 추가 ^ $d = date("YmdHi"); //$query = "update tb_coupon set cid=$cid, used='Y', use_date='$d' where id='$id' and coupon_id='$coupon'"; //2011.04.27 rtq값 등록 할 수 있도록 쿼리 수정 $query = "update tb_coupon set cid=$cid, used='Y', use_date='$d', rtq=$value_ins, seq = $seq where id='$id' and coupon_id='$coupon'"; executeQuery($dbconn, $query); } /** * 다시보기 저장 * @param object $cid 컨텐츠 아이디 * @param object $uid 사용자 아이디 * @param object $value 내용 * @param object $dbconn * @param object $contentLogID [optional] * @param object $replaychk [optional] * @return */ function insertReplayNew($cid, $uid, $value, $dbconn, $contentLogID=0, $replaychk=0) { if (empty($contentLogID)) $contentLogID = 0; $value = addslashes($value); $past = date("YmdHis", strtotime("-15 seconds")); //15초 이 후 결제 가능 $query = "select count(*) from tb_content_replay2 where userid='$uid' and cid=$cid and regdate >= '$past'"; $cnt = getOneValue($dbconn, $query); $now = date("YmdHis"); $query = "insert into tb_content_replay2 (cid, userid, regdate, content, contentlogid) values ($cid, '$uid', '$now', '$value', $contentLogID)"; //echo $query; if ($cnt == 0) executeQuery($dbconn, $query); if ($replaychk == 1){ return mysql_insert_id(); } } /** * 무료 운세 다시보기 저장 * @param object $cid 컨텐츠 아이디 * @param object $uid 사용자 아이디 * @param object $value 내용 * @param object $dbconn * @param object $contentLogID [optional] * @param object $replaychk [optional] * @return */ function insertReplayNewFree($cid, $uid, $value, $dbconn, $contentLogID=0, $replaychk=0) { if (empty($contentLogID)) $contentLogID = 0; $value = addslashes($value); $now = date("YmdHis"); $query = "insert into tb_content_replay2 (cid, userid, regdate, content, contentlogid) values ($cid, '$uid', '$now', '$value', $contentLogID)"; executeQuery($dbconn, $query); return mysql_insert_id(); } /** * 로그기록 * @param object $prefix 로그 구분자 * @param object $content 로그 내용 * @return */ function writeLog($prefix, $content) { $logPath = "/home/httpd/logs/fortunade/"; $filename = "log_" . date("Ymd") . "." . $prefix . "log"; $fp = fopen($logPath . $filename, "a+"); $time = date("Y-m-d H:i:s"); fwrite($fp, $time . ' ' . $content . "\n"); fclose($fp); } /** * 2020.01.20 * kakao 로그기록 (임시용) (success_charge.php, kakaoApproveDirect.php에서 사용) * @param object $prefix 로그 구분자 * @param object $content 로그 내용 * @return */ function writekakaoLog($prefix, $content) { $logPath = "/home/httpd/logs/fortunade/kakao/web/"; $filename = "log_" . date("Ymd") . "." . $prefix . "log"; $fp = fopen($logPath . $filename, "a+"); $time = date("Y-m-d H:i:s"); fwrite($fp, $time . ' ' . $content . "\n"); fclose($fp); } function logSubMain($mid, $sid) { if (empty($_SESSION['sess_userid']) && (substr($_SERVER['HTTP_REFERER'], -9) == "index.php" || (substr($_SERVER['HTTP_REFERER'], -14) == "fortunade.com/" ))) { $query = "select count(*) from tb_stat_main where regdate='" . date("Ymd") . "' and ip = '" . $_SERVER['REMODT_ADDR'] . "'"; if (getOneValue($dbconn, $query) == 0) { $query = "insert into tb_stat_main (regdate, main_menu, sub_menu, ip) values ('" . date("Ymd") . "', $mid, $sid, '" . $_SERVER['REMODT_ADDR'] . "')"; executeQuery($dbconn, $query); } } else { $query = "select count(*) from tb_stat_main where regdate='" . date("Ymd") . "' and id = '" . $_SESSION['sess_userid'] . "'"; if (getOneValue($dbconn, $query) == 0) { $query = "insert into tb_stat_main (regdate, main_menu, sub_menu, id) values ('" . date("Ymd") . "', $mid, $sid, '" . $_SESSION['sess_userid'] . "')"; executeQuery($dbconn, $query); } } } /** * URL 생성 기능 (지정된 파라미터를 통해 처리, trace기능) * @param $page 이동하고자 하는 페이지 또는 url * @return 지정 파라미터 추가된 페이지 또는 url */ function makePageURL ($page) { parse_str($_SERVER['QUERY_STRING'], $param); $page_param = explode('?', $page); $return_param = ''; if (isset($param['rtq'])) $rtq = $param['rtq']; else $rtq = '0'; if (isset($param['mbwprm'])) $mbwprm = $param['mbwprm']; else $mbwprm = '0'; if (count($page_param) > 1) { // 파라미터가 있는 경우 parse_str($page_param[1], $origin_param); $origin_param['rtq'] = $rtq; $origin_param['mbwprm'] = $mbwprm; foreach($origin_param as $key => $val) { $return_param .= $key . '=' . $val . '&'; } $return_param = substr($return_param, 0, -1); } else { // 파라미터가 없는 경우 $return_param = 'rtq=' . $rtq . '&mbwprm='. $mbwprm; } $pramtotal = $page_param[0] . '?' . $return_param; //20170412 강성원 rtq=0, mbwprm=0 삭제(통계의 정확성을 위해 불필요한 값 삭제) $pramtotal = str_replace(array("&rtq=0&mbwprm=0","?rtq=0", "&rtq=0", "&mbwprm=0","rtq=0","mbwprm=0", "&&"),"",$pramtotal); $pramtotal = str_replace("php&","php?",$pramtotal); /*$ip = $_SERVER['REMOTE_ADDR']; if($ip == "112.218.161.99"){ print_r($pramtotal); }*/ return $pramtotal; } function getRTQ() { parse_str($_SERVER['QUERY_STRING'], $param); if (isset($param['rtq'])) $rtq = $param['rtq']; else $rtq = '0'; return $rtq; } function getW() { parse_str($_SERVER['QUERY_STRING'], $param); if (isset($param['mbwprm'])) $mbwprm = $param['mbwprm']; else $mbwprm = '0'; return $mbwprm; } /** *@brief 바로포춘 *@remarks 바로포춘 설정을 한다. *@return str $bfValue on, off *@author 김응현 *@date 2012-05-11 */ function getFortune() { $bfvcookie=$_COOKIE['bfv']; $count=strrpos($_SERVER['HTTP_REFERER'], "fortunade.com"); if (empty($_COOKIE['bfv'])) { if (empty($_SERVER['HTTP_REFERER']) || $count > 0) { $_COOKIE['bfv'] = 'on'; setcookie("bfv", 'on', 0, '/'); } else { $_COOKIE['bfv'] = 'off'; setcookie("bfv", 'off', 0, '/'); } } else if ($_COOKIE['bfv'] == 'on') { if (empty($_SERVER['HTTP_REFERER']) || $count > 0) { $_COOKIE['bfv'] = 'on'; setcookie("bfv", 'on', 0, '/'); } else { $_COOKIE['bfv'] = 'off'; setcookie("bfv", 'off', 0, '/'); } } if (empty($_COOKIE['bfv'])){ setcookie("bfv", 'off', 0, '/'); return 'off'; } else{ return $_COOKIE['bfv']; } } function _microtime() { return array_sum(explode(' ',microtime())); } /** * PV 기록 모듈 * */ function logPV() { include_once $_SERVER['DOCUMENT_ROOT'] . "/_modules/mod_pdo.php"; $localIP = $_SERVER['REMOTE_ADDR']; $date = date("Ymd"); $pdo = new DBM(); $query = "INSERT INTO tb_stat_pv (regdate, ip, device, pv) VALUES (:date, :hostid, 'W', 1) ON DUPLICATE KEY UPDATE pv=pv+1"; $pdo->prepare($query); $pdo->bind(':date', $date, PDO::PARAM_STR); $pdo->bind(':hostid', $localIP, PDO::PARAM_STR); $pdo->execute(); } ?> 1) // $str_nav .= ""; // else // $str_nav .= ""; if ($curBlock > 1) { $prev_start = $start - $pagesPerBlock; $str_nav = $str_nav . "이전  "; } for ($i = $start; $i <= $end && $i <= $totalPage; $i++) { if ($i == $curPage) $str_nav = $str_nav . "[$i]  "; else if ($i < $end) $str_nav = $str_nav . "$i  "; else $str_nav = $str_nav . "$i  "; } if ($curBlock < $totalBlock) { $next_start = $start + $pagesPerBlock; $str_nav = $str_nav . "다음"; } // if ($curPage < $totalPage) // $str_nav .= ""; // else // $str_nav .= ""; // $str_nav .= ""; return $str_nav; } function printNavigation_new($totalPage, $curPage, $pagesPerBlock, $url, $pageName) { $str_nav = ""; $curBlock = ceil($curPage / $pagesPerBlock); $totalBlock = ceil($totalPage / $pagesPerBlock); $start = ($curBlock - 1) * $pagesPerBlock + 1; $end = $start + $pagesPerBlock - 1; if (strpos($url, "?") !== false) $separate = "&"; else $separate = "?"; if ($curBlock > 1) { $prev_start = $start - $pagesPerBlock; $str_nav = $str_nav . "이전  "; } for ($i = $start; $i <= $end && $i <= $totalPage; $i++) { if ($i == $curPage) $str_nav = $str_nav . "[$i]  "; else if ($i < $end) $str_nav = $str_nav . "$i  "; else $str_nav = $str_nav . "$i  "; } if ($curBlock < $totalBlock) { $next_start = $start + $pagesPerBlock; $str_nav = $str_nav . "다음"; } return $str_nav; } /** * 10보다 작은 숫자를 지정된 자릿수로 변환 * @param object $num 변환할 숫자 * @param object $cnt 자릿수 * @return */ function setDigit($num, $cnt) { $val = 1; for ($i = 0; $i < $cnt; $i++) { $val = $val . "0"; if ($num < $val) $num = "0" . $num; } return $num; } /** * @brief 등록된 컨텐츠 반환 * @remarks 퀵메뉴 컨테츠 정보를 반환한다. * @par 수정 * (kteran) 2012.05.24 퀵메뉴 반환시 regdate값 추가 * @param object $dbconn * @return object $result cid, path, content_name, regdate 반환 * @author 박종근 * @date 2011-08-23 */ function getQuickmenu($dbconn) { if (empty($dbconn)) { include_once $_SERVER['DOCUMENT_ROOT'] . '/_modules/mod_db.php'; $dbconn = connectDB(); } $query = "select a.cid, a.path, b.content_name, a.regdate from tb_quick_menu a, tb_content_new b where a.cid=b.cid and a.id='" . $_SESSION['sess_userid'] . "' order by a.regdate desc limit 0, 10"; $result = executeQuery($dbconn, $query); return $result; } /** * 등록된 퀵메뉴 컨텐츠의 수를 반환 * @return */ function getQuickmenuCount($dbconn) { if (empty($dbconn)) { include_once $_SERVER['DOCUMENT_ROOT'] . '/_modules/mod_db.php'; $dbconn = connectDB(); } $query = "select count(*) from tb_quick_menu where id='" . $_SESSION['sess_userid'] . "'"; $cnt = getOneValue($dbconn, $query); return $cnt; } /** * @brief 퀵메뉴 컨텐츠 등록 * @remarks 퀵메뉴 컨테츠를 등록 하도록 한다. 3개까지만. * @par 수정 * (kteran) 2012.05.24 3개이상 되는 레코드는 삭제, return 삭제 * @param str $id 사용자 아이디 * @param int $cid 컨텐츠 아이디 * @param str $path 컨텐츠 경로 * @param object $dbconn * @return str $msg 중복 체크 * @author 박종근 * @date 2011-08-23 */ function setQuickmenu($id, $cid, $path, $dbconn) { if (empty($dbconn)){ include_once $_SERVER['DOCUMENT_ROOT'] . '/_modules/mod_db.php'; $dbconn = connectDB(); } $id = mysql_real_escape_string($id); $cid = mysql_real_escape_string($cid); $path = mysql_real_escape_string($path); $query="select count(*) from tb_quick_menu where id = '".$id."' and cid = '".$cid."'"; $cid_cnt=getOneValue($dbconn, $query); if ($cid_cnt == 0){ $query="select count(*) from tb_quick_menu where id = '".$id."'"; $quick_cnt=getOneValue($dbconn, $query); if ($quick_cnt > 2){ $quick_cnt=$quick_cnt - 2; $query="DELETE FROM tb_quick_menu WHERE id = '".$id."' ORDER BY regdate LIMIT ".$quick_cnt; executeQuery($dbconn, $query); } $now = date("YmdHis"); $query = "insert into tb_quick_menu (id, cid, path, regdate) values ( '$id', $cid, '$path', '$now')"; executeQuery($dbconn, $query); $msg="YES"; }else{ $msg="NO"; } return $msg; } /** * 카테고리 아이디를 카테고리명으로 변환 * @param object $cat 카테고리 아이디 * @return */ function getCategoryName($cat) { $cat = mysql_real_escape_string($cat); $query = "select category_name from tb_category where category_id='".$cat."'"; $category_name = getOneValue($dbconn, $query); return $category_name; } /** * 서브메뉴 아이디를 서브메뉴명으로 변환 * @param object $sid 서브메뉴 아이디 * @return */ function getSubName ($sid) { $sid = mysql_real_escape_string($sid); $query = "select sub_menu_name from tb_sub_menu where sub_menu_id='".$sid."'"; $sub_name = getOneValue($dbconn, $query); return $sub_name; } /** *@brief 공지사항 롤링(구버전) *@remarks 공지글을 3개단위로 롤링 및 메뉴선택시 사라짐 *@par *@param obj $dbconn DBconnection *@param int $cnt 노출글 수 *@author 입성엽 *@date 2011-08-23 */ function getNoticeArticle($dbconn, $cnt=3){ $query = "SELECT * FROM tb_board_notice_new ORDER BY w_date DESC LIMIT 0, $cnt"; $result = executeQuery($dbconn, $query); $i=1; while($notice = fetchRow($result)){ if ($i == 1) $display="block"; else $display="none"; echo "
".$notice->subject."
"; $i++; } } /** * 경고메세지를 경고창으로 보여줍니다. */ function alert($msg='', $url=''){ if(!$msg) $msg = '올바른 방법으로 이용해 주십시오.'; echo ""; echo ""; if($url) moveUrl($url); exit; } // 경고메세지 출력후 창을 닫음 function alert_close_hotpoll($msg, $error=true) { if(!$msg) $msg = '올바른 방법으로 이용해 주십시오.'; //echo ""; //echo ""; if($url) moveUrl($url);*/ exit; } function moveUrl($url){ echo ""; exit; } /** * @brief 퀵메뉴 컨텐츠 삭제 * @remarks 퀵메뉴 컨테츠를 삭제한다. * @param str $id 사용자 아이디 * @param int $cid 컨텐츠 아이디 * @param str $regdate 퀵 메뉴 등록일 * @param object $dbconn * @author 김응현 * @date 2012-05-24 */ function delQuickmenu($id, $cid, $regdate, $dbconn){ if (empty($dbconn)) { include_once $_SERVER['DOCUMENT_ROOT'] . '/_modules/mod_db.php'; $dbconn = connectDB(); } $id = mysql_real_escape_string($id); $cid = mysql_real_escape_string($cid); $query="DELETE FROM tb_quick_menu WHERE id = '".$id."' and cid = '".$cid."' and regdate = '".$regdate."'"; executeQuery($dbconn, $query); } /** * @brief index left menu 기준일 구하기 * @remarks index left * @return ResultSet * @author 김응현 * @date 2013-07-25 */ function getNowWeekDays(){ $left_ars_week_key = date('w'); if ($left_ars_week_key == 0) $left_ars_week_key = 7; $left_ars_weekend = $left_ars_week_key; $left_ars_weekstart =$left_ars_weekend+6; $left_ars_keyDay['start'] = date("Ymd", strtotime("-".$left_ars_weekstart." days")); $left_ars_keyDay['end'] = date("Ymd", strtotime("-".$left_ars_weekend." days")); return $left_ars_keyDay; } /** * 2017.01.03 포춘에이드 메뉴 리스트 * depth : 0, 1 * gflag : L 왼쪽, R 오른쪽 구분값 * gkey : 그룹 key * way : 컨텐츠 운세의 그룹 key : 1=>타로카드, 2=>점성술, 3=>동양운세, 4=>퓨전운세 * * return array */ function getmenuslist(){ $query = "SELECT depth, gflag, gkey, name, url, icon_type, way, sort FROM tb_menus WHERE used = 'Y' and gkey <> 10 ORDER BY gflag,depth,sort"; $result = executeQuery($dbconn, $query); while($item=fetchRow($result)){ if($item->depth == 0){ $i[$item->gkey] = $item->sort - 1; $menu[$item->gflag][$i[$item->gkey]]['name'] = $item->name; $menu[$item->gflag][$i[$item->gkey]]['url'] = $item->url; $menu[$item->gflag][$i[$item->gkey]]['way'] = $item->way; }else if($item->depth == 1){ if(!$t[$item->gkey]) $t[$item->gkey] = 0; $menu[$item->gflag][$i[$item->gkey]]['depth1'][$t[$item->gkey]]['name'] = $item->name; $menu[$item->gflag][$i[$item->gkey]]['depth1'][$t[$item->gkey]]['url'] = $item->url; $menu[$item->gflag][$i[$item->gkey]]['depth1'][$t[$item->gkey]]['way'] = $item->way; $t[$item->gkey]++; } /** * 2018년 04월 부분 개편 관련 URL 변경 * 개발서버에서만 동작 */ // if ($_SERVER['SERVER_NAME'] == "dev.fortunade.com") { // if ($item->depth == 0 && ($item->gkey == 1 || $item->gkey == 2 || $item->gkey == 3 || $item->gkey == 5)) { // $menu[$item->gflag][$i[$item->gkey]]['url'] = str_replace("content_index.php", "content_index_postman.php", $item->url); // } // else if ($item->depth == 0 && $item->gkey == 7 ) { // $menu[$item->gflag][$i[$item->gkey]]['url'] .= 'index.postman.php'; // } // } } $result = $item = $t = $i = null; unset($query, $item, $t, $i, $result); return $menu; } /** * 2017.01.03 포춘에이드 컨텐츠 menu list * way : 컨텐츠 운세의 그룹 key : 1=>타로카드, 2=>점성술, 3=>동양운세, 4=>퓨전운세 * * return array */ function getmenulist(){ $query = "SELECT way, menu_id, menu_name, path, regdate FROM tb_menu WHERE used = 'Y' AND way > 0 ORDER BY way, menu_sort"; $result = executeQuery($dbconn, $query); while($item=fetchRow($result)){ if(!$i[$item->way]) $i[$item->way] = 0; $menu[$item->way][$i[$item->way]]['menu_id'] = $item->menu_id; $menu[$item->way][$i[$item->way]]['name'] = $item->menu_name; $menu[$item->way][$i[$item->way]]['path'] = $item->path; $i[$item->way]++; } $result = $item = $i = null; unset($query, $item, $i, $result); return $menu; } /** * 2017.01.03 포춘에이드 컨텐츠 sub menu list * * return array */ function getsubmenulist(){ $query = "SELECT menu_id, sub_menu_id, sub_menu_name, regdate, icon_type FROM tb_sub_menu WHERE used = 'Y' AND sub_menu_id NOT IN (8,12, 130) ORDER BY menu_id, sub_menu_sort"; $result = executeQuery($dbconn, $query); while($item=fetchRow($result)){ if(!$i[$item->menu_id]) $i[$item->menu_id] = 0; $menu[$item->menu_id][$i[$item->menu_id]]['sub_menu_id'] = $item->sub_menu_id; $menu[$item->menu_id][$i[$item->menu_id]]['name'] = $item->sub_menu_name; $menu[$item->menu_id][$i[$item->menu_id]]['regdate'] = $item->regdate; $menu[$item->menu_id][$i[$item->menu_id]]['icon_type'] = $item->icon_type; $i[$item->menu_id]++; } $result = $item = $i = null; unset($query, $item, $i, $result); return $menu; } /** * 2017.01.03 포춘에이드 컨텐츠 sub menu list 포춘에이드 메뉴 리스트에 add * $fmenu_list : content menu list * $fsubmenu_list : sub menu list * * return array */ function setsubmenulistadd($fmenu_list, $fsubmenu_list){ $NotSubMenuArr = array(57, 254); $fmenu_list_cnt = count($fmenu_list); for($i=1;$i<=$fmenu_list_cnt;$i++){ $sub_list_cnt = count($fmenu_list[$i]); for($t=0;$t<$sub_list_cnt;$t++){ $fmenu_list[$i][$t]['depth2'] = $fsubmenu_list[$fmenu_list[$i][$t]['menu_id']]; $depth2_cnt = count($fmenu_list[$i][$t]['depth2']); $depth2_cnt_minus = $depth2_cnt - 1; for($s=0;$s<$depth2_cnt;$s++){ $fmenu_list[$i][$t]['depth2'][$s]['url'] = '/content_list.php?menu='.$i.'&mid='.$fmenu_list[$i][$t]['menu_id'].'&sid='.$fmenu_list[$i][$t]['depth2'][$s]['sub_menu_id']; $sub_menu_id = $fmenu_list[$i][$t]['depth2'][$s]['sub_menu_id']; if( $s == $depth2_cnt_minus && $sub_menu_id > 0 && !in_array($sub_menu_id, $NotSubMenuArr) ){ $fmenu_list[$i][$t]['depth2'][$s+1]['name'] = $fmenu_list[$i][$t]['name'].' 소개'; $fmenu_list[$i][$t]['depth2'][$s+1]['url'] = '/'.$fmenu_list[$i][$t]['path'].'/introduce.php'; } } } } $fsubmenu_list = $NotSubMenuArr = null; unset($fmenu_list_cnt, $sub_list_cnt, $depth2_cnt, $depth2_cnt_minus); unset($NotSubMenuArr, $fsubmenu_list); return $fmenu_list; } /** * @brief cut text character set * @remarks PHP 4.0.6 이상 버전에서만 가능 * @param $string text * @param $start 시작 위치 * @param $length 길이 * @param $tail text 초과시 표현 text default '...' * @param $charset character set setting default 'UTF-8' * @return $string * @author 김응현 * @date 2017-01-11 */ function strcut_utf8higher($string,$start,$length,$tail='...', $charset=NULL){ if($charset==NULL) { $charset='UTF-8'; } /* 정확한 문자열의 길이를 계산하기 위해, mb_strlen 함수를 이용 */ $str_len=mb_strlen($string,$charset); if($str_len>$length){ /* mb_substr PHP 4.0.6 이상, iconv_substr PHP 5.0 이상 */ $string=mb_substr($string,$start,$length,$charset); $string.=$tail; } return $string; } /** * @brief banner list * @remarks * @param $device WEB,MOBILE * @param $pos tb_banner_schedule 의 pos 필드 참조 * @param $test service, test * @param $today Y-m-d * @param $time H:i:s * @return $Object * @author 김응현 * @date 2017-02-01 */ function getbannerlist($device, $pos, $test='service', $today='', $time=''){ if($test == 'service'){ if($device == 'WEB') $sub_query = "used = 'Y' AND "; else if($device == 'MOBILE') $sub_query = "mused = 'Y' AND "; } if($today == '') $today = date('Y-m-d'); if($time == '') $time = date('H:i:s'); $new = $today . ' ' . $time; $query = "SELECT * FROM tb_banner_schedule_new WHERE ".$sub_query." pos = '".$pos."' AND opendate <= '".$new."' AND closedate >= '".$new."' ORDER BY sort"; $result = executeQuery($dbconn, $query); return $result; } /** * @brief banner list * @remarks 2018년 4월 웹 UI 변경하면서 사용 * @param $device WEB,MOBILE * @param $pos tb_banner_schedule_new 의 pos 필드 참조 * @param $test service, test * @param $today Y-m-d * @param $time H:i:s * @return $Object * @author 박종근 * @date 2018-04-30 */ function getbannerlistNew($device, $pos, $test='service', $today='', $time=''){ if($test == 'service'){ if($device == 'WEB') $sub_query = "used = 'Y' AND "; else if($device == 'MOBILE') $sub_query = "mused = 'Y' AND "; } if($today == '') $today = date('Y-m-d'); if($time == '') $time = date('H:i:s'); $new = $today . ' ' . $time; $query = "SELECT * FROM tb_banner_schedule_new WHERE ".$sub_query." pos = '".$pos."' AND opendate <= '".$new."' AND closedate >= '".$new."' ORDER BY sort"; $result = executeQuery($dbconn, $query); return $result; } /** * @brief banner list * @remarks 랜덤하게 추출 * @param $device WEB,MOBILE * @param $pos tb_banner_schedule 의 pos 필드 참조 * @param $test service, test * @param $today Y-m-d * @param $time H:i:s * @return $Object * @author 박종근 * @date 2018-04-20 */ function getbannerlistRand($device, $pos, $test='service', $today='', $time=''){ if($test == 'service'){ if($device == 'WEB') $sub_query = "used = 'Y' AND "; else if($device == 'MOBILE') $sub_query = "mused = 'Y' AND "; } if($today == '') $today = date('Y-m-d'); if($time == '') $time = date('H:i:s'); $new = $today . ' ' . $time; $query = "SELECT * FROM tb_banner_schedule WHERE ".$sub_query." pos = '".$pos."' AND opendate <= '".$new."' AND closedate >= '".$new."' ORDER BY rand()"; $result = executeQuery($dbconn, $query); return $result; } /** * 접근 IP 확인 * IPv4, IPv6 */ function getRealIpAddr(){ if(!empty($_SERVER['HTTP_CLIENT_IP']) && getenv('HTTP_CLIENT_IP')){ return $_SERVER['HTTP_CLIENT_IP']; }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && getenv('HTTP_X_FORWARDED_FOR')){ return $_SERVER['HTTP_X_FORWARDED_FOR']; }elseif(!empty($_SERVER['REMOTE_HOST']) && getenv('REMOTE_HOST')){ return $_SERVER['REMOTE_HOST']; }elseif(!empty($_SERVER['REMOTE_ADDR']) && getenv('REMOTE_ADDR')){ return $_SERVER['REMOTE_ADDR']; } return false; } /* * IPv6 체크 */ function is_ipv6(){ $ip = getRealIpAddr(); if (!preg_match("/^([0-9a-f\.\/:]+)$/",strtolower($ip))) { return false; } if (substr_count($ip,":") < 2) { return false; } $part = preg_split("/[:\/]/", $ip); foreach ($part as $i) { if (strlen($i) > 4) { return false; } } return true; } /** * Setting Validation Rules * setParamRule addslashes, strip_tags */ function setParamRule ($str) { $str = @trim($str); if (!get_magic_quotes_gpc()) $str = addslashes($str); $str = strip_tags($str); return $str; } /** * Setting Validation Rules 2 * mysql_real_escape_string, strip_tags */ function setParamRuleEscape($dbconn, $str){ $str = @trim($str); if (!get_magic_quotes_gpc()) $str = mysql_real_escape_string($str, $dbconn); $str = strip_tags($str); return $str; } /** * Setting Validation Rules 3 * mysql_real_escape_string, strip_tags */ function setParamRuleInt($int, $flag='alert'){ $int = @trim($int); if($int != '' && !is_numeric($int) && $flag == 'alert'){ echo(''); exit(); }else if($int != '' && !is_numeric($int) && $flag != 'alert'){ return false; }else{ return $int; } } /** * 년 * @param start_year 시작년도 * @param end_year 종료년도 * @param select_year 선택년도 * @param flag text 표시 on, off */ function getSelectform_year($start_year='', $end_year='', $select_year='', $flag = 'off'){ $sel = $txt = ""; if($start_year == '') $start_year ='1940'; if($end_year == '') $end_year = date("Y"); if($select_year == '') $select_year = '1980'; if($flag == 'on') $txt = ' 년'; for ($i = $start_year; $i <= $end_year; $i++){ if ($i == $select_year) $sel = "selected"; else $sel = ""; $year.= "\n"; } return $year; } /** * 월 * @param select_month 선택월 * @param flag text 표시 on, off */ function getSelectform_month($select_month='1', $flag = 'off'){ $sel = $txt = ''; if($select_month == '') $select_month = '1'; $select_month = $select_month *1; if($flag == 'on') $txt = ' 월'; for ($i = 1; $i <= 12; $i++){ $j = ($i < 10) ? '0'.$i : $i; $sel = ($i != $select_month) ? '' : 'selected'; $month.= "\n"; } return $month; } /** * 일 * @param select_day 선택일 * @param flag text 표시 on, off */ function getSelectform_day($select_day='1', $flag = 'off'){ $sel = $txt = ''; if($select_day == '') $select_day = '1'; $select_day = $select_day *1; if($flag == 'on') $txt = ' 일'; for ($i = 1; $i <= 31; $i++){ $j = ($i < 10) ? '0'.$i : $i; $sel = ($i != $select_day) ? '' : 'selected'; $day.= "\n"; } return $day; } /** * 시 * @param select_hour 선택시 * @param flag text 표시 on, off */ function getSelectform_hour($select_hour='1', $flag = 'off'){ $sel = $txt = ''; if($select_hour == '') $select_hour = '1'; $select_hour = $select_hour *1; if($flag == 'on') $txt = ' 시'; for ($i = 0; $i < 24; $i++){ $j = ($i < 10) ? '0'.$i : $i; $sel = ($i != $select_hour) ? '' : 'selected'; $hour.= "\n"; } return $hour; } /** * 분 * @param select_min 선택시 * @param flag text 표시 on, off */ function getSelectform_min($select_min='1', $flag = 'off'){ $sel = $txt = ''; if($select_min == '') $select_min = '1'; $select_min = $select_min *1; if($flag == 'on') $txt = ' 분'; for ($i = 0; $i < 60; $i++){ $j = ($i < 10) ? '0'.$i : $i; $sel = ($i != $select_min) ? '' : 'selected'; $min.= "\n"; } return $min; } /** * lunar * @param select_lunar 양,음력 */ function getSelectform_lunar($select_lunar='0'){ $sel = ''; $lunartext = array('양력','음력'); for($i=0;$i<2;$i++){ $sel = ($i != $select_lunar) ? '' : 'selected'; $lunar.= "\n"; } return $lunar; } /** * leap * @param select_leap 평,윤달 */ function getSelectform_leap($select_leap='0'){ $sel = ''; $leaptext = array('평달','윤달'); for($i=0;$i<2;$i++){ $sel = ($i != $select_leap) ? '' : 'selected'; $leap.= "\n"; } return $leap; } /** * region * @param select_region 지역코드 */ function getSelectform_region($select_region=''){ $sel = ''; if($select_region == '') $select_region = ''; $regiontext = array('서울시', '경기도', '인천광역시','부산광역시','대구광역시','울산광역시','광주광역시','대전광역시','강원도','충북','충남','경북','경남','전북','전남','제주도'); $regioncnt = count($regiontext); for($i=0;$i < $regioncnt;$i++){ $sel = ($regiontext[$i] != $select_region) ? '' : 'selected'; $region.="\n"; } return $region; } /** * n달 뒤 날짜 * @param str now : YYYY-mm-dd * @param int term : n달 수 * @return YYYY-mm-dd */ function getLastMonthDate($now, $term=1) { if($term >= 0){$operator="+";$term2=$term;}else{$operator="-";$term2=$term*(-1);} $time = strtotime($operator.$term2." month", strtotime(date("Y-m",strtotime($now))." -01 ")); $l = date('t', $time); return date("Y-m-".$l, $time); } /** * url parser + param parser * @param str url : URL * @return array parser_url + parser_str */ function parseUrlAll($url){ $urlArr = parse_url($url); if($urlArr['query']){ parse_str($urlArr['query'], $urlArr['param']); } return $urlArr; } ?> email = decryptInfo($item->email); $item->phone1 = decryptInfo($item->phone1); $item->phone2 = decryptInfo($item->phone2); $item->phone3 = decryptInfo($item->phone3); $item->cell_phone1 = decryptInfo($item->cell_phone1); $item->cell_phone2 = decryptInfo($item->cell_phone2); $item->cell_phone3 = decryptInfo($item->cell_phone3); $item->addr1 = decryptInfo($item->addr1); $item->addr2 = decryptInfo($item->addr2); return $item; } /** * @brief 투데이 메세지 * @remarks 투데이 메세지 카드 정보 받아오기 * @param $dbconn dbconnection * @param string $id 회원 ID * @return Obj $item * @author 김응현 * @date 2011-08-23 */ function getTodayMsg($dbconn, $id) { $today = date("Ymd"); $query = "select a.card, b.basic_content1, b.basic_content2, b.basic_content3 from tb_" . $today . "_message a, tb_today_message_data_new b where a.card=b.card and userid='{$_SESSION['sess_userid']}'"; $result = executeQuery($dbconn, $query); $today_message = fetchRow($result); if ($today_message->card > 21) $pattern = ($today % 2) + 1; else $pattern = ($today % 3) + 1; $your_message[1] = $today_message->basic_content1; $your_message[2] = $today_message->basic_content2; $your_message[3] = $today_message->basic_content3; $returnToday[0]=$your_message[$pattern]; $returnToday[1]=$today_message->card; return $returnToday; } /** * @brief 투데이 메세지 카드명 * @remarks 투데이 메세지 카드명 받아오기 * @param $dbconn dbconnection * @return Obj $item * @author 김응현 * @date 2011-08-23 */ function getTodayCardName($dbconn){ $today = date("Ymd"); $query="select a.card, b.card_name from tb_" . $today . "_message a, tb_today_message_data_new b where a.card=b.card and a.userid = '{$_SESSION['sess_userid']}'"; $result = executeQuery($dbconn, $query); $today_message = fetchRow($result); $returnToday[0]=$today_message->card; $returnToday[1]=$today_message->card_name; return $returnToday; } /** *@brief 보완이 필요한 카드의 퍼스널 카드 그룹을 배열화 *@remarks 포타민에서 보완이 필요한 카드의 퍼스널 카드 정보를 배열로 return *@return Object $Tcard[투데이메세지카드번호][퍼스널카드번호] *@author 김응현 *@date 2012-05-11 */ function getTodayCardPersonalArray() { $Tcard=Array(12=>Array(3,10),13=>Array(20,14),15=>Array(9,2),16=>Array(8,13),18=>Array(9,2),30=>Array(6,19),34=>Array(17,1),35=>Array(10,4),43=>Array(14,21),44=>Array(3,19),46=>Array(7,0),47=>Array(11,9),52=>Array(13,4),53=>Array(8,9),55=>Array(19,5),56=>Array(1,12),57=>Array(14,18),58=>Array(0,6),61=>Array(11,16),62=>Array(10,12),63=>Array(17,21),69=>Array(15,8),72=>Array(7,15),74=>Array(18,16)); return $Tcard; } /** * 아이템 요청 또는 제공자 LIST */ function getProvideMember_login($dbconn, $id){ $today = date("Ymd"); $query="select reciveid as ids from tb_fortamin_note where id = '".$id."' and flag = '1' and regdate = '".$today."'"; $query.=" union "; $query.="select id as ids from tb_fortamin_note_comment where reciveid = '".$id."' and item_count > 0 and public = '2' and regdate = '".$today."'"; $result=executeQuery($dbconn,$query); $i=0; while($list=fetchRow($result)){ $memberId[$i]=$list->ids; $i++; } if (empty($memberId)) $memberId=""; return $memberId; } function getFortaminUserCount_login($dbconn, $todayCard, $id=""){ $todaypersonal=getTodayCardPersonalArray(); $personal=$todaypersonal[$todayCard]; if (count($personal) == 0){ $per_card="''"; $UserCount[0]=0; $UserCount[1]=1; }else{ $per_card=""; for($i=0;$i < count($personal);$i++){ $per_card.=$personal[$i].","; } $per_card=substr($per_card, 0, -1); if (empty($id)){ $UserCount[0]=0; }else{ $memberId=getProvideMember_login($dbconn, $id); $member_number=""; if (empty($memberId)){ $member_number="''"; }else{ for($i=0;$i UNIX_TIMESTAMP()"; $UserCount[0]=getOneValue($dbconn, $query); } $UserCount[1]=2; } return $UserCount; } /** * 포타민의 아이템 보내기로 올라온 글수 * * @param str $id 고객ID * @return int $NoteCount */ function getFortaminNote_login($dbconn, $id=""){ if (empty($id)){ $NoteCount = 0; }else{ $query="SELECT COUNT(*) FROM tb_fortamin_note WHERE regdate = '".date('Ymd')."' and reciveid = '".$id."' AND readding = '0'"; $NoteCount=getOneValue($dbconn, $query); } return $NoteCount; } /** * 포타민 이용 여부 체크 * @param str $id 고객ID * @return int $FTM_chk */ function getFortaminUse_login($dbconn, $id="") { if (empty($id)){ $FTM_chk = 0; }else{ // 포타민 이용 여부 확인 차 후 세션에 $FTM_chk값을 등록하여 처리하도록 한다. $query="select count(*) from tb_fortamin_user where id = '".$id."' and quitdate is NULL "; $FTM_chk=getOneValue($dbconn, $query); } return $FTM_chk; } /** * 포타민의 아이템 받기로 올라온 글수 * @param str $id 고객ID * @return int $FTM_chk */ function getFortaminNoteComment_login($dbconn, $id="") { $query="select count(*) from tb_fortamin_note_comment where readding= 0 and reciveid = '".$id."' AND regdate= '".date('Ymd')."' and item_count > 0 "; $FTM_chk=getOneValue($dbconn, $query); return $FTM_chk; } function couponTemp($dbconn, $id, $flag, $money, $grade) { $date = date("Y-m-d"); $query = "insert into tb_coupon_temp (id, flag, money, grade, regdate) values('$id', '$flag', $money, $grade, '$date')"; executeQuery($dbconn, $query); } /* * 포타민의 링크할 페이지 우선순위 체크 * * @param str $id 고객ID * @return int $NoteCount (3=글없음, 1=아이템 받기로 이동, 2=아이템 보내기로 이동) */ function getFortaminAll_login($dbconn, $id="") { if (empty($id)){ $NoteCount = 3; $NoteHit=2; }else{ $query="SELECT max(regtime) as regtime FROM tb_fortamin_note WHERE regdate = '".date('Ymd')."' and reciveid = '".$id."' AND readding = '0'"; $NoteCount=getOneValue($dbconn, $query); $chkCounts1=0; $chkCounts2=0; if (is_null($NoteCount)){ $chkCounts1=1; } $query="select max(regtime) as regtime from tb_fortamin_note_comment where readding= 0 and reciveid = '".$id."' AND regdate= '".date('Ymd')."' and item_count > 0 "; $CommentCount=getOneValue($dbconn, $query); if (is_null($CommentCount)){ $chkCounts2=2; } $chkCount=$chkCounts1+$chkCounts2; if($chkCount == 0){ if ($NoteCount>=$CommentCount) $NoteCount=2; else $NoteCount=1; } else $NoteCount=$chkCount; $query="select uhit from tb_fortamin_user where id = '".$id."'"; $Note_tmp=executeQuery($dbconn,$query); $Pcarduser=fetchRow($Note_tmp); $NoteChk=$Pcarduser->uhit; } $NoteCountReturn[0]=$NoteCount; $NoteCountReturn[1]=$NoteChk; return $NoteCountReturn; }; /** *@brief 알림 *@remarks 2017.02.06 수정 회원등급 하락 알림 * @param str $id 고객ID * @param int $grade 현재회원등급 * @return int $new_grade 변경 회원등급 * */ function alarm($dbconn, $id, $grade, $new_grade, $posi=''){ if($posi == 'charge'){ $downmsg = "충전 취소로 "; }else if($posi == 'direct'){ $downmsg = "직납 결제 취소로 "; }else{ $downmsg = "등급유지기간이 만료되어 "; } $grade_name[1]="브론즈"; $grade_name[2]="실버"; $grade_name[3]="골드"; $grade_name[4]="플래티넘"; $grade_name[5]="다이아몬드"; $exp_date = date("Ymd", strtotime("+30 days")); if ($new_grade > $grade) $content=$id."님 축하드립니다!
등급이 ".$grade_name[$grade]."에서 ".$grade_name[$new_grade]."(으)로 상향 조정되셨습니다."; else if($new_grade == $grade) $content=$id."님 축하드립니다!
".$grade_name[$grade]." 등급유지기간이 90일 연장되셨습니다."; else if($new_grade < $grade) $content=$id."님! ".$downmsg.$grade_name[$grade]."에서 ".$grade_name[$new_grade]."(으)로 조정 되셨습니다."; $query="insert into tb_alarm (id, content, regdate, exp) values ('$id','$content','".date('Ymd')."','".$exp_date."')"; executeQuery($dbconn,$query); } ?>