Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-03-2005, 10:38 AM
JohnBee JohnBee is offline
 
Join Date: Oct 2004
Posts: 544
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default A hack to display .txt file content?

I would like to publish the contents of a .txt file in a thread.
this way when there are updates to that .txt file say from a blog etc.
the thread would update as well.

Would this be hard to do?

The text would contain no formating but I don't want the left justifying
to happen, I have tested pasting a text file with basic formating using the
custom BB code option but when I click SUBMIT everything gets left
aligned

Is it feasible to produce a hack to do this?
Reply With Quote
  #2  
Old 05-03-2005, 12:19 PM
why-not why-not is offline
 
Join Date: Feb 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JohnBee
I would like to publish the contents of a .txt file in a thread.
this way when there are updates to that .txt file say from a blog etc.
the thread would update as well.

Would this be hard to do?

The text would contain no formating but I don't want the left justifying
to happen, I have tested pasting a text file with basic formating using the
custom BB code option but when I click SUBMIT everything gets left
aligned

Is it feasible to produce a hack to do this?
If you give me an example of exactly what you want to do I could show you how to do it!

What I would do is have a simple tag that allows you to diplay the file where you want, like bbcode tag but something you only know. Then when a post is displayed and the that special tag is found it calls the function and the template that would be used to display the file output!

example...

:EDIT:

NOTE use the full path to the file and the file name

Code:
[include_file]my_file.txt[/include_file]
How to do it

open './includes/functions_bbcodeparse.php';

FIND THIS...

Code:
	global $html_allowed;
REPLACE WITH

Code:
	global $html_allowed, $post;
FIND THIS...

Code:
	$bbcode = preg_replace($global_find, $global_replace, $bbcode);

BELOW IT ADD....

Code:
if ( ! $iswysiwyg )
{
	/* place all the userids that can use this tag
	 * 
	 * example userid 1, 4, 7 can use the tag
	 *
	 * $valid_users = array ( 1, 4, 7 );
	 *
	*/

	$valid_users = array ( 1 );

	if ( stripos ( $bbcode, '[include_file]' ) !== false )
	{
		$post_ok = 0;

		if ( ! empty ( $post['userid'] ) && in_array ( $post['userid'], $valid_users ) || ! empty ( $bbuserinfo['userid'] ) && in_array ( $bbuserinfo['userid'], $valid_users ) )
		{
			$post_ok = 1;
		}

		include_once ( './includes/functions_files.php' );
		$bbcode = process_files ( $bbcode, $post_ok );
	}
}

Now create a new file called 'functions_files.php'

place it in your './includes/' directory....

Put the following code in that file....

Code:
<?

function process_files ( $out, $ok )
{
	if ( ( $s = stripos ( $out, '[include_file]' ) ) !== false )
	{
		$t = substr ( $out, 0, $s );
		$u = substr ( $out, ( $s + 14 ) );
		$v = stripos ( $u, '[/include_file]' );
		$w = substr ( $u, 0, $v );
		$x = substr ( $u, ( strlen ( $w ) + 15 ) );

		if ( $ok )
		{
			$out = $t . do_file ( $w ) . $x;
		}
		else
		{
			$out = $t . $x;
		}

		$out = process_files ( $out, $ok );
	}

	return ( $out );
}

function do_file ( $path )
{
	global $stylevar, $vbphrase;

	$display = '';

	if ( is_readable ( $path ) )
	{
		$data = fread ( fopen ( $path, 'r' ),  filesize ( $path ) );

		eval('$display .= "' . fetch_template ( 'my_files' ) . '";');
	}
	else
	{
		$display .= $vbphrase['invalid_file'];
	}

	return ( $display );
}

?>

Now create (2) new 'phrases'
Code:
phrase type: global
phrase name: invalid_file
phrase text: (file not found)

phrase type: global
phrase name: blog_title
phrase text: My Blog Information:
Then create a new template... template name 'my_files'

Code:
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">$vbphrase[blog_title]</div>
	<pre class="alt2" style="margin:0px; padding:$stylevar[cellpadding]px; border:1px inset; width:$stylevar[codeblockwidth]; height:200px; overflow:auto"><div dir="ltr" style="text-align:left;">$data</div></pre>
</div>

All done...

Sonia
Reply With Quote
  #3  
Old 05-03-2005, 12:53 PM
zell_11 zell_11 is offline
 
Join Date: Dec 2004
Location: Edinburgh- Scotland
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got this error when i added it
Unable to add cookies, header already sent.
File: /home/fhlinux199/z/zenogaming.com/user/htdocs/forums/includes/init.php
Line: 27

and at the top of the page

Warning: Missing argument 2 for process_files() in /includes/functions_files.php on line 3
Reply With Quote
  #4  
Old 05-03-2005, 01:11 PM
why-not why-not is offline
 
Join Date: Feb 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by zell_11
I got this error when i added it
Unable to add cookies, header already sent.
File: /home/fhlinux199/z/zenogaming.com/user/htdocs/forums/includes/init.php
Line: 27

and at the top of the page

Warning: Missing argument 2 for process_files() in /includes/functions_files.php on line 3
Hi

Sorry I forgot to put the second ARG in the function call that is used in 'functions_bbcodeparse.php'

I fixed the code above, but all you must do is change this.....

in 'functions_bbcodeparse.php' added code only change

Code:
		$bbcode = process_files ( $bbcode );
To this....

Code:
		$bbcode = process_files ( $bbcode, $post_ok );

Sonia
Reply With Quote
  #5  
Old 05-03-2005, 03:35 PM
JohnBee JohnBee is offline
 
Join Date: Oct 2004
Posts: 544
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

WoW!

Fantastic support guys! thanks a bunch.

I will try this ASAP. Would you still like me to post my .txt file example here?
they are parameter tables / BOM from MCAD software.

So its important that we keep the original text file content spacing etc.
Addionally would this work if we attached the .txt file to a thread?

Ideally we would attach the file, and have a view of it in the thread for quick
study and troublshooting.

Oh! and also since this is possible it takes me to another obvious question.
The software also produces .xml files they are much cleaner than the .txt
file output versions and require no filtering on input accross different work
platforms, we already have the ability to attach them in the forums but what
are the possibilies of viewing either .xml of html files in a thread?

I am just curious about .xml and .html data viewing and I'm not asking anyone
to go out of there way to prove it can be done or anything, its just that if
you could see see this data, would it still function like it does when we publish
it from the software?

ex: Publishing a BOM in MCAD produces a nicely formated Bill Of Materials page
with links and dynamic content to expand and colapse details on the job.

If there was a way to post that in a thread, I think it could revolutionize the
support forums for this type of work environment.
Reply With Quote
  #6  
Old 05-03-2005, 03:42 PM
why-not why-not is offline
 
Join Date: Feb 2004
Posts: 218
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by JohnBee
WoW!

Fantastic support guys! thanks a bunch.

I will try this ASAP. Would you still like me to post my .txt file example here?
they are parameter tables / BOM from MCAD software.

So its important that we keep the original text file content spacing etc.
Addionally would this work if we attached the .txt file to a thread?

Ideally we would attach the file, and have a view of it in the thread for quick
study and troublshooting.

Oh! and also since this is possible it takes me to another obvious question.
The software also produces .xml files they are much cleaner than the .txt
file output versions and require no filtering on input accross different work
platforms, we already have the ability to attach them in the forums but what
are the possibilies of viewing either .xml of html files in a thread?

I am just curious about .xml and .html data viewing and I'm not asking anyone
to go out of there way to prove it can be done or anything, its just that if
you could see see this data, would it still function like it does when we publish
it from the software?

ex: Publishing a BOM in MCAD produces a nicely formated Bill Of Materials page
with links and dynamic content to expand and colapse details on the job.

If there was a way to post that in a thread, I think it could revolutionize the
support forums for this type of work environment.
Hi

Yes all that can be done, I have xml parser that can put xml files in a thread/post and can format the output in many ways, like an array, a list, a numbered list, all with key word link support. I even have one that can show pdf documents in line keeping the exact layout of the pdf file! All using the same rules as this basic example but using other functions too!

Any example you need just ask me!

Sonia
Reply With Quote
  #7  
Old 05-03-2005, 04:36 PM
JohnBee JohnBee is offline
 
Join Date: Oct 2004
Posts: 544
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
WoW!
Fantastic support guys!
Sorry to generalize its a speaking habit.
in case your not a guy

And your support is greatly appreciated! I will work on your shared examples
and see how far I can go with it all. I'll post my progress here, I think a feature
such as this could come in very handy on some types of forums!

.thumbsup.

Well that worked!

now if I put .html in there will it appear in a window or as part of the thread?

I'm not so sure that double posting hack is as useful as it would seem.
it sort of robs us of the thread update feature!

Okay, I installed the hack and everything works GREAT! I have a few questions
though, the search engine does not see anything withint the .txt file.
Although its not A MUST I was wondering if it was possible to intergrate
it right into the thread so that the search engine could read content.

Just curious

Also to post HTML in a thread using this method what changes would I need
to do?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:05 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04354 seconds
  • Memory Usage 2,239KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (10)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete