PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 26th, 2012, 03:30 PM
totalknowledge totalknowledge is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 60 totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 58 m 28 sec
Reputation Power: 8
Include a files Class or Data without displaying the page.

Wanted to see if anyone has a solution for my problem off the top of their head.

We have a set of pages for our system that are autogenerated by a program. (PHP Report Maker). These php pages contain both html and php. We have another section of the website where we post quick data based on the PHP Report Maker program. The solution we have in place right now is to copy the class out of the file. I would like to be able to some how include the file, or scrape the page instead of copying the class over so that changes are automatically handeled. I can't just use file_get_content because the site requires a log in. I am pretty sure it can be done with cURL, but the solution is likely to be over complicated for what we are doing and my supervisor won't accept the code. Another solution could be to use ob to caputre the output from the page and throw it away, but that isn't really a very eloquent solution and again is likely to be rejected by my supervision.

Is there a simple obvious solution I am missing?

Reply With Quote
  #2  
Old December 26th, 2012, 04:01 PM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,885 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 2 Weeks 3 Days 8 h 17 m 9 sec
Reputation Power: 581
I think your explanation is a bit confusing as it relates to the title. You use 'include' or 'require' for PHP code and nothing is output until you have PHP output it. On the other hand 'file_get_contents' is used for reading HTML (as well as other non-PHP things) with PHP. In your case, if I understand, you don't have to worry about non-log users since you can locate the HTML and included PHP files in a private directory. The public PHP code is what would handle authentication then load the include files and output what ever HTML you want from the private directory or directories. The user running HTTPD would be the only one that needs read access to it.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old December 26th, 2012, 05:41 PM
okesimojs okesimojs is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 7 okesimojs User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 28 sec
Reputation Power: 0
Please, don't get it twisted. You should be able to use : include() or require() to call your class, html or even php page on the fly without disclosing the page.

Go on top of the page you want to call the class or html document and type:

Include('pagename.html');
Include('myclass.php');
Comments on this post
gw1500se disagrees: Incorrect. It the pages are in a public directory a user can get at them one way or another.

Reply With Quote
  #4  
Old December 26th, 2012, 06:38 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,944 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 16 m 54 sec
Reputation Power: 7053
There is no way to include another PHP file without executing all of the code in it. In other words, if you have a PHP file that contains a mixture of PHP functions, classes and in-line code you can't include the functions and classes without executing the in-line code too. Using output buffering and then just discarding the output is really the only way you could do this; of course, that assumes that the in-line code doesn't change the state of the data at all.

Neither file_get_contents nor cURL can be used to include PHP functions or classes from another file.

You could write a script that modifies the generated output and then run that afterwords to get just the code you want to keep from it.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #5  
Old January 2nd, 2013, 06:53 AM
totalknowledge totalknowledge is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 60 totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 58 m 28 sec
Reputation Power: 8
Quote:
Originally Posted by E-Oreo
There is no way to include another PHP file without executing all of the code in it. In other words, if you have a PHP file that contains a mixture of PHP functions, classes and in-line code you can't include the functions and classes without executing the in-line code too. Using output buffering and then just discarding the output is really the only way you could do this; of course, that assumes that the in-line code doesn't change the state of the data at all.

Neither file_get_contents nor cURL can be used to include PHP functions or classes from another file.

You could write a script that modifies the generated output and then run that afterwords to get just the code you want to keep from it.


Sorry I didn't completely make clear that I need either the class, or the generated output after variable are passed in. So include doesn't work since it executes the page, but without the proper post/get variable being set. I have a couple of ideas now, and I will post back for postarity if something presents itself as a clear answer.

Reply With Quote
  #6  
Old January 2nd, 2013, 05:53 PM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Lost in code
Click here for more information.
 
Join Date: Dec 2004
Posts: 7,944 E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)E-Oreo User rank is General 91st Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 10 h 16 m 54 sec
Reputation Power: 7053
You can set $_GET and $_POST manually before including the file.

Reply With Quote
  #7  
Old January 3rd, 2013, 12:42 PM
totalknowledge totalknowledge is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 60 totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level)totalknowledge User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 58 m 28 sec
Reputation Power: 8
Quote:
Originally Posted by E-Oreo
You can set $_GET and $_POST manually before including the file.


Silly me, see that was the obvious answer I new was out there. Ultimately this isn't going to work either. After having put some thought into it. The variables are just as likely to change as the SQL.

I think what I will do is suggest we write a puppet script that auto-generates the new class file from the PHPReportMaker file each time we puppet (which is how we distribute new content/changes anyway)

Thanks for being my sounding board.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Include a files Class or Data without displaying the page.

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap