News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

ERROR! -> 8: Undefined variable: event

Started by dracius, September 13, 2008, 01:48:19 AM

Previous topic - Next topic

dracius

Today I started receiving an error on my 2nd computer when trying to access my website.
This occurred after I logged out to test something, and now it won't let me back in.
Luckily I can still access the site on this comp (but I'm afraid to log out of my admin account), so I was able to pull the error logs, and here's what I see.

http://silentreign.net/guild/index.php?action=Home
8: Undefined variable: event
File: /home/content/d/r/a/dracius/html/guild/Themes/default/CustomAction.template.php (eval?)
Line: 139



http://silentreign.net/guild/index.php?action=Home
8: Undefined variable: txt
File: /home/content/d/r/a/dracius/html/guild/Themes/default/CustomAction.template.php (eval?)
Line: 207


Here's the error my other comp gets when trying to access the website

Database Error: Lost connection to MySQL server during query
File: /home/content/d/r/a/dracius/html/guild/Sources/Security.php
Line: 280


I had some other ppl who haven't visited the site check it out for me, and they had no issues.

However, I'm also noticing lots of other errors appearing. Can someone help me clean these up?  :'(

Nathaniel

The first two errors are related to pages that you have created using the Custom Action Mod, you should be able to fix the issues, by using the error message to fix that code.

You might need to global the $txt and $event variables. ;)
Like this:
global $txt, $event;
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

dracius

Where do I add that though? I know hardly anything about SMF ;.;'

Nathaniel

Can you post the code that you are using for your custom action/page?
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

dracius

#4
<?php
// This is the template file for the Custom Action Mod.

// Show a custom action.
function template_main()
{
global $context;
if ($context['custom_action']['type'] == 'php')
eval($context['custom_action']['code']);
elseif ($context['custom_action']['type'] == 'bbc')
echo parse_bbc($context['custom_action']['code']);
else
echo $context['custom_action']['code'];
}

?>


But I notice that's in the "default" theme, when we're using a different theme. This has me a bit confused, not sure what code to post to help you

As you can see on our site http://silentreign.net/guild/index.php we have 3 custom action pages. Ranks, Recruitment, and Home.

Nathaniel

I mean the code from your admin panel, that you put into your custom actions, that you have added with that mod. ;)
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

dracius

#6
<?php
if (!defined('SMF'))



die(
'Hacking attempt...');

// This is the source file for the Custom Action Mod. I'm going to try to comment this one better than my Custom Profile Field Mod :)

// Actually go to a custom action.
function CustomAction()
{



global 
$context$modSettings;






// Find out which custom action to use...



$i 1;



while (isset(
$modSettings['CA' $i '_name']))



{





// Is this it?





if (
$context['current_action'] == $modSettings['CA' $i '_name'])





{







// Set $type, $title and $code, which will later be put into the $context variable.







$type $modSettings['CA' $i '_type'];







$title $modSettings['CA' $i '_title'];







$code $modSettings['CA' $i '_code'];







// No need to continue.







break;





}





$i++;



}



// OK, we found the action, but do we have any subactions?



if (isset(
$_GET['sa']))



{





// A subaction was specified, try to find it.





$n 1;





while (isset(
$modSettings['CA' $i '_sa' $n '_name']))





{







// Is this it?







if (
$_GET['sa'] == $modSettings['CA' $i '_sa' $n '_name'])







{









// Overwrite the type, title and code we set before.









$type $modSettings['CA' $i '_sa' $n '_type'];









$title $modSettings['CA' $i '_sa' $n '_title'];









$code $modSettings['CA' $i '_sa' $n '_code'];









// No need to continue.









break;







}







$n++;





}



}






// Set the action type and code for the template file to read.



$context['custom_action'] = array(





'type' => $type,





'code' => $code,



);






// Set the page title.



$context['page_title'] = $title;






// Now load the template.



loadTemplate('CustomAction');
}

