replace action=post with custom

Started by tdguchi, August 01, 2014, 09:57:27 AM

Previous topic - Next topic

tdguchi

Hi, Im writting a php file, that picks information from another website (via DOM (simple_dom_html.php) i have a form, to insert the url, and a button to submit, so, another file, reads the url, takes the information, and saves it in some php variables.

I have a variable called "$message" which contains all content structured as a like it posted. if I add echo $message, all code is show to be copied then pasted on a new topic.

Now what i want is the includes, and functions to automatically post it in smf (giving title, body, user etc) I have done it in phpbb, but now a need to use smf....

which is what would have to add to my post to send the file to smf. creating a new action

PD something like:

Include ......
Include........

my code and variables

function_to_post


including the user information

thanks

Arantor

You can use the createPost() function in Subs-Post.php (which requires SSI.php to have been loaded first) to perform post creation for you without having to touch any of Post.php's monstrous code (or action=post/action=post2)

tdguchi

#2
Quote from: ‽ on August 01, 2014, 10:12:30 AM
You can use the createPost() function in Subs-Post.php (which requires SSI.php to have been loaded first) to perform post creation for you without having to touch any of Post.php's monstrous code (or action=post/action=post2)

well.... i have read how to use createpost()... but i dont know how to use it... could you write me the structure of a simple createpost() example? (and where to put the php file and how to call it)

thanks


tdguchi

I had read that, and i have put the file in source directory.

but when I tried to point to the file, i get a "hacking attemp" message how can i fix it?

Arantor

You're not supposed to point to that file.

In your file, load SSI.php, then you call createPost() from your file, with three arrays to list the message details, topic details and poster details as documented.

tdguchi

IM new in smf, i dont understand you....

I will tell you what the file needs to do....

I have a .html, where is a forum... i get some information, and the board numer from the url, then, on submit i call to the file, which has the ability to adquire the information, then i hace a variable called "$subject" another called "$messaqe" and another called "$forum_id"

now im putting the structure of createpost() with the arrays, pointing board subject and message to my variables. and nothing happens...

files:
form : http://pastebin.com/NDzmCj8h
php file which posts the content of the form submmited http://pastebin.com/wSxTjuyy

could you tell me what is wrong in the script? I cannot see it...

thanks

vbgamer45

Brief example


require 'SSI.php';

// Create the post
require_once($sourcedir . '/Subs-Post.php');
$msgOptions = array(
'id' => 0,
'subject' => 'Subject Here',
'body' =>  'Body text here',
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => 0,
'board' => 1,
'poll' => null,
'lock_mode' => 0,
'sticky_mode' => null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => 0,
'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']),
);


preparsecode($msgOptions['body']);
createPost($msgOptions, $topicOptions, $posterOptions);

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

tdguchi

Quote from: vbgamer45 on August 01, 2014, 02:45:05 PM
Brief example


require 'SSI.php';

// Create the post
require_once($sourcedir . '/Subs-Post.php');
$msgOptions = array(
'id' => 0,
'subject' => 'Subject Here',
'body' =>  'Body text here',
'icon' => 'xx',
'smileys_enabled' => 1,
'attachments' => array(),
);
$topicOptions = array(
'id' => 0,
'board' => 1,
'poll' => null,
'lock_mode' => 0,
'sticky_mode' => null,
'mark_as_read' => true,
);
$posterOptions = array(
'id' => 0,
'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']),
);


preparsecode($msgOptions['body']);
createPost($msgOptions, $topicOptions, $posterOptions);



yeah... thats what I need to understand it.. only i have a point.... that script posts as a guest... how can i post as a registered user?

JBlaze

Can't remember if the user_id is stored in $user_info['id'] or $user_info['id_member']. It's been a while. Be here's the gist of it.

$posterOptions = array(
'id' => !$user_info['is_guest'] ? $user_info['id'] : 0,
'update_post_count' => !$user_info['is_guest'] && !isset($_REQUEST['msg']),
);
Jason Clemons
Former Team Member 2009 - 2012

Arantor

$user_info['id']. Also I seem to remember if $posterOptions['id'] wasn't supplied it'd try to grab it from $user_info anyway.

JBlaze

Quote from: ‽ on August 01, 2014, 04:53:39 PM
$user_info['id']. Also I seem to remember if $posterOptions['id'] wasn't supplied it'd try to grab it from $user_info anyway.
I thought so too, but that may have changed, or in the case of OP, the session may have been terminated. Who knows. If the latter, the way I posted will still post as guest.
Jason Clemons
Former Team Member 2009 - 2012

Arantor

True, true. Just pointing out the options :)

tdguchi

well, that part is finished, i could post information giving it directly to the script (giving values to the variables) but, when using the form, the script isnt working....  the url is not processed.... the rest of the information is working....

tdguchi

sorry for double post....

i have the url mysite.com/peliculas.php?action=post;board=66.0 and i have a php which have a form mode:post.... how can i get the board id?

thanks

Advertisement: