Friday, November 30, 2012

Number of Users Online script in PHP

Sometime our clients demand for showing how many visitors are online currently on their website. This can be done by many ways. I am going to illustrate two methods of doing this. One is file based and other one is database based. Let us see how to achieve this by both methods one by one.

1) File Based Method:

In this method PHP script writes online visitors information in a text file. That text file is updated after a specific interval of time and script reads that file and show a counter of online visitors where required. Let us see the details of this method step by step,

Step 1) First of all you have to create a .txt file and place it on any folder in your server. In my case I am creating this file on root folder of my website and naming it ip.txt. After updating this file by code, it looks something like this,

127.0.0.1****1354262381++++
127.0.0.1****1354262381++++
127.0.0.1****1354262381++++

Step 2):Then copy and paste the code below where you want to show that counter,

<php
    $url = $_SERVER['SCRIPT_FILENAME'];
    $pp = strrpos($url,"/");
    $url = substr($url,0,$pp);
    $ura = $_SERVER['SCRIPT_NAME'];
    $host = $_SERVER['SERVER_NAME'];
    $ser = "http://$host";
    $ura= $ser.$ura; 
    $pp1 = strrpos($ura,"/");
    $ura = substr($ura,0,$pp1);
    $url1=explode('/', $url);
    $url=array_pop($url1);
    $url1=implode('/', $url1);
    $ura1=explode('/', $ura);
    $ura=array_pop($ura1);
    $ura1=implode('/', $ura1);

    $hm = "$url1"; 
    $hm2 = "$ura1"; 
    include "onlinevisitors.php";
?>


Step 3):  Next step is to create a file named onlinevisitors.php file and place in the folder where you included it in above code. In our case root folder,


<?php
$rip = $_SERVER['REMOTE_ADDR'];
$sd  = time();
$count = 1;

$file1 = "ip.txt";
$lines = file($file1);
$line2 = "";

foreach ($lines as $line_num => $line)
{
 //echo $line."";
 $fp = strpos($line,'****');
 $nam = substr($line,0,$fp);
 $sp = strpos($line,'++++');
 $val = substr($line,$fp+4,$sp-($fp+4));
 $diff = $sd-$val;
 if($diff < 300 && $nam != $rip)
 {
  $count = $count+1;
  $line2 = $line2.$line;
  //echo $line2;
 }
}

$my = $rip."****".$sd."++++\n";
$open1 = fopen($file1, "w");
fwrite($open1,"$line2");
fwrite($open1,"$my");
fclose($open1);

echo "<table width=180 height=30 bgcolor=#fdfdfd style=\"border: 1px green solid;\"><tr><td align=left valign=top>";
echo "</td><td align=center>";
echo "<span style=\"font-family: verdana,arial,helvetica; font-size: 11px; font-weight: bold; color: #aaccaa;\">";
echo "Total users online - <font color=red>$count</font></span><br>";
echo "</td></tr></table>";
?>

2) Database Driven Method:

comming soon...

Wednesday, November 14, 2012

Which Web Programming language to learn to keep you employed?

There are thousands of programming languages out there and have their own value over one and other. But there are a few programming languages which can keep you employed and you don't have to worry about earnings. Learning a right programming language on right time and right place is very necessary for your carrier. There are many examples out there who are not happy with their field and struggling in the market due to this fact. That's why I am going to share with my blog readers about the best programming languages and their scope in different areas of the world.
  • PHP
  • MySQL
  • Javascript
  • Perl
  • Ruby
  • Python
  • ASP.net

Tuesday, November 13, 2012

How to increase PTCL EVO signals

PTCL EVO is one of the best source of wireless internet connectivity and it offers coverage in more than 250 cities in pakistan nationwide. But sometimes eVo customers are returning their devices within 3 days because of dis-satisfaction or no signals at there homes or offices. So i thought there should be some method to strengthen the eVo signals so that customers can enjoy the great internet service out there.

Friday, November 9, 2012

What is radiotherapy treatment?

