MyBB Community Forums

Full Version: how to clear this kind of warnings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: Screenshot_1650.png]


Code 

<?php
/**
 * Plugin Name: AutoMedia 3.0 for MyBB 1.8.*
 * Copyright © 2009-2016 doylecc
 * http://mybbplugins.tk
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */


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


// Caching templates
if (my_strpos($_SERVER['PHP_SELF'], 'usercp.php'))
{
	global $templatelist;
	if (isset($templatelist))
	{
		$templatelist .= ',';
	}
	$templatelist .= 'automedia_codebuttons,automedia_codebuttons_footer,automedia_codebuttons_private,automedia_embedly_button,automedia_embedly_direct,automedia_embedly_modal,automedia_embedly_button_card,automedia_embedly_direct_card,automedia_embedly_modal_card,automedia_head,automedia_head_embedly,automedia_videocount,automedia_usercp,automedia_ucpstatus_up,automedia_ucpstatus_down';
}
elseif (my_strpos($_SERVER['PHP_SELF'], 'showthread.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'private.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'newthread.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'newreply.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'editpost.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'calendar.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'modcp.php') ||
		my_strpos($_SERVER['PHP_SELF'], 'portal.php'))
{
	global $templatelist;
	if (isset($templatelist))
	{
		$templatelist .= ',';
	}
	$templatelist .= 'automedia_codebuttons,automedia_codebuttons_footer,automedia_codebuttons_private,automedia_embedly_button,automedia_embedly_direct,automedia_embedly_modal,automedia_embedly_button_card,automedia_embedly_direct_card,automedia_embedly_modal_card,automedia_head,automedia_head_embedly,automedia_videocount';
}

// Plugin version
define('AUTOMEDIA_VER', '3100');

// Plugin Info
function automedia_info()
{
	global $lang, $plugins_cache;

	if (!isset($lang->av_plugin_descr))
	{
		$lang->load("automedia");
	}

	$am_info = array(
		"name"			=> $lang->av_plugin_title,
		"description"	=> $lang->av_plugin_descr,
		"website"		=> "http://mybbplugins.tk",
		"author"		=> "doylecc",
		"authorsite"	=> "http://mybbplugins.tk",
		"version"		=> "3.1.0",
		"compatibility"	=> "18*",
		"codename"		=> "automedia"
		);

	// PHP 5.3 is required for the plugin
	if (version_compare(PHP_VERSION, '5.3.0', '<'))
	{
		$am_info['description'] .= "  <ul><li style=\"list-style-image: url(styles/default/images/icons/error.png)\">"
		.$lang->av_php_version
		."</li></ul>";
	}
	else
	{
		// Add cURL status to info
		if (automedia_is_installed() && is_array($plugins_cache) && is_array($plugins_cache['active']) && $plugins_cache['active']['automedia'])
		{
			$am_info['description'] .= @automedia_curl_status();
		}
	}
	return $am_info;
}


// Get the cURL and fsockopen status
function automedia_curl_status()
{
	global $lang, $db, $mybb;

	$result = $db->simple_select('settinggroups', 'gid', "name = 'AutoMedia Global'");
	$set = $db->fetch_array($result);
	$unsupported = $lang->av_unsupported;

	if (!function_exists('curl_init') && !function_exists("fsockopen"))
	{
		$status .= "  <ul><li style=\"list-style-image: url(styles/default/images/icons/warning.png)\">"
		.$unsupported
		."</li>
		<li style=\"list-style-image: url(styles/default/images/icons/default.png)\"><a href=\"index.php?module=tools-automedia\">"
		.$lang->automedia_modules
		."</a></li>
		<li style=\"list-style-image: url(styles/default/images/icons/custom.png)\"><a href=\"index.php?module=config-settings&amp;action=change&amp;gid=".(int)$set['gid']."\">".$lang->automedia_settings."</a></li>
		<li style=\"list-style-image: url(styles/default/images/icons/make_default.png)\"><a href=\"index.php?module=tools-automedia&amp;action=templateedits&amp;my_post_key=".$mybb->post_code."\">".$lang->automedia_template_edits1."</a> ".$lang->automedia_template_edits2."</li>
		</ul>\n";
	}
	else
	{
		$status = "<ul></li>
		<li style=\"list-style-image: url(styles/default/images/icons/default.png)\"><a href=\"index.php?module=tools-automedia\">"
		.$lang->automedia_modules
		."</a></li>
		<li style=\"list-style-image: url(styles/default/images/icons/custom.png)\"><a href=\"index.php?module=config-settings&amp;action=change&amp;gid=".(int)$set['gid']."\">".$lang->automedia_settings."</a></li>
		<li style=\"list-style-image: url(styles/default/images/icons/make_default.png)\"><a href=\"index.php?module=tools-automedia&amp;action=templateedits&amp;my_post_key=".$mybb->post_code."\">".$lang->automedia_template_edits1."</a> ".$lang->automedia_template_edits2."</li>
		</ul>\n";
	}
	return $status;
}


