PHP????????????????????
???????????? ???????[ 2013/7/11 14:16:36 ] ????????
?????????????????Linux?μ?PHP?????г??????????????????????????ж????????????TCPЭ?鷢?????????????????????????????????????????????????????????????????????????????????????????????????????????ж?????????
?????????????????PHP?????г????????????????????д???????д???????????????PHP????exec()??popen()?????????shell???????????????У????磺
<?php
exec("/bin/sh /opt/zhangyan.sh &");
?>
???????&?????shell????????????С?
??????????????????????????????????????????????·????????????????????????????????????????
--------------------------------------------------------------------------------
??????д?????PHP????/opt/zhangyan.php???????shell????/opt/zhangyan.sh???????????????
??????????????
????1??????/opt/zhangyan.php??????????500????????
????2????/opt/zhangyan.php?????????????????????????????????1?????н?????$p_number=500-1=499??????????????/opt/zhangyan.sh??????????????/opt/zhangyan.sh??????????????????????????
????3????????????????????????0??????н?????$p_number=0????/opt/zhangyan.php????1???????????????ж????/opt/zhangyan.sh???????δ?????????
????4?????1???????/opt/zhangyan.php????????/opt/zhangyan.sh???????????500?????н?????$p_number=0????????????1?????????????
????5?????/opt/zhangyan.php????????δ?????????/opt/zhangyan.sh????????????300????????н?????$p_number=500-300=200???????/opt/zhangyan.php?????????????200??/opt/zhangyan.sh??????
--------------------------------------------------------------------------------
????/opt/zhangyan.php???????£?
<?php
function run($input)
{
global $p_number;
if ($p_number <= 0)
{
$p_number = worker_processes($p_number);
}
$p_number = $p_number - 1;
$out = popen("/bin/sh /opt/zhangyan.sh "{$input}" &"?? "r");
pclose($out);
}
function worker_processes($p_number)
{
$limit = 500;//??????????????????
while ($p_number <= 0)
{
$cmd = popen("ps -ef | grep "/opt/zhangyan.sh" | grep -v grep | wc -l"?? "r");
$line = fread($cmd?? 512);
pclose($cmd);
$p_number = $limit - $line;
if ($p_number <= 0)
{
sleep(1);//???1????
}
}
return $p_number;
}
$input = http://blog.s135.com; //???????????ж??????????
for ($i = 1; $i <= 1000; $i++)
{
run($input);
echo "Idle process number: " . $p_number . "
";
}
?>
??????/opt/zhangyan.php???????????????????ж??1000????????????????/opt/zhangyan.sh????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11