Personal, Tips & Trick

Three days ago arvixe telling my site using to much their cpu usage. They complaint about wp-cron.php and index.php process which I believe it was looping and won’t stop in background. wp-cron is just like cron job in normal condition. The crazy thing everyone doesn’t know is, it’s loading each time visitors coming to their site. I don’t know why wordpress don’t fix it or at least give options to run it each time frame.

For a site using wordpress and have a lot articles/pages the optimization for it is just disable wp-cron, another option is disable wp-cron and running cron job from cpanel which can be setup in time frame.

You will lose schedulle post feature but it’s better than get suspended right? You still can run cron in time frame you setup from cron job panel than using crazy method like spawn it each time visitors coming to your site. Let’s do this thing, it’s very easy…


  1. Open your wp-config.php and put this after the <?php. define(‘DISABLE_WP_CRON’, true);
  2. Open wp-includes folder and find a file with name cron.php
  3. Find string “function wp_cron() {
  4. Replace all function with code below :
    function wp_cron()
    {// Prevent infinite loops caused by lack of wp-cron.php
    if ( strpos($_SERVER[‘REQUEST_URI’], ‘/wp-cron.php’) !== false || ( defined(‘DISABLE_WP_CRON’) && DISABLE_WP_CRON ) )
    return;if ( false === $crons = _get_cron_array() )
    return;$local_time = time();
    $keys = array_keys( $crons );
    if ( isset($keys[0]) && $keys[0] > $local_time )
    return;$schedules = wp_get_schedules();
    foreach ( $crons as $timestamp => $cronhooks ) {
    if ( $timestamp > $local_time ) break;
    foreach ( (array) $cronhooks as $hook => $args ) {
    if ( isset($schedules[$hook][‘callback’]) && !call_user_func( $schedules[$hook][‘callback’] ) )
    // spawn_cron( $local_time );
    break 2;
  5. Save it/replace cron.php file with the new edited cron.php
  6. Done

After doing this your wp-cron has been disabled and never ever run each time a visitors coming to your site. But you will lose schedulle post, to fix this problem open your hosting control panel and set cron job from there to run your wp-cron.php. You can set it run each 24 hours or in time frame you need.

After doing this small optimization arvixe not complaint to me. It’s mean this is maybe the big issue for worpdress to update their cron setting.

That’s a share for today, have a great day everyone, and Happy New Year! 😀


    Digg StumbleUpon Reddit Twitter RSS
Computer And Internet, Miscellaneous

This stupid idea come into my head when I analyze the most keywords coming to one of my lyrics site. Mostly people coming to my site with a relevant keyword, example: song title and artist name. I need something to make an interactive place for them to keep them coming back. I was thinking about an video preview and it ended with related video idea.

On this short articles I will share the way to created youtube related video using combination of PHP and javascript (using wordpress as CMS, of course you can edit it to fit your site). This feature will fits for mp3 sites or reviews related site which may need related video to give more information to visitors.

First we will need this javascript code:

function ytlist(data) {
var feed = data.feed;
var entries = feed.entry || [];
var html = [‘<ul class=”yt-related”>’];
for (var i = 0; i < entries.length; i++) {
var entry = entries[i];
var thumbnailUrl = entries[i].media$$thumbnail[0].url;
var playerUrl = entries[i].media$$content[0].url;
html.push(‘<li onclick=”loadVideo(\”, playerUrl, ‘\’, true)”>’, ‘<img src=”‘, thumbnailUrl, ‘” width=”130″ height=”90″/>’, ‘</span></li>’);
html.push(‘</ul><br style=”clear: left;”/>’);
document.getElementById(‘ytlist’).innerHTML = html.join(”);
if (entries.length > 0) {
loadVideo(entries[0].media$$content[0].url, false);
function loadVideo(playerUrl, autoplay) {
var atts = {
id: ‘ytbox’
swfobject.embedSWF(playerUrl + ‘&fs=1&enablejsapi=1&autoplay=’ + (autoplay ? 1 : 0), ‘player’, ‘500’, ‘300’, ‘9.0.0’, false, false, {
allowfullscreen: ‘true’
}, {
allowscriptaccess: ‘always’
function setVisibility(id, visibility) {
document.getElementById(id).style.display = visibility;


Save it as yt.js or get it directly from here yt.js upload it into the right place (in this sample I used wordpress so I put it into themes folder). Next in your header site put this code before </head> tag

<script type=”text/javascript” src=”http://YOURDOMAIN/PATH/yt.js”></script>
<script type=”text/javascript” src=””></script>

After this done create CSS file or add this code bellow if you’re already have the CSS file.

.close a{color:#111} li{cursor:pointer;float:left;list-style:none;margin:5px;width:130px}{margin-bottom:10px;margin-top:10px}

Last step is just put this code in area where you want related video shown. Because in this sample I used wordpress I put this code on single.php and using <?php the_title(); ?> as the keyword for related video (you can change this to anything you like).

<div id=”yt”> <h4>Video Terkait Tentang <?php the_title(); ?></h4>
<div id=”ytbox”>
<div class=”close”
onclick=”setVisibility(‘ytbox’, ‘none’);”>
<center><a href=”javascript:void(0)”>Selesai Menonton</a></center>
<object id=”player”></object>
<div id=”ytlist” onclick=”setVisibility(‘ytbox’, ‘block’);”>
<center><script type=”text/javascript”
src=”<?php the_title(); ?>&alt=json-in-script&callback=ytlist&max-results=4&format=5″>
<div id=”yt”> <h4>Video Terkait Tentang <?php the_title(); ?></h4>
<div id=”ytbox”>
<div class=”close”
onclick=”setVisibility(‘ytbox’, ‘none’);”>
<center><a href=”javascript:void(0)”>Selesai Menonton</a></center>
<object id=”player”></object>
<div id=”ytlist” onclick=”setVisibility(‘ytbox’, ‘block’);”>
<center><script type=”text/javascript”
src=”<?php the_title(); ?>&alt=json-in-script&callback=ytlist&max-results=4&format=5“>

The result will be like this sample:

You can check the live sample in here Try opening another post and check the related video it will automatically searching related video on youtube using post title as keyword.

Have problem to integrate? don’t be shy to asking as long I’m not busy I will help. That’s share for today, Have a nice day 🙂

    Digg StumbleUpon Reddit Twitter RSS
Computer And Internet, Personal, Tips & Trick

In this short articles we will learn how to automatically repair and optimize our database using Cron Job. Cron Job is most likely scheduler, mean it will run automatically after we setup it. I believe not many of us know how to using this features, We can use it to run periodically some PHP script we made. Example a sitemap generator script which may consume to many resource if we run it manually, we can set it run in schedule follow settings on Cron Job.

In this short articles I will give sample how we can use Cron Job to repair and optimize database automatically. Sometimes when you open your database using PHPmyadmin you may see some database corrupt. We need to repair it manually and optimize it then our database will run smoothly again, the impact is our website will run faster. The problem are when we have not much time on focus on this problem, or we manage to much database which may make us frustrating to work on it manually.

Alright enough for the bad explanation, here is a sample how to use Cron Job. First we need to coding some PHP script to follow what we need. In this sample I created an PHP script to repair and optimize my database.

mysql_connect(“localhost“, “DBUSER“, “DBPASS“) or die(mysql_error());
mysql_select_db(“DBNAME“) or die(mysql_error());
mysql_query(“REPAIR TABLE `TABLE1`, `TABLE2`, `TABLE3`”);
mysql_query(“OPTIMIZE TABLE `TABLE1`, `TABLE2`, `TABLE3`”);

I assume all of you already understand the code so let’s continue this articles. This sample script will repair and optimize our database when we open it via web browser. Next, we need to add it to cron job to run it follows the settings we made, so we don’t need to open it manually to repair and optimize database.


From your hosting cPanel, Click on Cron Job, Next choose the setting for run this job, you can choose common settings:

Next in command form type your/php/bin -q /your/path/to/file.php you need to know your php bin and your real path to file. It should works if you’re not set it wrong.

Cron job also can be used for another automation works. Example: backup your files periodically, backup your database periodically, generate your sitemap periodically, etc. All you need is coding that PHP code first then setup the cron job.

That share for today, Have a nice day 🙂

    Digg StumbleUpon Reddit Twitter RSS
Computer And Internet, Miscellaneous, Online Business, Personal, Tips & Trick

If we are using wordpress we can easily using plugin to make switch button between desktop version or mobile version for our blog. Question is how if we’re not using wordpress or we already using another CMS which not contain mobile device detection or we want to build it from zero. In this short articles I will write some technique to detecting mobile device or desktop device.

Google really inspired my creativity after they allowed my country language showing ads in mobile version. There is 2 version ads which it’s only shown for Android or iPhone and another one is for all mobile device. I want to target the ad to maximize my revenue so I looking a better way to detecting mobile device.

After searching yesterday I found one interesting project it was php-mobile-detect. Actually it PHP class to detecting all mobile device and some high-end device ex: android iphone, etc You can download php mobile detec class from here, open it, you may change something on there is you know about mobile device.


Next, how to using this class. It’s very simple because they already documented it. First upload php mobile detect class and then created some php files with content like this:

$detect = new Mobile_Detect();

After that there is 7 device you can detect using this class… isAndroid(), isBlackberry(), isOpera(), isPalm(), isWindows(), isGeneric(), and isMobile.() Next, If I want to shown ad only for android phone then I just created php script with content like this sample:

if ($detect->isAndroid()) {
// code to run for the Google Android platform

There is something missing on here, as we can see there is no detector for isDesktop() version. Don’t worry we can tricky it using some declaration. There is detector for isMobile() so we will using this variable. The sample code:

if (($detect->isMobile()) == false) {
// code to run for the desktop version

That’s it! now we can sepearated users based on their device 🙂 and we can target ad to shown only for device required. This script was tested on my small project today, you can visited by click this. It’s not done yet but it’s already detecting what device you’re using to access it. Be creative, use your imagination to make a better coding!

That’s it, Have a nice day everyone! 🙂

    Digg StumbleUpon Reddit Twitter RSS
Make Money Online, Personal, Tips & Trick

Hello everyone, In this short articles I will write about possibilities to monetize mobile site and how to integrate admob code into wordpress mobile site. In this short articles I used wodpress as desktop web engine and wp-mobile-pack plugin as mobile web engine. In the past articles on my blog we already know and learn about AdMob as alternative way to monetize mobile site, admob rank become better and legit after google purchase them so don’t worry about their reputation. For wp-mobile-pack you need to learn my past articles how to doing a small modification that will affect your SEO.

I’m assumed all of you already understand it so let’s get started. First we need to register on admob. Once we registered on admob we need to add mobile site/app. Honestly, I don’t like an category in admob which it’s to small for me (personally). Hope google read this articles and expand their categories. At the moment you can choose this category:


There is another option too add site/app. Not only mobile site there is Smartphone site , Android app, Iphone app, etc. You can choose which one best fit for your needs.

Once you add site/app into your admob account you will received an code from adbom. In this sample I used PHP (curl) code to implement it into wp mobile pack. Copy the php code admob provide and then save it with any name as you like ex: admob.php

Next, open your FTP programs and connect into your host, go to folder ..(may vary path)../wp-content/themes/mobile_pack_base/ and put your admob.php file on that folder.

Next We will try to attach this admob.php into wp mobile theme. You can customize it to shown in every place you like. Example you want to show it in header edit your header.php (in themes/mobile_pack_base/) and copy this code:

include ‘admob.php’;
echo admob_request($admob_params);

Last step, try it from your smartphone. If you see an test html admob ad then you just success integrate admob. Just focus on your content and let admob handle the ad and monetizing your mobile site.

*tested with motorola phone, windows mobile 5 and windows mobile 6.1 using opera mini and internet explorer.

That’s my share for today, hope everyone have a nice day 🙂

    Digg StumbleUpon Reddit Twitter RSS