irdavidnet
Banned
سلام .
من یه آمارگیر قاطی کردم ، مخلوطی از خودم و پارسی پی اچ پی (که از نسیم بلاگ کپی شده) ، شده این ، من تکمیلش کردم و کمی حرفه ای ترش کردم ، اگه توش مشکلی داره بگید ، یا اگه امکانات دیگه ای به نظرتون می رسه مطرح کنید .
این فایل Counter.php بود و این هم تیبلش
اگه از این اسکریپت استفاده می کنید ، بزنید که من نوشتم ، خیلی تغییرش دادم تا درست و دقیق شه .
خواهشاً بزنید کپی رایت : داود مظفری و لینک بدید به سایت : iroveb.com
من یه آمارگیر قاطی کردم ، مخلوطی از خودم و پارسی پی اچ پی (که از نسیم بلاگ کپی شده) ، شده این ، من تکمیلش کردم و کمی حرفه ای ترش کردم ، اگه توش مشکلی داره بگید ، یا اگه امکانات دیگه ای به نظرتون می رسه مطرح کنید .
PHP:
<?
include_once('db.php');
function update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $date , $nweek,$lweek)
{
global $conn;
$Query = sprintf( "UPDATE counter".( " SET counter_today='".$today."', counter_yesterday='{$yesterday}',
counter_thismonth='{$thismounth}', counter_lastmonth='{$lastmounth}', counter_thisyear='{$thisyear}',
counter_lastyear='{$lastyear}', counter_total='{$total}', counter_date='{$date}',
counter_thisweek='{$nweek}' , counter_lastweek='{$lweek}'" ) );
if ( !( $result = mysql_query( $Query, $conn ) ) )
{
exit( mysql_error( ) );
}
}
$Query = "SELECT * FROM counter";
$result = mysql_query( $Query, $conn );
$RowCounter = @mysql_fetch_array( $result );
$yesterday = $RowCounter['counter_yesterday'];
$today = $RowCounter['counter_today'];
$lastmounth = $RowCounter['counter_lastmonth'];
$thismounth = $RowCounter['counter_thismonth'];
$lastyear = $RowCounter['counter_lastyear'];
$thisyear = $RowCounter['counter_thisyear'];
$thisweek = $RowCounter['counter_thisweek'];
$lastweek = $RowCounter['counter_lastweek'];
$total = $RowCounter['counter_total'];
$date = $RowCounter['counter_date'];
list( $year, $month, $day , $week) = split( "-", $RowCounter['counter_date'] );
list( $CurrentYear, $CurrentMonth, $CurrentDay ,$CurrentWeek) = split( "-", date( "Y-m-d-W" ) );
$CurrentDate = date( "Y-m-d-W" );
++$total;
if ( $CurrentYear == $year )
{
if ( $CurrentMonth == $month )
{
if ($CurrentWeek == $week){
if ( $CurrentDay == $day )
{
++$today;
++$thismounth;
++$thisyear;
++$thisweek;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate , $thisweek , $lastweek);
}
if ( $CurrentDay == ++$day )
{
$yesterday = $today;
$today = 1;
++$thismounth;
++$thisyear;
++$thisweek;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate, $thisweek , $lastweek);
}
if ($CurrentDay == $day+2 || $CurrentDay == $day+3 || $CurrentDay == $day+4 || $CurrentDay == $day+5 || $CurrentDay==$day+6){
$yesterday = 0;
$today = 1;
++$thismounth;
++$thisyear;
++$thisweek;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate, $thisweek , $lastweek);
}
if ($CurrentDay == $day+7){
$yesterday = 0;
$today = 1;
++$thismounth;
++$thisyear;
$lastweek=$thisweek;
$thisweek=1;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate, $thisweek , $lastweek);
}
}
if ($CurrentWeek==++$week){
$lastweek= $thisweek;
$thisweek=1;
++$thismounth;
++$thisyear;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate ,$thisweek , $lastweek);
}
if ($CurrentWeek == $week+2 || $CurrentWeek == $week+3){
$lastweek= 0;
$thisweek=1;
++$thismounth;
++$thisyear;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate ,$thisweek , $lastweek);
}
if ($CurrentWeek == $week+4){
$lastweek= 0;
$thisweek=1;
$thismounth=$lastmounth;
$thismounth=1;
++$thisyear;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate ,$thisweek , $lastweek);
}
}
if ( $CurrentMonth == ++$month )
{
$lastmounth = $thismounth;
$thismounth = 1;
++$thisweek;
++$today;
++$thisyear;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate, $thisweek , $lastweek);
}
if ($CurrentMonth == $month+2 || $CurrentMonth == $month+3 || $CurrentMonth == $month+4 || $CurrentMonth == $month+5 || $CurrentMonth == $month+6 ||
$CurrentMonth == $month+7 || $CurrentMonth == $month+8 || $CurrentMonth == $month+9 || $CurrentMonth == $month+10 || $CurrentMonth == $month+11)
{
$lastmounth = 0;
$thismounth = 1;
++$thisyear;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate, $thisweek , $lastweek);
}
if ($CurrentMonth == $month+12){
$lastyear = $thisyear;
$thisyear = 1;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate, $thisweek , $lastweek);
}
}
if ( $CurrentYear == ++$year )
{
$lastyear = $thisyear;
$thisyear = 1;
++$thismounth;
++$thisweek;
++$today;
update( $today, $yesterday, $thismounth, $lastmounth, $thisyear, $lastyear, $total, $CurrentDate ,$thisweek , $lastweek);
}
?>
وCREATE TABLE `counter` (
`counter_today` int(11) NOT NULL default '0',
`counter_yesterday` int(11) NOT NULL default '0',
`counter_thismonth` int(11) NOT NULL default '0',
`counter_lastmonth` int(11) NOT NULL default '0',
`counter_thisyear` int(11) NOT NULL default '0',
`counter_lastyear` int(11) NOT NULL default '0',
`counter_total` int(11) NOT NULL default '0',
`counter_date` varchar(100) NOT NULL default '0000-00-00-00',
`counter_thisweek` int(11) NOT NULL default '0',
`counter_lastweek` int(11) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
نیاز دارم به این اسکریپت از دوستان تقاضا می کنم ، عیبشو بگن .INSERT INTO `counter` VALUES ('0', '0', '1', '0', '0', '0', '0', '0000-00-00-00', '0', '0');
اگه از این اسکریپت استفاده می کنید ، بزنید که من نوشتم ، خیلی تغییرش دادم تا درست و دقیق شه .
خواهشاً بزنید کپی رایت : داود مظفری و لینک بدید به سایت : iroveb.com
آخرین ویرایش: