"SELECT" and CSS with BROWSER Compatible Issues




Just gone through an issue regarding adding some style sheets on the "OPTION" tag of the "SELECT" box... and come up with an browser compatible issue that IE do not support such type of work. However Firefox goes well.Lets have an example:If we want to highlight, change selected value fonts or make changes in the font-weight it will not effect in IE at all.Just have a look this code in Both browsers and have a look the difference :
This is bold text
This is normal text

This is also being under discussion from several analysis point of view that IE may have playing some contradictory part with OPTGROUP. Here i am also mentioning couple of discussion forum links where these issues came under observations. Hope some or none might help you in knowing these in near future.

Forum Discussion 1 - forums.devshed.com
Forum Discussion2 - forums.whirlpool.net.au

XML Parsing into PHP array

At EVS we have been working many web services projects. these web services return XML that cannot be used directly. this function will convert XML into PHP array. by using this array we can extract data very easly.


$DataArray = xml2array($DataXML);


function xml2array($contents, $get_attributes=1)
{
if(!$contents) return array();
if(!function_exists('xml_parser_create'))
{
//print "'xml_parser_create()' function not found!";
return array();
}
//Get the XML parser of PHP - PHP must have this module for the parser to work
$parser = xml_parser_create();
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
xml_parse_into_struct( $parser, $contents, $xml_values );
xml_parser_free( $parser );

if(!$xml_values) return;//Hmm...

//Initializations
$xml_array = array();
$parents = array();
$opened_tags = array();
$arr = array();

$current = &$xml_array;

//Go through the tags.
foreach($xml_values as $data)
{
unset($attributes,$value);//Remove existing values, or there will be trouble
extract($data);//We could use the array by itself, but this cooler.

$result = '';
if($get_attributes)
{//The second argument of the function decides this.
$result = array();
if(isset($value)) $result['value'] = $value;

//Set the attributes too.
if(isset($attributes))
{
foreach($attributes as $attr => $val)
{
if($get_attributes == 1) $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
/** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */
}
}
}
elseif(isset($value))
{

$result = $value;
}

// See tag status and do the needed.

if($type == "open")
{ //The starting of the tag ''
$parent[$level-1] = &$current;

if(!is_array($current) or (!in_array($tag, array_keys($current))))
{ //Insert New tag
$current[$tag] = $result;
$current = &$current[$tag];

}
else
{ //There was another element with the same tag name
if(isset($current[$tag][0]))
{
array_push($current[$tag], $result);
}
else
{
$current[$tag] = array($current[$tag],$result);
}
$last = count($current[$tag]) - 1;
$current = &$current[$tag][$last];
}

} elseif($type == "complete")
{ //Tags that ends in 1 line ''
//See if the key is already taken.
if(!isset($current[$tag]))
{ //New Key
$current[$tag] = $result;

}
else
{ //If taken, put all things inside a list(array)
if((is_array($current[$tag]) and $get_attributes == 0)//If it is already an array...
or (isset($current[$tag][0]) and is_array($current[$tag][0]) and $get_attributes == 1))
{
array_push($current[$tag],$result); // ...push the new element into that array.
}
else
{ //If it is not an array...
$current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value
}
}

}
elseif($type == 'close')
{ //End of tag '
'
$current = &$parent[$level-1];
}
}

return($xml_array);
}

?>

Useful for Crawling Functions

Functions developed for crawling project at EVS। These functions are now being used be many guys here in EVS. here will find these functions along with a little documentation. feel free to use and modify them.

Useful for Crawling Functions

1) getdataA(startposition,endposition,string)

function getdataA($strStart, $strEnd, $text){

for ($i=0;$i<=strlen($text);$i++)

{

if (substr($text,$i,strlen($strStart))==$strStart)

{

$st=$i;

$k=$i;

while (substr($text,$k,strlen($strEnd))!=$strEnd)

{

$k++;

}

$en=$k+strlen($strEnd);

$start=$st+strlen($strStart);

$tmpstr= substr($text,$start,$k-$start);

}

}

return $tmpstr;

}

Explanation of the function:-

Lets suppose variable $tempdata contains the following string of data

How to use:-

If we use this function i.e getdataA, we should use as

$data = getdataA(��,

, $tempdata)

This function will return us a string, which contains all the data in $tempdata excluding tag i.e it will return us

Mean the starting and ending portions has been removed from the $tempdata.

2) getdataB(startposition,endposition,string)

function getdataB($strStart, $strEnd, $text){

for ($i=0;$i<=strlen($text);$i++)

{

if (substr($text,$i,strlen($strStart))==$strStart)

{

$st=$i;

$k=$i;

while (substr($text,$k,strlen($strEnd))!=$strEnd)

{

$k++;

}

$k=$k+strlen($strEnd);

$start=$st;

$tmpstr= substr($text,$start,$k-$start);

}

}

return $tmpstr;

}

Explanation of the function:-

Lets suppose variable $tempdata contains the following string of data

How to use:-

If we use this function i.e getdataA, we should use as

