Wednesday, April 30, 2008

"Exception thrown and not caught" error On IE

Hi
 update your js like this. and you will get the actual cause of that issue. then it will help to fix.

try
{
 // do your code here
} catch(e)
{
  alert(e.faultCode?e.faultCode:e.message?e.message:e)
}

and check the permission of the file too..


hope it will helps u...





--
Thankyou
with regards
Shanmugarajan.k
http://shanmugarajan.blogspot.com/
http://letus-know.blogspot.com/

"Exception thrown and not caught" error On IE

Hi
 update your js like this. and you will get the actual cause of that issue. then it will help to fix.

try
{
 // do your code here
} catch(e)
{
  alert(e.faultCode?e.faultCode:e.message?e.message:e)
}

and check the permission of the file too..


hope it will helps u...


Api Vtiger

http://api.vtiger.com/index.php

Tuesday, April 29, 2008

Google Latest SEO Issues

Google Latest SEO Issues



Hi guys, here are latest developments on how google is behaving these days when it comes to the SEO fraternity. A lot of developments have taken place and have effected the way the websites rank on Google. I have tried to assimilate the subject in 4 points for better understanding.

  • Google Canonical Issues: It has been noticed that Google now treats www.yourdomain.com, yourdomain.com, and yourdomain.com/index.html as different web sites, the effect of whihc is that these pages are treated with google as different web pages with same content and these pages are penalised for this fact. This is a basic indexing issue and its problem with googles indexing capability that it was unable to resolve this issue.
  • Google Sandbox Effect: It is seen that websites which are new launches face this problem that Google does not include them in the ranking index for a specified period of time thinking that the website having 1,00,0000 pages cannot be created in a short span of time and the links that it has cannot be natural and are either spam or paid. So google puts the website under the sandbox penalty to ensure that the website is a genuine source and monitors the website till it finally start to show it in the results. The time frames are your best guess. Although there are no written proofs of such phenomenon but it is noticed that for highly competitive terms generally this is noticed. Websites targeting less competitive terms still dont have to face the sandbox penalty.
  • Supplemental Page Issues: After the Big Daddy roll out the supplement page issue became a night mare of all webmasters. it was noticed that big names were hit by this supplement page problem where 1,00,000's of pages were put into the supplement index which was like burying the websites alive. The credit to this also goes to the Canonical Issues which google failed to resolve, but i guess the night mare is over to a lot of extent. TO add to the story is that duplicate content where the website in todays scenario use News feeds and Rss to cover the stories is also a problem which leads to supplement pages. The key lies in original content and well optimizes pages and solutions.

Cheers!!!

Monday, April 28, 2008

Some examples on how to use call-by-reference in PHP

Some examples on how to use call-by-reference in PHP

Whilst passing variables by copy is OK for most basic tasks, passing variables by reference is very useful when it comes to advanced data structures such as lists and trees.

PHP supports passing references using the & operator, but it can be a bit painful to work out what's going on, especially once you start trying to store references to objects in arrays, and then try to iterate over them.

So here goes...


$a=5; print("A=$a.");
A=5.

Introducing references...


$a=5; $a_ptr=&$a; print("A=$a."); $a_ptr=6; print("A=$a.");
A=5.A=6.

Introducing arrays...


$a=5; $b=50; $arr=array(&$a,&$b); print("A=$a, B=$b. "); $arr[0]=6; print("A=$a, B=$b. ");
A=5, B=50. A=6, B=50.

For each'ing...

This does not work as intended, because 'foreach' creates copies of the array elements. Changes made to those copies get lost after the loop body.
$a=5; $b=50; $arr=array(&$a,&$b); print("A=$a, B=$b. "); foreach( $arr as $x ) { $x=$x+1; print( "now $x. " ); } print("A=$a, B=$b. ");
A=5, B=50. now 6. now 51. A=5, B=50.

Replacement for 'for each' that works like references...

This will work with arrays of objects as well, of course. In that case, "$arr[$key]=$arr[$key]+1" will need to be replaced with something along the lines of "$arr[$key]->someFunction()".
$a=5; $b=50; $arr=array(&$a,&$b); print("A=$a, B=$b. "); foreach (array_keys($arr) as $key) { $arr[$key]=$arr[$key]+1; print( "now $arr[$key]. " ); } print("A=$a, B=$b. ");
A=5, B=50. now 6. now 51. A=6, B=51.
The end.

Bibliography

mysql query show tables with like and where

Thease querys will solve those problem.

show tables like "%countries%"
show tables where Tables_in_databasename="countries"

just change the second query <databasename> with u r original database name.

i hope helps u....


Sunday, April 27, 2008

Php swap the two variables by reference

<?php

$a =20;
$b =10;
echo $a . $b;
swap(&$a, &$b,$a,$b);  // passing addess and value of the $a,$b
echo "<br>".$a . $b;

function swap($a_ptr,$b_ptr,$a,$b){

$a_ptr = $b;
$b_ptr = $a;


}



Display the dyanamic column in php/mysql

$query_cat = "SELECT * FROM "table" WHERE";
    $query_cat .= " "filtered_row" = "parameter"";

    $cat = mysql_query($query_cat) or die(mysql_error());
    $total = mysql_num_rows($cat);

    while($row = mysql_fetch_array($cat))
    {
// -- This array will hold your data,
// -- I used it to hold a title, an id and an author
// -- but it can be extended based on your own needs
        $items[] = array(1 => $row['title'], 2 => $row['id'], 3 => $row['author']);
    }
        // Default # of Columns
        $numcols = 4;

        // Number of Items
        $numitems = count($items);

        // Number of Rows
        $numrows = ceil($numitems/$numcols);

        echo '<table width="100%">';
        for ($row=1; $row <= $numrows; $row++)
        {
            $cell = 0;
            echo ' <tr>'."\n";
            for ($col=1; $col <= $numcols; $col++)
            {
            echo '  <td width="'.round(100/$numcols).'%">'."\n";

            if ($col===1)
            {
                $cell += $row;
                print $items[$cell - 1][1]; /*  $items[$cell - 1][1] to display title  $items[$cell - 1][2] etc... */
            }
            else {
                $cell += $numrows;
                print $items[$cell - 1][1];
            }
            echo '  </td>'."\n";
            }
            echo ' </tr>'."\n";
        }
        echo '</table>';

How to remove/delete the duplicate entry in mysql

Remove duplicate entries. Assume the following table and data.

CREATE TABLE IF NOT EXISTS dupTest (
pkey int(11) NOT NULL auto_increment,
a int,
b int,
c int,
timeEnter timestamp(14),
PRIMARY KEY (pkey)

);

insert into dupTest (a,b,c) values (1,2,3),(1,2,3),
(1,5,4),(1,6,4);



mysql> select * from dupTest;
select * from dupTest;
+------+------+------+------+---------------------+
| pkey | a | b | c | timeEnter |
+------+------+------+------+---------------------+
| 1 | 1 | 2 | 3 | 2004-04-16 10:55:35 |
| 2 | 1 | 2 | 3 | 2004-04-16 10:55:35 |
| 3 | 1 | 5 | 4 | 2004-04-16 10:55:35 |
| 4 | 1 | 6 | 4 | 2004-04-16 10:55:35 |
+------+------+------+------+---------------------+
4 rows in set (0.00 sec)

