
<?php $time_h = array("*","1,2,3,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23","*"); $time_m = array("*/5","5,10,15,30,45,50,55","0"); $file_name = array("/home/zen-do/www/zip358.com/index.php","/home/zen-do/www/zip358.com/twitterbot/index-2.php","/home/zen-do/www/zip358.com/twitterbot/index-1.php"); $h = date("H"); $m = intval(date("i")); $cnt = 0; foreach($time_h as $h_ary){ $chk_h = chk($h_ary); if(is_array($chk_h)){ if(chk2($chk_h,$h)){ $chk_m = chk($time_m[$cnt]); if(chk4($chk_m,$time_m[$cnt],$m,$file_name[$cnt])); } }else{ if(chk3($time_h[$cnt],$chk_h,$h)){ $chk_m = chk($time_m[$cnt]); if(chk4($chk_m,$time_m[$cnt],$m,$file_name[$cnt])); } } $cnt++; } function chk($chk_hoge){ if(strcmp($chk_hoge,"*") == 0 ){ return "*"; } if(strstr($chk_hoge,"*/")){ return mb_substr($chk_hoge,2,strlen(chk_hoge)-2); } if(strstr($chk_hoge,",")){ return explode(",",$chk_hoge); } return $chk_hoge; } function chk2($chk_hoge,$H_or_M){ foreach($chk_hoge as $hoge){ if($H_or_M == $hoge){ return true; } } return false; } function chk3($chk_H_or_M,$chk_hoge,$H_or_M){ if(strcmp($chk_hoge,"*") == 0 ){ return true; }elseif(strstr($chk_H_or_M , "*/")){ if($H_or_M % $chk_hoge == 0){ return true; }else{ return false; } }else{ if($H_or_M == $chk_hoge){ return true; }else{ return false; } } return false; } function chk4($chk_hoge,$chk_hoge2,$m,$file_name){ if(is_array($chk_hoge)){ if(chk2($chk_hoge,$m)){ if(shell_exec("/usr/local/bin/php -f ".$file_name))echo "/usr/local/bin/php -f ".$file_name; return true; } }else{ if(chk3($chk_hoge2,$chk_hoge,$m)){ if(shell_exec("/usr/local/bin/php -f ".$file_name))echo " /usr/local/bin/php -f ".$file_name; return true; } } return false; } ?>