TinyPortal

Development => Support => Topic started by: Inny on April 22, 2009, 09:55:37 AM

Title: PHP Aid
Post by: Inny on April 22, 2009, 09:55:37 AM
Link to my site: http://www.epu-wow.com
SMF version: 1.1.8
TP version: 1.0.3
Theme name and version: Urban by Dzinerstudio
Mods installed:
1.     Pretty URLs Extras      0.9       [ Uninstall ]  [ List Files ]  [ Delete ]
2.    Move Old Topics    1.0    [ Uninstall ] [ List Files ] [ Delete ]
3.    Separate Sticky and Normal Topic    1.0    [ Uninstall ] [ List Files ] [ Delete ]
4.    Advanced Contact Form    1.1    [ Uninstall ] [ List Files ] [ Delete ]
5.    SMF Gallery Pro    1.4.5    [ Uninstall ] [ List Files ] [ Delete ]
6.    MCLegendII.2    3.0    [ Uninstall ] [ List Files ] [ Delete ]
7.    TinyPortal    1.075    [ Uninstall ] [ List Files ] [ Delete ]
8.    Regular smileys to dark background smiley set    1.0    [ Uninstall ] [ List Files ] [ Delete ]
9.    BBC Blizzard Quote Tag    1.0.3    [ Uninstall ] [ List Files ] [ Delete ]
10.    SMF 1.0.15 / 1.1.7 Update    1.0    [ List Files ] [ Delete ]
11.    SMF 1.0.14 / 1.1.6 Update    1.0    [ List Files ] [ Delete ]
12.    Aeva ~ Auto-Embed Video & Audio    5.2.56    [ List Files ] [ Delete ]
13.    Internal_Links_Use_Same_Window    1.2    [ Uninstall ] [ List Files ] [ Delete ]
14.    Googlebot & Spiders Mod    2.0.4    [ Uninstall ] [ List Files ] [ Delete ]
15.    [HTML] Permission Mod    1.01    [ Uninstall ] [ List Files ] [ Delete ]
16.    No Spam by Guests!    0.2    [ Uninstall ] [ List Files ] [ Delete ]
17.    Perfect Smiley Set    1.0    [ Uninstall ] [ List Files ] [ Delete ]
18.    TinyPortal    1.063    [ List Files ] [ Delete ]
19.    vBulletin Style Meta Tags    1.1    [ Uninstall ] [ List Files ] [ Delete ]
20.    Visual Verification Options    0.5.2    [ Uninstall ] [ List Files ] [ Delete ]
21.    RSS Feed Icon    1.1    [ Uninstall ] [ List Files ] [ Delete ]
22.    Aeva ~ Auto-Embed Video & Audio    6.2.75    [ Uninstall ] [ List Files ] [ Delete ]
23.    SMF 1.0.13 / 1.1.5 / 2.0 b3.1 Update    1.0    [ List Files ] [ Delete ]
24.    SMF 1.0.16 / 1.1.8 Update    1.0    [ Uninstall ] [ List Files ] [ Delete ]
25.    Regular smileys to dark background smiley set    1.0    [ Uninstall ] [ List Files ] [ Delete ]
26.    SMF Media Gallery    1.5.5    [ Uninstall ] [ List Files ] [ Delete ]
27.    User Control Panel By Alan S    2.0    [ Apply Mod ] [ List Files ] [ Delete ]
28.    Highslide Image Viewer    1.0    [ Uninstall ] [ List Files ] [ Delete ]
29.    Pretty URLs    0.9.1    [ Uninstall ] [ List Files ] [ Delete ]
30.    SMF Secure Login    1.0.4a    [ Uninstall ] [ List Files ] [ Delete ]
31.    Spoiler Tag    0.6    [ Uninstall ] [ List Files ] [ Delete ]
32.    reCAPTCHA for SMF    0.9.5.3    [ Uninstall ] [ List Files ] [ Delete ]
33.    AjaxChat Integration    3.0    [ Apply Mod ] [ List Files ] [ Delete ]
34.    Hide Info Center From Guests    1.0    [ Uninstall ] [ List Files ] [ Delete ]
Related Error messages: No error messages

Im requiring some aid to include something in a php article. Anyone that can help feel free to PM or reply here.

Thanks if advance.

