Display contents of TEXT-file in a post?

Started by SMiFFER, April 19, 2018, 02:59:51 PM

Previous topic - Next topic

SMiFFER

Can I somehow display the contents of a simple text-file in a post?

The file to be displayed could simply be put into the root path of the installed SMF on my server,
just how would or could I display that file?
(It contains a list, merely a CSV)
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

GigaWatt

What do you mean "display it in a post"? Something like a warning before a member posts or opens a new thread?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

SMiFFER

You think much too far:


Display contents of TEXT-file in a post:

When you open the post, the contest of that simple file are included in that post.

Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

GigaWatt

And this is supposed to be a default action, for every user, even admins and mods?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Kindred

There is no good way to do this safely/securely, imo
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SMiFFER

Quote from: GigaWatt on April 21, 2018, 11:53:15 AM
And this is supposed to be a default action, for every user, even admins and mods?

No.

So can it be done? How?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

GigaWatt

I don't know how it's done, but it should be similar to the way this SMF forum warns you about sending a PM to any member. Try writing somebody on this forum a PM, you'll see what I mean ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

albertlast

The simples way which i can imagen,
would be to create a post/topic by hand and
create a cronjob how read the csv and update in the table the body of the topic/post.

Pipke

Quote from: SMiFFER on April 28, 2018, 01:16:56 PM
Quote from: GigaWatt on April 21, 2018, 11:53:15 AM
And this is supposed to be a default action, for every user, even admins and mods?

No.

So can it be done? How?

This will display the content that is written inside the test.txt file at the locationpath to the SMF installation, the file content will display in every post on top and has no permissions, so everyone who has access with permissions to view posts can see it.

in Sources/Display.php

Code (find) Select

// Run BBC interpreter on the message.
$message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);


Code (add after) Select

global $boarddir;
$message['body'] = file_get_contents( $boarddir. '/test.txt').'<hr>'.$message['body'];


"If something is wrong, fix it if you can. But train yourself not to worry: Worry never fixes anything."

Click here to view my mods for SMF

Hey 👋 Did i helped... you like what i do. You can now buy me a coffee! ☕

Kindred

Pipke

that's not what he wants...   he wants ONE post to display the contents of a defined text file.
I assume that, at some point, he will want another post to display a second text file... and so on.

in other words, he needs a BBC that reads a text file
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

SMiFFER

Quote from: GigaWatt on April 28, 2018, 04:33:34 PM
I don't know how it's done, but it should be similar to the way this SMF forum warns you about sending a PM to any member. Try writing somebody on this forum a PM, you'll see what I mean ;).

I can not quite follow you. Which file is displayed there?
I can only see simple text from the language-modules being displayed and that is beside the point.


Quote from: albertlast on April 28, 2018, 05:35:59 PM
The simples way which i can imagen, would be to create a post/topic by hand and
create a cronjob how read the csv and update in the table the body of the topic/post.

That sounds rather feasible. Can you provide an example for
- implementing the cronjob to SMF (a link would be fair enough)
- the code of that fetch-text-from-csv-and-update-table-entry

Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

Aleksi "Lex" Kilpinen

#11


[html]<object width="300" height="300" type="text/plain" data="agreement.txt" border="0" >
</object>[/html]



To show the agreement.txt from the forum root. ;) Edit as needed.
( Edit: Do note, HTML tags only work for admins. )
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

SMiFFER

Thanks, that works for the file that I have.

But the font color is black, I would like to change that, but


[html]<object width="300" height="300" type="text/plain" font color="red" data="agreement.txt" border="0" >
</object>[/html]


does not work properly. What have I done wrong with font color="red" ?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

Aleksi "Lex" Kilpinen

Quite honestly, I am not sure if it's easily possible to affect the styling of the text within an object in that way.... Would have to look in to it.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

SMiFFER

Hm. No matter what I try: The font color of the displayed .txt file is always black.

How come?
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

Aleksi "Lex" Kilpinen

Because the object is separated from the surrounding webpage, for security, and displayed as raw text only. It will not take formatting.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

SMiFFER

Quote from: Aleksi "Lex" Kilpinen on May 11, 2018, 09:40:44 AM
Because the object is separated from the surrounding webpage, for security, and displayed as raw text only. It will not take formatting.

Well that is a pity, but better safe than sorry.

I can live with it for the 1 purpose I want it for...
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

SMiFFER

SOLVED for now,
but if someone finds a way to change the color from BLACK to anything else, feel welcome.
Quote of the day: A troll is an obstinate bloke who only hungers for your attention. If you feed him, he will puke all over you!

Advertisement: