Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
ltms.eemo.co.kr
/
public_html
/
super
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/ltms.eemo.co.kr/public_html/super/depletion_complete_proc.php
<? session_cache_limiter('no-cache, must-revalidate'); session_start(); header("Pragma: no-cache"); header("Cache-Control: no-cache,must-revalidate"); header("Content-Type: text/html; charset=utf-8"); include_once("dbconn.php"); include_once("lib.php"); $mode = $_REQUEST["mode"]; if($mode == "re_req"){//입추대기 재요청 foreach($_GET as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } foreach($_POST as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } $rs=RS("select * from farm_contract where no='".$cont_no."' "); $rs_farm = RS("select * from farm where no='{$rs[farm_no]}' "); //$rs_member = RS("select * from member where farm_no='{$rs[farm_no]}' and mtype=1 "); //한 농장에 농장주가 여러명일수도 있어서 변경함. $rs_members=mysql_query("select * from member where farm_no='{$rs[farm_no]}' and mtype=1 "); while($rsArr=mysql_fetch_array($rs_members)) { //SMS 발송 $data = array( 'msg' => "입추대기 요청이 왔습니다. 농장앱에서 메세지를 확인해주세요.", 'tel' => $rsArr["cel"] ); $url = "http://ltms.eemo.co.kr/super/sms_send_msg.php"; $ch = curl_init(); //curl 초기화 curl_setopt($ch, CURLOPT_URL, $url); //URL 지정하기 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //요청 결과를 문자열로 반환 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //connection timeout 10초 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //원격 서버의 인증서가 유효한지 검사 안함 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); //POST data curl_setopt($ch, CURLOPT_POST, true); //true시 post 전송 //echo $response; $response = curl_exec($ch); curl_close($ch); } //농장앱 푸쉬알림 $title_push ="입추대기재요청 알림"; $cont="[예정입추일 : {$sel_jdate}] {$msg}"; $tts_cont="입추대기재요청 알림입니다 예정입추일 ".$sel_jdate." ".$msg; $mode_push="notice"; if($rs_farm[set_alarm]==1) { $result_mem=mysql_query("select * from member where farm_no='{$rs[farm_no]}' and fcm_token is not null ") or die(); while($rs_mem=mysql_fetch_array($result_mem)) { $tokens = array(); $tokens[]=$rs_mem[fcm_token]; $istts=$rs_farm[set_alarm_tts]; $is_sound=$rs_farm[set_alarm_tts]==1?"0":$rs_farm[set_alarm_tts]; $isvib=$rs_farm[alarm_vibrate]; $ispopup=$rs_farm[alarm_popup]; $message = array("message" => $cont,"title" => $title_push,"mode" => $mode_push,"sound" => $is_sound=="1"?"1":'-1',"tts" => $tts_cont,"istts" => $istts=="1"?"1":'-1',"isvib" => $isvib=="1"?"1":'-1',"ispopup" => $ispopup=="1"?"1":'-1'); $rst=send_notification($tokens, $message); if($rst=="success") { $str_val=implode("&",$tokens); mysql_query("insert into push_send_log set arr_mem_no='{$rs_mem[no]}', title='$title_push', cont='$cont', tts_cont='$tts_cont', is_tts='$istts', mode='$mode_push', is_sound='$is_sound', regdate=now(), mode2='2' ") or die(mysql_error()); } else { } } //농장앱 푸쉬알림 끝 } $sqlTmps = "select * from farm_msg_alarm where farm_no = '{$rs[farm_no]}' and contract_no = '{$cont_no}' and fno = '{$fno}' order by seq desc limit 1"; $rsTmpAlarm=RS($sqlTmps); $seqTmp = (int)$rsTmpAlarm["seq"]; $seqTmp = $seqTmp + 1; $pno = $rsTmpAlarm["no"]; //농장앱 메세지로 푸쉬 $regDate = date("Y-m-d H:i:s"); $sqlTmp = " INSERT INTO `egg`.`farm_msg_alarm` ( `pno`, `fno`, `seq`, `farm_no`, `farm_code`, `contract_no`, `msg_gubun`, `title`, `cont`, `regdate`, `is_recall`, `is_confirm_msg`, `confirm_msg_type`) VALUES ( '{$pno}', '{$fno}', '{$seqTmp}', '{$rs[farm_no]}', '{$rs[farm_code]}', '{$cont_no}', '사육관리', '{$title}', '[예정입추일 : {$sel_jdate}] {$msg}', '{$regDate}', '1', '1', '1'); "; $rsTmps=mysql_query($sqlTmp); //부모 요청에 대한 재요청 보이지 않게 $sql_pno_update = "update farm_msg_alarm set recall_btn_view = '0' where no = '{$pno}' and fno = '{$fno}' "; $rsUpdate=mysql_query($sql_pno_update); $arr_rst['rst'] ='1'; echo json_encode($arr_rst); }else if($mode == "req"){//입추대기 요청 foreach($_GET as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } foreach($_POST as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } $arrExplode = explode('-', $arr); for($i=0; $i<count($arrExplode); $i++){ $rs=RS("select * from farm_contract where no='".$arrExplode[$i]."' "); $rs_farm = RS("select * from farm where no='{$rs[farm_no]}' "); //$rs_member = RS("select * from member where farm_no='{$rs[farm_no]}' and mtype=1 "); //한 농장에 농장주가 여러명일수도 있어서 변경함. $rs_members=mysql_query("select * from member where farm_no='{$rs[farm_no]}' and mtype=1 "); while($rsArr=mysql_fetch_array($rs_members)) { //SMS 발송 $data = array( 'msg' => "입추대기 요청이 왔습니다. 농장앱에서 메세지를 확인해주세요.", 'tel' => $rsArr["cel"] ); $url = "http://ltms.eemo.co.kr/super/sms_send_msg.php"; $ch = curl_init(); //curl 초기화 curl_setopt($ch, CURLOPT_URL, $url); //URL 지정하기 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //요청 결과를 문자열로 반환 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); //connection timeout 10초 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //원격 서버의 인증서가 유효한지 검사 안함 curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); //POST data curl_setopt($ch, CURLOPT_POST, true); //true시 post 전송 //echo $response; $response = curl_exec($ch); curl_close($ch); } //농장앱 푸쉬알림 $title_push="입추대기요청 알림"; $cont="[예정입추일 : {$sel_jdate}] {$msg}"; $tts_cont="입추대기요청 알림입니다 예정입추일 ".$sel_jdate." ".$msg; $mode_push="notice"; if($rs_farm[set_alarm]==1) { $result_mem=mysql_query("select * from member where farm_no='{$rs[farm_no]}' and fcm_token is not null ") or die(); while($rs_mem=mysql_fetch_array($result_mem)) { $tokens = array(); $tokens[]=$rs_mem[fcm_token]; $istts=$rs_farm[set_alarm_tts]; $is_sound=$rs_farm[set_alarm_tts]==1?"0":$rs_farm[set_alarm_sound]; $isvib=$rs_farm[alarm_vibrate]; $ispopup=$rs_farm[alarm_popup]; $message = array("message" => $cont,"title" => $title_push,"mode" => $mode_push,"sound" => $is_sound=="1"?"1":'-1',"tts" => $tts_cont,"istts" => $istts=="1"?"1":'-1',"isvib" => $isvib=="1"?"1":'-1',"ispopup" => $ispopup=="1"?"1":'-1'); $rst=send_notification($tokens, $message); if($rst=="success") { $str_val=implode("&",$tokens); mysql_query("insert into push_send_log set arr_mem_no='{$rs_mem[no]}', title='$title_push', cont='$cont', tts_cont='$tts_cont', is_tts='$istts', mode='$mode_push', is_sound='$is_sound', regdate=now(), mode2='2' ") or die(mysql_error()); } else { } } //농장앱 푸쉬알림 끝 } //농장앱 메세지로 푸쉬 $regDate = date("Y-m-d H:i:s"); $sqlTmp = " INSERT INTO `egg`.`farm_msg_alarm` ( `seq`, `farm_no`, `farm_code`, `contract_no`, `msg_gubun`, `title`, `cont`, `regdate`, `is_confirm_msg`, `confirm_msg_type`) VALUES ( '1', '{$rs[farm_no]}', '{$rs[farm_code]}', '{$arrExplode[$i]}', '사육관리', '{$title}', '[예정입추일 : {$sel_jdate}] {$msg}', '{$regDate}', '1', '1'); "; //echo $sqlTmp; $rsTmps=mysql_query($sqlTmp); $sqlTmps = "select * from farm_msg_alarm where farm_no = '{$rs[farm_no]}' and contract_no = '{$arrExplode[$i]}' order by regdate desc limit 1"; $rsTmpAlarm=RS($sqlTmps); $updateSql = "update farm_msg_alarm set fno = '{$rsTmpAlarm[no]}' where no = '{$rsTmpAlarm[no]}' "; $rsUpdates = mysql_query($updateSql); } $arr_rst['rst'] ='1'; echo json_encode($arr_rst); } function send_notification($tokens, $message) { $url = 'https://fcm.googleapis.com/fcm/send'; $fields = array( 'registration_ids' => $tokens, 'data' => $message ); $key = "AIzaSyCG6QsJex8nT-CVCMaDQL7vKxclJl3_XwI"; $headers = array( 'Authorization:key =' . $key, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $response = curl_exec($ch); curl_close($ch); $json=json_decode($response,true); //NotRegistered = 앱삭제 if($json["success"]) { return "success"; } else { return $response; } } ?>