$counter=1; foreach($arrReferrerList as $referrer=>$referrers){ $totalReferrences=count($referrers); $html.='
'; $html.=''.$counter++.''.$referrer.''.__('References',WSM_PREFIX).': '.$totalReferrences.''; $html.='
'; foreach($referrers as $page){ $html.=''; } $html.='
'.wsmMaskIPaddress($page['ipAddress']).''.$page['country'].''.$page['deviceType'].''.$page['browser'].''.$page['osystem'].'
'; $html.='
'; } // $html.='
'; // $html.=wsmFnGetPagination(count($arrReferrerList),$currentPage,admin_url('admin.php?page='.WSM_PREFIX.'_trafficsrc').'&subPage=RefSites'); // $html.='
'; } else { $html .="

Data / Statistics are not available.

"; } //$html.=''; $wsmAdminJavaScript.=' jQuery("#'.WSM_PREFIX.$atts['id'].' .wsmAccordian").click(function(){ //jQuery("#'.WSM_PREFIX.$atts['id'].' .wsmAccordian .wsmPanel").hide(); jQuery(this).find(".wsmPanel").toggle(); }); '; return $html; } function wsm_showTopReferrerList($atts, $content=""){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); global $wsmAdminJavaScript; $atts = shortcode_atts( array( 'id' => '_topRefferStatsList', 'title' => 'Top Referrer Sites', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], 'searchengine' => '' ), $atts, WSM_PREFIX.'_showTopReferrerList'); $arrReferrerList=array(); $arrReferrerListSecond=array(); $arrYesterDayReferrerList=array(); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; $arrAtts['searchengine'] = $atts['searchengine']; $arrAtts['adminURL']=admin_url('admin.php?page='.WSM_PREFIX.'_trafficsrc').'&subPage='.( $atts['searchengine'] ? 'SearchEngines' : 'RefSites' ).'&'.http_build_query($arrRequestData); $html='
'; $lastFrom=$lastTo=''; $format='d F Y'; $arrCompare=array(); $condition=$atts['condition']; $jsParamAarray=array(); $jsParamAarray['searchengine'] = $atts['searchengine']; $currentDayVisitors=$totalPrevDayVisitors=0; //echo $atts['type']; switch($atts['type']){ case 'Hourly': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; $arrReferrerList=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); $lastFrom=wsmGetDateByInterval('-1 days','Y-m-d', $arrAtts['from']); $lastTo=wsmGetDateByInterval('-1 days','Y-m-d', $arrAtts['to']); $currentDayVisitors=$this->objDatabase->fnGetReferralTotalVisitorsCount($atts['condition'],$arrAtts); $totalPrevDayVisitors=$this->objDatabase->fnGetReferralTotalVisitorsCount($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo)); $jsParamAarray['from']=$arrAtts['from']; $jsParamAarray['to']=$arrAtts['to']; } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; $arrReferrerList=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); $jsParamAarray['from']=$arrAtts['from']; $jsParamAarray['to']=$arrAtts['to']; } if($atts['condition']=='Compare'){ $arrAtts['date']=$atts['first']; $jsParamAarray['date']=$arrAtts['date']; $arrReferrerList=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); $arrAtts['date']=$atts['second']; $jsParamAarray['date2']=$arrAtts['date']; unset($arrAtts['currentPage']); unset($arrAtts['adminURL']); $arrCompare=array('date'=>$atts['second']); //$arrReferrerListSecond=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); } break; case 'Daily': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); $arrReferrerList=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); $lastFrom=wsmGetDateByInterval('-1 months','Y-m-d', $arrAtts['from']); $lastTo=wsmGetDateByInterval('-1 months','Y-m-d', $arrAtts['to']); $format='F Y'; $jsParamAarray['from']=$arrAtts['from']; $jsParamAarray['to']=$arrAtts['to']; } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($atts['to'].'-01')); $arrReferrerList=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); $jsParamAarray['from']=$arrAtts['from']; $jsParamAarray['to']=$arrAtts['to']; } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); $arrReferrerList=$this->objDatabase->fnGetReferralList('Range',$arrAtts); $jsParamAarray['from']=$arrAtts['from']; $jsParamAarray['to']=$arrAtts['to']; unset($arrAtts['currentPage']); unset($arrAtts['adminURL']); $arrAtts['from']=$atts['second'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); $arrCompare=array('from'=>$arrAtts['from'],'to'=>$arrAtts['to']); $jsParamAarray['from2']=$arrAtts['from']; $jsParamAarray['to2']=$arrAtts['to']; //$arrReferrerListSecond=$this->objDatabase->fnGetReferralList($atts['condition'],$arrAtts); } break; } if(count($arrReferrerList['data'])>0){ /*echo '
';   
                    print_r($arrReferrerList['data']);
                    echo '
'; */ $counter=(($currentPage-1)*WSM_PAGE_LIMIT)+1; $searchengine = $arrAtts['searchengine']; $arrAtts['searchengine'] = ''; $html.=''; $html.=''; foreach($arrReferrerList['data'] as $referrer=>$referrers){ $totalReferrences=count($referrers); $arrow=''; $lastReferrals=0; $prevDayVisitors=0; $compareReferrals=''; $toolTip=''; if($atts['condition']=='Normal'){ $lastReferrals=$this->objDatabase->fnGetTotalReferralsByRefURL($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo,'refUrl'=>$referrers['refUrl'])); //$prevDayVisitors=$this->objDatabase->fnGetReferralTotalVisitorsCountByOSBrowser($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo,'refUrl'=>$referrers['refUrl'])); //$diff=$referrers['total']-$lastReferrals; $class=""; $currentPer = $PrevPer= 0; if( $totalPrevDayVisitors ){ $PrevPer=($lastReferrals*100)/$totalPrevDayVisitors; } if( $currentDayVisitors ){ $currentPer=($referrers['total']*100)/$currentDayVisitors; } $diff=$currentPer-$PrevPer; $diffPer=$diff==0?100:$diff; $percent=number_format_i18n($diffPer,0); if($diff<0){ $arrow='
'; $class="wsmColorRed"; } if($diff>0){ $arrow='
'; $class="wsmColorGreen"; $percent='+'.$percent; } $toolTip=''.$referrers['refUrl'].''.wsmGetDateByTimeStamp($format,strtotime($arrAtts['from'])).' / '.wsmGetDateByTimeStamp($format,strtotime($lastFrom)).''.__('Visitors Performance',WSM_PREFIX).': '.$percent.'%'; } if($atts['condition']=='Compare'){ $arrCompare['refUrl']=$referrers['refUrl']; $condition=isset($arrCompare['date'])?$atts['condition']:'Range'; $lastReferrals=$this->objDatabase->fnGetTotalReferralsByRefURL($condition,$arrCompare); $compareReferrals='
'.$lastReferrals.'
'; } $jsParamAarray['condition']=$condition; $jsParamAarray['id']=$referrers['id']; $referrerUrlDetail = $jsParamAarray; $referrerUrlDetail['id'] = $referrers['id']; $referrerUrlDetail['action'] = 'refUrlDetails'; $html.=''; $kTitle=(isset($referrers['keyword']) && $referrers['keyword']!='' && $referrers['keyword']!='-')?$referrers['keyword']:$referrers['refUrl']; $html.=''; $html.=''; $counter++; } if(isset($arrReferrerList['pagination'])){ $html.=''; } $html.='
'.__('Rank',WSM_PREFIX).''.__('Referrer url',WSM_PREFIX).' '.__('References',WSM_PREFIX).'
'.$arrow.' '.$counter.$toolTip.'
'.$kTitle.''.number_format($referrers['total']).''.$compareReferrals.'
'; $html.='
'; $html.=$arrReferrerList['pagination']; $html.='
'; $html.='
'; $html.='
'; } else { $html ='

Data / Statistics are not available.

'; } $wsmAdminJavaScript.=' jQuery("#'.WSM_PREFIX.$atts['id'].' .wsmExpandCollapse").click(function(e){ e.preventDefault(); var subcolumn=\''.wsmGetSpinner().'\'; var parentRow=jQuery(this).parents(".wsmReferralRow"); //var jsonParam=JSON.stringify('.json_encode($jsParamAarray).'); var jsonParam=JSON.stringify(jQuery(this).data("referral_prg")); strRefUrl=\',"refUrl":"\'+parentRow.data("url")+\'"}\'; jsonParam=jsonParam.replace("}",strRefUrl); console.log(jsonParam); rowId=parentRow.attr("id"); var arrId = rowId.split("_"); var childRowId="wsmRowChild_"+arrId[1]; if(jQuery(this).hasClass("wsmCollapse")){ parentRow.siblings("#"+childRowId).slideUp().remove(); jQuery(this).removeClass("wsmCollapse"); return; } if(parentRow.siblings("#"+childRowId).length){ parentRow.siblings("#"+childRowId).html(subcolumn); }else{ parentRow.after(\'\'+subcolumn+\'\'); } var wsmFnGetRowDetails=function(){ jQuery.ajax({ type: "POST", url: wsm_ajaxObject.ajax_url, data: { action: \'refDetails\', requests: jsonParam, r: Math.random() } }).done(function( strResponse ) { parentRow.siblings("#"+childRowId).html(""+strResponse+""); }); }; wsmFnGetRowDetails(); jQuery(this).addClass("wsmCollapse"); }); '; return $html; } function wsm_showSearchEngineSummary( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $atts = shortcode_atts( array( 'id' => '_topRefferStatsList', 'title' => 'Top Referrer Sites', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], 'searchengine' => '' ), $atts, WSM_PREFIX.'_showTopReferrerList'); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; $arrAtts['searchengine'] = $atts['searchengine']; $condition=$atts['condition']; switch($atts['type']){ case 'Hourly': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Compare'){ $arrAtts['date']=$atts['first']; } break; case 'Daily': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($atts['to'].'-01')); } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } break; } /*$arrSearchEngineStatList = $this->objDatabase->fnGetTotalUserSeachEngineWise( $atts['condition'] ,$arrAtts);*/ $arrSearchEngineStatList = $this->objDatabase->fnGetTotalUserBySeachEngineWise( $atts['condition'] ,$arrAtts); if(count($arrSearchEngineStatList) > 0) { $totalUsers = array_sum( $arrSearchEngineStatList ); $html = '
'; $html .= ''; $html .= ''; $i=0; foreach( $arrSearchEngineStatList as $key => $arrSearchEngineStat ){ if($i > 4) break; if($arrSearchEngineStat > 0) { $number = $arrSearchEngineStat * 100 / $totalUsers; } else $number = 0; //echo "
"; $user_per = sprintf('%.2f',$number); //$user_per = round($number); $name = sprintf( '%s %s', str_replace(' ','', strtolower($key)), WSM_URL, $key, $key, $key ); $html .= ''; $i++; } $html .= '
Visitors
'.$name.'
'.($user_per).'%
'.$arrSearchEngineStat.'
'; $html .= '
'; } else { $html .="

Data / Statistics are not available.

"; } return $html; //print_r($arrSearchEngineStatList); } function wsm_showVisitorsDetail( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $atts = shortcode_atts( array( 'id' => '_topRefferStatsList', 'title' => 'Top Referrer Sites', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], 'searchengine' => '' ), $atts, WSM_PREFIX.'_showTopReferrerList'); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; $arrAtts['searchengine'] = $atts['searchengine']; $condition=$atts['condition']; $arrVisitorsInfo2 = array(); switch($atts['type']){ case 'Hourly': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first']; $arrAtts['to']=$atts['second']; } break; case 'Daily': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($atts['to'].'-01')); } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } break; } if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $condition, $compareAtts ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } //$arrVisitorsInfo2 = $this->objDatabase->getVisitorsInfo( $condition, $compareAtts ); }else{ $arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $condition, $arrAtts ); } $lastFrom=wsmGetDateByInterval('-1 days','Y-m-d', $arrAtts['from']); $lastTo=wsmGetDateByInterval('-1 days','Y-m-d', $arrAtts['to']); //$arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $atts['condition'] ,$arrAtts); $header = ''; $contentData = ''; $seperator = ''; $totaiVisitorsToday=$this->objDatabase->fnGetTotalVisitorsCount($atts['condition'] ,$arrAtts); $totaiVisitorsYesterday=$this->objDatabase->fnGetTotalVisitorsCount($atts['condition'] ,array('from'=>$lastFrom,'to'=>$lastTo)); if( is_array($arrVisitorsInfo) && count($arrVisitorsInfo) ){ $link_class = $class = 'active'; foreach( $arrVisitorsInfo as $key => $data ){ $unique_id = rand(); $contentData .= '
'; $contentData.=''; $title = ''; switch( $key ){ case 'OS': $title = 'Operation System'; break; default: $title = $key; break; } $contentData.=''; $counter = 1; $visitor_graph = array(); if(count($data) > 0) { foreach( $data as $data_key => $row ){ $arrAtts['rtype'] = $key; $arrAtts['id'] = $row['id']; if($atts['condition']=='Normal'){ $currentDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByBroswerOS($atts['condition'],$arrAtts); //$currentDayVisitors=$this->objDatabase->fnGetReferralTotalVisitorsCountByBroswerOS($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo, 'rtype' => $key ) ); $prevDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByBroswerOS($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo,'id'=> $row['id'], 'rtype' => $key )); //$prevDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByOSBrowser($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo,'id'=> $row['id'], 'rtype' => $key )); $arrow = $toolTip=''; $class2 = ""; $currentPer = $PrevPer= 0; if( $totaiVisitorsYesterday ){ $PrevPer=($prevDayVisitors*100)/$totaiVisitorsYesterday; } if( $totaiVisitorsToday ){ $currentPer=($row['total']*100)/$totaiVisitorsToday; } $diff=$currentPer-$PrevPer; $diffPer=$diff==0?100:$diff; $percent=number_format_i18n($diffPer,0); if($diff<0){ $arrow='
'; $class2="wsmColorRed"; } if($diff>0){ $arrow='
'; $class2="wsmColorGreen"; $percent='+'.$percent; } $format = 'd F Y'; $toolTip=''.$row['name'].''.wsmGetDateByTimeStamp($format,strtotime($arrAtts['from'])).' / '.wsmGetDateByTimeStamp($format,strtotime($lastFrom)).''.__('Visitors Performance',WSM_PREFIX).': '.$percent.'%'; } $compareValue = ''; if( $condition == 'Compare' ){ $compareAtts['rtype'] = $key; $compareAtts['id'] = $row['id']; $count = $this->objDatabase->fnGetReferralTotalVisitorsCountByOSBrowser( $condition, $compareAtts ); //$compareValue = '
'.( isset($arrVisitorsInfo2[$key][$data_key]['total']) && $arrVisitorsInfo2[$key][$data_key]['total'] ? $arrVisitorsInfo2[$key][$data_key]['total'] : 0).'
'; $compareValue = '
'.number_format($count).'
'; } $arrAtts['action'] = 'getReferralOSDetails'; $contentData.=''; $counter++; if( $counter <= 8 ){ $visitor_graph[] = array( $row['name'].' ('.$row['total'].')', $row['total'] ); } } } else { $contentData .=""; } $contentData.='
'.__('Rank',WSM_PREFIX).''.$title.' '.__('References',WSM_PREFIX).'
'.$arrow.' '.$counter.$toolTip.'
' .$row['name'].''.number_format($row['total']).$compareValue.'
Data / Statistics are not available
'; $contentData .= '
'; $header .= $seperator.''.$key.''; $link_class = ''; $seperator = ' | '; } } if( is_admin() ){ echo '
'. $header.'
'.$contentData; }else{ return $contentData; } } function wsm_showEachVisitorsDetailGraph($atts) { add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $atts = shortcode_atts( array( 'id' => '_topRefferStatsList', 'display' => '', 'title' => 'Top Referrer Sites', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], 'searchengine' => '' ), $atts, WSM_PREFIX.'_showTopReferrerList'); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; $arrAtts['searchengine'] = $atts['searchengine']; $condition=$atts['condition']; $arrVisitorsInfo2 = array(); ob_start(); switch($atts['type']){ case 'Hourly': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first']; $arrAtts['to']=$atts['second']; } break; case 'Daily': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($atts['to'].'-01')); } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } break; } if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $condition, $compareAtts ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } //$arrVisitorsInfo2 = $this->objDatabase->getVisitorsInfo( $condition, $compareAtts ); }else{ $arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $condition, $arrAtts ); } $lastFrom=wsmGetDateByInterval('-1 days','Y-m-d', $arrAtts['from']); $lastTo=wsmGetDateByInterval('-1 days','Y-m-d', $arrAtts['to']); //$arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $atts['condition'] ,$arrAtts); $totaiVisitorsToday=$this->objDatabase->fnGetTotalVisitorsCount($atts['condition'] ,$arrAtts); $totaiVisitorsYesterday=$this->objDatabase->fnGetTotalVisitorsCount($atts['condition'] ,array('from'=>$lastFrom,'to'=>$lastTo)); if( is_array($arrVisitorsInfo) && count($arrVisitorsInfo) ){ $link_class = $class = 'active'; if(strtolower($atts['display'])=="os") $finalArrVisitorsInfo['OS'] = $arrVisitorsInfo['OS']; else if(strtolower($atts['display'])=="browser") $finalArrVisitorsInfo['Browser'] = $arrVisitorsInfo['Browser']; else if(strtolower($atts['display'])=="resolution") $finalArrVisitorsInfo['Screen Resolution'] = $arrVisitorsInfo['Screen Resolution']; else $finalArrVisitorsInfo = $arrVisitorsInfo; //print_r($finalArrVisitorsInfo); foreach( $finalArrVisitorsInfo as $key => $data ){ $unique_id = rand(); $title = ''; switch( $key ){ case 'OS': $title = 'Operation System'; break; default: $title = $key; break; } $counter = 1; $visitor_graph = array(); foreach( $data as $data_key => $row ){ $arrAtts['rtype'] = $key; $arrAtts['id'] = $row['id']; if($atts['condition']=='Normal'){ $currentDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByBroswerOS($atts['condition'],$arrAtts); //$currentDayVisitors=$this->objDatabase->fnGetReferralTotalVisitorsCountByBroswerOS($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo, 'rtype' => $key ) ); $prevDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByBroswerOS($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo,'id'=> $row['id'], 'rtype' => $key )); //$prevDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByOSBrowser($atts['condition'],array('from'=>$lastFrom,'to'=>$lastTo,'id'=> $row['id'], 'rtype' => $key )); $arrow = $toolTip=''; $class2 = ""; $currentPer = $PrevPer= 0; if( $totaiVisitorsYesterday ){ $PrevPer=($prevDayVisitors*100)/$totaiVisitorsYesterday; } if( $totaiVisitorsToday ){ $currentPer=($row['total']*100)/$totaiVisitorsToday; } $diff=$currentPer-$PrevPer; $diffPer=$diff==0?100:$diff; $percent=number_format_i18n($diffPer,0); if($diff<0){ $arrow='
'; $class2="wsmColorRed"; } if($diff>0){ $arrow='
'; $class2="wsmColorGreen"; $percent='+'.$percent; } $format = 'd F Y'; $toolTip=''.$row['name'].''.wsmGetDateByTimeStamp($format,strtotime($arrAtts['from'])).' / '.wsmGetDateByTimeStamp($format,strtotime($lastFrom)).''.__('Visitors Performance',WSM_PREFIX).': '.$percent.'%'; } $compareValue = ''; if( $condition == 'Compare' ){ $compareAtts['rtype'] = $key; $compareAtts['id'] = $row['id']; $count = $this->objDatabase->fnGetReferralTotalVisitorsCountByOSBrowser( $condition, $compareAtts ); //$compareValue = '
'.( isset($arrVisitorsInfo2[$key][$data_key]['total']) && $arrVisitorsInfo2[$key][$data_key]['total'] ? $arrVisitorsInfo2[$key][$data_key]['total'] : 0).'
'; $compareValue = '
'.number_format($count).'
'; } $arrAtts['action'] = 'getReferralOSDetails'; $counter++; if( $counter <= 8 ){ $visitor_graph[] = array( $row['name'].' ('.$row['total'].')', $row['total'] ); } } echo "
".$title."
"; echo '
'. $header.'
'; } } $data = ob_get_contents(); ob_clean(); return $data; } function wsm_showVisitorsDetailGraph( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $atts = shortcode_atts( array( 'id' => '_topRefferStatsList', 'title' => 'Top Referrer Sites', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], 'searchengine' => '' ), $atts, WSM_PREFIX.'_showTopReferrerList'); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; $arrAtts['searchengine'] = $atts['searchengine']; $condition=$atts['condition']; switch($atts['type']){ case 'Hourly': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from']; $arrAtts['to']=$atts['to']; } if($atts['condition']=='Compare'){ $arrAtts['date']=$atts['first']; } break; case 'Daily': if($atts['condition']=='Normal'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } if($atts['condition']=='Range'){ $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($atts['to'].'-01')); } if($atts['condition']=='Compare'){ $arrAtts['from']=$atts['first'].'-01'; $arrAtts['to']=wsmGetDateByTimeStamp('Y-m-t',strtotime($arrAtts['from'])); } break; } //$arrVisitorsInfo = $this->objDatabase->getVisitorsInfo( $atts['condition'] ,$arrAtts); ob_start(); echo '

