Example #1
0
 /**
  * Event: 'frontcontroller.predispatch'.
  *
  * @param GenericEvent $event
  *
  * @return void
  */
 public function sessionExpired(GenericEvent $event)
 {
     if (\SessionUtil::hasExpired()) {
         // Session has expired, display warning
         header('HTTP/1.0 403 Access Denied');
         $return = \ModUtil::apiFunc('UsersModule', 'user', 'expiredsession');
         \System::shutdown();
     }
 }
Example #2
0
 /**
  * Form Die.
  *
  * @param string $msg Message to echo.
  *
  * @return void
  */
 public function formDie($msg)
 {
     echo $msg;
     System::shutdown(0);
 }
Example #3
0
 /**
  * If enabled and logged in, save login name of user in Apache session variable for Apache logs.
  *
  * Implements 'session.require'.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function requireSession(Zikula_Event $event)
 {
     $session = $this->serviceManager->get('session');
     try {
         $request = ServiceUtil::get('request');
         $request->setSession($session);
     } catch (Exception $e) {
         // ignore silently (for CLI)
     }
     try {
         if (!$session->start()) {
             throw new RuntimeException('Failed to start session');
         }
     } catch (Exception $e) {
         // session initialization failed so display templated error
         header('HTTP/1.1 503 Service Unavailable');
         require_once System::getSystemErrorTemplate('sessionfailed.tpl');
         System::shutdown();
     }
 }
Example #4
0
/**
 * Generate the sanity check page.
 *
 * This function do and generate the stanity check page.
 *
 * @param string $username Username of the admin user.
 * @param string $password Password of the admin user.
 *
 * @return void
 */
function _upg_sanity_check($username, $password)
{
    _upg_header();
    $validupgrade = true;
    if (version_compare(_ZINSTALLEDVERSION, _ZINSTALLVER, '=')) {
        // Already installed the correct version
        $validupgrade = false;
        echo '<h2>' . __('Already up to date') . "</h2>\n";
        echo '<p class="z-errormsg">' . __f("It seems that you have already installed version %s. Please remove this upgrade script, you do not need it anymore.", _ZINSTALLEDVERSION) . "</p>\n";
    } elseif (version_compare(_ZINSTALLEDVERSION, _Z_MINUPGVER, '<')) {
        // Not on version _Z_MINUPGVER yet
        $validupgrade = false;
        echo '<h2>' . __('Possible incompatible version found.') . "</h2>\n";
        echo '<p class="z-warningmsg">' . __f('The current installed version of Zikula is reporting (%1$s). You must upgrade to version (%2$s) before you can use this upgrade.', array(_ZINSTALLEDVERSION, _Z_MINUPGVER)) . "</p>\n";
    } elseif (version_compare(PHP_VERSION, '5.3.0', '>=')) {
        if (ini_get('date.timezone') == '') {
            echo '<p class="z-errormsg"><strong>' . __('date.timezone is currently not set. Since PHP 5.3.0, it needs to be set to a valid timezone in your php.ini such as timezone like UTC, GMT+5, Europe/Berlin.') . "</strong></p>\n";
            echo _upg_continue('sanitycheck', __('Check again'), $username, $password);
            $validupgrade = false;
        }
    }
    if ($validupgrade) {
        $pcreUnicodePropertiesEnabled = @preg_match('/^\\p{L}+$/u', 'TheseAreLetters');
        if (!isset($pcreUnicodePropertiesEnabled) || !$pcreUnicodePropertiesEnabled) {
            // PCRE Unicode property support is not enabled.
            $validupgrade = false;
            echo '<h2>' . __('PCRE Unicode Property Support Needed.') . "</h2>\n";
            echo '<p class="z-errormsg">' . __('The PCRE (Perl Compatible Regular Expression) library being used with your PHP installation does not support Unicode properties. This is required to handle multi-byte character sets in regular expressions. The PCRE library used must be compiled with the \'--enable-unicode-properties\' option.') . "</p>\n";
        }
    }
    if ($validupgrade) {
        $defaultTheme = System::getVar('Default_Theme');
        if ($defaultTheme == 'andreas08') {
            System::setVar('Default_Theme', 'Andreas08');
            $defaultTheme = System::getVar('Default_Theme');
        }
        $dir = is_dir("themes/{$defaultTheme}");
        $casing = preg_match('/\\p{Lu}/u', substr($defaultTheme, 0, 1));
        // first letter is uppercase.
        $underscore = preg_match('/_/', $defaultTheme);
        // has underscore
        if (!$dir || !$casing || $underscore) {
            // The default theme must be installed!
            $validupgrade = false;
            echo '<h2>' . __f("Theme Check Failed", $defaultTheme) . "</h2>\n";
            if (!$dir) {
                echo '<p class="z-errormsg">' . __f("Your configuration specifies a theme called '%s' that doesn't exist.  Please ensure that theme exists in themes/%s", array($defaultTheme, $defaultTheme)) . "</p>\n";
            }
            if (!$casing) {
                echo '<p class="z-errormsg">' . __f("Your configuration specifies a theme called '%s' which begins with a lower case letter.  You must first upgrade the theme's name to start with a capital letter.  This should be done in your 1.2.x installation before attempting this upgrade again.", array($defaultTheme, $defaultTheme)) . "</p>\n";
            }
            if ($underscore) {
                echo '<p class="z-errormsg">' . __f("Your theme called '%s' contains an underscore, this is now deprecated.  You must first upgrade the theme's name so it does not contain any underscore character.  This should be done in your 1.2.x installation before attempting this upgrade again.", array($defaultTheme, $defaultTheme)) . "</p>\n";
            }
        }
    }
    if (!$validupgrade) {
        _upg_footer();
        System::shutdown();
    }
    _upg_continue('upgrademodules', __('Proceed to upgrade (click once and wait)'), $username, $password);
    _upg_footer();
}
Example #5
0
 /**
  * Constructor.
  *
  * @param Zikula_ServiceManager $serviceManager ServiceManager.
  * @param string                $themeName      Theme name.
  */
 public function __construct(Zikula_ServiceManager $serviceManager, $themeName)
 {
     // store our theme information
     $this->themeinfo = ThemeUtil::getInfo(ThemeUtil::getIDFromName($themeName));
     // prevents any case mismatch
     $themeName = $this->themeinfo['name'];
     foreach (array('name', 'directory', 'version', 'state', 'xhtml') as $key) {
         $this->{$key} = $this->themeinfo[$key];
     }
     parent::__construct($serviceManager);
     if ($this->themeinfo['i18n']) {
         ZLanguage::bindThemeDomain($this->name);
         // property for {gt} template plugin to detect language domain
         $this->domain = ZLanguage::getThemeDomain($this->name);
     } else {
         $this->domain = null;
     }
     EventUtil::attachCustomHandlers("themes/{$themeName}/EventHandlers");
     EventUtil::attachCustomHandlers("themes/{$themeName}/lib/{$themeName}/EventHandlers");
     $event = new \Zikula\Core\Event\GenericEvent($this);
     $this->eventManager->dispatch('theme.preinit', $event);
     // change some base settings from our parent class
     // template compilation
     $this->compile_dir = CacheUtil::getLocalDir('Theme_compiled');
     $this->compile_check = ModUtil::getVar('ZikulaThemeModule', 'compile_check');
     $this->force_compile = ModUtil::getVar('ZikulaThemeModule', 'force_compile');
     // template caching
     $this->cache_dir = CacheUtil::getLocalDir('Theme_cache');
     $this->caching = (int) ModUtil::getVar('ZikulaThemeModule', 'enablecache');
     //if ($this->caching) {
     //    $this->cache_modified_check = true;
     //}
     // if caching and is not an admin controller
     if ($this->caching && strpos($this->type, 'admin') !== 0) {
         $modulesnocache = array_filter(explode(',', ModUtil::getVar('ZikulaThemeModule', 'modulesnocache')));
         if (in_array($this->toplevelmodule, $modulesnocache)) {
             $this->caching = Zikula_View::CACHE_DISABLED;
         }
     } else {
         $this->caching = Zikula_View::CACHE_DISABLED;
     }
     // halt caching for write operations to prevent strange things happening
     if (isset($_POST) && count($_POST) != 0) {
         $this->caching = Zikula_View::CACHE_DISABLED;
     }
     // and also for GET operations with csrftoken/authkey
     if (isset($_GET['csrftoken']) || isset($_GET['authkey'])) {
         $this->caching = Zikula_View::CACHE_DISABLED;
     }
     $this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'cache_lifetime');
     if (!$this->homepage) {
         $this->cache_lifetime = ModUtil::getVar('ZikulaThemeModule', 'cache_lifetime_mods');
     }
     // assign all our base template variables
     $this->_base_vars();
     // define the plugin directories
     $this->_plugin_dirs();
     // load the theme configuration
     $this->load_config();
     // check for cached output
     // turn on caching, check for cached output and then disable caching
     // to prevent blocks from being cached
     if ($this->caching && $this->is_cached($this->themeconfig['page'], $this->cache_id)) {
         $this->display($this->themeconfig['page'], $this->cache_id);
         System::shutdown();
     }
     // register page vars output filter
     $this->load_filter('output', 'pagevars');
     // register short urls output filter
     if (System::getVar('shorturls')) {
         $this->load_filter('output', 'shorturls');
     }
     // register trim whitespace output filter if requried
     if (ModUtil::getVar('ZikulaThemeModule', 'trimwhitespace')) {
         $this->load_filter('output', 'trimwhitespace');
     }
     $this->load_filter('output', 'asseturls');
     $event = new \Zikula\Core\Event\GenericEvent($this);
     $this->eventManager->dispatch('theme.init', $event);
     $this->startOutputBuffering();
 }
