JSONP for cross domain communication solution using with javascript and PHP

Last year in Feb I heard about JSONP and really liked the JSONP solutions. JSONP allows you to make an HTTP request outside your own domain
JSONP consume the Web Services from JavaScript code. Earlier I worked on so on AJAX but there is issue with working or communication issue with cross domain sites.

JSONP for cross domain communication solution using with javascript and PHP
JSONP for cross domain communication solution using with javascript and PHP

XMLHttpRequest is blocked from making external requests.

JSONP for cross domain communication solution using with javascript and PHP

JavaScript code to make a JSONP call will as follows:

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

function common_jsonpRequest(url, name, query) {

 if (url.indexOf("?") > -1)
 url += "&jsonp="
 else
 url += name + "&";
 if (query)
 url += encodeURIComponent(query) + "&";
 url += new Date().getTime().toString(); // prevent caching

 var JSONPscript = document.createElement("script");
 JSONPscript.id = 'wordpressapi_jsonpRequest';
 JSONPscript.setAttribute("src", url + "&CacheBuster=" + Math.random());
 JSONPscript.setAttribute("type","text/javascript");

 // write the jsonp script tag
 document.body.appendChild(JSONPscript);
 //script.text = "";

}

function returncall (data){
 alert(data);
// you can use data as a variable also.
}

[/viral-lock]

In same javascript you should write the returning function as above.

You can call JSONP this function as follows;

<a href="http://images.purabtech.in/JSONP-request.gif">
<img class="alignnone size-medium wp-image-1167" title="JSONP-request" src="http://images.purabtech.in/JSONP-request-300x125.gif" alt="" width="300" height="125" />
</a>
common_jsonpRequest(base_url+'getData.php?jsonp=mycallback&name=for_wordpressapi');

Notel: getData.php file will beahave like externaal javascript file so handle this file carefully.
getData.php sample file.

<?php
$data = "this is our dynamic data";
if($_REQUEST['name']=='for_wordpressapi'){

echo "returncall(".$data.")";

}

?>&nbsp;

This will return the “this is our dynamic data” as a alert.

How to create and read the xml using php

In this tutorial we given code sample for create and read the xml using php. we given explanation and there details

What is XML?
Extensible Markup Language (XML) is described as both a markup language. Now it is known as data storage format also

How to create and read the xml using php
How to create and read the xml using php

XML is very important in in today’s application development environment.
If you’ve never before worked with XML in PHP or have not yet made the jump to PHP5, this starter guide to working with new functionality available in PHP5 for XML.

Using following code you are able to create simple xml file.

<?php

//Creates XML string and XML document using the DOM
$dom = new DomDocument('1.0');

//add root - <books>
$books = $dom->appendChild($dom->createElement('books'));

//add <book> element to <books>
$book = $books->appendChild($dom->createElement('book'));

//add <title> element to <book>
$title = $book->appendChild($dom->createElement('title'));

//add <title> text node element to <title>
$title->appendChild(
$dom->createTextNode('Wordpressapi Magazine'));

//generate xml
$dom->formatOutput = true; // set the formatOutput attribute of
// domDocument to true
// save XML as string or file
$test1 = $dom->saveXML(); // put string in test1
$dom->save('wordpressapi1.xml'); // save as file
?>

Out put of above code will as follows:

<?xml version="1.0"?>
<books>
<book>
<title>Wordpressapi Magazine</title>
</book>
</books>

Now I am going to show you how to read the xml file using php

[/php]
loadXML(‘wordpressapi1.xml’);
if (!$dom) {
echo ‘Error while parsing the document’;
exit;
}

$s = simplexml_import_dom($dom);

echo $s->book[0]->title; // WordPressapi Magazine
?>
[/php]

or in other way

$xmlFileData = file_get_contents(“wordpressapi1.xml”);
// Here's our Simple XML parser!
$xmlData = new SimpleXMLElement($xmlFileData);
// output will be shown in array format
print_r($xmlData);

how to add tag cloud to wordpress theme

WordPress tags and tag cloud is important part in wordpress theme. Here in article given code to add tag cloud to wordpress theme. Tag cloud good for SEO.

I will give so much credit to tags and tag cloud because SEO prospective tag are important.

how to add tag cloud to wordpress theme

What is a tags and Tag cloud?

This is the process of adding keywords which link directly to a site that monitors and allows search of key tags to find information on websites and blogs.

Tag cloud are also same but that will attract the users and give more information about topics which write in your blog. Keep this in mind tag are really important for SEO.

