SimplePortal
Support => English Support => Topic started by: 420connect on April 08, 2015, 03:55:33 PM
-
Hey everyone and anyone!
I've got an issue from my PortalBlocks.php file according to my error log and on closer inspection, it is the line
eval($content);
I have very little knowledge about php and would appreciate if anyone could help me clear this error!
I have a suspicion it could be caused by a custom block I am using (if that could be the issue) but am pretty clueless to be honest..
Attach is my full PortalBlocks.php file if anyone would mind having a look and I'm happy to attach other files / code parts if needbe!
Many thanks as always!
-
Pretty useless if you don't type the full error code and message dude... Also, disable the evaluation of template, I got a feeling it is hiding the real error.
:)
-
To be honest, you will always get errors in the log. Might be from mods, custom themes, custom code in blocks etc.
If you are using standard curve theme and simple portal with nothing customized at all (no mods, no other code), you might be lucky and get no errors. And most errors do not affect the performance of your site.
Some might be attributed to your server configurations as well.
I do not bother checking or trying to fix errors unless there are hundreds/ thousand+ /day (some SMF mods do that) or 'critical'.
Andy
-
135+ mods, heavily customized default theme (if you don't know what I mean by heavily customized feel free to check it out: http://virtualinteractivege.com/index.php), lots of manual edits, error log is clear except of fake registrations notifications :)
-
Oops, sorry, I had posted this before going to bed and missed that out! :whistle:
(http://i.snag.gy/Rj4wy.jpg)
This is what it tell me ^^ and after checking, I already had my template evaluation thing disabled.
Hopefully it makes some sense to you :P
I currently have about 40 pages of the same error, and although I don't notice anything out of the ordinary, theres probably something not quite right in the code somewhere..
I thought I was bad with around 80 MOD's but Ninja takes that to a new extreme :P
(good to know, I still have room to customize though!)
-
That's so weird, it happens when there is an undefined somewhere but similar errors are being thrown when the evaluation of templates is enabled.
Forum » Administration Center » Server Settings » General
Disable evaluation of templates --> double check that the checkbox is checked.
-
:o
Yup, definitely have disable checked
-
No idea, never seen anything similar before, really. :(
-
420connect,
It appears to be caused by one of your custom php blocks.
Regards.
-
Hmm, how to debug this kind of issues? Usually (you will know this for sure) you turn eval of templates off and then you can see the error, but apparently it doesn't work if the issue is in a custom php block, is there a way to make it to show up?
-
Ninja ZX-10RR,
I don't think SP has been designed to show the actual block id within the error log.
The only way to figure it out is to disable custom PHP blocks through a process of elimination.
One would have to purge the error logs every time as each block is disabled during the process.
Regards.
-
If it's not too much of a hassle it could be a good feature for 2.3.7, among with the 2 bugs you have tracked down in the bug tracker ;)
Also, thank you for the explanation! :D
-
Sorry for the late return! :P
I think I've found what block is causing my issues (and possibly what line)..
Much appreciated if someone wouldn't mind having a check over the following..
my error log says line 3 but I'm no PHP expert at all..
global $sourcedir;
$block['style'] = sportal_parse_style('explode', $block['style'], true); //Parse block style parameters.
template_block($block); // Output the block.
$blocks = array(
array(
'label' => 'Chat',
'type' => 'sp_shoutbox',
'parameters' => array('display' => 1, 'shoutbox' => 2),
),
array(
'label' => 'Who`s Online',
'type' => 'sp_whosonline',
'parameters' => array('display' => 1),
),
array(
'label' => 'Recent Posts',
'type' => 'sp_php',
'parameters' => array('content' => file_get_contents($sourcedir . '/spcustomblock1.php')),
),
array(
'label' => 'Recent Topics',
'type' => 'sp_recent',
'parameters' => array('type' => 1, 'display' => 1),
),
array(
'label' => 'Unread Posts',
'type' => 'sp_php',
'parameters' => array('content' => file_get_contents($sourcedir . '/spcustomblock2.php')),
),
);
global $txt;
$button_list = array();
foreach ($blocks as $id => $block)
{
$txt['sp_bib_label_' . $id] = $block['label'];
$button_list[] = array(
'text' => 'sp_bib_label_' . $id,
'image' => '',
'lang' => true,
'url' => '#sp_bib_' . $id . '" id="sp_bib_button_' . $id . '" onclick="sp_bib_change(' . $id . '); return false;',
);
}
$button_list[0]['active'] = true;
echo '
<div style="overflow: auto;">
', template_button_strip($button_list), '
</div>';
foreach ($blocks as $id => $block)
{
echo '
<div id="sp_bib_', $id, '"', $id != 0 ? ' style="display: none;"' : '', '>';
$block['type']($block['parameters'], 0);
echo '
</div>';
}
echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function sp_bib_change(id)
{
for (var i = 0; i < ', count($blocks), '; i++)
{
document.getElementById(\'sp_bib_\' + i).style.display = i == id ? \'\' : \'none\';
document.getElementById(\'sp_bib_button_\' + i).className = \'button_strip_\' + i + (i == id ? \' active\' : \'\');
}
}
// ]]></script>';
-
420connect,
Prior to posting a fix it would be prudent to post the actual error from the log to be sure we are addressing your issue.
Regards.
-
Sorry I forgot to include it again, - just the same as stated earlier though..
(http://i.snag.gy/Rj4wy.jpg)
Thank you very much in advance!
(Can hardly believe I'll soon have a error free log! yey!)
-
420connect,
find:
global $sourcedir;
$block['style'] = sportal_parse_style('explode', $block['style'], true); //Parse block style parameters.
replace:
global $sourcedir;
$block = !empty($block) ? $block : array();
$block['style'] = !empty($block['style']) ? sportal_parse_style('explode', $block['style'], true) : array(); //Parse block style parameters.
... but that only patches it and does not address the issue to actually solve the problem. Also if the $block array is null line 2 should be throwing the error so I am not sure if you found the part that is causing it (it starts at line 0). I gave an edit to stop an error from line 2 or 3 of the code you just posted.
Regards.
-
*updated this
Damn, I still seem to be getting them after making the change although the error has changed from:
8: Undefined variable: block
to
8: Undefined index: style
Could it be from one of the custom blocks.. inside that block then?
2 custom blocks:
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/
/* [SETUP WHAT YOU WANT HERE] */
$topics_posts = 2; // TOPICS - 1 | MESSAGES - 2
$limit = 50; // How many recent posts do you want to output?
$number = 340; // How many characters do you want to output?
$exclude_boards = array(87, 93, 17, 71); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?
// Scroll Enable? Height and Speed?
$scrolling = 2; // ENABLE - 1 | DISABLE - 2
$speed = 4; // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "210px";
$scrollbar = 1; // ENABLE - 1 | DISABLE - 2
// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';
/* [STOP!] - THIS IS THE END OF SETUP */
//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}
// Let's grab some database results
if ($topics_posts == 1) {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);
$posts[] = array(
'id' => $row_posts['id_member_updated'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => parse_bbc($row_posts['body']),
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
} else {
if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method = $exclude_boards;
$exclude_boards = array();
}
$posts_result = $smcFunc['db_query']('', '
SELECT IFNULL(u.real_name, m.poster_name) AS poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '
WHERE m.approved=1' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array(
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
)
);
$posts = array();
while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);
$posts[] = array(
'id' => $row_posts['id_member'],
'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . ' ' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
'body' => parse_bbc($row_posts['body']),
'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
'board' => $row_posts['name'],
'time' => timeformat($row_posts['poster_time']),
'new' => !empty($row_posts['is_read'])
);
}
$smcFunc['db_free_result']($posts_result);
}
//Finally the Output
//Scrolling xD
if ($scrolling == 1)
echo '<div style="overflow: hidden;"><marquee height=' . $height . ' behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';
if ($scrollbar == 1)
echo '<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';
foreach ($posts as $post) {
// Lets fix the BBCode bug and Strip the Text
$content1 = str_replace("[", "<", $post['body']);
$content2 = str_replace("]", ">", $content1);
$content3 = strip_tags($content2);
$preview = substr ($content3,0,$number);
echo'<table>
<tr>
<td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
' . $post['subject'];
if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';
echo '<br />
<small>' . $text['who'] . ' ' . $post['username'] . ' | ' . $post['time'] .'</small>
</td>
</tr>
</table>';
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}
echo '<hr />';
}
//Scrolling xD
if ($scrollbar == 1)
echo '</div>';
if ($scrolling == 1)
echo '</marquee></div>';
?>
2
/* Unread Posts Block v1.4 || c/o Underdog @ http://askususaquestion.net */
global $settings, $sourcedir;
@require_once($sourcedir . '/PortalUnread.php');
/* Current default settings are for a full display example */
/* Recommended settings for compact display (ie. side block) : */
/* $parameters['container_style'] = 'font-family:Sans Serif;font-size:12px; */
/* $parameters['display'] = 'compact'; */
/* --------------------------------------------BLOCK SETTINGS-------------------------------------------- */
$seconds = 300;
$auto_refresh = false; /* Change to false to disable auto refresh */
/* Basic settings */
$parameters['type'] = 'Topics'; /* Posts/Topics */
$parameters['rows'] = '5'; /* (int) Amount of posts/topics per page */
$parameters['display'] = 'full'; /* full/compact */
$parameters['show_icon'] = 'yes'; /* yes/no - Show new icon */
$parameters['full_height'] = 35; /* (int) Uniform row height for full display */
$parameters['compact_height'] = 45; /* (int) Uniform row height for compact display */
$parameters['container_class'] = 'mediumtext'; /* Set the css class for the whole container .. */
$parameters['container_style'] = 'font-family: Verdana, Arial, sans-serif;'; /* Set the css attributes for the whole container */
// $parameters['boards'] = '1|2|3|4'; /* Specific boards to display ... uncomment to use this option! */
/* This is the number of recent topics to select new one's from */
$parameters['limit'] = 5; /* (int) Maximum amount of posts/topics to display */
/* Image/Language Text ... set $parameters['unread_icons'] = false; to disable images & use text */
/* All images located in directory /Themes/default/images/sp */
$parameters['unread_icons'] = true;
$parameters['prev'] = 'Prev';
$parameters['next'] = 'Next';
$parameters['vbar_x'] = '';
$parameters['vbar_y'] = '';
/* Starting page */
$_SESSION['sp_current_page'] = 1;
/* --------------------------------------------END BLOCK SETTINGS-------------------------------------------- */
/* Execute & then let jQuery reset the container every xx milliseconds */
sportal_unread($parameters, false, false);
if ($auto_refresh)
echo '<script type="text/javascript" src="'.$settings['default_theme_url'].'/scripts/sp-jquery-1.3.2.min.js"></script>
<script type="text/javascript">
setInterval(function() {
$("#sp_content").load(location.href+" #sp_content","");
event.stopPropagation();
}, '.((int)$seconds * 1000).');
</script>';
appreciated if you would have a check over these to make sure I've not mucked something up?
determined to find and solve this! :nervous-happy:
... I don't suppose a block that isn't enabled but is saved would be a cause?
-
420connect,
Try disabling the recent post block that was developed by me & then clear your error log.
If the problem is resolved then update that block with this: http://web-develop.ca/index.php?topic=112.msg928#forumposts
If you use the updated block + file make sure to read the instructions carefully that I gave to use it.
Let me know if this resolved the issue.
Regards.