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 )); } } } ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "WCF_DIR" in /in/bPN6q:3 Stack trace: #0 {main} thrown in /in/bPN6q on line 3
Process exited with code 255.
Output for 7.2.0, 7.3.32 - 7.3.33, 7.4.33
Warning: Use of undefined constant WCF_DIR - assumed 'WCF_DIR' (this will throw an Error in a future version of PHP) in /in/bPN6q on line 3 Warning: require_once(WCF_DIRlib/system/event/EventListener.class.php): failed to open stream: No such file or directory in /in/bPN6q on line 3 Fatal error: require_once(): Failed opening required 'WCF_DIRlib/system/event/EventListener.class.php' (include_path='.:') in /in/bPN6q on line 3
Process exited with code 255.
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.32
Warning: Use of undefined constant WCF_DIR - assumed 'WCF_DIR' (this will throw an Error in a future version of PHP) in /in/bPN6q on line 3 Warning: require_once(): open_basedir restriction in effect. File(WCF_DIRlib/system/event/EventListener.class.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/bPN6q on line 3 Warning: require_once(WCF_DIRlib/system/event/EventListener.class.php): failed to open stream: Operation not permitted in /in/bPN6q on line 3 Fatal error: require_once(): Failed opening required 'WCF_DIRlib/system/event/EventListener.class.php' (include_path='.:') in /in/bPN6q on line 3
Process exited with code 255.
Output for 7.2.6
Warning: Use of undefined constant WCF_DIR - assumed 'WCF_DIR' (this will throw an Error in a future version of PHP) in /in/bPN6q on line 3 Warning: require_once(): open_basedir restriction in effect. File(WCF_DIRlib/system/event/EventListener.class.php) is not within the allowed path(s): (/tmp:/in) in /in/bPN6q on line 3 Warning: require_once(WCF_DIRlib/system/event/EventListener.class.php): failed to open stream: Operation not permitted in /in/bPN6q on line 3 Fatal error: require_once(): Failed opening required 'WCF_DIRlib/system/event/EventListener.class.php' (include_path='.:') in /in/bPN6q on line 3
Process exited with code 255.
Output for 7.1.20
Notice: Use of undefined constant WCF_DIR - assumed 'WCF_DIR' in /in/bPN6q on line 3 Warning: require_once(): open_basedir restriction in effect. File(WCF_DIRlib/system/event/EventListener.class.php) is not within the allowed path(s): (/tmp:/in) in /in/bPN6q on line 3 Warning: require_once(WCF_DIRlib/system/event/EventListener.class.php): failed to open stream: Operation not permitted in /in/bPN6q on line 3 Fatal error: require_once(): Failed opening required 'WCF_DIRlib/system/event/EventListener.class.php' (include_path='.:') in /in/bPN6q on line 3
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10
Notice: Use of undefined constant WCF_DIR - assumed 'WCF_DIR' in /in/bPN6q on line 3 Warning: require_once(WCF_DIRlib/system/event/EventListener.class.php): failed to open stream: No such file or directory in /in/bPN6q on line 3 Fatal error: require_once(): Failed opening required 'WCF_DIRlib/system/event/EventListener.class.php' (include_path='.:') in /in/bPN6q on line 3
Process exited with code 255.

preferences:
193.43 ms | 403 KiB | 271 Q