HTML
1 year ago
views
5 months ago
Apply.php
6 months ago
Cron.php
1 year ago
CronJob.php
7 months ago
CronJobs.php
2 months ago
Crypt.php
1 month ago
DownloadStats.php
5 months ago
Email.php
4 days ago
EmailCron.php
1 year ago
FileSystem.php
1 year ago
Installer.php
4 hours ago
Messages.php
1 year ago
Query.php
4 months ago
Session.php
4 hours ago
Settings.php
4 years ago
SimpleMath.php
4 years ago
TempStorage.php
4 hours ago
Template.php
5 months ago
UI.php
6 months ago
Updater.php
4 years ago
UserAgent.php
2 years ago
__.php
1 month ago
__MailUI.php
3 years ago
SimpleMath.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace WPDM\__; |
| 5 | |
| 6 | |
| 7 | class SimpleMath |
| 8 | { |
| 9 | |
| 10 | static function show(){ |
| 11 | $img = imagecreate(100, 50); |
| 12 | |
| 13 | $textbgcolor = imagecolorallocate($img, 173, 230, 181); |
| 14 | $textcolor = imagecolorallocate($img, 0, 192, 255); |
| 15 | $ops = array('+', '*', '-'); |
| 16 | $op = $ops[random_int(0, 2)]; |
| 17 | $num1 = random_int(1, 9); |
| 18 | $num2 = random_int(1, 9); |
| 19 | self::saveResult($num1, $num2, $op); |
| 20 | $txt = "$num1 $op $num2"; |
| 21 | imagestring($img, 5, 5, 5, $txt, $textcolor); |
| 22 | ob_start(); |
| 23 | imagepng($img); |
| 24 | printf('<div class="w3eden"><div class="input-group"><div class="input-group-prepend"><div class="input-group-text"><img src="data:image/png;base64,%s"/ width="100"></div></div><input type="text" class="form-control"></div></div>', base64_encode(ob_get_clean())); |
| 25 | |
| 26 | } |
| 27 | |
| 28 | private static function saveResult($num1, $num2, $op){ |
| 29 | $result = 0; |
| 30 | if($op == '-') $result = $num1 - $num2; |
| 31 | if($op == '+') $result = $num1 + $num2; |
| 32 | if($op == '*') $result = $num1 * $num2; |
| 33 | Session::set('__wpdm_simplemath_result', $result); |
| 34 | } |
| 35 | |
| 36 | } |
| 37 |