Stop PHP nobody Spammers
PHP and Apache has a history of not being able to track which users are sending out mail through the PHP mail function from the nobody user causing leaks in formmail scripts and malicious users to spam from your server without you knowing who or where.
Watching your exim_mainlog doesn’t exactly help, you see th email going out but you can’t track from which user or script is sending it. This is a quick and dirty way to get around the nobody spam problem on your Linux server.
If you check out your PHP.ini file you’ll notice that your mail program is set to: /usr/sbin/sendmail and 99.99% of PHP scripts will just use the built in mail(); function for PHP – so everything will go through /usr/sbin/sendmail =)
Requirements:
We assume you’re using Apache 1.3x, PHP and Exim. This may work on other systems but we’re only tested it on a Cpanel/WHM Red Hat Enterprise system. Read more…
Rotating Banner in PHP
This is a snippet that will rotate a banner on a page. All you have to do is set $File and $Images to the paths to the images. It will just do the next image in $Images in order. It doesn’t rotate banners for seperate users, it just goes through. Before you use it, create the $Stat file and set the contents of it to 0 and your ready to go!
Read more…
Text counter in PHP
A counter is an essential part of a site to know how many people are coming to site. Here is an easy way to make a counter. All you need is access to PHP and be able to chmod a directory. We’re going to save the amount of hits in a .dat file, so you don’t even need a mySQL database. First off, you have create a directory and CHMOD it 777 so PHP can write the counter.dat file.
Here is what we have to do:
- Use the file_exists() function in PHP and see if the counter.dat file exists. If it does, then open the file using the PHP fopen() function.
- Use the PHP fgets() function to find the number of hits there and save it in a variable.
- Add one to the variable.
- Close the file.
- Display the number of hits.
- Open the counter.dat file using the fopen() function and save it as a variable.
- Use the PHP fputs() function to insert the new number of hits.
- Close the file.
- If the counter.dat file doesn’t exist, then use the fopen() function and declare it as a variable.
- Use the Fputs() function and put a “1″ in there.
- Print out that 1 person has come to the page and then close the file.
Here is the code: Read more…
Create Random Text in PHP
Want to put a random quote on your site? Or randomize some other aspect of your site? It’s easy. You’ll want to use PHP or some other server-side scripting language instead of a client-side scripting language like JavaScript. Server-side languages write the content to the page in html before it ever leaves the server. Search engines will be able to read the content on your page, but with JavaScript they cannot, so you lose any content value of the random code. Also, if a user turns off JavaScript, that random content is lost. Google, MSN, and Yahoo will see that the content is changing often, and that may help your rankings (depending on your implementation).
Here’s how to put the random elements into your page, using PHP.
Step 1:
Create a text file called ‘myData.txt’. Open the file and put in your random elements, placing each random element on its own line, (whether text, images or html). Then place ‘myData.txt’ in the same directory as your page containing the PHP script.
Step 2:
Place the following PHP code into your page where you want the random element:
Read more…
How To Install IonCube Loader
If you need IonCube loader in order to encode scripts. You will need to install IonCube loadar on your box.
- Login to your server as root and download the loaderfor your server: http://www.ioncube.com/loader_download.php
- Then extract it
tar -zxvf ioncube_loaders.tar.gz
cd ioncube - Copy ioncube-install-assistant.php file to a www diretory
cp ioncube-install-assistant.php /home/username_here/www
How to run PHP 4 and 5 on Cpanel
by Tweak on June 13, 2009
in Domain/Hosting, Php, Servers
This information is helpful for hosting companies that want to run PHP 4 & 5 on the same cPanel server. After this, Hosting costumers / cPanel users should choose what version of PHP will they use on theirs scripts.
You should consider some implications on your server performance, but webhosts are using because they don’t need two server to run the different PHP versions for different costumers.
How to run PHP 4 and 5 on the same Cpanel server
Read more…
How To Install ImageMagick
What is ImageMagick ?
ImageMagick is a software suite for image manipulation and display, supporting close to 100 image formats, it is mainly used to perform various transformation and conversion operations on images.
How To Install ImageMagick: Read more…
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…