Data / Statistics are not available.

'; $data = ob_get_contents(); ob_clean(); return $data; } function wsm_showStatKeywords($atts){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; if( is_admin() ){ $arrAtts['adminURL']=admin_url('admin.php?page='.WSM_PREFIX.'_trafficsrc').'&subPage=SearchKeywords';//'&'.http_build_query($arrRequestData); } $totalSearchKeywords = $this->objDatabase->fnGetReferralKeywords( $arrAtts ); $html = ''; if(count($totalSearchKeywords['data'])>0){ $html .= '
'; $html .= ''; foreach($totalSearchKeywords['data'] as $searchKeyword ){ $keyword = $searchKeyword['keyword']; if( !$keyword || $keyword == '-' ){ $keyword = wsmGetSearchKeywords( 'http://'. $searchKeyword['url'] ); } if( !$keyword ){ $keyword = '-'; } $html.=''; $html.= sprintf('', $keyword, date('Y/m/d', strtotime( $searchKeyword['serverTime'] )), $searchKeyword['ipAddress'], $searchKeyword['protocol'].$searchKeyword['url'], $searchKeyword['url']); $html.=''; $counter++; } if(isset($totalSearchKeywords['pagination'])){ $html.=''; } $html .= '
%s
%s - %s
%s
'; $html.='
'; $html.=$totalSearchKeywords['pagination']; $html.='
'; $html.='
'; $html .= '
'; } return $html; } function wsm_showGeoLocationGraph( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); global $wsmAdminJavaScript; $atts = shortcode_atts( array( 'id' => '__geoLocation', 'title' => 'Geo Location', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], ), $atts, WSM_PREFIX.'_showTopReferrerList'); $condition=$atts['condition']; $arrAtts = array(); switch($atts['type']){ case 'Hourly': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['from']; break; case 'Range': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['to']; break; case 'Compare': $arrAtts['from']=$atts['first']; $arrAtts['to']= $atts['second']; break; } break; case 'Daily': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['from'].'-01') ); break; case 'Range': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['to'].'-01') ); break; case 'Compare': $arrAtts['from']= $atts['first'].'-01'; $arrAtts['to']= $atts['second'].'-01'; break; } break; } $arrAtts['limit'] = 8; if( isset( $_GET['location'] ) ){ $arrAtts['location'] = 'city'; $arrAtts['city'] = 0; $arrAtts['compare'] = '!='; }else{ $arrAtts['countryId'] = 0; $arrAtts['compare'] = '>'; } if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $totalGeoLocationDetails = $this->objDatabase->getGeoLocationInfo( $condition, $compareAtts ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } $totalGeoLocationDetails2 = $this->objDatabase->getGeoLocationInfo( $condition, $compareAtts ); }else{ $totalGeoLocationDetails = $this->objDatabase->getGeoLocationInfo( $condition, $arrAtts ); } ob_start(); if($totalGeoLocationDetails) { foreach( $totalGeoLocationDetails as $key => $row ){ $total = $row['total_visitors']; if( $condition == 'Compare' ){ $total += $totalGeoLocationDetails2[$key]['total_visitors']; } $visitor_graph[] = array( $row['name']. ' ('.$total.')', number_format( $total ) ); } echo '
'; } else { $visitor_graph = null; echo '

