Category Archives: LAMP

Drupal Bullet Points

I have used Drupal in 2008-2010 and worked on Drupal5 and Drupal6.

I am just collecting some keywords during my learning.

Content Type
annonomouse user
logged in user
Roles and Permissions
role based permission
Single Sign on
drupal plugin software
hook system
event driven system.
Drupal core
Drupal contributed
menu paths
Drupal pages
Drupal index.php
clean urls
site configutaiion..
error reporting…
status report

Now I am not using Drupal, but which my work. This framework was awesome for CMS structure.

Happy Drupal.

Server Administration on LAMP Stack

The common process flow for LAMP Stack projects and there server maintenance.

  • * Get the best deal from hosting company.
  • * Get the root access and direct unique ID by which you can directly talk to them for any query and emergency.
  • * Do some hardware configuration check such as –
    • # CPU Check, Memory Check, Disk Space, Memory Status, Swap Space
  • * Do some software configuration check such as –
    • # LAMP Stack configuration, need to install via source or via standard packages.
  • * Security checks. Server need to be optimized with security checks.
    • # Configure Software Firewall.
    • # Changing in default SSH port
    • # Disable direct root login
    • # Change root password strong
    • # Create user group and give access to only developers and maintainers.
    • # White-list only port 80 and 443.
    • # Authenticate mailing ports.
    • # Enable SFTP for file uploads for developers.
    • # Disable SVN Access.
  • * Do server monitoring.
    • # Enable and watch server logs.
    • # Enable and watch error logs.
    • # Enable and watch slow query logs.
    • # Install Awstats for monitoring server logs.
    • # Install and configure Nagios as alert mechanism.
    • # Watch and maintain server space, memory utilization, HTTP Service, CPU Load, SSH Service.
  • * Later work on server optimization.
  • * Optimize PHP and MySQL configuration based on need and requirement.

This list can have more option. If you find new things, give me comments.

Happy Server.

Drupal Interview Questions

So while working with Drupal Projects in my previous company. Me and my team prepared some Drupal Interview Question. This does not have everything but this will be for 1st round for sure. If you know these many question then I think you know Drupal For Sure.

Here is the list which is basic Drupal Questions.

  • Drupal Basics – Node, Module, Teaser, theme, Path, taxonomy, Patch, Region, Block, Menu
  • Installation of Drupal, steps and how to upload it on the live site from the local Machine.
  • Core Module in Drupal, their Names and their Functionalities.
  • Hook, Node Concepts
  • Functions and their Functionalities for – t() Function, l() function, Watchdog functions etc
  • Theme System in Drupal.
  • Themes and Theme Templates.
  • Theme Engines (Interface between the Drupal Core and the theme template).
  • Theme Hooks (Provide a way of interaction between the Modules and theme)
  • Theme Template structure and different sections as Page.tpl.php, node.tpl.php, block.tpl.php, box.tpl.php, etc
  • Derivative themes or Sub themes or Theme inheritance concepts that came into existence in Drupal 6, about it and its functionalities.
  • Steps to create a derivative theme and how to move for creating the theme from Derivative themes to a new theme right from scratch.
  • Theme function.
  • Where the Drupal theme functions are defined?
  • How the Drupal Theme functions can be overridden.
  • How to Implement the AJAX Effects on the Block modules in Drupal 6
  • Theme registration and the concepts in Drupal 6.
  • CCK modules and its importance with major functionalities.
  • How to create a Module.
  • How to insert the database table schema from the Modules when they are installed and remove the table scheme when they are un-installed (modules.)
  • User, Permission, Role in Drupal
  • How the Drupal database works?

Please give comments for more Drupal Questions.

Long back I have shard my PHP Interview Questions also.

Happy Programming.

Start working with symfony 1.4

My colleague Subedar has started using Symfony 1.4. Today he shared me this list that how to install symfony 1.4 into your machine.

This is tested in windows, I have not tried in my ubuntu lappy. I will try and setup in my linux lappy and buzz you will more updates. I have some idea with 1.4 let see… Stay tuned…

