3v4l.org

run code in 300+ PHP versions simultaneously
<?php require_once(WCF_DIR . '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.60.0070.00718.53
8.3.50.0140.00622.82
8.3.40.0110.00418.97
8.3.30.0110.00419.09
8.3.20.0040.00420.43
8.3.10.0040.00423.48
8.3.00.0030.00519.38
8.2.180.0160.00618.54
8.2.170.0120.00922.96
8.2.160.0070.01020.35
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0080.00026.16
8.2.120.0000.00820.92
8.2.110.0000.01020.61
8.2.100.0060.00618.34
8.2.90.0040.00419.30
8.2.80.0000.00817.97
8.2.70.0000.00817.63
8.2.60.0030.00618.16
8.2.50.0030.00618.07
8.2.40.0050.00318.34
8.2.30.0050.00218.16
8.2.20.0040.00417.87
8.2.10.0060.00318.12
8.2.00.0050.00317.94
8.1.280.0090.00625.92
8.1.270.0090.00023.92
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0030.00622.08
8.1.230.0070.00419.24
8.1.220.0000.00917.77
8.1.210.0040.00418.77
8.1.200.0000.00917.48
8.1.190.0000.00817.23
8.1.180.0030.00518.10
8.1.170.0030.00618.78
8.1.160.0080.00022.11
8.1.150.0000.00818.95
8.1.140.0000.00717.44
8.1.130.0030.00317.86
8.1.120.0040.00417.44
8.1.110.0000.00817.42
8.1.100.0020.00517.47
8.1.90.0000.00717.43
8.1.80.0000.00817.46
8.1.70.0000.00717.45
8.1.60.0000.00917.65
8.1.50.0030.00617.50
8.1.40.0030.00617.59
8.1.30.0000.00917.64
8.1.20.0030.00517.67
8.1.10.0000.00817.63
8.1.00.0040.00417.60
8.0.300.0040.00418.77
8.0.290.0000.00816.75
8.0.280.0070.00018.47
8.0.270.0070.00017.39
8.0.260.0060.00317.43
8.0.250.0050.00217.02
8.0.240.0000.00717.10
8.0.230.0040.00417.06
8.0.220.0030.00317.03
8.0.210.0000.00716.95
8.0.200.0030.00316.98
8.0.190.0040.00417.03
8.0.180.0070.00317.09
8.0.170.0000.00817.00
8.0.160.0000.00717.08
8.0.150.0000.01017.09
8.0.140.0080.00017.00
8.0.130.0040.00413.44
8.0.120.0030.00517.00
8.0.110.0030.00517.09
8.0.100.0070.00017.02
8.0.90.0000.00817.05
8.0.80.0090.00616.99
8.0.70.0000.00717.06
8.0.60.0050.00316.91
8.0.50.0050.00216.94
8.0.30.0090.01017.17
8.0.20.0090.01217.40
8.0.10.0040.00417.12
8.0.00.0130.00817.00
7.4.330.0000.00515.10
7.4.320.0060.00016.73
7.4.300.0070.00016.52
7.4.290.0000.00716.63
7.4.280.0030.00816.61
7.4.270.0030.00716.52
7.4.260.0090.00316.54
7.4.250.0000.00816.59
7.4.240.0070.00016.73
7.4.230.0030.00316.64
7.4.220.0070.01316.67
7.4.210.0090.01316.70
7.4.200.0050.00216.64
7.4.160.0030.01416.63
7.4.150.0070.01017.40
7.4.140.0180.01017.86
7.4.130.0150.00216.64
7.4.120.0090.00916.50
7.4.110.0090.00916.79
7.4.100.0030.01416.79
7.4.90.0070.01016.55
7.4.80.0200.00019.39
7.4.70.0100.00616.57
7.4.60.0160.00616.45
7.4.50.0050.00016.39
7.4.40.0060.01016.67
7.4.30.0090.00916.44
7.4.00.0120.00315.14
7.3.330.0060.00013.48
7.3.320.0030.00313.33
7.3.310.0000.00716.49
7.3.300.0040.00416.49
7.3.290.0120.00316.51
7.3.280.0070.01016.48
7.3.270.0070.01017.40
7.3.260.0140.00716.56
7.3.250.0130.00716.57
7.3.240.0110.00616.46
7.3.230.0100.00716.63
7.3.210.0160.00816.43
7.3.200.0030.01419.39
7.3.190.0180.00016.59
7.3.180.0090.01216.43
7.3.170.0110.00516.72
7.3.160.0060.00916.54
7.2.330.0060.01116.71
7.2.320.0170.00616.63
7.2.310.0140.00716.70
7.2.300.0100.00716.66
7.2.290.0030.01416.71
7.2.60.0030.01316.50
7.2.00.0000.01219.01
7.1.200.0060.00615.56
7.1.100.0040.00717.57
7.1.70.0070.01317.01
7.1.60.0090.01619.46
7.1.50.0100.01016.95
7.1.00.0000.08022.43
7.0.200.0000.00916.59
7.0.140.0000.07721.92
7.0.100.0070.03720.00
7.0.90.0170.05320.03
7.0.80.0070.05020.05
7.0.70.0130.04020.08
7.0.60.0000.04720.07
7.0.50.0070.04020.34
7.0.40.0000.07020.03
7.0.30.0000.04320.10
7.0.20.0000.04720.10
7.0.10.0070.04320.09
7.0.00.0030.04320.16
5.6.280.0070.07321.17
5.6.250.0070.04020.61
5.6.240.0200.07320.66
5.6.230.0070.07020.72
5.6.220.0000.04320.63
5.6.210.0100.04320.54
5.6.200.0030.04321.01
5.6.190.0070.04321.00
5.6.180.0100.03721.00
5.6.170.0030.04321.16
5.6.160.0030.04321.17
5.6.150.0030.04021.05
5.6.140.0030.04021.05
5.6.130.0030.04021.12
5.6.120.0000.04720.97
5.6.110.0030.04321.07
5.6.100.0000.04320.99
5.6.90.0070.04021.08
5.6.80.0000.04320.36
5.6.70.0070.03720.44
5.6.60.0100.04320.43
5.6.50.0030.07020.43
5.6.40.0070.08020.45
5.6.30.0070.08020.42
5.6.20.0100.04720.53
5.6.10.0030.04020.47
5.6.00.0130.07320.55
5.5.380.0070.07720.56
5.5.370.0000.07020.45
5.5.360.0070.04020.48
5.5.350.0130.03320.45
5.5.340.0070.04020.85
5.5.330.0070.04320.95
5.5.320.0000.04320.77
5.5.310.0030.04320.77
5.5.300.0000.04320.77
5.5.290.0070.04320.95
5.5.280.0070.03320.96
5.5.270.0070.04020.68
5.5.260.0030.04320.87
5.5.250.0030.03320.73
5.5.240.0000.03720.32
5.5.230.0070.03720.19
5.5.220.0030.07720.16
5.5.210.0070.08020.26
5.5.200.0100.07020.05
5.5.190.0070.08320.22
5.5.180.0170.07020.17
5.5.160.0100.06020.17
5.5.150.0070.08320.27
5.5.140.0030.08020.20
5.5.130.0030.04720.19
5.5.120.0070.07720.19
5.5.110.0070.06720.01
5.5.100.0070.08020.16
5.5.90.0170.04720.16
5.5.80.0170.06720.11
5.5.70.0000.04320.17
5.5.60.0070.06720.13
5.5.50.0100.07720.10
5.5.40.0170.06320.16
5.5.30.0070.06019.97
5.5.20.0070.06720.19
5.5.10.0030.07320.17
5.5.00.0070.06720.09
5.4.450.0030.04019.18
5.4.440.0030.04319.27
5.4.430.0070.02719.46
5.4.420.0030.04019.48
5.4.410.0070.03719.11
5.4.400.0000.04019.01
5.4.390.0030.04318.95
5.4.380.0000.04018.96
5.4.370.0100.04719.21
5.4.360.0100.07019.17
5.4.350.0030.08019.09
5.4.340.0000.08319.09
5.4.320.0170.06319.10
5.4.310.0000.07319.05
5.4.300.0070.07319.04
5.4.290.0030.06719.15
5.4.280.0100.07719.21
5.4.270.0130.05319.03
5.4.260.0070.03319.29
5.4.250.0070.07319.03
5.4.240.0100.05319.12
5.4.230.0030.04319.12
5.4.220.0000.07719.04
5.4.210.0000.08719.24
5.4.200.0030.06319.23
5.4.190.0100.07319.03
5.4.180.0030.07718.84
5.4.170.0130.06018.85
5.4.160.0070.04719.16
5.4.150.0030.08319.11
5.4.140.0070.05716.53
5.4.130.0070.04016.39
5.4.120.0070.07016.39
5.4.110.0030.06716.49
5.4.100.0200.06316.48
5.4.90.0070.07316.33
5.4.80.0070.06016.40
5.4.70.0100.07016.50
5.4.60.0130.06716.30
5.4.50.0030.06716.50
5.4.40.0030.07716.42
5.4.30.0070.07716.37
5.4.20.0130.06716.46
5.4.10.0130.06316.35
5.4.00.0070.05715.95

preferences:
36.04 ms | 401 KiB | 5 Q