what is my ip?

Sometimes you need to know what your external IP (internet protocol) address is. Whether just to know or a part of maintenance. Well, I need it sometimes to check whether I’m being blocked by any website or not. I made a list of how to check our external IP address, check it out!

1. Google Search

The simplest way to check your IP is by doing a Google Search with this keywords : “what is my IP”.

Google will give you your IP address like this: Your public IP address is 202.93.37.81.

Since most of the latest browser available has the ability to do search operation using search bar, or even searching right from the address bar, it will be so easy for you.

2. Web Service

If you don’t have much time to type the phrase “what is my IP”, you might want to bookmark one of the websites below and put it on your bookmark toolbar, so all you have to do is to click the bookmark and wait till the page loaded.

  • www.whatismyip.com
  • www.whatismyipaddress.com
  • www.whatsmyip.org
  • www.ip-address.org

and lot more websites out there with same functionality. What a waste -__-"

3. PHP code

Or if you’re sick of useless page contents of those websites and only need to know your IP address real quick, you may code your own PHP script and put it on your website. Here’s the code:

<?
if (!empty($_SERVER[‘HTTP_CLIENT_IP’]))   //check ip from share internet
    {
      $ip=$_SERVER[‘HTTP_CLIENT_IP’];
    }
    elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’]))   //to check ip is pass from proxy
    {
      $ip=$_SERVER[‘HTTP_X_FORWARDED_FOR’];
    }
    else
    {
      $ip=$_SERVER[‘REMOTE_ADDR’];
    }
echo $ip;
?>

Copy the code above, paste it on notepad, and then save it as a .php file (eg. myip.php) and upload it to your web server, so you can access it like this: www.yourwebsite.com/myip.php .

One example of the live site that will give you only your IP address is : http://www.whatismyip.org.

redesigning my homepage

Nowadays personal branding is getting more important. That’s why I will redesign my homepage (http://andisetiawan.com).

I will make it more interactive, more fresh, and I will add more features so visitors can interact directly from the homepage.

Let see the result in next few days.

On Going Project: BKOL

I’m currently working a new project from 2 weeks ago. It hasn’t finished yet because I don’t have much time to code lately. The name is BKOL, stand for “Bursa Kerja OnLine”, ordered by a friend of my last client. They told her (their friend) that I helped them to work on their project, so she interested in my skill and asked me to complete her project.

The script is a web application where user can register as User or Publisher. Publisher is a kind of user who can post vacant position in their company and User is the one who is seeking for a job and can browse available jobs based on their criteria.

 

The thing made the script special for me is that the script uses Gammu. It means one of the feature is SMS center. So people can register to the site by sending an SMS. That’s cool! User can get information of available job vacancies thru SMS.

The script is 40% finished now. Need much more ideas to develop the script. And it will take much times since She has to consult the project with her Lecturer about the development.

Sitemap for andiim3.com

Today I created a sitemap for andiim3.com, I took my blog’s sitemap as the example. So if you open the sitemap, you’ll find it weird remembering my site is using custom script without any WordPress engine at all.

The script written in PHP and store the data to sitemap.xml, well, actually I can just submit the script’s URL to Google (http://andiim3.com/sitemap.php), but the other search engine will not find it. So  I use the sitemap.xml instead. I set the script to run every one hour, so Google will love my site.. Smile

I’ve submitted the sitemap to Google Websmaster Tool, so Google could know if there something new in my website.

You can see the live sitemap here: http://andiim3.com/sitemap.xml .

If you need the sample of the script, please contact me Open-mouthed smile

Deleting error_log automatically

I’ve been noticed by my hosting disk space warning, the indicator bar was red. Why? Oh, the disk space was decreased automatically because the error_log is growing up every my scripts executed. So, I have to delete it every time it’s growing up.

Why?

Why error_log appear automatically in my hosting directories? it is because the hosting guy has turned on the error logging, so the error on the php script won’t be displayed when it’s executed, but store the error string into a file named “error_log”.

Why there’s so many of them? Because most of the directories on my hosting has a PHP script inside it.

Why the size of them are so big for a file? Well, frankly, there are some error inside the PHP engine used by my hosting server and it is not fixed yet until now. Unfortunately, every time a script executed, the size of error_log will grow up. Even when you deleted the file, the file will remain growing up every your site loaded. So, it is important to inspect your directories, and delete error_log frequently.

How?

The first thing I’ve done is by deleting it manually, but it will waste your time. So I created a script to do that automatically, the script also collect the size of total error_log detected.

When?

I set the script to run once every day, you can do that by utilizing “cron job” in the cPanel (see documentation)

Here’s a sample of simple PHP cron Job:

/usr/local/bin/php -f /home/(username)/public_html/(scriptname).php

Who?

Of course I am the person who code this script, but you can do that too by using my script,.

Just copy my script in your root directory, then run it on your browser, or run it automatically thru Cron Job.

Demo

See the demo here: http://otakbali.com/hapuserror.php 

The Script

Copy and paste the script bellow to a PHP script. Or download it here.

<?php
// set the time limit first, remember, if you have 
// a huge number of files, it will be useful
set_time_limit(36000);
$dir = "./";
$num=0;
$bytes=0;
$deleted=0;
$bytesdel=0;
$echo="";
 
echo "Looking for <b>error_log</b> in every directories <br/>";
 
buka($dir);
 
$bytes=format_bytes($bytes);
$bytesdel=format_bytes($bytesdel);
echo "Found $num error_log files ($bytes), 
and deleted $deleted ($bytesdel) files."
;
echo "<hr/> <ol>$echo</ol>";
 
 
// below are the functions, modify it on your risk
 
 
// open directory, search error_log, delete it
function buka($dir){
  global $num, $deleted, $bytes, $bytesdel, $echo;
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
           if(($file!=".") and ($file!="..")){
              
              // cek sub dir,
              if($dir=="./"){
                $cek=$file;
              } else {                
                $cek="$dir/$file";
              }
              $type=filetype($cek);
              if($type=="dir"){
                
                // kalo tipenya dir, buka..
                buka($cek);
                
                } else {
              
                // cek file error_log
                if($file=="error_log"){
                  // jumlah yg ketemu
                  $num=$num+1;
                  $ukuran=filesize($dir."/".$file);
                  $bytes=$bytes+$ukuran;
                  $ukurannya=format_bytes($ukuran);
                  if($dir=="./"){
                    $filenya=$file;
                  } else {                
                    $filenya="$dir/$file";
                  }
                  
                  $echo.="<li>$filenya ($ukurannya ) </li>";
                  //kalo ketemu, delete
                  $del=unlink($filenya);
                  //kalo deleted, naikkan value $num
                  if($del){
                    $deleted=$deleted+1;
                    $bytesdel=$bytesdel+$ukuran;
                   }
                }
              }              
           }
       }
       closedir($dh);
   }
}
 
}// end function
 
function format_bytes($bytes) {
   if ($bytes < 1024) return $bytes.' B';
   elseif ($bytes < 1048576) return round($bytes / 1024, 2).' KB';
   elseif ($bytes < 1073741824) return round($bytes / 1048576, 2).' MB';
   elseif ($bytes < 1099511627776) return round($bytes / 1073741824, 2).' GB';
   else return round($bytes / 1099511627776, 2).' TB';
}
?>