3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface EventListener { /** * Executes this action. * * @param object $eventObj * @param string $className * @param string $eventName */ public function execute($eventObj, $className, $eventName); } /** * Handles activation of the thank'o'mat in postcreation and editing * * @author Christian "Plunts" Grubert * @copyright 2010 Duetschi Kreativagentur * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> * @package de.wbb3mods.wbb.thankbot */ class ThreadAddFormThankBotListener implements EventListener { const THANKS_AUTOENABLE_NONE = 0; const THANKS_AUTOENABLE_THREAD = 1; const THANKS_AUTOENABLE_ALL = 2; protected $eventObj; protected $className; protected $hasThank = -1; protected $saveThankSetting = false; protected $autoEnableThankomat = -1; /** * @see EventListener::execute() */ public function execute($eventObj, $className, $eventName) { $this->eventObj = $eventObj; $this->className = $className; if ($this->autoEnableThankomat == -1) { $this->autoEnableThankomat = THANKS_AUTOENABLE; if ($this->autoEnableThankomat > 0) { // check if thankomat is only disabled for this forum! if (WCF::getUser()->getPermission('user.board.canActivateThank') && !$this->eventObj->board->getPermission('canActivateThank')) { // global right = true, board right = false $this->autoEnableThankomat = 0; } } if (THANKS_ALLOW_SAVE_AUTOENABLE) { $userOption = WCF::getUser()->autoEnableThankomat; if ($userOption > 0) { $this->autoEnableThankomat = $userOption - 1; } } } switch ($eventName) { case 'readData': $this->readData(); break; case 'readFormParameters': $this->readFormParameters(); break; case 'assignVariables': $this->assignVariables(); break; case 'saved': $this->saved(); break; } } private function checkHasThank() { if ($this->hasThank == -1) { if ($this->autoEnableThankomat == self::THANKS_AUTOENABLE_THREAD && ($this->className == 'ThreadAddForm' || (isset($this->eventObj->post, $this->eventObj->thread) && $this->eventObj->post->postID == $this->eventObj->thread->firstPostID))) $this->hasThank = 1; elseif ($this->autoEnableThankomat == self::THANKS_AUTOENABLE_ALL) $this->hasThank = 1; else $this->hasThank = 0; } } private function readData() { if (!count($_POST)) { $this->hasThank = $this->eventObj->post->hasThank; } } private function readFormParameters() { $this->checkHasThank(); if ($this->eventObj->board->getPermission('canActivateThank') && $this->className != 'PostQuickAddForm') { if (isset($_REQUEST['hasThank'])) $this->hasThank = intval($_REQUEST['hasThank']); else $this->hasThank = 0; } if (isset($_REQUEST['saveThankSetting'])) $this->saveThankSetting = (intval($_REQUEST['saveThankSetting']) != 0); } private function assignVariables() { if (THANKS_FIRSTPOSTONLY && $this->className != 'ThreadAddForm' && (!isset($this->eventObj->postID) || $this->eventObj->postID != $this->eventObj->thread->firstPostID)) { return; } if ($this->eventObj->board->getPermission('canActivateThank')) { $this->checkHasThank(); WCF::getTPL()->assign(array( 'hasThank' => $this->hasThank, 'saveThankSetting' => $this->saveThankSetting, 'autoEnableThankomat' => $this->autoEnableThankomat )); $additionalSettings = WCF::getTPL()->fetch('postThankSetting'); WCF::getTPL()->append(THANKS_POSITION, $additionalSettings); } } private function saved() { if (THANKS_FIRSTPOSTONLY && $this->className != 'ThreadAddForm' && (!isset($this->eventObj->postID) || $this->eventObj->postID != $this->eventObj->thread->firstPostID)) { return; } // Bedanko beim bearbeiten nicht deaktivieren, wenn die Rechte fehlen! if ($this->className == 'PostEditForm' && !$this->eventObj->board->getPermission('canActivateThank')) { return; } $postID = 0; switch ($this->className) { case 'ThreadAddForm': $postID = $this->eventObj->newThread->firstPostID; break; case 'PostAddForm': case 'PostQuickAddForm': $postID = $this->eventObj->newPost->postID; break; case 'PostEditForm': $postID = $this->eventObj->postID; break; } $sql = "UPDATE wbb" . WBB_N . "_post SET hasThank = " . intval($this->hasThank) . " WHERE postID = " . intval($postID); WCF::getDB()->sendQuery($sql); if (THANKS_ALLOW_SAVE_AUTOENABLE && $this->saveThankSetting) { WCF::getUser()->getEditor()->updateOptions(array( 'autoEnableThankomat' => $this->hasThank == 0 ? self::THANKS_AUTOENABLE_NONE + 1 : self::THANKS_AUTOENABLE_ALL + 1 )); } } } ?>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0090.00918.33
8.3.50.0060.00922.79
8.3.40.0110.00718.79
8.3.30.0110.00318.98
8.3.20.0060.00320.33
8.3.10.0060.00323.67
8.3.00.0040.00419.26
8.2.180.0090.00918.17
8.2.170.0070.00722.96
8.2.160.0060.01020.52
8.2.150.0040.00424.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0000.00820.91
8.2.110.0070.00320.55
8.2.100.0060.00618.22
8.2.90.0040.00419.35
8.2.80.0030.00517.97
8.2.70.0100.00017.75
8.2.60.0000.00818.03
8.2.50.0080.00418.07
8.2.40.0030.00518.28
8.2.30.0050.00317.98
8.2.20.0080.00017.66
8.2.10.0040.00418.21
8.2.00.0000.00717.77
8.1.280.0090.01225.92
8.1.270.0030.00623.96
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00023.70
8.1.230.0080.00319.22
8.1.220.0090.00017.77
8.1.210.0000.00818.77
8.1.200.0060.00617.35
8.1.190.0040.00417.22
8.1.180.0060.00318.10
8.1.170.0040.00418.62
8.1.160.0030.00622.11
8.1.150.0000.00718.97
8.1.140.0040.00417.55
8.1.130.0040.00417.87
8.1.120.0000.00717.50
8.1.110.0050.00217.45
8.1.100.0000.00717.39
8.1.90.0040.00417.50
8.1.80.0080.00017.50
8.1.70.0030.00317.33
8.1.60.0080.00017.61
8.1.50.0090.00017.49
8.1.40.0030.00617.46
8.1.30.0040.00417.57
8.1.20.0040.00417.68
8.1.10.0050.00317.50
8.1.00.0040.00417.46
8.0.300.0040.00418.77
8.0.290.0070.00016.72
8.0.280.0030.00318.49
8.0.270.0080.00017.36
8.0.260.0000.00717.24
8.0.250.0000.00716.99
8.0.240.0000.00717.00
8.0.230.0000.00716.97
8.0.220.0030.00316.82
8.0.210.0000.00716.87
8.0.200.0000.00617.03
8.0.190.0040.00416.87
8.0.180.0050.00516.84
8.0.170.0050.00317.00
8.0.160.0000.00816.84
8.0.150.0030.00616.79
8.0.140.0040.00416.89
8.0.130.0060.00013.33
8.0.120.0080.00016.92
8.0.110.0000.00716.92
8.0.100.0000.00716.93
8.0.90.0000.00817.00
8.0.80.0070.01017.00
8.0.70.0060.00316.77
8.0.60.0030.00516.91
8.0.50.0050.00316.88
8.0.30.0080.01217.07
8.0.20.0140.01317.40
8.0.10.0030.00616.93
8.0.00.0110.01116.75
7.4.330.0000.00515.05
7.4.320.0000.00616.47
7.4.300.0030.00316.57
7.4.290.0030.00316.66
7.4.280.0030.00716.54
7.4.270.0030.00716.66
7.4.260.0070.00016.57
7.4.250.0050.00316.52
7.4.240.0010.00616.59
7.4.230.0040.00416.45
7.4.220.0140.01116.69
7.4.210.0090.00616.54
7.4.200.0040.00416.41
7.4.160.0140.01416.67
7.4.150.0090.00917.40
7.4.140.0120.00817.86
7.4.130.0090.00916.68
7.4.120.0080.00916.53
7.4.110.0170.00716.61
7.4.100.0070.01016.45
7.4.90.0120.00616.58
7.4.80.0060.01219.39
7.4.70.0040.01216.45
7.4.60.0100.01016.55
7.4.50.0040.00416.51
7.4.40.0050.01116.55
7.4.30.0070.01016.62
7.4.00.0070.01115.00
7.3.330.0020.00313.26
7.3.320.0030.00313.23
7.3.310.0080.00016.17
7.3.300.0060.00016.11
7.3.290.0090.01216.27
7.3.280.0050.01116.24
7.3.270.0060.01017.40
7.3.260.0110.00716.36
7.3.250.0080.01216.43
7.3.240.0130.00316.47
7.3.230.0090.00916.42
7.3.210.0130.00416.60
7.3.200.0030.01319.39
7.3.190.0070.01016.52
7.3.180.0140.00916.25
7.3.170.0090.01216.48
7.3.160.0070.00916.34
7.2.330.0180.00416.53
7.2.320.0090.00916.70
7.2.310.0090.01216.76
7.2.300.0070.01116.74
7.2.290.0060.01016.38
7.1.70.0110.00416.81
7.1.60.0140.01119.46
7.1.50.0110.00816.69
7.1.00.0000.08022.52
7.0.200.0040.00416.60
7.0.140.0070.06722.08
7.0.100.0200.04320.03
7.0.90.0170.07319.96
7.0.80.0170.07719.95
7.0.70.0200.06719.95
7.0.60.0130.06720.05
7.0.50.0130.07020.41
7.0.40.0000.10020.09
7.0.30.0200.07720.05
7.0.20.0000.05320.13
7.0.10.0030.06720.13
7.0.00.0070.04320.16
5.6.280.0070.07021.10
5.6.250.0070.04320.77
5.6.240.0030.04020.65
5.6.230.0000.05020.65
5.6.220.0070.04320.73
5.6.210.0100.06720.80
5.6.200.0030.08721.13
5.6.190.0030.05021.01
5.6.180.0030.05021.07
5.6.170.0070.08321.09
5.6.160.0070.08321.21
5.6.150.0100.08020.99
5.6.140.0030.07321.18
5.6.130.0070.08720.98
5.6.120.0130.08021.01
5.6.110.0070.08021.04
5.6.100.0170.05321.07
5.6.90.0100.07721.02
5.6.80.0100.03720.45
5.6.70.0070.08720.36
5.6.60.0000.04720.37
5.6.50.0100.04020.48
5.6.40.0000.05320.45
5.6.30.0030.08020.52
5.6.20.0000.04320.46
5.6.10.0070.04020.54
5.6.00.0030.04320.34
5.5.380.0100.07320.50
5.5.370.0070.04320.41
5.5.360.0130.05020.46
5.5.350.0030.05020.47
5.5.340.0030.05020.84
5.5.330.0030.04720.92
5.5.320.0100.08320.86
5.5.310.0170.06020.92
5.5.300.0200.07320.85
5.5.290.0000.05020.85
5.5.280.0100.04320.88
5.5.270.0100.07720.95
5.5.260.0200.07020.93
5.5.250.0070.08720.73
5.5.240.0000.07720.08
5.5.230.0070.05320.32
5.5.220.0070.08020.18
5.5.210.0100.06320.32
5.5.200.0130.06720.32
5.5.190.0070.04320.31
5.5.180.0130.06720.29
5.5.160.0030.04020.23
5.5.150.0100.04720.32
5.5.140.0070.06320.23
5.5.130.0100.03720.30
5.5.120.0070.06320.04
5.5.110.0100.05320.16
5.5.100.0070.08320.21
5.5.90.0000.07020.21
5.5.80.0000.04320.09
5.5.70.0030.04020.21
5.5.60.0030.04020.01
5.5.50.0170.05720.04
5.5.40.0070.07320.07
5.5.30.0070.08320.09
5.5.20.0070.04020.04
5.5.10.0100.03720.18
5.5.00.0030.08020.16
5.4.450.0070.04019.38
5.4.440.0030.08719.50
5.4.430.0130.03719.45
5.4.420.0100.07319.45
5.4.410.0070.06019.10
5.4.400.0100.03319.17
5.4.390.0070.04018.94
5.4.380.0030.05718.87
5.4.370.0070.05018.96
5.4.360.0070.06718.85
5.4.350.0070.07319.09
5.4.340.0000.03718.94
5.4.320.0070.06319.18
5.4.310.0070.07318.90
5.4.300.0070.07319.05
5.4.290.0070.04719.04
5.4.280.0070.07319.18
5.4.270.0030.05718.87
5.4.260.0000.07019.04
5.4.250.0070.07318.87
5.4.240.0030.07719.02
5.4.230.0030.06019.08
5.4.220.0070.08319.03
5.4.210.0070.07719.16
5.4.200.0130.07019.02
5.4.190.0070.06319.07
5.4.180.0100.07718.85
5.4.170.0030.07319.01
5.4.160.0070.07319.23
5.4.150.0130.06019.11
5.4.140.0070.05316.52
5.4.130.0000.05016.47
5.4.120.0030.05716.31
5.4.110.0030.05016.33
5.4.100.0030.03716.57
5.4.90.0030.04016.38
5.4.80.0030.07316.47
5.4.70.0030.07316.31
5.4.60.0030.03316.52
5.4.50.0070.07316.41
5.4.40.0030.03716.42
5.4.30.0100.06316.41
5.4.20.0030.04016.46
5.4.10.0030.07716.52
5.4.00.0000.03715.92

preferences:
40.95 ms | 401 KiB | 5 Q