MyBB Community Forums

Full Version: MyAlerts breaking website
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, so we've been using MyAlerts consistently for the past year or so without faults, but due to a mistake it was deactivated for 10 hours yesterday, and once activated something broke the website. (any place where myalerts is) Which leads me to believe that somewhere in a template or myalerts.php, there is an error which shouldn't be. 

I have honestly not much of a clue, I checked all myalerts template as well as header templates, index templates and even the myalerts.php plugin file without being able to target the error.

If any information is needed to pinpoint this, please let me know, the line 415 and 416 in index.php looks like this:

415: eval('$index = "'.$templates->get('index').'";');
416: output_page($index);

Thanks for any help.
can you post code lines from index template of active theme
Hi there, I am Godless101's colleague, he isn't able to answer right now, so here I have the index code.

<html>
    <head>
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
        <title>{$mybb->settings['bbname']}</title>
        {$headerinclude}
		{$recentthread_headerinclude}
        <script type="text/javascript">
        <!--
            lang.no_new_posts = "{$lang->no_new_posts}";
            lang.click_mark_read = "{$lang->click_mark_read}";
        // -->
        </script>
    </head>
    <body id="index">
        {$header}
				<if !$mybb->user['uid'] then>
			<div class="welcomeguest d-flex">
				Welcome to {$mybb->settings['bbname']}! To start engaging in our community, and our pretty sweet leaks & resources, click the register or login button on the right side!
				<span class="ml-auto d-flex">
					<a href="{$mybb->settings['bburl']}/member.php?action=login" class="button text-center" style="margin-right: .5rem">Login</a>							
					<a href="{$mybb->settings['bburl']}/member.php?action=register" class="button button-dark text-center">Register</a>
				</span>
			</div>
		</if>
        <div class="d-flex mobile-noflex">
            <div class="whole">
				{$dvz_shoutbox}
				<br />
				{$forums}

			</div>
			<div class="sidebar">
				<table border="0" cellspacing="0" cellpadding="5" class="tborder dailyGoals">
<thead>
    <tr>
        <td class="thead" colspan="2">
            <span><strong><span style="color: #FFF;font-weight: 700;">Daily Goals</span><br><span style="color: rgba(255, 255, 255, 0.7);"><small>Today's goals for posts & threads</small></span></strong></span>
        </td>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="trow1">	