As x-Rays have been discovered almost 10 years ago and these are being used in medical science. These are used for the diagnosis purpose as well as for the treatment such as radiotherapy. There are two types of radiotherapy,

1. External radiotherapy

2. Internal radiotherapy

External radiotherapy is for external body and internal radiotherapy is used for internal body parts. Radiotherapy is actually used to distroye cancel cells but it may damage normal cells as well. But fortunately normal cells can repair themselves later on.

List of TOP 60 Insurance Companies in Pakistan

Tips on Accessing DSL Router, Modem or CPE

We are going to discuss that how can we access the DSL Modem, Router or CPE to put the internet settings and to configure it.

By following theses simple steps we can access the CPE and establish a connection to internet.

Keep reading this post for complete guide.

Connect the CPE to the Computer:

  1. Connect the Power Adapter to the AC power plug and attach the connector of adapter to the CPE and switch it on.
  2. Attach one end of LAN wire (RJ-45) to the LAN interface of CPE and the other end to the LAN wire to the LAN interface of computer’s LAN card.
  3. Link Indicator lights will lit up and show the connectivity.
DSL Configuration in CPE and Computer:
  1. Go to Start Menu > Control Panel > Network and Internet Connections > Network Connections. Check that the Local Area Connection is enabled. Right click local Area network and click properties.
  2. Double click “internet protocol (TCP/IP)”, Check “Use the following IP address” and make the following settings:
  3. IP Address: 192.168.1.5
  4. Subnet Mask: 255.255.255.0
  5. Gateway: 192.168.1.1
  6. Then, check “Obtain DNS server addresses automatically” and click "OK" to apply these settings.
Now open Internet Explorer and type “192.168.1.1” in address bar and press enter. There must not be any proxy setting in the internet Explorer.

A small pop up window will open as shown in the figure below and ask ”User Name” and “Password” for opening the CPE’s interface.

Enter User Name: “admin” and Password: “admin” and press OK.


You can read this http://our-knowledge-base.blogspot.com/2012/11/how-to-do-ptcl-dsl-modem-and-router.html to learn how to do router settings.

Thursday, November 8, 2012

Techniques of Adding New Widget Sections In Blogger On Different Places?

Adding new widget sections in blogger template is very easy task to do. There are many posts about this topic on the internet but those are very lengthy to read. Purpose of my post is to clear the concept.

If you want to add a widget which should be shown on home page of your blogspot blog then you have to follow these steps.

Step # 1. Go to templates section of your blog and click on html Editor.

Step # 2. Now decide where you want to add new widget section.

Step # 3. And past below code and save.

<b:if cond='data:blog.url == data:blog.homepageUrl'>
<b:section class='sidebar' id='magazine-left' showaddelement='yes' >
<b:widget id='Text51' locked='false' title='Test Title 1' type='Text'/> 
</b:section> </b:if>

If you want to add a widget which should be displayed on every page of your blog then you have to past below code in the corresponding area and save the template. All other steps will remain same.

<b:section class='sidebar' id='magazine-left' showaddelement='yes' >
<b:widget id='Text51' locked='false' title='Test Title 1' type='Text'/>
</b:section>

How to do PTCL DSL Modem and Router configuration

Hi guys, today i am going to share with you the most important and useful information regarding PTCL DSL modem configuration. This is a common problem that our internet stops working and we have no knowledge about what to do. There are two methods of configuring PTCL DSL router.


1. Call 1236 Helpline:

One method id to call 1236 PTCL line anf ask them, they should configure you DSL modem remotely and the other method is to configure you modem manually.


2. Manual Method:

2nd method is to do manual configuration. First of all open Internet Explorer and write “192.168.1.1” in address bar and press enter. There must not be any proxy setting in the internet Explorer. This will open a login window and will ask for username and password to access the router console. The default username and password for router is admin/admin. So write admin in username box and admin in password box and click on login button.

How to access router using browser can be found in this post http://our-knowledge-base.blogspot.com/2012/11/how-to-do-ptcl-dsl-modem-and-router.html