public function tags_cloud()
 {
     $max_font_size = 28;
     $min_font_size = 8;
     $factory = new statisticFactory(dirname(__FILE__) . '/classes');
     $factory->isValid('allTags');
     $report = $factory->get('allTags');
     $report->setDomain($this->domain);
     $report->setUser($this->user);
     $report->setStart($this->from_time);
     $report->setFinish($this->to_time);
     $result = $report->get();
     $max = $result['max'];
     $sum = $result['sum'];
     $lines = array();
     $sz = sizeof($result['labels']);
     for ($i = 0; $i < $sz; $i++) {
         $label = $result['labels'][$i];
         $id = $label['id'];
         $tag = $label['tag'];
         $cnt = $label['cnt'];
         $font_size = ceil(($max_font_size - $min_font_size) * ($cnt / $max)) + $min_font_size;
         $proc = round($cnt * 100 / $sum, 1);
         $lines[] = array('attribute:id' => $id, 'attribute:weight' => $proc, 'attribute:fontweight' => $font_size, 'node:name' => $tag);
     }
     return !empty($lines) ? array('nodes:tag' => $lines) : array('nodes:message' => array(array('node:name' => getLabel('message-no-tags'))));
 }
 public function tagsCloud($template = "default", $limit = 50, $max_font_size = 16)
 {
     list($template_block, $template_line, $template_separator) = def_module::loadTemplates("stat/" . $template, "tags_block", "tags_block_line", "tags_separator");
     $factory = new statisticFactory(dirname(__FILE__) . '/classes');
     $factory->isValid('allTags');
     $report = $factory->get('allTags');
     $report->setStart(0);
     $report->setFinish(strtotime("+1 day", time()));
     $result = $report->get();
     $max = $result['max'];
     $lines = array();
     $i = 0;
     $sz = sizeof($result['labels']);
     for ($i = 0; $i < min($sz, $limit); $i++) {
         $label = $result['labels'][$i];
         $line_arr = array();
         $tag = $label['tag'];
         $cnt = $label['cnt'];
         $fontSize = ceil($max_font_size * ($cnt / $max));
         $line_arr['node:tag'] = $tag;
         $line_arr['attribute:cnt'] = $cnt;
         $line_arr['attribute:font-size'] = $fontSize;
         $line_arr['void:separator'] = $i < $sz - 1 ? $template_separator : "";
         $line_arr['void:font_size'] = $fontSize;
         $lines[] = def_module::parseTemplate($template_line, $line_arr);
     }
     $block_arr = array();
     $block_arr['subnodes:lines'] = $lines;
     $block_arr['total'] = $sz;
     $block_arr['per_page'] = $limit;
     return def_module::parseTemplate($template_block, $block_arr);
 }
