<?php
/**
 * luffy丶大叔 
 * <><><><><><><><><><><><><>有妹子加微信不哦！~<><><><><><><><><><><><><><><><>
 * $Author: luffy丶大叔 
 * $Z 2015-4-14 16:07:52
 * $email luffy00789@126.com
 * $encoding UTF-8
 * $ Copyright (c) 2014-2015, http://www.globex.cn. All Rights Reserved.
*/
/**
 * 异常管理计划任务
 */

require_once 'config.php';
$flag = APPLICATION_PATH . '/../data/log/ExceptionCron.lock';

if (@file_exists($flag)) {
  echo "Another process is running\r\n";
  echo "{$flag}\r\n";
  exit();
}
$handler = fopen($flag, 'wb');
fclose($handler);
echo '[', date('Y-m-d H:i:s'), '] Start', "\r\n";

$exceptionType  =   Service_ExceptionType::getByCondition(array(
    'et_status'=>1,
    'et_auto'   =>  0,
    'at_that_time'=>true
));

if($exceptionType){
    foreach ($exceptionType as  $value) {
        //处理
        require_once APPLICATION_PATH.'/../libs/Exception.php';
        $cronFunc   =   strtolower($value['et_code']);        
        if(!method_exists('Lib_Exception',$cronFunc)){           
            continue;
        }
        Lib_Exception::$cronFunc();
        Service_ExceptionType::update(array(
            'last_e_time'=>time()
        ), $value['et_code'] , 'et_code');
    }
}

echo '[', date('Y-m-d H:i:s'), '] End', "\r\n";
@unlink($flag);