Step for symfony 1.4 installation

  1. create a folder for your project on your local machine
    Ex project name  “testproject”
  2. Create “lib” folder in  project folder and create “vendor” in lib folder
    now the directory structure become  projectname/lib/vendor
  3. Now put symfony1.4 file in vendor folder and rename it as symfony
  4. Now execute the following command
    if  you want project with propel then execute

    php lib\vendor\symfony\data\bin\symfony generate:project testproject --orm=Propel

    if you want project in doctrine

    php lib\vendor\symfony\data\bin\symfony generate:project testproject --orm=none
  5. Now set database and password
    php symfony configure:database "mysql:host=localhost;dbname=dbname"  root rootPassword
  6. you can directly change in the file database.yml and propel.ini
  7. Now create application by executing
    php symfony generate:app frontend
  8. Create module
    php symfony generate:module frontend default
  9. Check php.ini if extension=php_pdo.dll not open then open it also check extension=php_pdo_mysql.dll

Hope this will be helpfull. Happy Programming.

quick ffmpeg audio-video encoding usage help

o from last 2-3 days I spent my so much time on file conversion with ffmpeg and mencoder.

After work done, I got some good links to follow for my future help and for all other readers.

The command what I tried for my use is like this

For High Quality and FFMPEG and libx264 vcodec i used this.

/usr/bin/ffmpeg -i /home/ganu/public_html/video/316.mp4
-b 1M -bt 4M -vcodec libx264 -pass 2 -vpre hq -acodec libfaac
-ac 2 -ar 44100 -ab 192k -threads 0 -s 552x311 -bufsize 200000000
-f flv -y /home/ganu/public_html/flvideo/316x.flv

Finally I used this this is working fine.

/usr/bin/ffmpeg -i /home/ganu/public_html/video/316.mp4
-r 30000/1001 -b 2M -bt 4M -acodec libfaac -ac 2 
-ar 44100 -ab 192k -s 552x311 -f flv -y /home/ganu/public_html/flvideo/316x.flv
/usr/bin/ffmpeg -i /home/ganu/public_html/video/316.mp4
-f image2 -ss 00:00:1 -s 120x90 -vframes 2
-y /home/ganu/public_html/tmp/thumbs/316/%08d.jpg

For metadata injection i used like this.

/usr/bin/flvtool2 -Uv

So first say the file 316.mp4 is converted to 316x.flv. And after flvtool2 the meta information is injected and final file will be 316.flv

So this is how, the flv conversion is done.

Happy Programming. 🙂

Symfony Criteria for table alias with join of same table

Symfony Criteria for table alias and join a quick example.

Yesterday got a good situation, A kind of join with same table and with table alias.
I need to use the first query with symfony criteria.

I got this, hope this will be usefull to you too.

FROM tbl_test
LEFT JOIN tbl_users u1 ON ( tbl_test.TEST_USER1_ID = u1.USR_ID )
LEFT JOIN tbl_users u2 ON ( tbl_test.TEST_USER2_ID = u2.USR_ID )
LEFT JOIN tbl_users u3 ON ( tbl_test.TEST_USER3_ID = u3.USR_ID )
$c = new Criteria();

Or take another example

SELECT FROM article a RIGHT JOIN article b ON a.article_id = ORDER BY DESC, DESC
$c=new Criteria();
$c->addAlias('a', 'article');
$c->addAlias('b', 'article');
$c->addJoin('a.arcticle_id','','RIGHT JOIN');
$rs = ArticlePeer::doSelectRS($c);  

Happy Programming. 😎

PHP & MySQL quick search bookmarklets

If you want to quick search to MySQL, here is the fast quick bookmarklet


And the same goes for PHP too same like above…


Happy Programming. 😀

quick symfony tips.

I am learning symfony. Just got some good tips to share with you.
Symfony rocks. 🙂

I will update this regularly.

1> How to write OR condition query in symfony.
$c = new Criteria();
$cton1 = $c->getNewCriterion(TABLEPEER::TBL_ID1, $some_condition , Criteria::EQUAL);
$cton2 = $c->getNewCriterion(TABLEPEER::TBL_ID1, $some_condition , Criteria::EQUAL);

