I am using php JavaBridge library,
the thing is, I need to include the php client library directly from server using
require_once "someremoteurl.com"
For this allow_url_include should be enabled, but I am in situation where this should be avoided.
Is there anyone who did this before? Is there any workaround?
I tried downloading file real-time using fread and then including it from local, but it does not work somehow, giving some php error inside JavaBridge class... I do not see any difference though.
As suggested by Marc B, used the following code:
$remote_contents = file_get_contents($url);
file_put_contents($local, $remote_contents);
include($local);
Didn't work on first try, but worked after adding this line before the include:
define ("JAVA_SERVLET", "/WordBridge/servlet.phpjavabridge");
Related
I am student (not long being doing PHP so don't know a lot about PHP) but I am trying to get my code to work, at first it was working fine, until it was transfer to a different server but since it had I was getting the following error:
'Warning: Cannot modify header information - headers already sent by (output started at /home/deanj/public_html/login.php:21) in /home/deanj/public_html/login.php on line 60'.
Then I got suggested to use ob_start(); so I tried to use it but didnt get much good results. So what do I need to do use this? and is it the best option? if not what is?
p.s. please make it as simple as you can.
In php.ini set output buffering to On. You should NOT have to modify your code using ob_start() since it is clearly an environment issue. The key to knowing that is in your question, "it was working fine, until it was transfer to a different server".
To fix it, in your php.ini file you want:
output_buffering = On
http://php.net/manual/en/outcontrol.configuration.php
That is also likely why the same code worked on one server, but not on your new one (since output buffering was configured differently).
Background:
I'm trying to get tweets from a specified username using PHP and OAuth. This example seems very useful. My problem is that my code doesn't return from the $feed = curl_init(); line near the bottom. There are no errors displayed, I only know that it stops because my debug statements after that line are not executed.
I didn't have cURL installed so I installed it on my Windows machine (using this example). It still doesn't produce any errors, it just leaves and never comes back.
Question:
How do I access cURL from my PHP program where I want to use it?
You need to download the windows php zipped manual installer from windows.php.net, the manual zip comes with all the extensions. Once php has been installed, enable the CURL extensions.. and any other extension that you need in the php.ini file. Copy the php-production.ini to %systemroot% directory and rename it to php.ini.
Hope that helps !!!
I am implementing a template system using the wrapper class in this example: http://www.php.net/manual/en/stream.streamwrapper.example-1.php
I use this code to get the wrapper output:
ob_start();
include("template://" . $template_name);
$template .= ob_get_contents();
ob_end_clean();
However, in some servers this code is not working, all I get is a blank page. I am not sure if it is a php directive issue, I changed allow_url_include to both 0 and 1, but it did not have any effects on the code.
So what is the problem with the code.
EDIT: error logging is on, and it is not showing any errors related to this issue
in some servers this code is not working
In all likelihood, this is because php streams are not available or configured properly on these servers. It die with an error, and you don't see the error because of the output buffer
My host updated to Litespeed and a more stringent Suhosin setup. At first I thought it was Litespeed, but it was indeed Suhosin (I twigged from this thread, thanks!).
It's just a php.ini setting you need to change, you have to add your stream name to the include whitelist:
suhosin.executor.include.whitelist = template://
And then it'll work fine again. Here's a couple more links saying the same:
A bigger example: http://cweiske.de/tagebuch/suhosin-phar.htm
-Others struggling with the same: http://forum.bytesforall.com/showthread.php?t=12262&page=2
Suhosin doco (doesn't really explain with huge detail) search for: suhosin.executor.include.whitelist
I had the same issue and found that PHP Suhosin was causing this 'white screen of death'.
That could explain why this works on some servers and not on others.
There could be a Suhosin config option for dealing with that, check out the website: http://www.hardened-php.net/suhosin/
tl;dr I ended up removing Suhosin which resolved the issue.
The php script is calling four functions that scrape different websites for data.
$returnData[0]=getWebsite1Data($description);
$returnData[1]=getWebsite2Data($description);
$returnData[2]=getWebsite3Data($description);
$returnData[3]=getWebsite4Data($description);
The script displays the web-page correctly if I disable the call to any one random function.
That makes me think its a resource problem. If it is a resource problem how do I correct it in Xampp. I've tried unsetting the variables but that didn't work either.
Make sure Error Reporting is set high enough in php.ini
Check your phpinfo and see what your "memory_limit" is. Try doubling it in your php.ini.
I'm debugging some PHP code written by an outsourcing company (I'm not a PHP guy at all but know the basics; we have an offshore team of PHP developers working for us on this project) that's not working; the code is supposed to be called every 30 minutes by a cron job but its not firing. I tried to run the PHP script via the command line to test if it's working, but it's giving me the following (anonymized) errror:
PHP Fatal error: require_once(): Failed opening required '/myapp/_lib/_classes/MySql.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/myapp/_lib/_base/common.inc.php on line 6
However, the file /var/www/html/myapp/_lib/_classes/MySql.php exists under the proper directory. I'm missing something simple, I'm sure, but like I said I know really nothing beyond the bare basics of PHP and I really need to get this service up and running.
EDIT: The code is using the __autoload() function with all classes in /_lib/_classes
if you start a file name with a slash, it means it's an absolute path. try instead:
require_once('/var/www/html/myapp/_lib/_classes/MySql.php');
Case sensitivity maybe? I've had that problem before.
I'm guessing it's a permissions issue - make sure both your account (for testing purposes) and whatever account cron is going to run your script under (quite possibly yours, but maybe a different one) have read privileges on the file.
Also: the path for the include says /myapp/_lib/_classes/MySql.php, whereas it exists in /var/www/html/myapp/_lib/_classes/MySql.php. Can you change the include to reference the full path?
As said, casing and in addition the correct permissions to access that file are needed.