$data = getdataA(��,

, $tempdata)

This function will return us a string, which contains all the data in $tempdata i.e it will return us. So by using this function i.e getdataB we can get all the data including starting and ending points motioned in the function.

Main difference between getdataA and getdataB

In the light of above given few examples we can easily conclude the difference between the functions getadataA and getdataB , i.e getdataA returns a string between the specified string or tag while getdataB returns the whole string including the starting and ending tag.

3) getdataC(startposition,endposition,string)

function getdataC($strStart, $strEnd, $text){

for ($i=0;$i<=strlen($text);$i++)

{

if (substr($text,$i,strlen($strStart))==$strStart)

{

$st=$i;

$k=$i;

while (substr($text,$k,strlen($strEnd))!=$strEnd)

{

$k++;

}

$en=$k+strlen($strEnd);

$start=$st+strlen($strStart);

$tmpstr= substr($text,$start,$k-$start);

break;

}

}

return $tmpstr;

}

Explanation of the function:-

This function returns us the data which occurs for the first time.Lets suppose variable $tempdata contains the following string of data

How to use:-

If we use this function i.e getdataC, we should use as

$data = getdataA(��, , $tempdata)

This function will return us a string, which contains following data form $tempdata i.e it will return us

Evision

So by using this function i.e getdataC we can get all the data including starting and ending points motioned in the function.

4) Function function reducere($text)

function reducere($text)

{

$a = array("\r", "\t", "\n");

$r = str_replace($a, '', $text);

return $r;

}

Explanation of the function:-

This function is used to remove extra spaces new line breaks and tabs.

5) function getdataArray(startposition,endposition,string)

function getdataArray($strStart, $strEnd, $text){

for ($i=0;$i<=strlen($text);$i++)

{

if (substr($text,$i,strlen($strStart))==$strStart)

{

$st=$i;

$k=$i;

while (substr($text,$k,strlen($strEnd))!=$strEnd)

{

$k++;

}

$k=$k+strlen($strEnd);

$start=$st;

$tmpstr[]= substr($text,$start,$k-$start);

}

}

return $tmpstr;

}

Explanation of the function:-

This function returns us an array of data.Lets suppose variable $tempdata contains the following string of data

How to use:-

If we use this function i.e getdataA, we should use as

$data = getdataArray, , $tempdata)

This function returns us an array which include data such as

$data[0] = Evision

$data[1] = Software

$data[2] = Islamabad

So by using this function i.e getdataArray we can get an array of data excluding starting and ending tag.

Html Fieldset Rounded Corners - Internet Explorer (IE) and Firefox


I don't usually prefer anything about Internet Explorer. However, IE's default presentation for the Html fieldset tag just looks nicer. Firefox, on the otherhand, defaults to an ugly square box presentation.

So, to try to get Firefox to look more like IE (something I never thought that I would say) ...

fieldset { 
-moz-border-radius-bottomleft:7px;
-moz-border-radius-bottomright:7px;
-moz-border-radius-topleft:5px;
-moz-border-radius-topright:7px;
border-radius: 3px;
}

I confess this only addresses IE and Firefox. Supposedly, Safari and Chrome will support rounded corners under their CSS3 support (eta?). I tried -webkit-border-radius: 3px;, but it never rendered correctly in the versions of Safari and Chrome that I have. I'm also assuming that Opera falls in this same category.


If you absolutely must have rounded corners: http://www.spiffycorners.com. However, I caution you against the author's approach because it requires too much Html for an effect that will be cleanly implemented in CSS3. Again, this is only a nice to have.


Example:


Title
contents



ISAPI Rewrite based URL manipulation module for IIS

ISAPI_Rewrite provides a rule-based rewriting engine to rewrite requested URLs on the fly. It supports virtually unlimited number of rules and virtually unlimited number of attached rule conditions to provide really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on tests for HTTP headers, Server variables, the requested URL itself and various different conditions.

URL manipulations are established using text configuration files with set of directives inside. There are several levels of configurations. First global (server wide) configuration directives are placed in file with the name httpd.conf in the ISAPI_Rewrite installation folder. There are also several tags that can enclose directives to apply for special locations: , , , , , and . Finally ISAPI_Rewrite supports .htaccess files that can uppear in any directory inside a web site and rules from these files will apply to this location and subdirectories. All configuration files are reloaded automatically every time the file is changed. It is allowed to change file content from third party programs and scripts.

In most cases ISAPI_Rewrite is used to rewrite requested URL. In addition to rewrite ISAPI_Rewrite can modify, create or remove any other HTTP header of the client REQUEST. Module operation may lead in rewriting, proxying, redirection, or blocking of an original client request to a server.

Rewriting will cause server to continue request processing with a new URL as if it has been originally requested by a client. New URL can include query string section (following the question mark) and may point to any plain static files, scripts (like ASP), programs (like EXE), etc. within the same web application (which usually means same web site). Rewriting is completely transparent to the user and web site applications because it is done internally on a server and before web application receives request.

Proxying causes the resulting URL to be internally treated as a target on another server and immediately (i.e. rules processing stops here) passed to the remote server. Response of the remote server will then be passed back to the client. Proxy requires you to specify fully qualified URL, starting from protocol, host name, etc. ISAPI_Rewrite uses ISAPI extension to handle proxy requests. You can read more about this in configuring proxy chapter.

Redirection will result in sending of immediate response with a redirect instruction (HTTP response code 302 or 301) setting substituted URL as a new location. You can use an absolute URL format (and that is required by the RFC 2616) in redirection instruction to redirect the request to a different host, port and protocol. If this information is omitted, ISAPI_Rewrite will automatically supply URL with the current request's protocol, server name and directory location. Redirect instruction always causes rewriting engine to stop rules processing sequence.

Rules are applied in the order of appearance in configuration files. Directory level configuration files are processed file by file starting from the parents. Rules from global (server wide) configuration file are applied first. Order of rules is important because substitution result of one rule will become a source for subsequent rules application.

Before any URL modification ISAPI_Rewrite saves original URL into the HTTP header named X-Rewrite-URL. Then it can be retrieved in script as HTTP_X_REWRITE_URL server variable. Since in IIS world server variables cannot be modified ISAPI_Rewrite cannot provide this variable as REQUEST_URI for Apache compatibility. If your application is designed to rely on REQUEST_URI variable you will need to patch it to work with HTTP_X_REWRITE_URL variable instead. Here is a patch example for PHP code:

if (isset($_SERVER['HTTP_X_REWRITE_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}

Multiple RewiteCond directives followed by RewriteRule (or RewriteProxy) directive affect only that single rule. If some condition has to be used with more than on rule, this condition directive should be repeated for every rule to apply.

resizing Image, Thumbnail for WIN and LINUX

To execute its functionality do:

< img src="img_resize.php?path=logo.jpg&imgWidth=100" >

and it will work.

Note: File formats supported are jpg, jpeg, png, gif and wbmp. For transparent images it showes black background.

Code is given bellow. Code file is attached also.

resizeimage( $_GET['path'], $_GET['imgWidth']);
function resizeimage($overlay, $autosize){
//Find if overlay image exists

if(!file_exists($overlay)) {
die("Overlay image does not exist.");
}
$extension_o = strtolower(substr($overlay, strrpos($overlay, ".") + 1));
//Load overlay image from file
switch ($extension_o)
{
case 'jpg':
$overlay = imagecreatefromjpeg( $overlay);
break;
case 'jpeg':
$overlay = imagecreatefromjpeg( $overlay);
break;
case 'png':
$overlay = imagecreatefrompng( $overlay);
break;
case 'gif':
$overlay = imagecreatefromgif( $overlay);
break;
case 'wbmp':
$overlay = imagecreatefromwbmp( $overlay);
break;
default:
die("Image is of unsupported type.");
}
// Get the size of overlay
$oowidth = imagesx($overlay);
$ooheight = imagesy($overlay);

$owidth = $autosize;
$oheight = $autosize;

$oheight = $ooheight * ($owidth/$oowidth);
$owidth = $oowidth * ($oheight/$ooheight);

$image_resized_o = imagecreatetruecolor($owidth, $oheight);
imagecopyresampled($image_resized_o, $overlay, 0, 0, 0, 0, $owidth, $oheight, $oowidth, $ooheight);
// make white color tarnsaparent for Overlay image
$img = imagecreatetruecolor($owidth,$oheight);

// from this one can make transparent given color RGB now it make white color //transparent
$trans = imagecolorallocate($img,255,255,255);
imagecolortransparent($img,$trans);
imagecopy($img,$image_resized_o,0,0,0,0,$owidth,$oheight);
imagetruecolortopalette($img, true, 256);
imageinterlace($img);
//=========================================================
header("Content-type: image/jpeg");
header("Content-Disposition: filename=" . $overlay);
imagejpeg($img); // to view image in web browser
}
?>

Coloring Your Scrollbars with CSS

To add the scrollbar property rules for the browser scrollbar or the textarea form field scrollbar.

As shown below:

* For the browser scrollbar colors, add the scrollbar property attribute rules to the body element.
* For the textarea scrollbars, add the scrollbar property attribute rules to the textarea element.

Here is the CSS for this,

body {
scrollbar-3dlight-color:#FFD700;
scrollbar-arrow-color:#FFFF00;
scrollbar-base-color:#FF6347;
scrollbar-darkshadow-color:#FFA500;
scrollbar-face-color:#008080;
scrollbar-highlight-color:#FF69B4;
scrollbar-shadow-color:#FF00FF;
}

/* CSS rules for the forms scrollbar */

textarea {
scrollbar-3dlight-color:gold;
scrollbar-arrow-color:yellow;
scrollbar-base-color:tomato;
scrollbar-darkshadow-color:orange;
scrollbar-face-color:teal;
scrollbar-highlight-color:hotpink;
scrollbar-shadow-color:magenta;
}