2> How to get query where first date greater then and less then last date.
$date1 = date('Y-m-d 00:00:00');
$date2 = date('Y-m-d 23:59:59');
$cton1 = $gUser->getNewCriterion(TABLEPEER::TBLE_CREATEDAT, $date1, Criteria::GREATER_EQUAL);
$cton1->addAnd($gUser->getNewCriterion(TABLEPEER::TBLE_CREATEDAT, $date2, Criteria::LESS_EQUAL));

3> how to run the update query in symfony.

“update table TableName set TableField1=’1′ where TableField2=$some_value.”

$update = new TableName();
$update->setTableField2($imageId); // this is primary key of the table. include this line.

technorati tags:
, , , , Continue reading

PHP – LAMP interview questions

Its very tough to get the PHP interview question in net. So I thought to put/share some of the PHP interview question.

Part 1

  • difference between php4 & php5
  • How will you call the static members of a class
  • some Coding conventions
  • write some 5-10-15 linux commands with some short eg.
  • How sessions work? internally 🙂
  • something about directives in php.ini
  • the internal funda of upload file.
  • abstract class and an interface
  • all about function and method and diff
  • OOPS concept, more you know, you will get more depth q.
  • diff between PHP,Perl,.net,JSP
  • dynamic memory management.
  • if you know unix then grep,sed, awk
  • regx are main 🙂
  • CURL
  • standard q. diff between div and sapn
  • AJAX, DOM, ajax response type
  • waht is output buffering.
  • database designing/types/normalization/optimiztion.
  • any idea about soap,xml-rpc.
  • xml in PHP4 and PHP5.
  • the error “cannot modify headers” why it occurs?
  • Send a http request without browser thro telnet?
  • difference between padding and margin?
  • what is register globals?
  • how to execute system command.
  • what is xss and how to avoid this.
  • header internals.
  • magick quotes/here docs.

I am collecting more PHP q. and upload sooon.

Add more question in the comment line and make this list big.

Technorati Tags: , , , , ,

Find last day of the month in PHP

Yday I was working with dates and got the situation to get the last day of the month so got this piece of code.

date(’Y-m-d’,strtotime(’-1 second’,strtotime(’+1 month’,strtotime(date(’m').’/01/’.date(’Y').’ 00:00:00′))));

And this piece of code will gv you the last day of the your corrent month. 

tags: , , ,

My 2 weekends @foss.in2006 and @barcampbangalore :)


OMG!! if I feel my last 2 weeks then this is like full of work. For first week I was busy with and the next week barcampbangalore.

So I will say I enjoyed both the event a lot. in I was volunteer so I had so many things to learn and so many things to watch and to meet so many other big guys. And this is like awesome.

So this is the

As I told I was volunteer in that

volunteer in 2006

you can see me at extreme left. ( a fat boy ) :){ thnx to spo0nman for taking this photo – more of spo0nman’s photos. }

I am not so good in linux , I am on it from last 6 months only. But I found this is so kool more then windows. so after attending this event I learnt so many things. on the summary I got a kind of zeal.

I met rasmus too. and it was like a dream come true talking to rasmus. If you have not attended this event then I am sure you missed so many things. 🙂

any way meet you in the same event next year.


I am sure you must be knkowing that what is barcamp. Prev year too I have attended the barcampbangalore. Now this is the time for V2.0 so this weekend went to ThoughtWorks for attending the barcampbangalore2.

this is also awesome event. I enjoyed a lot and learnt a lot too. From last so many time i m jsut learning so this time I will also gv my views for any topic. I do not know I have some kind of hasitation or what ?? I do not know but will figure out till the next meetup.

I have attended around 7 talks and all are good and unique for there type.

You can get the slides HERE and HERE. and what abt the photos you can get it from HERE.

So if you were there I am sure you have enjoyed both the events. If you were not there in that then plan for the next year. 🙂

Happy Programming.

Technorati Tags: , , , , , , ,

PHP function summary

Just while surfing I got some imp categorization of the PHP functions. And this is really very nice to go thru it.

PHP strings : strstr, strchr, stristr, strpos, strrchr, stripos, mb_strpos, mb_strrpos, strrpos, strripos, substr

