Server.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: chendeben
  5. * Date: 2018/8/31
  6. * Time: 下午9:35
  7. */
  8. namespace Heanup\App\Script\Controller;
  9. use Cloudflare\Api;
  10. use Cloudflare\Zone;
  11. use Cloudflare\Zone\Dns;
  12. use Heanup\App\Api\Package\Database\Mail;
  13. use Heanup\App\Script\Controller;
  14. use Heanup\Library\Curl;
  15. use Heanup\Library\Vestacp;
  16. use ProfiCloS\VestaCP\ClientException;
  17. use ProfiCloS\VestaCP\ProcessException;
  18. class Server extends Controller
  19. {
  20. /**
  21. * 执行逻辑
  22. */
  23. protected function main()
  24. {
  25. $whereString = "status=1 AND expired_time<:expired_time";
  26. $where = [
  27. ':expired_time' => date("Y-m-d H:i:s")
  28. ];
  29. $emails = Mail::select([], $where, $whereString);
  30. if ($emails) {
  31. foreach ($emails as $email) {
  32. try {
  33. Vestacp::getInstance()->getModuleMail("admin")->deleteAccount($email['domain'], strtolower($email['email']));
  34. Mail::update(['status'=>0], ['id'=>$email['id']]);
  35. echo sprintf("[%s]\t删除账号成功![%s]\r\n", date("Y-m-d H:i:s"),$email['email'] . "@" . $email['domain']);
  36. } catch (ClientException $e) {
  37. } catch (ProcessException $e) {
  38. }
  39. }
  40. }
  41. $this->checkDomain();
  42. }
  43. public function checkDomain(){
  44. $key = "093fcd440ed453c2689c42150bdb7d5dbc4fb";
  45. // $zone_identifier = "89a0fe0d09762c557fd0c7799efb1c9a";
  46. // $client = new Api('chendeben@qq.com', $key);
  47. $zone=new Zone('chendeben@qq.com', $key);
  48. $data=$zone->zones();
  49. $data=json_decode(json_encode($data),true);
  50. foreach ($data as $item) {
  51. $domain=$item['name'];
  52. $url=sprintf("http://www.%s",$domain);
  53. file_put_contents(APP_DIR."/curl.log", Curl::get($url),FILE_APPEND);
  54. }
  55. }
  56. }