function HwSend($host, $port, $tkey) { set_time_limit(0); ///设置超时时间 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if (false == $socket) { echo "error建立socket失败~!"; } ///建立socket if (false == ($result = socket_connect($socket, $host, $port))) { echo "error链接失败~![{$host}]:{$port}"; } $in = HwCrypt_Encode("100{$tkey}" . Rndkeys(18)); socket_write($socket, $in, strlen($in)); //发送 usleep(30000); socket_close($socket); return 0; }
function VeFileType($type, $Fid) { global $link, $veState; $result = mysql_query('select id,fid,nkey,var,act,tpy,son from conf_tab where fid=' . $Fid, $link); if ($result) { switch ($type) { case '.ini': /*输出ini格式文件*/ $hdat = ''; while ($row = @mysql_fetch_array($result)) { if (strlen($row['nkey']) > 0) { $hdat .= $row['nkey'] . " = \"" . $row['var'] . "\"\n"; } } break; default: /*默认输出ini文件*/ $hdat = ''; $Nodes = array('main' => ''); while ($row = @mysql_fetch_array($result)) { if (strlen($row['nkey']) > 0) { $Nodes[$row['son']] .= $row['nkey'] . ' = "' . $row['var'] . "\"\n"; } else { $Nodes[$row['son']] .= $row['var'] . "\n"; } //如果没有key则直接输出,类似.htaccess正阳的文件 } while ($RetRow = current($Nodes)) { if ('main' != key($Nodes)) { $hdat .= '[' . key($Nodes) . "]\n"; } //默认项节 $hdat .= $RetRow; next($Nodes); } break; } @mysql_free_result($result); /*清除任务*/ //if(!HwExec('delete from task_tab where id='.$Fid)){/*$hdat=HwCrypt_Encode('delete fail ~!');*/}else{/*$hdat=HwCrypt_Encode('Delete yes ~!');*/} } else { $veState = HwCrypt_Encode('Check conf error'); } return $hdat; }
function RunTask() { $hstr = explode("", HGT('info')); $fid = preg_replace('/[^0-9]/', '', $hstr[0]); $node = preg_replace('/[^0-9]/', '', $hstr[1]); if (!empty($node)) { $node = GetColumn("select ip from node_tab where id={$node}"); } else { echo 'error-node: ' . $hstr[1]; exit; } if (!empty($node) && !empty($fid)) { $ftr = HwCheckFile($fid); if (!empty($ftr)) { HwCreateTask($node, $fid, HwCrypt_Encode($ftr)); } } else { echo 'error-idornode'; } }
<?php echo HwCrypt_Encode("Xjy!@0gn-k8Nhtl2Q4") . "\n"; $hdat = "\n"; echo strlen($hdat) . "\n"; echo HwCrypt_Encode($hdat) . "\n";