Archive for the ‘PHP’
Protect image hotlinking with php
Sometimes we want to protect our content from using our website traffic and images hotlinking, it is possible to do with mod_rewrite .htaccess method and mod_rewrite method is faster , but if you want to protect partial content from code , you can use php gd library to protect image from hotlinking.
Here is the code [...]
Inheritance and polymorphism curl tip
Inheritance is one of the best methods to shorten the thousands miles of code and your time in time of developing, it used in many programming languages like PHP, C#, Java , Python and more. This way of coding should be implemented after clear requirements for your application, well planed database, input and output.
I will [...]
Posting comments with PHP and curl automatically
Here is an experiment of posting comments with php curl library, this is the part of glurt seo tools. With a little imagination you may create a great auto commenting software for any blog cms and any website to promote your website on web or for another purposes. I created this script because I was [...]
Design Patterns for Web Programming in PHP
1. Singleton pattern
Name: Singleton
Problem: You need exactly one global instance of a class and a global point
of access to it.
Context: Any
Solution & Consequences: Make an encapsulated static variable holding
the single instance of a class. Provide a get-method that:
• has a static variable for holding the one and only instance
• instantiates the instance if it [...]
Yahoo map service php tutorial
Yahoo provides simple, great maps service to be handled with php, if you need a fast dynamic solution for your website or web service, yahoo MapService api returns images of geo locations by request url. We will show you basic usage of yahoo maps with zoom in and zoom out. You can send the requests [...]
Shrink your url with tiny url api
Url shortening procedure could be much simple if you use url shortening api. Tiny Url api makes it possible to shorten urls with file_get_contents php function. the $u variable is a long variable inserted into the function . Function returns shortened url.
function TinyURL($u){
return file_get_contents(’http://tinyurl.com/api-create.php?url=’.$u);
}
PHP Ajax chat tutorial
In this tutorial you will learn how to create your own chat using php, mysql and ajax technology . This is the basic tutorial of working browser chat , and it will work great on any existing PHP based website , or as a stand alone chat website. First consider which folder will contain your [...]
Ajax php example
AJAX is a complex technology that means different things to different people. Computer users
appreciate that their favorite websites are now friendlier and feel more responsive. Web
developers learn new skills that empower them to create sleek web applications with little effort.
Indeed, everything sounds good about AJAX! Here is an example of how to use ajax to [...]
PHP mysql connection class
If you are pure PHP developer, and maybe creating your own classes framework, you can use PHP mysql connection class, include it in your created bootstrap or in the place you would like to connect to the database with require or include function , for example you stored the code in mysql.class.php file , require [...]
Twitter API posting and deleting status with curl
Twitter API provides developers structure to work with curl, you can update and delete twitter status using API without open id, with direct twitter authentication using curl. In our last tutorial we connected Twitter via curl and our script got recent statuses of authenticated user.
Now we will create script that will connect Twitter API via [...]
