Thursday, January 31, 2008

CRICKET TEAM

check it our cricket team!

Wednesday, January 30, 2008

Content crawling

http://wiki.dreamhost.com/CURL

Image Crawling in php

<?php
$image_url = "http://www.isbnonline.com/files/b/8/3597/200/ASP-NET-2-0-Website-Programming-Problem-Design-Solution-Programmer-to-Programmer.jpg";
$ch = curl_init();
$timeout = 0;
curl_setopt ($ch, CURLOPT_URL, $image_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

// Getting binary data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);

// output to browser
header("Content-type: image/jpeg");
$Imp=fopen("image/book.jpg","w");
fwrite($Imp,$image);
print $image;
?>

Tuesday, January 29, 2008

Image Alignment on HTML Pages using ALIGN tag

Image Alignment on HTML Pages

Image Source
To use a graphic with a page of HTML text, use the markup
<IMG SRC = "source & file type of the image">

The source of the image is defined by where the image is relative to the main document. The simplest situation is where the image is in the same directory as the main document. Then the image source is simply the name of the image file and its file type:
<IMG HEIGHT=140 WIDTH=125 SRC = "koala.jpg">.

If images are stored in a separate "graphics" directory/folder on the server:
<IMG HEIGHT=140 WIDTH=125 SRC = "graphics/koala.jpg">.


ALIGN=TOP
HTML: <IMG HEIGHT=140 WIDTH=125 SRC="graphics/koala.jpg" ALIGN=TOP>


ALIGN=MIDDLE
HTML: <IMG HEIGHT=140 WIDTH=125 SRC="graphics/koala.jpg" ALIGN=MIDDLE>    


ALIGN=BOTTOM
HTML: <IMG HEIGHT=140 WIDTH=125 SRC="graphics/koala.jpg" ALIGN=BOTTOM>

ALIGN=LEFT
HTML: <IMG HEIGHT=140 WIDTH=125 SRC="graphics/koala.jpg" ALIGN=LEFT>

ALIGN=RIGHT
HTML: <IMG HEIGHT=140 WIDTH=125 SRC="graphics/koala.jpg" ALIGN=RIGHT>

ALIGN=RIGHT With Space Control
HTML: <IMG HEIGHT=140 WIDTH=125 SRC="graphics/koala.jpg" ALIGN=RIGHT HSPACE=50 VSPACE=50>

for more info :
http://www.nmacmillan.com/images.htm

PHP Multi Dimensional Array Sort

<?php
    /**
    * @desc You really should validate the posted sort direction against a list of valid possibilities.
    *         Options are SORT_ASC, SORT_DESC, etc, as shown in the documentation for array_multisort
    */
    //$sort['direction'] = $_POST['sort_direction'] ? $_POST['sort_direction'] : 'SORT_ASC';
    $sort['direction']='SORT_ASC';
   // $sort['field']       = $_POST['sort_field'] ? $_POST['sort_field'] : 'value';
                    $sort['field']='age';
    $array_to_sort = array();   
    $array_to_sort['TestCase1'] = array('age'=>'24','name'=>'Test1','value'=>'218');
    $array_to_sort['TestCase2'] = array('age'=>'21','name'=>'Test2','value'=>'10');
    $array_to_sort['TestCase3'] = array('age'=>'34','name'=>'Test3','value'=>'64');
   
    /**
    * @desc Build columns using the values, for sorting in php
    */
    $sort_arr = array();
    foreach($array_to_sort AS $uniqid => $row){
        foreach($row AS $key=>$value){
            $sort_arr[$key][$uniqid] = $value;
            
        }
    }
   
    print '<b>Before sorting</b>: <br> <pre>';
    print_r($array_to_sort);
    print '</pre>';
   
    if($sort['direction']){
        array_multisort($sort_arr[$sort['field']], constant($sort['direction']), $array_to_sort);
    }

    print '<b>After sorting</b>: <br> <pre>';
    print_r($array_to_sort);
    print '</pre>';
   
?>

Friday, January 25, 2008

Time Line display JS

HI
easy integration on time line display on ur website..
Check this information.

http://simile.mit.edu/timeline/docs/basics.html

ALL source code available here.
http://simile.mit.edu/repository/timeline/trunk/src/webapp/api/


Thursday, January 24, 2008

create a timeline display on your site

Easy way to create the time time display for ur website.. check the below link.

http://www.mytimelines.net/create-a-timeline/


example:
<head>
<script src="http://simile.mit.edu/timeline/api/timeline-api.js" type="text/javascript"></script>
<script src=" http://www.mytimelines.net/js/mytimelines.v1.0.php?u=http://news.search.yahoo.com/news/rss?p=india&ei=UTF-8&fl=0&x=wrt " type="text/javascript"></script>
</head>
<body>
<div><div id="my-timeline" style="height: 400px; width: 500px; border: 1px solid #eaeaea; font-size: 11px; font-family: arial;"></div></div>
</body>



Wednesday, January 23, 2008

Flash movie with a transparent background - Flash movie overlap with to javascript menu

<param name=WMODE  value=transparent>

and add the variable on
WMODE ="transparent" on emmbed tag.

WIDTH="450" HEIGHT="300" WMODE ="transparent"></EMBED>


Tuesday, January 22, 2008

Simpler Ajax development with Prototype.js

Simpler Ajax development with Prototype.js

Lana Kovacevic, Builder AU

Prototype.js (http://www.prototypejs.org/) is a library of JavaScript objects and functions, designed to help you code easier. It is particularly useful for Ajax development, as it contains a number of objects that handle Ajax communication, previously requiring lengthy amounts of code.

To begin taking advantage of Prototype.js, download the latest version from (http://www.prototypejs.org/download ), save it to a file called prototype.js and import it into your HTML page via:

<script type="text/javascript" src="prototype.js"></script>

The Ajax functionality revolves around the use of three main objects of the Ajax class, namely, Ajax.Request, Ajax.Updater and Ajax.Responders.

Ajax.Request

Ajax.Request object encapsulates the commonly used Ajax code for setting up the XMLHttpRequest object, performing cross-browser checking for compatibility and callback handling.

The example code below will check if an entered username is available or taken.

Firstly, a username is to be entered into a text field:

<body>
<form>
Please enter a username:
<input type="text" id="username" onchange="checkAvailability()" />
</form>
</body>
</html>

The element id is assigned, so that JavaScript can refer to it later. The onchange event will trigger the checkAvailability () function which is described below.

var url = "checkAvailability.php";
function checkAvailability() {
new Ajax.Request(url, {
method: 'get',
parameters: { username: document.getElementById('username').value },
onSuccess: process,
onFailure: function() {
alert("There was an error with the connection");
}
});
}

The function initialises an Ajax.Request object to handle the request. Notice, that in the URL variable, the server-side script is supplied, which will be explained later. The Ajax.Request is getting two parameters passed to it; the URL of the script and an object that has the parameters for the AJAX call. These parameters are the method, the callbacks, and the username to be sent to the script. The process function is passed to the onSucess callback. The onFailure callback will alert the user if an error had occurred while connecting to the server. The process function is shown below.

function process(transport) {
var response = transport.responseText;
if(response == 'available')
alert("This username is available");
else
alert("This username is already registered, please choose another");
}

The response from the server is stored in the responseText property. In this case the server will return "available" or "unavailable" and the user will be notified accordingly.

The server-side script, checkAvailability.php is needed to check if the username is already taken. For the sake of simplicity of this example an array will hold the usernames that are taken.

<?php

$usernames = array('neb', 'lkovacev10', 'emuns','ena5','dado17','lara', 'amela12', 'zozo');
if(in_array($_GET['username'], $usernames))
echo 'unavailable';
else
echo 'available';
?>

Ajax.Updater

Ajax.Updater is an extension of the Ajax.Request object in that it performs an Ajax request and also updates the page with the returned information.

new Ajax.Updater(container, url[, options])

As you can see, it takes three parameters instead of two, with the additional parameter being the container or the location in the HTML page where the returned information should be displayed. In the example below, when a user clicks a button the contents of a <div> element are filled with different types of fruit.

<body>
<div id="saladContainer">Empty </div>
<button onclick="fruitSalad()">Fill it with fruit </button>
</body>

The code for the fruitSalad () function is displayed below. An Ajax.Updater object is created and passed three parameters; the id of the <div> element, the destination URL and a method, in this case "get".

function fruitSalad () {
new Ajax.Updater('saladContainer', 'fruit.php', { method: 'get' });
}

Next, fruit.php script needs to be created to execute the code of retrieving different types of fruit from an array.

<?php
$fruits = array('oranges', 'bananas', 'grapes', 'strawberries', 'watermelon', 'apples');

for($i = 0; $i < sizeof($fruits); $i++)
echo $fruits[$i] . "<br />";
?>

Additionally, Ajax.PeriodicalUpdater can be used to update the content at regular intervals while the response from the server remains unaltered. To do this, use the frequency attribute to set the number of seconds after which the content is to be updated.

For instance, frequency: 5, means that the content will be updated every five seconds.

Ajax.Responders

Responders are global objects that monitor all Ajax activity on the page and get notified of each step in the communication process. To register one of these "listeners" use the code below:

Ajax.Responders.register(responder)

You can similarly, unregister them when they are no longer required using:

Ajax.Responders.unregister(responder)

For instance, let's say while the requests are processing we want to show a "processing" icon and hide it when the requests are complete.

The code below shows how this can be done:

Firstly, the image needs to be inserted within <body></body> tags and the CSS display property set to none. This will hide the image from the beginning.

<img src="processing.gif" id ="inProgress" style="display: none" />

Firstly, we use the Ajax.Responders object to register the onCreate and onComplete callbacks. The onCreate callback is triggered when an Ajax.Request object is created, and the onComplete callback is triggered when the request completes executing. The two callbacks are set to functions showProcessing and hideProcessing which in turn will show or hide the processing icon inside the document.

Ajax.Responders.register({
onCreate: showProcessing,
onComplete: hideProcessing
});

function showProcessing() {
if(Ajax.activeRequestCount > 0)
document.getElementById('inProgress').style.display = 'inline';
}

function hideProcessing () {
if(Ajax.activeRequestCount <= 0)
document.getElementById('inProgress').style.display = 'none';
}

The examples above illustrate some of the advantages of using Prototype.js for Ajax development. One of the biggest advantages is the amount of code needed to develop an application is greatly reduced and therefore ends up being more comprehensible.

Sunday, January 20, 2008

ZIP and UNZIP linux command

tar -cf yourcontent.tar yourcontent
gzip yourcontent.tar

tar -cf yoursql.tar yoursql
gzip yoursql.tar


scp -r yourcontent.tar.gz username@127.0.0.255:/home/username
password

scp -r yoursql.tar.gz username@127.0.0.255:/home/username
password

tar -zxvf yourcontent.tar.gz

Wednesday, January 9, 2008

getElementsByClass

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName (tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if (pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      classElements[j].style.display="none";
      //alert(classElements[j]);
      j++;
    }
  }
  return classElements;
  //alert(classElements);
}

u  can use this like
getElementsByClass("oddp2",null,"p")