How to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source
This article shows how to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source. It should work on most systems, however may need some tweaking from system to sytem.
- Download source tarballs:
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget http://www4.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
Securing PHP
Well PHP is one of the most popular applications that run on Linux and Windows servers today. It’s also one of the main sources for servers and user accounts getting compromised. I want to go over some of the things you can do to help lock down PHP, securing php and securing php.ini
First off you want to figure out how you can edit php.ini This is the main configuration file for PHP. You can find it by logging into shell and typing in the following:
# php -i |grep php.ini
Turn on safe_mode
Safe mode is an easy way to lock down the security and functions you can use. PHP.net explains php safe_mode as, “The PHP safe mode is an attempt to solve the shared-server security problem. It is architecturally incorrect to try to solve this problem at the PHP level, but since the alternatives at the web server and OS levels aren’t very realistic, many people, especially ISP’s, use safe mode for now.”
Read more…
Good and Bad PHP Code
When interviewing a PHP developer candidate for a job at SitePoint, there is one question that I almost always ask, because their answer tells me so much about the kind of programmer they are. Here’s the question: “In your mind, what are the differences between good PHP code and bad PHP code?â€
The reason I like this question is because it tests more than just a candidate’s encyclopedic knowledge of PHP’s functions. Zend’s PHP certification does a good job of that (as does the test that Yahoo! issues to applicants for its PHP developer jobs, apparently).
Rather, the answer to this question tells me whether a PHP developer has, for example, experienced the pain of working with poorly-written code inherited from a careless predecessor, and whether he or she will go the extra mile to save the rest of the team from that same pain.
I don’t have a set notion of the perfect answer to the question, but I do know the kinds of things I’m hoping to hear. Just off the top of my head:
Read more…
Page Loading Time
Learn how to output the time a page takes to load.
Have you ever noticed that lots of websites feature a little “Page loading took x.xxx seconds to load” at the bottom of their pages? It’s a pretty simple thing to make and gives your site something that we all love… Stats!
Here is what we have to do:
- Get the time in micro-seconds using the function: microtime().
- Turn the micro-time into an array using the explode() function.
- Add the two parts to the array together (the micro-seconds to the seconds).
- Repeat steps 1,2 and 3 for the bottom of the page
- Find the total loading time by taking the time taken at the end of the page from the time taken at the top of the page
- Round the microtime and return it to the browser
Simple Password Protection using PHP
Learn how to super protect your files without the use of mySQL.
This tutorial will help you learn how to password protect your file quickly and easily in a few lines of code.
The code can be split up into three if-else statements. Let’s take a look at what we will have to do in order to set up the password protection:
- If the user has not been authenticated, then use the PHP header and ask for a username and password.
- Else, if the user’s name is “tweak” and the password is “tweak”, log in. Inside here you would put all the code for the user.
- Else tell them the user/password failed.
Displaying PHP APC Cache Information
APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. I posted about how to install APC on Linux a couple of days ago, and will now look at the apc.php script which comes with APC and shows information about how much of the cache is being used, what files are being cached, the number of times they’ve been accessed etc.
Read more…
Rounding numbers with PHP
round()
The round() function rounds the number passed in to the specified number of decimal places. If the decimal places is a negative number then the numbers to the left of the decimal place are rounded. If the decimal places parameter is not passed in then it defaults to zero and will round as an integer. 5 is round up and < 5 is rounded down.
echo round(125.751, 2); // 125.75
echo round(125.751, 1); // 125.8
echo round(125.751); // 126
echo round(125.751, -1); // 130
echo round(125.751, -2); // 100
Read more…
Installing the Alternative PHP Cache (APC)
APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP library files can be fed from the parsed cache. This will generally lead to a speed increase when serving a PHP site, especially one with a lot of library files. This post looks at how to install APC for PHP on Linux. The Linux distribution I used was CentOS 5, but it should be fairly similar for most distros.
Read more…