mysql>

Note, the first two rows contains duplicates in columns a and b. It contains
other duplicates; but, leaves the other duplicates alone.

mysql> ALTER IGNORE TABLE dupTest ADD UNIQUE INDEX(a,b);

mysql> select * from dupTest;
select * from dupTest;
+------+------+------+------+---------------------+
| pkey | a | b | c | timeEnter |
+------+------+------+------+---------------------+
| 1 | 1 | 2 | 3 | 2004-04-16 11:11:42 |
| 3 | 1 | 5 | 4 | 2004-04-16 11:11:42 |
| 4 | 1 | 6 | 4 | 2004-04-16 11:11:42 |
+------+------+------+------+---------------------+
3 rows in set (0.00 sec)

Thursday, April 24, 2008

What are the advantages of stored procedures, triggers, indexes

A stored procedure is a set of SQL commands that can be compiled and stored in the server. Once this has been done, clients don't need to keep re-issuing the entire query but can refer to the stored procedure. This provides better overall performance because the query has to be parsed only once, and less information needs to be sent between the server and the client. You can also raise the conceptual level by having libraries of functions in the server. However, stored procedures of course do increase the load on the database server system, as more of the work is done on the server side and less on the client (application) side.


Triggers will also be implemented. A trigger is effectively a type of stored procedure, one that is invoked when a particular event occurs. For example, you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that stored procedure automatically deletes the corresponding customer from a customer table when all his transactions are deleted.


Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks.

Wednesday, April 23, 2008

perl examples

Perl Examples

   1. Calling System Commands
          * Image Processing
          * Renaming Files
          * File Conversion
          * Creating Directories
          * Padding & Unpadding Files

   2. Scanning the Network
          * Finding Free Machines
          * Finding Processes
          * Finding Files
          * Finding Users

   3. File Manipulation
          * Generating HTML Files
          * Generating Xpost Scripts
          * Modifying Files
          * Convert Raw Data

Remember: In order to be able to run your perl script, it must begin with the line:

   #!/usr/local/bin/perl

Furthermore, if you've named the file "myFile", then to make the file executable, you need to type in a unix window:

   chmod 755 myFile

Image Processing

#!/usr/local/bin/perl
#
# composite series of images over a background image
#

if ($#ARGV != 4) {
 print "usage: compem bg.rgb inbase outbase startNum stopNum\n";
 exit;
}

$bg = $ARGV[0];
$inbase = $ARGV[1];
$outbase = $ARGV[2];
$start = $ARGV[3];
$stop = $ARGV[4];

# for each image
for ($i=$start; $i <= $stop; $i++) {

    # pad numbers
    $num = $i;
    if($i<10) { $num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    # call unix command "over"
    $cmd = "over $bg $inbase.$num $outbase.$num 0 0";
    print $cmd."\n";
    if(system($cmd)) { print "over failed\n"; }
}


Renaming Files

#!/usr/local/bin/perl
#
# rename series of frames
#
if ($#ARGV != 3) {
    print "usage: rename old new start stop\n";
    exit;
}

$old = $ARGV[0];
$new = $ARGV[1];
$start = $ARGV[2];
$stop = $ARGV[3];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {    $num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "mv $old.$num $new.$num";
    print $cmd."\n";
    if(system($cmd)) { print "rename failed\n"; }
}


File Conversion

#!/usr/local/bin/perl
#
# convert series of images from one format to another
#
if ($#ARGV != 5) {
    print "usage: fconvert intype outtype old new start stop\n";
    exit;
}

$intype = $ARGV[0];
$outtype = $ARGV[1];
$old = $ARGV[2];
$new = $ARGV[3];
$start = $ARGV[4];
$stop = $ARGV[5];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {    $num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "imgcvt -i $intype -o $outtype $old.$num $new.$num";
    print $cmd."\n";
    if(system($cmd)) { print "imgcvt failed\n"; }
}


Creating Directories

#!/usr/local/bin/perl
#
# create a series of directories
#
if ($#ARGV != 2) {
    print "usage: mkdirs base start stop\n";
    exit;
}

$base = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {    $num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "mkdir $base$num";
    print $cmd."\n";
    if(system($cmd)) { print "mkdir failed\n"; }
}


Padding & Unpadding Files

#!/usr/local/bin/perl
#
# pad file numbers with zeros
#
if ($#ARGV != 2) {
    print "usage: pad base start stop\n";
    exit;
}

$base = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];

for ($i=$start; $i <= $stop; $i++) {

    $num = $i;
    if($i<10) {    $num = "00$i"; }
    elsif($i<100) { $num = "0$i"; }

    $cmd = "mv $base$i $base$num";

    # to unpad, use this instead:
    # $cmd = "mv $base$num $base$i";

    print $cmd."\n";
    if(system($cmd)) { print "pad failed\n"; }
}


Finding Free Machines

#!/usr/local/bin/perl
#
# search list of machines for machines with no users logged on
#
$machines = `systems sgi`;
chop($machines);
@sgis = split(/ /, $machines);
@sgis = sort(@sgis);

foreach $machine (@sgis) {

    if(!(`rusers $machine`)) {
    print "$machine\n";
    }
}


Finding Processes

#!/usr/local/bin/perl
#
# search for processes running on machines
#

if ($#ARGV != 0) {
    print "usage: findprocess process\n";
    exit;
}

$process = $ARGV[0];
$machines = `systems sgi`;
chop($machines);
@sgis = split(/ /,$machines);
@sgis = sort(@sgis);

foreach $machine (@sgis) {

    print "Checking $machine...\n";

    @lines = `rsh $machine \"ps -ef | grep $process | grep -v findprocess | grep -v grep\"`;

    if(@lines) {
    foreach $line (@lines) {
        $line =~ /^\s*(\w+)\s+(\d+)/;
        $user = $1;
        $pid = $2;
        print "$user on $machine  pid: $pid\n";
    }
    }
}


Finding Files

#!/usr/local/bin/perl
#
# search for a file in all subdirectories
#
if ($#ARGV != 0) {
    print "usage: findfile filename\n";
    exit;
}

$filename = $ARGV[0];

# look in current directory
$dir = `pwd`;
chop($dir);
&searchDirectory($dir);

sub searchDirectory {
    local($dir);
    local(@lines);
    local($line);
    local($file);
    local($subdir);

    $dir = $_[0];

    # check for permission
    if(-x $dir) {

    # search this directory
    @lines = `cd $dir; ls -l | grep $filename`;
    foreach $line (@lines) {
        $line =~ /\s+(\S+)$/;
        $file = $1;
        print "Found $file in $dir\n";
    }
   
    # search any sub directories
    @lines = `cd $dir; ls -l`;
    foreach $line (@lines) {
        if($line =~ /^d/) {
        $line =~ /\s+(\S+)$/;
        $subdir = $dir."/".$1;
        &searchDirectory($subdir);
        }
    }
    }
}


Finding Users

#!/usr/local/bin/perl
#
# check whether user is logged on
#

if ($#ARGV != 0) {
    print "usage: finduser username\n";
    exit;
}

$username = $ARGV[0];
$machines = "insanity ".`systems sgi`;
chop($machines);
@machines = split(/ /,$machines);
@machines = sort(@machines);

foreach $machine (@machines) {
   
    if(`rusers $machine | grep $username`) {
    print "$username logged on $machine\n";
    }
}


Generating HTML Files

#!/usr/local/bin/perl
#
# create n html files linked together in slide show
#

if ($#ARGV != 1) {
    print "usage: htmlslides base num\n";
    exit;
}

$base = $ARGV[0];
$num = $ARGV[1];

for ($i=1; $i <= $num; $i++) {

    open(HTML, ">$base$i.html");

    if($i==$num) {
    $next = 1;
    } else {
    $next = $i+1;
    }

    print HTML "<html>\n<head>\n<title>$base$i</title>\n</head>\n<body>\n";
    print HTML "<a href=\"$base$next.html\"><img src=\"$base$i.jpg\"></a>\n";
    print HTML "</body>\n</html>\n";

    close(HTML);
}


Generating Xpost Scripts

#!/usr/local/bin/perl
#
# generate an xpost script to adjust saturation, and run xpost
#
if ($#ARGV != 2) {
 print "usage: fixsat infile.tiff outfile.tiff satval\n";
 exit;
}

$infile = $ARGV[0];
$outfile = $ARGV[1];
$satval = $ARGV[2];

# open xpost script
open(XPOST, "&gt__tmp.xp");

# set view to register A
print XPOST "view A\n";

# load original image into reg A
print XPOST "load $infile\n";

# run Kmult to turn down saturation
print XPOST "Kmult $satval $satval $satval  1.0 a b\n";

# set view to register B
print XPOST "view B\n";

# save unsaturated image
print XPOST "save tiff $outfile\n";

# close xpost script
close(XPOST);

# run xpost script
$cmd = "xpost -q -s __tmp.xp";
print $cmd."\n";
system($cmd);

# clean up
$cmd = "/bin/rm -f __tmp.xp";
print $cmd."\n";
system($cmd);


Modifying Text Files

#!/usr/local/bin/perl
#
# change all occurances of a string in a file to another string
#

if ($#ARGV != 3) {
    print "usage: chstring oldfile newfile oldstring newstring\n";
    exit;
}

$oldfile = $ARGV[0];
$newfile = $ARGV[1];
$old = $ARGV[2];
$new = $ARGV[3];

open(OF, $oldfile);
open(NF, ">$newfile");

# read in each line of the file
while ($line = <OF>) {
    $line =~ s/$old/$new/;
    print NF $line;
}

close(OF);
close(NF);


Convert Raw Timecode Data to Readable Data

#!/usr/local/bin/perl
#
# Change raw timecode data to different format
#
# timecode data event looks like:
#
# Event: 1
# 00:01:05:23
# 00:01:27:21
# a-2-9
#
# Event: 2
# 00:01:56:13
# 00:02:03:19
# a-3-9
#
# ...and so on...
#
# Want to change it to the form:
#
# a-2-9 = 21.93 seconds = 658 frames
# a-3-9 = 7.20 seconds = 216 frames
#

open(FP,"<log.txt");

$first = 1;
$total = 0;

while($line = <FP>) {

    if ($line =~ /^\d\d/ && $first) {
    $in = $line;
    $first = 0;
    } elsif ($line =~ /^\d\d/ && !$first) {
    $out = $line;
    $first = 1;
    } elsif ($line =~ /^\w-/) {
    $shot = $line;
    chop($shot);

    # parse timecodes and
    # translate in and out into seconds
    $in =~ /(\d\d):(\d\d):(\d\d):(\d\d)/;
    $hrs = $1;
    $mns = $2;
    $scs = $3;
    $fms = $4;
    $inSecs = $hrs * 3600 + $mns * 60 + $scs + $fms / 30;

    $out =~ /(\d\d):(\d\d):(\d\d):(\d\d)/;
    $hrs = $1;
    $mns = $2;
    $scs = $3;
    $fms = $4;
    $outSecs = $hrs * 3600 + $mns * 60 + $scs + $fms / 30;

    # calc duration
    $dur = $outSecs - $inSecs;
    $total += $dur;

    # print line
    printf("$shot = %.2f seconds = %d frames\n", $dur, $dur * 30);
    }
}

print "total = ".($total / 60)." mins\n";

close FP;

Tuesday, April 22, 2008

Some interesting Bugs in php

<?
if(isset($_REQUEST['submit']))
echo "<pre>";
print_r($_POST);
echo "</pre>"

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method="POST">
<input type="hidden" name="test.one" value="1" />
<input type="hidden" name="test#two" value="2" />
<input type="submit" name="submit Me" value="Click me" />
</form>

</body>
</html>

<?
echo date('Y-m-d', strtotime('first monday jan 2007'));
echo "<br>";

echo date('Y-m-d', strtotime('first monday feb 2007')); 
echo "<br>";

echo date('Y-m-d', strtotime('first thursday feb 2007'));
echo "<br>";

echo date('Y-m-d', strtotime('first thursday jan 2007'));
echo "<br>";
?>

<?
preg_match('/(.{0,20})$/us', " ", $m);
var_export($m);
?>

<?
for ($char="A";$char<="Z";$char++)
{
echo "$char - ";
}
?>

<?
$test = "X\\X?asdasdasd\\asdasd.*";

echo $tt=preg_quote($test);
//echo preg_match("/X\\X/", $tt)."\n";
?>

pregquote

<?
$test = "X\\X?asdasdasd\\asdasd.*";

echo $tt=preg_quote($test);
//echo preg_match("/X\\X/", $tt)."\n";
?>

Monday, April 21, 2008

Smarty sites

http://www.pagepi.com/php/smarty/language.variables.php#LANGUAGE.ASSIGNED.VARIABLES
http://www.phpreg.com/index.php?option=com_wrapper&Itemid=46
http://smarty.p3l.info/language.syntax.variables.html

orcale

http://www.orafaq.com/faqphp.htm

Thursday, April 17, 2008

Connecting to a database Simple query

Connecting to a database

use DBI;
$dbh = DBI->connect('DBI:mysql:databasename', 'username', 'password'
) || die "Could not connect to database: $DBI::errstr";
# (insert query examples here...)
$dbh->disconnect();

Connecting to a different host:


$dbh = DBI->connect('DBI:mysql:databasename;host=db.example.com', 'username', 'password',
{ RaiseError => 1 }
);

Simple query

$dbh->do('CREATE TABLE exmpl_tbl (id INT, val VARCHAR(100))');
$dbh->do('INSERT INTO exmpl_tbl VALUES(1, ?)', undef, 'Hello');
$dbh->do('INSERT INTO exmpl_tbl VALUES(2, ?)', undef, 'World');
$c = $dbh->do('DELETE FROM exmpl_tbl WHERE id=1');
print "Deleted $c rows\n";

(Do not use $dbh->do() for SELECT statements because it does not return a statement handle, making it impossible to fetch data)

Typical query

$sth = $dbh->prepare('SELECT val FROM exmpl_tbl WHERE id=1');
$sth->execute();
$result = $sth->fetchrow_hashref();
print "Value returned: $result->{val}\n";

Query using placeholders

$sth = $dbh->prepare('SELECT id FROM exmpl_tbl WHERE val=?',
undef, 'World');
@result = $sth->fetchrow_array();
print "ID of World is $result[0]\n";