Data / Statistics are not available.

'; } $data = ob_get_contents(); ob_clean(); return $data; } function wsm_showGeoLocationDetails( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $totalGeoLocationDetails2 = array(); global $wsmAdminJavaScript; $atts = shortcode_atts( array( 'id' => '__geoLocation', 'title' => 'Geo Location', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], ), $atts, WSM_PREFIX.'_showTopReferrerList'); $condition=$atts['condition']; $locationType = isset( $_GET['location'] ) ? $_GET['location'] : ''; $arrAtts = array(); if( isset( $_GET['location'] ) ){ $arrAtts['location'] = 'city'; $arrAtts['city'] = 0; $arrAtts['compare'] = '!='; }else{ $arrAtts['countryId'] = 0; $arrAtts['compare'] = '>'; } switch($atts['type']){ case 'Hourly': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['from']; break; case 'Range': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['to']; break; case 'Compare': $arrAtts['from']=$atts['first']; $arrAtts['to']= $atts['second']; break; } break; case 'Daily': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['from'].'-01') ); break; case 'Range': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['to'].'-01') ); break; case 'Compare': $arrAtts['from']= $atts['first'].'-01'; $arrAtts['to']= $atts['second'].'-01'; break; } break; } if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $totalGeoLocationDetails = $this->objDatabase->getGeoLocationInfo( $condition, $compareAtts ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } $totalGeoLocationDetails2 = $this->objDatabase->getGeoLocationInfo( $condition, $compareAtts ); }else{ $totalGeoLocationDetails = $this->objDatabase->getGeoLocationInfo( $condition, $arrAtts ); } $graphAttr = $preArrAtts = $arrAtts; $preArrAtts['from'] = $lastFrom; $preArrAtts['to'] = $preArrAtts['from']; $totaiVisitorsToday = $this->objDatabase->fnGetReferralTotalVisitorsCountByCountry( $arrAtts ); $startFrom = $arrAtts['from']; $lastFrom = $preArrAtts['from'] = date('Y-m-d', strtotime($preArrAtts['from'] .' -1 day')); $preArrAtts['to'] = $preArrAtts['from']; $graphAttr['from'] = date('Y-m-d', strtotime($graphAttr['from'] .' -30 day')); $graphAttr['action'] = 'getDateWiseLocationDetail'; $totaiVisitorsYesterday = $this->objDatabase->fnGetReferralTotalVisitorsCountByCountry( $preArrAtts ); $contentData = ''; $contentData .= '
'; $contentData .= '
Country | City
'; $contentData.=''; $contentData.=''; $counter = 1; if(count($totalGeoLocationDetails) > 0) { $visitor_graph = array(); foreach( $totalGeoLocationDetails as $key => $row ){ $arrow = ''; $locationGraph = ''; if($condition=='Normal'){ $arrAtts['compare'] = '='; $preArrAtts['compare'] = '='; if( isset( $_GET['location'] ) ){ $arrAtts['location'] = 'city'; $arrAtts['city'] = $row['name']; $preArrAtts['city'] = $row['name']; }else{ $arrAtts['countryId'] = $row['countryId']; $preArrAtts['countryId'] = $row['countryId']; } $currentDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByCountry( $arrAtts ); $prevDayVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCountByCountry( $preArrAtts ); $arrow = $toolTip=''; $class2 = ""; $currentPer = $PrevPer= 0; if( $totaiVisitorsYesterday ){ $PrevPer=($prevDayVisitors*100)/$totaiVisitorsYesterday; } if( $totaiVisitorsToday ){ $currentPer=($row['total_visitors']*100)/$totaiVisitorsToday; } $diff=$currentPer-$PrevPer; $diffPer=$diff==0?100:$diff; $percent=number_format_i18n($diffPer,0); if($diff<0){ $arrow='
'; $class2="wsmColorRed"; } if($diff>0){ $arrow='
'; $class2="wsmColorGreen"; $percent='+'.$percent; } $format = 'd F Y'; $user_per = number_format($currentPer, 2, '.', ''); $locationGraph = '
'.$user_per.'%
'; $toolTip=''.$row['name'].''.wsmGetDateByTimeStamp($format,strtotime($startFrom)).' / '.wsmGetDateByTimeStamp($format,strtotime($lastFrom)).''.__('Visitors Performance',WSM_PREFIX).': '.$percent.'%'; } $compare_total_unique_visitors = $compare_total_visitors = $compare_total_page_views = $compare_ppv = ''; if( $condition == 'Compare' ){ $compare_total_unique_visitors = '
'.( isset($totalGeoLocationDetails2[$key]['total_unique_visitors']) && $totalGeoLocationDetails2[$key]['total_unique_visitors'] ? $totalGeoLocationDetails2[$key]['total_unique_visitors'] : 0).'
'; $compare_total_visitors = '
'.( isset($totalGeoLocationDetails2[$key]['total_visitors']) && $totalGeoLocationDetails2[$key]['total_visitors'] ? $totalGeoLocationDetails2[$key]['total_visitors'] : 0).'
'; $compare_total_page_views = '
'.( isset($totalGeoLocationDetails2[$key]['total_page_views']) && $totalGeoLocationDetails2[$key]['total_page_views'] ? $totalGeoLocationDetails2[$key]['total_page_views'] : 0).'
'; if( isset($totalGeoLocationDetails2[$key]['total_page_views']) && $totalGeoLocationDetails2[$key]['total_page_views'] && isset($totalGeoLocationDetails2[$key]['total_visitors']) && $totalGeoLocationDetails2[$key]['total_visitors'] ){ $compare_ppv = $totalGeoLocationDetails2[$key]['total_page_views'] / $totalGeoLocationDetails2[$key]['total_visitors']; $compare_ppv = '
'. number_format($compare_ppv, 1, ".", "" ) .'
'; } } if( isset( $row['countryId'] ) ){ $graphAttr['countryId'] = $row['countryId']; } if( isset( $_GET['location'] ) ){ $graphAttr['compare'] = '='; $graphAttr['city'] = $row['name']; } $ppv = $row['total_page_views'] / $row['total_visitors']; $contentData.=''; $counter++; } } else { $contentData .=""; } $contentData.='
'.__('Rank',WSM_PREFIX).''.( isset($arrAtts['location']) ? __('City',WSM_PREFIX) : __('Country',WSM_PREFIX) ) . ''. __('New visitors',WSM_PREFIX) .'' .__('Visitors',WSM_PREFIX). '' .__('Page viewed',WSM_PREFIX). ''.__('Ppv', WSM_PREFIX).'
'.$arrow.' '.$counter.$toolTip.'
'.$row['name'].' ' .$row['name'].' '. number_format($row['total_unique_visitors']).$compare_total_unique_visitors. ' '. number_format($row['total_visitors']).$compare_total_visitors. ' ' .number_format($row['total_page_views']).$compare_total_page_views. $locationGraph.' '. number_format($ppv, 1, ".", "" ).$compare_ppv .'
Data / Statistics are not available.
'; $contentData .= '
'; return $contentData; } function wsm_showContentByURL( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $totalGeoLocationDetails2 = array(); $atts = shortcode_atts( array( 'id' => '__contentByURL', 'title' => 'Content by URL', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], ), $atts, WSM_PREFIX.'_showContentByURL'); $condition=$atts['condition']; $arrAtts = array(); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; if( is_admin() ){ $arrAtts['adminURL']=admin_url('admin.php?page='.WSM_PREFIX.'_content');//'&'.http_build_query($arrRequestData); } switch($atts['type']){ case 'Hourly': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['from']; break; case 'Range': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['to']; break; case 'Compare': $arrAtts['from']=$atts['first']; $arrAtts['to']= $atts['second']; break; } break; case 'Daily': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['from'].'-01') ); break; case 'Range': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['to'].'-01') ); break; case 'Compare': $arrAtts['from']= $atts['first'].'-01'; $arrAtts['to']= $atts['second'].'-01'; break; } break; } $arrAtts['date'] = $arrAtts['from']; //$totalHits = $this->objDatabase->fnGetTotalHitsCount( $arrAtts ); $totalVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCount($condition, $arrAtts); $totalFirstTimeVisitors = $this->objDatabase->fnGetFirstTimeVisitorCount($condition, $arrAtts); if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $urlStatsResult = $this->objDatabase->getContentByURLStats( $compareAtts, 12 ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } }else{ $urlStatsResult = $this->objDatabase->getContentByURLStats( $arrAtts, 12 ); } //print_r($arrAtts); $preArrAtts = $arrAtts; $totaiVisitorsToday = $totaiVisitorsYesterday = 0; $totaiVisitorsToday = $this->objDatabase->getContentByURLTotalRecords( $arrAtts ); if($condition=='Normal'){ $startFrom = $arrAtts['from']; $lastFrom = $preArrAtts['from'] = date('Y-m-d', strtotime($preArrAtts['from'] .' -1 day')); $preArrAtts['to'] = $preArrAtts['from']; $totaiVisitorsYesterday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); } if($condition=='Compare'){ $preArrAtts['to'] =$arrAtts['from']; $totaiVisitorsToday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); $startFrom = $arrAtts['to']; $lastFrom = $preArrAtts['to']; $preArrAtts['from'] = $arrAtts['from']; $totaiVisitorsYesterday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); } $graphAttr['to'] = $arrAtts['from']; $graphAttr['from'] = date('Y-m-d', strtotime($arrAtts['from'] .' -30 day')); $graphAttr['action'] = 'getContentUrlDayView'; $html = ''; $site_url = str_replace( array( 'http://www.', 'https://wwww.', 'http://', 'https://','www.'), array(), site_url() ); if( is_array( $urlStatsResult ) && isset( $urlStatsResult['data'] ) && count($urlStatsResult['data'])>0){ $html .= ''; } return $html; } function wsm_showContentByURLStats( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $totalGeoLocationDetails2 = array(); $atts = shortcode_atts( array( 'id' => '__contentByURL', 'title' => 'Content by URL', 'type' => $arrPostData['filterType'], 'content' => '', 'limit' => 50, 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], ), $atts, WSM_PREFIX.'_showContentByURL'); $condition=$atts['condition']; if( $atts['content'] == 'byTitle' ){ $_GET['subPage'] = 'byTitle'; } $arrAtts = array(); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; if( isset( $_REQUEST['search'] ) && $_REQUEST['search'] ){ $arrAtts['search'] = $_REQUEST['search']; } if( is_admin() ){ $admin_url = admin_url('admin.php?page='.WSM_PREFIX.'_content'); if( isset( $_GET['subPage'] ) && $_GET['subPage'] == 'byTitle' ){ $admin_url .= '&subPage='.$_GET['subPage']; } $arrAtts['adminURL'] = $admin_url.'&'.http_build_query($arrRequestData); } switch($atts['type']){ case 'Hourly': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['from']; break; case 'Range': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['to']; break; case 'Compare': $arrAtts['from']=$atts['first']; $arrAtts['to']= $atts['second']; break; } break; case 'Daily': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['from'].'-01') ); break; case 'Range': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['to'].'-01') ); break; case 'Compare': $arrAtts['from']= $atts['first'].'-01'; $arrAtts['to']= $atts['second'].'-01'; break; } break; } $arrAtts['date'] = $arrAtts['from']; //$totalHits = $this->objDatabase->fnGetTotalHitsCount( $arrAtts ); $totalVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCount($condition, $arrAtts); $totalFirstTimeVisitors = $this->objDatabase->fnGetFirstTimeVisitorCount($condition, $arrAtts); if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $urlStatsResult = $this->objDatabase->getContentByURLStats( $compareAtts ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } }else{ $urlStatsResult = $this->objDatabase->getContentByURLStats( $arrAtts, $atts['limit'] ); } //print_r($arrAtts); $preArrAtts = $arrAtts; $totaiVisitorsToday = $totaiVisitorsYesterday = 0; $totaiVisitorsToday = $this->objDatabase->getContentByURLTotalRecords( $arrAtts ); if($condition=='Normal'){ $startFrom = $arrAtts['from']; $lastFrom = $preArrAtts['from'] = date('Y-m-d', strtotime($preArrAtts['from'] .' -1 day')); $preArrAtts['to'] = $preArrAtts['from']; $totaiVisitorsYesterday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); } if($condition=='Compare'){ $preArrAtts['to'] =$arrAtts['from']; $totaiVisitorsToday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); $startFrom = $arrAtts['to']; $lastFrom = $preArrAtts['to']; $preArrAtts['from'] = $arrAtts['from']; $totaiVisitorsYesterday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); } $graphAttr['to'] = $arrAtts['from']; $graphAttr['from'] = date('Y-m-d', strtotime($arrAtts['from'] .' -30 day')); $graphAttr['action'] = 'getContentUrlDayView'; $html = ''; $site_url = str_replace( array( 'http://www.', 'https://wwww.', 'http://', 'https://','www.'), array(), site_url() ); if( is_array( $urlStatsResult ) && isset( $urlStatsResult['data'] ) && count($urlStatsResult['data'])>0){ $order_query = $arrAtts['adminURL'].'&orderby=hits&order=asc'; $order_class = 'dashicons-arrow-down'; if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ){ $order_query = $arrAtts['adminURL'].'&orderby=hits&order=desc'; $order_class = 'dashicons-arrow-up'; } $urlTitle = __('Url',WSM_PREFIX); if( isset( $_GET['subPage'] ) && $_GET['subPage'] == 'byTitle' ){ $urlTitle = __('Title',WSM_PREFIX); } $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; $html .= ''; $html .= ''; $counter = 1; foreach($urlStatsResult['data'] as $row ){ $arrow = $toolTip = ''; $graphAttr['id'] = $row['id']; $arrAtts['id'] = $row['id']; $preArrAtts['id'] = $row['id']; if($condition=='Compare'){ $temp = $arrAtts; $temp['to'] = $arrAtts['from']; $urlVisitors = $this->objDatabase->getContentByURLVisitors( $temp ); }else{ $urlVisitors = $this->objDatabase->getContentByURLVisitors( $arrAtts ); } $url = str_replace( $site_url, '', $row['url'] ); $name = $url; if( isset( $_GET['subPage'] ) && $_GET['subPage'] == 'byTitle' ){ $post_id = url_to_postid( $row['protocol'].$row['url'] ); if( $post_id ){ $name = get_the_title( $post_id ); }else{ $name = wsmArchiveTitleFromURL( $url ); } if( $url == $name && !empty( $row['title'] ) ){ $name = $row['title']; } } if($condition=='Normal'){ $class2 = ""; $currentPer = $PrevPer= 0; $currentDayVisitors = $this->objDatabase->getContentByURLTotalRecords( $arrAtts ); $prevDayVisitors = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); if( $totaiVisitorsYesterday ){ $PrevPer=($prevDayVisitors*100)/$totaiVisitorsYesterday; } if( $totaiVisitorsToday ){ $currentPer=( $currentDayVisitors*100)/$totaiVisitorsToday; } $diff=$currentPer-$PrevPer; $diffPer=$diff==0?100:$diff; $percent=number_format_i18n($diffPer,0); if($diff<0){ $arrow='
'; $class2="wsmColorRed"; } if($diff>0){ $arrow='
'; $class2="wsmColorGreen"; $percent='+'.$percent; } $format = 'd F Y'; $user_per = number_format($currentPer, 2, '.', ''); $toolTip=''. $name .''.wsmGetDateByTimeStamp($format,strtotime($startFrom)).' / '.wsmGetDateByTimeStamp($format,strtotime($lastFrom)).''.__('Visitors Performance',WSM_PREFIX).': '.$percent.'%'; } $compare_total_unique_visitors = $compare_total_visitors = $compare_total_hits = ''; if( $condition == 'Compare' ){ $compareAtts['id'] = $row['id']; $hitsPer = $totalVisitorsPer = $totalfirstTimeVisitorsPer = 0; $urlStatsResult2 = $this->objDatabase->getContentByURLStats( $compareAtts ); $hits = isset( $urlStatsResult2['data'][0]['hits'] ) ? $urlStatsResult2['data'][0]['hits'] : 0; $urlStatsResult2 = $this->objDatabase->getContentByURLVisitors( $compareAtts ); $visitors = isset($urlStatsResult2['visitors']) ? $urlStatsResult2['visitors'] : 0; $newVisitors = isset($urlStatsResult2['newVisitors']) ? $urlStatsResult2['newVisitors'] : 0; $new_value = array( $hits, $visitors, $newVisitors ); sort($new_value); $hits = $new_value[2]; $visitors = $new_value[1]; $newVisitors = $new_value[0]; if( $newVisitors && $totaiVisitorsYesterday ){ $totalfirstTimeVisitorsPer = number_format( ( $newVisitors * 100 ) / ($totaiVisitorsYesterday * 10) , 2) ; } if( $hits && $totaiVisitorsYesterday ){ $hitsPer = number_format ( ( $hits * 100 ) / ( $totaiVisitorsYesterday * 10 ) , 2 ); } if( $visitors && $totaiVisitorsYesterday ){ $totalVisitorsPer = number_format ( ( $visitors * 100 ) / ( $totaiVisitorsYesterday * 10), 2 ); } $compare_total_hits = '
'.$hits.' ( '.$hitsPer.' %)
'; $compare_total_unique_visitors = '
'.$newVisitors.' ( '.$totalfirstTimeVisitorsPer.' %)
'; $compare_total_visitors = '
'.$visitors.' ( '.$totalVisitorsPer.' %)
'; } $hitsPer = $totalVisitorsPer = $totalfirstTimeVisitorsPer = 0; $hitsPer = number_format ( ( $row['hits'] * 100 ) / ( $totaiVisitorsToday * 10 ) , 2 ); if( $urlVisitors['visitors'] && $totalVisitors ){ $totalVisitorsPer = number_format ( ( $urlVisitors['visitors'] * 100 ) / ( $totalVisitors * 10), 2 ); } if( $urlVisitors['newVisitors'] && $totalFirstTimeVisitors && $totalFirstTimeVisitors > 0 ){ $totalfirstTimeVisitorsPer = number_format( ( $urlVisitors['newVisitors'] * 100 ) / ($totalFirstTimeVisitors * 10) , 2) ; } $row_number = ( $currentPage > 1 ? ( ($currentPage - 1) * 100 ) + $counter : $counter ); $html .= ''; $counter++; } if(isset($urlStatsResult['pagination'])){ $html.=''; } $html .= '
'.__('Rank',WSM_PREFIX).' '. $urlTitle . ' '. __('Hits',WSM_PREFIX) .' ' .__('Visitors Entry',WSM_PREFIX). ' ' .__('New Visitors Entry',WSM_PREFIX). '
'.$arrow.' '.$row_number.$toolTip.'
'. $name .' '. number_format($row['hits']).' ('.$hitsPer.'%)'. $compare_total_hits. ' '. number_format($urlVisitors['visitors']).' ('.$totalVisitorsPer.'%)'. $compare_total_visitors. ' ' .number_format($urlVisitors['newVisitors']).' ('.$totalfirstTimeVisitorsPer.'%)'. $compare_total_unique_visitors .'
'; $html.='
'; $html.=$urlStatsResult['pagination']; $html.='
'; $html.='
'; $html .= '
'; } else $html = "

Data / Statistics are not available.

"; return $html; } function wsm_showTitleCloud( $atts ){ add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $arrRequestData=wsmFnGetFilterPostData(); $arrPostData=wsmSanitizeFilteredPostData(); $atts = shortcode_atts( array( 'id' => '__contentByURL', 'title' => 'Content by URL', 'type' => $arrPostData['filterType'], 'condition' => $arrPostData['filterWay'], 'from' => $arrPostData[$arrPostData['filterWay']]['from'], 'to' => $arrPostData[$arrPostData['filterWay']]['to'], 'first' => $arrPostData[$arrPostData['filterWay']]['first'], 'second' => $arrPostData[$arrPostData['filterWay']]['second'], ), $atts, WSM_PREFIX.'_showContentByURL'); $condition=$atts['condition']; $arrAtts = array(); $currentPage=isset($_GET['wsmp'])&&$_GET['wsmp']!=''?$_GET['wsmp']:1; $arrAtts['currentPage']=$currentPage; if( isset( $_REQUEST['search'] ) && $_REQUEST['search'] ){ $arrAtts['search'] = $_REQUEST['search']; } $admin_url = ''; if( is_admin() ){ $admin_url = admin_url('admin.php?page='.WSM_PREFIX.'_content'); if( isset( $_GET['subPage'] ) && $_GET['subPage'] == 'byTitle' ){ $admin_url .= '&subPage='.$_GET['subPage']; } $arrAtts['adminURL'] = $admin_url.'&'.http_build_query($arrRequestData); $admin_url = $arrAtts['adminURL']; } switch($atts['type']){ case 'Hourly': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['from']; break; case 'Range': $arrAtts['from']=$atts['from']; $arrAtts['to']= $atts['to']; break; case 'Compare': $arrAtts['from']=$atts['first']; $arrAtts['to']= $atts['second']; break; } break; case 'Daily': switch( $condition ){ case 'Normal': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['from'].'-01') ); break; case 'Range': $arrAtts['from']=$atts['from'].'-01'; $arrAtts['to']= date('Y-m-t', strtotime( $atts['to'].'-01') ); break; case 'Compare': $arrAtts['from']= $atts['first'].'-01'; $arrAtts['to']= $atts['second'].'-01'; break; } break; } $arrAtts['date'] = $arrAtts['from']; //$totalHits = $this->objDatabase->fnGetTotalHitsCount( $arrAtts ); $totalVisitors = $this->objDatabase->fnGetReferralTotalVisitorsCount($condition, $arrAtts); $totalFirstTimeVisitors = $this->objDatabase->fnGetFirstTimeVisitorCount($condition, $arrAtts); if( $condition == 'Compare' ){ $compareAtts = $arrAtts; $compareAtts['from'] = $arrAtts['from']; $compareAtts['to'] = $arrAtts['from']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['from'] ) ); } $urlStatsResult = $this->objDatabase->getContentByURLStats( $compareAtts ); $compareAtts['from'] = $arrAtts['to']; $compareAtts['to'] = $arrAtts['to']; if( $atts['type'] == 'Daily' ){ $compareAtts['to'] = date('Y-m-t', strtotime( $arrAtts['to'] ) ); } }else{ $urlStatsResult = $this->objDatabase->getContentByURLStats( $arrAtts ); } //print_r($arrAtts); $preArrAtts = $arrAtts; $totaiVisitorsToday = $totaiVisitorsYesterday = 0; $totaiVisitorsToday = $this->objDatabase->getContentByURLTotalRecords( $arrAtts ); if($condition=='Normal'){ $startFrom = $arrAtts['from']; $lastFrom = $preArrAtts['from'] = date('Y-m-d', strtotime($preArrAtts['from'] .' -1 day')); $preArrAtts['to'] = $preArrAtts['from']; $totaiVisitorsYesterday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); } if($condition=='Compare'){ $preArrAtts['to'] =$arrAtts['from']; $totaiVisitorsToday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); $startFrom = $arrAtts['to']; $lastFrom = $preArrAtts['to']; $preArrAtts['from'] = $arrAtts['from']; $totaiVisitorsYesterday = $this->objDatabase->getContentByURLTotalRecords( $preArrAtts ); } $graphAttr['to'] = $arrAtts['from']; $graphAttr['from'] = date('Y-m-d', strtotime($arrAtts['from'] .' -30 day')); $graphAttr['action'] = 'getContentUrlDayView'; $html = ''; $site_url = str_replace( array( 'http://www.', 'https://wwww.', 'http://', 'https://','www.'), array(), site_url() ); $title_cloud_array = array(); $title_cloud_html = array(); if( is_array( $urlStatsResult ) && isset( $urlStatsResult['data'] ) && count($urlStatsResult['data'])>0){ $html .= ''; } else { $html = "