<?php 
if (isset($postgoal) && isset($todaypost) 
{
	$diff = $opstgoal-$todaypost;

    $color;
if (diff <= 0) 
    {
        $color = "#2abd3d";
    } else {
        $color = "#d05a04";
    }
} else {
        $color = "#fff";
}

echo "<div style='padding: 200px;'> HELLO </div>";

?>

<span>Posts:</span><span style="float:right;color: <?php echo $color; ?>" >{$progress}</span>
        </td>
    </tr>
    <tr>
        <td class="trow1">
            <div class="prog-bar-border">
                <div id="prog-color" class="prog-bar-bar">
					<span id="prog-count" style="width:{$percent}; background: linear-gradient(to right, #632b6b, #682d70, #6c2f75, #71317b, #763380);"></span>
					<p id="prog-percent" style="color: rgb(255, 255, 255);">{$percent}</p>
                </div>
            </div>
        </td>
    </tr>
	<tr>
        <td class="trow1">
<?php 
if (isset($threadgoal) && isset($todaythread) 
{
	$diffT = $threadgoal-$todaythread;

    $colorT;
    if (diffT <= 0) 
    {
        $colorT = "#2abd3d";
    } else {
        $colorT = "#d05a04";
    }
} else {
        $colorT = "#fff";
}
?>
<span>Threads:</span><span style="float:right;color:<?php echo $colorT; ?>">{$progressT}</span>
        </td>
    </tr>
    <tr>
        <td class="trow1">
            <div class="prog-bar-border"><div id="prog-color" class="prog-bar-bar"><span id="prog-count" style="width: {$percentT}; background: linear-gradient(to right, #632b6b, #682d70, #6c2f75, #71317b, #763380);"></span><p id="prog-percent" style="color: rgb(255, 255, 255);">{$percentT}</p>
                </div>
            </div>
        </td>
    </tr>
</tbody>
</table>
				
				
				<br />
				<style>
					.sidebar-banner {
						max-width: 374px;
						margin:auto;
					}
				</style>
				<if $mybb->user['usergroup'] == 3 || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 6 || $mybb->user['usergroup'] == 8 || $mybb->user['usergroup'] == 9 || $mybb->user['usergroup'] == 11  then>
					<elseif !$mybb->user['uid'] then>
					<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
						<tbody>
							<tr><td class="trow1"><a href="https://URLHERE"><img src="https://cdn.discordapp.com/attachments/681086448824352788/693046986391289946/2mb.gif" class="sidebar-banner"></a></td></tr>
						</tbody>
					</table>
					
					<br />
						<else>
												<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
						<tbody>
							<tr><td class="trow1"><a href="https://URLHERE"><img src="https://cdn.discordapp.com/attachments/681086448824352788/693046986391289946/2mb.gif" class="sidebar-banner"></a></td></tr>
						</tbody>
					</table>
					
					<br />
						
				</if>	
			
			
				{$sidebar}
				<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
					<tr>
						<td class="thead">Staff Online</td>
					</tr>
					<tr><td class="trow1">{$staffline_list}</td></tr>
				</table>
<br>
				<div class="table stats">
					<div class="tborder">
						<div class="thead"><strong>Statistics</strong></div>
						<div class="trow1">Posts: <span class="number right">{$stats['numposts']}</span></div>						
						<div class="trow1">Threads: <span class="number right">{$stats['numthreads']}</span></div>						
						<div class="trow1 no_bottom_border">Members: <span class="number right">{$stats['numusers']}</span></div>			
						<div class="tcat">Newest Member</div>
						<div class="trow1 no_bottom_border"><a href="member.php?action=profile&amp;uid={$stats['lastuid']}">{$stats['lastusername']}</a><br>Is our newest member.</div>
					</div>
				</div>
				<br />
			</div>
		</div>
		<div class="d-flex mobile-noflex">
			<div class="whole">
				{$boardstats}
				</div> <!-- // end in boardstats -->
				</div> <!-- // end in boardstats -->
			</div>
		</div>
    	{$footer}
    </body>
</html>
Since MyAlerts is a part of the header/menu I'd believe a more relevant template to look at would be the header template(s).

It's here:
<script>
	if($('#user_avatar').attr('src') == null || $('#user_avatar').attr('src') == '') {
		$('#user_avatar').attr('src', 'images/default_avatar.png');
	}
</script>

<div id="header" class="mobileSideNav d-none">
	<ul class="menu top_links menu-nav">
		<li class="bold text-uppercase d-flex"><a href="{$mybb->settings['bburl']}" id="nav-index"><i class="fa fa-home"></i>&nbsp; Home</a></li>
		<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/upgrade.php" id="nav-upgrade"><i class="fa fa-star"></i>&nbsp; Upgrade</a></li>		
                <li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/awards.php" id="nav-awards"><i class="fas fa-trophy"></i>&nbsp; Awards</a></li>		
		<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/misc.php?action=help" id="nav-help"><i class="fas fa-life-ring"></i>&nbsp; Help</a></li>
		<if $mybb->user['uid'] then>
			<div class="tcat fullwidth">My Account</div>
			<li class="bold text-uppercase d-flex"><a href="{$mybb->settings['bburl']}/private.php" id="nav-messages" class="d-flex-i align-items-center"><i class="fa fa-envelope"></i>&nbsp; Messages <span class="messages-icon ml-auto">{$mybb->user['unreadpms']}</span></a></li>
			<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/user-{$mybb->user['username']}" id="nav-profile"><i class="fa fa-user"></i>&nbsp; Profile</a></li>
			<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/usercp.php" id="nav-settings"><i class="fa fa-cog"></i>&nbsp; Settings</a></li>
			<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}"><i class="fas fa-sign-out-alt"></i>&nbsp; Sign Out</a></li>
		</if>
		<if $mybb->user['usergroup'] == 3 || $mybb->user['usergroup'] == 6 || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 13 then>
			<div class="tcat fullwidth">Staff</div>
			<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/modcp.php" id="nav-modcp"><i class="fas fa-gavel"></i>&nbsp; Mod Panel</a></li>			
			<if $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 13  then>
				<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/{$admin_dir}/index.php"><i class="fas fa-user-secret"></i>&nbsp; Admin Panel</a></li>
			</if>
		</if>
	</ul>
</div>

<div id="container">
		<a name="top" id="top"></a>
		<div id="header">
			<div class="header-background"></div>
			<div class="header-inner">
				<ul class="menu top_links fixed-menu p-0">
					<div class="width d-flex align-items-center">
						<div class="mobile-hide d-flex">
							<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}" id="nav-index"><i class="fa fa-home"></i>&nbsp; Home</a></li>
							<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/newpoints.php" id="nav-newpoints"><i class="fas fa-coins"></i>&nbsp; Credits</a></li>
		                    <li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/upgrade.php" id="nav-upgrade"><i class="fas fa-star"></i>&nbsp; Upgrade</a></li>
	                        <li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/awards.php" id="nav-awards"><i class="fas fa-trophy"></i>&nbsp; Awards</a></li>
          					<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/misc.php?action=help" id="nav-help"><i class="fas fa-life-ring"></i>&nbsp; Help</a></li>

						</div>
						<li class="bold mobileSideNavToggle mobile-show">
							<a style="padding: 18px 16px !important;">
								<i class="fa fa-bars"></i>
							</a>
						</li>
						<if $mybb->user['uid'] then>
							<div class="ml-auto d-flex-i align-items-center">
								{$myalerts_headericon}
								<li class="bold">
									<a href="{$mybb->settings['bburl']}/private.php">
										<i class="fas fa-envelope"></i>&nbsp; <span class="messages-icon head-messages">{$mybb->user['unreadpms']}</span>
									</a>
								</li>
								<li class="bold ml-auto dropdown">
									<a class="d-flex-i align-items-center dropdown-toggle">
										<img src="{$mybb->user['avatar']}" width="25" height="25" style="border-radius: 2px; margin-right: .5rem" id="user_avatar" />
										{$mybb->user['username']}&nbsp;&nbsp; <i class="fas fa-angle-down"></i>
									</a>
									<div class="dropdown-menu">
										<div class="arrow-up"></div>
										<a class="trow1 border-top-none" href="{$mybb->settings['bburl']}/user-{$mybb->user['username']}">
											<i class="fas fa-user"></i>
											<span class="ml-auto">Profile</span>
										</a>
										<a class="trow2" href="{$mybb->settings['bburl']}/usercp.php?action=avatar">
											<i class="fas fa-crop"></i>
											<span class="ml-auto">Change Avatar</span>
										</a>
										<a class="trow1" href="{$mybb->settings['bburl']}/usercp.php">
											<i class="fas fa-cog"></i>
											<span class="ml-auto">Settings</span>
										</a>
										<if $mybb->user['usergroup'] == 3 || $mybb->user['usergroup'] == 6 || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 13 then>
											<a class="trow1" href="{$mybb->settings['bburl']}/modcp.php">
												<i class="fas fa-gavel icon-mod"></i>
												<span class="ml-auto">Moderation</span>
											</a>
											<if $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 13 then>
												<a class="trow1" href="{$mybb->settings['bburl']}/{$admin_dir}/index.php">
													<i class="fas fa-user-secret icon-admin"></i>
													<span class="ml-auto">Administration</span>
												</a>
											</if>
										</if>
										<a class="trow1" href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}">
											<i class="fas fa-sign-out-alt"></i>
											<span class="ml-auto">Sign Out</span>
										</a>
									</div>
								</li>
							</div>
						<else />
							<div class="ml-auto">
								<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/member.php?action=register" id="nav-register"><i class="fa fa-user-plus"></i>&nbsp; Register</a></li>						
								<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/member.php?action=login" id="nav-login"><i class="fas fa-sign-in-alt"></i>&nbsp; Login</a></li>
							</div>
						</if>
					</div>
					<script>
						$('.dropdown-toggle').click(function() {
							$('.dropdown-menu').stop(true, true).fadeToggle();
						});
					</script>
				</ul>
				<div id="logo">
					<div class="wrapper d-flex align-items-center justify-content-center">
						<a href="{$mybb->settings['bburl']}/" title="{$mybb->settings['bbname']}">
							<img src="https://cdn.discordapp.com/attachments/586923621214322710/587350118978813962/1xxxxxx.png" alt="{$mybb->settings['bbname']}" title="{$mybb->settings['bbname']}" width="400" />		
						</a>
						{$welcomeblock}
					</div>
				</div>
				<ul class="menu top_links menu-nav ribbon">
					<div class="d-flex align-items-center">
						<navigation>
					</div>
				</ul>
				<div class="ribbon-back"></div>
			</div>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-143661960-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-143661960-1');
</script>

		</div>
		<div id="content">
			<div class="wrapper">
				<div class="inner-container">
					{$pm_notice}{$ougc_awards_requests}
					{$username_approval}
					{$bannedwarning}
					{$bbclosedwarning}
					{$unreadreports}
					{$pending_joinrequests}{myadvertisements[zone_1]}

And more interestingly would obvious be the myalerts part of the header here:
<if $mybb->user['uid'] then>
							<div class="ml-auto d-flex-i align-items-center">
								{$myalerts_headericon}
								<li class="bold">
									<a href="{$mybb->settings['bburl']}/private.php">
										<i class="fas fa-envelope"></i>&nbsp; <span class="messages-icon head-messages">{$mybb->user['unreadpms']}</span>
									</a>
								</li>
								<li class="bold ml-auto dropdown">
									<a class="d-flex-i align-items-center dropdown-toggle">
										<img src="{$mybb->user['avatar']}" width="25" height="25" style="border-radius: 2px; margin-right: .5rem" id="user_avatar" />
										{$mybb->user['username']}&nbsp;&nbsp; <i class="fas fa-angle-down"></i>
									</a>
									<div class="dropdown-menu">
										<div class="arrow-up"></div>
										<a class="trow1 border-top-none" href="{$mybb->settings['bburl']}/user-{$mybb->user['username']}">
											<i class="fas fa-user"></i>
											<span class="ml-auto">Profile</span>
										</a>
										<a class="trow2" href="{$mybb->settings['bburl']}/usercp.php?action=avatar">
											<i class="fas fa-crop"></i>
											<span class="ml-auto">Change Avatar</span>
										</a>
										<a class="trow1" href="{$mybb->settings['bburl']}/usercp.php">
											<i class="fas fa-cog"></i>
											<span class="ml-auto">Settings</span>
										</a>
										<if $mybb->user['usergroup'] == 3 || $mybb->user['usergroup'] == 6 || $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 13 then>
											<a class="trow1" href="{$mybb->settings['bburl']}/modcp.php">
												<i class="fas fa-gavel icon-mod"></i>
												<span class="ml-auto">Moderation</span>
											</a>
											<if $mybb->user['usergroup'] == 4 || $mybb->user['usergroup'] == 13 then>
												<a class="trow1" href="{$mybb->settings['bburl']}/{$admin_dir}/index.php">
													<i class="fas fa-user-secret icon-admin"></i>
													<span class="ml-auto">Administration</span>
												</a>
											</if>
										</if>
										<a class="trow1" href="{$mybb->settings['bburl']}/member.php?action=logout&amp;logoutkey={$mybb->user['logoutkey']}">
											<i class="fas fa-sign-out-alt"></i>
											<span class="ml-auto">Sign Out</span>
										</a>
									</div>
								</li>
							</div>
						<else />
							<div class="ml-auto">
								<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/member.php?action=register" id="nav-register"><i class="fa fa-user-plus"></i>&nbsp; Register</a></li>						
								<li class="bold text-uppercase"><a href="{$mybb->settings['bburl']}/member.php?action=login" id="nav-login"><i class="fas fa-sign-in-alt"></i>&nbsp; Login</a></li>
							</div>
						</if>
are you using php in templates plugin ?
(2020-03-29, 12:33 PM).m. Wrote: [ -> ]are you using php in templates plugin ?

Well there has never been a problem with it and yes that is one of our plugins indeed. But we have not touched any php in template code for more than half a year without issues. It has never impeded myalert.

We are currently working on abstracting all php in template to actual plugins for better readability, reversability and easier updates.

But so far index has not been changed for long... :3

Thanks for your interest, we really appreciate any help.
okay.
I'd suggest to put index template code in a editor;
replace other templates variables with their actual codes
(eg. headerinclude, recentthread_headerinclude , header ...)
then try to analyze error lines - around lines 63 & 97
... ...
(2020-03-29, 01:28 PM).m. Wrote: [ -> ]okay.
I'd suggest to put index template code in a editor;
replace other templates variables with their actual codes
(eg. headerinclude, recentthread_headerinclude , header ...)
then try to analyze error lines - around lines 63 & 97
... ...

Alright I will systematically go through it, thanks for the idea. Will be back if I fix or am unable to fix.