Example #6
0
function cronShutdown() {
    Zikula_View_Theme::getInstance()->clear_all_cache();
    Zikula_View_Theme::getInstance()->clear_compiled();
    Zikula_View_Theme::getInstance()->clear_cssjscombinecache();
    Zikula_View::getInstance()->clear_all_cache();
    Zikula_View::getInstance()->clear_compiled();

    System::shutdown();

}
Example #7
0
} catch (Zikula_Exception_Fatal $e) {
    $response = new Zikula_Response_Ajax_Fatal($e->getMessage());
} catch (PDOException $e) {
    $response = new Zikula_Response_Ajax_Fatal($e->getMessage());
} catch (Exception $e) {
    $response = new Zikula_Response_Ajax_Fatal($e->getMessage());
}
// Handle database transactions
if (System::getVar('Z_CONFIG_USE_TRANSACTIONS')) {
    if (isset($e) && $e instanceof Exception) {
        $dbConn->rollback();
    } else {
        $dbConn->commit();
    }
}
// Process final response.
// If response is not instanceof Zikula_Response_Ajax_AbstractBase provide compat solution
if (!$response instanceof Zikula_Response_Ajax_AbstractBase) {
    $response = !is_array($response) ? array('data' => $response) : $response;
    $response['statusmsg'] = LogUtil::getStatusMessages();
    if (System::isLegacyMode()) {
        $response['authid'] = SecurityUtil::generateAuthKey(ModUtil::getName());
    }
    $response = json_encode($response);
    header("HTTP/1.1 200 OK");
    header('Content-type: application/json');
}
// Issue response.
echo $response;
System::shutdown();
Example #8
0
    /**
     * Encode data in JSON and return.
     *
     * This functions can add a new authid if requested to do so (default).
     * If the supplied args is not an array, it will be converted to an
     * array with 'data' as key.
     * Authid field will always be named 'authid'. Any other field 'authid'
     * will be overwritten!
     * Script execution stops here
     *
     * @param mixed   $args         String or array of data.
     * @param boolean $createauthid Create a new authid and send it back to the calling javascript.
     * @param boolean $xjsonheader  Send result in X-JSON: header for prototype.js.
     * @param boolean $statusmsg    Include statusmsg in output.
     * @param string  $code         Optional error code, default '200 OK'.
     *
     * @deprecated since 1.3.0
     *
     * @return void
     */
    public static function output($args, $createauthid = false, $xjsonheader = false, $statusmsg = true, $code = '200 OK')
    {
        if (!System::isLegacyMode()) {
            $response = new Zikula_Response_Ajax($args);
            echo $response;
            System::shutDown();
        }
        // Below for reference - to be deleted.

        // check if an error message is set
        $msgs = LogUtil::getErrorMessagesText('<br />');

        if ($msgs != false && !empty($msgs)) {
            self::error($msgs);
        }

        $data = !is_array($args) ? array('data' => $args) : $args;

        if ($statusmsg === true) {
            // now check if a status message is set
            $msgs = LogUtil::getStatusMessagesText('<br />');
            $data['statusmsg'] = $msgs;
        }

        if ($createauthid === true) {
            $data['authid'] = SecurityUtil::generateAuthKey(ModUtil::getName());
        }

        // convert the data to UTF-8 if not already encoded as such
        // Note: this isn't strict test but relying on the site language pack encoding seems to be a good compromise
        if (ZLanguage::getEncoding() != 'utf-8') {
            $data = DataUtil::convertToUTF8($data);
        }

        $output = json_encode($data);

        header("HTTP/1.0 $code");
        header('Content-type: application/json');
        if ($xjsonheader == true) {
            header('X-JSON:(' . $output . ')');
        }
        echo $output;
        System::shutdown();
    }
Example #9
0
 /**
  * loadsmilies
  * returns a html snippet for selecting autosmilies
  *
  */
 public function loadsmilies()
 {
     echo $this->view->fetch('ajax/bbsmiles.tpl');
     System::shutdown();
 }
Example #10
0
 function shutDown()
 {
     System::shutdown();
 }
Example #11
0
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
    // Begin PNphpBB2 Module
    //	global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images;
    global $db, $template, $board_config, $phpbb_theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $images;
    // End PNphpBB2 Module
    global $userdata, $user_ip, $session_length;
    global $starttime;
    if (defined('HAS_DIED')) {
        die("message_die() was called multiple times. This isn't supposed to happen. Was message_die() used in page_tail.php?");
    }
    define('HAS_DIED', 1);
    $sql_store = $sql;
    //
    // Get SQL error if we are debugging. Do this as soon as possible to prevent
    // subsequent queries from overwriting the status of sql_error()
    //
    if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
        $sql_error = $db->sql_error();
        $debug_text = '';
        if ($sql_error['message'] != '') {
            $debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
        }
        if ($sql_store != '') {
            $debug_text .= "<br /><br />{$sql_store}";
        }
        if ($err_line != '' && $err_file != '') {
            $debug_text .= '<br /><br />Line : ' . $err_line . '<br />File : ' . basename($err_file);
        }
    }
    if (empty($userdata) && ($msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR)) {
        $userdata = session_pagestart($user_ip, PAGE_INDEX);
        init_userprefs($userdata);
    }
    //
    // If the header hasn't been output then do it
    //
    if (!defined('HEADER_INC') && $msg_code != CRITICAL_ERROR) {
        if (empty($lang)) {
            if (!empty($board_config['default_lang'])) {
                include $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx;
            } else {
                include $phpbb_root_path . 'language/lang_english/lang_main.' . $phpEx;
            }
        }
        // Begin PNphpBB2 Module
        if (empty($template) || empty($phpbb_theme)) {
            $phpbb_theme = setup_style($board_config['default_style']);
        }
        // End PNphpBB2 Module
        //
        // Load the Page Header
        //
        if (!defined('IN_ADMIN')) {
            include $phpbb_root_path . 'includes/page_header.' . $phpEx;
        } else {
            include $phpbb_root_path . 'admin/page_header_admin.' . $phpEx;
        }
    }
    switch ($msg_code) {
        case GENERAL_MESSAGE:
            if ($msg_title == '') {
                $msg_title = $lang['Information'];
            }
            break;
        case CRITICAL_MESSAGE:
            if ($msg_title == '') {
                $msg_title = $lang['Critical_Information'];
            }
            break;
        case GENERAL_ERROR:
            if ($msg_text == '') {
                $msg_text = $lang['An_error_occured'];
            }
            if ($msg_title == '') {
                $msg_title = $lang['General_Error'];
            }
            break;
        case CRITICAL_ERROR:
            //
            // Critical errors mean we cannot rely on _ANY_ DB information being
            // available so we're going to dump out a simple echo'd statement
            //
            include $phpbb_root_path . 'language/lang_english/lang_main.' . $phpEx;
            if ($msg_text == '') {
                $msg_text = $lang['A_critical_error'];
            }
            if ($msg_title == '') {
                // Begin PNphpBB2 Module
                //				$msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>';
                $msg_title = 'ZphpBB2 : <b>' . $lang['Critical_Error'] . '</b>';
                // End PNphpBB2 Module
            }
            break;
    }
    //
    // Add on DEBUG info if we've enabled debug mode and this is an error. This
    // prevents debug info being output for general messages should DEBUG be
    // set TRUE by accident (preventing confusion for the end user!)
    //
    if (DEBUG && ($msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR)) {
        if ($debug_text != '') {
            $msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text;
        }
    }
    if ($msg_code != CRITICAL_ERROR) {
        if (!empty($lang[$msg_text])) {
            $msg_text = $lang[$msg_text];
        }
        if (!defined('IN_ADMIN')) {
            $template->set_filenames(array('message_body' => 'message_body.tpl'));
        } else {
            $template->set_filenames(array('message_body' => 'admin/admin_message_body.tpl'));
        }
        $template->assign_vars(array('MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text));
        ob_start();
        // ZphpBB2
        $template->pparse('message_body');
        $content = ob_get_contents();
        // ZphpBB2
        ob_end_clean();
        // ZphpBB2
        if (!defined('IN_ADMIN')) {
            include $phpbb_root_path . 'includes/page_tail.' . $phpEx;
        } else {
            echo $content;
            // ZphpBB2
            include $phpbb_root_path . 'admin/page_footer_admin.' . $phpEx;
        }
    } else {
        echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>";
    }
    // ZphpBB2 =>
    if (defined('IN_ADMIN')) {
        exit;
    } else {
        if (Zikula_Core::VERSION_NUM >= '1.4.0') {
            LogUtil::registerStatus($content);
            System::redirect(ModUtil::url('ZphpBB2', 'user', 'message'));
        } else {
            echo $content;
            Zikula_View_Theme::getInstance()->themefooter();
            System::shutdown();
        }
    }
    //exit;
    // <= ZphpBB2
}