Articles in the PHP Category
Linux, PHP »
By default, SELinux will block the ability for Apache/webapps to write to files in Fedora. This is a security feature to limit what folders Apache can write to. You can notice this issue if you get errors in your Apache logs such as:
PHP Warning: move_uploaded_file(): Unable to move ‘/tmp/…’ to ‘…….’
Command to set permissions:
chcon -R -t httpd_sys_rw_content_t [Name of Folder]
You can check the SELinux permissions via the following command:
ls -halZ
AJAX, PHP »
If you have an AJAX application that uses a PHP back-end app on a different server as your web front-end server (e.g. load balancing, cdn’s, etc), your PHP script will need to send header variables with the allowed content server name(s).
Web browsers are now following a standard for HTTP Access control to prevent client-side Cross Site scripting attacks.
I tested this with Firefox and it simply blocks the request without any error messages. Google Chrome browser will error out with the following message if the access control origin is not set correctly on your PHP script. (woot!)
“XMLHttpRequest cannot load [PHP URL].. Origin [JAVASCRIPT URL] is not allowed by Access-Control-Allow-Origin.”
For example, if the Javascript is hosted on example.com and your PHP app is on example.org.
Below is the PHP script for fixing this error. [see full message for the solution]
MySQL, PHP »
If you ever have the need to find the answer to the following:
- What are the number of tables in a MySQL database?
- What are the number of rows in a MySQL database?
- How much space is the MySQL database using up on the server?
- How many tables there are in a MySQL server?
- How many rows there are in a MySQL server?
One of the quickest ways to find out MySQL reporting stats is using PHPMyAdmin. The software is usually installed on a number of servers by default, so its just a matter of locating where in the program to find this info.
This is an example of what the stats look …
Frameworks, PHP »
Drupal 7 has been released. There are a number of improvements to the system with this release including a new administrative interface, built-in custom content structure (it was a previously a plug-in), improved performance, and an automated testing framework built-in.
For more information, visit the Drupal website: http://drupal.org/drupal-7.0
There are also Drupal release parties on January 7, 2011. http://www.drupal7releaseparty.org/
PHP »
There is currently a bug in PHP 5.2/5.3 for certain numbers to take up all system resources in a 32-bit system using the x87 instruction set (Most Intel/AMD boxes use this instruction set). Systems running 64-bit operating systems are not affected by this bug.
You can test whether your system is running 64-bit by typing the following command in a shell window:
uname -m
If you see i386, you are running a 32-bit server. Listings with x86_64, or amd64 denote a 64-bit machine.
