Archive for 2012

category/tmp/blog_item

defined('_JEXEC') or die('Restricted access'); ?>
user->authorize('com_content', 'edit', 'content', 'all') || $this->user->authorize('com_content', 'edit', 'content', 'own')); ?>
item->state == 0) : ?>




item->params->get('show_title') || $this->item->params->get('show_pdf_icon') || $this->item->params->get('show_print_icon') || $this->item->params->get('show_email_icon') || $canEdit) : ?>


item->params->get('show_title')) : ?>



item->params->get('show_pdf_icon')) : ?>



item->params->get( 'show_print_icon' )) : ?>



item->params->get('show_email_icon')) : ?>







item->params->get('link_titles') && $this->item->readmore_link != '') : ?>

escape($this->item->title); ?>


escape($this->item->title); ?>


item, $this->item->params, $this->access); ?>

item, $this->item->params, $this->access); ?>

item, $this->item->params, $this->access); ?>

item, $this->item->params, $this->access); ?>


item->params->get('show_intro')) :
echo $this->item->event->afterDisplayTitle;
endif; ?>
item->event->beforeDisplayContent; ?>

item->params->get('show_section') && $this->item->sectionid) || ($this->item->params->get('show_category') && $this->item->catid)) : ?>





item->params->get('show_author')) && ($this->item->author != "")) : ?>





item->params->get('show_create_date')) : ?>





item->params->get('show_url') && $this->item->urls) : ?>









item->modified) != 0 && $this->item->params->get('show_modify_date')) : ?>





item->params->get('show_readmore') && $this->item->readmore) : ?>






item->params->get('show_section') && $this->item->sectionid && isset($this->item->section)) : ?>

item->params->get('link_section')) : ?>
item->sectionid)).'">'; ?>

item->section; ?>
item->params->get('link_section')) : ?>
'; ?>

item->params->get('show_category')) : ?>




item->params->get('show_category') && $this->item->catid) : ?>

item->params->get('link_category')) : ?>
item->catslug, $this->item->sectionid)).'">'; ?>

item->category; ?>
item->params->get('link_category')) : ?>
'; ?>





item->created_by_alias ? $this->item->created_by_alias : $this->item->author) ); ?>

  

item->created, JText::_('DATE_FORMAT_LC2')); ?>


item->urls; ?>


item->toc)) : ?>
item->toc; ?>

item->text; ?>

item->modified, JText::_('DATE_FORMAT_LC2'))); ?>


item->readmore_register) :
echo JText::_('Register to read more...');
elseif ($readmore = $this->item->params->get('readmore')) :
echo $readmore;
else :
echo JText::sprintf('Read more...');
endif; ?>


item->state == 0) : ?>


 
item->event->afterDisplayContent; ?>

Php Magic constants

PHP provides a large number of predefined constants to any script which it runs. Many of these constants, however, are created by various extensions, and will only be present when those extensions are available, either via dynamic loading or because they have been compiled in.

There are five magical constants that change depending on where they are used. For example, the value of __LINE__ depends on the line that it's used on in your script. These special constants are case-insensitive and are as follows:

A few "magical" PHP constants

Name

Description

__LINE__

The current line number of the file.

__FILE__

The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path whereas in older versions it contained relative path under some circumstances.

__FUNCTION__

The function name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the function name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.

__CLASS__

The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.

__METHOD__

The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).

special data types in php

                                     resource data types and null data types




resource data types refers the external resources  like data connection , file pointer , FTP connection ...ect


<?php

