Thursday, June 17, 2010

PHP Birthday

This information took from

PHP was released by Rasmus Lerdorf on June 8, 1995. His original usenet post is still available online if you want to examine a computing artefact from the dawn of the web. Many of us owe our careers to the language, so here’s a brief history of PHP…

PHP originally stood for “Personal Home Page” and Rasmus started the project in 1994. PHP was written in C and was intended to replace several Perl scripts he was using on his homepage. Few people will be ancient enough to remember CGI programming in Perl, but it wasn’t much fun. You could not embed code within HTML and development was slow and clunky.

Rasmus added his own Form Interpreter and other C libraries including database connectivity engines. PHP 2.0 was born on this day 15 years ago. PHP had a modest following until the launch of version 3.0 in June 1998. The parser was completely re-written by Andi Gutmans and Zeev Suraski; they also changed the name to the recursive “PHP: Hypertext Preprocessor”.

Critics argue that PHP 3.0 was insecure, had a messy syntax, and didn’t offer standard coding conventions such as object-orientated programming. Some will quote the same arguments today. However, while PHP lacked elegance it made web development significantly easier. Programming novices could add snippets of code to their HTML pages and experts could develop full web applications using an open source technology which became widely installed by web hosts.

PHP 4.0 was released on May 22, 2000. It provided rudimentary object-orientation and addressed several security issues such as disabling register_globals. Scripts broke, but it was relatively easy to adapt applications for the new platform. PHP 4.0 was an instant success and you’ll still find it offered by web hosts today. Popular systems such as WordPress and Drupal still run on PHP 4.0 even though platform development has ceased.

Finally, we come to PHP 5.0 which was released on July 13, 2004. The language featured more robust object-orientated programming plus security and performance enhancements. The uptake has been more sedate owing to the success of PHP 4.0 and the introduction of competing frameworks such as ASP.NET, Ruby and Python.

PHP has its inconsistencies and syntactical messiness, but it’s rare you’ll encounter a language which can be installed on almost any OS, is provided by the majority of web hosts, and offers a similar level of productivity and community assistance. Whatever your opinion of the language, PHP has provided a solid foundation for server-side programming and web application development for the past 15 years. Long may it continue.

Thanks & Regards
Manoj Ninave

Tuesday, April 6, 2010

Import Customers by csv file in Magento

Import Customers by csv file in Magento
here i developed script to import customers in magento by csv file.
csv file have following columns
########customerid (unique key) accesskey (customer type) emailaddress password firstname lastname companyname billingaddress1 city state postalcode country phonenumber faxnumber

here i didn't use any magento's core file.

code is given below,i hope it will help you :)
* @Use Script to import customer's data in Magento Database
* @createDate Mar 2010
* @author Manoj Ninave (

define("DB_HOST","localhost",TRUE); // database server name
define("DB_USER","root",TRUE); // database user
define("DB_PASS","",TRUE); // database user's password
define("DB_NAME","dbname",TRUE); // database name

if( !isset($db_obj) ) {
$db_obj = new db;

$db_conect = $db_obj->connect();
//function to take country code from magento
//if the countr code are already in your csv file then //don't use this function.
function getCountryCode($countryName)
$xml = simplexml_load_file("territories.xml");
foreach($xml as $a => $b)
if($b == $countryName)
foreach($b->attributes() as $c)
return $c ;
echo "*******************Customer Import Module********************";
$file_handle = fopen("customers.csv", "r");

while (!feof($file_handle) ) {

$line_of_text = fgetcsv($file_handle, 1024);

if($i > 0)
$customerid =addslashes($line_of_text[0]);
$accesskey =addslashes($line_of_text[1]);
$emailaddress =addslashes($line_of_text[2]);
$password =md5($line_of_text[3]);
$firstname =addslashes($line_of_text[4]);
$lastname =addslashes($line_of_text[5]);
$companyname =addslashes($line_of_text[6]);
$billingaddress1 =addslashes($line_of_text[7]);
$billingaddress2 =addslashes($line_of_text[8]);
$city =addslashes($line_of_text[9]);
$state =addslashes($line_of_text[10]);
$postalcode =addslashes($line_of_text[11]);
$country =addslashes($line_of_text[12]);
$phonenumber =addslashes($line_of_text[13]);
$faxnumber =addslashes($line_of_text[14]);
$paysstatetax =addslashes($line_of_text[15]);
$taxid =addslashes($line_of_text[16]);
$emailsubscriber =addslashes($line_of_text[17]);
$percentdiscount =addslashes($line_of_text[18]);
$websiteaddress =addslashes($line_of_text[19]);
$discountlevel =addslashes($line_of_text[20]);
$customer_isanonymous =addslashes($line_of_text[21]);
$issuperadmin =addslashes($line_of_text[22]);
$allow_access_to_private_sections =addslashes($line_of_text[23]);
$customer_notes =addslashes($line_of_text[24]);
$Today = date("Y-m-d H:i:s");
$country_code = getCountryCode($country);

$sql_email = $db_obj->query("SELECT email from customer_entity where email='".$emailaddress."'",$db_conect);
$num_email = $db_obj->num_rows($sql_email);

if(!$emailaddress=="" && $num_email<=0) { $db_obj->query("INSERT INTO customer_entity(entity_type_id,attribute_set_id,website_id,email,group_id,increment_id,store_id,created_at,updated_at,is_active) VALUES (1,0,1,'".$emailaddress."',1,'',1,'".$Today."','".$Today."',1)",$db_conect);

$sql_parent_id = $db_obj->query("SELECT max(entity_id) as id from customer_entity",$db_conect);

$rs_parent_id = $db_obj->fetch_array($sql_parent_id);
$parentId = $rs_parent_id['id'];

$db_obj->query("UPDATE customer_entity SET increment_id='".$parentId."' WHERE entity_id='".$parentId."'",$db_conect);

$db_obj->query("INSERT INTO customer_address_entity(entity_type_id,attribute_set_id,parent_id,created_at,updated_at,is_active) VALUES (2,0,'".$parentId."','".$Today."','".$Today."',1)",$db_conect);

$sql_max_entity_id = $db_obj->query("SELECT max(entity_id) as id from customer_address_entity",$db_conect);

$rs_max_entity_id = $db_obj->fetch_array($sql_max_entity_id);
$maxentityId = $rs_max_entity_id['id'];

$db_obj->query("INSERT INTO customer_address_entity_text(entity_type_id,attribute_id,entity_id,value) VALUES (2,23,'".$maxentityId."','".$billingaddress1."')",$db_conect);

$db_obj->query("INSERT INTO customer_address_entity_varchar(entity_type_id,attribute_id,entity_id,value) VALUES

$db_obj->query("INSERT INTO customer_entity_int(entity_type_id,attribute_id,entity_id,value) VALUES

$db_obj->query("INSERT INTO customer_entity_varchar(entity_type_id,attribute_id,entity_id,value) VALUES
(1,3,'".$parentId."','Default Store View'),

echo "Customer Imported Successfully.";

Friday, February 12, 2010

Import images into Magento database without using Magento core files.

here code is to import images into magento databse without using any core files.
this is for product's images. you can modify it for gallery images also.
here all the images took from media/import and copied to that perticular directory.

you can find here,how images created there directory structure.

if images name is example.gif,then will create directory structure like e/x/example.gif.
that is means this images will copy to media/catalog/product/e/x/example.gif
and the value /e/x/example.gif will insert into table can see this image at fronend to that perticular product.Actaully i did script to imaport product with catagory,attribute,images,description.... etc
it is nothing but a cron job.i took only import images part from my script.


$first_2_letter = substr("$LargeProductImageURL", 0,2);
$first_letter = substr("$first_2_letter", 0,1);
$second_letter = substr("$first_2_letter", -1);
$product_image ="/".$first_letter."/".$second_letter."/".$LargeProductImageURL;

//copy ( string $source , string $dest [, resource $context ] )

#####check Is images are ready for copy or not
if (file_exists($import_images)) {
$product_image = $product_image;
else {
$UrlKey = strtolower(str_replace(" ","-",$PName));
$URL_path= $PName.".html";


$db_obj->query("INSERT INTO catalog_product_entity_varchar(entity_type_id, attribute_id,store_id,entity_id,value) VALUES
('".$catalog_product."','83','0','".$entity_id."','".$URL_path."')", $db_conect);

Manoj Ninave

Thursday, February 11, 2010


If God answer your Prayer, He is increasing Your Faith, If He Delay He is Increasing Your Patience, and If He Doesn’t Answer It means something is better for you. Believe In God. Always…….

Friday, February 5, 2010

How to get detail information about facebook user

Solution to get Detailed information about facebook user.

1) First you need to log in to the Facebook Developer application:
Go to the Facebook Developer AppAfter following the link,
click “Allow” to let the Developer application access your profile.
2) Begin setting up a new application.
Go to the Developer application and click “Set Up New Application”.
Give your application a name, check to accept the Terms of Service,
then click Submit.
You’ll see some basic information about your application, including:

but for that you will need PHP client library
you can download “PHP client library” after clicking the above link.
for detail information see get started

* Your API key: this key identifies your application to Facebook.
You pass it with all your API calls.
* Your application secret:
Facebook uses this key to authenticate the requests you make.
As you can tell by its name,
you should never share this key with anyone.


require_once ‘facebook.php’;
$appapikey = ‘Your API Key’;
$appsecret = ‘Your API Secrete Key’;
$facebook = new Facebook($appapikey, $appsecret);
$user_id = $facebook->require_login();

//to get detailed information about facebook user,you can use,




if you would like to get user’s name and city,
then you should write
foreach($userdetails as $k){

$user_name= $k['name'];
$City= $k['hometown_location']['city'];

echo $user_name;

save this code in index.php and test that,what you get.

Manoj Ninave

Loading web pages problem in Firefox and Crome browser?

I faced problem to load some web page in Firefox and Crome browser
so i passed some code in .htaccess files.
code is given as follow:

php_value output_handler ob_gzhandler

simply copy and paste it to .htaccess file.

Also see that following lines are passed are not:

php_flag allow_call_time_pass_reference on
php_flag magic_quotes_runtime off
php_flag register_globals off
php_flag magic_quotes_gpc On
php_flag register_argc_argv on
php_value register_long_arrays on
php_value display_errors on
php_value allow_url_include on

to compress your files for faster loading
“php_value output_handler ob_gzhandler” is very useful.


Manoj Ninave

Magento Tables required to Import Products.

Data inserted in following tables while importing products.



Manoj Ninave