In this article I will show how to create the beautiful tag using wordpress api.

In your template you will found the single.php and page.php or index.php files in that file, You are already using some loop for fetching the posts. In that loop just put following code for displaying the tags.


the_tags( $before, $separator, $after );

<php the_tags();?>

Now comes interesting part,  adding a tag cloud to your sidebar or footer.

Using following code you can display the tag could but don’t put following code in any loop.


<!--?php wp_tag_cloud('smallest=8&largest=22'); ?-->

If you want to show tag cloud more interesting than use my code in your style.css file.


.tags{
 clear:both;
 background:#FAFAFA bottom;
 margin:10px 0 10px;
 padding:12px 10px 15px 10px;
 -moz-box-shadow:0 2px 2px rgba(0, 0, 0, 0.2);
 width:auto;
 margin-bottom:5px;
 width:304px;
 border:1px solid #cfdcc7;
}

.tags a:link,.entry a:visited {
 font-weight:normal;
 color:#356BB2;
}
.tags a:hover {
 background:#356BB2;
 color:#fff;
 font-weight:normal;
 text-decoration:none;
}

Your tag cloud will look like..as follows.

how to add tag cloud to wordpress theme
how to add tag cloud to wordpress theme

you can pass following param to tag_cloud function.


More help full function tag related as follows:

the_tags, tag_description, single_tag_title, wp_tag_cloud, wp_generate_tag_cloud, get_tags, get_the_tags, get_the_tag_list, get_tag_link

You can visit the pages and check the details.

wordpress vs wordpressmu

As we know the wordpress is best featured CMS and growing very fast. Thousands sites are building wordpress daily. When it comes to which wordpress CMS we need to use then You should think about following points. Points about wordpress vs wordpressmu

wordpress vs wordpressmu

I am WordPressMU fan frankly speaking but that comes after words. When you are choosing wordpress client in senorio you should better understand the requirement and future plans of client.

In this article I am going to talk about some good features of both (wordpress and wordpressMU). We should also discuss about when to choose wordpress and when to choose wordpressmu.

——————————x———————x———————————–x—————

  • Use WordPress When following criteria is fitting with your client.
wordpress vs wordpressmu
wordpress vs wordpressmu

1. When client want create website in very less time

2. There are only few admin are going to handle the site

3. There is not so much huge amount of data to listed on website

4. Client is no huge future plans about website

5. If client want so much free plugins or many features.

6. Client has less knowledge about handling CMS

7. For single small firms  and business like (lawyer, Doctor, real estate agents, builders, witter,  advertiser,   engineers, professionals). In this situation wordpress is best suitable.

8. For small sites and wordpress will give the best performance.

9. SEO purpose wordpress is the best tool.

10. You will get so many free plugins and tools for wordpress

11. You will easily get the so much help and documentation

12. wordpress will always get first update from wordpress compnay

13. Performance – WordPress gives the is best in performance. But you should think about data size.

————————x———————————x—————————x——————————–

  • Use WordPressMU When following criteria is fitting with your client.
wordpress vs wordpressmu
wordpress vs wordpressmu

1. When Client has big future plans with the website

2. There is enough time develop the site

3. If client is agree to develop custom solutions

4. If client is taking interest and he is having some knowledge about CMS

5. They are so many authors going to write and mange the website

6. There is very huge data need to be insert in website

7. For Big firms and business like (Magazine, Publication house, book writters, groups, social community, Big manufactures, big offices…etc). In this situation wordpressmu is the best solution.

8. For bigger sites I would recommend use wordpressMU

9. SEO purpose wordpressmu is also good but you need to do some customization in code.

10. For wordpressmu there are always few plugins and tool. (No plugins like wordpress)

11. You will get documentation and help but limited becasue not so many developers working on WordPressMU

12. WordPressMU always wait for update from wordpress company

13. Performance – WordPressMU gives best in performance in any condition.

But still I say I love WordPressMU and I think in future automatic will merge wordpress with wordpressMU.

So have fun and develop sites in wordpress.

Advanced rounded corner with only css

CSS tutorial, Advanced rounded corner with only css. I got so many scripts which had solution with javascripts and some are given solutions with images.

In one of my project I got requirement about half rounded corner in header and footer.

Advanced rounded corner with only css

But I want customize every thing like color of rounded corner header background, footer background and border also.

I did so much R&D about same but did not found any solution.

So I tried to code myself in CSS and I got succeed in that.
In this article I am going to share the code with you.

first put my style sheet in your webpage.

<style type="text/css">
body {background-color: #fff;font: normal 10pt ,Arial,sans-serif;}

img{border:none;}

.wordpressapi-main{
 clear:both;
 float:left;
 width:300px;
 /*border:1px solid #f00;*/
}

.wordpressapi_round_header {
 background-color: #ddd;

 -moz-border-radius: 15px 15px 0px 0px;
 -webkit-border-radius: 15px 15px 0px 0px;
 border-radius: 15px 15px 0px 0px;
 /*behavior: url(border-radius.htc);*/
 text-align:center;
 padding:5px 0px 5px 0px;
 clear:both;
 float:left;
}

.wordpressapi_round_footer {
 background-color: #ddd;

 -moz-border-radius: 0px 0px 15px 15px;
 -webkit-border-radius: 0px 0px 15px 15px;
 border-radius: 0px 0px 15px 15px;

 /*behavior: url(border-radius.htc);*/
 text-align:right;

 clear:both;
 float:left;

}
.wordpressapi_round_middle {
 text-align:center;
 color:blue;
 clear:both;
 float:left;
}
.inner_ad {
 padding:10px;
 text-align:left;
 color:black;
 font-size:12px;
 vertical-align: middle;

}
.round_heading{
font-size:16px;
line-height:26px;
font-weight:bold;

}

/* rounded corners */
.wordpressapi-blue-round-container{ /*margin-top:10px;*/}
.wordpressapi-blue-round-container-top, .wordpressapi-blue-round-container-bot, .wordpressapi-acco-top, .wordpressapi-acco-bot {
 display:block;
 background:#fff;
 font-size:1px;
 clear:both;

}
.blue-round-t1, .blue-round-t2, .blue-round-t3, .blue-round-t4 {display:block; overflow:hidden;}
.blue-round-t1, .blue-round-t2, .blue-round-t3 {height:1px;}
.blue-round-t2, .blue-round-t3, .blue-round-t4 {
 background:#0000FF;
 border-left:1px solid #ccc;
 border-right:1px solid #ccc;
}
.blue-round-t1 {
 margin:0 5px;
 background:#0000FF;
 border-top:1px solid #ccc;
 height:0px;
}
.blue-round-t2 {margin:0 3px; border-width:0 2px;}
.blue-round-t3 {margin:0 2px;}
.blue-round-t4 {height:2px; margin:0 1px;}

.white-round-t1, .white-round-t2, .white-round-t3, .white-round-t4 {display:block; overflow:hidden;}
.white-round-t1, .white-round-t2, .white-round-t3 {height:1px;}
.white-round-t2, .white-round-t3, .white-round-t4 {
 background:#FFF;
 border-left:1px solid #ccc;
 border-right:1px solid #ccc;
}
.white-round-t1 {
 margin:0 5px;
 background:#FFF;
 border-top:1px solid #ccc;
 height:0px;
}
.white-round-t2 {margin:0 3px; border-width:0 2px;}
.white-round-t3 {margin:0 2px;}
.white-round-t4 {height:2px; margin:0 1px;}

.wordpressapi-blue-round-contents{
 display:block;
 border:1px solid #000;
 border-width:0 1px;
 padding: 0 15px;
 background:#0000FF;
 color:#000;
 text-align:justify;
 width: 878px;
 clear:both;
 float:left;

}

.hold{
 border-left:1px solid #ccc;
 border-right:1px solid #ccc;
 clear:both;
 float:left;
 width:298px;
}

.inner-adds-bottom{
 padding-top:1px;
 clear:both;
 float:left;
}

/* rounded corners */

.cross-img, .cross-img:link, .cross-img:hover{
 background:url(close_button.gif) no-repeat center;
 width:12px;
 height:12px;
 display:inline-block;
}

.info-img, .info-img:link, .info-img:hover{
 background:url(information_btn.gif) no-repeat center;
 width:12px;
 height:12px;
 display:inline-block;
}
</style>

Then Put following code in your HTML body.

Advanced rounded corner with only css
Advanced rounded corner with only css

You will get the following result as follows:

Download the main html file from  here: Advanced rounded corner with CSS

How to append html code using javascript and php

append html code using javascript and php, In this example I am going to show you how to add the dynamic HTML code into Document using javascript and PHP.

How to append html code using javascript and php

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php

$random_id = 125845465; // PUTTING SOME RANDOM ID YOU CAN USE YOURSELF.

$DYNAMIC_HTML = '<div>
<b>Sponsored Links</b>

<div>
 12px;font-weight:bold;" href="http://www.ucoz.com/" rel="nofollow">Create a website for free - uCoz

Build a website quickly and easily
Customizable templates and graphics

</div>

<div>
 12px;font-weight:bold;" href="http://www.purabtech.in/files/domain_names/">$1.99 Domain Names

 With every new non-domain purchase thru <a href="http://www.purabtech.in/files/domain_names/" rel="nofollow">wordpressapi</a>, you get a domain name for only $1.99.
</div>

<div>
 12px;font-weight:bold;" href="http://www.purabtech.in/files/" rel="nofollow">FREE Hosting!

 With every domain you register with <a href="http://www.purabtech.in/files/" rel="nofollow">wordpressapi</a> you get FREE hosting.
</div>
</div>';

 $HTML = "var objHead = document.getElementsByTagName('head');
 var objCSS = objHead[0].appendChild(document.createElement('link'));
 objCSS.id = '.$random_id.';
 objCSS.rel = 'stylesheet';
 objCSS.href = 'http://YOURSITE/STYLE.css';
 objCSS.type = 'text/css';";

 $HTML .= '
 var WORDPRESAPI_html_'.$random_id.' = document.createElement("div");
 WORDPRESAPI_html_'.$random_id.'.id = "WORDPRESAPI_html_'.$random_id.'";
 WORDPRESAPI_html_'.$random_id.'.style.position = "absolute";
 WORDPRESAPI_html_'.$random_id.'.style.zIndex = "100";
 WORDPRESAPI_html_'.$random_id.'.style.left = "0px";
 WORDPRESAPI_html_'.$random_id.'.style.top = "0px";
 WORDPRESAPI_html_'.$random_id.'.style.visibility = "hidden";
 WORDPRESAPI_html_'.$random_id.'.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
 WORDPRESAPI_html_'.$random_id.'.innerHTML = "'.addcslashes($DYNAMIC_HTML,"\\\'\"&\n\r<>").'";
 document.body.appendChild(WORDPRESAPI_html_'.$random_id.');';

echo $HTML;

?>

In this code if you observe then following line is very important.

 WORDPRESAPI_html_'.$uniqid.'.innerHTML = "'.addcslashes($HTML,"\\\'\"&\n\r<>").'"; 
How to append html code using javascript and php
How to append html code using javascript and php

Whenever you are using javascript and PHP both together then use following way to push your HTML in Dom.

install php and memcached server on centos5

In this article I given full step by step installation guide about php and memcached . Check full article for install php and memcached server on centos5.

install php and memcached server on centos5

What is Memcached?

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

install php and memcached server on centos5
install php and memcached server on centos5

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

Please use following commands for installtion;
[root@ip-192-168-2-125 wordpressapi]# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-2.noarch.rpm

[root@ip-192-168-2-125 wordpressapi]# yum remove php-common

[root@ip-192-168-2-125 wordpressapi]# yum install php-pdo php-mcrypt squirrelmail php-pecl-apc php-xml php-gd php-devel php php-imap php-pgsql php-pear php-soap php-mbstring php-ldap php-mysql php-cli php-pecl-memcache

[root@ip-192-168-2-125 wordpressapi]# /etc/init.d/memcached restart
Shutting down Distributed memory caching (memcached): [ OK ]
Starting Distributed memory caching (memcached): [ OK ]

[root@ip-192-168-2-125 wordpressapi]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

[root@ip-192-168-2-125 wordpressapi]# vim /etc/php.ini
In php.ini file Please find the “extension=modulename.extension” words
Under that sentance please paste following line:
extension=memcache.so
Note: dont comments that line.

[root@ip-192-168-2-125 wordpressapi]# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@ip-192-168-2-125 wordpressapi]#

CPM, CPI, PPC, CPA, CTR and ECPM in AD serving logic

Many people wondering what is CPM, CPI, PPC, CPA, CTR and ECPM concepts. As I worked on ad serving projects so I created some points these concepts. I worked in to admedia domain for some years. I worked with openx adserver technology. I am going to give you very brief ieda about CPM, CPI, PPC, CPA, CTR and ECPM logics.

CPM, CPI, PPC, CPA, CTR and ECPM in AD serving logic

First I am going to give small description and brief about same.

CPM, CPI, PPC, CPA, CTR and ECPM in AD serving logic
CPM, CPI, PPC, CPA, CTR and ECPM in AD serving logic

CPM – Cost per thousand
CPI – Cost Per Impression
PPC – Pay per click
CPA – Cost Per Action
CTR – Click-through rate
ad serving
Click fraud
Cost Per Click
View-through rate
Clicktag

Breif description is helpful for common people as well as developers.

Impression – Per Page Views( per Page loads)
Click – Per ad click
CTR (Click through rate)
Click-through rate or CTR is a way of measuring the success of an online advertising campaign. A CTR is obtained by dividing the “number of users who clicked on an ad” on a web page by the “number of times the ad was delivered” (impressions).

Formulae:
CTR (%) = (Clicks/Impressions)*100

For example, if a banner ad was delivered 100 times (impressions delivered) and one person clicked on it (clicks recorded), then the resulting CTR would be 1 percent.
CTR (%) = (1/100)*100 = 1%

CPM (Cost Per Thousand Impressions)
The CPM model refers to advertising bought on the basis of impression.
The total price paid in a CPM deal is calculated by multiplying the CPM rate by the number of CPM units.

Formulae:
CPM unit = (Impressions/1000)
Total Price ($) = CPM unit * CPM rate ($)
Per Impression cost ($)= CPM rate ($) / 1000

For example, one million impressions at $10 CPM equals a $10,000 total price.
1,000,000 / 1,000 = 1,000 units
1,000 units X $10 CPM = $10,000 total price

The amount paid per impression is calculated by dividing the CPM by 1000. For example, a $10 CPM equals $.01 per impression.
$10 CPM / 1000 impressions = $0.01 per impression

ECPM (Effective Cost Per Thousand Impressions)
eCPM is calculated by dividing total earnings by total number of impressions in thousands.
It is a great performance measure for your various ad units, so when experimenting, you can use eCPM to compare your results.
Even for smaller sites, eCPM can be a useful statistic to track ad performance.

Formulae:
eCPM = (Total Earnings / Impressions) * 1000
Note : In openx total earnings refers to Rev (Revenue) in statistics

For example, eCPM for 370 page impressions and $1.48 total earnings will be :
eCPM = (Total Earnings / Impressions) * 1000
= ($1.48 / 370 ) * 1000
= $4.00

Reading this article, I think you will be able to catch the CPM, CPI, PPC, CPA, CTR and ECPM concepts

Google’s is creating the Buzz more secure in few more days

On Saturday, the company announced it would change Buzz again, not with regard to profiles (which will apparently continue to be made public, if only to other Buzz users, by default) but rather, followers. As Buzz product manager Todd Jackson wrote, “Starting this week, instead of an auto-follow model in which Buzz automatically sets you up to follow the people you email and chat with most, we’re moving to an auto-suggest model. You won’t be set up to follow anyone until you have reviewed the suggestions and clicked ‘Follow selected people and start using Buzz.'”
GoogleBuzzLogo68
Also over the weekend, Google essentially admitted it was not the best of ideas to assume that items already shared through Picasa and Google Reader, on a local basis, should become automatically shared through Buzz; new users were discovering they were already sharing Picasa photos without ever having given their permission. What we have also yet to see next week is whether Buzz users can still make use of a trick that a security engineer discovered last Friday, to use Picasa to ascertain one’s semi-public Google Profile URL as though it were a fully public one.

A Google spokesperson confirmed to Betanews this afternoon that a second round of privacy changes, the nature of which was revealed last Saturday evening, is still being developed, and may yet go live “in the next couple of days.”

Source Link

how to create rounded corners using css

CSS tutorial, how to create rounded corners using css. We always need the rounded corners for our various web projects. W3C has offered borders in CSS3.

W3C has offered some new options for borders in CSS3, of which one is border-radius. Both Mozila/Firefox and Safari 3 have implemented this function.

how to create rounded corners using css

There are many javascripts are available to create the rounded corner using scripts. But specially recommend use pur css to avoid unnecessary script loading. So many sites uses the background image also, We need to avoid that also.

Following css will give you the rounded corners using only css:

.main_container {background:#ccc; color:#fff; margin:0 15px;}
.wordpressapitop, .wordpressapibottom{
display:block;
background:#fff;
}
.wordpressapitop *, .wordpressapibottom *{
display: block;
height: 1px;
overflow: hidden;
background:#ccc;
}
.wordpressapi1{margin: 0 5px}
.wordpressapi2{margin: 0 3px}
.wordpressapi3{margin: 0 2px}
.wordpressapi4{
margin: 0 1px;
height: 2px
}

Use following code in your html file and you are able to use rounded corners without using the javascript

round-code

How to create rounded corner using css
How to create rounded corner using css

Above script will work on all browsers FF, Chrome, Safari, IE6, IE7, IE8.