Execute and fetch in one command

$sth = $dbh->prepare('SELECT * FROM exmpl_tbl');
$results = $dbh->selectall_hashref('SELECT * FROM exmpl_tbl', 'id');
foreach my $id (keys %$results) {
print "Value of ID $id is $results->{$id}->{val}\n";
}

Simple Perl Script

use DBI;
$dbh = DBI->connect("DBI:mysql:db_name:localhost", "username", "password") ||
    die "DBI->connect: $DBI::errstr\n";

$sql_stmt = "insert into my_table (field_1, field_2, field_3)
             values (?, ?, ?)";
$sth = $dbh->do($sql_stmt, {}, "value_1", "value_2", "value_3") ||
    die "dbh->do($sql_stmt: value_1, value_2, value_3): $DBI::errstr\n";


$sql_stmt = "select field_1, field_2, field_3 from my_table";
$sth = $dbh->prepare($sql_stmt) ||
    die "dbh->prepare($sql_stmt): $DBI::errstr\n";

$sth->execute ||
    die "sth->execute($sql_stmt): $DBI::errstr\n";

while (($field1, $field2, $field3) = $sth->fetchrow)
{
    print "column 1 = $field_1; column 2 = $field_2; column 3 = $field_3\n";
}

perl books

http://books.perl.org/books

how to create the view in Mysql

Tto create the view in Mysql
mysql> CREATE VIEW test.v AS SELECT * FROM t;

--------------

ex:


mysql> CREATE TABLE t (qty INT, price INT);
mysql> INSERT INTO t VALUES(3, 50);
mysql> CREATE VIEW v AS SELECT qty, price, qty*price AS value FROM t;
mysql> SELECT * FROM v;
+------+-------+-------+
| qty | price | value |
+------+-------+-------+
| 3 | 50 | 150 |
+------+-------+-------+

A view definition is subject to the following restrictions:

  • The SELECT statement cannot contain a subquery in the FROM clause.

  • The SELECT statement cannot refer to system or user variables.

  • The SELECT statement cannot refer to prepared statement parameters.

  • Within a stored routine, the definition cannot refer to routine parameters or local variables.

  • Any table or view referred to in the definition must exist. However, after a view has been created, it is possible to drop a table or view that the definition refers to. In this case, use of the view results in an error. To check a view definition for problems of this kind, use the CHECK TABLE statement.

  • The definition cannot refer to a TEMPORARY table, and you cannot create a TEMPORARY view.

  • The tables named in the view definition must already exist.

  • You cannot associate a trigger with a view.

Wednesday, April 16, 2008

Free html/css/wordpress template

check it out here for all free css/html/wordpress/durpal templates.

http://www.webshapes.org


Tuesday, April 15, 2008

Adobe AIR brings the Web to the desktop





Adobe AIR brings the Web to the desktop

Tony Patton, TechRepublic

One of the points of my article about the qooxdoo (http://cgi.cnet.com.au/link/?id=21972) JavaScript library was the concept of building Web applications with a rich user interface that mimics desktop applications. This is good if you want to mimic the look and feel of a desktop application within a Web page. On the flip side is bringing the Web to the desktop -- that is, leveraging Web development skills on the desktop. The Adobe Labs has released the Adobe Integrated Runtime (AIR), which provides this functionality.

Adobe describes AIR as a cross-operating system runtime that allows developers to leverage existing Web development skills to build and deploy rich Web applications to the desktop. It provides support for Flash (http://www.adobe.com/devnet/air/flash/), Flex (http://www.adobe.com/devnet/air/flex/), HTML, JavaScript, and AJAX (http://www.adobe.com/devnet/ajax/).

Getting it

To get started with AIR development, you must install the AIR runtime on your computer. Once it is installed, you may download sample applications to see AIR in action and possibly take a peek under the covers at its code.

There are two downloads relevant to AIR development:

|> Runtime (http://labs.adobe.com/downloads/air.html) provides the runtime environment for running AIR applications. Downloads are available for both Windows and Macintosh operating systems.
|> Software Development Kit (SDK) (http://labs.adobe.com/downloads/airsdk.html) provides everything necessary to build AIR applications. This includes templates, Adobe AIR APIs, and debugger and developer tools. The SDK is available for both Windows and Macintosh platforms. The command line debugger and developer tools require a Java installation (JRE or JDK version 1.4.2 or newer).

Additional downloads are available that allow you to build AIR applications within specific Web development tools:

|> Adobe Flex Builder 3: Includes support for building Flex applications on Adobe AIR from within Flex Builder.
|> Adobe Flex SDK: Allows you to build AIR applications via Flex.
|> Adobe AIR Extension for Dreamweaver CS3 (http://labs.adobe.com/wiki/index.php/AIR:Dreamweaver_CS3_Extension): Adds support for building AIR applications within Dreamweaver CS3.
|> Adobe AIR Extension for Flash CS3 Professional: Allows you to build AIR applications with Flash CS3 Professional.

In addition, a plug-in is available for the Aptana IDE (http://www.aptana.com/air). Once the runtime is installed, you can easily install and run AIR applications, and the SDK allows you to build AIR applications.

AIR HTML application basics

This article focuses on using standard Web technologies HTML and JavaScript to build an AIR application. AIR uses WebKit (http://webkit.org/) to parse, layout, and render HTML and JavaScript content. The AIR API provides host classes and objects for providing desktop applications functionality like reading and writing files and managing windows. In addition, an HTML-based AIR application has the Flash API available to it.

An important distinction of HTML-based AIR applications is that the use of the AIR API is optional. That is, you may choose to use only standard HTML and JavaScript to build an application and run it via the AIR runtime. The runtime includes an HTML renderer and JavaScript interpreter in addition to other features.

There are at least two files in every HTML-based AIR application. The first is an application descriptor file that specifies the application metadata via XML. The second file is a top-level HTML page. Also, AIR provides a JavaScript file (AIRAliases.js) that provides aliases for AIR API classes. More robust applications will include more files like Web pages and JavaScript code.

The AIR SDK includes plenty of sample code for getting a feel for the platform. The following sample code is included in the documentation to get you going with a first, simple application (the ever present Hello World demo).

The following descriptor file provides the details of the application. It references the AIR namespace and assigns a name to the application (Hello World!). The initalWindow element defines application start-up behaviour as an HTML file (Hello.html) is loaded.

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://ns.adobe.com/air/application/1.0.M5"
appId="sample.HelloWorld" version="0.1">
<name>Hello World </name>
<initialWindow>
<content>Hello.html</content>
<visible>true</visible>
</initialWindow>
</application>

The HTML file (Hello.html) defines the user interface displayed when the application is launched via the AIR runtime. First, the JavaScript aliases file is included to make it easier to work with AIR classes. Next, the JavaScript appLoad function defines what happens when the application loads (function called by onLoad event of page).

The JavaScript function loads data from a simple text file via AJAX and places the text from the file in the HTML element with the ID called replace.

<html><head>
<title>Hello World</title>
<script src="AIRAliases.js"
mce_src="AIRAliases.js"
type="text/javascript"></script>
<script type="text/javascript">
function appLoad(){
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "request.txt",true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.getElementById('replace').innerHTML =
xmlhttp.responseText;
} }
xmlhttp.send(null)

</script>
</head>
<body onLoad="appLoad();">
<h1>AIR</h1>
<div id="replace">
<p>Placeholder</p>
</div>
</body>
</html>

Once the application is developed, the AIR command line tools can be used to package and distribute it. The AIR Developer Tool (ADT) (http://livedocs.adobe.com/labs/air/1/devappshtml/help.html?content=CommandLineTools_3.html#1028335) creates installation packages, but it requires a digital certificate.

A simple approach

The AIR platform offers a great approach to building desktop applications. I love the fact that it allows me to use existing skills like HTML and JavaScript.

The AIR API offers additional functionality for building client interfaces. The API is JavaScript, so it is easily used within your application. While the qooxdoo approach is the exact opposite, I find the AIR model much more intuitive and easy-to-use. Everything necessary to get started with AIR is freely available online.

Leverage existing skills

A key point of AIR is the ability to port Web development skills to desktop development. Also, using Web technologies like HTML and Flash deliver a familiar interface to users, and developers do not have to spend time learning a new technology such as Microsoft .NET for thick client development. Another strong point is the cross-platform support that is not readily available in other development platforms. If you are interested in desktop applications, take a look at AIR.

The Web browser has evolved into the de facto standard application interface these days, but client applications are still necessary. Have you been faced with developing applications for the desktop? Have you taken a look at AIR? Let me know by posting to the article discussion.



Moving to CSS-based layouts with the YUI Library



Moving to CSS-based layouts with the YUI Library

Tony Patton, TechRepublic

While initiating a recent project to make substantial changes to an existing Web application, it was decided to dump the table-based layout used in its original design in favour of CSS. We opted to use the Yahoo! User Interface (YUI) Library ( http://developer.yahoo.com/yui/index.html) after evaluating different approaches. The YUI Library provides core CSS resources that have been developed by a professional team of developers and extensively tested by the Web community.

This tutorial walks you through the steps of how to move from a table-based design to a CSS-based layout with the help of the YUI Library.

The layout

It is worth considering the division of screen real estate in the application to understand how it is coded using both tables and CSS. The overall page is divided into two horizontal sections: a header and a body.

The header portion can be further divided into three horizontal strips. The first strip contains a strip of colour at the top. The middle row contains text and a logo on a white background. The final row has its own background colour along with a breadcrumb.

The body portion of the page is divided into two columns. The first column is a navigation area featuring a list of navigation links. The second column is divided into two rows with a small footer row at the bottom, and the rest is devoted to page content.

The site design does not change from the original product developed with Dreamweaver and HTML tables. The introduction of CSS will deliver cleaner code with a smaller footprint and simplified maintenance.

Table-based layout

The original design used six HTML tables to divide the page and deliver the solution. It used CSS to style text on the page, but CSS usage stopped at that point. The following listing includes the HTML source. Background colours are assigned to each table (via the bgcolour attribute) to provide a visual cue of the layout.

<html>
<head><title>Table-based page layout</title></head>
<body>
<table bgcolour="yellow" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr><td colspan="3" width="100%"></td></tr>

<tr><td colspan="3">
<table bgcolour="red" border="0" width="100%" cellspacing="0">
<tr>
<td width="85%" valign="middle">Header Text</td>
<td width="15%"><img src="logo.jpg" mce_src="logo.jpg" /></td>
</tr></table></td></tr>
<tr>
<td width="16%" height="20" nowrap>Breadcrumb</td>
<td width="40%" height="20" align="right" nowrap></td>
</tr>
<tr>
<td width="10%" rowspan="2" valign="top">
<table bgcolour="green" width="101%" height="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td height="167" valign="top">
<table bgcolour="light blue" width="100%" border="0" cellspacing="0">
<tr><td colspan="3">Menu</td></tr>
<tr>
<td width="8"> </td>
<td>Nav Link</td>
<td width="4"> </td>
</tr></table></td></tr></table></td>
<td height="100%" colspan="2" valign="top">
<table bgcolour="brown" width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr><td valign="top">
<table bgcolour="silver" width="96%" height="220" border="0" cellpadding="10">
<tbody><tr>
<td valign=top align=left width="100%">
<p>Content goes here</p>
</td></tr></tbody></table></td></tr><tr>
<td height="40" valign="middle">
Footer
</td></tr>
</table></td></tr></table></body></html>

The table-based layout solution delivers the desired results, but it can be confusing to make layout changes. A quick perusal of the code demonstrates the confusing nature of using tables for layout.

It takes time to make layout changes and to convert a table-based solution to a CSS alternative, so selling such a change to a client can be daunting. In our case, the client was technically savvy and easily convinced when we showed the simplified approach offered by CSS.

YUI Grids CSS

The use of the YUI Grids CSS ( http://developer.yahoo.com/yui/grids/) feature of the YUI Library added another level of acceptance via a tested solution. YUI Grids CSS provides a CSS solution for delivering page layouts that divide the page into areas.

A great aspect of the YUI Grids CSS feature is its A-level browser support (http://developer.yahoo.com/yui/articles/gbs/index.html#history), which provides the highest support level in terms of browsers. This means you don't have to worry about the quirks in different browsers when using CSS for layout.

CSS layout

YUI Grids CSS offers preset page widths and templates, along with the ability to nest and stack layouts to generate what you need. Yahoo boasts the capability to deliver more than 1,000 layout combinations with it. YUI Grids CSS is part of the YUI Library download (http://developer.yahoo.com/yui/download/).

We used the following features of the YUI Grids CSS feature:

|> The 100% page width is employed via the doc3 id attribute assigned to the overall <DIV> container.
|> The entire page is divided into three rows using three <DIV> elements. The YUI Grids CSS standard id attributes for header (hd), body (bd), and footer (ft) are used.
|> The header has three rows using two <P> elements and a <DIV> element. The <DIV> includes another <DIV> that uses YUI Grids CSS features. This includes the 100% page width (doc3 attribute), as well as a preset template that has two columns with the narrower column on the left with a width of 180 pixels. The narrower column is assigned the class id of yui-b with the larger column assigned the yui-main attribute. The two columns are used to ensure the breadcrumb appears above the content area of the page.
|> The middle or body row of the whole page layout is divided into two columns with a left column width of 180 pixels. This is accomplished with a predefined template employed by assigning the yui-t2 class to the body's <DIV> container. The smaller left column is designated with the yui-b class assignment, and the main area is designated with the yui-main class assignment.
|> The footer row uses the same approach as the body with two columns -- a left column of 180 pixels.
|> The smaller left column of the body row of the page contains a navigation menu. The menu is created with an HTML unordered list and styled via CSS.
|> The YUI Grids CSS is contained in one CSS file available in the YUI Library download. The file is called grids.css and has a small footprint of 4KB.

Here is the source of the reworked page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Reworked with YUI Grids CSS</title>
<link rel="stylesheet" type="text/css" href="grids.css" mce_href="grids.css">
</head>
<body>
<div id="doc3">
<div id="hd">
<p class="header1"></p>
<p class="header3">
<span>Text</span>
<span class="logo"></span>
</p>
<div>
<div id="doc3" class="yui-t2">
<div class="yui-b"></div>
<div id="yui-main">
<div class="yui-b">Breadcrumb</div>
</div>
</div>
</div>
</div>
<div id="bd">
<div id="doc3" class="yui-t2">
<div class="yui-b">
<ul class="nav">
<li class="main">Menu</li>
<li class="sub">Nav Link</li>
</ul>
</div>
<div id="yui-main">
<div class="yui-b">
Content goes here
</div>
</div>
</div>
</div>
<div id="ft">
<div id="doc3" class="yui-t2">
<div class="yui-b">
</div>
<div id="yui-main">
<div class="yui-b">

Footer
</div>

</div>

</div>

</div>

</div>

</body></html>

You may cringe at the sight of so many <DIV> elements, but this is much easier to follow compared to its table counterpart. Also, the CSS approach allows you to easily modify the layout by editing the CSS or changing what YUI Grids CSS features are used.

For example, we could easily modify the layout to use a layout with a left column of 160 pixels by changing the class assigned to the <DIV> elements from yui-t2 to yui-t1. In order to use this approach, you need to be familiar with using YUI Grids CSS.

There's a caveat to working with the free CSS elements of the YUI Library: It's tricky to alter the source CSS. The code contains many so-called hacks in order to work with all browsers that you may not be fully aware of all of them when you're editing the CSS. For me, I avoid working directly with the source and work within the confines of the YUI Library.

Making the switch

CSS has matured to the point where using it for layout is now acceptable. However, this approach does have pitfalls, which include browser quirks. For this reason, I find the freely available YUI Grids CSS portion of the YUI Library to be an excellent resource for building Web interfaces that use Web standards.

Are you embracing CSS for Web page layout? Do you use any aspect of the YUI Library in your applications? Share your experiences with the Web Developer community.



Fwd: What is cross-site scripting?



---------- Forwarded message ----------
From: Builder AU Wide World of Web <members@newsletters.builderau.com.au>
Date: Wed, Apr 16, 2008 at 5:54 AM
Subject: What is cross-site scripting?
To: shanmugarajan.k@gmail.com


Wednesday April 16, 2008. Unsubscribe from this e-mail
Builder AU - By Developers for Developers

Wide World of Web

Advertisement

What is cross-site scripting?

Chad Perrin, TechRepublic

Cross-site scripting, also known as "XSS," is a class of security exploit that has gotten a fair bit of attention in the last few years. Many users, and even Web developers, aren't entirely clear on what the term means, however. I'll explain cross-site scripting for you, so you will know where the dangers lie.

Defining cross-site scripting

JavaScript is a powerful tool for developing rich Web applications. Without client-side execution of code embedded in HTML and XHTML pages, the dynamic nature of Web applications like Google Maps (http://maps.google.com/), Try Ruby! (http://tryruby.hobix.com/) and Zoho Office (http://www.zoho.com/) would not be possible. Unfortunately, any time you add complexity to a system, you increase the potential for security issues -- and adding JavaScript to a Web page is no exception.

Among the problems introduced by JavaScript are:

|> A malicious Web site might employ JavaScript to make changes to the local system, such as copying or deleting files.
|> A malicious Web site might employ JavaScript to monitor activity on the local system, such as with keystroke logging.
|> A malicious Web site might employ JavaScript to interact with other Web sites the user has open in other browser windows or tabs.

The first and second problems in the above list can be mitigated by turning the browser into a sort of "sandbox" that limits the way JavaScript is allowed to behave so that it only works within the browser's little world. The third can be limited somewhat as well, but it is all too easy to get around that limitation because whether a particular Web page can interact with another Web page in a given manner may not be something that can be controlled by the software employed by the end user. Sometimes, the ability of one Web site's JavaScript to steal data meant for another Web site can only be limited by the due diligence of the other Web site's developers.

The key to defining cross-site scripting is in the fact that vulnerabilities in a given Web site's use of dynamic Web design elements may give someone the opportunity to use JavaScript for security compromises. It's called "cross-site" because it involves interactions between two separate Web sites to achieve its goals. In many cases, however, even though the exploit involves the use of JavaScript, the Web site that's vulnerable to cross-site scripting exploits does not have to employ JavaScript itself at all. Only in the case of local cross-site scripting exploits does the vulnerability have to exist in JavaScript sent to the browser by a legitimate Web site.

Types of cross-site scripting

There are currently three major categories of cross-site scripting. Others may be discovered in the future, however, so don't think this sort of misuse of Web page vulnerability is necessarily limited to these three types.

|> Reflected: Probably the most common type of cross-site scripting exploit is the reflected exploit. It targets vulnerabilities that occur in some Web sites when data submitted by the client is immediately processed by the server to generate results that are then sent back to the browser on the client system. An exploit is successful if it can send code to the server that is included in the Web page results sent back to the browser, and when those results are sent the code is not encoded using HTML special character encoding -- thus being interpreted by the browser rather than being displayed as inert visible text.

The most common way to make use of this exploit probably involves a link using a malformed URL, such that a variable passed in a URL to be displayed on the page contains malicious code. Something as simple as another URL used by the server-side code to produce links on the page, or even a user's name to be included in the text page so that the user can be greeted by name, can become a vulnerability employed in a reflected cross-site scripting exploit.
|> Stored: Also known as HTML injection attacks, stored cross-site scripting exploits are those where some data sent to the server is stored (typically in a database) to be used in the creation of pages that will be served to other users later. This form of cross-site scripting exploit can affect any visitor to your Web site, if your site is subject to a stored cross-site scripting vulnerability. The classic example of this sort of vulnerability is content management software such as forums and bulletin boards where users are allowed to use raw HTML and XHTML to format their posts.

As with preventing reflected exploits, the key to securing your site against stored exploits is ensuring that all submitted data is translated to display entities before display so that it will not be interpreted by the browser as code.
|> Local: A local cross-site scripting exploit targets vulnerabilities within the code of a Web page itself. These vulnerabilities are the result of incautious use of the Document Object Model in JavaScript so that opening another Web page with malicious JavaScript code in it at the same time might actually alter the code in the first page on the local system. In older versions of Internet Explorer (before IE 6 on MS Windows XP Service Pack 2), in fact, this could even be used on local Web pages (stored on the local computer rather than retrieved from the World Wide Web), and through those pages break out of the browser "sandbox" to affect the local system with the user privileges used to run the browser. Because most MS Windows users have tended to run everything as the Administrator account, this effectively meant that local cross-site scripting exploits on MS Windows before XP Service Pack 2 could do just about anything.

In a local cross-site scripting exploit, unlike reflected and stored exploits, no malicious code is sent to the server at all. The behaviour of the exploit takes place entirely on the local client system, but it alters the pages provided by the otherwise benign Web site before they are interpreted by the browser so that they behave as though they carried the malicious payload to the client from the server. This means that server-side protections that filter out or block malicious cross-site scripting will not work with this sort of exploit. For more about local cross-site scripting, see the explanation at DOM Based Cross Site Scripting (http://www.webappsec.org/projects/articles/071105.shtml).

Protection Against Cross-Site Scripting

The most comprehensive way to protect your Web design from being exploited by cross-site scripting is to translate any and all special characters in user-provided input -- even in URLs -- into display entities, such as HTML entities (http://www.w3schools.com/tags/ref_entities.asp). This applies not only to server-side code like PHP, Perl, and ASP.NET code, but also JavaScript that works with any user-provided input as well. This may interfere with the operation of Web sites where users expect to be able to use HTML and XHTML in their input, such as for Web site design helper applications -- in which case more complex code may be needed to protect against malicious code. Such fine-grained filtering is just one side of an arms race against malicious security crackers, however, and cannot reasonably be 100% effective.

Another way to protect your Web site from cross-site scripting exploits is to never directly use any user-provided input in your pages. Accepting a limited number of values in user-provided input that are each used as "keys," for lack of a better term, to choose from among certain predefined options is an example of how user-provided input can be used to define output, but obviously greatly limits the dynamic nature of Web applications. If your Web site does not need greater dynamism than this provides, however, this may be your safest option for generating output based on user input.

Similarly, input validation that simply strips out all characters unauthorised for specific, limited input types (such as removing everything but dashes, parentheses, periods, and digits from input expected to contain telephone numbers), or that rejects input containing unauthorised characters entirely, can be used. This is a useful technique for many forms of input, but not all. Such validation techniques should be used whenever possible, because they not only provide some protection against cross-site scripting, but also against direct attempts to compromise the server itself through buffer overflows, SQL injection, and other attempts to exceed the bounds of the system.

Cookies are often used to provide some form of security against cross-site scripting. Many cross-site scripting exploits are designed to "steal" session cookies, but a cookie can be "tied" to a particular IP address so that hijacked cookies fail validation when employed by cross-site scripting exploits. There are potential work-arounds for this sort of security, such as when the legitimate user of a given cookie and a cross-site scripting exploit both originate from behind the same proxy server or Network Address Translation (NAT) device, of course. Internet Explorer implements an HTTPOnly flag that prevents local scripts from affecting a cookie to try to guard against this sort of cookie abuse, but it is ineffective against cross-site request forgery attacks, where unintended requests may be sent via cross-site scripting exploits alongside a cookie used to authorise the requests at the server.

The single most effective means of avoiding cross-site scripting in Web development, however, is to design your Web site so that it does not require client-side code at all. That way, if your users want to turn off the JavaScript interpreters in their browsers, they can do so without losing the ability to make use of your Web site. This does not protect against all forms of potential malicious input to your server, of course, and it does not actually limit the vulnerability of your Web site all by itself -- but it does give visitors to your Web site the option of protecting themselves.

Advertisement

Street Kings Competition
To celebrate the release of the new, action-packed movie Street Kings, 20th Century Fox and GameSpot AU is offering the opportunity to win the ultimate action prize pack!
Click here to enter now!


Also on Builder AU

Send XML documents online with SAAJ
SOAP with Attachments API for Java (SAAJ) provides a standard way to send XML documents over the Internet from the Java platform. SAAJ enables you to produce and consume messages conforming to the SOAP 1.1 and 1.2 specifications and SOAP with Attachments note.
Read Full Story

Microsoft blamed for Google Docs flaw threat
Google has fixed a flaw in Google Docs that allowed an attacker to hijack sessions on any Google service -- but security experts say that the real damage is being caused by Internet Explorer, not Google's technology.
Read Full Story

Yahoo-Microsoft to hitch this week say analysts
As Yahoo gears up to report its first quarter performance next week, one analyst predicts the Internet search pioneer may clock in at the lower end of its revenue range, while other analysts predict a buyout deal with Microsoft may be in the mix this week.
Read Full Story

Advertisement

TV.com Aussie Personality Competition
TV.com is giving you the chance to win the ultimate TV setup with a 32 inch LCD TV, home theatre system and AU$500 for a TV party with your best mates!
Click here to enter now!


Sign up for more free newsletters from Builder AU
To change your e-mail address, personal details or newsletter selections, visit the Builder AU Membership Centre.
Send your comments and questions about this newsletter to editor@builderau.com.au.
Unsubscribe from this e-mail | FAQ

Security & Privacy Policy | Advertise | Contact | About Builder AU
Copyright © 2008 CNET Networks, Inc. All rights reserved. Builder AU is a registered service mark of CNET Networks, Inc. Builder AU Logo is service mark of CNET Networks, Inc.




--
Thankyou
with regards
Shanmugarajan.k
http://shanmugarajan.blogspot.com/
http://letus-know.blogspot.com/

use curl function instead of file_get_contents

hi
use curl function instead of file_get_contents
because if you use file_get_contents u may get "http request failed" error;

PHP Warning: file_get_contents(http://static.heywatch.com/thumbs/E9aGH0nw8D/Butterfly.flv.jpg) [function.file-get-contents]: failed to open stream: HTTP request failed! in /usr/local/dzoic/heywatch/ping_after_encode.php on line 36

so avoid that we can use,

//get video content using CURL library
$ch = curl_init($real_url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$video_content = curl_exec($ch);
curl_close($ch);


please note: curl should be enabled/configured in your system


How to change PHP parameters when you don't have access to php.ini

How to change PHP parameters when you don't have access to php.ini

Unless you have your own "root" server, you are most probably sharing the same hardware with a few thousand other so-called "virtual" domains. For this reason, it is all too natural that your ISP will deny you access to the system-wide php.ini file (usually located under /etc). Whatever value you enter there, is going to affect all the virtual domains running on that machine!

But what to do if you find out that you must change a setting and you are told to change it in php.ini? Fortunately, there is an alternative way - and once again the .htaccess file (see Section 25.4) comes to your rescue:

To set register_globals to off (a good idea from a security point of view, see Section 23.4.2), for example, add

php_flag register_globals off

to the .htaccess file in the PHP-Nuke root directory.

To set magic_quotes to off (a bad idea from a security point of view, see Section 23.4.2), you can add the following line to the .htaccess file in the PHP-Nuke root directory:

php_flag magic_quotes_gpc off

To set "display_errors" to off, add:

php_flag display_errors off

while to set the include path (see Section 3.9.10), you can add

php_value include_path "your/include/path/here"

If you get a memory limit error like:

Fatal error: Allowed memory size of 8388608 bytes exhausted 
(tried to allocate 67584 bytes) in xxx/xxxxxxx/xxxxx

then you can try to increase allocated memory with

php_value memory_limit "16M"

although you will probably not achieve the desired result, due to restrictions that your ISP has set in place.

To change the maximum execution time limit of your PHP scripts, add:

php_value max_execution_time 60

This will set the time limit to 60 seconds. But if you are not allowed to change php.ini, it is doudtful that you will be allowed to change the value of max_execution_time in a .htaccess file. If you can do it, however, then the .htaccess method gives you the flexibility to set different time limits in different directories - and thus different scripts that reside therein. See also Page genration time too long.

As you have guessed by now wink, the general syntax is:

php_value PHP-variable value

How do I change the PHP Max Upload file size? (.htaccess)

How do I change the PHP Max Upload file size? (.htaccess)


In the root folder of site! there is a file called htaccess.txt rename this to .htaccess. If you have already renamed the file then continue....

The PHP value you need to add is

Code: Select all
    php_value upload_max_filesize



So to allow a max upload of 8 Megabytes you would add to the .htaccess

Code: Select all
    php_value upload_max_filesize 8M

    php_value post_max_size 8M

Friday, April 11, 2008

jquery lightbox script

Hi
check it out the jquery light box plugin

http://leandrovieira.com/projects/jquery/lightbox/

--
Thankyou
with regards
Shanmugarajan.k

Create a thumbnail in php

to create the thumbnail in php
just check it out
http://www.gen-x-design.com/projects/php-thumbnailer-class/


simple xml


The XML file we'll use looks something like this:



   <?xml version="1.0" encoding="utf-8" ?>

   <movies>

      <movie>
         <title>Star Wars</title>

         <year>1977</year>

      </movie>

      <movie>

         <name>Apocalypse Now</name>

         <year>1979</year>

      </movie>

      <movie>

         <title>Raiders Of The Lost Ark</title>

         <year>1981</year>

      </movie>

   </movies>

if (!$myxml=simplexml_load_file('mymovies.xml')){

echo 'Error reading the XML file';

}

foreach($myxml as $movie){

echo 'Title: ' . $movie->title . '<br />';

echo 'Year: ' . $movie->year . '<br /><hr />';

}

?>

Wednesday, April 9, 2008

Shell script dir

<?php
$dir = shell_exec("dir");
$subject = "Half-hourly file report.";
$body = "The following files are in the current directory : \n\n";
$body .= $dir;

echo $body;
?>

batch file with php

How to run window batch file in php?
Step 1
Creata bacth file like that

mkdir %1

save the file name as test.bat


step-2

php program
<?
shell_exec("test.bat india");
?>

Run the php automaticaly create one floder



Manual installation in linux/unbntu DEB,RPM FILES

if you want to know how to install the deb,rpm files in linux/unbntu, here is the answer...
Manual installation in linux/unbntu DEB,RPM FILES

Manual installation  FOR DEB FILES:
cd Desktop
sudo dpkg -i opera_9.10-20061214.6-shared-qt_en_i386.deb

Manual installation  FOR RPM FILES:
cd Desktop
sudo alien -i opera_9.10-20061214.6-shared-qt_en_i386.rpm

Manual installation  FOR TAR FILES
tar -xvzf obscure-1.0.tar.gz
cd obscure-1.0
./configure
make
sudo make install

ping server

<?php
   $server = "www.java2s.com";

   $count = 3;

   echo "<pre>";
      system("/bin/ping -c $count $server");
   echo "</pre>";

   system("killall -q ping");
?>

Alexa Ranks Very simple script

http://davidwalsh.name/php-alexa-rank-fetcher-xml

php get the alexa ranking script

To get the alexa ranking

   1.
      <?php
   2.
       
   3.
      /**
   4.
      * Get Stats from Alexa.com
   5.
      * @author  Seo Sonar
   6.
      * @copyright www.seosonar.com Free for non-commercial use
   7.
      * @link http://www.seosonar.com/blog/category/alexa
   8.
      */
   9.
      class api_alexa
  10.
      {
  11.
      var $popularity;
  12.
      var $reach;
  13.
      var $inlinks;
  14.
      
  15.
      /**
  16.
      * Get the alexa details for a domain
  17.
      *
  18.
      * @param string $domain
  19.
      * @return bool
  20.
      */
  21.
      public function getDetails($domain)
  22.
      {
  23.
      if(!$html = file_get_contents(
  24.
      "http://alexa.com/xml/dad?url=$domain"))
  25.
      return false;
  26.
      
  27.
      // alexa rank
  28.
      if (preg_match('/POPULARITY URL="[a-z0-9\\-\\.\\/]{1,}" '.
  29.
      'TEXT="([0-9]{1,12})"/', $html, $regs))
  30.
      $this-&gt;popularity = (int) $regs[1];
  31.
      
  32.
      // alexa reach
  33.
      if (preg_match('/REACH RANK="([0-9]{1,12})"/',
  34.
      $html, $regs))
  35.
      $this-&gt;reach = (int) $regs[1];
  36.
      
  37.
      // alexa inlinks
  38.
      if (preg_match('/LINKSIN NUM="([0-9]{1,12})"/',
  39.
      $html, $regs))
  40.
      $this-&gt;inlinks = (int) $regs[1];
  41.
      
  42.
      return true;
  43.
      }
  44.
      }
  45.
     ?>


 

Friday, April 4, 2008

Linux grep

The way we search for a string with grep is to put the words we are searching for together in single quotes.

  • The syntax: % grep pattern file-name-1 file-name-2 …file-name-n
  • An example: % grep 'mountain bike' sports hobbies

As a result of entering this command the operating system will print all the lines in the file "sports" and the file "hobbies" that contain the string "mountain bike". By default the line will be printed on the computer screen (in the shell window, where the command was issued).

Save Search Results

To save your search to a file, you need to redirect the information in the following way:

  • The syntax: %grep pattern file-name1 file-name2 > results-file
  • An example: % grep 'mountain bike' sports hobbies > results

Here, we saved the results to a file, which we named "results". We can then open this file and look at it either using emacs, vi, or similar programs.

Some Options

The following is a list of some of the most useful grep options:

  • -h if you search more than one file at a time, the results contain the name of the file from which the string was found. This option turns off that feature, giving you only the lines without the file name.
  • -w restricts the search to whole words only
  • -b precedes each matched line with its file block number.
  • -c displays only a count of the number of matched lines and not the lines themselves.
  • -E causes grep to behave like egrep.
  • -e pattern specifies one or more patterns for which grep is to search. You may indicate each pattern with a separate -e option character, or with newlines within pattern. For example, the following two commands are equivalent:
    grep -e pattern_one -e pattern_two file
    grep -e 'pattern_one pattern_two' file
  • -F causes grep to behave like fgrep.
  • -f patternfile reads one or more patterns from patternfile. Patterns in patternfile are separated by newlines.
  • -i - tells grep to ignore case so that it treats "the" and "The" as the same word
  • -l lists only the file names that contain the matching lines.
  • -n - precedes each line with the line number where it was found
  • -q suppresses output and simply returns appropriate return code.
  • -s suppresses the display of any error messages for nonexistent or unreadable files.
  • -U[b|B|l|L] forces the specified files to be treated as Unicode files. By default, these utilities assume that Unicode characters are little-endian. If a byte-order marker is present, that is used to determine the byte order for the characters. You can force Unicode characters to be treated as big-endian by specifying -Ub or -UB. Similarly, you can force them to be treated as little-endian by specifying -Ul or -UL.
  • -v displays all lines not matching a pattern.
  • -x requires a string to match an entire line.

The option (always preceded by a "-") goes between the grep command and the search pattern.

  • The syntax:
    % grep -option pattern file-name1 file-name2 > results-file
  • Example of using a single option:
    % grep -h 'mountain bike' sports hobbies > results
  • Example of using multiple options:
    % grep -hi 'mountain bike' sports hobbies > results

Remember: There can be any number of options, but you should use only one "-".

Two Variations of grep are "fgrep" and "egrep"

fgrep searches files for one or more pattern arguments, but does not use regular expressions. It does direct string comparison to find matching lines of text in the input.

egrep works similarly, but uses extended regular expression matching. If you include special characters in patterns typed on the command line, escape them by enclosing them in apostrophes to prevent inadvertent misinterpretation by the shell or command interpreter. To match a character that is special to egrep, a backslash (\) should be put in front of the character. It is usually easier to use fgrep if you don't need special pattern matching.

Important: Use the man command (% man) to see how a command is used on your particular computer.