MyBB Community Forums
[For 1.8] MyBB Guest Home - Show homepage for guest - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Releases (https://community.mybb.com/forum-102.html)
+---- Thread: [For 1.8] MyBB Guest Home - Show homepage for guest (/thread-231172.html)

Pages: 1 2 3


MyBB Guest Home - Show homepage for guest - YASAKA - 2021-02-09

Feature
  • Show Index Page for Guest

Description
This plugin will show an index page for guests only and you can freely edit the page in Global Templates >> index_guest.

[Image: o4sKpkF.png]
[Image: gp03DtF.png]

Download Link
https://community.mybb.com/mods.php?action=view&pid=1434


RE: MyBB Guest Home - Show homepage for guest - Omar G. - 2021-02-09

Hi, thank you for your contribution.

However, please note that the following is wrong:
$gid = $mybb->user['gid'];

As the gid key doesn't exists, you should instead simply use the uid key:
if($mybb->settings['mybbguest_onoff'] == "1" && $mybb->user['uid'] <= "0")



RE: MyBB Guest Home - Show homepage for guest - MyBBEinstein - 2021-02-09

(2021-02-09, 01:41 AM)Omar G. Wrote: Hi, thank you for your contribution.

However, please note that the following is wrong:
$gid = $mybb->user['gid'];

As the gid key doesn't exists, you should instead simply use the uid key:
if($mybb->settings['mybbguest_onoff'] == "1" && $mybb->user['uid'] <= "1")
 
Hi , and exactly where should this be inserted?

My forums usergroup = Guest  = gid=1

here is the full plugin.php cod


<?php

// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.");
}

$plugins->add_hook("index_start", "mybbguest_page");

function mybbguest_info()
{
	$codename = str_replace('.php', '', basename(__FILE__));
	
	return array(
		"name"			=> "MyBB Guest Home",
		"description"	=> "Show homepage for guest.",
		"website"		=> "https://sinfulsite.com",
		"author"		=> "YASAKA",
		"authorsite"	=> "https://sinfulsite.com/@YASAKA",
		"version"		=> "1.0",
		"guid" 			=> "",
		"codename"		=> $codename,
		"compatibility" => "18*"
	);
}

function mybbguest_is_installed()
{
	global $mybb;

	if(isset($mybb->settings['mybbguest_onoff']))
	{
	    return true;
	}
	
	return false;
}

function mybbguest_install()
{
	mybbguest_install_settings();
	mybbguest_install_templates();
}

function mybbguest_uninstall()
{
	mybbguest_uninstall_settings();
	mybbguest_uninstall_templates();
}

function mybbguest_install_settings()
{
	global $db;

	$group = array(
        "name" => "mybbguest",
        "title" => "MyBB Guest Home",
        "description" => "Show homepage for guest.",
        "disporder" => 1,
        "isdefault" => 0
    );
    $gid = $db->insert_query("settinggroups", $group);

    $setting = array(
        "sid"            => NULL,
        "name"            => "mybbguest_onoff",
        "title"            => "MyBB Guest Home",
        "description"    => "Enable or disable this plugin.",
        "optionscode"    => "onoff",
        "value"            => "1",
        "disporder"        => 0,
        "gid"            => $gid
    );
    $db->insert_query("settings", $setting);

    rebuild_settings();
}

function mybbguest_uninstall_settings()
{
	global $db;

	$db->delete_query('settings', "name IN ('mybbguest_onoff')");
	$db->delete_query('settinggroups', "name = 'mybbguest'");

	rebuild_settings();
}

function mybbguest_install_templates()
{
	global $db;

	$template = '<html>
<head>
<title>{$mybb->settings[\'bbname\']}</title>
{$headerinclude}
</head>
<body>
{$header}
<div align="center" style="width: 50%; margin: auto;">
	<h1>Welcome to {$mybb->settings[\'bbname\']}</h1>
	<h2>Forum of Cracking</h2>
	<h4>Sinful Site is a forum based on general discussion and sharing of related resources. We encourage creativity, freedom, and above all, individuality. You can also find lots of leaks, tools, software, tutorials, and more. Learn many things here, new friends and have fun with our special features. We will not disappoint you!
If you want to contact us, you can use our contact form.</h4>
	<br>
	<a class="button" href="{$mybb->settings[\'bburl\']}/member.php?action=login" onclick="$(\'#quick_login\').modal({ fadeDuration: 250, keepelement: true, zIndex: (typeof modal_zindex !== \'undefined\' ? modal_zindex : 9999) }); return false;" style="margin-right:10px">Login</a>
	<a href="{$mybb->settings[\'bburl\']}/member.php?action=register" class="button">Register</a>
</div>
{$footer}
</body>
</html>';
	$insert_array = array(
	    'title' => 'index_guest',
	    'template' => $db->escape_string($template),
	    'sid' => '-1',
	    'version' => '',
	    'dateline' => time()
	);
	$db->insert_query('templates', $insert_array);
}

function mybbguest_uninstall_templates()
{
	global $db;

	$db->delete_query("templates", "title = 'index_guest'");
}

function mybbguest_page()
{
	global $mybb, $db, $templates, $lang, $header, $headerinclude, $footer, $theme;

	$uid = $mybb->user['uid'];

	if($mybb->settings['mybbguest_onoff'] == "1" && $uid <= "1")
	{
		eval('$index = "'.$templates->get('index_guest').'";');
		output_page($index);
		die();
	}
}



RE: MyBB Guest Home - Show homepage for guest - Whiteneo - 2021-02-09

As Omar said to you Guests users does not have a valid user id, so it is better to use that besides groups.

User gid is not present if you declare to integer then you may see the values and put the same condition.

See yah !!!


RE: MyBB Guest Home - Show homepage for guest - MyBBEinstein - 2021-02-10

(2021-02-09, 05:41 PM)Whiteneo Wrote: As Omar said to you Guests users does not have a valid user id, so it is better to use that besides groups.

User gid is not present if you declare to integer then you may see the values and put the same condition.

See yah !!!

Yes I tried it as @Omar wrote it, but it didn't work for me because everyone gets in the table that only Guest users should come in!

everyone saw it, not just the guests!

is there any solution why? or can the problem be solved?


RE: MyBB Guest Home - Show homepage for guest - chack1172 - 2021-02-10

If I'm not wrong guests have uid = 0 so you can check that:
if ($mybb->user['uid'] == 0) {
  // Show guest page
}



RE: MyBB Guest Home - Show homepage for guest - MyBBEinstein - 2021-02-10

(2021-02-10, 10:10 AM)chack1172 Wrote: If I'm not wrong guests have uid = 0 so you can check that:
if ($mybb->user['uid'] == 0) {
  // Show guest page
}

Hi , 

I'm login Admin panels

cheak guest -- admin/index.php?module=user-groups&action=edit&gid=1


RE: MyBB Guest Home - Show homepage for guest - chack1172 - 2021-02-10

I know that, but I think the best way to check if they are really guests is to check the user id (uid field).


RE: MyBB Guest Home - Show homepage for guest - MyBBEinstein - 2021-02-10

(2021-02-10, 10:18 AM)chack1172 Wrote: I know that, but I think the best way to check if they are really guests is to check the user id (uid field).


I understand, but then what's wrong with me, why it doesn't work the way it should, @Omar what I wrote I did, but not good unfortunately!

i can't find the uid anywhere, where can i find it at all?


RE: MyBB Guest Home - Show homepage for guest - chack1172 - 2021-02-10

Oh, I saw now the updated code. It is correct but instead of ['uid'] <= "1" the correct condition is ['uid'] < "1".