Explore Yourself !!!


All about .htaccess
May 9, 2009, 10:23 pm
Filed under: LAMP | Tags: , ,

what is .htaccess?
=> it’s a file located at your server use for control apache activities. usually we place .htaccess file in server root but it’s also possible to locate elsewhere. moreover, .htaccess file help us to rewrite apache behavior. in addition, you can rewrite some variables of php.ini form .htaccess file. regardless of php framework or coding style .htaccess is helpful for all.

have a look my previous tutorial which describe basics of .htaccess file in server and local host.

Well now some advance topics. you can rewriet php.ini upload maximum file size value using the following line of command in your .htaccess file
php_value upload_max_filesize “25M”

and test it from your php script by
echo
ini_get("upload_max_filesize");

.htaccess ReWrite Rules(Short and Very Very useful)
http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html



Mail goes to Spam for Yahoo Recipient [Solved]
April 21, 2009, 11:26 am
Filed under: LAMP | Tags: , , , , ,

It’s a good experience for me. i have posted the problem elsewhere as well. let me copy and paste that one first. http://www.bluehostforum.com/showthread.php?p=68607#post68607

last 2 days i have spent couple of hours to resolve an issue of mail sending. here is my code of php

Finally PHP Code:
<?php
include_once('class.phpmailer.php');
$mail             = new PHPMailer(); // defaults to using php "mail()"

$body = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
$body             = eregi_replace("[\]",'',$body);

$mail->From       = "webmaster@shopno-dinga.com";
$mail->FromName   = "Shopno Dinga";
$mail->Subject    = "PHPMailer Test Subject via mail()";
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress("aminulsumon@yahoo.com", "hello faruk");
//$mail->AddAttachment("images/phpmailer.gif");             // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

?>

my script doesn’t show any error. it’s able to send mail to gmail and hotmail inbox. but only for yahoo it goes spam folder. i don’t think that, it’s an issue of yahoo.

Please note that, webmaster@shopno-dinga.com email address is created through cpanel.
I ask some friends to resolve it. Someone says, use @, some one say’s seems to him ok and one says, go google and search phpmailer(he is the busiest one ;) ). however, i have tried to implement phpmailer one and i get success. It’s easy to implement. a very simple php class and set some value. that’s all.

phpmailer site: http://phpmailer.codeworxtech.com/
donwload link: http://sourceforge.net/project/showfiles.php?group_id=26031&package_id=252700 and click PHPMailer v2.3 for PHP5/6

PHP Code:

$subject = 'Birthday Reminders for August';

// message
$message =
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
;
$subject = ‘Birthday Reminders for August’;
$to = ‘aminulsumon@yahoo.com’;
$headers=‘MIME-Version: 1.0′.“\r\n”;
$headers.=‘Content-type: text/html; charset=iso-8859-1′.“\r\n”;
$headers.=‘To: Aminul <aminulsumon@yahoo.com>’.“\r\n”;
$headers.=‘From: Shopno dinga <webmaster@shopno-dinga.com>’.“\r\n”;
mail($to, $subject, $message, $headers);

And Still same result. Mail goes to spam folder for yahoo !!!

Well, lets analyze with this simple code

&lt;?php
$to = 'aminulsumon@yahoo.com';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To: Aminul Sir &lt;aminulsumon@yahoo.com&gt;' . "\r\n";
$headers .= 'From: Dinga &lt;webmaster@shopno-dinga.com&gt;' . "\r\n";
$headers .= 'Reply-To: webmaster@shopno-dinga.com' . "\r\n";

$message = 'very simple mail. only text no html currently.';
$subject = 'test mail from manktech';

if(mail($to, $subject, $message, $headers))
echo "mail goes to $to \r\n";
else
echo 'mail jai nai.';
?&gt;

Please note that, from some hosting(i think those are first class domain) this code is able to send yahoo recipient mail in their inbox but still not from my hosting(bluehsot) :(

Debugging Starts: First check whether your domain is blacklisted or not. Check through http://www.mxtoolbox.com/ site.
=>checked and try to fix many ways but still mail goes to spam for yahoo recipient.

Well, after couple of days, i get only person who is able to provide me proper explanation. Most of the professionals reply as, “It’s completely header issue. so try to fix that and it will work”. but when i request himself to change he failed. someone point his finger to use third party emailer but after implement when i knock them “Still it’s spam”. they have no proper explanation. i found less people who say “Sorry brother can’t understand what actually going on”. Well, only one friend reply the real fact. He said “Yes, yahoo have some additional filtering and that’s why mail from all domain are not accepted and goes spam. But google have an excellent service which will overcome spam issue.” here is his mail’s reply:

At the following links given below has all mx server installation with domain name & hosting features by google apps migration service management for developers, i think it would be best to test the yahoo mail service with other domain with less finance cost.

and finally i do a good RnD. simple few steps configuration. Most importantly, MX Entry configuration. keep in mind, it’s in your cpanel not at your domain control panel(by example, godaddy.com). Finally, i am able to create email account which is fully featured of gmail. :) yes it’s surprising. exactly same outlooking and features(by example, google doc, calendar) of gmail.

Now i am able to access my email from https://www.google.com/a/cpanel/shopno-dinga.com using username :admin@shopno-dinga.com and password: something.

This tutorial may be helpful for someone who is interested to learn mail stuffs with proper explanation. And it’s really charming to get gmail features for your domain email accounts. Best of luck :)



Ubuntu: Install and Configure Network / Internet
April 8, 2009, 11:23 pm
Filed under: LAMP | Tags: , ,

Finally i purchase a second hand but fresh condition laptop with 26K, here is it’s configuration: Toshiba Sattelite L300, Intel Celeron 2.0 GHz, HDD: 80GB, Display 15.4 inc, RAM: 1 GB, Used: 8 month.

So it require me to setup internet and here are the steps to setup network. Note that my mac address is: 00:13:D3:9E:65:7F. First install fedora operating system and follow these steps.

LINUX COMMANDS(For Ubuntu Network Setup)
====================================================

#sudo update-rc.d -f NetworkManager remove
=> Remove default connection.

#sudo nano /etc/network/interfaces
=> Enter the following configuration(change according to your configuration)
auto eth0
iface eth0 inet static
address 192.168.2.155
netmask 255.255.255.0
gateway 192.168.2.1
hwaddress ether 00:13:D3:9E:65:7F

#sudo nano /etc/resolv.conf
Entere here the following informations(Pref DNS):
nameserver 192.168.2.1

#sudo /etc/init.d/networking restart
=>to avoid reboot pc/laptop

Debugging:—>

#iptables -F
=> Flash Firewall

#ifconfig
=> display current configuration

Still not working?? Don’t worry Reboot Your pc….. Still not working? I am sorry but search in google :)

ENJOY UBUNTU !!!!!!



Useful Linux Commands
March 31, 2009, 8:32 pm
Filed under: LAMP | Tags: , ,

PHP is best suited with Linux but Linux is not easy OS like windows. On the other hand, so far i feel, LINUX is more speedy/powerful then windows not only in server pc but also developer pc. So when i plan to switch to linux i need to think about some issues one by one and try to solve.

PHP Editor->
-> Windows: e-text editor
-> Mac: textmate
-> Linux: gphpedit, netBeans, bluefish

Web Server->
-> Windows: WAMP, XAMP
-> Linux: I am searching. May be built in

There are millions of linux command over the net. but here are some commands  i use so far. my target is to learn minimum number of commands what are always used. I am using Linux Fedora 10 version. i feel, linux command changed over version of linux(not basic commands).

TO install a Software(Say yuuguu)
=> # vi /etc/yum.repos.d/yuuguu.repo
[yuuguu]
name=Yuuguu
baseurl=http://update.yuuguu.com/repositories/yum/
enabled=1
gpgcheck=0
=> # yum install yuuguu

TO uninstall a Software(Say yuuguu)
=> # yum remove yuuguu (Best One)
=> # rpm -e yuuguu-build.2257-1.i386
=> # rpm -e yuuguu-build.2257-1.i386 –nodeps
=> # rpm -e yuuguu-build.2257-1.i386 –force

TO update a Software(not Sure)
=> # yum update yuuguu