mysql_connect("hostname",username","password");

?>

<?php

$con=mysql_connect("hostname",username","password");
echo $con;

?>

here con is external resource type

output :    resource #id2
                                                                  null data type



null is not a value

the variable not initialized with any  value
the variable initialized with null value
if the value of the variable is removed using unset function

based on by that 3 conditions we consider a variable has null value


<?php

$a=100;
unset($a);
echo is_null($a);

?>

output :  1

if is it null returns 1 else returns nothing




Image uploading in PHP

Simple image uploading script in PHP.
First; create a file, and copy-paste above code into this file.  After your form is fine, create a new file that named upload.php this file contains our main uploading action. When you are done, create a folder where we store images. That is all, now you can upload images.


<!-- Form Area -->
<form enctype= "multipart/form-data" action= "upload.php" method= "post" >
Select Image: <input type= "file" name= "userfile" >
<input type= "submit" value= "Upload!" >
</form>
<!-- Form Area -->


<?php

# Variables
$path = "images/"
$max_size = "200000" ;

# File
$filename = $_POST [ 'userfile' ] ;

# Control
if ( !isset ( $HTTP_POST_FILES [ 'userfile' ] ) ) exit;

if ( is_uploaded_file ( $HTTP_POST_FILES [ 'userfile' ] [ 'tmp_name' ] ) ) {

if ( $HTTP_POST_FILES [ 'userfile' ] [ 'size' ] >$max_size ) {
echo "The File is Too Big. The Max File Size is $max_size KB<br>n"
exit; 
}

# Type Control
if (
( $HTTP_POST_FILES [ 'userfile' ] [ 'type' ] == "image/gif" )    ||         
( $HTTP_POST_FILES [ 'userfile' ] [ 'type' ] == "image/jpg" )    ||   
( $HTTP_POST_FILES [ 'userfile' ] [ 'type' ] == "image/bmp" )    ||
( $HTTP_POST_FILES [ 'userfile' ] [ 'type' ] == "image/png" )    ||
( $HTTP_POST_FILES [ 'userfile' ] [ 'type' ] == "image/jpeg" )
)
{

# If File Exist
if ( file_exists ( $path . $HTTP_POST_FILES [ 'userfile' ] [ 'name' ] ) )
{
echo "A File With That Name Already Exists!<br>"
exit; 
}

$res = copy ( $HTTP_POST_FILES [ 'userfile' ] [ 'tmp_name' ] , $path .

$HTTP_POST_FILES [ 'userfile' ] [ 'name' ] ) ;
if ( !$res ) {
echo "Upload Failed!<br>"
exit; 
}
else {
echo "Upload Sucessful!<br>"
}

echo "File Name: " .$HTTP_POST_FILES [ 'userfile' ] [ 'name' ] . "<br>" ;
echo "File Size: " .$HTTP_POST_FILES [ 'userfile' ] [ 'size' ] . " bytes<br>" ;
echo "File Type: " .$HTTP_POST_FILES [ 'userfile' ] [ 'type' ] . "<br>" ;
echo "<a href=$path" .$HTTP_POST_FILES [ 'userfile' ] [ 'name' ] . ">View Image</a>" ;
}
else
{
echo "Wrong File Type<br>"
exit; 
}
}

?>

Qué es PHP?

PHP (acrónimo de "PHP: Hypertext Preprocessor") es un lenguaje de "código abierto" interpretado, de alto nivel, embebido en páginas HTML y ejecutado en el servidor.

Una respuesta corta y concisa, pero, ¿qué significa realmente? Un ejemplo nos aclarará las cosas:

 

<html>

<head>

<title>Ejemplo</title>

</head>

<body>

<?php

echo "Hola, soy un script PHP!";

?>

</body>

</html>

Puede apreciarse que no es lo mismo que un script escrito en otro lenguaje de programación como Perl o C -- En vez de escribir un programa con muchos comandos para crear una salida en HTML, escribimos el código HTML con cierto código PHP embebido (incluido) en el mismo, que producirá cierta salida (en nuestro ejemplo, producirá un texto). El código PHP se incluye entre etiquetas especiales de comienzo y final que nos permitirán entrar y salir del modo PHP.

Lo que distingue a PHP de la tecnología Javascript, la cual se ejecuta en la máquina cliente, es que el código PHP es ejecutado en el servidor. Si tuviésemos un script similar al de nuestro ejemplo en nuestro servidor, el cliente solamente recibiría el resultado de su ejecución en el servidor, sin ninguna posibilidad de determinar qué código ha producido el resultado recibido. El servidor web puede ser incluso configurado para que procese todos los archivos HTML con PHP.

Lo mejor de usar PHP es que es extremadamente simple para el principiante, pero a su vez, ofrece muchas características avanzadas para los programadores profesionales.

PHP Environment


In order to develop and run PHP Web pages three vital components need to be installed on your computer system.
  • Web Server - PHP will work with virtually all Web Server software, including Microsoft's Internet Information Server (IIS) but then most often used is freely available Apache Server. Download Apache for free here: http://httpd.apache.org/download.cgi
  • Database - PHP will work with virtually all database software, including Oracle and Sybase but most commonly used is freely available MySQL database. Download MySQL for free here: http://www.mysql.com/downloads/index.html
  • PHP Parser - In order to process PHP script instructions a parser must be installed to generate HTML output that can be sent to the Web Browser. This tutorial will guide you how to install PHP parser on your computer.
PHP Parser Installation:
Before you proceed it is important to make sure that you have proper environment setup on your machine to develop your web programs using PHP.
Type the following address into your browser's address box.
If this displays a page showing your PHP installation related information then it means you have PHP and Webserver installed properly. Otherwise you have to follow given procedure to install PHP on your computer.
This section will guide you to install and configure PHP over the following four platforms:
Apache Configuration:
If you are using Apache as a Web Server then this section will guide you to edit Apache Configuration Files.
PHP.INI File Configuration:
The PHP configuration file, php.ini, is the final and most immediate way to affect PHP's functionality.
Just Check it here: PHP.INI File Configuration
Windows IIS Configuration:
To configure IIS on your Windows machine you can refer your IIS Reference Manual shipped along with IIS.

How to get XML/HTML result set with mysql

you can get directly HTML,XML format of your resultset by just executing the query by following syntax.

uttam@uttam:~$ mysql -u[userName] -p -H -e "[query]" [database]

where -H is to get HTML resultset.you can replace this with -X to get XML output.
-e is to execute the query specified.

go to the shell promt. and thry this example.
mysql -uroot -p -H -e "select * from user" mysql




running perl script in apache

Perl script can be run as executable files in apache.All you have to do is to follow some basic steps given below.

open your apache.conf file in write mode and add the following line.by default it's under /etc/apache2/ directory.

AddHandler cgi-script .cgi .pl

save the file.

Next, search for the line that says " in the file. It should look something like this:[In this case /var/www/ is the document root.]


Options FollowSymLinks
AllowOverride None


Add "+ExecCGI" to the options list. The line now looks like this:
Options FollowSymLinks +ExecCGI

generally you can find this in sites-enabled/000-default file.

Restart your apache web server.

test by typing URL of your perl script in web browser.

ListContains

The ListContains function is a quick and easy function to use. The ListContains function determines the index of the first list element that contains the specified substring. If the substring can not be found in the list, The ListContains function will returns zero. This function will not ignore empty sets; thus the list "a,b,c,,,d" has 8 elements
 
The Function:
<php
function ListContains($list,$substring,$delimiter=",")
{
    $delimiter = substr($delimiter,1);
    $a = explode($list,$delimiter);
    $return = 0;
    for($i=0;$i< count($a);$i++)
    {
        if(strstr($a[$i],$substring))
        {
            $return = $i + 1;
        }
    }
    return $return;
}

?>
Usage:
Using the ListContains function is simple:
 
<?php
    $list = "one,two,three";
    $substr = "two"
    if(ListContains($list,$substr) > 0)
    {
        echo $substr . " found at position " . ListContains($list,$substr):
    }
?>

The output of this function will be: two found at position 2

read a file in php

<?php

if(isset($_POST['filename']))
{
  if(!empty($_POST['filename']))
  {
    $file=$_POST['filename'].'.txt';
    if(file_exists($file))
    {
         $filename = fopen("$file", "r") ;
         while(!feof($filename))
               {
                 echo fgets($filename)."<br>";
               }
         fclose($filename);
    }
    else
    echo 'file not exits';
  }
 else
echo 'empty';

}
?>

<form action="file-read.php" method="POST">
<input type="text" name="filename">
.txt
<input type="submit" value="submit">
</form>

output :
1)enter the file name for read that file
2)that file must be text file