Data / Statistics are not available.

"; } return $html; } function wsm_showIPExclustion( $atts ){ $ipAddress = get_option('exclusion_ip_address_list'); $html = '
'; $html .= '
'; $html .= '
'; $html .= ''; $html .= ''; $html .= ''; $html .= '
'; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $count = 1; if( $ipAddress && is_array($ipAddress) ){ foreach( $ipAddress as $address => $status ){ $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $count++; } }else{ $html .= ''; } $html .= '
NoI.P. AddressStatusAction
'.$count.''.$address.'Delete
'.__('No records found.').'
'; $html .= '
'; return $html; } function wsm_showGeneralStats() { add_action('wp_footer', array('wsmInitPlugin',WSM_PREFIX. '_commonScript')); $totalPageViews=$this->objDatabase->fnGetTotalPageViewCount(); $totalVisitors=$this->objDatabase->fnGetTotalVisitorsCount('Today'); $todayVisitors=$this->objDatabase->fnGetTotalVisitorsCount('Online'); $onlineVisitors=$this->objDatabase->fnGetTotalVisitorsCount('Online'); $pageViews=0; if($totalPageViews>0 && $totalVisitors>0){ $pageViews=($totalPageViews/$totalVisitors); } $totalPageViews=number_format_i18n($totalPageViews,0); $totalVisitors=number_format_i18n($totalVisitors,0); $pageViews=number_format_i18n($pageViews,2); $onlineVisitors=number_format_i18n($onlineVisitors,0); $html ="
"; $html ="
"; $html .="
".$onlineVisitors."
"; $html .="
"; $html .="
"; $html .="
".$todayVisitors."
"; $html .="
"; $html .="
"; $html .="
".$totalPageViews."
"; $html .="
"; $html .="
"; $html .="
".$totalVisitors."
"; $html .="
"; $html .="
"; return $html; } }