/**
  * Create a new session.
  *
  * @param int The user id to bind the session to.
  */
 function create_session($uid = 0)
 {
     global $db;
     $speciallocs = $this->get_special_locations();
     // If there is a proper uid, delete by uid.
     if ($uid > 0) {
         $db->delete_query("sessions", "uid='{$uid}'");
         $onlinedata['uid'] = $uid;
     } else {
         if ($this->is_spider == true) {
             $db->delete_query("sessions", "sid='{$this->sid}'");
         } else {
             $db->delete_query("sessions", "ip='" . $db->escape_string($this->ipaddress) . "'");
             $onlinedata['uid'] = 0;
         }
     }
     // If the user is a search enginge spider, ...
     if ($this->is_spider == true) {
         $onlinedata['sid'] = $this->sid;
     } else {
         $onlinedata['sid'] = md5(uniqid(microtime()));
     }
     $onlinedata['time'] = TIME_NOW;
     $onlinedata['ip'] = $db->escape_string($this->ipaddress);
     $onlinedata['location'] = $db->escape_string(get_current_location());
     $onlinedata['useragent'] = $db->escape_string($this->useragent);
     $onlinedata['location1'] = intval($speciallocs['1']);
     $onlinedata['location2'] = intval($speciallocs['2']);
     $onlinedata['nopermission'] = 0;
     $db->replace_query("sessions", $onlinedata, "sid", false);
     $this->sid = $onlinedata['sid'];
     $this->uid = $onlinedata['uid'];
 }
Beispiel #2
0
/**
 * Default configuration
 */
function configure()
{
    global $output, $mybb, $errors, $lang;
    $output->print_header($lang->board_config, 'config');
    echo <<<EOF
\t\t<script type="text/javascript">\t
\t\tfunction warnUser(inp, warn)
\t\t{
\t\t\tvar parenttr = \$('#'+inp.id).closest('tr');
\t\t\tif(inp.value != inp.defaultValue)
\t\t\t{
\t\t\t\tif(!parenttr.next('.setting_peeker').length)
\t\t\t\t{
\t\t\t\t\tvar revertlink = ' <a href="javascript:revertSetting(\\''+inp.defaultValue+'\\', \\'#'+inp.id+'\\');">{$lang->config_step_revert}</a>';
\t\t\t\t\tparenttr.removeClass('last').after('<tr class="setting_peeker"><td colspan="2">'+warn+revertlink+'</td></tr>');
\t\t\t\t}
\t\t\t} else {
\t\t\t\tparenttr.next('.setting_peeker').remove();
\t\t\t\tif(parenttr.is(':last-child'))
\t\t\t\t{
\t\t\t\t\tparenttr.addClass('last');
\t\t\t\t}
\t\t\t}
\t\t}
\t\t\t
\t\tfunction revertSetting(defval, inpid)
\t\t{
\t\t\t\$(inpid).val(defval);\t\t\t
\t\t\tvar parenttr = \$(inpid).closest('tr');
\t\t\tparenttr.next('.setting_peeker').remove();
\t\t\tif(parenttr.is(':last-child'))
\t\t\t{
\t\t\t\tparenttr.addClass('last');
\t\t\t}\t\t\t
\t\t}
\t\t</script>
\t\t
EOF;
    // If board configuration errors
    if (is_array($errors)) {
        $error_list = error_list($errors);
        echo $lang->sprintf($lang->config_step_error_config, $error_list);
        $bbname = htmlspecialchars_uni($mybb->get_input('bbname'));
        $bburl = htmlspecialchars_uni($mybb->get_input('bburl'));
        $websitename = htmlspecialchars_uni($mybb->get_input('websitename'));
        $websiteurl = htmlspecialchars_uni($mybb->get_input('websiteurl'));
        $cookiedomain = htmlspecialchars_uni($mybb->get_input('cookiedomain'));
        $cookiepath = htmlspecialchars_uni($mybb->get_input('cookiepath'));
        $contactemail = htmlspecialchars_uni($mybb->get_input('contactemail'));
    } else {
        $bbname = 'Forums';
        $cookiedomain = '';
        $websitename = 'Your Website';
        $protocol = "http://";
        if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") {
            $protocol = "https://";
        }
        // Attempt auto-detection
        if ($_SERVER['HTTP_HOST']) {
            $hostname = $protocol . $_SERVER['HTTP_HOST'];
            $cookiedomain = $_SERVER['HTTP_HOST'];
        } elseif ($_SERVER['SERVER_NAME']) {
            $hostname = $protocol . $_SERVER['SERVER_NAME'];
            $cookiedomain = $_SERVER['SERVER_NAME'];
        }
        if (my_substr($cookiedomain, 0, 4) == "www.") {
            $cookiedomain = substr($cookiedomain, 4);
        }
        // IP addresses and hostnames are not valid
        if (my_inet_pton($cookiedomain) !== false || strpos($cookiedomain, '.') === false) {
            $cookiedomain = '';
        } else {
            $cookiedomain = ".{$cookiedomain}";
        }
        if ($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 && !preg_match("#:[0-9]#i", $hostname)) {
            $hostname .= ':' . $_SERVER['SERVER_PORT'];
        }
        $currentlocation = get_current_location('', '', true);
        $noinstall = substr($currentlocation, 0, strrpos($currentlocation, '/install/'));
        $cookiepath = $noinstall . '/';
        $bburl = $hostname . $noinstall;
        $websiteurl = $hostname . '/';
        $contactemail = $_SERVER['SERVER_ADMIN'];
    }
    echo $lang->sprintf($lang->config_step_table, $bbname, $bburl, $websitename, $websiteurl, $cookiedomain, $cookiepath, $contactemail);
    $output->print_footer('adminuser');
}
Beispiel #3
0
define("ADMIN_IP_SEGMENTS", 0);
require_once dirname(dirname(__FILE__)) . "/inc/init.php";
$shutdown_queries = $shutdown_functions = array();
send_page_headers();
if (!isset($config['admin_dir']) || !file_exists(MYBB_ROOT . $config['admin_dir'] . "/inc/class_page.php")) {
    $config['admin_dir'] = basename(dirname(__FILE__));
}
define('MYBB_ADMIN_DIR', MYBB_ROOT . $config['admin_dir'] . '/');
define('COPY_YEAR', my_date('Y', TIME_NOW));
require_once MYBB_ADMIN_DIR . "inc/class_page.php";
require_once MYBB_ADMIN_DIR . "inc/class_form.php";
require_once MYBB_ADMIN_DIR . "inc/class_table.php";
require_once MYBB_ADMIN_DIR . "inc/functions.php";
require_once MYBB_ROOT . "inc/functions_user.php";
// Set cookie path to our admin dir temporarily, i.e. so that it affects the ACP only
$loc = get_current_location('', '', true);
$mybb->settings['cookiepath'] = substr($loc, 0, strrpos($loc, "/{$config['admin_dir']}/")) . "/{$config['admin_dir']}/";
if (!isset($cp_language)) {
    if (!file_exists(MYBB_ROOT . "inc/languages/" . $mybb->settings['cplanguage'] . "/admin/home_dashboard.lang.php")) {
        $mybb->settings['cplanguage'] = "english";
    }
    $lang->set_language($mybb->settings['cplanguage'], "admin");
}
// Load global language phrases
$lang->load("global");
$lang->load("messages", true);
if (function_exists('mb_internal_encoding') && !empty($lang->settings['charset'])) {
    @mb_internal_encoding($lang->settings['charset']);
}
header("Content-type: text/html; charset={$lang->settings['charset']}");
$time = TIME_NOW;
function configure()
{
    global $output, $mybb, $errors, $lang;
    $output->print_header($lang->board_config, 'config');
    // If board configuration errors
    if (is_array($errors)) {
        $error_list = error_list($errors);
        echo $lang->sprintf($lang->config_step_error_config, $error_list);
        $bbname = htmlspecialchars_uni($mybb->input['bbname']);
        $bburl = htmlspecialchars_uni($mybb->input['bburl']);
        $websitename = htmlspecialchars_uni($mybb->input['websitename']);
        $websiteurl = htmlspecialchars_uni($mybb->input['websiteurl']);
        $cookiedomain = htmlspecialchars_uni($mybb->input['cookiedomain']);
        $cookiepath = htmlspecialchars_uni($mybb->input['cookiepath']);
        $contactemail = htmlspecialchars_uni($mybb->input['contactemail']);
    } else {
        $bbname = 'Forums';
        $cookiedomain = '';
        $cookiepath = '/';
        $websiteurl = $hostname . '/';
        $websitename = 'Your Website';
        $contactemail = '';
        $protocol = "http://";
        if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off" || substr($bburl, 0, 5) == "https") {
            $protocol = "https://";
        }
        // Attempt auto-detection
        if ($_SERVER['HTTP_HOST']) {
            $hostname = $protocol . $_SERVER['HTTP_HOST'];
            $cookiedomain = '.' . $_SERVER['HTTP_HOST'];
        } elseif ($_SERVER['SERVER_NAME']) {
            $hostname = $protocol . $_SERVER['SERVER_NAME'];
            $cookiedomain = '.' . $_SERVER['SERVER_NAME'];
        }
        if (substr($cookiedomain, 0, 5) == ".www.") {
            $cookiedomain = my_substr($cookiedomain, 4);
        }
        if ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'localhost' || ip2long($_SERVER['SERVER_NAME']) != false) {
            $cookiedomain = '';
        }
        if ($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 && !preg_match("#:[0-9]#i", $hostname)) {
            $hostname .= ':' . $_SERVER['SERVER_PORT'];
        }
        $currentlocation = get_current_location();
        if ($currentlocation) {
            // TODO: Change this to find the last position of /install/
            $pos = my_strpos($currentlocation, '/install/');
            if ($pos === 0) {
                $cookiepath = "/";
            } else {
                $cookiepath = my_substr($currentlocation, 0, $pos) . '/';
            }
        }
        $currentscript = $hostname . get_current_location();
        if ($currentscript) {
            $bburl = my_substr($currentscript, 0, my_strpos($currentscript, '/install/'));
        }
        if ($_SERVER['SERVER_ADMIN']) {
            $contactemail = $_SERVER['SERVER_ADMIN'];
        }
    }
    echo $lang->sprintf($lang->config_step_table, $bbname, $bburl, $websitename, $websiteurl, $cookiedomain, $cookiepath, $contactemail);
    $output->print_footer('adminuser');
}
Beispiel #5
0
/**
 * Google SEO URL hook.
 *
 * Converts requested Google SEO URLs back to the ID number parameters
 * which are required and expected by stock MyBB to find the correct
 * forum / thread / etc. to display.
 *
 * This is also the point where Google SEO updates the URLs in case
 * the requested item changed its name since the last update.
 */
function google_seo_url_hook()
{
    global $db, $mybb, $settings;
    // Translate URL name to ID and verify.
    switch (THIS_SCRIPT) {
        case 'forumdisplay.php':
            // Translation.
            $url = google_seo_url_dynamic($mybb->input['google_seo_forum']);
            if (strlen($url) && !array_key_exists('fid', $mybb->input)) {
                $fid = google_seo_url_id(GOOGLE_SEO_FORUM, $url);
                $mybb->input['fid'] = $fid;
                $location = get_current_location();
                $location = str_replace("google_seo_forum={$url}", "fid={$fid}", $location);
            }
            // Verification.
            $fid = (int) $mybb->input['fid'];
            if ($fid) {
                google_seo_url_create(GOOGLE_SEO_FORUM, $fid);
            }
            break;
        case 'showthread.php':
            // Translation.
            $url = google_seo_url_dynamic($mybb->input['google_seo_thread']);
            if (strlen($url) && !array_key_exists('tid', $mybb->input)) {
                $tid = google_seo_url_id(GOOGLE_SEO_THREAD, $url);
                $mybb->input['tid'] = $tid;
                $location = get_current_location();
                $location = str_replace("google_seo_thread={$url}", "tid={$tid}", $location);
            }
            // Verification.
            $tid = (int) $mybb->input['tid'];
            if ($tid) {
                google_seo_url_create(GOOGLE_SEO_THREAD, $tid);
            }
            $pid = $mybb->input['pid'];
            break;
        case 'announcements.php':
            // Translation.
            $url = google_seo_url_dynamic($mybb->input['google_seo_announcement']);
            if (strlen($url) && !array_key_exists('aid', $mybb->input)) {
                $aid = google_seo_url_id(GOOGLE_SEO_ANNOUNCEMENT, $url);
                $mybb->input['aid'] = $aid;
                $location = get_current_location();
                $location = str_replace("google_seo_announcement={$url}", "aid={$aid}", $location);
            }
            // Verification.
            $aid = (int) $mybb->input['aid'];
            if ($aid) {
                google_seo_url_create(GOOGLE_SEO_ANNOUNCEMENT, $aid);
            }
            break;
        case 'member.php':
            // Translation.
            $url = google_seo_url_dynamic($mybb->input['google_seo_user']);
            if (strlen($url) && !array_key_exists('uid', $mybb->input)) {
                $uid = google_seo_url_id(GOOGLE_SEO_USER, $url);
                $mybb->input['uid'] = $uid;
                $location = get_current_location();
                $location = str_replace("google_seo_user={$url}", "uid={$uid}", $location);
            }
            // Verification.
            $uid = (int) $mybb->input['uid'];
            if ($uid && $mybb->input['action'] == 'profile') {
                google_seo_url_create(GOOGLE_SEO_USER, $uid);
            }
            break;
        case 'calendar.php':
            // Translation.
            // Event.
            $url = google_seo_url_dynamic($mybb->input['google_seo_event']);
            if (strlen($url) && !array_key_exists('eid', $mybb->input)) {
                $eid = google_seo_url_id(GOOGLE_SEO_EVENT, $url);
                $mybb->input['eid'] = $eid;
                $location = get_current_location();
                $location = str_replace("google_seo_event={$url}", "eid={$eid}", $location);
            }
            // Verification.
            $eid = (int) $mybb->input['eid'];
            if ($eid) {
                google_seo_url_create(GOOGLE_SEO_EVENT, $eid);
            } else {
                // Calendar.
                $url = google_seo_url_dynamic($mybb->input['google_seo_calendar']);
                if (strlen($url) && !array_key_exists('calendar', $mybb->input)) {
                    $cid = google_seo_url_id(GOOGLE_SEO_CALENDAR, $url);
                    // Hack to cause invalid calendar message to appear:
                    // If cid is not set, the default calendar would be shown.
                    // However in this case it means an invalid URL was given.
                    if (!$cid) {
                        $cid = -1;
                    }
                    $mybb->input['calendar'] = $cid;
                    $location = get_current_location();
                    $location = str_replace("google_seo_calendar={$cid}", "calendar={$cid}", $location);
                }
                // Verification.
                $cid = (int) $mybb->input['calendar'];
                if ($cid) {
                    google_seo_url_create(GOOGLE_SEO_CALENDAR, $cid);
                }
            }
            break;
    }
    if ($location) {
        $location = substr($location, 0, 150);
        global $google_seo_location;
        $google_seo_location = $location;
    }
}
Beispiel #6
0
    }
}
// Are we showing the quick language selection box?
$lang_select = '';
if ($mybb->settings['showlanguageselect'] != 0) {
    $languages = $lang->get_languages();
    foreach ($languages as $key => $language) {
        $language = htmlspecialchars_uni($language);
        // Current language matches
        if ($lang->language == $key) {
            $lang_options .= "<option value=\"{$key}\" selected=\"selected\">&nbsp;&nbsp;&nbsp;{$language}</option>\n";
        } else {
            $lang_options .= "<option value=\"{$key}\">&nbsp;&nbsp;&nbsp;{$language}</option>\n";
        }
    }
    $lang_redirect_url = get_current_location(true, 'language');
    eval("\$lang_select = \"" . $templates->get("footer_languageselect") . "\";");
}
// DST Auto detection enabled?
if ($mybb->user['uid'] > 0 && $mybb->user['dstcorrection'] == 2) {
    $auto_dst_detection = "<script type=\"text/javascript\">if(MyBB) { Event.observe(window, 'load', function() { MyBB.detectDSTChange('" . ($mybb->user['timezone'] + $mybb->user['dst']) . "'); }); }</script>\n";
}
eval("\$footer = \"" . $templates->get("footer") . "\";");
// Add our main parts to the navigation
$navbits = array();
$navbits[0]['name'] = $mybb->settings['bbname_orig'];
$navbits[0]['url'] = $mybb->settings['bburl'] . "/index.php";
// Set the link to the archive.
$archive_url = $mybb->settings['bburl'] . "/archive/index.php";
// Check banned ip addresses
if (is_banned_ip($session->ipaddress, true)) {
Beispiel #7
0
        $change_dir = $forumdir;
    } else {
        die("\$forumdir is invalid!");
    }
}
$templatelist = "portal_welcome,portal_welcome_membertext,portal_stats,portal_search,portal_whosonline_memberbit,portal_whosonline,portal_latestthreads_thread,portal_latestthreads,portal_announcement_numcomments_no,portal_announcement,portal_announcement_numcomments,portal_pms,portal";
$templatelist .= ",portal_welcome_guesttext,postbit_attachments_thumbnails_thumbnail,postbit_attachments_images_image,postbit_attachments_attachment,postbit_attachments_thumbnails,postbit_attachments_images,postbit_attachments";
require_once $change_dir . "/global.php";
require_once MYBB_ROOT . "inc/functions_post.php";
require_once MYBB_ROOT . "inc/functions_user.php";
require_once MYBB_ROOT . "inc/class_parser.php";
$parser = new postParser();
// Load global language phrases
$lang->load("portal");
// Fetch the current URL
$portal_url = get_current_location();
add_breadcrumb($lang->nav_portal, "portal.php");
$plugins->run_hooks("portal_start");
// get forums user cannot view
$unviewable = get_unviewable_forums(true);
if ($unviewable) {
    $unviewwhere = " AND fid NOT IN ({$unviewable})";
    $tunviewwhere = " AND t.fid NOT IN ({$unviewable})";
}
// get inactive forums
$inactive = get_inactive_forums(true);
if ($inactive) {
    $inactivewhere = " AND fid NOT IN ({$inactive})";
    $tinactivewhere = " AND t.fid NOT IN ({$inactive})";
}
// If user is known, welcome them
Beispiel #8
0
                $selected = " selected=\"selected\"";
            } else {
                $selected = '';
            }
            eval('$lang_options .= "' . $templates->get('footer_languageselect_option') . '";');
        }
        $lang_redirect_url = get_current_location(true, 'language');
        eval('$lang_select = "' . $templates->get('footer_languageselect') . '";');
    }
}
// Are we showing the quick theme selection box?
$theme_select = $theme_options = '';
if ($mybb->settings['showthemeselect'] != 0) {
    $theme_options = build_theme_select("theme", $mybb->user['style'], 0, '', false, true);
    if (!empty($theme_options)) {
        $theme_redirect_url = get_current_location(true, 'theme');
        eval('$theme_select = "' . $templates->get('footer_themeselect') . '";');
    }
}
// If we use the contact form, show 'Contact Us' link when appropriate
$contact_us = '';
if ($mybb->settings['contactlink'] == "contact.php" && $mybb->settings['contact'] == 1 && ($mybb->settings['contact_guests'] != 1 && $mybb->user['uid'] == 0 || $mybb->user['uid'] > 0) || $mybb->settings['contactlink'] != "contact.php") {
    if (my_substr($mybb->settings['contactlink'], 0, 1) != '/' && my_substr($mybb->settings['contactlink'], 0, 7) != 'http://' && my_substr($mybb->settings['contactlink'], 0, 8) != 'https://' && my_substr($mybb->settings['contactlink'], 0, 7) != 'mailto:') {
        $mybb->settings['contactlink'] = $mybb->settings['bburl'] . '/' . $mybb->settings['contactlink'];
    }
    eval('$contact_us = "' . $templates->get('footer_contactus') . '";');
}
// DST Auto detection enabled?
$auto_dst_detection = '';
if ($mybb->user['uid'] > 0 && $mybb->user['dstcorrection'] == 2) {
    $auto_dst_detection = "<script type=\"text/javascript\">if(MyBB) { \$([document, window]).bind(\"load\", function() { MyBB.detectDSTChange('" . ($mybb->user['timezone'] + $mybb->user['dst']) . "'); }); }</script>\n";
Beispiel #9
0
if (isset($_POST['search'])) {
    if (empty($_POST['zip']) && empty($_POST['word']) && ($_POST['word'] == "What do you need?" || $_POST['zip'] == "Zip code")) {
        $sql = admin::displayItems(@$_SESSION['SORTING']);
    } else {
        $sql = user::searchAll(@$_SESSION['SORTING']);
    }
} elseif (isset($_SESSION['search']['word']) || isset($_SESSION['search']['zip'])) {
    $sql = user::searchAll(@$_SESSION['SORTING']);
    //$file=$URL_SITE."front/searchListing.php";
} else {
    $sql = admin::displayItems(@$_SESSION['SORTING']);
}
$objPagination = new Ps_Pagination($conn, $sql, 10, 5);
$exsql = $objPagination->paginate();
$total_item = @mysql_num_rows(@$exsql);
$location = get_current_location($ip);
?>
	
<div class="containersearch">
	<!--containertop-->
	
	<div class="searchslide">
		<img src="<?php 
echo $URL_SITE;
?>
images/img_1.png"/>
	</div>

	<div class="srch">
		<form id='' method="POST" action ="searchListing.php" >			
			<div class="containersrchtop">
    public static function edit($boxes, $width, $script)
    {
        global $mybb, $lang, $templates, $headerinclude;
        if ($mybb->settings['asb_minify_js']) {
            $min = '.min';
        }
        $left_insert = $boxes[0];
        $right_insert = $boxes[1];
        $width_left = $width[0];
        $width_right = $width[1];
        $toggles = $show = array();
        $filename = THIS_SCRIPT;
        // if admin wants to show the toggle icons . . .
        if ($mybb->settings['asb_show_toggle_icons']) {
            // we will need this js
            $headerinclude .= <<<EOF
<script type="text/javascript" src="jscripts/asb/asb{$min}.js"></script>
EOF;
            $toggle_info['left'] = array("close" => array("img" => 'inc/plugins/asb/images/left_arrow.png', "alt" => '&lt;'), "open" => array("img" => 'inc/plugins/asb/images/right_arrow.png', "alt" => '&gt;'));
            $toggle_info['right']['close'] = $toggle_info['left']['open'];
            $toggle_info['right']['open'] = $toggle_info['left']['close'];
            foreach (array('left', 'right') as $key) {
                // check the cookie
                if ($mybb->cookies["asb_hide_{$key}"] == 1) {
                    // hide left
                    $show[$key] = $close_style = 'display: none; ';
                    $open_style = '';
                } else {
                    // show left
                    $close_style = '';
                    $open_style = 'display: none; ';
                }
                // produce the link
                $open_image = $toggle_info[$key]['open']['img'];
                $close_image = $toggle_info[$key]['close']['img'];
                $open_alt = $toggle_info[$key]['open']['alt'];
                $close_alt = $toggle_info[$key]['close']['alt'];
                $column_id = "asb_hide_column_{$key}";
                $closed_id = "asb_{$key}_close";
                $open_id = "asb_{$key}_open";
                eval("\$toggles[\$key] = \"" . $templates->get('asb_toggle_icon') . "\";");
            }
        }
        foreach (array('left', 'right') as $key) {
            // if there is content
            $var_name = "{$key}_insert";
            if (${$var_name}) {
                $prop_name = "{$key}_content";
                $width_name = "width_{$key}";
                $width = ${$width_name};
                $show_column = $show[$key];
                $column_id = "asb_{$key}_column_id";
                $insert_name = "{$key}_insert";
                $sideboxes = ${$insert_name};
                eval("\$content_pad = \"" . $templates->get('asb_content_pad') . "\";");
                eval("\$content = \"" . $templates->get('asb_sidebox_column') . "\";");
                $toggle_left = $toggle_right = '';
                $toggle_name = "toggle_{$key}";
                ${$toggle_name} = $toggles[$key];
                // finally set $POSITION_content for ::make_edits()
                ${$prop_name} = <<<EOF

\t\t\t<!-- start: ASB {$key} column -->{$toggle_left}
\t\t\t{$content}
\t\t\t<!-- end: ASB {$key} column -->{$toggle_right}
EOF;
            }
        }
        eval("\$insert_top = \"" . $templates->get('asb_begin') . "\";");
        eval("\$insert_bottom = \"" . $templates->get('asb_end') . "\";");
        if (is_array($script['extra_scripts']) && !empty($script['extra_scripts'])) {
            $sep = '';
            $dateline = TIME_NOW;
            foreach ($script['extra_scripts'] as $id => $info) {
                // build the JS objects to pass to the custom object builder
                $extra_scripts .= <<<EOF
{$sep}{ addon: '{$info['module']}', id: {$id}, position: {$info['position']}, rate: {$info['rate']}, dateline: {$dateline} }
EOF;
                $sep = ", ";
            }
            $location = get_current_location();
            $headerinclude .= <<<EOF

<script type="text/javascript" src="jscripts/asb/asb_xmlhttp{$min}.js"></script>
<script type="text/javascript">
<!--
\tEvent.observe(window, 'load', function() {
\t\tASB.ajax.buildUpdaters([ {$extra_scripts} ], { left: {$width_left}, right: {$width_right} }, '{$location}');
\t});
// -->
</script>
EOF;
        }
        if (is_array($script['js'])) {
            foreach ($script['js'] as $script_name) {
                if (file_exists(MYBB_ROOT . "jscripts/asb/{$script_name}{$min}.js")) {
                    $script_name .= $min;
                }
                $headerinclude .= <<<EOF

<script type="text/javascript" src="jscripts/asb/{$script_name}.js"></script>
EOF;
            }
        }
        // replace everything on the page?
        if ($script['replace_all'] == true) {
            // if there is content
            if ($script['replacement']) {
                // replace the existing page entirely
                $templates->cache[$script['template_name']] = str_replace(array('{$asb_left}', '{$asb_right}'), array($insert_top, $insert_bottom), $script['replacement']);
            }
        } elseif ($script['eval']) {
            // globalize our columns
            global $asb_left, $asb_right;
            // globalize all the add-on template variables
            if (is_array($script['template_vars']) && !empty($script['template_vars'])) {
                foreach ($script['template_vars'] as $var) {
                    global ${$var};
                }
            }
            // now eval() their content for the custom script
            eval("\$asb_left = \"" . str_replace("\\'", "'", addslashes($insert_top)) . "\";");
            eval("\$asb_right = \"" . str_replace("\\'", "'", addslashes($insert_bottom)) . "\";");
        } else {
            // if there are columns stored
            if ($insert_top || $insert_bottom) {
                // make the edits
                $find_top_pos = strpos($templates->cache[$script['template_name']], $script['find_top']);
                if ($find_top_pos !== false) {
                    $find_bottom_pos = strpos($templates->cache[$script['template_name']], $script['find_bottom']);
                    if ($find_bottom_pos !== false) {
                        /*
                         * split the template in 3 parts and splice our columns in after 1 and before 3
                         * it is important that we function this way so we can work with the
                         * FIRST instance of the search text (find_top and find_bottom) rather
                         * than replacing multiple found instances
                         */
                        $templates->cache[$script['template_name']] = substr($templates->cache[$script['template_name']], 0, $find_top_pos + strlen($script['find_top'])) . $insert_top . substr($templates->cache[$script['template_name']], $find_top_pos + strlen($script['find_top']), $find_bottom_pos - ($find_top_pos + strlen($script['find_top']))) . $insert_bottom . substr($templates->cache[$script['template_name']], $find_bottom_pos);
                    }
                }
            }
        }
    }
Beispiel #11
0
function tapatalk_get_url()
{
    global $mybb;
    $location = get_current_location();
    $split_loc = explode(".php", $location);
    $parameters = $param_arr = array();
    if ($split_loc[0] == $location) {
        $filename = '';
    } else {
        $filename = my_substr($split_loc[0], -my_strpos(strrev($split_loc[0]), "/"));
    }
    if ($split_loc[1]) {
        $temp = explode("&amp;", my_substr($split_loc[1], 1));
        foreach ($temp as $param) {
            $temp2 = explode("=", $param, 2);
            $parameters[$temp2[0]] = $temp2[1];
        }
    }
    switch ($filename) {
        case "forumdisplay":
            $param_arr['fid'] = $parameters['fid'];
            $param_arr['location'] = 'forum';
            $param_arr['page'] = isset($parameters['page']) ? intval($parameters['page']) : 1;
            $param_arr['perpage'] = $mybb->settings['threadsperpage'];
            break;
        case "index":
        case '':
            $param_arr['location'] = 'index';
            break;
        case "private":
            if ($parameters['action'] == "read") {
                $param_arr['location'] = 'message';
                $param_arr['mid'] = $parameters['pmid'];
            }
            break;
        case "search":
            $param_arr['location'] = "search";
            break;
        case "showthread":
            if (!empty($parameters['pid'])) {
                //$param_arr['fid'] = $parameters['fid'];
                $param_arr['location'] = 'post';
                $param_arr['tid'] = $parameters['tid'];
                $param_arr['pid'] = $parameters['pid'];
            } else {
                //$param_arr['fid'] = $parameters['fid'];
                $param_arr['location'] = 'topic';
                $param_arr['tid'] = $parameters['tid'];
            }
            $param_arr['page'] = isset($parameters['page']) ? intval($parameters['page']) : 1;
            $param_arr['perpage'] = $mybb->settings['postsperpage'];
            break;
        case "member":
            if ($parameters['action'] == "login" || $parameters['action'] == "do_login") {
                $param_arr['location'] = 'login';
            } elseif ($parameters['action'] == "profile") {
                $param_arr['location'] = 'profile';
                $param_arr['uid'] = $parameters['uid'];
            }
            break;
        case "online":
            $param_arr['location'] = 'online';
            break;
        default:
            $param_arr['location'] = 'other';
            break;
    }
    $queryString = http_build_query($param_arr);
    $url = $mybb->settings['bburl'] . '/?' . $queryString;
    $url = preg_replace('/^(https|http)/isU', 'tapatalk', $url);
    return $url;
}
function asb_start()
{
    global $mybb, $theme;
    // side box, add-on and custom box classes
    require_once MYBB_ROOT . 'inc/plugins/asb/classes/forum.php';
    // don't waste execution if unnecessary
    if (!asb_do_checks()) {
        return;
    }
    $asb = asb_get_cache();
    $this_script = asb_get_this_script($asb, true);
    // no boxes, get out
    if (!is_array($this_script['sideboxes']) || empty($this_script['sideboxes']) || empty($this_script['sideboxes'][0]) && empty($this_script['sideboxes'][1]) || strlen($this_script['find_top']) == 0 || strlen($this_script['find_bottom']) == 0) {
        return;
    }
    $width = $boxes = array(0 => '', 1 => '');
    // make sure this script's width is within range 120-800 (120 because the templates
    // aren't made to work any smaller and tbh 800 is kind of arbitrary :s
    foreach (array("left" => 0, "right" => 1) as $key => $pos) {
        $width[$pos] = (int) max(120, min(800, $this_script["width_{$key}"]));
    }
    // does this column have boxes?
    if (!is_array($this_script['sideboxes']) || empty($this_script['sideboxes'])) {
        return;
    }
    // functions for add-on modules
    require_once MYBB_ROOT . 'inc/plugins/asb/functions_addon.php';
    // loop through all the boxes for the script
    foreach ($this_script['sideboxes'] as $pos => $sideboxes) {
        // does this column have boxes?
        if (!is_array($sideboxes) || empty($sideboxes)) {
            continue;
        }
        // loop through them
        foreach ($sideboxes as $id => $module_name) {
            // verify that the box ID exists
            if (!isset($asb['sideboxes'][$id])) {
                continue;
            }
            // then load the object
            $sidebox = new Sidebox($asb['sideboxes'][$id]);
            // can the user view this side box?
            if (!asb_check_user_permissions($sidebox->get('groups'))) {
                continue;
            }
            // is this theme available for this side box?
            $good_themes = $sidebox->get('themes');
            if ($good_themes && !in_array($theme['tid'], $good_themes)) {
                continue;
            }
            $result = false;
            // get the template variable
            $template_var = "{$module_name}_{$id}";
            // attempt to load the box as an add-on module
            $module = new Addon_type($module_name);
            // if it is valid, then the side box was created using an
            // add-on module, so we can proceed
            if ($module->is_valid()) {
                // build the template. pass settings, template variable
                // name and column width
                $result = $module->build_template($sidebox->get('settings'), $template_var, $width[$pos], get_current_location());
            } elseif (isset($asb['custom'][$module_name]) && is_array($asb['custom'][$module_name])) {
                $custom = new Custom_type($asb['custom'][$module_name]);
                // if it validates, then build it, otherwise there was an error
                if ($custom->is_valid()) {
                    // build the custom box template
                    $result = $custom->build_template($template_var);
                }
            } else {
                continue;
            }
            /*
             * all box types return true or false based upon whether they have
             * content to show. in the case of custom boxes, false is returned
             * when the custom content is empty; in reference to add-on modules
             * many factors are involved, but basically, if the side box depends on
             * an element (threads for example) and there are none, it will return
             * false-- IF asb_show_empty_boxes is true then it will return a side
             * box with a 'no content' message, if not, it will be skipped
             */
            if ($result || $mybb->settings['asb_show_empty_boxes']) {
                $boxes[$pos] .= asb_build_sidebox_content($sidebox->get('data'));
            }
        }
    }
    // load the template handler class definition and make the edits
    require_once MYBB_ROOT . 'inc/plugins/asb/classes/template_handler.php';
    ASBTemplateHandler::edit($boxes, $width, $this_script);
}