<commit_before><?php
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2008 <NAME> <<EMAIL>>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  <NAME> <<EMAIL>>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 * @package jojo_hold_page
 */


class Jojo_Plugin_jojo_hold_page extends Jojo_Plugin {

	function hold_page_check() {
		global $_USERGROUPS;

		// Do we show the hold page?
		if (Jojo::getOption('hold_page_active', 'no') == 'yes') {
			$allowed_groups = self::get_allowed_groups();
			foreach ($allowed_groups as $group) {
				if (in_array($group, $_USERGROUPS)) {
					return array();
				}
			}
			// Check if it's an allowed type of supporting file
			// Now compile the list of allowed types (to prevent doing work before hand if we weren't going to get this far)
			$allowed_files = self::get_allowed_files();
			if (!in_array(pathinfo($_GET['uri'], PATHINFO_EXTENSION), $allowed_files)) {
				self::show_hold_page();
			}
		}
	}

	function get_allowed_groups() {
		$allowed_groups = Jojo::getOption('hold_page_allowed_login_groups', 'admin, owner');
		$allowed_groups = explode(',', strtolower(str_replace(' ', '', $allowed_groups)));
		return $allowed_groups;
	}

	function get_allowed_files() {
		$allowed_files = Jojo::getOption('hold_page_allowed_filetypes');
		$allowed_files = explode(',', strtolower(str_replace(' ', '', $allowed_files)));
		return $allowed_files;
	}

 	function show_hold_page() {
		global $smarty;
		$pageData = Jojo::selectRow(
			"SELECT pg_title,
			        pg_seotitle,
			        pg_body
			   FROM page
			  WHERE pg_link LIKE 'Jojo_Plugin_jojo_hold_page'");

		if (Jojo::getOption('hold_page_status_code') == '503') {
			header('HTTP/1.1 503 Service Unavailable');
		}
		$url = preg_replace('#^login/#', '', $_GET['uri']);
		$content = Jojo::applyFilter('content', $pageData['pg_body']);
		$title = ($pageData['pg_seotitle']) ? $pageData['pg_seotitle'] : $pageData['pg_title'];

		$smarty->assign('held_url', $url);
		$smarty->assign('hold', ($url == $_GET['uri']) ? true : false );
		$smarty->assign('title', $title);
		$smarty->assign('content', $content);

		// Send the anti-cache headers as well as using the meta tags in the template
		header("Cache-Control: no-cache, must-revalidate");
		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
		echo $smarty->fetch('hold-page.tpl');
		exit();
	}
}<commit_msg>Hold Page - Fix for php5.4 errors<commit_after><?php
/**
 *                    Jojo CMS
 *                ================
 *
 * Copyright 2008 <NAME> <<EMAIL>>
 *
 * See the enclosed file license.txt for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 *
 * @author  <NAME> <<EMAIL>>
 * @license http://www.fsf.org/copyleft/lgpl.html GNU Lesser General Public License
 * @link    http://www.jojocms.org JojoCMS
 * @package jojo_hold_page
 */


class Jojo_Plugin_jojo_hold_page extends Jojo_Plugin {

    public static function hold_page_check() {
        global $_USERGROUPS;

        // Do we show the hold page?
        if (Jojo::getOption('hold_page_active', 'no') == 'yes') {
            $allowed_groups = self::get_allowed_groups();
            foreach ($allowed_groups as $group) {
                if (in_array($group, $_USERGROUPS)) {
                    return array();
                }
            }
            // Check if it's an allowed type of supporting file
            // Now compile the list of allowed types (to prevent doing work before hand if we weren't going to get this far)
            $allowed_files = self::get_allowed_files();
            if (!in_array(pathinfo($_GET['uri'], PATHINFO_EXTENSION), $allowed_files)) {
                self::show_hold_page();
            }
        }
    }

    static function get_allowed_groups() {
        $allowed_groups = Jojo::getOption('hold_page_allowed_login_groups', 'admin, owner');
        $allowed_groups = explode(',', strtolower(str_replace(' ', '', $allowed_groups)));
        return $allowed_groups;
    }

    static function get_allowed_files() {
        $allowed_files = Jojo::getOption('hold_page_allowed_filetypes');
        $allowed_files = explode(',', strtolower(str_replace(' ', '', $allowed_files)));
        return $allowed_files;
    }

    static function show_hold_page() {
        global $smarty;
        $pageData = Jojo::selectRow(
            "SELECT pg_title,
                    pg_seotitle,
                    pg_body
               FROM page
              WHERE pg_link LIKE 'Jojo_Plugin_jojo_hold_page'");

        if (Jojo::getOption('hold_page_status_code') == '503') {
            header('HTTP/1.1 503 Service Unavailable');
        }
        $url = preg_replace('#^login/#', '', $_GET['uri']);
        $content = Jojo::applyFilter('content', $pageData['pg_body']);
        $title = ($pageData['pg_seotitle']) ? $pageData['pg_seotitle'] : $pageData['pg_title'];

        $smarty->assign('held_url', $url);
        $smarty->assign('hold', ($url == $_GET['uri']) ? true : false );
        $smarty->assign('title', $title);
        $smarty->assign('content', $content);

        // Send the anti-cache headers as well as using the meta tags in the template
        header("Cache-Control: no-cache, must-revalidate");
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        echo $smarty->fetch('hold-page.tpl');
        exit();
    }
}
{'fraction_non_alphanumeric': 0.15335120643431635, 'fraction_numerical': 0.008936550491510277, 'mean_word_length': 3.0433526011560694, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3172981', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1729, 'n_words': 408}