if (!empty($_SERVER['HTTP_CLIENT_IP']))
$ip=$_SERVER['HTTP_CLIENT_IP'];
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
else
$ip=$_SERVER['REMOTE_ADDR'];
?>
Most Ajax pages are not SEO friendly, so the natural question is how to implement this in ZK. You can learn that on https://webchimpy.com. The question is also applies if your ZK application works using a Bookmark mechanism. You can implement SEO in an easy manner following these two steps. Best to find out more
Here is the whole ZK SEO-Workflow
We create a SEODesktopInit to receive the bookmark changed event which is fired by customized Javascript we provided in the zk.xml. You can store the bookmark mapping information to where you want (like a Database), in this case, we store them in a static HashMap object. We implement the SEORenderer interface to render the related links for the SEO spider. For good link building services you can see here to get help. Once the spider visits the link, the SEOComposer will handle the request and post a bookmark change event. On bookmark charge the relevant page will be created. This page is exactly the same as visiting from a bookmark url (i.e. zksandbox/userguide/#f1)
Steps
1. Copy the following Javascript code into your zk.xml.
For example,
ajax
2. Specify the following setting in your zk.xml.
For example,
For bookmark SEOSEODesktopInitSEOComposerorg.zkoss.zk.ui.sys.SEORenderer.classSEORenderer
Note: the preference of “org.zkoss.zk.ui.sys.SEORenderer.class” is applicable to ZK 5.0.6 version.
Here are the implementations:
1.SEODesktopInit.java
public class SEODesktopInit implements org.zkoss.zk.ui.util.DesktopInit {
public static Map SEOMap = new HashMap();
public void init(final Desktop desktop, Object request) throws Exception {
desktop.addListener(new AuService() {
public boolean service(AuRequest request, boolean everError) {
final String cmd = request.getCommand();
if (cmd.equals("onBookmarkSEO")) {
String name = (String) request.getData().get("nm");
String uri = (String) request.getData().get("uri");
SEOMap.put(name, uri);
return true;
} else return false;
}
});
}
}
2.SEORenderer.java
public class SEORenderer implements org.zkoss.zk.ui.sys.SEORenderer {
public void render(Page page, Writer out) throws IOException {
for (Iterator it = SEODesktopInit.SEOMap.entrySet().iterator(); it.hasNext();) {
Map.Entry me = (Map.Entry)it.next();
String url = Executions.encodeURL("/" + me.getValue());
if (url.indexOf("?bk=") >= 0) {
int start = url.indexOf("?bk=");
int end = url.indexOf("&", start + 4);
url = url.substring(0, start) + "?bk=" + me.getKey() + url.substring(end + 1, url.length());
} else if (url.indexOf("&bk=") >= 0) {
int start = url.indexOf("&bk=");
int end = url.indexOf("&", start + 4);
url = url.substring(0, start) + "&bk=" + me.getKey() + url.substring(end + 1, url.length());
} else {
if (url.indexOf("?") >=0) {
url += "&bk=" + me.getKey();
} else {
url += "?bk=" + me.getKey();
}
}
out.write(""+me.getKey()+"");
}
}
}
3.SEOComposer.java
public class SEOComposer implements Composer {
public void doAfterCompose(Component comp) throws Exception {
// only handle once.
Object seo = comp.getDesktop().getAttribute("SEO");
if (seo == null) {
String name = Executions.getCurrent().getParameter("bk");
if (!Strings.isEmpty(name)) {
Events.postEvent(new BookmarkEvent("onBookmarkChange", name));
comp.getDesktop().setAttribute("SEO", Boolean.TRUE);
}
}
}
}
Question: How to integrate the new Ajax bookmark crawling method with Google
The question is how do we integrate the mechanism (#!) with Google’s described methodology from Google’s the tutorial . The answer is to modify the SEOComposer.java to recognize the request parameter that Google passed and post a onBookmarkChange event for ZK.
I am writing from Cusco Peru, I have my website http://www.porcelltoursperu.com and I would like to make the seo,but here the people who work in this they say it is a little difficult to make the positioning of my website because they don´t know how it was made, etc, they only work with html format, so please tell me if you can make the positioning, if you do that, i will be very pleased to work with you.or please give me some details to put my website in internet to sell my tours.
Hello,
I am writing from Cusco Peru, I have my website http://www.porcelltoursperu.com and I would like to make the seo,but here the people who work in this they say it is a little difficult to make the positioning of my website because they don´t know how it was made, etc, they only work with html format, so please tell me if you can make the positioning, if you do that, i will be very pleased to work with you.or please give me some details to put my website in internet to sell my tours.
Thanks for your prompt reply.
Regards.
Rene Porcel