ex :        test.txt

ListDeleteAt

The ListDeleteAt function is a neat little coldfusion function and works just as well in PHP. This function is good for removing counted values from lists. I use it a lot in conjunction with other list functions.
The Function:

<php
function ListDeleteAt($list,$position,$delimiter)
{
$delimiter = substr($delimiter, 1);
$a = explode($delimiter,$list);
for($i=0;$i<count($a);$i++)

{
if($i != $position)
{
if(! isset($return))
{
$return = $a[$i];
}
else
{
$return .= $delimiter . $a[$i];
}
}
}
return $return;
}
?>

Usage:

To use the ListDeleteAt function with the default delimiter ',':

<php
$list = "a,b,c,d,e,f,g";

$position = 3;
echo ListDeleteAt($list,$position);
?>
The Result: a,b,d,e,f,g. The 'c' which was in the third position has noe been removed!

To use the ListDeleteAt function with a custom delimiter:

<php
$list = "12345";

$position = 2;
echo ListDeleteAt($list,$position);
?>

The Result: '1345'. The '2' which was in the second position has noe been removed!

xml to array

Here is the function which convert xml data to respective array.

function xmlToArray($xml,$ns=null){
$a = array();
for($xml->rewind(); $xml->valid(); $xml->next()) {
$key = $xml->key();
if(!isset($a[$key])) { $a[$key] = array(); $i=0; }
else $i = count($a[$key]);
$simple = true;
foreach($xml->current()->attributes() as $k=>$v) {
$a[$key][$i][$k]=(string)$v;
$simple = false;
}
if($ns) foreach($ns as $nid=>$name) {
foreach($xml->current()->attributes($name) as $k=>$v) {
$a[$key][$i][$nid.':'.$k]=(string)$v;
$simple = false;
}
}
if($xml->hasChildren()) {
if($simple) $a[$key][$i] = xmlToArray($xml->current(), $ns);
else $a[$key][$i]['content'] = xmlToArray($xml->current(), $ns);
} else {
if($simple) $a[$key][$i] = strval($xml->current());
else $a[$key][$i]['content'] = strval($xml->current());
}
$i++;
}
return $a;
}
This function can be used as follows.
$xml = new SimpleXmlIterator('./a.xml', null, true);
$namespaces = $xml->getNamespaces(true);
$arr = xmlToArray($xml,$namespaces);

Testing web Application


Nowadays lot's of effort is gone for testing and quality assurance of the web application which can be minimized by using web based testing tools available on the web.

There are lot's of Ad-ons available for mozila firfox for different kind of the testing which Includes such as iMacros for Firefox, WASP, Fireshot, Window Resizer, Selenium IDE, Web Developer, SwitchProxy, IE Tab, Molybdenum, HackBar, and many more.

Selenium IDE
is an integrated development environment for Selenium tests.allows you to record, edit, and debug tests.You can choose to use its recording capability, or you may edit your scripts by hand.

Web Developer The Web Developer extension adds a menu and a toolbar to the browser with various web developer tools. It is designed for Firefox, Flock and Seamonkey, and will run on any platform that these browsers support including Windows, Mac OS X and Linux.

Hackbar allow you to test your web pages against sql injections, XSS holes and site security.It is not used for executing standard exploits.

These are few ad-ons which I use and It help me as a developer/tester to test website more rapidly.

Introduction.

Are you really pissed off trying again and again to install
these basic web development environments on Windows
Vista and still not getting desired results? Don’t worry you
are at the right place now. I will guide you step by
step to install these free wares effectively. This process
is ridiculously painful and it took me several days to find
out a reliable solution. So, I decided to post this blog
to help installing these packages easily.

Please follow all the chapters in this website carefully
and you will be able to install all three packages without
any trouble.


Also visit:

-> www.neuronsoftsols.com


-> http://online-income-sources.blogspot.com/








GuDLuck!



I have always wanted to make money online, but didn't know where to begin. Prosperly.com supplied me with great internet marketing tips and helped me start making money.

PHP Variable Types




The main way to store information in the middle of a PHP program is by using a variable.
Here are the most important things to know about variables in PHP.
·         All variables in PHP are denoted with a leading dollar sign ($).
·         The value of a variable is the value of its most recent assignment.
·         Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
·         Variables can, but do not need, to be declared before assignment.
·         Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters.
·         Variables used before they are assigned have default values.
·         PHP does a good job of automatically converting types from one to another when necessary.
·         PHP variables are Perl-like.
PHP has a total of eight data types which we use to construct our variables:
·         Integers: are whole numbers, without a decimal point, like 4195.
·         Doubles: are floating-point numbers, like 3.14159 or 49.1.
·         Booleans: have only two possible values either true or false.
·         NULL: is a special type that only has one value: NULL.
·         Strings: are sequences of characters, like 'PHP supports string operations.'
·         Arrays: are named and indexed collections of other values.
·         Objects: are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.
·         Resources: are special variables that hold references to resources external to PHP (such as database connections).
The first five are simple types, and the next two (arrays and objects) are compound - the compound types can package up other arbitrary values of arbitrary type, whereas the simple types cannot.
We will explain only simile data type in this chapters. Array and Objects will be explained separately.

Integers:

