News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

HELP:News integration for my website.

Started by mpglivecarlo, October 23, 2009, 06:20:58 PM

Previous topic - Next topic

Arantor

Assuming it's just raw subject and message... I'm fairly sure off hand in 1.1 it's this:

$subject = strtr($func['htmlspecialchars'](stripslashes($subject)), array("\r" => '', "\n" => '', "\t" => ''));
$message = $func['htmlspecialchars'](stripslashes($message), ENT_QUOTES);
preparsecode($message);


P.S. No, I don't.
Holder of controversial views, all of which my own.


mpglivecarlo

#81
Quote from: Arantor on March 05, 2010, 04:24:43 PM
Assuming it's just raw subject and message... I'm fairly sure off hand in 1.1 it's this:

$subject = strtr($func['htmlspecialchars'](stripslashes($subject)), array("\r" => '', "\n" => '', "\t" => ''));
$message = $func['htmlspecialchars'](stripslashes($message), ENT_QUOTES);
preparsecode($message);


P.S. No, I don't.

Not working right,

When using code u gave me using it before utf-8 conversion the message does not get posted because of the accents. And when using conversion before your code html strings on the message get damaged or get interpreted like text only in smf.

what im doing is first converting string to UTF-8 (message) and then runing it thru your code. Utf-8 conversion goes right cause accents are not being damaged and neither are the html tags.

just needing the single quotes removed without affecting the html tags and i think im done.

Arantor

That code came directly from Post.php, Post2() function, you know where subjects and messages are transferred during posting...
Holder of controversial views, all of which my own.


mpglivecarlo

mmm, seems i will have to delete or edit every single problematic string so html tags dont get lost and dont get mysql syntax errors.

thx tho

mpglivecarlo

another question, is there a way that with create post an attachment can be inserted into the table? i have the image file on a folder inside the forum folder. i looked at the create attachment but dont know if that only works when uploading the file.

Arantor

It's a lot more complex than that. Between Post2() and createAttachment, they handle the upload, hashing the filename, renaming it, adding a new DB record, and updating the DB records to match the post.

More specifically, Post2() sanitises that the attachment can take place, and createAttachment does it - have a look at the Function Database to see exactly what it expects and what it will do for you. It will sort of do what you want, but it'll end up doing a lot more processing (like thumbnails, for example)
Holder of controversial views, all of which my own.


mpglivecarlo

there was a variable in create attachment that asks for a state i would think that's some sort of response between scripts to have a status of the file, but dont know exactly what could i set on the array to skip this steps between scripts and just generate the DB entry with the info, and rename file with correct hash.

Arantor

You know there's a function database here, right? See under the Support tab.

Tells you what almost every function in SMF does, what parameters it needs and what to expect from it.
Holder of controversial views, all of which my own.


mpglivecarlo

Quote from: Arantor on March 06, 2010, 06:09:10 PM
You know there's a function database here, right? See under the Support tab.

Tells you what almost every function in SMF does, what parameters it needs and what to expect from it.

yes i know thats what i mean, createAttachment() has a variable whitch is an array named errors but it says only the posible error responses but when it has no errors then what should it be? all the other non-optional variables that are used by the function i can set them and have the information for, but thats the only one that havent got figured out.

Arantor

Yes, I see what you mean.

Clue here is in the function spec, it's a void function and it uses &$attachmentOptions - void means it doesn't actually *return* a value (you don't call it with $variable = createAttachment(...)) and the & means it's passing the variable in by reference, not by value. Meaning that it can and will change things in the variable after.

$attachmentOptions['errors'] should be empty going in and may contain one or more values coming back out.
Holder of controversial views, all of which my own.


mpglivecarlo

so if i understand correctly, even if i set the variable to an empty value it will still need or be set a value afterwards, so in conclusion i cant use only the createattachment function but need to work with other functions involved aswell?

then if i understood well, can i just make a simple script to insert the records on attachments table with the information needed there? because i did, and i dont know where it goes wrong but once executed some avatar images (mainly the older users avatars) get damaged and replaced by the latest news images.

I think i know what could be wrong, ill test something and maybe my script will be all i need, i havent seen it in SMF1.1 but in RC2 there is an option where you can "regenerate" all attachment thumnails to a certain size, dont know if it exists in SMF 1.1 or is it hidden because of a theem im using, do you know for certain if it exists and where?

Arantor

Seriously, this is not complex PHP to understand.

You build $attachmentOptions with the details of the attachment you want to attach.

$attachmentOptions['errors'] is empty.

Call createAttachment($attachmentOptions).

Notice there is no $variable = createAttachment(...).

createAttachment MODIFIES $attachmentOptions before giving it back to you.

So once you've called it, look to see if $attachmentOptions['errors'] now has something in it.
Holder of controversial views, all of which my own.


mpglivecarlo

didnt understand you first time, ill try and see what i get.

mpglivecarlo

got it working, thx; one question i am using the recent topics function from ssi but when the new migration finishes the recent topics does not output the information. weird. will see how can i fix it.

Arantor

Holder of controversial views, all of which my own.


mpglivecarlo

yes output is set to array, and the function has an exclusion for boards, and the board i am migrating the information is excluded.

Arantor

That's kind of why. Last parameter being array means it won't output anything but returns the value back to your code.
Holder of controversial views, all of which my own.


mpglivecarlo

Quote from: Arantor on March 08, 2010, 01:34:36 PM
That's kind of why. Last parameter being array means it won't output anything but returns the value back to your code.

i know and im using output variables in my code to echo the information with the website style, but no information is getting printed before the migration, after migration i can see the output

mpglivecarlo

hey mate got a question about recent topics or posts function, i know that there is a part of the function where you can exclude board ids so they dont get in the recent list, it says on the function database that it has to be an array or numbers, but is not working for me, can you correct me if i got something wrong plz? here´s code:


<?php
                     $exclude
= array(38, 44);
                     
$topics = ssi_recentTopics(5, $exclude, 'Array');
                        foreach (
$topics as $post)
                               echo
'
                                     <div class="texto_col">
                                     <span>&#38;#9658;</span><a href="'
, $post['href'], '">', $post['subject'], '</a>
                                     <div class="texto_col"><span></span>Por'
, $txt[525], ' ', $post['poster']['link'], '</div>
                                     '
, $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"></a>', '
                                     </div><div class="linea_s"></div>'
;
                   
?>


should exclude new topics from boards 38 and 44. thx

Arantor

Looks right to me. So what exactly does it give you?
Holder of controversial views, all of which my own.


Advertisement: