SimplePortal
Customization => Custom Coding => Topic started by: locutusweb on January 30, 2013, 05:20:06 AM
-
Hi,
I am experimenting with sort of commenting system. I found some code to create a post here: http://www.simplemachines.org/community/index.php?topic=404858.0
I created a page in simpleportal's custom page system like this:
<?php
//set some arbitrary data
require_once('SSI.php');
require_once('Sources/Subs-Post.php');
$name="Put a name here";
$subject="Put your subject here";
$email="email@yourdomain.com";
$message="Isnt it great when things just work!";
$message = $smcFunc['htmlspecialchars']($message, ENT_QUOTES);
preparsecode($message);
$msgOptions = array(
'subject' => '[Feedback] ' . $smcFunc['htmlspecialchars']($_REQUEST['subject'], ENT_QUOTES),
'body' => $message,
);
$topicOptions = array(
'board' => 78, // this is ID of board where message gets posted
);
// if guest use specifed name and email
if ($user_info['is_guest'])
{
$posterOptions = array(
'name' => $smcFunc['htmlspecialchars']($_REQUEST['name'], ENT_QUOTES),
'email' => $smcFunc['htmlspecialchars']($_REQUEST['email'], ENT_QUOTES),
);
}
// otherwise just use user id and don't count as a post
else
{
$posterOptions = array(
'id' => $user_info['id'],
'update_post_count' => false, // don't count as a post
);
}
createPost($msgOptions, $topicOptions, $posterOptions);
// display something like thank you page
?>
But I get this fatal error:
Fatal error: Function name must be a string in /home/***/domains/***/public_html/Sources/Subs-Portal.php(1157) : eval()'d code on line 14
Could someone help me out?
-
locutusweb,
You neglected to include the necessary globals at the onset of the block and also all your $_REQUEST array must be checked if empty or your log will be full of undefined errors. Although this is a block or page you are attempting to create, the support you seek is that of coding itself & is not really related to the SimplePortal software.
Please post your question at simplemachines.org in this board: SMF Scripting Help (http://www.simplemachines.org/community/index.php?board=8.0)
-
You neglected to include the necessary globals at the onset of the block
That's it. Thanks for shining your light on this.
and also all your $_REQUEST array must be checked if empty or your log will be full of undefined errors.
That was still part of th original code, I remove all the $_REQUEST's.
Although this is a block or page you are attempting to create, the support you seek is that of coding itself & is not really related to the SimplePortal software.
The script worked nice "stand alone"; integrated in a Simpleportal page/block it failed. I think it's a grey area.
Anyway thanks for the help.