Example #3
0
		public function json_get_referer_pages() {
            $this->updateFilter();
			$requestId = (int) $_REQUEST['requestId'];
			
			if($host = getRequest('host')) {
				$_SERVER['HTTP_HOST'] = $host;
			}

			$domain_url = "http://" . $_SERVER['HTTP_HOST'];
			$referer_uri = str_replace($domain_url, "", $_SERVER['HTTP_REFERER']);

			$factory = new statisticFactory(dirname(__FILE__) . '/classes');
			$factory->isValid('pageNext');
			$report = $factory->get('pageNext');



			$report->setStart(time() - 3600*24*7);	//TODO: Fix to real dates
			$report->setFinish(time() + 3600*24);	//TODO: Fix to real dates
			
			if(!$referer_uri) $referer_uri = "/";

			$report->setParams( Array("page_uri" => $referer_uri) );

			$result = $report->get();

			$res = <<<END
var response = new lLibResponse({$requestId});
response.links = new Array();


END;

			$total = 0;

			foreach($result as $r_item) {
				$total += (int) $r_item['abs'];

				$res .= <<<END
response.links[response.links.length] = {"uri": "{$r_item['uri']}", "abs": "{$r_item['abs']}"};

END;
			}


			$res .= <<<END

response.total = '{$total}';

END;


			$res .= <<<END

lLib.getInstance().makeResponse(response);

END;

			$this->flush($res);
		}
    public function phrase()
    {
        $sReturnMode = getRequest('param1');
        // !!!
        $query_id = $_REQUEST['param0'];
        $thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
        $thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
        $thisMdlUrl = '/' . $thisLang . '/admin/stat/';
        $thisUrl = $thisMdlUrl . __FUNCTION__ . "/" . $query_id;
        $thisUrlTail = '';
        $params = array();
        $this->updateFilter();
        $factory = new statisticFactory(dirname(__FILE__) . '/classes');
        $factory->isValid('sourcesSEOKeywordsConcrete');
        $report = $factory->get('sourcesSEOKeywordsConcrete');
        $report->setStart($this->from_time);
        $report->setFinish($this->to_time);
        $report->setLimit($this->items_per_page);
        $report->setParams(array("query_id" => $query_id));
        $report->setDomain($this->domain);
        $report->setUser($this->user);
        if ($sReturnMode === 'xml') {
            $result = $report->get();
            $iHoveredAbs = 0;
            $iTotalAbs = $result['summ'];
            $iTotalRecs = $result['total'];
            $sAnswer = "";
            $sAnswer .= "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n";
            $sAnswer .= <<<END
\t\t\t\t\t<statistics>
\t\t\t\t\t<report name="sourcesSEOKeywordsConcrete" title="Поисковые системы по выбранной фразе" host="{$thisHost}" lang="{$thisLang}"  timerange_start="{$this->from_time}" timerange_finish="{$this->to_time}">
\t\t\t\t\t<table>
\t\t\t\t\t\t<column field="name" title="Поисковая система" valueSuffix="" prefix="" />
\t\t\t\t\t\t<column field="cnt" title="Переходы абс." units="" prefix="" />
\t\t\t\t\t\t<column field="rel" title="Переходы отн." valueSuffix="%" prefix="" />
\t\t\t\t\t</table>
\t\t\t\t\t<chart type="pie">
\t\t\t\t\t\t<argument />
\t\t\t\t\t\t<value field="cnt" />
\t\t\t\t\t\t<caption field="name" />
\t\t\t\t\t</chart>
\t\t\t\t\t
\t\t\t\t\t<data>
END;
            foreach ($result['all'] as $info) {
                $iAbs = $info['cnt'];
                $iHoveredAbs += $iAbs;
                $attr_uri = '';
                $attr_name = htmlspecialchars($info['name']);
                //
                $fRel = round($iAbs / ($iTotalAbs / 100), 1);
                $sAnswer .= <<<END
\t\t\t\t\t\t<row cnt="{$iAbs}" name="{$attr_name}" uri="{$attr_uri}" rel="{$fRel}" />
END;
            }
            $iRest = $iTotalAbs - $iHoveredAbs;
            if ($iRest > 0) {
                $sAnswer .= "<row cnt=\"{$iRest}\" name=\"Прочее\" uri=\"\" rel=\"" . round($iRest / ($iTotalAbs / 100), 1) . "\" />";
            }
            $sAnswer .= "</data>\n";
            $sAnswer .= "</report></statistics>";
            //
            header("Content-type: text/xml; charset=utf-8");
            header("Content-length: " . strlen($sAnswer));
            $this->flush($sAnswer);
            return "";
        }
        $params = array();
        $params['filter'] = $this->getFilterPanel();
        $params['ReportPhrase']['flash:report'] = "url=" . $thisUrl . "/xml/" . $thisUrlTail;
        $this->setDataType("settings");
        $this->setActionType("view");
        $data = $this->prepareData($params, 'settings');
        $this->setData($data);
        return $this->doData();
    }
		public function visitersCommonHours() {
			$this->updateFilter();
			$sReturnMode = getRequest('param0');
			//
			
			//
			
			
			
			//
			$thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
			$thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
			$thisUrl = '/'.$thisLang.'/admin/stat/'.__FUNCTION__;
			$thisUrlTail = '';
			//
			$factory = new statisticFactory(dirname(__FILE__) . '/classes');
			$factory->isValid('visitersCommonHours');
			$report = $factory->get('visitersCommonHours');
			//
			$report->setStart($this->from_time);
			$report->setFinish($this->to_time);
			$report->setDomain($this->domain); $report->setUser($this->user);
			//$report->setLimit($this->items_per_page);
			//
			//
			//
			if ($sReturnMode === 'xml') {
				$result = $report->get();

				$iHoveredAbs = 0; $iTotalAbs = $result['summ'];
				$iTotalRecs = $result['total'];
				$sAnswer = "";
				$sAnswer .= "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
				$sAnswer .= <<<END
					<statistic report="visitCommonHours" title="Динамика захода посетителей за выбранный период по часам суток" host="{$thisHost}" lang="{$thisLang}"  timerange_start="{$this->from_time}" timerange_finish="{$this->to_time}">
					<cols>
						<col name="name" title="Час" valueSuffix="" prefix="" />
						<col name="cnt" title="Посетителей" valueSuffix="" prefix="" />
					</cols>
					<reports>
						<report type="xml" title="xml" uri="{$thisUrl}/xml/{$thisUrlTail}" />
						<report type="txt" title="txt" uri="{$thisUrl}/txt/{$thisUrlTail}" />
						<report type="rfccsv" title="csv" uri="{$thisUrl}/rfccsv/{$thisUrlTail}" />
						<report type="mscsv" title="xls" uri="{$thisUrl}/mscsv/{$thisUrlTail}" />
					</reports>
					<details>
END;
					$iHour = 0;
					for ($iHour = 0; $iHour < 24; $iHour++) {
						if (isset($result['detail'][$iHour])) {
							$info = $result['detail'][$iHour];
						} else {
							$info = array('ts'=>mktime($iHour), 'cnt'=>0);
						}
						//
						$iAbs = $info['cnt'];
						$iHoveredAbs += $iAbs;
						$page_uri = '';
						$iTtlHour = intval(date('G', $info['ts']));
						$page_title = $iTtlHour."..".($iTtlHour+1);
						//
						$attr_page_title = htmlspecialchars($page_title);
						$attr_uri= htmlspecialchars($page_uri);
						//
						$sAnswer .= "<detail ";
							$sAttrs = '';
							$sAttrs .= 'cnt="'.$iAbs.'" ';
							$sAttrs .= 'name="'.$attr_page_title.'" ';
							$sAttrs .= 'uri="'.$attr_uri.'" ';
							$sAttrs .= 'ts="'.$info['ts'].'" ';
							$sAttrs .= 'hour="'.$iTtlHour.'" ';
							$sAnswer .= $sAttrs;
						$sAnswer .= "/>\n";
					}
					$iRest = ($iTotalAbs - $iHoveredAbs);
					if ($iRest > 0) {
						$sAnswer .= "<detail cnt=\"{$iRest}\" name=\"Прочее\" uri=\"\" />";
					}
					$sAnswer .= "</details>\n";
				$sAnswer .= "</statistic>";
				//
				header("Content-type: text/xml; charset=utf-8");
				header("Content-length: ".strlen($sAnswer));
				$this->flush($sAnswer);
				return "";
			} else {
				$params = array();
				$params['swf'] = <<<END
		<statgraph w="100%" h="530" id="linear" align="middle" src="/images/cms/stat/line.swf" quality="high" bgcolor="#ffffff">
			<flashvar disable-output-escaping="yes"><![CDATA[xmlswf=/images/cms/stat/xml.swf&xmlini=/images/cms/stat/ini/ini.xml&xmlstat={$thisUrl}/xml/{$thisUrlTail}]]></flashvar>
		</statgraph>
END;
				$params['stat_param'] = $this->returnParamPanel();
				
				if(!(cmsController::getInstance()->getModule("geoip") === false))
				$params['city_report'] = '[<a href="%pre_lang%/admin/stat/auditoryLocation/"><b><![CDATA[Города]]></b></a>]&nbsp;';
				
				//
				return $this->parse_form("visitersCommonHours", $params);
			}
		}