P.S.: Some mods are just uploaded and no installed.
Title: Re: PHP Aid
Post by: Lesmond on April 22, 2009, 10:06:38 AM
Not that I am any good with php, to help you we would need more info, like what do you want to add to a article?  or you could read the Posting Guidelines (http://www.tinyportal.net/index.php/topic,581) Please!
Title: Re: PHP Aid
Post by: Inny on April 22, 2009, 10:12:48 AM
I dont see how my Site info will help on this since its a simple php include in an article, thats why i posted this topic in Chit-Chat and not Support.

Edited my first post to fit your needs.

Missed a question: Im generating daily reports. Those daily reports are saved in a directory in the server root. In that directory i have an index.html which gives links to various html report files in that directory.

So far i was adding those reports in an iframe, but i would like to work on it some more and include them with php. Problem i have with that is that the links in the index.html are pointing after the article name.

This is the code i tried to use.


  /* If the script you are trying to include a file into is
       within a sub-folder of the web root, then include
       that folder in the path*/
    $dirName = dirname($_SERVER['PHP_SELF']);

    // If the including folder is sitting below the script, omit this part.

    /* Concatenate all the above values to set the includes
       folder in the path of php parser to find the scripts
       called with the include() function.*/
    ini_set('$dirName . 'raidreports/190409/');

    // After the above configuration, now you can call your scripts just by their name:
    include('index.html');



Title: Re: PHP Aid
Post by: Ken. on April 22, 2009, 12:17:31 PM
Inny, I've moved your topic to the support boards so that one of our code specialists may see it and be able to offer help.
Title: Re: PHP Aid
Post by: Zetan on April 22, 2009, 01:30:16 PM
Quote from: Inny on April 22, 2009, 09:55:37 AM

Anyone that can help feel free to PM or reply here.


We try not to encourage the use of PMs for support, please keep all support topics in the boards where other members can benefit.

Thanks.


Title: Re: PHP Aid
Post by: Inny on April 22, 2009, 01:33:55 PM
Quote from: Zetan on April 22, 2009, 01:30:16 PM
Quote from: Inny on April 22, 2009, 09:55:37 AM

Anyone that can help feel free to PM or reply here.


We try not to encourage the use of PMs for support, please keep all support topics in the boards where other members can benefit.

Thanks.




Yeah i asked for PM support because its not TP specific (kinda), while i knew that someone else might need it, there are plenty of forums around that i can ask this but im more bonded with this one :P

In any case thanks.
Title: Re: PHP Aid
Post by: JPDeni on April 22, 2009, 02:33:49 PM
I'm wondering about the use of include here. That function should be used with a php file. The function loads in the file and tries to execute it. There's nothing to execute in an html file.

What you can do is read the file into memory and then echo it out. For example, the file command reads the file and places it into an array. Then it would just be a matter of looping through with a foreach and echo-ing the line.

Also, I'm not familiar with the ini_set function, but in reading about it, I don't think that's what you want.

You might give this a try:


$dirName = dirname($_SERVER['PHP_SELF']);
$fileName = '$dirName . 'raidreports/190409/';
$lines = file($fileName);
foreach ($lines as $line)
  echo $line;


You might still run into trouble if this is a complete html file, though, because you're going to have an extra head section and other stuff that shouldn't be in an article. I'm not sure if it'll cause any problems or not. Only one way to find out. ;)
Title: Re: PHP Aid
Post by: Inny on April 22, 2009, 05:08:28 PM
The above gives error on line 2.

The html file is complete yes. I guess any problem wont show up with iframe but it will with this method.
Title: Re: PHP Aid
Post by: IchBin on April 22, 2009, 05:35:30 PM
$fileName = '$dirName . 'raidreports/190409/';

Should be:
$fileName = $dirName . 'raidreports/190409/';
Title: Re: PHP Aid
Post by: Inny on April 22, 2009, 07:16:34 PM
becomes an empty article this way.

Only way i could make it work was with include, just somehow need to find a way to make the links right
Title: Re: PHP Aid
Post by: JPDeni on April 22, 2009, 08:47:39 PM
QuoteOnly way i could make it work was with include

The include worked? What is the issue, then?
Title: Re: PHP Aid
Post by: Inny on April 22, 2009, 10:27:53 PM
Include Method. (links broken)
Here (http://www.epu-wow.com/page/118/)

Here base url is the Article url. Somehow if its duable i wanna change base directory so the links work.

Iframe Method. (Working Fine but its iframe :()
Here (http://www.epu-wow.com/page/148/)

Normal Without TP
Here (http://www.epu-wow.com/raidreports/190409/u_0x0500000001A7DCFF_1.html)

Title: Re: PHP Aid
Post by: Ianedres on April 22, 2009, 11:51:30 PM
Is the script (running from SMF/TP's directory) interpreting the $dirName improperly?

Can you refer to the location by way of relative links? Using '../' before the pathname to the files? That way, the script goes up one directory (presumably to the root) before moving over to the intended path?
Title: Re: PHP Aid
Post by: JPDeni on April 23, 2009, 01:14:26 AM
It would have been very handy for you to have given us the information about what you were getting at the start. Then I could have told you that you will have to parse the links if you want to use them in an article. Obviously just printing them out doesn't do what you want it to do.
Title: Re: PHP Aid
Post by: Inny on April 23, 2009, 01:27:06 AM
Attaching a small zip with the actual report.

raidreports directory is in my server root. Same as SMF if that matters.


P.S. Bad typo, instead of raidreports is raireports.
Title: Re: PHP Aid
Post by: Ianedres on April 23, 2009, 04:33:08 AM
Several things...

1) directory changes each day, thus the article would need to automatically determine such and link accordingly.
2) base target needs to be set; used echo to output the ole' "base href" kludge.
3) links within the generated report link directly to file (i.e. the report script would have to be rewritten)

I handled #1 and #2 with your archived info by placing a directory as "/raidreports"  in the root. Fill in your domain in the first line...$yourdomain = 'http://www.yourdomain.com';

$numdate = date("dmy");

echo '<base href="' . $yourdomain . '/raidreports/' . $numdate . '/" > ';

include("../raidreports/{$numdate}/index.html");


Problem #3 will remain; it will display the first page in the article, but the links go directly to another page without TP...
Title: Re: PHP Aid
Post by: Inny on April 23, 2009, 07:16:22 AM
For each report i create a new article, forgot to mention that.

With the iframe script i was only changing the date.

Gonna give a go at the code you gave me and reply back.

Edit: Select Box is not working for me, but thats maybe because of PrettyUrls. Gonna try something with .htaccess.