// Load the install/admin functions in ACP.
if (defined("IN_ADMINCP"))
{
	require_once MYBB_ROOT."inc/plugins/automedia/automedia_install.php";
	require_once MYBB_ROOT."inc/plugins/automedia/automedia_admincp.php";
}
else  // Load the frontend functions
{
	require_once MYBB_ROOT."inc/plugins/automedia/automedia_functions.php";
}


// Build and empty cache
function automedia_cache($clear=false)
{
	global $cache;
	if ($clear == true)
	{
		$cache->update('automedia',false);
	}
	else
	{
		global $db;
		$sites = array();
		$query = $db->simple_select('automedia', 'name,class');
		while ($site = $db->fetch_array($query))
		{
			$sites[$site['name']] = $site;
		}
		$cache->update('automedia', $sites);
	}
}
first question, from your shared file it appears you are using say build # 8 ie: 3.x when the plugin is at build #22 ie: 4.x and my question is, is there a reason you are opting to use a plugin file say 12 releases behind latest version as such issues are corrected in later versions?

anyhoo, in those older versions the templates where in the automedia_install.php file whereas the newer version use an xml file for template isertion, regardless in the version you are using

ie:

automedia_install.php

<head>
<title>{$mybb->settings[bbname]} - {$lang->av_ucp_title}</title>
{$headerinclude}
</head>
<body>
{$header}
<form action="usercp.php" method="post">
<table width="100%" border="0" align="center">
<tr>
{$usercpnav}
<td valign="top">
<table border="0" cellspacing="{$theme[borderwidth]}" cellpadding="{$theme[tablespace]}" class="tborder">
<tr>
<td class="thead" colspan="3"><strong>{$lang->av_ucp_title}</strong></td>
</tr>
<tr>
<td align="center" class="trow1" width="60%">
{$lang->av_ucp_label}
</td>
<td class="trow1" width="20%">
<input type="radio" name="automedia" value="Y"{$av_checked_yes} />{$lang->av_ucp_yes}<br />
<input type="radio" name="automedia" value="N"{$av_checked_no} />{$lang->av_ucp_no}
</td>
<td align="center" class="trow1" width="20%">
<div>{$ucpset}</div>
</td>
</tr>
</table>
<br />
<div align="center">
<input type="hidden" name="action" value="do_automedia" />
<input type="submit" class="button" name="submit" value="{$lang->av_ucp_submit}" />
</div>
</td>
</tr>
</table>
</form>
{$footer}
</body>
</html>

notice the missing ' '

for:

{$mybb->settings[bbname]}
{$theme[borderwidth]}
{$theme[tablespace]}

Your warnings are suggesting it is expecting:

{$mybb->settings['bbname']}
{$theme['borderwidth']}
{$theme['tablespace']}

but finding:

{$mybb->settings[bbname]}
{$theme[borderwidth]}
{$theme[tablespace]}

thus the warning.... and the warning is clearly telling you what to fix, simple as that...

ie:

also factor in how this is included in install

ie:

{$mybb->settings[\'bbname\']}
{$theme[\'borderwidth\']}
{$theme[\'tablespace\']}


so ie:

automedia_install.php

<head>
<title>{$mybb->settings[\'bbname\']} - {$lang->av_ucp_title}</title>
{$headerinclude}
</head>
<body>
{$header}
<form action="usercp.php" method="post">
<table width="100%" border="0" align="center">
<tr>
{$usercpnav}
<td valign="top">
<table border="0" cellspacing="{$theme[\'borderwidth]\'}" cellpadding="{$theme[\'tablespace\']}" class="tborder">
<tr>
<td class="thead" colspan="3"><strong>{$lang->av_ucp_title}</strong></td>
</tr>
<tr>
<td align="center" class="trow1" width="60%">
{$lang->av_ucp_label}
</td>
<td class="trow1" width="20%">
<input type="radio" name="automedia" value="Y"{$av_checked_yes} />{$lang->av_ucp_yes}<br />
<input type="radio" name="automedia" value="N"{$av_checked_no} />{$lang->av_ucp_no}
</td>
<td align="center" class="trow1" width="20%">
<div>{$ucpset}</div>
</td>
</tr>
</table>
<br />
<div align="center">
<input type="hidden" name="action" value="do_automedia" />
<input type="submit" class="button" name="submit" value="{$lang->av_ucp_submit}" />
</div>
</td>
</tr>
</table>
</form>
{$footer}
</body>
</html>


Now if you dont want to edit plugin file: you have the option to update the plugin to later versions

or you can also edit your existing installed template:

Edit Template: automedia_usercp

and find the following:

{$mybb->settings[bbname]}
{$theme[borderwidth]}
{$theme[tablespace]}

and change each to:

{$mybb->settings['bbname']}
{$theme['borderwidth']}
{$theme['tablespace']}

Best of luck! Big Grin