Check a software installed or not
=> # rpm -qa | grep yuuguu

So far these are all. I am trying to move forward and i shall fillup this white board :)



How to install subversion in shared hosting
March 30, 2009, 9:39 pm
Filed under: LAMP | Tags: , ,

we all know the feature and advantages of serversion. although, i like DRY(Don’t Repeat Yourself), but i like to introduce a scanario. say we are developing a project where a number of folders and hundred or thousands of files exists. this is common scanario for projects developed using framework. now, in order to develop or fix a module, its tough for developers to keep in mind which files he had changed or write last night or couple of hours ago. in addition, this is an extra headake(incorrect spelling ;) ) for developers to keep in mind these things. on top of, subversion allow you to rollback whole sites days back or month back.

well, previously i thought, it’s not possible to install subversion in shared hosting. its’ only for dedicated hosting and as though, shopno-dinga is not dedicated server, it’s not possible to get subversion huge huge benifit. but i was 100% wrong. i have googled and find out myself, it’s possible for both dedicated and shared hosting. what to do ? how to setup? these are the commmon question in my mind. to install subversion in shared server first requirermnt is to activate SSH. i have go through two shared hosting cpanel. one have SSH option and other don’t have. so, i have to request to get SSH feature in cpanel(for non-existant SSH). now another one, one cpanel have SSH feature and i thought it’s activated. but once again, i am 100% wrong. i start trying to activate SSH. to do so, i need to create public key(shopno-dinga-key.pub) and private key(shopno-dinga-key.ppk). that’s all ?? NOP !!! after create these keys i need to submit my photo id and i do so. But still my request is pending. because i am not owner of my shared hosting :D , which mean the owner have to sent an email from his account to activate SSH. i have called bluehost 24 hour live support and using Yes-No-Verygood english i understand, it’s not possible for me to activate SSH without my hosting orinigal owner. So i am waiting for that activation !!!

As soon as SSH will be activated, i shall start intall subversion into my shopno-dinga.com shared hosting. :)



Fedora: Install and Configure Network / Internet
March 28, 2009, 7:41 pm
Filed under: LAMP | Tags: , ,

Yes right now i have two pc. One is running Windows and another Linux. I have installed Fedora 10. But configure network and internet was really a nightmare for me. But last night i was able to do it successfully (after one week failure). By one of my junior friends(Rony) help here is the configuration. All these configurations i create from fedora terminal.

Install Linux(Huge resource over the net):

http://www.howtoforge.com/the_perfect_desktop_fedora7

LINUX COMMANDS
====================================================

#ifconfig
=> Display configuration

#iptables -F
=> Flash Firewall

To Set IP “Addrerss” and Netmask
================================
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
DEVICE=eth0
IPADDR=192.168.2.119
NETMASK=255.255.255.0
BOOTPROTO=static
MACADDR=00:13:D3:9E:65:7F

:wq (This is save file)
To Set IP “Gateway”
========================
#vi /etc/sysconfig/network
NETWORKING=yes
FORWARD_IPV4=yes
HOSTNAME=aminul-sumon
GATEWAY=192.168.2.1

:wq (This is save file)

To Check Cable Connectivity
=====================
#mii-tool
Correct Output =>  eth0: negotiated 100baseTx-FD, link ok

Most Easy Way is
=============
#netconfig
#service network restart

Now after configure my network here are the output taken from terminal:

here are the output of my linux machine:
————————————————
# mii-tool
eth0: autonegotiation failed, link ok

[root@aminul-sumon network-scripts]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:13:D3:9E:65:7F
inet addr:192.168.2.118  Bcast:192.168.2.255  Mask:255.255.255.0
inet6 addr: fe80::213:d3ff:fe9e:657f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:64706 errors:45 dropped:0 overruns:0 frame:0
TX packets:43550 errors:6 dropped:0 overruns:0 carrier:12
collisions:2513 txqueuelen:1000
RX bytes:70177860 (66.9 MiB)  TX bytes:5549528 (5.2 MiB)
Interrupt:21 Base address:0xc000

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:42 errors:0 dropped:0 overruns:0 frame:0
TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7007 (6.8 KiB)  TX bytes:7007 (6.8 KiB)

