Archive for the Category ◊ All Tutorials ◊

To view database tables details:

How change tables database engine:

How read and import csv file data:

LOAD DATA
LOCAL INFILE ‘C:/uk.csv’
INTO TABLE myTable
FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n’ (
id,
tableField1,
tableField2,
tableField3
);
SHOW WARNINGS;

How insert data using select query in mysql:

INSERT INTO new_table (date,record_id,data_field)
SELECT date, record_id, data_field FROM old_table
ON DUPLICATE KEY UPDATE date=old_table.data, data_field=old_table.data_field;

Step:1 Download latest Mysql from:
http://dev.mysql.com/downloads/mysql/5.1.html#win32 (Windows Essentials (x86))

Step:2 Then run installer.

Ideas about PHP file upload Security

* Check the referrer
* Restrict file types
* Rename files (check double-barreld extensions like upload.php.gif and eliminate extensions you don’t allow)
* Change permissions

// PHP FILE UPLOAD
echo "Size: " . round(($_FILES["uploaded"]["size"] / 1024),2) . " Kb
“;
echo “Size: ” . round((($_FILES["uploaded"]["size"] / 1024)/1024),2) . ” MB
“;
echo “Name: ” . $_FILES["uploaded"]["name"] . “
“;
echo “Type: ” . $_FILES["uploaded"]["type"] . “
“;
echo “Referer: ” . $_SERVER['HTTP_REFERER'] . “
“;

$yourSite = “mywebsite.com”;
$yourSite2 = “www.mywebsite.com”;
$uploaded_size = $_FILES["uploaded"]["size"] / 1024;
$uploaded_type = $_FILES["uploaded"]["type"];

$domain = parse_url($_SERVER['HTTP_REFERER']);
echo “Referer Host: ” . $domain['host'] . “
“;

$target = “upload/”;
$target = $target . basename( $_FILES['uploaded']['name']) ;
$okFlag=1;

//This is our size condition
if ($uploaded_size > 400000)
{
echo “Your file is too large.
“;
$okFlag=0;
}

//This is our limit file type condition
if ($uploaded_type ==”text/php”)
{
echo “No PHP files
“;
$okFlag=0;
}

// Allow only gif image to upload
if (!($uploaded_type==”image/gif”)) {
echo “You may only upload GIF files.
“;
$okFlag=0;
}

// Check the referrer
if (!($domain['host'] == $yourSite || $domain['host'] == $yourSite2) ) {
echo “The referrer is not right.
“;
$okFlag=0;
}

//Here we check that $okFlag was not set to 0 by an error
if ($okFlag==0)
{
Echo “Sorry your file was not uploaded”;
}

//If everything is okFlag we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo “The file “. basename( $_FILES['uploadedfile']['name']). ” has been uploaded successfully”;
}
else
{
echo “Sorry, there was a problem uploading file.”;
}
}

?>

Please choose a file:

Category: All Tutorials  | One Comment

We need to edit the httpd.conf in C:\ server\Apache\conf to make sure that Apache knows where is php modules.

Step 1:

Add the following lines at the end of httpd.conf.
LoadModule php5_module “C:/server/php/php5apache2_2.dll”
PHPIniDir “C:/server/php/”
AddType application/x-httpd-php .php

Step 2:

Find this line in httpd.conf.
DirectoryIndex index.html
and add:
DirectoryIndex index.html index.php

Step 3:

Find this line in httpd.conf.

Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from None

Change this to:

Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all

Step 4:

Find this line in httpd.conf.
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
Change this to:
AllowOverride All

Step 5:

Find and remove # at the beginning from the following lines
#LoadModule rewrite_module modules/mod_rewrite.so
#ServerName localhost:80

Step 6:

Now create a file php phpinfo, and add the following in the text field:
and save as phpinfo.php and Place this file in the root of your server C:\server\Apache2\htdocs.
Well that is it we setup now PHP in windows.

Download PHP5 the Windows Binaries: http://uk3.php.net/get/php-5.2.9-2-Win32.zip

Step1.
Unzip the file to C:\server\php.

Step2.
You must include the Windows PATH environment variable by using following steps.
php install 1
php install 2
php install 3

Step 3.
Go to C:\server\php and find the php.ini-recommended. Rename this file to php.ini.

Find the line with extension_dir = “./” and change it to: extension_dir = “C:\server\php\ext”
Find the line with ;session.save_path = “/tmp” and change it to: session.save_path = “C:\server\tmp”
also removing semicolon ; at the beginning.
Find the line with short_open_tag = Off and change it to:short_open_tag = On

Please also uncomment the lines by removing semicolon ; at the beginning of the Windows Extensions of the as needed:
The most used extensions for most php scripts are:
;extension=php_curl.dll
;extension=php_mbstring.dll
;extension=php_exif.dll
;extension=php_gd2.dll
;extension=php_mcrypt.dll
;extension=php_mysql.dll
;extension=php_sockets.dll

Please note enable both the php_mbstring.dll and php_exif.dll DLL’s in php.ini. The php_mbstring.dll DLL must be loaded before the php_exif.dll DLL so adjust your php.ini accordingly.

Step 4
To find out if our PHP is working, from the start menu – run and type cmd. In the command prompt window type php -v. The outcome will be something like this.
php5 install test

Install Apache on Windows XP

Download latest Apache from::http://httpd.apache.org/download.cgi (apache_2.2.11-win32-x86-no_ssl.msi)

Create a folder with a name “server” on C:\
This is the folder where all of our apache, php, mysql and tmp files will be kept.
Apache install 1

Installing Apache:

On the downloaded “apache_2.2.11-win32-x86-no_ssl” click and this will start the installation of Apache server
Apache install 2
Apache install 3
Apache install 5
Apache install 6
Apache install 7
Apache install 8
Apache install 9
Apache install 10
Apache install 11
Apache install 12

click Finish to exit setup

To test if Apache is running. Open your browser type in http://localhost. You should see
the following display:
Apache install 13

                         Freelance reliable, timely services within your budget.
       ©2009 - www.999solutions.com | Freelance Web Solutions, Services and Consultancy