<?php
@set_time_limit(0);
@ignore_user_abort(true);
    $result = mysql_query("SELECT * FROM {$table}query");
    $p2 = @mysql_fetch_array(mysql_query("SELECT * FROM {$table}service_group"));
    while ($row = mysql_fetch_array($result,true)) {
        $r = mysql_fetch_array(mysql_query("SELECT * FROM {$table}members WHERE user='".$row['user']."'"));
        $trobot=mysql_query("SELECT * FROM {$table}service_group WHERE qq='".$r['noticeqq']."'");
        $num_test=mysql_num_rows($trobot);
        if($num_test=='0'){
            $edit=@mysql_query("UPDATE ".$table."members
 SET noticeqq='".$p2[0]."' 
 WHERE user = '".$row['user']."'");
            echo '2&nbsp;|&nbsp;'.$row['user'].'&nbsp;|&nbsp;'.$r['noticeqq'].'<br>';
            continue;
        }
        $p = mysql_fetch_array($trobot);
        echo '1&nbsp;|&nbsp;'.$row['user'].'&nbsp;<=&nbsp;'.$r['noticeqq'].'<br>';
        $iemail = new iemail;
        $ry =$iemail->send($row['email'],$row['head'],$row['message']);
        echo $ry;
        $mqq = new SET_MQQ($p['qq'], $p['password']);
        $rand=$mqq->Login();
        echo $rand.'<br>';
        $rand=json_decode($rand,true);
        if($rand['status']=='ok'){
            $mqq->SendMsg($row['noticeqq'], $row['message']);
            mysql_query("DELETE FROM {$table}query
WHERE `id`='{$row['id']}'");
            continue;
        }
        else{
            echo $p['qq'].' Error!Please Check.'.'<br>';
            mysql_query("DELETE FROM {$table}query
WHERE `id`='{$row['id']}'");
            continue;
        }
        
    }
    $s=(int)date("j")-4;
    $dir = 'data/log/'.date("Y").'-'.date("m").'-'.$s.'.log';
    unlink($dir);
    echo '<br>OK!';