// Set the settings for custom actions through the admin interface.
function CustomActionSettings()
{



global 
$txt$scripturl$context$settings$sc$modSettings$db_prefix;






// Adding an action?



if (isset(
$_GET['addaction']))



{





// Check the session.





checkSession('get');










// These are the settings we're going to add.





$settings = array(







'CA' $_GET['addaction'] . '_name' => '',







'CA' $_GET['addaction'] . '_type' => 'html',







'CA' $_GET['addaction'] . '_title' => '',







'CA' $_GET['addaction'] . '_code' => '',





);





// Actually add them.





addSettingsActionMod($settings);










// Go back to the action index.





redirectexit('action=featuresettings;sa=actions');



}



// Adding a sub-action?



elseif (isset(
$_GET['addsub']))



{





// Check the session.





checkSession('get');










// These are the settings we're going to add.





$settings = array(







'CA' $_GET['parentaction'] . '_sa' $_GET['addsub'] . '_name' => '',







'CA' $_GET['parentaction'] . '_sa' $_GET['addsub'] . '_type' => 'html',







'CA' $_GET['parentaction'] . '_sa' $_GET['addsub'] . '_title' => '',







'CA' $_GET['parentaction'] . '_sa' $_GET['addsub'] . '_code' => '',





);





// Actually add them.





addSettingsActionMod($settings);










// Go back to the sub-action index.





redirectexit('action=featuresettings;sa=actions;sasettings=' $_GET['parentaction']);



}



// Deleting an action?



elseif (isset(
$_GET['deleteaction']))



{





// Check the session.





checkSession('get');










// Delete the action.





deleteAction($_GET['deleteaction']);










// Go back to the action index.





redirectexit('action=featuresettings;sa=actions');



}



// Deleting a sub-action?



elseif (isset(
$_GET['deletesub']))



{





// Check the session.





checkSession('get');










// Delete the sub-action.





deleteSubAction($_GET['deletesub'], $_GET['parentaction']);










// Go back to the sub-action index.





redirectexit('action=featuresettings;sa=actions;sasettings=' $_GET['parentaction']);



}



// Set the sub-actions for an action.



elseif (isset(
$_GET['sasettings']))



{





$config_vars = array();





// Loop through each sub-action.





$i 1;





while (isset(
$modSettings['CA' $_GET['sasettings'] . '_sa' $i '_name']))





{







// Show all the settings.







$config_vars[] = array('text''CA' $_GET['sasettings'] . '_sa' $i '_name'null'Name');







$config_vars[] = array('select''CA' $_GET['sasettings'] . '_sa' $i '_type', array('html' => 'HTML''php' => 'PHP''bbc' => 'BBC',), 'Type');







$config_vars[] = array('text''CA' $_GET['sasettings'] . '_sa' $i '_title'null'Page Title');







$config_vars[] = array('large_text''CA' $_GET['sasettings'] . '_sa' $i '_code'10'Code');







// Show some additional options for each sub-action.







$config_vars[] = '<a href="' $scripturl '?action=' $modSettings['CA' $_GET['sasettings'] . '_name'] . ';sa=' $modSettings['CA' $_GET['sasettings'] . '_sa' $i '_name'] . ';sesc=' $sc '">[ Go To Page ]</a> <a href="' $scripturl '?action=featuresettings;sa=actions;deletesub=' $i ';parentaction=' $_GET['sasettings'] . ';sesc=' $sc '">[ Delete ]</a>';







// And a <hr /> between sub-actions.







$config_vars[] = '';







$i++;





}





// Show the button to add an action.





$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=actions;addsub=' $i ';parentaction=' $_GET['sasettings'] . ';sesc=' $sc '">Add a sub-action</a>';










// The post URL and page title.





$context['post_url'] = $scripturl '?action=featuresettings2;save;sa=actions;sasettings=' $_GET['sasettings'];





$context['settings_title'] = 'Sub-Action Settings For "' $modSettings['CA' $_GET['sasettings'] . '_name'] . '" Action';



}



// List all the actions and their settings.



else



{





$config_vars = array();





// Loop through each action.





$i 1;





while (isset(
$modSettings['CA' $i '_name']))





{







// Show all the settings.







$config_vars[] = array('text''CA' $i '_name'null'Name');







$config_vars[] = array('select''CA' $i '_type', array('html' => 'HTML''php' => 'PHP''bbc' => 'BBC',), 'Type');







$config_vars[] = array('text''CA' $i '_title'null'Page Title');







$config_vars[] = array('large_text''CA' $i '_code'10'Code');







// Show some additional options for each action.







$config_vars[] = '<a href="' $scripturl '?action=' $modSettings['CA' $i '_name'] . '">[ Go To Page ]</a> <a href="' $scripturl '?action=featuresettings;sa=actions;sasettings=' $i ';sesc=' $sc '">[ Sub-Actions ]</a> <a href="' $scripturl '?action=featuresettings;sa=actions;deleteaction=' $i ';sesc=' $sc '">[ Delete ]</a>';







// And a <hr /> between actions.







$config_vars[] = '';







$i++;





}





// Show the button to add an action.





$config_vars[] = '<a href="' $scripturl '?action=featuresettings;sa=actions;addaction=' $i ';sesc=' $sc '">Add an action</a>';










// The post URL and page title.





$context['post_url'] = $scripturl '?action=featuresettings2;save;sa=actions';





$context['settings_title'] = 'Custom Action Settings';



}



// Saving?



if (isset(
$_GET['save']))



{





saveDBSettings($config_vars);










// Where should we redirect to?





if (isset(
$_GET['sasettings']))







redirectexit('action=featuresettings;sa=actions;sasettings=' $_GET['sasettings']);





else







redirectexit('action=featuresettings;sa=actions');



}



// Show the settings.



prepareDBSettingContext($config_vars);
}