PHP Regular Expression : ereg, eregi, mb_ereg, mb_eregi, preg_match, preg_match_all

PHP string substitution : ereg_replace, eregi_replace, mb_ereg_replace, mb_eregi_replace, preg_replace, str_ireplace, str_replace, ltrim, rtrim, trim, nl2br

PHP MySQL connection : dbx_connect, fbsql_connect, ibase_connect, msql_connect, msql_pconnect, mssql_connect, mysql_connect, odbc_connect, pg_connect, pg_pconnect,
sesam_connect, ifx_pconnect, ifx_connect, sqlite_open, sqlite_popen, mysqli_connect, mysqli_pconnect

PHP file open : dio_open, fopen, proc_open, popen, gzopen

PHP file reading : dio_read, fread, gzread, socket_read, socket_recv, socket_recvfrom,
    socket_recvmsg, readline, fgetc, fgets, stream_get_line, file

PHP writing & printing : print, echo, printf, fprintf, vprintf, dio_write, fwrite, fputs,
    gzwrite, socket_send, socket_sendmsg, socket_sendto, socket_write, socket_writev

PHP closing : closelog, dio_close, fclose, gzclose, pclose, socket_close, proc_close

PHP splitting : split, explode, strtok, spliti, chunk_split, mb_split, preg_split, str_split

PHP array play : array_filter, preg_grep, array_search, array_unique, in_array, array_map, array_walk, array_count_values, array_change_key_case, array_sum

PHP sorting : sort, arsort, asort, krsort, ksort, natsort, natcasesort, rsort, usort,  array_multisort, uasort, uksort, dbx_sort, imap_sort, ldap_sort, yaz_sort

PHP escaping : dbx_escape_string, escapeshellarg, escapeshellcmd, pg_escape_bytea,
pg_escape_string, pg_unescape_bytea, addslashes, addcslashes, preg_quote, quotemeta, mysql_escape_string, mysql_real_escape_string, mysqli_real_escape_string, sqlite_escape_string

PHP miscellaneous : array_combine, array_fill, array_merge, list, range, count,    create_function, strtr, pow, putenv, getenv, getmygid, getmypid, getmyuid

May be some thing is remaing , then plz go thru that also. 😉

Technorati Tags: , ,

PHP and Perl – a good comparison

Now this is again a good topic , and I got 1 more link, and this link is also good.

I found that the owner has done some kind of perfect analysis of the language Perl and PHP.

Like you can say.

Number of PHP main functions: 3079 [1]
Number of Perl main functions: 206 [2]

Median PHP function name length: 13
Mean PHP function name length: 13.67

Median Perl function name length: 6
Mean Perl function name length: 6.22

and it has one more statement as “Why has PHP got 3079 functions while Perl does with only 206? In PHP, there are usually several functions that are very similar. In Perl, you have to know and remember less.”

By this way , you can also check this site.

chk this –

tags: , ,

-> Linux file structure

Linux File Structure: Directories

Different distributions have different directory structures.

  • /bin – essential UNIX commands such as ls, etc. Should contain all binaries needed to boot the system or run it in single-user mode
  • /boot – files used during booting and possibly the kernel itself are stored here
  • /dev – contains device files for various devices on system
  • /etc – files used by subsystems such as networking, NFS, and mail. Includes tables of disks to mount, processes to run on startup, etc.
  • /etc/profile.d – contains scripts that are run by /etc/profile upon login.
  • /etc/rc.d – contains a number of shell scripts that are run on bootup at different run levels. There is also typically an rc.inet1 script to set up networking (in Slackwar), an rc.modules script to load modular device drivers, and an rc.local script that can be edited to run commands desired by the administrator, along the lines of autoexec.bat in DOS.
  • /etc/rc.d/init.d – contains most of the initialization scripts themselves on an rpm-based system.
  • /etc/rc.d/rc*.d – where “*'' is a number corresponding to the default run level. Contains files for services to be started and stopped at that run level. On rpm-based systems, these files are symbolic links to the initialization scripts themselves, which are in /etc/rc.d/init.d.
  • /etc/skel – directory containing several example or skeleton initialization shells. Often contains subdirectories and files used to populate a new user's home directory.
  • /etc/X11 – configuration files for the X Window system
  • /home – home directories of individual users
  • /lib – standard shared library files
  • /lib/modules – modular device driver files, most with .o extensions
  • /mnt – typical mount point for many user-mountable devices such as floppy drives, cd-rom readers, etc. Each device is mounted on a subdirectory of /mnt.
  • /proc – virtual file system that provides a number of system statistics
  • /root – home directory for root
  • /sbin – location of binaries used for system administration, configuration, and monitoring
  • /tmp – directory specifically designed for programs and users to store temporary files.
  • /usr – directory containing a number of subdirectory with programs, libraries, documentation, etc.
  • /usr/bin – contains most user commands. Should not contain binaries necessary for booting the system, which go in /bin. The /bin directory is generally located on the same disk partition as /, which is mounted in read-only mode during the boot process. Other filesystems are only mounted at a later stage during startup, so putting binaries essential for boot here is not a good idea.
  • /usr/bin/X11 – most often a symbolic link to /usr/X11R6/bin, which contains executable binaries related to the X Window system
  • /usr/doc – location of miscellaneous documentation, and the main location of program documentation files under Slackware
  • /usr/include – standard location of include files used in C programs such as stdio.h
  • /usr/info – primary location of the GNU info system files
  • /usr/lib – standard library files such as libc.a. Searched by the linker when programs are compiled.
  • /usr/lib/X11 – X Window system distribution
  • /usr/local/bin – yet another place to look for comon executables
  • /usr/man – location of manual page files
  • /usr/sbin – other commands used by superuser for system administration
  • /usr/share – contains subdirectories where many installed programs have configuration, setup and auxiliary files
  • /usr/share/doc – location of program documentation files under Mandrake and Red Hat
  • /usr/src – location of source programs used to build system. Source code for programs of all types are often unpacked in this directory.
  • /usr/src/linux – often a symbolic link to a subdirectory whose name corresponds to the exact version of the Linux kernel that is running. Contains the kernel sources.
  • /var – administrative files such as log files, used by various utilities
  • /var/log/packages – contains files, each of which has detailed information on an installed package in Slackware. The same file can also be found at /var/adm/packages, since the adm subdirectory is a symbolic link to log. Each package file contains a short description plus a list of all installed files.
  • /var/log/scripts – package installation scripts in Slackware are stored here. You can inspect these scripts to see what special features are included in individual packages.
  • /var/spool – temporary storage for files being printed, mail that has not yet been picked up, etc.

-> MySQL Joins ‘the perfect example’

There are 3 kinds of join: INNER, LEFT OUTER, and RIGHT OUTER.

Each requires an ON clause to let the RDBMS know what fields to use joining the tables. For each join there are two tables: the left table and the right table. The syntax is as follows:

{left table} {INNER | LEFT | RIGHT} JOIN {right table} ON {join criteria}

An INNER JOIN returns only those rows from the left table having a matching row in the right table based on the join criteria.

A LEFT JOIN returns ALL rows from the left table even if no matching rows where found in the right table. Any values selected out of the right table will be null for those rows where no matching row is found in the right table.

A RIGHT JOIN works exactly the same as a left join but reversing the direction. So it would return all rows in the right table regardless of matching rows in the left table.

It is recommended that you not use right joins, as a query can always be rewritten to use left joins which tend to be more portable and easier to read.

With all of the joins, if there are multiple rows in one table that match one row in the other table, that row will get returned many times.

For example:
Table A
tid, name
1, 'Linux'
2, 'Debian'

Table B
fid, tid, message
1, 1, 'Very Cool'
2, 1, 'What an example'

Query 1:
SELECT, b.message FROM a INNER JOIN b ON a.tid = b.tid
Result 1:
Linux, Very Cool
Linux, What an example

Query 2:
SELECT, b.message FROM a LEFT JOIN b ON a.tid = b.tid
Result 2:
Linux, Very Cool
Linux, What an example
Debian, <null>

The acricle is taken by – thnx to drupal community. 🙂

Tags : mysqljoin , database 

%d bloggers like this: