IIS7 + PHP + Zend - Not executing <= *pic* - php

I have PHP, IIS7, ReWrite Module for IIS and Zend all installed.
I can execute PHP pages just fine, even got PHPINFO showing up.
I setup a Zend quickstart app on IIS and when I open it this is what I see:
You can see from the source that it's not executing the <= portions.
Any idea what needs to change?
alt text http://www.gonrad.com/200902/zendiis.jpg

You need to enable shortags in your php.ini:
short_opentag = on
However, even though Zend's examples use the open tag, for portability you really should use the full echo statement as not all webhosts allow for short_opentag. The short tag might save a bit of time typing but may actually be worse in the long run.

make sure <? is enabled and not just <?php
if you use <?
php.ini --->short_opentag=On

Related

php5 reading remote file the valid way

I recently upgraded from php4 to php5 and with it came the notice that all my remote php file access no longer worked. I've been doing quite a bit of research into this and I dont seem to have a clear answer as to what is the correct way to include remote urls in php5.
The first example is to include the file this way
<?php
$data = file_get_contents("http://example.com/example.inc.php",0);
echo $data;
?>
The 2nd is this way
<?php
$ch = curl_init("http://example.com/example.inc.php");
curl_exec($ch);
curl_close($ch);
?>
and 3rd is to set in my php.ini file
allow_url_include = On
allow_url_fopen = On
and use the good old
<?php include_once('http://example.com/example.inc.php');?>
I want to do this right and secure.
All solutions are correct and there is no real difference in safety AFAIK.
I think the difference can be summed up like this:
The ini-settings provide the behaviour as known from prior versions. The reason why they are disabled by default is the security thread, but that is equal to all three solutions. Including remote files is a security problem, regardless of whether you control the rmeote site or not.
file_get_contents() and the curl extension creates some overhead, since you have to buffer the content, but for php include files that is more a cosmetic thing. Their usage is slightly more complex when reading through a script. But the buffering also adds benefits: you might create a local cache for example or a checksum towards a basic plausibility check. Also a syntax check prior to execution is possible thus preventing the crash of your calling script.
Curl is provided as a php extension. So the curl solution only works when the extension is installed, but it offers a much higher grade of freedom, much more options. If you don't require those stay with the builtin functions.
Well,
First method => Is correct and you shouldnt worry using it.
Second method= > Is correct, but curl extension should be enabled
Third method => Is correct, but using this option is not recommended because enabling allow_url_include likely makes your site vulnerable. For more detail see http://en.wikipedia.org/wiki/Include_vulnerability and this link http://wiki.dreamhost.com/Allow_url_include

How to view PHP or Apache error log online in a browser?