// Delete an action.
function deleteAction($id)
{



global 
$modSettings;






// Start with moving up each action that's above the one we're going to delete.



$i $id 1;



while (isset(
$modSettings['CA' $i '_name']))



{





moveUpActionMod($i);





$i++;



}



// Now delete the action at the top.



$i--;






// Set what we want to delete.



$settings = array('CA' $i '_name''CA' $i '_title''CA' $i '_type''CA' $i '_tile''CA' $i '_code',);



// Also delete any sub-actions for this action.



$n 1;



while (isset(
$modSettings['CA' $i '_sa' $n '_name']))



{





$settings[] = 'CA' $i '_sa' $n '_name';





$settings[] = 'CA' $i '_sa' $n '_type';





$settings[] = 'CA' $i '_sa' $n '_title';





$settings[] = 'CA' $i '_sa' $n '_code';





$n++;



}






// Now actually delete them.



deleteSettingsActionMod($settings);
}

// Delete a sub-action.
function deleteSubAction($id$action)
{



global 
$modSettings;






// Start with moving up each action that's above the one we're going to delete.



$i $id 1;



while (isset(
$modSettings['CA' $action '_sa' $i '_name']))



{





moveUpSubActionMod($i$action);





$i++;



}



// Now delete the action at the top.



$i--;






// Set what we want to delete.



$settings = array('CA' $action '_sa' $i '_name''CA' $action '_sa' $i '_type''CA' $action '_sa' $i '_title''CA' $action '_sa' $i '_code',);






// Now actually delete them.



deleteSettingsActionMod($settings);
}

// I use these functions in all my mods that you can and/or remove settings in. I named them differently just in case they're already being used in another mod.

