Apr 29

The MySql database backup website backup is very similar to the previous backup that I showed you 2 days ago. We are going to create a php file that is going to dump our database into filename with the current date and time.

Ok so let’s get going:
1. Create the file “backup_database.php” and input the following code into it:
<?php exec(‘cd /home/your_user/backup/db/;mysqldump –add-drop-table -h localhost –user=your_user –password=your_pass database_name > `date +%y-%m-%d_%H-%M`.sql’); ?>

Sometimes the path to your home dir looks different than ‘/home/your_user/’, so execute the ‘pwd’ command like explained in my previous post

Here we use the command mysqldump in a tutorial that I wrote previously about the dumping the sql database from one host to another. Now the database will be saved directly on the server that is hosting your website

Apr 26

Hello guys and ladies,
Long time no see :) . Today I’m going to show you how to make a php script to perform full website backup the script can be executed via http request or via ssh shell or like a cron job .
We all know about the most standard way to add backup for your website maintenance for example using the Cron Jobs in the CPanel. If you already don’t know this – if your hosting provider does support CPanel you should be able to access it via this URL: www.yourwebsite.com/cpanel
Cron Job CPanel

May 10

Today i found this very cool tutorial regarding the using of using ssl with PHP.

I’ll copy here the most interesting of it.

HTTP with PHP Sockets

// don’t need to specify http, it’s the default protocol
$hostname = “www.google.com”;
$port = 80;

// create and configure the client socket
$fp = fsockopen($hostname, $port); // optional: $error_number, $error_string, $connect_timeout
if ($fp) {
stream_set_timeout($fp, 30); // seconds to wait for i/o operations

// send request headers
fwrite($fp, “GET / HTTP/1.1\r\n”);
fwrite($fp, “Host: $hostname\r\n”);
fwrite($fp, $additional_headers); // Accept, User-Agent, Referer, etc.
fwrite($fp, “Connection: close\r\n”);

// read response
$response = “”;
while (!feof($fp)) {
$response .= fgets($fp, 128);
}
echo $response;

// close the socket
fclose($fp);
}

Apr 08

Hello fellas,  because these days i had a case where i had to include some RSS feed on my site and i needed a very simple and fast solution in php how to do it i was very dissapointed from what i’ve found on the web. There are all kind of widgets, tools PHP scripts using the xml-reader class, whatever – but i just needed some very simple solution. So ofcourse i had to write it myself at the end :)

in this example i’m going to import feed from yahoo’s technology news rss:

Mar 30

I’m going to talk about some good object oriented practices for small/medium projects. The object oriented programming itself will save you enourmous amount of time. The inheritance is part of the Object Oriented Programming (OOP) and is very good thing that is going to save you even more time when you start to use some object oriented model in your programming.

Let’s say we need to have some root class – lets say “Base”, with the __construct() (the class’s constructor) – notice that since PHP 5.0 the constructor of a class is defined in __constructs(), instead of “the-name-of-your-class”(). Anyway you can define the constructor information in Base() as well, but better do it in __construct, because you don’t know if there will be support for the old PHP 4 constructors in PHP 6 :)

so let’s get on business..

Mar 20

I don’t know if this will be interesting for you, but it was very interesting for me when i found that it is very easy to modify header information and send POST/GET variables through header using php. Anyway with CURL you are able to do much more that just modify the header information etc., but we wont have that time-frame :)

I will give you simple example where i login through script on localhost on some site – in this example: “gametrailers.com” – without actually enter any username and password :) , i think this will be the easiest way to understand it.

so here is the example:

Mar 19

Hello :) today i’m going to talk about resizing your the images in your site.
So let’s say for example that you have a CMS system – like Joomla for example. In the administration you usually have functionality like – uploading images and linking them in your content.
But often the problem with that is that usually the customers will upload too large images (copied in raw jpeg directly from their cameras) and when they link them to the content of their website, it get’s really messy.
Anyway you can fix this by writing some script that directly resize the image to some resolution like 500px/* for example, but what will happen if you want to put lightbox or something other to show the image in large resolution, or you just want to put some function to download the original file etc. You simply can’t because the image was resized at the moment it was uploaded on the server.

How about dinamically resize the image at the very  moment that client requests it?

So that way we wont have a big image that the client has to download, and at the same time we will still have the original, good resolution copy of the image, in case that we need it. We can also use the following PHP script for creating thumbnails.

Well – as you will see below it’s not hard at all to do it,  i mean not hard at all :)

Mar 09

Hello everybody,

today i’ll be talking about how to export / import your Excel file into you your database using the PHP and the CSV file format.
First of all we need an Excel file with our data.

Every row of the excel file should be the same format as the previous row (so that we can make our life easier), for example if we want to import a excel file with name/url addres corresponding to this name we should have our excel file in a format like this:
exel file example
After u have the file in this excel format u should hit -> File -> Save as -> CSV (Comma Delimited) or more ofter its Called “Comma Separated Values”. For the comma separator use “;” if it asks you. So after you save the file in the CSV file format you should have something like this after you open the file with notepad etc.: