前提・実現したいこと
こちらのカウントダウンタイマーを00:00:00になったら停止するようにしたいのですが
どこを変えれば良いのか教えていただける方お願いします!
元にしたソースはこちらになります
https://github.com/Omgitsonlyalex/EmailCountdown
発生している問題・エラーメッセージ
特にエラーは出てません。
該当のソースコード
php
1<?php 2 3 //Leave all this stuff as it is 4 date_default_timezone_set('Asia/Tokyo'); 5 include 'GIFEncoder.class.php'; 6 include 'php52-fix.php'; 7 $time = $_GET['time']; 8 $future_date = new DateTime(date('r',strtotime($time))); 9 $time_now = time(); 10 $now = new DateTime(date('r', $time_now)); 11 $frames = array(); 12 $delays = array(); 13 14 15 // Your image link 16 $image = imagecreatefrompng('images/countdown.png'); 17 18 $delay = 100;// milliseconds 19 20 $font = array( 21 'size' => 30, // Font size, in pts usually. 22 'angle' => 0, // Angle of the text 23 'x-offset' => 30, // The larger the number the further the distance from the left hand side, 0 to align to the left. 24 'y-offset' => 32, // The vertical alignment, trial and error between 20 and 60. 25 'file' => __DIR__ . DIRECTORY_SEPARATOR . 'Reader-Bold.otf', // Font path 26 'color' => imagecolorallocate($image, 255, 255, 255), // RGB Colour of the text 27 ); 28 for($i = 0; $i <= 60; $i++){ 29 30 $interval = date_diff($future_date, $now); 31 32 if($future_date < $now){ 33 // Open the first source image and add the text. 34 $image = imagecreatefrompng('images/countdown.png'); 35 ; 36 $text = $interval->format('00:00:00'); 37 imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text ); 38 ob_start(); 39 imagegif($image); 40 $frames[]=ob_get_contents(); 41 $delays[]=$delay; 42 $loops = 1; 43 ob_end_clean(); 44 break; 45 } else { 46 // Open the first source image and add the text. 47 $image = imagecreatefrompng('images/countdown.png'); 48 ; 49 $text = $interval->format('%H:%I:%S'); 50 imagettftext ($image , $font['size'] , $font['angle'] , $font['x-offset'] , $font['y-offset'] , $font['color'] , $font['file'], $text ); 51 ob_start(); 52 imagegif($image); 53 $frames[]=ob_get_contents(); 54 $delays[]=$delay; 55 $loops = 0; 56 ob_end_clean(); 57 } 58 59 $now->modify('+1 second'); 60 } 61 62 //expire this image instantly 63 header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); 64 header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); 65 header( 'Cache-Control: no-store, no-cache, must-revalidate' ); 66 header( 'Cache-Control: post-check=0, pre-check=0', false ); 67 header( 'Pragma: no-cache' ); 68 $gif = new AnimatedGif($frames,$delays,$loops); 69 $gif->display();
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
php7.2.10
HTMLメールで使用したいためJSでの制御ができないです。
回答1件
あなたの回答
tips
プレビュー