wookie Posted February 20, 2008 Share Posted February 20, 2008 This is an autoposting script that posts direct to SMF (Simple Machine Forum), I was given this to work with but I am getting the following error. Parse error: syntax error, unexpected '<' in /home/stev1965/public_html/foru/automate.php on line 125 I can see by previewing the message here the syntax is not quite right in the last part of this script due to the colours and the problem part being all black. I'm thinking that its the ?> in $txt = preg_replace( !s*<br(s*/)?>\s*!i', "\n", $txt); that is the error but could be wrong (and most probably...I am wrong). Can anyone see the problem to help me solve this? <?php include_once('/absolute path/SSI.php'); require_once($sourcedir . '/Post.php'); require_once($sourcedir . '/Subs-Post.php'); // comment out below line to run in shell if (!isset($context['user']) || !$context['user']['is_admin']) die ('Unknown error 744 has occurred'); $topic = 0; // set to 0 for new topic, set to a topic id to reply $board = 1; // set to valid board id $ID_MEMBER = 1; $_POST['subject'] = 'you\'re okay'; // the notify function uses this $msgSubject = addslashes($_POST['subject']); $msgBody = '[quote author=anon]<br> You can use bbc code here<p> This script assumes you have html-ized body which it will convert to smf compatible format [/quote] <p> it\'s all good '; $msgBody = prepBody( $msgBody); $msgOptions = array( 'id' => 0, // set id to modify 'subject' => $msgSubject, 'body' => $msgBody, 'icon' => 'xx', // look at smf_message_icons table to see all possible values 'smileys_enabled' => 1, 'attachments' => empty($attachIDs) ? array() : $attachIDs, ); $topicOptions = array( 'id' => empty($topic) ? 0 : $topic, 'board' => $board, 'poll' => null, 'lock_mode' => 0, 'sticky_mode' => null, 'mark_as_read' => true, ); $posterOptions = array( 'id' => $ID_MEMBER, 'name' => 'some name', 'email' => 'me@domain.com', 'update_post_count' => 1 ); $newTopic = empty($topic) || $topic == 0; createPost($msgOptions, $topicOptions, $posterOptions); if (isset($topicOptions['id'])) $topic = $topicOptions['id']; if ($newTopic) notifyMembersBoard(); else sendNotifications($topic, 'reply'); redirectexit('topic=' . $topic); // take an htmlized $txt and turn it into a smf compatible msg // no cr lf, no html tags, <br> turned into <br /> and <p> made into <br /><br /> function prepBody( $txt) { // cr lf to spaces $txt = str_replace( "\r", ' ', $txt); $txt = str_replace( "\n", ' ', $txt); // reduce blank spaces $txt = preg_replace( '/[ ][ ]+/', ' ', $txt); // turn <br> or <br /> into \n $txt = preg_replace( !s*<br(s*/)?>\s*!i', "\n", $txt); // turn <p ...> and <p> into \n\n $txt = preg_replace( '/\s*<p([^>]+|)>\s*/i', "\n\n", $txt); // mercilessly strip all other html $txt = preg_replace( '/<[^>]+>/', '', $txt); $txt = preg_replace( '!</[a-z]+>!i', '', $txt); // turn \n back to <br /> $txt = str_replace( "\n", '<br />', trim( $txt)); return addslashes($txt); } ?> Many thanks Wookie Quote Link to comment https://forums.phpfreaks.com/topic/92089-automateautopost-script-giving-errors/ Share on other sites More sharing options...
rhodesa Posted February 20, 2008 Share Posted February 20, 2008 you are missing a single quote $txt = preg_replace( '!s*<br(s*/)?>\s*!i', "\n", $txt); Quote Link to comment https://forums.phpfreaks.com/topic/92089-automateautopost-script-giving-errors/#findComment-471580 Share on other sites More sharing options...
wookie Posted February 20, 2008 Author Share Posted February 20, 2008 Many thanks rhodesa, much appreciated and topic is solved now. Wookie Quote Link to comment https://forums.phpfreaks.com/topic/92089-automateautopost-script-giving-errors/#findComment-471660 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.