Home
About US
Contact US
SiteMap
E-Book
COUNTER
/* hi friends i am back again but this time something most required and wanted by every web site that is a counter which is easy to use and most informative , plus with every new user hitting ur web site u get a confirmation email , just to know that someone is seeing it now ofcource u can upgrade this program to get visitor ipaddress and country . to configure please read the "readme instructions" , advantage with this code is u can plug it to any web site on the net ( javaservlet, jsp, asp , php , perl etc..) , if u have access to it , i wrote it in php but u can do the same in any langauge of ur chose u are comfortable. 01) Step 1 : I assume that u have access to a webserver running php and mysql database [please note: refer http://www.php.net to learn about php and http://www.mysql.com both FREE , FAST , POWERFULL and BEST in open source environment over 3 million sites on net i read somewhere , u can download it and install it easily ] 02) Step 2 : login to MYSQL Database 03) Step 3 : create a database named "counterdb" 14) Step 4 : Edit dbconnection.php file and Edit these lines var $IPADD = "localhost"; //if running on ur pc use 'localhost' else 'ipaddress' //ex (194.215.24.223) var $USER = "databaseusername"; //database username var $PASS = "*********"; //database password var $DBASE = "counterdb"; //database name 04) Step 4 : create table named "mycount" 05) Step 5 : structure is as follows :: CREATE TABLE mycount ( mycntin int(4) NOT NULL auto_increment, mycnt int(4) DEFAULT '0' NOT NULL, mytime varchar(20), PRIMARY KEY (mycntin) ); 06) Step 6 : now make the index.html (home page or start page) file of ur site into frames , one of the frames will call this file "http://www.yourphpmysqlservername.com/directoryname/top.php" and other frame will call ur actual site 07) Step 7 : whenever user visits ur site the program "top.php" gets executed and a)) it registers a hit b)) it sends Emails to u (Administrator) 08) Step 8 : u can check ur email in ur inbox 09) Step 9 : view counter at "http://www.yourphpmysqlservername.com/directoryname/counter.php"" 10) Step 10 : download source code from this zip file here or from http://www.geocities.com/james_smith73/counter.zip 11) Step 11 : view its working on mysite http://www.geocities.com/james_smith73/ by clicking on the link BEST COUNTER */ //Start Database Connection Parameter if (empty($connect) OR $connect!='1') { $connect = include ("dbconnection.php"); } $db = new classname; $db->init(); if (!$db->init()) { echo "Connection Failed"; } // End Database Connection if($fromcounter) { $todaytime= mktime (0,0,0,$month,$day,$year); $dtodaytime =date("d",$todaytime); $mtodaytime =date("m",$todaytime); $Ytodaytime =date("Y",$todaytime); } else { $todaytime=time(); $dtodaytime =date("d",$todaytime); $mtodaytime =date("m",$todaytime); $Ytodaytime =date("Y",$todaytime); } //End Connection class Calendar { function Calendar() { } function getDayNames() { return $this->dayNames; } function setDayNames($names) { $this->dayNames = $names; } function getMonthNames() { return $this->monthNames; } function setMonthNames($names) { $this->monthNames = $names; } function getStartDay() { return $this->startDay; } function setStartDay($day) { $this->startDay = $day; } function getStartMonth() { return $this->startMonth; } function setStartMonth($month) { $this->startMonth = $month; } function getCalendarLink($month, $year) { return ""; } function getDateLink($day, $month, $year) { $link = "counter.php?day=$day&month=$month&year=$year&fromcounter=1"; return "$link"; } function getCurrentMonthView() { $d = getdate(time()); return $this->getMonthView($d["mon"], $d["year"]); } function getCurrentYearView() { $d = getdate(time()); return $this->getYearView($d["year"]); } function getMonthView($month, $year) { return $this->getMonthHTML($month, $year); } function getYearView($year) { return $this->getYearHTML($year); } function getDaysInMonth($month, $year) { if ($month < 1 || $month > 12) { return 0; } $d = $this->daysInMonth[$month - 1]; if ($month == 2) { if ($year%4 == 0) { if ($year%100 == 0) { if ($year%400 == 0) { $d = 29; } } else { $d = 29; } } } return $d; } function getMonthHTML($m, $y, $showYear = 1) { $s = ""; $a = $this->adjustDate($m, $y); $month = $a[0]; $year = $a[1]; $daysInMonth = $this->getDaysInMonth($month, $year); $date = getdate(mktime(12, 0, 0, $month, 1, $year)); $first = $date["wday"]; $monthName = $this->monthNames[$month - 1]; $prev = $this->adjustDate($month - 1, $year); $next = $this->adjustDate($month + 1, $year); if ($showYear == 1) { $prevMonth = $this->getCalendarLink($prev[0], $prev[1]); $nextMonth = $this->getCalendarLink($next[0], $next[1]); } else { $prevMonth = ""; $nextMonth = ""; } $header = $monthName . (($showYear > 0) ? "
" . $year : "
"); $s .= "
\n"; $s .= "
\n"; $s .= "
" . (($prevMonth == "") ? " " : "
<<
") . "
\n"; $s .= "
$header
\n"; $s .= "
" . (($nextMonth == "") ? " " : "
>>
") . "
\n"; $s .= "
\n"; $s .= "
\n"; $s .= "
" . $this->dayNames[($this->startDay)%7] . "
\n"; $s .= "
" . $this->dayNames[($this->startDay+1)%7] . "
\n"; $s .= "
" . $this->dayNames[($this->startDay+2)%7] . "
\n"; $s .= "
" . $this->dayNames[($this->startDay+3)%7] . "
\n"; $s .= "
" . $this->dayNames[($this->startDay+4)%7] . "
\n"; $s .= "
" . $this->dayNames[($this->startDay+5)%7] . "
\n"; $s .= "
" . $this->dayNames[($this->startDay+6)%7] . "
\n"; $s .= "
\n"; $d = $this->startDay + 1 - $first; while ($d > 1) { $d -= 7; } $today = getdate(time()); while ($d <= $daysInMonth) { $s .= "
\n"; for ($i = 0; $i < 7; $i++) { $class = ($year == $today["year"] && $month == $today["mon"] && $d == $today["mday"]) ? "calendarToday" : "calendar"; $s .= "
"; if ($d > 0 && $d <= $daysInMonth) { $link = $this->getDateLink($d, $month, $year); $mtime=mktime(); $dnow=date("d",$mtime); $mnow=date("m",$mtime); if(($dnow==$d) AND ($mnow==$month)) { $s .= (($link == "") ? $d : "
$d
"); } else { $s .= (($link == "") ? $d : "
$d
"); } } else { $s .= " "; } $s .= "
\n"; $d++; } $s .= "
\n"; } $s .= "
\n"; return $s; } /* Generate the HTML for a given year */ function getYearHTML($year) { $s = ""; $prev = $this->getCalendarLink(0, $year - 1); $next = $this->getCalendarLink(0, $year + 1); $s .= "
\n"; $s .= "
"; $s .= "
" . (($prev == "") ? " " : "
<<
") . "
\n"; $s .= "
" . (($this->startMonth > 1) ? $year . " - " . ($year + 1) : $year) ."
\n"; $s .= "
" . (($next == "") ? " " : "
>>
") . "
\n"; $s .= "
\n"; $s .= "
"; $s .= "
" . $this->getMonthHTML(0 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(1 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(2 + $this->startMonth, $year, 0) ."
\n"; $s .= "
\n"; $s .= "
\n"; $s .= "
" . $this->getMonthHTML(3 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(4 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(5 + $this->startMonth, $year, 0) ."
\n"; $s .= "
\n"; $s .= "
\n"; $s .= "
" . $this->getMonthHTML(6 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(7 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(8 + $this->startMonth, $year, 0) ."
\n"; $s .= "
\n"; $s .= "
\n"; $s .= "
" . $this->getMonthHTML(9 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(10 + $this->startMonth, $year, 0) ."
\n"; $s .= "
" . $this->getMonthHTML(11 + $this->startMonth, $year, 0) ."
\n"; $s .= "
\n"; $s .= "
\n"; return $s; } function adjustDate($month, $year) { $a = array(); $a[0] = $month; $a[1] = $year; while ($a[0] > 12) { $a[0] -= 12; $a[1]++; } while ($a[0] <= 0) { $a[0] += 12; $a[1]--; } return $a; } var $startDay = 0; var $startMonth = 1; var $dayNames = array("
Sunday
", "
Monday", "
Tuesday", "
Wednesday", "
Thursday", "
Friday", "
Saturday"); var $monthNames = array("
January
", "
February
", "
March
", "
April
", "
May
", "
June
", "
July
", "
August
", "
September
", "
October
", "
November
", "
December
"); var $daysInMonth = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); } class MyCalendar extends Calendar { function getCalendarLink($month, $year) { $s = getenv('SCRIPT_NAME'); return "$s?month=$month&year=$year"; } } $d = getdate(time()); if ($month == "") { $month = $d["mon"]; } if ($year == "") { $year = $d["year"]; } $cal = new MyCalendar; echo $cal->getMonthView($month, $year); print("
"); $qry="SELECT * FROM mycount"; $result=mysql_query($qry); $num=mysql_num_rows($result); $count=0; echo "
Sl No
Date
Time
"; if($row=mysql_fetch_array($result)) { do { $mycnt=$row['mycnt']; $mytime=$row['mytime']; $dshowtime = date("d",$mytime); $mshowtime = date("m",$mytime); $Yshowtime = date("Y",$mytime); $showtimenow1 = date("D dS, F Y ",$mytime); $showtimenow2 = date("g:i a",$mytime); if(($dshowtime==$dtodaytime) AND ($mshowtime==$mtodaytime) AND ($Yshowtime==$Ytodaytime)) { echo "
Hit Number $mycnt
$showtimenow1
$showtimenow2
"; $count++; } } while($row=mysql_fetch_array($result)); } echo "
Number of hits Today :
$count
Number of hits Totally :
$num
"; ?>
1
HTML MAIL
2
COUNTER
3
DATA BASE CONNECTION
4
FILE UPLOA D MANAGER
www.balujalabs.com
www.
tutorjugaad
.com
www.delhisikhmatrimonial.com
www.ignoujugaad.com
Privacy policy
Copy right © balujalabs.com All Right