MyBB Community Forums

Full Version: Moderator Control panel Password plugins Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Warning [2] Use of undefined constant bbname - assumed 'bbname' (this will throw an Error in a future version of PHP) - Line: 4 - File: inc/plugins/modcppassword.php(215)

that plugin of a member have share

Mod CP Password (1.0)

now i try to found where i have downloaded i dont find but

is working to use password on mod control panel is just because when we click on mod control panel is have A page of error and Down of the page we can enter the password after when is enter all is okais ..
uninstall the plugin and change that bbname in the plugin file to 'bbname' ; reinstall the plugin

edited typo !
i dont understand Look what you have write you say replace bbname to bbname is the same ?
^ sorry, there was a typing mistake.
I meant to add quote marks around bbname in the specified line of the plugin file
(2020-07-17, 02:06 PM).m. Wrote: [ -> ]^ sorry, there was a typing mistake.
I meant to add quote marks around bbname in the specified line of the plugin file

What do you mean by quote marks ? i dont speak well english can you Write it for me i will say thanks you i understand haha Smile


<title>{\$mybb->settings[bbname]} - {\$lang->password_required} </title>

do you mean ” ” ?

i try this before i uninstall i make change save and i re install

<head>
<title>{\$mybb->settings[”bbname”]} - {\$lang->password_required} </title>
{\$headerinclude}


after is not working is not show the password section
<title>{\$mybb->settings[bbname]} - {\$lang->password_required} </title>
should be changed to
<title>{\$mybb->settings[\'bbname\']} - {\$lang->password_required} </title>
i.e. use single quote marks for bbname
i find again the plugin to re download I dont know why i have re made to the start without " " and save and re install is not workingt to ask for password ? why

is not appear now i have recount and rebuil the cache i dont know if is can help but change nothing .. i have try uninstall and re install 10 time ..


omg my website not working with the cote single is white page not loading i have restart nginx etc and not working again i take out the quote is working i think is make a mistake in the cote

when i use your quote single is Write bbname in Black and not in pink purple .. is made error

if is can help


<?php

if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}


$plugins->add_hook("modcp_start", "modcppassword");
$plugins->add_hook("modcp_start", "modcppassword_logout");
$plugins->add_hook("moderation_start", "modcp_loggedin");


function modcppassword_info()
{
	
	return array(
		"name"			=> "Mod CP Password",
		"description"	=> "Requires a password to enter the Mod CP.",
		"website"		=> "http://www.mybbsecurity.net/",
		"author"		=> "MyBB Security Group",
		"authorsite"	=> "http://www.mybbsecurity.net/",
		"version"		=> "1.0",
		"compatibility" => "18*",
	);
}

function modcppassword_install()
{
	global $db;

    $group = array(
        "gid" => "NULL",
        "name" => "modcppassword",
        "title" => "Mod CP Password",
        "description" => "Settings for the plugin.",
        "disporder" => "9999",
        "isdefault" => "no",
        );
        
    $db->insert_query("settinggroups", $group);
    $gid = $db->insert_id();

    $setting_1 = array(
        "sid" => "NULL",
        "name" => "modcppassword_enabled",
        "title" => "Enabled?",
        "description" => "Should this plugin be enabled?",
        "optionscode" => "yesno",
        "value" => "2",
        "disporder" => "1",
        "gid" => intval($gid),
        );
    $db->insert_query("settings", $setting_1);
    
    $setting_2 = array(
        "sid" => "NULL",
        "name" => "modcppassword_password",
        "title" => "Mod CP Password",
        "description" => "The password used to login to the Mod CP. A blank password will have the same effect as it being disabled.",
        "optionscode" => "text",
        "value" => random_str(),
        "disporder" => "2",
        "gid" => intval($gid),
        );
    $db->insert_query("settings", $setting_2);

}

function modcppassword_uninstall()
{
	global $db, $mybb;

    $query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='modcppassword'");
    $g = $db->fetch_array($query);
    $db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");
    $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");
    rebuild_settings();
}

function modcppassword_activate()
{
	global $db;
	
	$template_1 = array(
		"tid"		=> NULL,
		"title"		=> 'modcp_password',
		"template"	=> '<html>
<head>
<title>{\$mybb->settings[bbname]} - {\$lang->password_required} </title>
{\$headerinclude}
</head>
<body>
{\$header}
<form action="{\$_SERVER[REQUEST_URI]}" method="post">
<table border="0" cellspacing="{\$theme[borderwidth]}" cellpadding="{\$theme[tablespace]}" class="tborder">
<tr>
<td class="thead" align="center" colspan="2"><strong>{\$lang->password_required}</strong></td>
</tr>
<tr>
<td class="trow2" colspan="2">{\$lang->modcp_password_note}</td>
</tr>
<tr>
<td class="tcat" colspan="2"><strong>{\$lang->enter_password_below}</strong></td>
</tr>
{\$pwnote}
<tr>
<td class="trow1" align="center" colspan="2"><input type="password" class="textbox" name="pwverify" size="50" value="" /></td>
</tr>
</table>
<br />
<div align="center"><input type="submit" class="button" name="submit" value="{\$lang->verify_modcp_password}" /></div>
</form>
{\$footer}
</body>
</html>',
		"sid"		=> "-1",
		"version"	=> "1605",
		"dateline"	=> TIME_NOW,
	);

	$db->insert_query("templates", $template_1);
	
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	
	find_replace_templatesets("modcp_nav", "#".preg_quote('{$lang->nav_menu}')."#i", '{$lang->nav_menu}  (<a href="modcp.php?action=logout&amp;my_post_key={$mybb->post_code}">{$lang->welcome_logout}</a>)');
	
}

function modcppassword_deactivate()
{
	global $db;
	
	$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title = 'modcp_password'");
	
	require_once MYBB_ROOT."/inc/adminfunctions_templates.php";
	
	find_replace_templatesets("modcp_nav", "#".preg_quote('(<a href="modcp.php?action=logout&amp;my_post_key={$mybb->post_code}">{$lang->welcome_logout}</a>)')."#i", '');
}

function modcppassword_is_installed()
{
	global $db;
	
	$query = $db->simple_select("settings", "name", "name='modcppassword_enabled'");

	$rows = $db->num_rows($query);

	if(intval($rows) == 1)
	{
		return true;
	}
	
	return false;
}

function modcppassword()
{
	global $mybb, $header, $footer, $headerinclude, $theme, $templates, $lang, $forum_cache;
	
	$lang->modcp_password_note = 'The administrator has required it so that a password is required for access the moderator control panel.';
	$lang->verify_modcp_password = 'Verify Password';
	
	$showform = true;
	
	$enabled = false;
	if($mybb->settings['modcppassword_enabled'] == 1)
	{
		$enabled = true;
	}
	
	$password = $mybb->settings['modcppassword_password'];

	if($enabled && $password !== '')
	{
		if($mybb->input['pwverify'])
		{
			if($password == $mybb->input['pwverify'])
			{
				my_setcookie("modcppassword", md5($mybb->user['uid'].$mybb->input['pwverify']), null, true);
				$showform = false;
			}
			else
			{
				eval("\$pwnote = \"".$templates->get("forumdisplay_password_wrongpass")."\";");
				$showform = true;
			}
		}
		else
		{
			if(!$mybb->cookies['modcppassword'] || ($mybb->cookies['modcppassword'] && md5($mybb->user['uid'].$password) != $mybb->cookies['modcppassword']))
			{
				$showform = true;
			}
			else
			{
				$showform = false;
			}
		}
	}
	else
	{
		$showform = false;
	}

	if($showform)
	{
		if($pid)
		{
			header("Location: ".$_SERVER['REQUEST_URI']);
		}
		else
		{
			$_SERVER['REQUEST_URI'] = htmlspecialchars_uni($_SERVER['REQUEST_URI']);
			eval("\$pwform = \"".$templates->get("modcp_password")."\";");
			output_page($pwform);
		}
		exit;
	}
}

function modcppassword_logout()
{
	global $mybb;
	
	if($mybb->input['action'] == 'logout')
	{
		verify_post_check($mybb->input['my_post_key']);
	
		my_setcookie("modcppassword", '', null, true);
		redirect('modcp.php');
		exit;
	}
}

function modcp_loggedin()
{

	$password = $mybb->settings['modcppassword_password'];

	if($mybb->settings['modcppassword_enabled'] == 1 && $mybb->cookies['modcppassword'] && md5($mybb->user['uid'].$password) == $mybb->cookies['modcppassword'])
	{
		redirect('modcp.php');
		exit;
	}
}

?>
^ oh! please change that line to
<title>{\$mybb->settings[\'bbname\']} - {\$lang->password_required} </title>
(2020-07-17, 02:57 PM).m. Wrote: [ -> ]^ oh! please change that line to
<title>{\$mybb->settings[\'bbname\']} - {\$lang->password_required} </title>

hi i have try with ' ' 1 quote not working white page of the board

i try with your line
<title>{\$mybb->settings[\'bbname'\]} - {\$lang->password_required} </title>

not working i cannot acess to the plugin section is not show the plugins

and i want to precised i have uninstall before the change and save the change in the plugin ..

(2020-07-17, 02:57 PM).m. Wrote: [ -> ]^ oh! please change that line to
<title>{\$mybb->settings[\'bbname\']} - {\$lang->password_required} </title>

omg i have re try your last line of code

MyBB has experienced an internal SQL error and cannot continue.

i will come back to the first version for the moment of the line of code

i have again the problem Is A complex headache
^ hmm., would you like to PM me temporary access to your forum admin panel & files (ftp) to check it
Pages: 1 2