Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/92089-automateautopost-script-giving-errors/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.