Tuesday, 27 July 2010

JQuery Radio Button and inner HTML .

JQuery to check radio button for value and set inner html value.


$("input[@name='property_type']").change(function() {
 if ($("input[@name='property_type']:checked").val() == 'aroom') {
  // Code for handling value 'aroom'
  value = 'Radio Button as follows';
  value = value + '< input type="radio" name="property_shared" id="property_shared" value="yes" checked="checked" />Yes   < input type="radio" name="property_shared" id="property_shared" value="no" />No';
  $("#shared_property_option").html(value);
 }
 else { // Code for handling value for else case.
  $("#shared_property_option").html('');
 }
});

Thursday, 22 July 2010

Trim Function in Javascript

// Trim in Javascript, JQuery, Trim in JQuery
//this.replace(/^\s*/, "").replace(/\s*$/, "")
pc6_summary = ($('#pc6-summary').val()).replace(/^\s*/, "").replace(/\s*$/, "");
room_title = ($('#room_title').val()).replace(/^\s*/, "").replace(/\s*$/, "");

// Implementing Trim Function for strings in JQuery, Trim Function for strings in Javascript, a trim function for strings in javascript
< script language="JavaScript" type="text/javascript" >

String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
var s = new String(" Hello ");
// use it like this
s=s.trim();
alert("!" + s + "!");
// end hiding contents -->
< /script >

Monday, 5 July 2010

SLC Result 2066/67, 2010 has been published, to view result goto http://www.nepalipathshala.com/slc

School Leaving Certificate (SLC) examination result 2066/2067 (2010 AD) has been just published on 02 July 2010...
School Leaving Certificate (SLC) examination result 2066/2067 (2010 AD) has been just published 02 July 2010...

For details information, please do LogOn to http://www.nepalipathshala.com/slc,

Best of luck for better result to you !!!

Sunday, 6 June 2010

RSS Feeds with XML Format.

< ?php
header('Content-type: text/xml');

/* Creating OBJECT of included class file from module*/
$article=new article();

echo '< ?xml version="1.0" encoding="utf-8"?>';
echo '< rss version="2.0" xml:base="'.SITE_URL.'" xmlns:dc="http://purl.org/dc/elements/1.1/">';
echo '< channel>';
echo '< title>Site Title< /title>';
echo '< link>http://www.grabhost.net< /link>';
echo '< description>Grab Host Articles List< /description>';
/* Sample code for fetching the object for feeds. */
$articles = $article->get_articles_for_rss_feed();

foreach ( $articles as $article_array)
{ /* Converting timestamp format datetime value to standard RSS format Date Time Format. */
$getdate = $article_array['timestamp'];
if(!empty($getdate)){
$getdate = explode(" ", $getdate);
$getdate = explode("-", $getdate[0]);
$gettime = explode(":", $getdate[1]);
$gettime[0] = !empty($gettime[0]) ? $gettime[0] : 0;
$gettime[1] = !empty($gettime[1]) ? $gettime[1] : 0;
$gettime[2] = !empty($gettime[2]) ? $gettime[2] : 0;
$getdate[0] = !empty($getdate[0]) ? $getdate[0] : 0;
$getdate[1] = !empty($getdate[1]) ? $getdate[1] : 0;
$getdate[2] = !empty($getdate[2]) ? $getdate[2] : 0;
$getdate = mktime($gettime[0], $gettime[1], $gettime[2], $getdate[1] , $getdate[2], $getdate[0]);
$getdate = date("D, d M y H:i:s O", $getdate);
}

echo '';
echo '< title>< ![CDATA[' . $article_array['title'] . ']]>< /title>';
echo '< link>' . SITE_URL . $article_array['seo_title'] . '< /link>';
echo '< description>< /description>';
echo '< comments>' . SITE_URL . $article_array['seo_title'] . '#comments< /comments>';
echo '< pubDate>'.$getdate.'< /pubDate>';
echo '< dc:creator/>';
echo '< guid isPermaLink="false">'.getrandnum(4).' at '.SITE_URL.''; // getrandnum(4) generate the random value having length four (4)
echo '< /item>';
}

echo '< /channel>';
echo '< /rss>';

// RSS Feeds RSS 2.0 with Standard XML format.
?>

RSS Feeds with XML Format.

< ?php
header('Content-type: text/xml');