Example #6
0
 public function getCurrentUserTags()
 {
     if (!$this->enabled) {
         return;
     }
     if (isset($_SESSION['stat']['user_id'])) {
         $stat_user_id = $_SESSION['stat']['user_id'];
     } else {
         return false;
     }
     $factory = new statisticFactory(dirname(__FILE__) . '/classes');
     $factory->isValid('fastUserTags');
     $report = $factory->get('fastUserTags');
     $report->setParams(array("user_id" => $stat_user_id));
     $user_info = $report->get();
     return $user_info['labels'];
 }
	public function openstatAdsByService() {
		//
		$iServiceId = intval(getRequest('param0'));
		$sReturnMode = getRequest('param1'); // !!!
		
		//
        $this->updateFilter();
		
		
		
		//
		$thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
		$thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
		$thisUrl = '/'.$thisLang.'/admin/stat/'.__FUNCTION__;
		$thisUrlTail = '';
		//
		$factory = new statisticFactory(dirname(__FILE__) . '/classes');
		$factory->isValid('openstatAds');
		$report = $factory->get('openstatAds');
		//
		$report->setParams(array('service_id'=>$iServiceId));
		$report->setStart($this->from_time);
		$report->setFinish($this->to_time);
		$report->setDomain($this->domain); $report->setUser($this->user);
		$report->setLimit($this->items_per_page);
		
		//
		if ($sReturnMode === 'xml') {
			$result = $report->get();

			$iHoveredAbs = 0; $iTotalAbs = $result['summ'];
			$iTotalRecs = $result['total'];
			$sAnswer = "";
			$sAnswer .= "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
			$sAnswer .= <<<END
				<statistics><report name="openstatAdsByService" title="Рекламные объявления ресурса" host="{$thisHost}" lang="{$thisLang}"  timerange_start="{$this->from_time}" timerange_finish="{$this->to_time}">
				<table>
					<column field="name" title="Рекламное объявление" prefix="" valueSuffix="" />
					<column field="cnt" title="Переходов абс." prefix="" valueSuffix="" />
					<column field="rel" title="Переходов отн." prefix="" valueSuffix="%" />
				</table>
				<chart type="pie">
						<argument />
						<value field="cnt" />
						<caption field="name" />
				</chart>
				<data>
END;
				foreach($result['all'] as $info) {
					$iAbs = $info['abs']; $iHoveredAbs += $iAbs;
					$fRel = $info['rel'];
					$sName = $info['name'];
					$sUri = "";
					//
					$attr_name = htmlspecialchars($sName);
					$attr_cnt = $iAbs;
					$attr_rel = round($fRel, 1);
					$attr_uri= htmlspecialchars($sUri);
					//
					$sAnswer .= <<<END
						<row name="{$attr_name}" cnt="{$attr_cnt}" rel="{$attr_rel}" uri="{$attr_uri}"  />
END;
				}
				$iRest = ($iTotalAbs - $iHoveredAbs);
				if ($iRest > 0) {
					$fRestRel = round($iRest/($iTotalAbs/100), 1);
					$sAnswer .= <<<END
						<row name="Прочее" cnt="{$iRest}" rel="{$fRestRel}" uri=""  />
END;
				}
				$sAnswer .= "</data>\n";
			$sAnswer .= "</report></statistics>";
			//
			header("Content-type: text/xml; charset=utf-8");
			header("Content-length: ".strlen($sAnswer));
			$this->flush($sAnswer);
			return "";
		} else {
			$params = array();
            $params['filter'] = $this->getFilterPanel();            
            $params['ReportOpenstatAdsByService']['flash:report']  = "url=".$thisUrl."/xml/".$thisUrlTail;            
            $this->setDataType("settings");
            $this->setActionType("view");
            $data = $this->prepareData($params, 'settings');
            $this->setData($data);                        
            return $this->doData();
		}
	}
    public function sectionHitsIncluded()
    {
        $sReturnMode = getRequest('param1');
        // !!!
        $sSectionId = getRequest('param0');
        $thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
        $thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
        $thisUrl = '/' . $thisLang . '/admin/stat/' . __FUNCTION__ . "/" . $sSectionId;
        $thisUrlTail = '';
        $this->updateFilter();
        $factory = new statisticFactory(dirname(__FILE__) . '/classes');
        $factory->isValid('sectionHits');
        $report = $factory->get('sectionHits');
        $report->setStart($this->from_time);
        $report->setFinish($this->to_time);
        $report->setLimit($this->items_per_page);
        $report->setDomain($this->domain);
        $report->setUser($this->user);
        if ($sReturnMode === 'xml') {
            $result = $report->getIncluded($sSectionId);
            $iHoveredAbs = 0;
            $iTotalAbs = $result['summ'];
            $iTotalRecs = $result['total'];
            $sAnswer = "";
            $sAnswer .= "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n";
            $sAnswer .= <<<END
\t\t\t\t<statistics>
\t\t\t\t<report name="pagesHits" title="Популярность подразделов" host="{$thisHost}" lang="{$thisLang}"  timerange_start="{$this->from_time}" timerange_finish="{$this->to_time}">
\t\t\t\t<table>
\t\t\t\t\t<column field="name" title="Раздел" prefix="" valueSuffix="" datatipField="uri" />
\t\t\t\t\t<column field="cnt" title="Показов абс." prefix="" valueSuffix="" />
\t\t\t\t\t<column field="rel" title="Показов отн." prefix="" valueSuffix="%" />
\t\t\t\t</table>
\t\t\t\t<chart type="pie">
\t\t\t\t\t<argument />
\t\t\t\t\t<value field="cnt" />
\t\t\t\t\t<caption field="name" />
\t\t\t\t</chart>
\t\t\t\t<data lcol="Раздел" rcol="Запросов">
END;
            foreach ($result['all'] as $info) {
                $iAbs = $info['abs'];
                $fRel = $info['rel'];
                $iHoveredAbs += $iAbs;
                $page_uri = $info['uri'];
                $page_title = '';
                //
                if ($element_id = umiHierarchy::getInstance()->getIdByPath($page_uri)) {
                } elseif ($page_uri == "/") {
                    $element_id = umiHierarchy::getInstance()->getDefaultElementId();
                }
                if ($element = umiHierarchy::getInstance()->getElement($element_id)) {
                    $page_title = $element->getName();
                }
                if (!strlen($page_title)) {
                    $page_title = $info['section'];
                }
                //
                $attr_page_title = htmlspecialchars($page_title);
                $attr_uri = htmlspecialchars($page_uri);
                //
                $sAnswer .= "<row ";
                $sAttrs = '';
                $sAttrs .= 'cnt="' . $iAbs . '" ';
                $sAttrs .= 'name="' . $attr_page_title . '" ';
                $sAttrs .= 'uri="' . $attr_uri . '" ';
                $sAttrs .= 'rel="' . round($fRel, 1) . '" ';
                foreach ($info as $sName => $sVal) {
                    if ($sName !== 'cnt' && $sName !== 'name' && $sName !== 'uri' && $sName !== 'rel') {
                        $sAttrs .= $sName . '="' . htmlspecialchars($sVal, ENT_COMPAT) . '" ';
                    }
                }
                $sAnswer .= $sAttrs;
                $sAnswer .= "/>\n";
            }
            $iRest = $iTotalAbs - $iHoveredAbs;
            if ($iRest > 0) {
                $sAnswer .= "<row cnt=\"{$iRest}\" name=\"Прочее\" uri=\"\" rel=\"" . round($iRest / ($iTotalAbs / 100), 1) . "\" />";
            }
            $sAnswer .= "</data>\n";
            $sAnswer .= "</report>\n</statistics>";
            //
            header("Content-type: text/xml; charset=utf-8");
            header("Content-length: " . strlen($sAnswer));
            $this->flush($sAnswer);
            return "";
        }
        $params = array();
        $params['filter'] = $this->getFilterPanel();
        $params['ReportSubsectionsPopularity']['flash:report'] = "url=" . $thisUrl . "/xml/" . $thisUrlTail;
        $this->setDataType("settings");
        $this->setActionType("view");
        $data = $this->prepareData($params, 'settings');
        $this->setData($data);
        return $this->doData();
    }
 public function tags_mk_cloud($i_domain_id = NULL, $s_template = "tags", $i_per_page = -1, $b_ignore_paging = true, $b_by_usage = false, $arr_users = array())
 {
     // init and context :
     $s_tpl_tags = "cloud_tags";
     $s_tpl_tag = "cloud_tag";
     $s_tpl_tag_sep = "cloud_tagseparator";
     $s_tpl_tags_empty = "cloud_tags_empty";
     // validate input :
     if (!$arr_users || intval($arr_users) === -1 || strval($arr_users) === 'all' || $arr_users == "Все") {
         $arr_users = array();
     }
     if (is_int($arr_users)) {
         $arr_users = array(intval($arr_users));
     } elseif (is_array($arr_users)) {
         $arr_users = array_map('intval', $arr_users);
     } else {
         $arr_users = array(intval(strval($arr_users)));
     }
     $i_per_page = intval($i_per_page);
     if (!$i_per_page) {
         $i_per_page = 10;
     }
     if ($i_per_page === -1) {
         $b_ignore_paging = true;
     }
     $s_template = strval($s_template);
     if (!strlen($s_template)) {
         $s_template = "tags";
     }
     $i_curr_page = intval(getRequest('p'));
     if ($b_ignore_paging) {
         $i_curr_page = 0;
     }
     // load templates :
     list($tpl_tags, $tpl_tag, $tpl_tag_sep, $tpl_tags_empty) = $this->loadTemplates("content/" . $s_template, $s_tpl_tags, $s_tpl_tag, $s_tpl_tag_sep, $s_tpl_tags_empty);
     // process :
     $max_font_size = 32;
     $min_font_size = 10;
     //
     $s_prefix = '';
     //
     if ($b_by_usage) {
         $o_object_type = umiObjectTypesCollection::getInstance()->getTypeByGUID('root-pages-type');
         $i_tags_field_id = $o_object_type->getFieldId('tags');
         //
         $result = umiObjectProperty::objectsByValue($i_tags_field_id, 'all', true, true, $i_domain_id ? $i_domain_id : -1);
     } else {
         $stat = cmsController::getInstance()->getModule('stat');
         $sStatIncPath = dirname(dirname(dirname(dirname(__FILE__)))) . '/stat/classes';
         if (class_exists("statisticFactory") == false) {
             return;
         }
         $factory = new statisticFactory($sStatIncPath);
         $factory->isValid('allTags');
         $report = $factory->get('allTags');
         if ($i_domain_id) {
             $s_prefix = 'Domain';
             $v_domains = $report->setDomain($i_domain_id);
         } else {
             $s_prefix = 'Account';
             $v_domains = $report->setDomain(-1);
         }
         if (is_array($arr_users) && count($arr_users)) {
             $report->setUserIDs($arr_users);
         }
         $result = $report->get();
     }
     if (isset($result['values']) && is_array($result['values'])) {
         natsort2d($result['values'], "cnt");
         $result['values'] = array_slice($result['values'], -$i_per_page, $i_per_page);
         natsort2d($result['values'], "value");
     }
     $max = intval($result['max']);
     $sum = intval($result['sum']);
     $arrTags = array();
     $s_values_label = $b_by_usage ? 'values' : 'labels';
     $s_value_label = $b_by_usage ? 'value' : 'tag';
     $s_value_cnt = 'cnt';
     $sz = sizeof($result[$s_values_label]);
     for ($i = 0; $i < $sz; $i++) {
         $label = $result[$s_values_label][$i];
         $tag = $label[$s_value_label];
         if (is_null($tag)) {
             continue;
         }
         //$tag = '[nontagged]';
         $cnt = intval($label[$s_value_cnt]);
         $f_weight = round($cnt * 100 / $sum, 1);
         $font_size = round(($max_font_size - $min_font_size) / 100 * $f_weight + $min_font_size);
         $arrTags[$tag] = array('weight' => $f_weight, 'font' => $font_size);
     }
     //
     $summ_weight = 0;
     if (count($arrTags)) {
         $arrTagsTplteds = array();
         foreach ($arrTags as $sTag => $arrTagStat) {
             $summ_weight += $arrTagStat['weight'];
             $params = array('tag' => $sTag, 'tag_urlencoded' => rawurlencode($sTag), 'attribute:weight' => $arrTagStat['weight'], 'attribute:font' => $arrTagStat['font'], 'attribute:context' => $s_prefix);
             $arrTagsTplteds[] = def_module::parseTemplate($tpl_tag, $params);
         }
         if (isset($arrTagsTplteds[0]) && is_array($arrTagsTplteds[0])) {
             // udata
             $arrForTags = array('subnodes:items' => $arrTagsTplteds);
         } else {
             // not udata
             $arrForTags = array('items' => implode($tpl_tag_sep, $arrTagsTplteds));
         }
         //
         $arrForTags['attribute:summ_weight'] = ceil($summ_weight);
         $arrForTags['attribute:context'] = $s_prefix;
         // RETURN
         return def_module::parseTemplate($tpl_tags, $arrForTags);
     } else {
         $arrForTags = array();
         // RETURN
         return def_module::parseTemplate($tpl_tags_empty, $arrForTags);
     }
 }
