Monday, July 6, 2009

Task in Interview for php programmer

create an application
User can browse the file from the disk.
Get the data from that file then
create a XML file that contains most number of words first. only 100 words. word is not less than 3 characters. following format



the
ram
....

Tuesday, March 24, 2009

Mail sending with attachment using PHP

//Gather file data
$filename = $_FILES['filename1']['name'];
$tmp = $_FILES['filename1']['tmp_name'];
$sep = md5(time());

//Get file contents
$fdata = chunk_split(base64_encode(file_get_contents($tmp))); //Encode data into text form

//Email To address
$to = "ramkrism@gmail.com";

//Determine mime type
$ext = explode('.', $filename);
$ext = $ext[1];

if($ext == "JPG" || $ext == "jpg" || $ext == "JPEG" || $ext == "jpeg") {
$mime_type = "image/jpeg";
}
elseif($ext == "gif" || $ext == "GIF") {
$mime_type = "image/gif";
}
else {
exit("Error: Wrong file type!");
}

//message
$message = "Email content";

// headers
$headers = "From: \"From Name\" MIME-Version: 1.0
Content-Type: Multipart/Mixed; boundary=\"$sep\"
charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
--$sep
Content-Type: $mime_type; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$filename\"
$fdata --$sep";

$subject = "Email Subject Here";
if(mail($to, $subject, $message, $headers)){
echo 'Sent';
}
else {
echo 'Not Sent';
}
?>

Saturday, March 21, 2009

What is the difference between connect and pconnect in PHP?

mysql_connect opens up a database connection every time a page is loaded. mysql_pconnect opens up a connection, and keeps it open across multiple requests.

mysql_pconnect uses less resources, because it does not need to establish a database connection every time a page is loaded.

First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, username and password. If one is found, an identifier for it will be returned instead of opening a new connection.

Second, the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect()).

These type of links is therefore called 'persistent'.

Monday, March 9, 2009

PHP Questions 1

1. HTML, XHTML and DHTML
2. Session handling in php. where session value will be stored.
3. File uploading in PHP. $_FILES parameters
4. Inheritance
5. Abstraction
6. Encapsulation
7. data abstraction
8. Types of Array.
9. split and explode
10. implode and explode
11. htmlentities()
12. urlencode and urldecode
13. require and include
14. Get and post
15. Connect and pconnect
16. max execution time change dynamically
17. max upload size change dynamically
18. Interface
19. OOPS concepts.
20. Which is not supported in PHP.
21. Which inhertance not supported in PHP
22. Types of inheritance.
23. public, private and protected
24. what is abstract class.
25. Cookies
26. differece Session and Cookies

Sunday, March 1, 2009

What is drupal

What is drupal

- Open source CMS.
- Highly Modular.
- used to build websites.
- Drupal is written in PHP
- Drupal ships with basic core functionality,
and additional functionality is gained by enabling built-in or third-party modules.
- Drupal is designed to be customized, but customization is done by overriding the core or by adding modules, not by modifying the code in the core.
- Drupal’s design also successfully separates content management from content presentation.

Differance between Drupal 5 and 6 and 4
-----------------------------------------
- Drupal 6 gives you things like:
* More AJAX - you can drag & drop things to order them instead of setting weights by numbers in select boxes.
* Views 2 - this version of the Views module is incredible, and only available for Drupal 6.
* Trigger and Actions - built in.
* Status updates - Drupal 6 emails you when new versions of your installed modules are available.

How Drupal Works
-----------------
- index.php
- bootstrap.inc
- callback
- Rendering html

Architecture of Drupal
Hierarchy of drupal

Folder Structure of drupal
-----------------------------
- includes - libraries of common functions that Drupal uses.
- misc - stores JavaScript and miscellaneous icons and images available to a stock
Drupal installation
- modules - core modules
- profiles - different installation profiles for a site.An example would be an e-commerce profile that automatically sets up Drupal as an e-commerce platform.
- sites - your modifications to Drupal in the form of settings, modules, and themes.
* all
* default - default configuration file for your Drupal site—default.settings.php.
- scripts - contains scripts for checking syntax, cleaning up code, running
Drupal from the command line, and handling special cases with cron.
- themes - template engines and default themes for Drupal.
- cron.php, index.php, install.php, update.php, xmlrpc.php, robots.txt

MVC Framework
---------------
- Drupal not a strict MVC. But some modules in MVC.
- Drupal is not a true MVC framework

How to upgrade
---------------
- Backup the files
- Get New version
- Put site into offline
- Disable contributed and custom modules and themes
- run the update.php

What is node
------------
- A node is a single piece of content that is published on a Drupal site.
- If it is content... such as stories, videos, images, pages, etc... it is a node. If you create your own content types, those would be nodes as well.
- Nodes are the basic content building blocks of a Drupal site

What is hook
-------------
* Allow modules to interact with the Drupal core.
* Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.
* To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and call that hook in all enabled modules that implement it.
* The available hooks to implement are explained here in the Hooks section of the developer documentation. The string "hook" is used as a placeholder for the module name is the hook definitions. For example, if the module file is called example.module, then hook_help() as implemented by that module would be defined as example_help().

Increase file upload size
---------------------------
- php.ini file max_upload_size

Increase PHP memory limit
--------------------------
- memory_limit = 16M to your php.ini file (recommended, if you have access)
- ini_set('memory_limit', '16M'); to your sites/default/settings.php file
- php_value memory_limit 16M to your .htaccess file in the Drupal root

How to convert HTML to Drupal / how to create theme and tpl
------------------------------
- put Html and style file in sites/all/themes dir
- print print_r(get_defined_vars());
- Print these PHP variables in page.tpl

Variables in page.tpl
- defined in phptemplate.engine
- _phptemplate_variables() create new variables
- themename_preprocess_page(&$vars)

what are all tpl's are there and their uses
-------------------------------------------
- page.tpl
- node.tpl
- comment.tpl
- block.tpl

Panels
--------
create pages that are divided into areas of the page

Blocks
----------
- A block is information that can be enabled or disabled in a specific location on your web site’s template. For example, a block might display the number of current active users on your site.
- You might have a block containing links to the most popular content on the site, or a list of upcoming events. Blocks are typically placed in a template’s sidebar, header, or footer.
- Blocks can be set to display on nodes of a certain type, only on the front page, or according to other criteria. Often blocks are used to present information that is customized to the current user.
- For example, the user block only contains links to the administrative areas of the site to which the current user has access, such as the “My account” page. Regions where blocks may appear (such as the header, footer, or right or left sidebar) are defined in a site’s theme; placement and visibility of blocks within those regions is managed through the web-based administrative interface.

How to create Module
---------------------
- create directory in sites/all/modules
- create module.info & module.module
- inforamtion abt the module
- create hook"

Video and audio module
-----------------------

Legacy Module
-------------
* Do not use this module; it is no longer supported. Consider using Path Redirect instead.
* Legacy Path is intended to support websites that are moving to Drupal but have content that either won't be managed by Drupal immediately or at all, but must remain reachable through it's original URL. The assumption is made that the legacy system remains operational, but at a different (sub)domain or directory.
* Note per #236414: Module does not work with 'Normal' caching enabled. that this module does not work with Normal caching enabled.
* For example, an online newspaper might have an existing archive system that provides permalinks such as:
http://paper.example.com/content.php?section=12&article=22
After a Drupal installation, the online newspaper has moved the old system to the URL:
http://archive.example.com/content.php?section=12&article=22
* This module accomodates redirecting (using HTTP redirects) the old URL to the new URL.
* The module follows this flow:
1. An incoming URL is checked to see if it is present in Drupal. If the module is not set to force all paths to redirect, the module returns control to the normal Drupal request handling process.
2. The module then iterates through the redirect rules from lightest to heaviest checking for a matching pattern.
3. When a match is found, the module checks to see if the redirect URL is in the cache. If it is, and the cache entry is not expired, a redirect is sent to the browser and the module terminates. Otherwise, the module validates the new URL. If it is valid, the URL is cached, the redirect sent to the browser, and the module terminates.
4. If the match did not produce a valid URL, processing continues to the next redirect rule.
5. If no matches and/or no valid redirects are found, the module returns control of request handing to Drupal which can then produce the 404 response.

Legal module
-------------
* Displays your Terms & Conditions to users who want to register, and requires that they accept the T&C before their registration is accepted.
* If T&Cs are changed users with an existing account will be asked to accept the new version, and will not be able to log in until they have.
* T&C text should only be entered by administrators or other highly trusted users. filter_xss_admin() is used to filter content for display, this is a very permissive XSS/HTML filter intended for admin-only use.
* The Checkbox Validate module is required.
* Note: there is a conflict with the SecureSite module - do not use Legal and SecureSite on the same site.

Localization module
- translates the user's menus
- provides a language switch block
- translates the node's content
cck module
IRC Module / Chat
Ubercart or Payment modules
multiple sites

what s Taxonomy & how to create
- Categorizing the content
- Add vocabulary
- Add Term
What are all the Errors in Drupal
- Page Not found - 404
- Access denied - 403
Chart