/* Creating OBJECT of included class file from module*/
$article=new article();

echo '< ?xml version="1.0" encoding="utf-8"?>';
echo '< rss version="2.0" xml:base="'.SITE_URL.'" xmlns:dc="http://purl.org/dc/elements/1.1/">';
echo '< channel>';
echo '< title>Site Title< /title>';
echo '< link>http://www.grabhost.net< /link>';
echo '< description>Grab Host Articles List< /description>';
/* Sample code for fetching the object for feeds. */
$articles = $article->get_articles_for_rss_feed();

foreach ( $articles as $article_array)
{ /* Converting timestamp format datetime value to standard RSS format Date Time Format. */
$getdate = $article_array['timestamp'];
if(!empty($getdate)){
$getdate = explode(" ", $getdate);
$getdate = explode("-", $getdate[0]);
$gettime = explode(":", $getdate[1]);
$gettime[0] = !empty($gettime[0]) ? $gettime[0] : 0;
$gettime[1] = !empty($gettime[1]) ? $gettime[1] : 0;
$gettime[2] = !empty($gettime[2]) ? $gettime[2] : 0;
$getdate[0] = !empty($getdate[0]) ? $getdate[0] : 0;
$getdate[1] = !empty($getdate[1]) ? $getdate[1] : 0;
$getdate[2] = !empty($getdate[2]) ? $getdate[2] : 0;
$getdate = mktime($gettime[0], $gettime[1], $gettime[2], $getdate[1] , $getdate[2], $getdate[0]);
$getdate = date("D, d M y H:i:s O", $getdate);
}

echo '';
echo '< title>< ![CDATA[' . $article_array['title'] . ']]>< /title>';
echo '< link>' . SITE_URL . $article_array['seo_title'] . '< /link>';
echo '< description>< /description>';
echo '< comments>' . SITE_URL . $article_array['seo_title'] . '#comments< /comments>';
echo '< pubDate>'.$getdate.'< /pubDate>';
echo '< dc:creator/>';
echo '< guid isPermaLink="false">'.getrandnum(4).' at '.SITE_URL.''; // getrandnum(4) generate the random value having length four (4)
echo '< /item>';
}

echo '< /channel>';
echo '< /rss>';

// RSS Feeds RSS 2.0 with Standard XML format.
?>

Creating RSS Feeds with Plain display......

Here is the code for creating RSS Feeds in plain XML Feed format..
< ?php
header('Content-type: text/xml');

$feed_contents = "< !--XML Format RSS Feed for Website -- >";
$feed_contents .= "< listing>";
$feed_contents .= "< item>< name>Name 1 here< address>Address 1 here< /address>< /item>";
$feed_contents .= "< item>< name>Name 2 here< /name>< address>Address 2 here< /address>< /item>";
$feed_contents .= ''< /listing >";

$xml_filename = 'feed.xml'; // give the xml file path here
/* deleting the XML file if exists. */
if (file_exists($xml_filename)) {
unlink($xml_filename);
}
/* Writing the XML file. */
$file_handle = fopen($xml_filename, 'a');
fwrite($file_handle, $feed_contents);
fclose($file_handle);

echo $feed_contents;

?>

Wednesday, 12 May 2010

How to CURL the site using PHP CURL Spider in your site.

\< ? php
/ * Before Running this Curl. First Goto
*
* 1. Enable the PHP CURL library in you apache configuration.
* 2. First open the "php.ini" file of your apache or php configuration file.
* for example, in Xampp on Windows, goto /xampp/php/php.ini.
* 3. then open that file and find the ";extension=php_curl.dll" and remove the semicolumn(;) from that line and change into "extension=php_curl.dll".
* 4. Finally, Restart the Apache Server.
* 5. Run the following file by providing necessary curl_url and and curled_filename.
* 6. Goto the index-curled.html file to check the curled result.
* * /

$url_to_curl = "http://localhost/mysite/";
$curled_filename = "index-curled.html";

$ch = curl_init($url_to_curl);
$fp = fopen($curled_filename, "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

if(!curl_errno($ch))
{
$info = curl_getinfo($ch);
echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
}

curl_exec($ch);
curl_close($ch);
fclose($fp);

? >
In Coldfusion CURL CURLING,
We can use the [ cfhttp ] tag for curl.
and [ cffile ] to save the file