Example #10
0
    public function sources_entry()
    {
        $this->updateFilter();
        //
        $sReturnMode = getRequest('param1');
        // !!!
        $source_id = (int) $_REQUEST['param0'];
        $thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
        $thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
        $thisMdlUrl = '/' . $thisLang . '/admin/stat/';
        $thisUrl = $thisMdlUrl . __FUNCTION__ . "/" . $source_id;
        $thisUrlTail = '';
        if ($sReturnMode == 'xml') {
            $factory = new statisticFactory(dirname(__FILE__) . '/classes');
            $factory->isValid('entryByReferer');
            $report = $factory->get('entryByReferer');
            $report->setStart($this->from_time);
            $report->setFinish($this->to_time);
            $report->setParams(array("source_id" => $source_id));
            $report->setDomain($this->domain);
            $report->setUser($this->user);
            $aRet = $report->get();
            $sAnswer = "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n";
            $sAnswer .= '<statistics>					
					<report name="sourcesEntry" title="Точки входа для выбранного источника" 
							host="' . $thisHost . '" lang="' . $thisLang . '" timerange_start="' . $this->from_time . '" timerange_finish="' . $this->to_time . '">
					<table>
						<column field="name"  title="Точка входа" datatipField="uri" />
						<column field="count" title="Переходов"  />
					</table>
					<chart type="pie">
						<argument />
						<value field="count" />
						<caption field="name" />
					</chart>					
					<data>';
            foreach ($aRet as $aRow) {
                $sName = $aRow['section'];
                $sURI = htmlspecialchars($aRow['uri']);
                $iCount = $aRow['count'];
                $sAnswer .= "<row name=\"" . $sName . "\" count=\"" . $iCount . "\" uri=\"" . $sURI . "\" />";
            }
            $sAnswer .= "</data></report></statistics>";
            header("Content-type: text/xml; charset=utf-8");
            header("Content-length: " . strlen($sAnswer));
            $this->flush($sAnswer);
            return "";
        }
        $params = array();
        $params['filter'] = $this->getFilterPanel();
        $params['ReportSourcesEntry']['flash:report1'] = "url=" . $thisUrl . "/xml/" . $thisUrlTail;
        $this->setDataType("settings");
        $this->setActionType("view");
        $data = $this->prepareData($params, 'settings');
        $this->setData($data);
        return $this->doData();
    }
Example #11
0
    public function visits_hits()
    {
        $this->updateFilter();
        $sReturnMode = getRequest('param0');
        //
        $curr_page = (int) getRequest('p');
        //
        //
        $thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
        $thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
        $thisUrl = '/' . $thisLang . '/admin/stat/' . __FUNCTION__;
        $thisUrlTail = '';
        //
        $factory = new statisticFactory(dirname(__FILE__) . '/classes');
        //
        if ($sReturnMode === 'xml') {
        } elseif ($sReturnMode === 'xml1') {
            $factory->isValid('visitCommon');
            $report = $factory->get('visitCommon');
            //
            $report->setStart($this->from_time);
            $report->setFinish($this->to_time);
            $report->setDomain($this->domain);
            $report->setUser($this->user);
            //
            $result = $report->get();
            // =================================
            $iHoveredAbs = 0;
            $iTotalAbs = $result['summ'];
            $iTotalRecs = $result['total'];
            $sAnswer = "";
            $sAnswer .= "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n";
            $sAnswer .= <<<END
                <statistics> 
                 <report name="visitCommon" title="Динамика хитов по дням" host="{$thisHost}" lang="{$thisLang}"  timerange_start="{$this->from_time}" timerange_finish="{$this->to_time}">
                <table>
                    <column field="timestamp" title="День" showas="date" valueSuffix="" prefix="" />
                    <column field="count"    title="Хитов (абсолютное значение)" valueSuffix="" prefix="" />
                    <column field="rel"      title="Хитов (относительное значение)" valueSuffix="%" prefix="" />
                </table>
                <chart type="column" drawTrendLine="true">
                    <argument field="timestamp" />
                    <value field="count" description="Количество хитов" axisTitle="Количество хитов" />
                    <caption field="date" />
                </chart>
                <data>

END;
            $iOldTimeStamp = $this->from_time;
            foreach ($result['detail']['result'] as $info) {
                if (!isset($info['ts'])) {
                    $info['ts'] = NULL;
                }
                $sThisDate = date('d M', $info['ts']);
                while ($iOldTimeStamp < $info['ts'] && date('d M', $iOldTimeStamp) != $sThisDate) {
                    $attr_page_uri = htmlspecialchars('');
                    $sAnswer .= "<row " . "timestamp=\"" . $iOldTimeStamp . "\" " . "count=\"0\" " . "date=\"" . __stat_admin::makeDate('d M', $iOldTimeStamp) . "\" " . "uri=\"" . $attr_page_uri . "\" rel=\"0\" />\n";
                    $iOldTimeStamp += 86400;
                }
                $iOldTimeStamp = $info['ts'] + 86400;
                $iAbs = isset($info['cnt']) ? $info['cnt'] : 0;
                $iHoveredAbs += $iAbs;
                $page_uri = '';
                $attr_uri = htmlspecialchars($page_uri);
                $sAnswer .= "<row ";
                $sAttrs = '';
                $sAttrs .= 'timestamp="' . $info['ts'] . '" ';
                $sAttrs .= 'count="' . $iAbs . '" ';
                $sAttrs .= 'date="' . __stat_admin::makeDate('d M', $info['ts']) . '" ';
                $sAttrs .= 'uri="' . $attr_uri . '" ';
                $sAttrs .= 'rel="' . round($iAbs / ($iTotalAbs / 100), 1) . '" ';
                $sAnswer .= $sAttrs;
                $sAnswer .= "/>\n";
            }
            $sThisDate = date('d M', $this->to_time + 86400);
            while ($iOldTimeStamp < $this->to_time + 86400 && date('d M', $iOldTimeStamp) != $sThisDate) {
                $attr_page_uri = htmlspecialchars('');
                $sAnswer .= "<row " . "timestamp=\"" . $iOldTimeStamp . "\" " . "count=\"0\" " . "date=\"" . __stat_admin::makeDate('d M', $iOldTimeStamp) . "\" " . "uri=\"" . $attr_page_uri . "\" rel=\"0\" />\n";
                $iOldTimeStamp += 86400;
            }
            $iRest = $iTotalAbs - $iHoveredAbs;
            $sAnswer .= "</data>\n";
            $sAnswer .= "</report>\n</statistics>";
            //
            header("Content-type: text/xml; charset=utf-8");
            header("Content-length: " . strlen($sAnswer));
            $this->flush($sAnswer);
            return "";
        } elseif ($sReturnMode === 'xml2') {
            $factory->isValid('visitCommonHours');
            $report = $factory->get('visitCommonHours');
            //
            $report->setStart($this->from_time);
            $report->setFinish($this->to_time);
            $report->setDomain($this->domain);
            $report->setUser($this->user);
            //
            $result = $report->get();
            // =================================
            $iHoveredAbs = 0;
            $iTotalAbs = $result['summ'] ? $result['summ'] : 1;
            $iTotalRecs = $result['total'];
            $sAnswer = "";
            $sAnswer .= "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n";
            $sAnswer .= <<<END
                <statistics>
                <report name="visitCommonHours" title="Распеределение хитов по часам суток" host="{$thisHost}" lang="{$thisLang}"  timerange_start="{$this->from_time}" timerange_finish="{$this->to_time}">
                <table>
                    <column field="hourint"  title="Часы" valueSuffix="" prefix="" />
                    <column field="count" title="Хитов (абсолютное значение)" valueSuffix="" prefix="" />
                    <column field="rel"   title="Хитов (относительное значение)" valueSuffix="%" prefix="" />
                </table>
                <chart type="line" drawTrendLine="true">
                    <argument field="hour" />
                    <value field="count" description="Количество хитов" axisTitle="Количество хитов" />
                    <caption field="hourint" />
                </chart>
                <data>

END;
            $iHour = 0;
            for ($iHour = 0; $iHour < 24; $iHour++) {
                if (isset($result['detail'][$iHour])) {
                    $info = $result['detail'][$iHour];
                } else {
                    $info = array('ts' => mktime($iHour), 'cnt' => 0);
                }
                $iAbs = $info['cnt'];
                $iHoveredAbs += $iAbs;
                $page_uri = '';
                $iTtlHour = intval(date('G', $info['ts']));
                $page_title = $iTtlHour . ".." . ($iTtlHour + 1);
                $attr_page_title = htmlspecialchars($page_title);
                $attr_uri = htmlspecialchars($page_uri);
                $sAnswer .= "<row ";
                $sAttrs = '';
                $sAttrs .= 'count="' . $iAbs . '" ';
                $sAttrs .= 'hourint="' . $attr_page_title . '" ';
                $sAttrs .= 'uri="' . $attr_uri . '" ';
                $sAttrs .= 'timestamp="' . $info['ts'] . '" ';
                $sAttrs .= 'rel="' . round($iAbs / ($iTotalAbs / 100), 1) . '" ';
                $sAttrs .= 'hour="' . $iTtlHour . '" ';
                $sAnswer .= $sAttrs;
                $sAnswer .= "/>\n";
            }
            $iRest = $iTotalAbs - $iHoveredAbs;
            $sAnswer .= "</data>\n";
            $sAnswer .= "</report>\n</statistics>";
            //
            header("Content-type: text/xml; charset=utf-8");
            header("Content-length: " . strlen($sAnswer));
            $this->flush($sAnswer);
            return "";
        } else {
            $params = array();
            $params['filter'] = $this->getFilterPanel();
            $params['ReportHitsByDays']['flash:report1'] = "url=" . $thisUrl . "/xml1/" . $thisUrlTail;
            $params['ReportHitsByHours']['flash:report2'] = "url=" . $thisUrl . "/xml2/" . $thisUrlTail;
            $this->setDataType("settings");
            $this->setActionType("view");
            $data = $this->prepareData($params, 'settings');
            $this->setData($data);
            return $this->doData();
        }
    }