They are whole numbers, without a decimal point, like 4195. They are the simplest type .they correspond to simple whole numbers, both positive and negative. Integers can be assigned to variables, or they can be used in expressions, like so:
$int_var = 12345;
$another_int = -12345 + 12345;
Integer can be in decimal (base 10), octal (base 8), and hexadecimal (base 16) format. Decimal format is the default, octal integers are specified with a leading 0, and hexadecimals have a leading 0x.
For most common platforms, the largest integer is (2**31 . 1) (or 2,147,483,647), and the smallest (most negative) integer is . (2**31 . 1) (or .2,147,483,647).

Doubles:

They like 3.14159 or 49.1. By default, doubles print with the minimum number of decimal places needed. For example, the code:
$many = 2.2888800;
$many_2 = 2.2111200;
$few = $many + $many_2;
print(.$many + $many_2 = $few<br>.);
It produces the following browser output:
2.28888 + 2.21112 = 4.5

Boolean:

They have only two possible values either true or false. PHP provides a couple of constants especially for use as Booleans: TRUE and FALSE, which can be used like so:
if (TRUE)
   print("This will always print<br>");
else
   print("This will never print<br>");

Interpreting other types as Booleans:

Here are the rules for determine the "truth" of any value not already of the Boolean type:
·         If the value is a number, it is false if exactly equal to zero and true otherwise.
·         If the value is a string, it is false if the string is empty (has zero characters) or is the string "0", and is true otherwise.
·         Values of type NULL are always false.
·         If the value is an array, it is false if it contains no other values, and it is true otherwise. For an object, containing a value means having a member variable that has been assigned a value.
·         Valid resources are true (although some functions that return resources when they are successful will return FALSE when unsuccessful).
·         Don't use double as Booleans.
Each of the following variables has the truth value embedded in its name when it is used in a Boolean context.
$true_num = 3 + 0.14159;
$true_str = "Tried and true"
$true_array[49] = "An array element";
$false_array = array();
$false_null = NULL;
$false_num = 999 - 999;
$false_str = "";

NULL:

NULL is a special type that only has one value: NULL. To give a variable the NULL value, simply assign it like this:
$my_var = NULL;
The special constant NULL is capitalized by convention, but actually it is case insensitive; you could just as well have typed:
$my_var = null;
A variable that has been assigned NULL has the following properties:
·         It evaluates to FALSE in a Boolean context.
·         It returns FALSE when tested with IsSet() function.

Strings:

They are sequences of characters, like "PHP supports string operations". Following are valid examples of string
$string_1 = "This is a string in double quotes";
$string_2 = "This is a somewhat longer, singly quoted string";
$string_39 = "This string has thirty-nine characters";
$string_0 = ""; // a string with zero characters
Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences.
<?
$variable = "name";
$literally = 'My $variable will not print!\\n';
print($literally);
$literally = "My $variable will print!\\n";
print($literally);
?>
This will produce following result:
My $variable will not print!\n
My name will print
There are no artificial limits on string length - within the bounds of available memory, you ought to be able to make arbitrarily long strings.
Strings that are delimited by double quotes (as in "this") are preprocessed in both the following two ways by PHP:
·         Certain character sequences beginning with backslash (\) are replaced with special characters
·         Variable names (starting with $) are replaced with string representations of their values.
The escape-sequence replacements are:
·         \n is replaced by the newline character
·         \r is replaced by the carriage-return character
·         \t is replaced by the tab character
·         \$ is replaced by the dollar sign itself ($)
·         \" is replaced by a single double-quote (")
·         \\ is replaced by a single backslash (\)

Here Document:

You can assign multiple lines to a single string variable using here document:
<?php
 
$channel =<<<_XML_
<channel>
<title>What's For Dinner<title>
<link>http://menu.example.com/<link>
<description>Choose what to eat tonight.</description>
</channel>
_XML_;
 
echo <<<END
This uses the "here document" syntax to output
multiple lines with variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
<br />
END;
 
print $channel;
?>
This will produce following result:
This uses the "here document" syntax to output
multiple lines with variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
 
<channel>
<title>What's For Dinner<title>
<link>http://menu.example.com/<link>
<description>Choose what to eat tonight.</description>

Variable Scope:

Scope can be defined as the range of availability a variable has to the program in which it is declared. PHP variables can be one of four scope types:
·         Local variables
·         Function parameters
·         Global variables
·         Static variables

Variable Naming:

Rules for naming a variable is:
·         Variable names must begin with a letter or underscore character.
·         A variable name can consist of numbers, letters, underscores but you cannot use characters like + , - , % , ( , ) . & , etc
There is no size limit for variables.