// Add settings to $modSettings.
function addSettingsActionMod($settings$overwrite false)
{



global 
$db_prefix;






// Format the settings into SQL data.



$string '';



foreach (
$settings as $k => $v)





$string .= '









(\'' 
$k '\', \'' addslashes($v) . '\'),';












// Do the query.



if (
$string != '')





$result db_query("







. ($overwrite 'REPLACE' 'INSERT IGNORE') . " INTO {$db_prefix}settings









(variable, value)







VALUES" 
substr($string0, -1),__FILE__,__LINE__);
}

// Delete settings.
function deleteSettingsActionMod($settings)
{



global 
$db_prefix;






// Loop through each setting and delete it.



foreach (
$settings as $delete)





$result db_query("DELETE FROM {$db_prefix}settings WHERE variable = '$delete' LIMIT 1"__FILE____LINE__);




}

// Move up an action.
function moveUpActionMod($id)
{



global 
$modSettings;






$replace $id 1;



// Move one action up and the other down.



$settings = array(





'CA' $replace '_name' => $modSettings['CA' $id '_name'],





'CA' $replace '_type' => $modSettings['CA' $id '_type'],





'CA' $replace '_title' => $modSettings['CA' $id '_title'],





'CA' $replace '_code' => $modSettings['CA' $id '_code'],





'CA' $id '_name' => $modSettings['CA' $replace '_name'],





'CA' $id '_type' => $modSettings['CA' $replace '_type'],





'CA' $id '_title' => $modSettings['CA' $replace '_title'],





'CA' $id '_code' => $modSettings['CA' $replace '_code'],



);



// Add and sub-action.



$i 1;



while (isset(
$modSettings['CA' $id '_data' $i]))



{





$settings['CA' $replace '_sa' $i '_name'] = $modSettings['CA' $id '_sa' $i '_name'];





$settings['CA' $replace '_sa' $i '_type'] = $modSettings['CA' $id '_sa' $i '_type'];





$settings['CA' $replace '_sa' $i '_title'] = $modSettings['CA' $id '_sa' $i '_title'];





$settings['CA' $replace '_sa' $i '_code'] = $modSettings['CA' $id '_sa' $i '_code'];





$i++;



}



$i 1;



while (isset(
$modSettings['CA' $replace '_data' $i]))



{





$settings['CA' $id '_sa' $i '_name'] = $modSettings['CA' $replace '_sa' $i '_name'];





$settings['CA' $id '_sa' $i '_type'] = $modSettings['CA' $replace '_sa' $i '_type'];





$settings['CA' $id '_sa' $i '_title'] = $modSettings['CA' $replace '_sa' $i '_title'];





$settings['CA' $id '_sa' $i '_code'] = $modSettings['CA' $replace '_sa' $i '_code'];





$i++;



}






// Actually move the specified rows (with overwrite true).



addSettingsActionMod($settingstrue);
}

function 
moveUpSubActionMod($id$field)
{



global 
$modSettings;






$replace $id 1;



// Move one sub-action up and the other down.



$settings = array(





'CA' $field '_sa' $replace '_name' => $modSettings['CA' $field '_sa' $id '_name'],





'CA' $field '_sa' $replace '_type' => $modSettings['CA' $field '_sa' $id '_type'],





'CA' $field '_sa' $replace '_title' => $modSettings['CA' $field '_sa' $id '_title'],





'CA' $field '_sa' $replace '_code' => $modSettings['CA' $field '_sa' $id '_code'],





'CA' $field '_sa' $id '_name' => $modSettings['CA' $field '_sa' $replace '_name'],





'CA' $field '_sa' $id '_type' => $modSettings['CA' $field '_sa' $replace '_type'],





'CA' $field '_sa' $id '_title' => $modSettings['CA' $field '_sa' $replace '_title'],





'CA' $field '_sa' $id '_code' => $modSettings['CA' $field '_sa' $replace '_code'],



);






// Actually move the specified rows (with overwrite true).



addSettingsActionMod($settingstrue);
}
?>


I didn't notice any change when removing the code from the "Ranks" or "Recruitment" sections.

dracius

#7
I lie, I removed all the code from the "Home" action, and the errors stopped.
However, I still have the issue where if I'm not logged in, the page some times doesn't load and I get an SQL error. =*(

Here's the code:

echo '<table width="100%"><tr><td>';

require("/home/content/d/r/a/dracius/html/guild/SSI.php");

// Posts/Topics Snippet
// By Dragooon
// www.gforumx.com
// Version 3.0

//The instructions are posted in the thread of this snippet + they are quite here.

// Lets call the file
global $sourcedir;
require_once($sourcedir . '/PostsTopicsSnippet.php');

// Declare it. There is NO need to edit this part
$boards_id = array();
$cats_id = array();
/************************************
* How To Customize!
************************************/
# This is how to customize the block. To customize this please edit the variable given in the Below function call (postsTopicsSnippet). Do Not edit the variables given in this How To. This How to explains, what is the variable is and what does it do.
# How to Customize is given below.
# Make sure not to remove ANY comma
# Make sure not to remove "array()" part in the $boards_id and $cats_id variables.

# $mode : Mode of the Block
# 1 = Recent Topics
# 2 = Recent Posts
# 3 = Top Viewed
# 4 = Top Replied

# $boards_id : ID Of Boards to show the posts/topics from
# Do Not remove array() part, Insert the ID(s) of boards you want posts to show from.
# Use comma ( , ) as a separator
# Example : $boards_id = array(1, 2, 3)
# Leave empty to grab posts from all boards

# $cats_id : ID Of categories to show the posts/topics from
# Do Not remove array() part, Insert the ID(s) of categories you want posts to show from.
# Use comma ( , ) as a separator
# Example : $cats_id = array(1, 2, 3)
# Leave empty to grab posts from all categories

# $stickyOnly : Weather to get the topics which are sticky only or not
# true : yes
# false : no

# $limit : Maximum no. of topics/posts to show

# $subjectLength : Max characters the subject can have.

# $bodylength : Max characters the subject can have
# Setting it to 0 will result showing of no body.

# Below are some configuration variables
# For these, if set to true, it means Yes.
# If set to false, it means no.

# $parseSmileys : Weather to parse smileys or not

# $show_board : Weather to show the board the topic/post is posted in or not

# $show_views : Weather to show the no. of views or not

# $show_replies : Weather to show the no. of replies or not

# $show_category : Weather to show category or not

# $show_author : Weather to show the author who posted this or not

# $show_newIcon : If the post is unread, weather to show the New Icon or not

# $show_time : Weather to show the time the post/topic is posted on or not

# $scroll : If the height it longer than 40 pixels, weather to make it as a scroll or not

# $aScroll : Weather to make it auto scroll or not
# NOTE : If $scroll AND $aScroll are both true, $scroll turns back to false so that it doesn't clashes.
/************************************
* End How to Customize!
************************************/

/************************************
* The Function!
************************************/
postsTopicsSnippet(
$mode = 1,
$boards_id = array(13),
$cats_id = array(),
$stickyOnly = false,
$limit = 3,
$subjectLength = 50,
$bodylength = 100000,
$parseSmileys = true,
$show_board = false,
$show_views = true,
$show_replies = true,
$show_category = false,
$show_author = true,
$show_newIcon = true,
$show_time = true,
$scroll = false,
$aScroll = false
);

//Thank you for using this Code snippet.

echo '</td><td valign="top" align="center" width="15%">';

global $scripturl, $modSettings, $sourcedir;

$now = mktime() + $modSettings['time_offset'] * 3600;
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array();

         $day_name_length = 2;
         $month_href = $scripturl . '?action=calendar';
         $first_day = 0;
         $pn = array();

$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()

#retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$events = calendarEventArray($low_date, $high_date);
$birthdays = calendarBirthdayArray($low_date, $high_date);

#add important days to the days array
foreach($events as $startdate => $value)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : '#191919').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($event['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

foreach($birthdays as $startdate => $value)
$days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birth['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');

$today_date = $year.'-'.($month<10 ? '0'.$month : $month).'-'.$today;

if(empty($events[$today_date]))
$days[$today] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>');
else
$days[$today] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: yellow; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>');


$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
$day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name

list($month, $year, $month_name, $weekday) = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).' '.$year;  #note that some locales don't capitalize month and day names

#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\n".
'<caption >'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
#if day_name_length is >3, the full name of the day will be printed
foreach($day_names as $d)
$calendar .= '<th class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
if($weekday == 7){
$weekday   = 0; #start a new week
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar.'</tr>';

#crate notice for the next N days events. N is set in Settings.
if (ssi_todaysCalendar('')) {
$result = ssi_todaysCalendar('');
if(!empty($result['events']))
{
echo '<tr><td><hr></td><td colspan="5" class="smalltext" align="center"><b>Upcoming</b></td><td><hr></td></tr><td colspan="7" class="smalltext">';
echo '
<span style="color: #' . $modSettings['cal_eventcolor'] . ';">' . $txt['calendar4b'] . '</span><br /> ';
$events = $result['events'];
foreach ($events as $event)
{
echo '
'.substr($event['start_date'],5 , 2).'/'.substr($event['start_date'],8).':';
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '</td></tr>';
}

echo '</table>';

echo '<br /><br />';

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.7.1        //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 5/9/2007
// 1.7.1
// - quick fix to parsing the url
//
// Updated 5/9/2007
// 1.7
// - added option to view pics that members on your buddy list posted
//
// For list of all previous updates history, see the UPDATES.TXT attached file
// in the post where you got this code, or the .ZIP file if you downloaded it
//
// Used in a TinyPortal phpblock or Article.
// This block displays random picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

global $scripturl, $db_prefix, $modSettings, $boardurl, $ID_MEMBER, $user_info, $context;

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 1;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 0;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 1;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 1;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 1;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?

$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;


//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = "4,2,7" - don't show categories 2, 4, or 7
$gal_disallowCats = "";
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

if (empty($modSettings['gallery_url'])){
$modSettings['gallery_url'] = $boardurl . '/gallery/';
}

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort)){
$gal_sort_text = 'DESC';
} else {
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile"){
$gal_member = empty($_GET['u']) ? $ID_MEMBER : $_GET['u'];
}
// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view')){
$gal_query = '
SELECT
thumbfilename,
ID_PICTURE,
ID_MEMBER,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
ID_CAT
FROM '.$db_prefix.'gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "AND ID_MEMBER = NULL " : "AND ID_MEMBER in ($gal_buddylist)")) : "AND ID_MEMBER = $gal_member" ).'
'.(empty($gal_disallowCats) ? "" : " AND ID_CAT NOT IN ($gal_disallowCats)").'
'.(empty($gal_allowCats) ? "" : " AND ID_CAT IN ($gal_allowCats)").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}
$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';
$gal_result = mysql_query($gal_query);
if (!$gal_result){
// error retrieving information from database
if (mysql_errno() == 1146){
echo '<p />Error, no database found!<p />';
} else {
echo '<p />MySQL error:'.mysql_error().'<p />';
}
} else {
echo "\n".'<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%">'."\n";

$gal_colcnt = 1;
echo " <tr>\n";
while ($row = mysql_fetch_assoc($gal_result)){
if ($gal_colcnt > $gal_columns){
// close out the row and start a new row
echo " </tr>\n <tr>\n".' <td colspan="'.$gal_columns.'"><hr /></td>'."\n </tr>\n <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}
echo ' <td class="'.$gal_textclass.'" align="center">'."\n";
// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle)){
echo " ".($ID_MEMBER == $row['ID_MEMBER'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;id='.$row['ID_PICTURE'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}
// display the picture thumbnail and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['ID_PICTURE'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";
// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate)){
echo 'Posted';
if (!empty($gal_dispMember)){
// display the membername who posted pic?  need to get name based on ID_MEMBER
$gal_tmp = mysql_fetch_assoc(mysql_query("SELECT memberName FROM ".$db_prefix."members WHERE ID_MEMBER = ".$row['ID_MEMBER']));
echo ' by <a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$gal_tmp['memberName'].'</a>';
}
echo "<br />\n";
}
// display category if enabled
if (!empty($gal_dispCategory)){
// get category name based on category id
$gal_tmp = mysql_fetch_assoc(mysql_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE ID_CAT = ".$row['ID_CAT']));
echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['ID_CAT'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}
// display number of views if enabled
if (!empty($gal_dispViews)){
echo "Viewed ".$row['views']." times<br />\n";
}
// display dimensions if enabled
if (!empty($gal_dispDimensions)){
echo $row['width']."w X ".$row['height']."h<br />\n";
}
// display filesize if enabled
if (!empty($gal_dispSize)){
echo $row['filesize']." bytes<br />\n";
}
// display description if enabled
if (!empty($gal_dispDescription)){
echo "<br />".$row['description']."<br />\n";
}
echo " </td>\n";
$gal_colcnt++;
}
mysql_free_result($gal_result);
echo " </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';
if (!empty($gal_buddies) && empty($_GET['gal_viewall'])){
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
} else {
echo 'Sorry, you do not have permission to view pictures!';
}

echo '</td></tr></table>';

Nathaniel

Okay, to fix those undefined errors, you should be able to perform these edits:

Replace this code:
// Lets call the file
global $sourcedir;


With this code:
// Lets call the file
global $sourcedir, $txt;


Replace this code:
#add important days to the days array
foreach($events as $startdate => $value)
   $days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : '#191919').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($event['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');
   
foreach($birthdays as $startdate => $value)
   $days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($birth['start_date'],8).'" target="_self">'.substr($startdate,8).'</a>');


With this code:
#add important days to the days array
foreach($events as $startdate => $value)
   $days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : '#191919').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self">'.substr($startdate,8).'</a>');
   
foreach($birthdays as $startdate => $value)
   $days[substr($startdate,8)] = array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; background-color: '.(substr($startdate,8)<$today ? 'lightblue' : 'yellow').'; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.substr($startdate,8).'" target="_self">'.substr($startdate,8).'</a>');


To fix the security error, I believe that you will have to use the 'db_query()' function instead of the 'mysql_query()' function. I would do that for you, but its probably better if you try to contact the user that created this code block (Dragooon), so that they can try to fix it.
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

dracius

#9
Well, I'm not sure where the code is that's giving the SQL error.

I removed all the custom actions, so that the pages were blank, and still got the error.

So it's one of the other files, but I have no idea where to start looking.

If you're willing, I can set you up with admin and ftp to the directory. This is a rather massive bug, that's stopping some ppl from even going to the site, so I'd be willing to even pay a small fee to have these fixed.

PS: I made the changes you suggested, and the forum errors went away. Thank you a billion for that. :)

Still receiving the SQL error however which causes certain pages to either not load, or load extremely slow at times.
  :'(

[SiNaN]

What does the error message say exactly?
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: