The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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? |
#2
|
|||
|
|||
Quote:
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] open './includes/functions_bbcodeparse.php'; FIND THIS... Code:
global $html_allowed; Code:
global $html_allowed, $post; 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: 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 |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
Quote:
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 ); Code:
$bbcode = process_files ( $bbcode, $post_ok ); Sonia |
#5
|
|||
|
|||
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. |
#6
|
|||
|
|||
Quote:
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 |
#7
|
|||
|
|||
Quote:
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? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|