Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Thursday, June 11, 2009

Installing CPAN modules in perl in linux.

Perl support lots of in built module available under CPAN [Comprehensive Perl Archive Network] which can be install by the following command.

uttam@uttam:/ sudo perl -MCPAN -e shell

after this command you'ill be under cpan shell and you'll see the following text on screen..

cpan shell -- CPAN exploration and modules installation (v1.9205)
ReadLine support available (maybe install Bundle::CPAN or Bundle::CPANxxl?)

cpan[1]>

Now you can install module you want with perl.for example you can type "install DBI" to install DBI modules.

After successful installation you can view the DBI directory under following folder.
/usr/local/lib/perl/5.10.0/.

Wednesday, December 17, 2008

ADODB with PHP and oracle

Oracle is the popular commercial database which is being used with the PHP.There are vaious ways to connect to oracle database.ADODB library is one of the fastest way to connect php with the oracle database.It has Has multi-tier design. Simple high-level design for beginners, and also lower-level advanced Oracle functionality.ADODB provide very high speed databse connectivity with catching and fastest database abstaction.It also allow multiple prepare statement.

An example to connect php with oracle using ADODB library is as follows.

include"/path/to/adodb.inc.php";
$db = NewADOConnection("oci8");
$db->Connect($tnsName, "scott", "tiger");

$rs = $db->Execute("select * from emp where empno>:emp order by empno",
array('emp' => 7900));
while ($arr = $rs->FetchRow())
{
print_r($arr);

}
The Execute( ) function returns a recordset object, and you can retrieve the rows returned using $recordset->FetchRow( ).
You can also query the database using the standard Microsoft ADO MoveNext( ) metaphor. The data array for the current row is stored in the fields property of the recordset object, $rs. MoveNext( ) offers the highest performance among all the techniques for iterating through a recordset:

$rs = $db->Execute("select * from emp where empno>:emp", array('emp' => 7900));
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}

For easy pagination support, we provide the SelectLimit function. The following will perform a select query, limiting it to 100 rows, starting from row 201 (row 1 being the 1st row):

$offset = 200; $limitrows = 100;
$rs = $db->SelectLimit('select * from table', $limitrows, $offset);

Caching

You can define a database cache directory using $ADODB_CACHE_DIR, and cache the results of frequently used queries that rarely change. This is particularly useful for SQL with complex where clauses and group-by's and order-by's. It is also good for relieving heavily-loaded database servers.The following example will cache the following select statement for 7200 seconds

$ADODB_CACHE_DIR = '/var/tmp';
$rs = $db->CacheExecute(7200, "select names from allcountries order by 1");
Using Prepare statements

Prepare( ) is for compiling frequently used SQL statement for reuse. For example, suppose we have a large array which needs to be inserted into an Oracle database. The following will result in a massive speedup in query execution (at least 20-40%), as the SQL statement only needs to be compiled once:


Friday, October 10, 2008

PHP Security

Now-a-days web security has been a major concern.During development, when the code is being written, it is important to consider illegitimate uses of your application. Often, the focus is on making the application work as intended, and while this is necessary to deliver a properly functioning application, it does nothing to help make the application secure. fact that you are here is evidence that you care about security,

Since PHP is a growing language being used for the web development,It's very important to discuss about PHP security.

Input flaws
most common PHP security flaws is the unvalidated input error. User-provided data simply cannot be trusted and should be validated properly.

register_globals = OFF. The register_globals directive is disabled by default in PHP versions 4.2.0 and greater.Enabling register_globals may cause a security risk.
A common example to explain the problem is as follows.
this example that illustrates how register_globals can be problematic is the following use of include with a dynamic path:

With register_globals enabled, this page can be requested with ?path=http%3A%2F%2Fevil.example.org%2F%3F in the query string in order to equate this example to the following:




Avoid using $_REQUEST[] since as per GPC rule $_GET has higher priorities than $_POST, So $_POST variables may be overwritten.

Always validate input data against maxlength in PHP.you can use array and for each to do this.
50);
foreach($max as $key=>$val)
{
if(strlen($_POST[$key])>$val)
{
//display maxlength error
}
}
?>



Monday, September 29, 2008

web usabilty

Usability has it’s own importance in a website.Some dos and don’t s to achieve a good usability are as follows.

  • Do:
    • Use ALT tags for all graphics, especially navigation graphics.
    • Use black text on white background whenever possible for optimal legibility.
    • Use either plain-color backgrounds or extremely subtle background patterns.
    • Make sure text is in a printable color (not white).
    • Place navigation in a consistent location on each page of your website.
    • Use a familiar location for navigation bars.
    • Keep the design from scrolling horizontally.
    • Use one axis of symmetry for centered text on a page.
    • Encourage scrolling by splitting an image at the fold.
  • Don’t:
    • Allow ALT tags to get clipped (especially an issue for small, fixed width images).
    • Display static text in blue or underlined.
    • Use boldface or ALL CAPS for long pieces of text. These slow down reading.
    • Leave too much white space–reduces scannability.
    • Make the user scroll to find critical information, especially transaction buttons and navigation links.
    • Use horizontal rules to separate chunks of content.
    • Alternate too frequently between centered text and left-aligned text. Most text should be left-aligned.
    • Fix pages at larger than 800 x 600 pixels. Larger pages may force users to scroll horizontally.