Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP Include only works from the outside?

PHP Include only works from the outside?
Thread Tools
l008com
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Oct 15, 2003, 10:42 AM
 
I got this news portal script for my Vbulletin forum. It takes a predefined forum, and grabs the first post in each and sticks it into a page, as news items. It works really nice, except...
I can only include it using its full URL (http://) when I try to include it locally, I get no output. Very strange. And when I copy all its code and paste it directly into my index file, it still doesn't output. The only way I can get any output is to call or link to the file via its full URL. The problem with this is that it is very very slow to load the page that way. The author said that thats the way the script works, it outputs a whole page and therefore can't be included. But that doesn't make any sense to be at all. I viewed the source of the file when called directly and it doesn't even output html or body tags, just the table tags that it creates and thats it! Its getting very annoying, the author also tried to help me get it working but there must be some sort of communication barrier because he doesn't seem to ever understand what I'm telling him. Does anyone else have any ideas about this situation? I can post the script if needed. Thanks.
     
xanderwilson
Junior Member
Join Date: Aug 2002
Location: North Carolina's Triangle
Status: Offline
Reply With Quote
Oct 15, 2003, 01:59 PM
 
Too many possible problems. Post the script, but only if it's all right with the person who created the script. And be as specific as you can as to what you've done and what you'd like it to do.

Alex.
www.telltaleweekly.org - Funding a Free Audiobook Library. Now available in AAC.
www.alexwilson.com - Alex Wilson Studios
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Oct 15, 2003, 02:08 PM
 
Code:
<? // Simple Newsportal & Threads overview hack // Copyright by KuraFire, 2002 :) // With extra credit to PPN for the permissions section $templatesused = 'newsportal,newsportal_threadbit,newsportal_newsbit'; include('/webfolder/fellsbiker/forum/global.php'); // These variables define your newsforum, limit of newsposts, // limit of threads, and forums to exclude in the threadlisting $newsforum = 17; $newslimit = 4; /* ### NEWS SECTION ### */ $newsql = $DB_site->query("SELECT thread.threadid as tid, thread.title as ttitle, thread.replycount as treply, thread.postusername as user, thread.postuserid as userid, thread.dateline as dateline, post.pagetext as pagetext FROM thread LEFT JOIN post USING (threadid) WHERE forumid=$newsforum GROUP BY thread.threadid ORDER BY thread.threadid DESC LIMIT $newslimit"); while ($news=$DB_site->fetch_array($newsql)) { $userid=$news['userid']; $pagetext=$news['pagetext']; $message=bbcodeparse2($pagetext,"1","1","1","1"); $user=$news['user']; $threadid=$news['tid']; $title=$news['ttitle']; $replycount=$news['treply']; $dateline=$news['dateline']; $dateposted = date("F jS, Y",$dateline); if ($replycount == 1){ $replies = $replycount . " reply"; } else { $replies = $replycount . " replies"; } eval("\$newsbits .= \"".gettemplate('newsportal_newsbit')."\";"); } eval("dooutput(\"".gettemplate("newsportal")."\");"); ?>

This script goes in my forum's folder. The way I have it set up now, is that that main page of that site calls an include() that calls the full URL path of that file, instead of just calling "forum/newsportal.php". When you call it locally, you get no errors and no output of the script. The page also loads very slowly. And I think it will be noticeably faster if I can call it from a local path. Right now when I load the page my stats show two distinct users to the page at once, one from my internal local IP (loading the index page) and one from my external IP (loading the newsportal page from its full URL)
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Oct 18, 2003, 02:31 AM
 
     
clam2000
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Oct 18, 2003, 11:58 AM
 
what does the file 'global.php' look like?

by calling it from outside you are executing php on it (so if there are php tags in that file they will be evaluated by php.)

try replacing that line with:
eval('/path/to/global.php');


--will
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Oct 18, 2003, 12:37 PM
 
whats the difference between eval and include?
     
clam2000
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Oct 18, 2003, 02:22 PM
 
the difference between eval and include is that eval will work on a string, while include works on a file.

it's hard to figure out what isn't working without seeing at least part of the file global.php

--will
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Oct 19, 2003, 12:21 AM
 
global is where vbulletin stores all its info/data i believe, but I don't think it that has much to do with the problem. I don't think. I don't know maybe I'm wrong. Global is also a very big file, and its a commercial script so I don't think I can post it on the web either. My news portal is just an add on I'm trying to get to work.
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 01:23 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,