Author Topic: HTML or PHP question  (Read 2878 times)

Offline tfs

  • Quality Assurance
  • *
  • Posts: 974
    • View Profile
HTML or PHP question
« on: September 01, 2011, 10:04:07 pm »
I have a SimpleDesk front page displayed that looks like this...

http://sd2.patsong.com/index.php

And I'd like to give someone direct access to populating the text of one of those colored tables.  I thought that I could allow him to upload a TXT file to the server via FTP, and that in the HTML that creates the page I could somehow display the contents of that TXT file.  (He is 100% trusted)  I don't allow him to edit directly because it's HTML, which he wouldn't be able to do, and also it requires ADMIN access to do that.

So... anyone have an idea how I'd pull the contents of a TXT file into one of those colored tables?
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Offline chilly

  • Beta Tester
  • *
  • Posts: 58
  • Cookie!
    • View Profile
Re: HTML or PHP question
« Reply #1 on: September 09, 2011, 09:43:31 am »
well.. php can open and read the file and display it's content inside that box. I'm just not sure (because I did not yet use it) what you can put into that front page.
got a cookie for me?

Offline cσσкιє мσηѕтєя

  • Co-Founder
  • SD Friends
  • *
  • Posts: 1,158
  • The cake is a lie. We have but cookies.
    • View Profile
Re: HTML or PHP question
« Reply #2 on: September 09, 2011, 10:31:14 am »
I do believe the front page supports PHP, right? If it does, this should work:

Code: [Select]
// This is your file
$your_txt_file = "/path/to/text.txt";

// Read the file
$file_handler = fopen($your_txt_file, 'r');
$file_content = fread($file_handler, filesize($your_txt_file));
fclose($file_handler);

// Echo out the content
echo $file_content;

Offline tfs

  • Quality Assurance
  • *
  • Posts: 974
    • View Profile
Re: HTML or PHP question
« Reply #3 on: September 09, 2011, 12:10:26 pm »
It's not displaying anything.  Maybe because it's all contained within a bbcode HTML wrapper?  Here's what's contained within the front page here... http://sd2.patsong.com/index.php?action=helpdesk;sa=main

Code: [Select]
[html]<span class="upperframe"><span></span></span>
<div class="roundframe"><br>
<div style="text-align: center;"><big>If
your issue is critical, please call the office after filing a ticket
(555)555-1212 and ask for Technical Support. </big><br>
</div>
<br>
<table
style="text-align: left; margin-left: auto; margin-right: auto; width: 95%;"
cellpadding="6" cellspacing="6">
<tbody>
<tr>
<td
style="border: 1px solid rgb(94, 123, 182); background-color: rgb(208, 220, 234); vertical-align: top; width: 24%;"><span
style="font-weight: bold;">REMINDER: </span>the
first Thursday of
each month at 10am CT and repeating at 2pm CT, SD2 hosts webinar
discussion/training sessions on hot topics desired by our clients.
Webinar connection instructions are e-mailed to clients two days prior
to each meeting (also posted on sd2.patsong.com). We
hope you can join us! <em></em> </td>
<td
style="border: 1px solid rgb(88, 13, 74); background-color: rgb(218, 195, 223); vertical-align: top; width: 24%;"><strong></strong><font><span
style="font-weight: bold;"></span></font><span
style="font-weight: bold;">Thursday 7/7, is our First Thursday
TechFest (User Forum) for July.&nbsp; </span>The current schedules
calls for the subject to be "Mapping Software" for people with no sense
of direction.<br>
<br>
</td>
</tr>
</tbody>
</table>
<br>
<table
style="text-align: left; margin-left: auto; margin-right: auto; width: 95%;"
cellpadding="6" cellspacing="6">
<tbody>
<tr>
<td
style="border: 1px solid rgb(88, 13, 74); background-color: rgb(218, 195, 223); vertical-align: top; width: 24%;"><span
style="font-weight: bold;"></span><font><span
style="font-weight: bold;">Check out our main page for important
random filler material!</span></font><br>
<em></em> </td>
<td
style="border: 1px solid rgb(94, 123, 182); background-color: rgb(208, 220, 234); vertical-align: top; width: 24%;"><span
style="font-weight: bold;">SD2 Patsong, Inc. (SD2)</span><br>
4444 N. Hello Ave., #224<br>
Los Angeles, CA&nbsp; 90503<br>
(555)555-1212 - Voice<br>
(888)555-1212 - Toll Free<br>
(555)555-1211 - Fax<br>
<br>
</td>
</tr>
</tbody>
</table>
<br>
<table
style="text-align: left; margin-left: auto; margin-right: auto; width: 95%;"
cellpadding="6" cellspacing="6">
<tbody>
<tr>
<td
style="border: 1px solid rgb(94, 123, 182); background-color: rgb(208, 220, 234); vertical-align: top; width: 24%;"><span
style="font-weight: bold;">REMINDER: </span>the
first Thursday of
each month at 10am CT and repeating at 2pm CT, SD2 hosts webinar
discussion/training sessions on hot topics desired by our clients.
Webinar connection instructions are e-mailed to clients two days prior
to each meeting (also posted on sd2.patsong.com). We
hope you can join us! <em></em> </td>
<td
style="border: 1px solid rgb(88, 13, 74); background-color: rgb(218, 195, 223); vertical-align: top; width: 24%;"><strong></strong><font><span
style="font-weight: bold;"></span></font><span
style="font-weight: bold;"></span><?php // This is your file
$your_txt_file "http://sd2.patsong.com/news1.txt";

// Read the file
$file_handler fopen($your_txt_file'r');
$file_content fread($file_handlerfilesize($your_txt_file));
fclose($file_handler);

// Echo out the content
echo $file_content;?>
<br>
<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
</div>
<span class="lowerframe"><span></span></span>
[/html]

The file I'm trying to display definitely exists.  I've tried using relative paths also.  It's got to be because of the bbcode parser I'm guessing.
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Offline tfs

  • Quality Assurance
  • *
  • Posts: 974
    • View Profile
Re: HTML or PHP question
« Reply #4 on: September 09, 2011, 12:22:58 pm »
Hmm... I've got it in a plain html file, but it's still not working...

http://sd2.patsong.com/Test1.html
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Offline cσσкιє мσηѕтєя

  • Co-Founder
  • SD Friends
  • *
  • Posts: 1,158
  • The cake is a lie. We have but cookies.
    • View Profile
Re: HTML or PHP question
« Reply #5 on: September 09, 2011, 02:21:12 pm »
The frontpage allows you to choose plain text, bbc and php, am I right? I really can't remember how it's set up :P If so, then you need to choose PHP there. If it doesn't support PHP we can solve it using either javascript or a simple iframe (HTML).

Offline tfs

  • Quality Assurance
  • *
  • Posts: 974
    • View Profile
Re: HTML or PHP question
« Reply #6 on: September 09, 2011, 03:40:02 pm »
Front page allows PHP or BBCode, not HTML.  The overall page I want to display is designed in HTML.  Which is why I had been using HTML inside of a bbcode html block.
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Offline cσσкιє мσηѕтєя

  • Co-Founder
  • SD Friends
  • *
  • Posts: 1,158
  • The cake is a lie. We have but cookies.
    • View Profile
Re: HTML or PHP question
« Reply #7 on: September 09, 2011, 08:07:26 pm »
The PHP version will support HTML. Just echo it out instead of using the html tag.

Code: [Select]
<?php

echo'<strong>your html</strong>';

?>

Offline tfs

  • Quality Assurance
  • *
  • Posts: 974
    • View Profile
Re: HTML or PHP question
« Reply #8 on: September 10, 2011, 07:02:14 pm »
Since the final result is to display PHP inside of an HTML table, can it be nested like that?  To have PHP nested within HTML that is itself nested within PHP?

I suppose some testing will tell.  :)
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.

Offline cσσкιє мσηѕтєя

  • Co-Founder
  • SD Friends
  • *
  • Posts: 1,158
  • The cake is a lie. We have but cookies.
    • View Profile
Re: HTML or PHP question
« Reply #9 on: September 11, 2011, 06:40:11 am »
Code: [Select]
<?php

echo'<div>my first html box</Div>
<div>my second html box</Div>'
;

// This is your file
$your_txt_file "/path/to/text.txt";

// Read the file
$file_handler fopen($your_txt_file'r');
$file_content fread($file_handlerfilesize($your_txt_file));
fclose($file_handler);

// Echo out the content
echo '<div>',$file_content,'</div>
<div>My fourth html box, the third one contained the txt-file</div>'
;

?>

Offline tfs

  • Quality Assurance
  • *
  • Posts: 974
    • View Profile
Re: HTML or PHP question
« Reply #10 on: September 11, 2011, 01:23:44 pm »
I must have tried it five different ways yesterday but couldn't get it working.  I've switched to the simplest PHP block in SimplePortal, attempting to display the contents of license.txt, but still haven't gotten it to work.  Regarding the path to the TXT file, should that be the full HTTP path, the full machine name path, or the relative path?  If it's the relative path, is it relative to the root folder of the forum?
A good tree cannot bring forth evil fruit, neither can an evil tree bring forth good fruit.