예제 #1
0
	foreach ($cache->obtain_hooks() as $hook)
	{
		@include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
	}
}
else
{
	$phpbb_hook = false;
}

// Set some standard variables we want to force
$config = array(
	'load_tplcompile'	=> '1'
);

$template->set_custom_template('../adm/style', 'admin');
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');

// the acp template is never stored in the database
$user->theme['template_storedb'] = false;

$install = new module();

$install->create('install', "index.$phpEx", $mode, $sub);
$install->load();

// Generate the page
$install->page_header();
$install->generate_navigation();

$template->set_filenames(array(
예제 #2
0
    ${$var} = $qi_config[$var];
}
// We need some phpBB functions to.
require $phpbb_root_path . 'includes/functions.' . $phpEx;
require $phpbb_root_path . 'includes/constants.' . $phpEx;
require $phpbb_root_path . 'includes/auth.' . $phpEx;
require $phpbb_root_path . 'includes/acm/acm_file.' . $phpEx;
require $phpbb_root_path . 'includes/cache.' . $phpEx;
require $phpbb_root_path . 'includes/functions_install.' . $phpEx;
require $phpbb_root_path . 'includes/session.' . $phpEx;
require $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;
$mode = request_var('mode', 'main');
$qi_install = empty($qi_config) ? true : false;
// We need to set the template here.
$template = new template();
$template->set_custom_template('style', 'qi');
// Create the user.
$user = new user();
// Get and set the language.
$language = !empty($qi_config['qi_lang']) ? $qi_config['qi_lang'] : 'en';
// If there is a language selected in the dropdown menu it's sent as GET, then igonre the hidden POST field.
if (isset($_GET['lang'])) {
    $language = request_var('lang', $language);
} else {
    if (!empty($_POST['sel_lang'])) {
        $language = request_var('sel_lang', $language);
    }
}
$user->lang = file_exists($quickinstall_path . 'language/' . $language) ? $language : 'en';
qi::add_lang(array('qi', 'phpbb'), $quickinstall_path . 'language/' . $user->lang . '/');
// Probably best place to validate the settings
예제 #3
0
function gettemplate($files, $template = false, $template_path = false)
{
    global $user;
    $template_ex = '.tpl.html';
    if ($template === false) {
        return sys_file_read(TEMPLATE_DIR . '/' . $files . $template_ex);
    }
    if (is_string($files)) {
        //    $files = array('body' => $files);
        $files = array(basename($files) => $files);
    }
    if (!is_object($template)) {
        $template = new template();
    }
    //$template->set_custom_template($template_path ? $template_path : TEMPLATE_DIR, TEMPLATE_NAME, TEMPLATE_DIR);
    $tmpl_name = gettemplatename($user['dpath']);
    $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL . 'design/templates/') . $tmpl_name . '/', $tmpl_name, TEMPLATE_DIR);
    foreach ($files as &$filename) {
        $filename = $filename . $template_ex;
    }
    $template->set_filenames($files);
    return $template;
}
예제 #4
0
 /**
  * @param string|string[] $files
  * @param bool|false $template
  * @param bool|false $template_path
  *
  * @return template
  *
  * (c) Gorlum 2015
  */
 public static function get($files, $template = false, $template_path = false)
 {
     !is_object($template) ? $template = new template() : false;
     //$template->set_custom_template($template_path ? $template_path : TEMPLATE_DIR, TEMPLATE_NAME, TEMPLATE_DIR);
     // $tmpl_name = gettemplatename($user['dpath']);
     $template->set_custom_template(($template_path ? $template_path : SN_ROOT_PHYSICAL . 'design/templates/') . DEFAULT_TEMPLATE . '/', DEFAULT_TEMPLATE, TEMPLATE_DIR);
     // TODO ГРЯЗНЫЙ ХАК! Это нужно, что бы по возможности перезаписать инфу из языковых пакетов модулей там, где она была перезаписана раньше инфой из основного пакета. Почему?
     //  - сначала грузятся модули и их языковые пакеты
     //  - затем по ходу дела ОСНОВНОЙ языковой пакет может перезаписать данные из МОДУЛЬНОГО языкового пакета
     // Поэтому и нужен этот грязный хак
     // В норме же - страницы заявляют сами, какие им пакеты нужны. Так что сначала всегда должны грузится основные языковые пакеты, а уже ПОВЕРХ них - пакеты модулей
     //    global $sn_mvc, $sn_page_name;
     //    !empty($sn_mvc['i18n']['']) ? lng_load_i18n($sn_mvc['i18n']['']) : false;
     //    $sn_page_name ? lng_load_i18n($sn_mvc['i18n'][$sn_page_name]) : false;
     if (!empty($files)) {
         is_string($files) ? $files = array(basename($files) => $files) : false;
         foreach ($files as &$filename) {
             $filename = $filename . TEMPLATE_EXTENSION;
         }
         $template->set_filenames($files);
     }
     return $template;
 }
예제 #5
0
    /**
     * 
     * Displays a poll
     * 
     */
    public function get_poll($topicID = 0, $showLink = false, $template = 'prosilver')
    {
        global $db, $user, $auth, $config, $phpEx, $wpUnited, $phpbbForum;
        static $pollHasGenerated = false;
        $fStateChanged = $phpbbForum->foreground();
        if (!$pollHasGenerated) {
            $user->add_lang('viewtopic');
            $pollHasGenerated = true;
        }
        $display = false;
        $ajax = false;
        $inboundVote = array();
        // Is this an AJAX request?
        if ($topicID == 0) {
            $topicID = (int) request_var('pollid', 0);
            $template = (string) request_var('polltemplate', 'prosilver');
            $inboundVote = request_var('vote_id', array('' => 0));
            $display = (int) request_var('display', 0) == 1;
            $ajax = (int) request_var('ajax', 0) == 1;
            $showLink = (int) request_var('showlink', 0) == 1;
        }
        if (!$topicID) {
            return '';
        }
        // Or was this form submitted without JS? If so, which poll was it for? (Unlike in phpBB, there could be more than one)
        if (!$ajax) {
            // submitted:
            if (isset($_POST['update']) && isset($_POST['vote_id'])) {
                $pollID = (int) request_var('pollid', 0);
                if ($pollID == $topicID) {
                    $inboundVote = request_var('vote_id', array('' => 0));
                    // the same poll block could be on the page multiple times. We only want to register the vote once.
                    unset($_POST['update']);
                    unset($_POST['vote_id']);
                }
            }
            // view results link:
            if (isset($_GET['wpupolldisp'])) {
                $pollID = (int) request_var('pollid', 0);
                if ($pollID == $topicID) {
                    $display = 1;
                }
            }
        }
        if (trim($template) == '') {
            $template = 'prosilver';
        }
        $currURL = wpu_get_curr_page_link();
        $pollMarkup = '';
        $actionMsg = '';
        $sql = '
			SELECT t.topic_id, t.topic_title, t.topic_status, t.poll_title, t.poll_start, t.poll_length, 
						t.poll_max_options, t.poll_last_vote, t.poll_vote_change, 
						p.bbcode_bitfield, p.bbcode_uid, 
						t.forum_id, u.user_id, f.forum_name, f.forum_status, u.username, u.user_colour, u.user_type
			FROM ' . TOPICS_TABLE . ' AS t, ' . USERS_TABLE . ' AS u, ' . FORUMS_TABLE . ' AS f, ' . POSTS_TABLE . ' AS p
			WHERE t.topic_poster = u.user_id 
				AND t.forum_id = f.forum_id
				AND t.topic_id = ' . (int) $topicID . ' 
				AND p.post_id = t.topic_first_post_id';
        if (!($result = $db->sql_query($sql))) {
            $phpbbForum->restore_state($fStateChanged);
            wp_die(__('Could not access the database.', 'wp-united'));
        }
        $topicData = $db->sql_fetchrow($result);
        $db->sql_freeresult($result);
        if (!$topicData['poll_start'] || !$auth->acl_get('f_read', $topicData['forum_id'])) {
            $phpbbForum->restore_state($fStateChanged);
            return $pollMarkup;
        }
        $pollOptions = array();
        $sql = '
			SELECT * 
			FROM ' . POLL_OPTIONS_TABLE . ' 
			WHERE topic_id = ' . (int) $topicID;
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            $pollOptions[] = $row;
        }
        $db->sql_freeresult($result);
        $currVotedID = array();
        if ($user->data['is_registered']) {
            $sql = '
				SELECT poll_option_id
				FROM ' . POLL_VOTES_TABLE . '
				WHERE topic_id = ' . (int) $topicID . '
				AND vote_user_id = ' . $user->data['user_id'];
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $currVotedID[] = $row['poll_option_id'];
            }
            $db->sql_freeresult($result);
        } else {
            // Cookie based guest tracking ...
            if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topicID])) {
                $currVotedID = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topicID]);
                $currVotedID = array_map('intval', $currVotedID);
            }
        }
        // Can not vote at all if no vote permission
        $userCanVote = $auth->acl_get('f_vote', $topicData['forum_id']) && ($topicData['poll_length'] != 0 && $topicData['poll_start'] + $topicData['poll_length'] > time() || $topicData['poll_length'] == 0) && $topicData['topic_status'] != ITEM_LOCKED && $topicData['forum_status'] != ITEM_LOCKED && (!sizeof($currVotedID) || $auth->acl_get('f_votechg', $topicData['forum_id']) && $topicData['poll_vote_change']) ? true : false;
        $displayResults = !$userCanVote || $userCanVote && sizeof($currVotedID) || $display ? true : false;
        if (sizeof($inboundVote) && $userCanVote) {
            //  ********   register vote here ********
            if (sizeof($inboundVote) > $topicData['poll_max_options'] || in_array(VOTE_CONVERTED, $currVotedID)) {
                if (!sizeof($inboundVote)) {
                    $actionMsg = $user->lang['NO_VOTE_OPTION'];
                } else {
                    if (sizeof($inboundVote) > $topicData['poll_max_options']) {
                        $actionMsg = $user->lang['TOO_MANY_VOTE_OPTIONS'];
                    } else {
                        if (in_array(VOTE_CONVERTED, $currVotedID)) {
                            $actionMsg = $user->lang['VOTE_CONVERTED'];
                        }
                    }
                }
            } else {
                foreach ($inboundVote as $option) {
                    if (in_array($option, $currVotedID)) {
                        continue;
                    }
                    $sql = '
						UPDATE ' . POLL_OPTIONS_TABLE . '
						SET poll_option_total = poll_option_total + 1
						WHERE poll_option_id = ' . (int) $option . '
							AND topic_id = ' . (int) $topicID;
                    $db->sql_query($sql);
                    if ($user->data['is_registered']) {
                        $sql_ary = array('topic_id' => (int) $topicID, 'poll_option_id' => (int) $option, 'vote_user_id' => (int) $user->data['user_id'], 'vote_user_ip' => (string) $user->ip);
                        $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
                        $db->sql_query($sql);
                    }
                }
                foreach ($currVotedID as $option) {
                    if (!in_array($option, $inboundVote)) {
                        $sql = '
							UPDATE ' . POLL_OPTIONS_TABLE . '
							SET poll_option_total = poll_option_total - 1
							WHERE poll_option_id = ' . (int) $option . '
								AND topic_id = ' . (int) $topicID;
                        $db->sql_query($sql);
                        if ($user->data['is_registered']) {
                            $sql = '
								DELETE FROM ' . POLL_VOTES_TABLE . '
								WHERE topic_id = ' . (int) $topicID . '
									AND poll_option_id = ' . (int) $option . '
									AND vote_user_id = ' . (int) $user->data['user_id'];
                            $db->sql_query($sql);
                        }
                    }
                }
                if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot']) {
                    $user->set_cookie('poll_' . $topicID, implode(',', $inboundVote), time() + 31536000);
                }
                $sql = '
					UPDATE ' . TOPICS_TABLE . '
					SET poll_last_vote = ' . time() . "\n\t\t\t\t\tWHERE topic_id = {$topicID}";
                $db->sql_query($sql);
                $actionMsg = $user->lang['VOTE_SUBMITTED'] . '<br />';
                // Reload vote state:
                $pollOptions = array();
                $sql = '
					SELECT * 
					FROM ' . POLL_OPTIONS_TABLE . ' 
					WHERE topic_id = ' . (int) $topicID;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    $pollOptions[] = $row;
                }
                $db->sql_freeresult($result);
                $currVotedID = $inboundVote;
                $userCanVote = $auth->acl_get('f_votechg', $topicData['forum_id']) && $topicData['poll_vote_change'];
                $displayResults = true;
            }
            // ***** end of vote registration ******
        }
        $pollTotal = 0;
        foreach ($pollOptions as $pollOption) {
            $pollTotal += $pollOption['poll_option_total'];
        }
        $pollBBCode = false;
        if ($topicData['bbcode_bitfield']) {
            require_once $wpUnited->get_setting('phpbb_path') . 'includes/functions_posting.' . $phpEx;
            require_once $wpUnited->get_setting('phpbb_path') . 'includes/bbcode.' . $phpEx;
            $pollBBCode = new bbcode();
        }
        for ($i = 0, $size = sizeof($pollOptions); $i < $size; $i++) {
            $pollOptions[$i]['poll_option_text'] = censor_text($pollOptions[$i]['poll_option_text']);
            if ($pollBBCode !== false) {
                $pollBBCode->bbcode_second_pass($pollOptions[$i]['poll_option_text'], $topicData['bbcode_uid'], $topicData['bbcode_bitfield']);
            }
            $pollOptions[$i]['poll_option_text'] = bbcode_nl2br($pollOptions[$i]['poll_option_text']);
            $pollOptions[$i]['poll_option_text'] = $phpbbForum->parse_phpbb_text_for_smilies($pollOptions[$i]['poll_option_text']);
        }
        $topicData['poll_title'] = $phpbbForum->censor($topicData['poll_title']);
        if ($pollBBCode !== false) {
            $pollBBCode->bbcode_second_pass($topicData['poll_title'], $topicData['bbcode_uid'], $topicData['bbcode_bitfield']);
        }
        $topicData['poll_title'] = bbcode_nl2br($topicData['poll_title']);
        $topicData['poll_title'] = $phpbbForum->parse_phpbb_text_for_smilies($topicData['poll_title']);
        unset($pollBBCode);
        $pollEnd = $topicData['poll_length'] + $topicData['poll_start'];
        $pollLength = $topicData['poll_length'] ? sprintf($user->lang[$pollEnd > time() ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($pollEnd)) : '';
        $topicLink = $phpbbForum->seo ? "topic{$topicID}.html" : "viewtopic.{$phpEx}?t={$topicID}";
        $pTemplate = new template();
        $pTemplate->set_custom_template($wpUnited->get_plugin_path() . 'extras/quickpoll/templates/', 'wpupoll');
        $pTemplate->set_filenames(array('poll' => "{$template}.html"));
        $pTemplate->assign_vars(array('POLL_QUESTION' => $topicData['poll_title'], 'TOTAL_VOTES' => $pollTotal, 'POLL_LEFT_CAP_IMG' => str_replace($wpUnited->get_setting('phpbb_path'), $phpbbForum->get_board_url(), $user->img('poll_left')), 'POLL_RIGHT_CAP_IMG' => str_replace($wpUnited->get_setting('phpbb_path'), $phpbbForum->get_board_url(), $user->img('poll_right')), 'POLL_ID' => $topicID, 'L_MAX_VOTES' => $topicData['poll_max_options'] == 1 ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topicData['poll_max_options']), 'L_POLL_LENGTH' => $actionMsg . $pollLength, 'POLL_TEMPLATE' => $template, 'S_CAN_VOTE' => $userCanVote, 'S_DISPLAY_RESULTS' => $displayResults, 'S_SHOW_LINK' => $showLink, 'U_TOPIC_LINK' => $phpbbForum->get_board_url() . $topicLink, 'L_TOPIC_LINK' => __('View poll in forum', 'wp-united'), 'S_IS_MULTI_CHOICE' => $topicData['poll_max_options'] > 1 ? true : false, 'S_POLL_ACTION' => $currURL, 'U_VIEW_RESULTS' => !strstr($currURL, '?') ? $currURL . '?wpupolldisp=1' : $currURL . '&amp;wpupolldisp=1'));
        foreach ($pollOptions as $pollOption) {
            $optionPct = $pollTotal > 0 ? $pollOption['poll_option_total'] / $pollTotal : 0;
            $optionPctTxt = sprintf("%.1d%%", round($optionPct * 100));
            $pTemplate->assign_block_vars('poll_option', array('POLL_OPTION_ID' => $pollOption['poll_option_id'], 'POLL_OPTION_CAPTION' => $pollOption['poll_option_text'], 'POLL_OPTION_RESULT' => $pollOption['poll_option_total'], 'POLL_OPTION_PERCENT' => $optionPctTxt, 'POLL_OPTION_PCT' => round($optionPct * 100), 'POLL_OPTION_IMG' => str_replace($wpUnited->get_setting('phpbb_path'), $phpbbForum->get_board_url(), $user->img('poll_center', $optionPctTxt, round($optionPct * 250))), 'POLL_OPTION_VOTED' => in_array($pollOption['poll_option_id'], $currVotedID) ? true : false));
        }
        ob_start();
        $pTemplate->display('poll');
        $pollMarkup = ob_get_contents();
        unset($pTemplate);
        ob_end_clean();
        $phpbbForum->restore_state($fStateChanged);
        if ($ajax) {
            wpu_ajax_header();
            echo '<wpupoll>';
            echo '<newnonce>' . wp_create_nonce('wpu-poll-submit') . '</newnonce>';
            echo '<pollid>' . $topicID . '</pollid>';
            echo '<markup><![CDATA[' . base64_encode($pollMarkup) . ']]></markup>';
            echo '</wpupoll>';
            exit;
        }
        return $pollMarkup;
    }
예제 #6
0
function gettemplate($templatename, $is_phpbb = false)
{
    $templatename .= '.tpl';
    if ($is_phpbb) {
        $template = new template();
        $template->set_custom_template(TEMPLATE_DIR, TEMPLATE_NAME);
        $template->set_filenames(array('body' => $templatename));
        return $template;
    } else {
        return ReadFromFile(TEMPLATE_DIR . '/' . $templatename);
    }
}
예제 #7
0
<?php

/**
 * @author John "JohnMaguire2013" Maguire <*****@*****.**>
 * @package BitLuck
 * @version 0.3
 * @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU Lesser General Public License
 */
/* Include configuration */
require_once 'config.inc.php';
/* Include the template engine and set it up */
require_once 'classes/template.php';
$template = new template();
$template->set_custom_template('templates', 'default');
/* Find the pot size to entice viewers */
try {
    $pot_size = number_format($bc->getbalance("Lottery Pot"), 2) . " BTC";
} catch (Exception $e) {
    if ($debug) {
        echo "EXCEPTION: " . $e->getMessage();
    } else {
        die("Sorry, an error occured and we cannot continue processing this page.");
    }
}
/* Site name */
$template->assign_vars(array('SITENAME' => 'BitLuck', 'DONATE' => '16nCPK6mx4WxSzbAQQCU7Sh9XTzDHDwB63', 'TOTALPOT' => $pot_size, 'OWNERPERCENTAGE' => $owner_fee * 100, 'WINNERPERCENTAGE' => 100 - $owner_fee * 100, 'DRAWTIME' => $draw_time, 'COST' => $ticket_cost));
/* Load up the header to be used on each page */
$template->set_filenames(array('header' => 'site_header.html'));
if (isset($_POST['submit'])) {
    /* Check if the address was valid */
    try {