pan0      Link encap:Ethernet  HWaddr E2:FF:9B:26:8C:DE
BROADCAST MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@aminul-sumon network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]

[root@aminul-sumon network-scripts]# vi ifcfg-eth0
ONBOOT=yes
DEVICE=eth0
IPADDR=192.168.2.119
NETMASK=255.255.255.0
BOOTPROTO=none
MACADDR=00:13:D3:9E:65:7F
USERCTL=no
IPV6INIT=no
NM_CONTROLLED=no
GATEWAY=192.168.2.1
TYPE=Ethernet

#vi /etc/sysconfig/network
NETWORKING=yes
FORWARD_IPV4=yes
HOSTNAME=aminul-sumon
GATEWAY=192.168.2.1

ENJOY LINUX !!!!!!

::::::::::::::========= LAMP =========:::::::::::::::

Installl LAMP(Linux, Apache, Mysql and Php) in one shoot.
#yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-mbstring php-mcrypt php-mhash php-mssql php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel mod_fcgid php-cli httpd-devel



Start taking Taste of Web development with PHP
January 6, 2009, 12:09 am
Filed under: LAMP | Tags: , ,

 

Taste of Web development using PHP

 Well at this stage, we know how to setup PHP, MySql and Apache. We have installed either XAMP or WAMP (ready made package of PHP, MySql and Apache). Moreover we run a simple PHP script hello_world.php. Which means now we are able to create a project, write php code and run it in browser.

Lets move forward with a simple page with some HTML controls. Lets define our requirement first.

It’s a member information page with the following fields: first name, last name, email, contact no, present address and sex. When we enter data and submit this page it will goes to another page and shows the information. That’s all for today.

Lets start. Our first task is to create a simple page member_info.php. Now lets add the fields first name, last name, email, contact no, present address and sex. Before write a single line of code we have to think first, which HTML fields we will use. For first name, last name, email address it’s fair to choice text box. Moreover, for present address wise to select text area as though address need multiple line of input. Lastly, for sex it’s clever decision to choose radio button with predefined values Male and Female. So here is our page member_information.php.

 

Untitled Document

Welcome to Member Information Page
First name
Last Name
Email
Address
Sex Male

Female

 

Now when you browse this page (like: http://localhost/project_name/member_information.php ) you will get all fields of your page. When you enter some informations and press submit the page goes to http://localhost/project_name/success.php. Lets clarify how is it works. if you observe this page closely you found

//some html controls.. text box, radio button and submit button


A submit button is fully responsible to submit the page to server along with all inputed informations. And form action=”success.php” define where these informations will be submitted. As a result it submits to success.php. Hey!!! It shows you No page Found 404 Error Right? Don’t worry. You are correct. Just make sure your URL (at address bar) end with success.php.

Well at second step. lets build success.php. This is a simple page where we show all data inputed at member_information.php. Here is the code of success.php

Untitled Document

Welcome to Member Information Page
First name
Last Name
Email
Address
Sex

So you get your inputed data. right? Right now you url in address bar is http://localhost/project_name/success.php Lets analyze success.php. Actually we use here $_POST['field_name'] to display any field_name value. By example, we have

which means address is a HTML field what is submitted to success.php through a POST method. Lets remind our mind we have

in member_information.php page.

that’s all for today. Try yourself to understand how this page is working. test by add some fields like phone number in member_information.php page and display it at success.php.

Best of luck :)



Foreign key in MySql [when ENGINE=InnoDB]
November 20, 2008, 8:47 am
Filed under: LAMP | Tags: , ,

Many developers and DBAs who spent their lives on M$ SQL or Oracle turn up their noses at mysql, they refer to it with disdain. According to them the lack of foreign key support in mysql means it is not a proper RBMS and not standard compliant. Nothing can be further from the truth.

Mysql has supported foreign keys for a long time now many people simply don’t know of it or use it because foriegn keys cannot be used with MyISAM type of tables. You need to use InnoDB type tables instead.

Since many of the mysql tutorials on the web were written long long ago before InnoDB support was added, they rarely refer to the use of this table type or foreign keys. Fortunately it’s a trival matter to convert your tables from MyISAM to InnoDB – provided that their data integrity has not been violated.