Example #12
0
 public function tag() {
     $this->updateFilter();
     $sReturnMode = getRequest('param1');
     $iTagId      = (int) getRequest('param0');
     $thisHost   = cmsController::getInstance()->getCurrentDomain()->getHost();
     $thisLang   = cmsController::getInstance()->getCurrentLang()->getPrefix();
     $thisMdlUrl = '/'.$thisLang.'/admin/stat/';
     $thisUrl    = $thisMdlUrl.__FUNCTION__.'/'.$iTagId;
     //----------------------------------------------------------------------------------
     if($sReturnMode == 'xml') {
         $factory = new statisticFactory(dirname(__FILE__) . '/classes');
         $factory->isValid('tag');
         $report  = $factory->get('tag');
         $report->setStart($this->from_time);
         $report->setFinish($this->to_time);
         $report->setParams(array("tag_id" => $iTagId));
         $report->setDomain($this->domain); $report->setUser($this->user);
         $aRet  = $report->get();
         $sXML  = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">\n";
         $sXML .= "<statistics>\n";
         $sXML .= "  <report name=\"Tag\" title=\"\" lang=\"".$thisLang."\" host=\"".$thisHost."\">
                       <chart type=\"pie\">
                         <argument field=\"uri\" />
                         <value    field=\"count\" />
                         <caption  field=\"uri\" />
                       </chart>
                       <table>
                         <column field=\"uri\"   title=\"Страница\" />
                         <column field=\"count\" title=\"Показов тега (всего)\" />
                         <column field=\"rel\"   title=\"Показов тега (относительно других страниц)\" valueSuffix=\"%\" />
                       </table>
                       <data>";
         foreach($aRet as $aRow) {
             $sXML .= "      <row uri=\"".$aRow['uri']."\" count=\"".$aRow['count']."\" rel=\"".number_format($aRow['rel']*100, 2, '.', '')."\" />";
         }
         $sXML .= "    </data>\n  </report>\n</statistics>";
         header("Content-type: text/xml; charset=utf-8");
         header("Content-length: ".strlen($sXML));
         $this->flush($sXML);
         return "";
     }
     //----------------------------------------------------------------------------------
     $params = array();
     $params['filter'] = $this->getFilterPanel();
     $params['ReportTag']['flash:report1'] = "url=".$thisUrl."/xml/";
     $this->setDataType("settings");
     $this->setActionType("view");
     $data = $this->prepareData($params, 'settings');
     $this->setData($data);
     return $this->doData();
 }
    public function auditoryLocation()
    {
        $this->updateFilter();
        //
        $sReturnMode = getRequest('param0');
        // !!!
        $curr_page = 0;
        //(int) isset($_REQUEST['p'])?;
        $thisHost = cmsController::getInstance()->getCurrentDomain()->getHost();
        $thisLang = cmsController::getInstance()->getCurrentLang()->getPrefix();
        $thisMdlUrl = '/' . $thisLang . '/admin/stat/';
        $thisUrl = $thisMdlUrl . __FUNCTION__ . "/";
        $thisUrlTail = '';
        if ($sReturnMode == 'xml') {
            $factory = new statisticFactory(dirname(__FILE__) . '/classes');
            $factory->isValid('cityStat');
            $report = $factory->get('cityStat');
            $report->setStart($this->from_time);
            $report->setFinish($this->to_time);
            $report->setDomain($this->domain);
            $report->setUser($this->user);
            $aRet = $report->get();
            $sAnswer = "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">\n";
            $sAnswer .= '<statistics>                    
				<report name="auditoryLocation" title="Распределение аудитории по городам" 
						host="' . $thisHost . '" lang="' . $thisLang . '" timerange_start="' . $this->from_time . '" timerange_finish="' . $this->to_time . '">
				<table>
					<column field="name"  title="Город" />
					<column field="count" title="Количество посетителей"  />
				</table>
				<chart type="pie">
					<argument />
					<value field="count" />
					<caption field="name" />
				</chart>                    
				<data>';
            foreach ($aRet as $aRow) {
                $sName = $aRow['location'];
                $iCount = $aRow['count'];
                $sAnswer .= "<row name=\"" . $sName . "\" count=\"" . $iCount . "\" />";
            }
            $sAnswer .= "</data></report></statistics>";
            header("Content-type: text/xml; charset=utf-8");
            header("Content-length: " . strlen($sAnswer));
            $this->flush($sAnswer);
            return "";
        }
        if (!(cmsController::getInstance()->getModule("geoip") === false)) {
            $params = array();
            $params['filter'] = $this->getFilterPanel();
            $params['ReportLocation']['flash:report1'] = "url=" . $thisUrl . "/xml/" . $thisUrlTail;
            $this->setDataType("settings");
            $this->setActionType("view");
            $data = $this->prepareData($params, 'settings');
            $this->setData($data);
            return $this->doData();
            //END;
        } else {
            throw new publicAdminException(getLabel('error-no-geoip'));
            return null;
        }
    }
 public function tags_mk_eff_cloud($i_domain_id = NULL, $s_template = "tags", $i_per_page = -1, $b_ignore_paging = true, $arr_users = array())
 {
     if (!$arr_users || intval($arr_users) === -1 || strval($arr_users) === 'all' || $arr_users == "Все") {
         $arr_users = array();
     }
     if (is_int($arr_users)) {
         $arr_users = array(intval($arr_users));
     } elseif (is_array($arr_users)) {
         $arr_users = array_map('intval', $arr_users);
     } else {
         $arr_users = array(intval(strval($arr_users)));
     }
     $i_per_page = intval($i_per_page);
     if (!$i_per_page) {
         $i_per_page = 10;
     }
     if ($i_per_page === -1) {
         $b_ignore_paging = true;
     }
     $s_template = strval($s_template);
     if (!strlen($s_template)) {
         $s_template = "tags";
     }
     $i_curr_page = intval(getRequest('p'));
     if ($b_ignore_paging) {
         $i_curr_page = 0;
     }
     // load templates :
     list($tpl_tags, $tpl_tag, $tpl_tag_sep, $tpl_tags_empty) = $this->loadTemplates("content/" . $s_template, "cloud_tags", "cloud_tag", "cloud_tagseparator", "cloud_tags_empty");
     // process :
     $max_font_size = 32;
     $min_font_size = 10;
     $s_prefix = 'Account';
     if ($i_domain_id) {
         $s_prefix = 'Domain';
     }
     // by usage :
     $o_object_type = umiObjectTypesCollection::getInstance()->getTypeByGUID('root-pages-type');
     $i_tags_field_id = $o_object_type->getFieldId('tags');
     //
     $result_u = umiObjectProperty::objectsByValue($i_tags_field_id, 'all', true, true, $i_domain_id ? $i_domain_id : -1);
     // by popularity
     $stat = cmsController::getInstance()->getModule('stat');
     $sStatIncPath = dirname(dirname(dirname(dirname(__FILE__)))) . '/stat/classes';
     $factory = new statisticFactory($sStatIncPath);
     $factory->isValid('allTags');
     $report = $factory->get('allTags');
     if ($i_domain_id) {
         $v_domains = $report->setDomain($i_domain_id);
     } else {
         $v_domains = $report->setDomain(-1);
     }
     if (is_array($arr_users) && count($arr_users)) {
         $report->setUserIDs($arr_users);
     }
     $result_p = $report->get();
     $arrTags = array();
     $i_sum_u = intval($result_u['sum']);
     $i_sum_p = intval($result_p['sum']);
     $arr_usage_tags = $result_u['values'];
     $arr_popular_tags = $result_p['labels'];
     $arr_u_tags = array();
     $arr_p_tags = array();
     $arr_eff_tags = array();
     foreach ($arr_usage_tags as $arr_next_tag) {
         $s_tag = $arr_next_tag['value'];
         $i_tag = intval($arr_next_tag['cnt']);
         $arr_u_tags[$s_tag] = round($i_tag * 100 / $i_sum_u, 1);
         if (!isset($arr_eff_tags[$s_tag])) {
             $arr_eff_tags[$s_tag] = 0;
         }
     }
     foreach ($arr_popular_tags as $arr_next_tag) {
         $s_tag = $arr_next_tag['tag'];
         $i_tag = intval($arr_next_tag['cnt']);
         $arr_p_tags[$s_tag] = round($i_tag * 100 / $i_sum_p, 1);
         if (!isset($arr_eff_tags[$s_tag])) {
             $arr_eff_tags[$s_tag] = 0;
         }
     }
     foreach ($arr_eff_tags as $s_tag => $i_efficiency) {
         if (isset($arr_u_tags[$s_tag]) && isset($arr_p_tags[$s_tag])) {
             $arr_eff_tags[$s_tag] = round($arr_p_tags[$s_tag] / $arr_u_tags[$s_tag], 1);
         } elseif (isset($arr_u_tags[$s_tag])) {
             $arr_eff_tags[$s_tag] = 0;
             // 0/100
         } elseif (isset($arr_p_tags[$s_tag])) {
             $arr_eff_tags[$s_tag] = 1000;
             // 100/0.1 (0.1 - round(x/y, 1))
         }
     }
     $arrTags = array();
     foreach ($arr_eff_tags as $s_tag => $i_efficiency) {
         if (is_null($s_tag)) {
             $s_tag = '[nontagged]';
         }
         $f_weight = round($i_efficiency / 10, 1);
         $i_font = round(($max_font_size - $min_font_size) / 100 * $f_weight + $min_font_size);
         $arrTags[$s_tag] = array('weight' => $f_weight, 'font' => $i_font);
     }
     $summ_weight = 0;
     if (count($arrTags)) {
         $arrTagsTplteds = array();
         foreach ($arrTags as $sTag => $arrTagStat) {
             $summ_weight += $arrTagStat['weight'];
             $params = array('tag' => $sTag, 'tag_urlencoded' => rawurlencode($sTag), 'attribute:weight' => $arrTagStat['weight'], 'attribute:font' => $arrTagStat['font'], 'attribute:context' => $s_prefix);
             $arrTagsTplteds[] = def_module::parseTemplate($tpl_tag, $params);
         }
         if (isset($arrTagsTplteds[0]) && is_array($arrTagsTplteds[0])) {
             // udata
             $arrForTags = array('subnodes:items' => $arrTagsTplteds);
         } else {
             // not udata
             $arrForTags = array('items' => implode($tpl_tag_sep, $arrTagsTplteds));
         }
         //
         $arrForTags['attribute:summ_weight'] = $summ_weight;
         $arrForTags['attribute:context'] = $s_prefix;
         // RETURN
         return def_module::parseTemplate($tpl_tags, $arrForTags);
     } else {
         $arrForTags = array();
         // RETURN
         return def_module::parseTemplate($tpl_tags_empty, $arrForTags);
     }
 }