Creating Database

I have been assigned a new project. For which I am preparing its database. Its been a fun doing so, as I have complete overview of the Application, that I am going to develop, as I make Database on paper.

But all fun goes when I have to make that db in SQL Server 2005. Now I am more or less remain a data entry operator to input data. I cannot pass this job to other, as I have to make relations and other store procedure for it as well.

But as Programmer its always better to make a DB before you start a application. Let us wait and see what my fellow programmer code with my new DB design.

Bookmarked PHP Programming

PDF generation through PHP Code

I have use PDF file gets emailed to customer feature in lot of my project. For this we use various PDF generation classes available. But today I am going to talk about absolutely free method of doing this. For this I use  html2pdf  and GhostScript. Just a suberb combination of making PDF on the fly.

I install both of them in my windows XP machine running Apache web server and they give me my blogs screenshot as PDF file with default settings only. What else you want to know about their power. They just get my Online web blog screen shot.

Rating for them is 10 /10.


Multithreading : How important it is for human

I just finish on windows application, that need to parse Given webpage for some data, and store them in CSV format. As this project is not too big, I never plan to use high end concepts and very  complex exceptional handling.

Similarly I never  plan to use multithreading in my application. Every thing works perfect, except human mind for the application. When  I send that application to client to test, he runs it to perfection, but as my application generate log of what it has done, customer want to scroll that Text Box to read that log. Since I never user Multithreading. As soon as he start the application my application goes, in loop that make the application appear Hanged, as it stop the user Interface from getting refreshed, Though I call Application.DoEvents() in between but nothing happens. Its only than I realize,  I should use Multithreading in my application, so I can Update my User Interface so client doesn’t get that feeling.

So I simply make a new thread during application startup and put every thing I wrote in Button Clicked function in a new function that, I need to pass as parameter to my new thread. And on button click simply Start and Stop of thread does rest of work.

I hardly increase my code by 10 lines but it gives a pleasent interface to user. This is why multithreading is important in today’s word.


Two Forms in ASP.Net


As any other ASP.Net developer, I was not feeling comfortable with only one form concept that ASP.Net has (not sure about v2.0 as never work on it). Also, when you have to put something like google Search or other such service on your Site and place for such “explicit” forms are in middle of your Only “Runat Server form” how will you put the other forms …

Well what I did is simply use IFrame, capabilities of web browsers. I simply make a HTML page of Google search, and using IFrame call that page. now since it load explicit HTML page, you don’t have to worry about nested form, but simply about how it looks.

though It has a disadvantage that , on older browser your site might not be viewable, but who cares about old stuffs … every body you should get new browser after all browser are free 🙂

Sumit Gupta

Concept/algorithm Operating System PHP

Linux User authentication using PHP

In one of my last post i try to define how linux store its password. Today I will be putting Complete PHP code for it.

Just run it on your local server(mind it your Http server must be running as root user in order to use this script )

Its a raw way of doing password matching and shouldn’t be used for commerical application or servers. its purely Learning script

So here goes the script

6 && CRYPT_MD5 == 1) {
$salts = explode(“$”,”$userlist[1]”);
$salt = “\$1\$”.$salts[2].”\$”;
$gen_password= crypt($password,$salt);
if ($gen_password == $userlist[1]) {
$UserMatch = true;
$UserMatch = false;
else {
$UserMatch = false;
return $UserMatch ;

if (ReadUser(“sumit”) == true)
if (MatchPassword(“sumit”,”sumit”) == true )
echo “Login successful”;
echo “Login unsuccessful”;

Hope that helps learn understanding linux passwd and shadow usage.

EDIT: I will update the script sometime sooner maybe!!!

PHP Server Configuration

Three things to do for File upload using PHP and Apache

Recently I have been ask by a developer to check the Apache configuration as his PHP script is not able to upload files more than 512KB. I looked around with my basic knowledge to see whats the cause of problem. And found these three things need to be modify in order to correctly upload file using PHP with Apache Webserver.

1) Check the php.ini for
upload_max_size it must be greater than what you required for example to upload 10 MB file you need

upload_max_size 10M in PHP.ini


php_flag upload_max_size 10M in .htaccess (it will only work if Apache is not using SUExec , not sure why is it so)

2) Check the PHP.ini for post_max_size

in PHP.ini it should be
post_max_size 11M ( as you will be having some text field with your 10 MB file so make space for them, it should always be greater than upload_max_size otherwise you are not able to upload full size files )

3) Its not necessary is set by default. And not sure whats its default value, but if you are getting this error in your Apache Error log

Requested content-length of xxx is larger than the configured limit of xxx, referer:

than you need this in your httpd.conf file

<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 11534336

this will set the PHP to have upload 11MB of body text, and header is not counted here. Again this must be set great than upload_max_size setting for php.ini

Now you can upload any file upto 10MB on your server.

Enjoy file uploading …

Sumit Gupta

Operating System Programming

Patching Source Code in Linux

Recently I download one source code for linux box, But unfortuntely that code is too old (2002) so we need to patch the source code as its available for my Linux distro.

Command is simple for it though we need a PATCH installer package first.

Command is

patch -p1 < [Patch_file_name]

this will patch your source code…

Ah one thing, your patch file must be in root of your source code 🙂

So enjoy your patched codes

Sumit Gupta