ALTER TABLE tablename TYPE=InnoDB is all that is needed to perform the conversion. Now you are ready to add foreign keys – let’s look at an example.
alter table userProfile add Foreign key (userId) REFERENCES users(userId);

This foreign key isn’t particularly usefull – all it can do is stop you from entering a User Profile for a non existent user (as you were about to ..). Rather more usefull is to have a foreign key that results in an unwanted user’s profile being deleted when you delete the entry in the user’s table. But first we need to drop the contraint that we have already created. alter table userProfile drop foreign key userId;

Beware; this drop foreign key statement will fail if there are inconsistencies in your data. The only remedy then is to create a new table do an INSERT .. SELECT query , drop the original table and rename the new table to use the old table name then take a deep breath.

Before we were so rudely disturbed, we were discussing cascading deletes, here is how you should create your foreign key if you want to make use of this feature: alter table userProfile add constraint foreign key (userId) references users(userId) on delete cascade;

[100% copy and paste from http://www.raditha.com/blog/archives/000490.html]



Blood Bank Hacking Stoped WITHOUT Captcha
November 16, 2008, 10:56 pm
Filed under: LAMP | Tags: ,

Yes… we feel grief that, shopno-dinga blood bank hacking stopped. :(
As you all know that, good and excellent website, product, or news face lot criticism. in that way shopno-dinga was pleased after hacked daily. oh sorry it wasn’t once daily instead, number of times a day. but it’s now past. we are not hacked any more now a days. Yes really surprised. really surprised.

for your kind information:
Blood bank registration page: http://www.shopno-dinga.com/blood_bank/
Blood bank list of donor page: http://www.shopno-dinga.com/blood_bank/DonarList/

we have not used CAPTCHA (image validation). we think, shopno-dinga hacker is tired. ha ha ha ha ha. if hacker is not tired then how is it possible to prevent hacker without using CAPTCHA.

however, think yourself. it’s your duty but we are highly disappointed that, no more hacker :( :) :D

i am sure you are 100% right. Yes this is the way by which shopno dinga prevent hacker WITHOUT Captcha
http://lab.pxwebdesign.com.au/jquery/a-simple-way-to-ease-spam-from-forms/20



How to start PHP
October 7, 2008, 8:18 am
Filed under: LAMP | Tags: , , ,

Before start php you need some back understanding of web technology. How web sites are developed?

Web site consist of three parts. We need to understand clearly what these are and how it works. First of all you need a server called web server. Apache is a server of linux where you actually put your files. Secondly you need to choose a scripting language. Without any scripting language you site can’t be dynamic. We choose PHP as web language. Finally to handle operations of data you need a database. Mysql is best suited with PHP and Apache.

LAMP: Stands for Linux, Apache, Mysql and PHP. So we can easily understands that, PHP is best suited in Linux server and this is the reason why everybody chooce Linux server for hosting. In contrast, most of we are using windows. Moreover, configure LAMP is not so easy for everyone. So what’s the solution? There are a number of integrated tools which are simple to install and configure automatically. XAMP is a very good one. WAMP is another one. You can download both for free from the web. Download XAMP/WAMP anyone  you like and compatible with your OS. Once XAMP/WAMP download and installed you are ready for to code with PHP, MySql and Apache.

For instance lets download and install XAMP. Then goto c://xamp/htdocs/ this is called root/document root. Lets create our first project named practice

create a folder c://xamp/htdocs/practice named practice.
now create a file named hello_world.php inside practice folder. i.e c://xamp/htdocs/practice/hello_world.php
Web consist of HTML/XHTML , Scripting language(PHP, C# dot net, JSP, Cold Fusio etc), Javascript and Database.
PHP code must contain a beginning and ending tag.
Short tag: <? …… ?>
Full tag: <?php …… ?>
Paste following code into hello_world.php file
<?php
echo “hello world”;
?>
How to run your script/site? Open a new browser window(Mozilla firefox or Internet explorer or Google Chrome) and paste the following url into your address bar.
where practice = project name
hello_world.php = file name.