Posts

Showing posts from May, 2010

Watermark Images with Text Using PHP and GD Library

Image
Hi This code snippet allows you to watermark uploaded images on the fly. The script saves the uploaded image in the specified location, the prints the specified message (for example a copyright notice) on the image and saves the watermarked image as a JPEG file in another location. You can use this script to copy-protect your images by permanently imprinting a copyright notice on the image. Though the example script covers most general needs, PHP programmers should customize the script for their needs. The Complete Example The working code sample consists of the following items: HTML form that posts an image to the PHP script The PHP Script HTML Form The HTML form needs a file upload element :< input type="file"> . You must also specify the correct encoding type:  enctype="multipart/form-data"  for the form. <form action="watermark-image.php" method="post" enctype="multipart/form-data">  Select a file to upload for pro...

What is LAMP

What is LAMP? LAMP includes a stack of software, mostly open source and free software, used to run dynamic websites or/and servers. What is the advantage of LAMP and why should we use LAMP? LAMP involves a combination of open source programs. LAMP allows for lower cost development and when the programs are used together they support application servers and development environments such as Java/J2EE and Microsoft.Net. The combination in LAMP has become popular because of its low acquisition cost and because of the versatility of its components since it can be used in most of the Linux distributions. The acronym of LAMP is as follows Linux - operating system. Apache - web server. MySQL - Database management system or database server. PHP or Perl, Python - programming languages. Primarily, LAMP is a combination of the above-mentioned technologies which is used for a wide variety of purposes such to design a web server infrastructure, design a programming paradigm of developing soft...

update content every X seconds using ajax

how to update some web page section or a block content on a page every x seconds. Some real life examples of this functionality are Twitter search results that come out when there are new tweets with search keyword or bit.ly real time link tracking that updates it’s charts every 5 seconds. t is clear without saying that we are going to update our page content using AJAX and of course we love AJAX in jQuery flavor. So key to this functionality is JavaScript's built-in setInterval() function. It lets you to run some javascript function every X seconds. For example, the following code would pop alert box every five seconds: setInterval( "alert('Hello')", 5000 ); Now consider we want to update shouts in our shoutbox every 10 seconds. function updateShouts(){ // Assuming we have #shoutbox $('#shoutbox').load('latestShouts.php'); } setInterval( "updateShouts()", 10000 ); The code above will run every 10 seconds (10,000 ms) and...

Ajax Frameworks

The best technology to build dynamic web pages is Ajax. JavaScript code embedded into the HTML page is used to send requests to the server. At the server side, some processing is required to handle them, find the info or store the data. To do that, we need for a specialized framework. The framework has always a JavaScript part, and sometimes a server side part in another scripting language. A lot of them exist in various programming languages, in all environments around, but we retain here only the most widely used. Summary Why a framework? JavaScript libraries PHP frameworks Java frameworks .NET frameworks ColdFusion frameworks Ajax and XUL Resources Why a framework? Actually, this framework is the Ajax engine described by J. J. Garrett and intended to suppress waiting for the user when accessing the server. The framework provides classical, cross-browser functions to use the XMLHttpRequest object. But a framework may goes beyond that, and allow to build "r...

what is new in php6

PHP 6.0 looks to be an exciting release. Nothing is absolutely fixed yet, but it looks like it will see the demise of three of my pet peeves: register_globals, magic_quotes_gpc and safe_mode. The first was just a big  security   hole, the second messed with the data and made changing environments potentially nightmarish, while the third was a misnomer that nobody really understood, and provided a false sense of security. There's also quite a lot of work scheduled to do with Unicode. Here are some of the changes: The register_globals, safe_mode and the various magic quotes options will be removed. The ereg extension is removed, while the XMLReader, XMLWriter and Fileinfo extensions are added to the core, and by default are on. Another addition I find particularly exciting is that APC (Alternative PHP Cache) will be added to the core, though will be off by default. APC can provide serious performance benefits. All E_STRICT messages will be merged into E_ALL, anothe...

Tracking file upload progress in php

Tracking file upload progress To receive a file, we must first set up a form which will receive the file. Conveniently, HTML comes with a standard field type for files. Like all HTML form fields, it is named logically, as type file  It comes with a handy  Browse  button that appears to the right of the block by default. HTML form for upload.php <?php $id = $_GET['id']; ?> <form enctype="multipart/form-data" id="upload_form" action="target.php" method="POST"> <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $id?>"/> <input type="file" id="test_file" name="test_file"/><br/> <input onclick="window.parent.startProgress(); return true;" type="submit" value="Upload!"/> </form> We need to make a PHP page for this form because we need a unique k...