Is there a way to view the PHP error logs or Apache error logs in a web browser?
I find it inconvenient to ssh into multiple servers and run a "tail" command to follow the error logs. Is there some tool (preferably open source) that shows me the error logs online (streaming or non-streaming?
Thanks
A simple php code to read log and print:
<?php
exec('tail /var/log/apache2/error.log', $error_logs);
foreach($error_logs as $error_log) {
echo "<br />".$error_log;
}
?>
You can embed error_log php variable in html as per your requirement. The best part is tail command will load the latest errors which wont make too load on your server.
You can change tail to give output as you want
Ex. tail myfile.txt -n 100 // it will give last 100 lines
See What commercial and open source competitors are there to Splunk? and I would recommend https://github.com/tobi/clarity
Simple and easy tool.
Since everyone is suggesting clarity, I would also like to mention tailon. I wrote tailon as a more modern and secure alternative to clarity. It's still in its early stages of development, but the functionality you need is there. You may also use wtee, if you're only interested in following a single log file.
You good make a script that reads the error logs from apache2..
$apache_errorlog = file_get_contents('/var/log/apache2/error.log');
if its not working.. trying to get it with the php functions exec or shell_exec and the command 'cat /var/log/apache2/error.log'
EDIT: If you have multi servers(i quess with webservers on it) you can create a file on the machine, when you make a request to that script(hashed connection) you get the logs from that server
I recommend LogHappens: https://loghappens.com, it allows you to view the error log in web, and this is what it looks like:
LogHappens supports kinds of web server log format, it comes with parses for Apache and CakePHP, and you can write your own.
You can find it here: https://github.com/qijianjun/logHappens
It's open source and free, I forked it and do some work to make it work better in dev env or in public env. That is:
Support token for security, one can't access the site without the token in config.php
Support IP whitelists for security and privacy
Sopport config the interval between ajax requests
Support load static files from local (for local dev env)
I've found this solution https://code.google.com/p/php-tail/
It's working perfectly. I only needed to change the filesize, because I was getting an error first.
56 if($maxLength > $this->maxSizeToLoad) {
57 $maxLength = $this->maxSizeToLoad;
58 // return json_encode(array("size" => $fsize, "data" => array("ERROR: PHPTail attempted to load more (".round(($maxLength / 1048576), 2)."MB) then the maximum size (".round(($this->maxSizeToLoad / 1048576), 2) ."MB) of bytes into memory. You should lower the defaultUpdateTime to prevent this from happening. ")));
59 }
And I've added default size, but it's not needed
125 lastSize = <?php echo filesize($this->log) || 1000; ?>;
I know this question is a bit old, but (along with the lack of good choices) it gave me the idea to create this tiny (open source) web app. https://github.com/ToX82/logHappens. It can be used online, but I'd use an .htpasswd as a basic login system. I hope it helps.

How to stop xdebug from stopping on first line with PhpStorm?

I'm having this weird problem. All my settings used to work OK, until I updated my version of PHP. I use macports and have the php5 and php5-xdebug ports installed.
xdebug is working, but it is stopping on the first line of my script even though I have the option disabled in PhpStorm. There is no breakpoint there, and breakpoints in other parts of the code are working OK.
If it helps, here is the xdebug portion of phpinfo (in two parts);
https://dzwonsemrish7.cloudfront.net/items/3K3R2N1f1A190K372n0S/Screen%20shot%202011-08-18%20at%203.06.29%20PM.png?v=54c8964d, https://dzwonsemrish7.cloudfront.net/items/0i133s0U430k3u3w3B1E/Screen%20shot%202011-08-17%20at%205.14.25%20PM.png?v=1278da84 and the proof it is disabled in phpStorm: https://dzwonsemrish7.cloudfront.net/items/3W2S060I1b0W1q0z0c45/Screen%20shot%202011-08-18%20at%203.07.00%20PM.png?v=85471026
Is there an xdebug setting I need to change? When I did the upgrade, I lost my php.ini that had some other xdebug configuration.
The above didn't work for me because as far as I can tell if you're using Xdebug the only debug bookmarklets you get is start/stop and debug this page. I don't see any bookmarklet specific to stopping on first line, and neither the start/stop bookmarklets nor stopping PHPStorm from listening within PHPStorm fixed the problem for me.
To get it to stop I did this (on OS X):
Go to Preferences > Languages & Frameworks > PHP > Debug
Uncheck both of the 'force break at the first line...' options
Apply and close
In the Run menu, uncheck 'Break at the first line in PHP scripts'
For example, even if you have Path-Mappings, the public/index.php path may not be considered as part of the project.
Check the "Force break at the first line..." in the PHP->Debug section of preferences.
BESIDES THAT, also check this setting:
My problem with PHPStorm was that I was doing Drupal and the index.php was outside the project (since the project is a module). I needed to uncheck the settings "Force break at the first line..." in the PHP->Debug section of preferences.
Do you use debug bookmarklets? 'Break at the first line' option could be also controlled via 'xdebug Break On' and 'xdebug Break Off' bookmarklets.

Load php extensions dynamically

I have a live server which I want to occasionally use for testing purposes. I only have access to FTP and some basic administration tools there.
Reading the documentation for dl() gives me hope I can load xDebug dynamically even though I can't add it to the loaded extension list. I have little idea how though.
Question: How to obtain the appropriate compiled version of xdebug (or any other PHP extension) which would be ready to be used with dl()?
BTW, AFAIK the OS is CentOS 4 in my case, but I'd appreciate a broader answer too - for future reference.
xdebug is a zend-engine extension and thus cant be loaded dynamically.
You can try with xhprof instead. That should be possible to load at run time (I haven't much experience with it though, so i cant offer you specifics)
I usually use php_uname to determine the server OS
function os_check() {
$os_string = php_uname('s');
if (strpos(strtoupper($os_string), 'WIN')!==false) {
return 'windows';
} else {
return 'linux';
}
Such information is in various places in phpInfo()
<?php
phpinfo();
?>

Zend farme work Doubt2

I put this in to php.ini
include_path = ".;c:\php\includes;C:\wamp\zend\library"
C:\wamp\: here I put the zend frame work
when I run the WAMP sever , I seen a page as usual
How I check whether it's install or not,
How I start my work in the frame work
check the output of php_info() to see if you settings were applied as expected ...
also a screencast to let you get kick off.

Categories