3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once('http://callofduty.ingame.de/lib/system/event/EventListener.class.php'); /** * 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.70.0090.00616.75
8.3.60.0120.00318.23
8.3.50.0240.00822.95
8.3.40.0130.01018.79
8.3.30.0070.00719.24
8.3.20.0080.00020.20
8.3.10.0040.00423.47
8.3.00.0030.00519.38
8.2.180.0120.00918.66
8.2.170.0100.01022.96
8.2.160.0080.00820.55
8.2.150.0050.00324.18
8.2.140.0080.00024.66
8.2.130.0030.00526.16
8.2.120.0050.00321.02
8.2.110.0030.00620.46
8.2.100.0080.00418.34
8.2.90.0040.00419.26
8.2.80.0000.00817.97
8.2.70.0030.00617.75
8.2.60.0050.00318.17
8.2.50.0110.00018.07
8.2.40.0050.00318.27
8.2.30.0000.00718.18
8.2.20.0040.00417.92
8.2.10.0000.00818.09
8.2.00.0090.00017.85
8.1.280.0060.01025.92
8.1.270.0000.00923.86
8.1.260.0050.00526.35
8.1.250.0040.00428.09
8.1.240.0000.00923.97
8.1.230.0070.00419.29
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0000.01317.35
8.1.190.0030.00517.23
8.1.180.0060.00318.10
8.1.170.0030.00618.77
8.1.160.0000.00822.04
8.1.150.0080.00018.93
8.1.140.0060.00317.50
8.1.130.0030.00317.88
8.1.120.0000.00717.49
8.1.110.0050.00317.44
8.1.100.0000.00717.52
8.1.90.0040.00417.40
8.1.80.0040.00417.39
8.1.70.0000.00717.37
8.1.60.0060.00317.73
8.1.50.0050.00517.56
8.1.40.0040.00417.67
8.1.30.0000.00817.55
8.1.20.0030.00517.80
8.1.10.0060.00317.54
8.1.00.0030.00517.60
8.0.300.0040.00418.77
8.0.290.0040.00417.00
8.0.280.0000.00718.68
8.0.270.0000.00717.38
8.0.260.0000.00817.43
8.0.250.0000.00717.23
8.0.240.0000.00717.18
8.0.230.0000.00717.23
8.0.220.0000.00717.12
8.0.210.0040.00417.04
8.0.200.0070.00017.23
8.0.190.0080.00017.16
8.0.180.0070.00317.13
8.0.170.0000.00817.21
8.0.160.0000.00817.12
8.0.150.0000.00817.11
8.0.140.0020.00517.11
8.0.130.0000.00613.56
8.0.120.0050.00317.12
8.0.110.0000.00717.17
8.0.100.0000.00717.08
8.0.90.0040.00417.00
8.0.80.0070.01017.12
8.0.70.0080.00016.95
8.0.60.0040.00417.08
8.0.50.0030.00517.16
8.0.30.0150.01017.05
8.0.20.0110.01217.40
8.0.10.0000.00816.97
8.0.00.0080.01216.80
7.4.330.0000.00515.04
7.4.320.0030.00316.63
7.4.300.0060.00016.61
7.4.290.0040.00416.62
7.4.280.0070.00316.68
7.4.270.0030.00616.72
7.4.260.0000.00716.72
7.4.250.0040.00416.71
7.4.240.0020.00516.69
7.4.230.0000.00716.72
7.4.220.0150.00516.51
7.4.210.0070.00716.64
7.4.200.0000.00716.55
7.4.160.0040.01216.48
7.4.150.0140.00717.40
7.4.140.0100.00917.86
7.4.130.0120.00516.57
7.4.120.0130.00416.63
7.4.110.0090.00916.54
7.4.100.0070.01016.58
7.4.90.0110.00716.33
7.4.80.0060.01519.39
7.4.70.0120.00416.61
7.4.60.0100.00716.48
7.4.50.0100.00016.41
7.4.40.0140.00316.54
7.4.30.0120.00416.61
7.4.00.0050.01215.08
7.3.330.0060.00013.40
7.3.320.0030.00313.42
7.3.310.0000.00716.22
7.3.300.0030.00316.26
7.3.290.0150.00016.42
7.3.280.0060.01116.39
7.3.270.0110.00617.40
7.3.260.0060.01216.56
7.3.250.0120.00816.50
7.3.240.0100.00616.35
7.3.230.0070.01016.64
7.3.210.0110.00616.38
7.3.200.0070.01119.39
7.3.190.0060.01116.51
7.3.180.0070.01416.37
7.3.170.0120.00416.49
7.3.160.0140.00316.54
7.3.120.0040.01314.62
7.3.110.0070.01014.86
7.3.100.0040.01014.65
7.3.90.0040.01114.74
7.3.80.0050.00614.87
7.3.70.0090.00514.98
7.3.60.0050.00814.74
7.3.50.0020.01114.79
7.3.40.0020.00814.77
7.3.30.0000.00914.72
7.3.20.0060.00516.50
7.3.10.0090.00716.58
7.3.00.0050.00916.47
7.2.330.0150.00316.61
7.2.320.0070.01316.68
7.2.310.0140.00716.39
7.2.300.0080.01116.42
7.2.290.0080.00816.48
7.2.250.0130.00715.00
7.2.240.0050.01214.98
7.2.230.0100.00614.87
7.2.220.0050.00814.87
7.2.210.0030.00914.94
7.2.200.0030.01214.90
7.2.190.0030.01014.80
7.2.180.0090.00414.95
7.2.170.0100.00414.89
7.1.330.0070.00815.63
7.1.320.0030.01015.49
7.1.310.0030.00615.76
7.1.300.0050.00715.70
7.1.290.0040.00815.76
7.1.280.0050.00715.64
7.1.270.0060.00615.71
7.1.260.0040.00915.57
7.1.70.0100.00316.65
7.1.60.0070.01719.46
7.1.50.0110.01116.98
7.1.00.0000.08022.45
7.0.200.0050.00516.55
7.0.140.0030.07322.11
7.0.100.0070.07020.14
7.0.90.0030.08020.07
7.0.80.0130.05720.06
7.0.70.0030.07720.26
7.0.60.0200.05020.02
7.0.50.0070.04020.46
7.0.40.0070.05720.04
7.0.30.0130.07720.03
7.0.20.0130.06720.08
7.0.10.0100.07320.07
7.0.00.0030.04320.04
5.6.280.0030.07321.09
5.6.250.0100.04320.67
5.6.240.0100.07020.71
5.6.230.0000.04720.70
5.6.220.0070.04320.79
5.6.210.0100.04320.69
5.6.200.0070.05021.15
5.6.190.0100.06721.00
5.6.180.0070.04721.16
5.6.170.0200.06721.01
5.6.160.0030.06721.12
5.6.150.0030.05020.96
5.6.140.0030.07721.04
5.6.130.0130.04021.08
5.6.120.0000.04721.14
5.6.110.0100.05721.21
5.6.100.0030.08321.20
5.6.90.0170.07320.99
5.6.80.0070.08020.34
5.6.70.0030.06720.41
5.6.60.0030.06320.36
5.6.50.0200.06320.57
5.6.40.0000.05020.34
5.6.30.0100.07020.36
5.6.20.0070.05320.35
5.6.10.0000.07020.50
5.6.00.0170.05020.55
5.5.380.0030.08020.41
5.5.370.0100.05320.41
5.5.360.0070.06320.45
5.5.350.0100.07320.38
5.5.340.0030.04720.81
5.5.330.0030.05020.69
5.5.320.0030.04320.95
5.5.310.0070.07320.97
5.5.300.0070.05720.95
5.5.290.0070.08020.96
5.5.280.0170.08720.93
5.5.270.0030.05720.85
5.5.260.0130.06020.84
5.5.250.0070.08320.75
5.5.240.0030.06020.24
5.5.230.0100.04720.18
5.5.220.0130.07720.21
5.5.210.0100.07720.18
5.5.200.0070.06020.25
5.5.190.0030.08320.30
5.5.180.0130.06720.26
5.5.160.0070.04020.33
5.5.150.0070.08020.31
5.5.140.0200.06320.29
5.5.130.0070.08320.32
5.5.120.0000.04720.29
5.5.110.0170.07020.29
5.5.100.0030.07020.06
5.5.90.0000.05320.12
5.5.80.0100.03720.11
5.5.70.0070.04320.08
5.5.60.0030.07020.11
5.5.50.0030.07720.11
5.5.40.0030.04720.13
5.5.30.0070.04720.14
5.5.20.0070.04020.09
5.5.10.0130.04020.02
5.5.00.0030.07720.04
5.4.450.0100.07719.49
5.4.440.0030.04719.17
5.4.430.0030.07719.19
5.4.420.0070.04319.52
5.4.410.0100.04319.36
5.4.400.0100.04019.16
5.4.390.0030.10019.25
5.4.380.0070.04018.88
5.4.370.0070.06319.21
5.4.360.0100.07019.12
5.4.350.0000.08019.05
5.4.340.0000.05719.13
5.4.320.0000.04319.22
5.4.310.0000.07718.88
5.4.300.0000.05018.95
5.4.290.0130.07719.23
5.4.280.0030.05019.15
5.4.270.0030.05719.11
5.4.260.0170.06019.04
5.4.250.0070.07718.89
5.4.240.0030.04019.12
5.4.230.0100.04719.22
5.4.220.0100.06019.22
5.4.210.0130.04319.17
5.4.200.0130.06019.12
5.4.190.0030.05319.12
5.4.180.0030.07019.17
5.4.170.0070.04318.89
5.4.160.0130.03719.07
5.4.150.0030.06319.14
5.4.140.0070.04016.27
5.4.130.0000.04016.42
5.4.120.0100.03016.19
5.4.110.0030.04316.56
5.4.100.0070.03316.56
5.4.90.0100.06316.45
5.4.80.0030.03716.47
5.4.70.0100.04016.43
5.4.60.0100.07016.31
5.4.50.0100.08016.50
5.4.40.0100.06316.41
5.4.30.0000.05716.38
5.4.20.0070.03716.37
5.4.10.0100.05316.29
5.4.00.0030.05015.89

preferences:
44.94 ms | 401 KiB | 5 Q