| Current Path : /var/www/element/data/www/greenpr.ru/bitrix3/modules/seo/admin/ |
| Current File : /var/www/element/data/www/greenpr.ru/bitrix3/modules/seo/admin/seo_tools.php |
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
require_once($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/prolog.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/img.php");
/********************** Check user access rights ***********************/
if (!$USER->CanDoOperation('seo_tools'))
$APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
//Page path
$documentRoot = CSite::GetSiteDocRoot($site);
$absoluteFilePath = $documentRoot.$path;
if (false !== ($pos = strrpos($absoluteFilePath, '/')))
{
$absoluteDirPath = substr($absoluteFilePath, 0, $pos);
}
$path = "/";
if (isset($_REQUEST["path"]) && strlen($_REQUEST["path"]) > 0)
{
$path = $_REQUEST["path"];
$path = Rel2Abs("/", $path);
}
$bReadOnly = false;
if (IsModuleInstalled("fileman"))
{
if (!$USER->CanDoOperation('fileman_admin_files') && !$USER->CanDoOperation('fileman_edit_existent_files'))
$bReadOnly = true;
}
IncludeModuleLangFile(__FILE__);
//Check permissions
if (!is_file($absoluteFilePath))
{
CAdminMessage::ShowMessage(GetMessage('SEO_TOOLS_ERROR_FILE_NOT_FOUND')." (".htmlspecialchars($path).")");
die();
}
elseif (!$USER->CanDoFileOperation('fm_edit_existent_file',Array($site, $path)))
{
$bReadOnly = true;
}
function SeoShowHelp($topic)
{
$msg = GetMessage('SEO_HELP_'.$topic);
if (strlen($msg) > 0)
{
$msg = ShowJSHint($msg, array('return' => true));
}
return $msg;
}
function CMP($a,$b){if($a['TOTAL']==$b['TOTAL'])return 0;return ($a['TOTAL']<$b['TOTAL'])?1:-1;}
CModule::IncludeModule('seo');
//get site settings
$site = SITE_ID;
if (isset($_REQUEST["site"]) && strlen($_REQUEST["site"]) > 0)
{
$obSite = CSite::GetByID($_REQUEST["site"]);
if ($arSite = $obSite->Fetch())
{
$site = $_REQUEST["site"];
$server_name = $arRes['SERVER_NAME'];
if (strlen($server_name) <= 0)
$server_name = COption::GetOptionString('main', 'server_name', '');
}
}
//lang
if (!isset($_REQUEST["lang"]) || strlen($_REQUEST["lang"]) <= 0)
$lang = LANGUAGE_ID;
// title changers
if (strlen($_REQUEST['title_changer_name']))
$titleChangerName = $_REQUEST['title_changer_name'];
if (strlen($_REQUEST['title_changer_link']) > 0)
$titleChangerLink = base64_decode($_REQUEST['title_changer_link']);
if (strlen($_REQUEST['title_final']))
$titleFinal = $_REQUEST['title_final'];
// browser title changers
if (strlen($_REQUEST['title_win_changer_name']))
$titleWinChangerName = $_REQUEST['title_win_changer_name'];
if (strlen($_REQUEST['title_win_changer_link']) > 0)
$titleWinChangerLink = base64_decode($_REQUEST['title_win_changer_link']);
if (strlen($_REQUEST['title_win_final']))
$titleWinFinal = $_REQUEST['title_win_final'];
//back url processing
$back_url = (isset($_REQUEST["back_url"]) ? $_REQUEST["back_url"] : "");
$original_backurl = $back_url;
if (false !== ($pos = strpos($back_url, '?')))
{
$query = substr($back_url, $pos+1);
$back_url = substr($back_url, 0, $pos);
$arQuery = explode('&', $query);
$arExcludedParams = array('clear_cache', 'clear_cache_session', 'back_url_admin', 'login', 'logout', 'compress');
foreach ($arQuery as $key => $param)
{
if (false !== ($pos = strpos($param, '=')))
{
$param_name = substr($param, 0, $pos);
if (substr($param_name, 0, 7) == 'bitrix_' || substr($param_name, 0, 7) == 'show_' || in_array($param_name, $arExcludedParams))
{
unset($arQuery[$key]);
}
}
}
if (count($arQuery) > 0)
{
$back_url .= '?'.implode('&', $arQuery);
}
}
$fileContent = $APPLICATION->GetFileContent($absoluteFilePath);
/************************** GET/POST processing ***************************************/
$strWarning = '';
if ($_SERVER["REQUEST_METHOD"] == "POST" && !check_bitrix_sessid())
{
CUtil::JSPostUnescape();
$strWarning = GetMessage("MAIN_SESSION_EXPIRED");
}
elseif (!$bReadOnly && $_SERVER["REQUEST_METHOD"] == "POST" && isset($_REQUEST["save"]))
{
//Title
if (isset($_POST["pageTitle"]) && strlen($_POST["pageTitle"]) > 0)
{
$fileContent = SetPrologTitle($fileContent, $_POST["pageTitle"]);
}
//Title
$prop_code = COption::GetOptionString('seo', 'property_window_title', 'title');
if (isset($_POST["property_".$prop_code]))
{
$fileContent = SetPrologProperty($fileContent, $prop_code, $_POST["property_".$prop_code]);
}
//Properties
if (isset($_POST["PROPERTY"]) && is_array($_POST["PROPERTY"]))
{
foreach ($_POST["PROPERTY"] as $arProperty)
{
$arProperty["CODE"] = (isset($arProperty["CODE"]) ? trim($arProperty["CODE"]) : "");
$arProperty["VALUE"] = (isset($arProperty["VALUE"]) ? trim($arProperty["VALUE"]) : "");
if (preg_match("/[a-zA-Z_-~]+/i", $arProperty["CODE"]))
{
$fileContent = SetPrologProperty($fileContent, $arProperty["CODE"], $arProperty["VALUE"]);
}
}
}
$prop_code = COption::GetOptionString('seo', 'property_internal_keywords', 'keywords_inner');
if ($arProperty = explode(",", $_POST["property_".$prop_code."_local"]))
{
array_walk($arProperty, 'trim');
$fileContent = SetPrologProperty($fileContent, $prop_code, implode(', ', $arProperty));
}
$success = $APPLICATION->SaveFileContent($absoluteFilePath, $fileContent);
if ($success)
{
if (isset($_POST["property_".$prop_code."_section"]))
{
$arProperty = explode(",", $_POST["property_".$prop_code."_section"]);
if (!is_array($arProperty)) $arProperty = array();
array_walk($arProperty, 'trim');
$arDirProperties = array();
$sSectionName = '';
if (file_exists($_SERVER['DOCUMENT_ROOT'].$absoluteDirPath."/.section.php"))
require($_SERVER['DOCUMENT_ROOT'].$absoluteDirPath."/.section.php");
$arDirProperties[$prop_code] = implode(', ', $arProperty);
$strSectionName = '$sSectionName = "'.EscapePHPString($sSectionName).'";';
$strDirProperties = "\$arDirProperties = Array(\n";
$bNeedComma = false;
foreach ($arDirProperties as $prop_code => $value)
{
if (strlen($value) > 0 && preg_match("/[a-zA-Z_-~]+/i", $prop_code) )
{
if($bNeedComma)
$strDirProperties .= ",\n";
$strDirProperties .= " \"".EscapePHPString($prop_code)."\" => \"".EscapePHPString($value)."\"";
$bNeedComma = true;
}
}
$strDirProperties .= "\n);\n";
$APPLICATION->SaveFileContent($absoluteDirPath."/.section.php", "<"."?\n".$strSectionName."\n".$strDirProperties."?".">");
}
}
if ($success === false && ($exception = $APPLICATION->GetException()))
$strWarning = $exception->msg;
else
LocalRedirect("/".ltrim($back_url, "/"));
die();
}
if ($strWarning != "")
{
CAdminMessage::ShowMessage($strWarning);
die();
}
//Properties from fileman settings
$arFilemanProperties = Array();
if (CModule::IncludeModule("fileman") && is_callable(Array("CFileMan", "GetPropstypes")))
$arFilemanProperties = CFileMan::GetPropstypes($site);
//Properties from page
$arPageSlice = ParseFileContent($fileContent);
$arDirProperties = $arPageSlice["PROPERTIES"];
$pageTitle = $arPageSlice["TITLE"];
//All properties for file. Includes properties from root folders
$arInheritProperties = $APPLICATION->GetDirPropertyList(Array($site, $path));
if ($arInheritProperties === false)
$arInheritProperties = Array();
//Delete equal properties
$arGlobalProperties = Array();
foreach ($arFilemanProperties as $propertyCode => $propertyDesc)
{
if (array_key_exists($propertyCode, $arDirProperties))
$arGlobalProperties[$propertyCode] = $arDirProperties[$propertyCode];
else
$arGlobalProperties[$propertyCode] = "";
unset($arDirProperties[$propertyCode]);
unset($arInheritProperties[strtoupper($propertyCode)]);
}
foreach ($arDirProperties as $propertyCode => $propertyValue)
unset($arInheritProperties[strtoupper($propertyCode)]);
$counters = COption::GetOptionString('seo', 'counters', SEO_COUNTERS_DEFAULT);
//HTML output
$aTabs = array(
array("DIV" => "seo_edit1", "TAB" => GetMessage('SEO_TOOLS_TAB_PAGE'), "ICON" => "main_settings", "TITLE" => GetMessage('SEO_TOOLS_TAB_PAGE_TITLE').' '.$back_url),
array("DIV" => "seo_edit2", "TAB" => GetMessage('SEO_TOOLS_TAB_EDIT'), "ICON" => "main_settings", "TITLE" => GetMessage('SEO_TOOLS_TAB_EDIT_TITLE')),
array("DIV" => "seo_edit3", "TAB" => GetMessage('SEO_TOOLS_TAB_INDEX'), "ICON" => "main_settings", "TITLE" => GetMessage('SEO_TOOLS_TAB_INDEX_TITLE')),
array("DIV" => "seo_edit4", "TAB" => GetMessage('SEO_TOOLS_TAB_WORDS'), "ICON" => "main_settings", "TITLE" => GetMessage('SEO_TOOLS_TAB_WORDS_TITLE')),
array("DIV" => "seo_edit5", "TAB" => GetMessage('SEO_TOOLS_TAB_REFERERS'), "ICON" => "main_settings", "TITLE" => GetMessage('SEO_TOOLS_TAB_REFERERS_TITLE')),
);
$tabControl = new CAdminTabControl("seoTabControl", $aTabs);
$APPLICATION->SetTitle(GetMessage('SEO_TOOLS_TITLE'));
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php");
?>
<form name="seo_form" method="POST" action="/bitrix/admin/public_seo_tools.php" enctype="multipart/form-data">
<input type="hidden" name="lang" value="<?=LANGUAGE_ID?>" />
<input type="hidden" name="path" value="<?echo htmlspecialcharsEx($path)?>" />
<input type="hidden" name="backurl" value="<?echo htmlspecialcharsEx($original_backurl)?>" />
<?=bitrix_sessid_post()?>
<?
$tabControl->Begin();
$tabControl->BeginNextTab();
?>
<style type="text/css">
div#bx_admin_form table.edit-table table.bx-seo-words-table tr td {padding: 2px !important; text-align: center;}
div#bx_page_extended_data a {text-decoration: none;}
table.legend {margin:0px 0px 7px 10px; font-size:70%;}
table.legend td {padding:3px 10px 3px 0px;}
table.phrases-table, table.referers-table {width: 85%;}
table.phrases-table tr.bx-th td, table.referers-table tr.bx-th td {text-align: center; font-weight: bold !important;}
div#bx_admin_form table.phrases-table tr td, div#bx_admin_form table.referers-table tr td {height: 18px; padding: 3px 3px 0px 0px !important;}
table.phrases-table td div, table.referers-table td div {color: black !important; white-space: nowrap;}
table.phrases-table td div div, table.referers-table td div div {color: white !important; white-space: nowrap; overflow: hidden;}
table.phrases-table td table, table.referers-table td table {width: 90%;}
div#bx_page_extended_data div {height: 130px; width: 99%; overflow: auto; margin-right: 5px; border: solid 1px #E0E4F1;}
#bx_page_errors ol li {line-height: 22px;}
</style>
<?
if (strlen($counters) > 0):
$counters = str_replace(array('#DOMAIN#'), array($server_name), $counters);
$dbEvents = GetModuleEvents("seo", "OnSeoCountersGetList");
while ($arEvent = $dbEvents->Fetch())
{
if ($str = ExecuteModuleEvent($arEvent))
{
$counters .= "\r\n\r\n".$str;
}
}
?>
<tr>
<td width="40%" valign="top"><?echo GetMessage('SEO_TOOLS_COUNTERS')?><?echo SeoShowHelp('counters')?>: </td>
<td width="60%"><?echo $counters;?></td>
</tr>
<?endif;?>
</table>
<table id="bx_stats_loading_notify" class="edit-table"><tr><td align="center"><?echo BeginNote(),GetMessage('SEO_TOOLS_LOADING'),EndNote();?></td></tr></table>
<table id="bx_stats_loading_error" class="edit-table"><tr><td align="center" id="bx_seo_error_text"></td></tr></table>
<table id="bx_stats_table" class="edit-table" cellspacing="0" cellpadding="0" border="0" style="display: none;">
<tbody>
<tr height="0"><td width="40%" nowrap="nowrap"></td><td width="60%" nowrap="nowrap"></td></tr>
<tr class="heading" id="bx_page_stats_row">
<td colspan="2" align="center"><?echo GetMessage('SEO_TOOLS_STATS')?></td>
</tr>
<tr class="heading" id="bx_page_stats_row">
<td colspan="2" align="center"><?echo GetMessage('SEO_TOOLS_ANALYSIS')?></td>
</tr>
<tr>
<td colspan="2">
<div id="bx_page_extended_data"><table width="100%">
<tr>
<td width="67%">
<div id="bx_ex_out"></div>
</td>
<td width="33%">
<a href="javascript: void(0)" id="bx_seo_link_HEADERS" onclick="BXShowExtendedStat('HEADERS');">HTTP HEADERS</a><br />
<a href="javascript: void(0)" id="bx_seo_link_TITLE" onclick="BXShowExtendedStat('TITLE')">HTML TITLE (<TITLE>)</a><br />
<a href="javascript: void(0)" id="bx_seo_link_H" onclick="BXShowExtendedStat('H')">HTML HEADING(<H1>-<H6>)</a><br />
<a href="javascript: void(0)" id="bx_seo_link_META_DESCRIPTION" onclick="BXShowExtendedStat('META_DESCRIPTION')">META DESCRIPTION</a><br />
<a href="javascript: void(0)" id="bx_seo_link_META_KEYWORDS" onclick="BXShowExtendedStat('META_KEYWORDS')">META KEYWORDS</a><br />
<a href="javascript: void(0)" id="bx_seo_link_BOLD" onclick="BXShowExtendedStat('BOLD')">BOLD (<B>, <STRONG>)</a><br />
<a href="javascript: void(0)" id="bx_seo_link_ITALIC" onclick="BXShowExtendedStat('ITALIC')">ITALIC (<I>, <EM>)</a><br />
<a href="javascript: void(0)" id="bx_seo_link_LINK" onclick="BXShowExtendedStat('LINK')">LINK</a><br />
<a href="javascript: void(0)" id="bx_seo_link_NOINDEX" onclick="BXShowExtendedStat('NOINDEX')">NOINDEX</a><br />
<a href="javascript: void(0)" id="bx_seo_link_NOFOLLOW" onclick="BXShowExtendedStat('NOFOLLOW')">NOFOLLOW</a><br />
</td>
</tr>
</table></div>
</td>
</tr>
<tr class="heading">
<td colspan="2" align="center"><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS')?></td>
</tr>
<?
if ($prop_code = COption::GetOptionString('seo', 'property_internal_keywords', 'keywords_inner')):
$arInnerKeywords = array(
'local' => $arGlobalProperties[$prop_code],
'section' => $APPLICATION->GetDirProperty($prop_code, array($site, $path)),
);
$bSectionInherited = true;
$file = $absoluteDirPath.'/.section.php';
$arDirProperties = array();
if (file_exists($file))
require($file);
if (count($arDirProperties) > 0)
{
$arKeyMap = array();
foreach ($arDirProperties as $key => $value)
{
if (ToUpper($key) == ToUpper($prop_code))
$bSectionInherited = false;
}
}
foreach ($arInnerKeywords as $key => $prop_value)
{
if (strlen($prop_value) > 0)
{
$arInnerKeywords[$key] = explode(',', $prop_value);
}
else
{
$arInnerKeywords[$key] = array();
}
}
$aSubTabs = array();
foreach ($arInnerKeywords as $key => $ar)
{
$aSubTabs[] = array("DIV" => "int_keyw_".$key, "TAB" => GetMessage('SEO_TOOL_TAB_'.$key));
}
$childTabControl = new CAdminViewTabControl("childTabControl", $aSubTabs);
?>
<tr>
<td colspan="2">
<?
$childTabControl->Begin();
foreach ($arInnerKeywords as $key => $arKeywords):
foreach ($arKeywords as $k => $v) $arKeywords[$k] = trim($v);
TrimArr($arKeywords);
$childTabControl->BeginNextTab();
?>
<?
if ($bReadOnly || $key == 'section' && $bSectionInherited):
?>
<div id="bx_view_property_<?=$prop_code?>_section" style="overflow:hidden;padding:2px 12px 2px 2px; border:1px solid #F8F9FC; width:90%; cursor:text; box-sizing:border-box; -moz-box-sizing:border-box;background-color:transparent; background-position:right; background-repeat:no-repeat; height: 22px;" <?if (!$bReadOnly):?>onclick="var input = BXEditProperty('<?=$prop_code?>_section'); input.name='property_<?=$prop_code?>_section'; input.onblur=function() {BXBlurProperty(input,'<?=$prop_code?>_section'); BXCallUpdateKeywordsStats(this.value, 'window.BXUpdateKeywordsStats_<?echo $key?>');}" <?endif;?>onmouseover="this.style.borderColor = '#434B50 #ADC0CF #ADC0CF #434B50';" onmouseout="this.style.borderColor = '#F8F9FC'" class="edit-field"><?echo htmlspecialcharsEx(implode(', ', $arKeywords))?></div>
<?
if (!$bReadOnly):
?>
<div id="bx_edit_property_<?=$prop_code?>_section" style="display:none;"></div>
<?
endif;
else:
?>
<div><input type="text" id="property_<?echo $prop_code?>_<?echo $key?>" rows="5" name="property_<?echo $prop_code?>_<?echo $key?>" style="width: 90%;" onblur="BXCallUpdateKeywordsStats(this.value, 'window.BXUpdateKeywordsStats_<?echo $key?>')" value="<?echo htmlspecialcharsEx(implode(', ', $arKeywords))?>" /></div>
<?
endif;
?>
<br />
<table width="100%" class="bx-seo-words-table" id="bx_seo_words_table_<?echo $key?>">
<thead>
<tr class="heading">
<td><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS_WORD');?></td>
<td><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS_ALL_CONTRAST');?></td>
<td><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS_HEADERS');?></td>
<td><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS_BOLD_ITALIC');?></td>
<td><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS_DESCR_KEYWORDS');?></td>
<td><?echo GetMessage('SEO_TOOLS_INTERNAL_KEYWORDS_LINKS');?></td>
</tr>
</thead>
<tbody></tbody>
</table>
<script type="text/javascript">
window.BXUpdateKeywordsStats_<?echo $key?> = function(data) {BXUpdateKeywordsStats('<?echo $key?>', data)};
</script>
<?
endforeach;
$childTabControl->End();
?>
</td>
</tr>
<?
endif;
?>
<tr class="heading">
<td colspan="2" align="center"><?echo GetMessage('SEO_PAGE_RECOMMEMDATIONS')?></td>
</tr>
<tr>
<td colspan="2" id="bx_page_errors"></td>
</tr>
</tbody>
<?
/*************************************/
/* file and directory properties tab */
/*************************************/
$tabControl->BeginNextTab();
?>
<tr>
<td><?echo GetMessage('SEO_PAGE_BASE_TITLE')?> <?echo SeoShowHelp('base_title')?>: </td>
<td><input type="text" name="pageTitle" value="<?=htmlspecialcharsEx($pageTitle)?>" size="50" /></td>
</tr>
<?
if ($titleFinal != $pageTitle):
?>
<tr>
<td valign="top"><?echo GetMessage('SEO_PAGE_CURRENT_TITLE')?> <?echo SeoShowHelp('current_title')?>: </td>
<td valign="top">
<script>
window.jsPopup_subdialog = new JCPopup({'suffix':'subdialog', 'zIndex':parseInt(jsPopup.zIndex)+20});
</script>
<?
if ($titleChangerLink)
{
$titleChangerLink = preg_replace(
"/jsPopup.ShowDialog\('(.*?)',([^\)]*)\)/is",
"jsPopup_subdialog.ShowDialog('\\1&subdialog=Y&suffix=subdialog',\\2)",
$titleChangerLink
);
}
?>
<b><?echo htmlspecialcharsEx($titleFinal)?></b> <?if ($titleChangerName != ''):?>(<?echo htmlspecialchars($titleChangerName)?>) <?endif;?><?if ($titleChangerLink):?><br /><a href="<?echo $titleChangerLink?>"><?echo GetMessage('SEO_PAGE_CURRENT_TITLE_EDIT')?></a><?endif;?>
</tr>
<?
endif;
if ($prop_code = COption::GetOptionString('seo', 'property_window_title', 'title')):
$value = $arGlobalProperties[$prop_code];
if (strlen($value) <= 0)
$value = $APPLICATION->GetDirProperty($prop_code, array($site, $path));
?>
<tr>
<td><?echo $arFilemanProperties[$prop_code] ? $arFilemanProperties[$prop_code] : GetMessage('SEO_PAGE_PROPERTY_WINDOW_TITLE')?> <?echo SeoShowHelp('property_window_title')?>: </td>
<td><input type="text" name="property_<?echo htmlspecialcharsEx($prop_code)?>" value="<?=htmlspecialcharsEx($value)?>" size="50" /></td>
</tr>
<?
if ($value != $titleWinFinal):
?>
<tr>
<td valign="top"><?echo $arFilemanProperties[$prop_code]?> (<?echo GetMessage('SEO_PAGE_WINDOW_TITLE_CURRENT')?>) <?echo SeoShowHelp('current_window_title')?>: </td>
<td valign="top">
<?
if ($titleWinChangerLink)
{
$titleWinChangerLink = preg_replace(
"/jsPopup.ShowDialog\('(.*?)',([^\)]*)\)/is",
"jsPopup_subdialog.ShowDialog('\\1&subdialog=Y&suffix=subdialog',\\2)",
$titleWinChangerLink
);
}
?>
<b><?echo htmlspecialcharsEx($titleWinFinal)?></b> <?if ($titleWinChangerName != ''):?>(<?echo htmlspecialchars($titleWinChangerName)?>) <?endif;?><?if ($titleWinChangerLink):?><br /><a href="<?echo $titleWinChangerLink?>"><?echo GetMessage('SEO_PAGE_CURRENT_TITLE_EDIT')?></a><?endif;?>
</tr>
<?
endif;
endif;
$arEditProperties = array();
if ($prop_code = COption::GetOptionString('seo', 'property_keywords', 'keywords')) $arEditProperties['keywords'] = $prop_code;
if ($prop_code = COption::GetOptionString('seo', 'property_description', 'description')) $arEditProperties['description'] = $prop_code;
foreach ($arEditProperties as $key => $prop_code):
$value = $arGlobalProperties[$prop_code];
?>
<tr>
<td><?echo $arFilemanProperties[$prop_code]?> <?echo SeoShowHelp('property_'.$key)?>: </td>
<td><?
if (strlen($value) <= 0):
$value = $APPLICATION->GetDirProperty($prop_code, array($site, $path));
?>
<input type="hidden" name="PROPERTY[<?=$prop_code?>][CODE]" value="<?=htmlspecialcharsEx($prop_code)?>" />
<div id="bx_view_property_<?=$prop_code?>" style="overflow:hidden;padding:2px 12px 2px 2px; border:1px solid #F8F9FC; width:90%; cursor:text; box-sizing:border-box; -moz-box-sizing:border-box;background-color:transparent; background-position:right; background-repeat:no-repeat; height: 22px;" onclick="BXEditProperty('<?=$prop_code?>')" onmouseover="this.style.borderColor = '#434B50 #ADC0CF #ADC0CF #434B50';" onmouseout="this.style.borderColor = '#F8F9FC'" class="edit-field"><?=htmlspecialcharsEx($value)?></div>
<div id="bx_edit_property_<?=$prop_code?>" style="display:none;"></div>
<?
else:
?>
<input type="text" name="property_<?echo htmlspecialcharsEx($prop_code)?>" value="<?=htmlspecialcharsEx($value)?>" size="50" /></td>
<?
endif;
?>
</tr>
<?
endforeach;
?>
<?
/********************************/
/* searchers indexing stats tab */
/********************************/
$tabControl->BeginNextTab();
if (!CModule::IncludeModule('statistic')):
?>
<tr>
<td><?ShowError(GetMessage('SEO_PAGE_ERROR_NO_STATS'));?></td>
</tr>
<?
elseif ($APPLICATION->GetGroupRight("statistic") < 'R'):
?>
<tr>
<td><?ShowError(GetMessage('SEO_PAGE_ERROR_NO_STATS_RIGHTS'));?></td>
</tr>
<?
else:
$searchers = COption::GetOptionString('seo', 'searchers_list', '');
$arSearchers = array();
if (strlen($searchers) > 0)
{
$arSearchers = explode(',', $searchers);
$arSearcherHits = array();
if (count($arSearchers) > 0)
{
$dbRes = CSearcher::GetList($by = 's_name', $order = "asc", array('ID' => implode('|', $arSearchers)), $is_filtered);
$arSearchers = array();
while ($arRes = $dbRes->Fetch())
{
$arSearchers[$arRes['ID']] = $arRes;
$arSearcherHits[$arRes['ID']] = 0;
}
}
}
if (count($arSearchers) <= 0):
?>
<tr>
<td><?echo BeginNote(),GetMessage('SEO_PAGE_ERROR_NO_SEARCHERS'),EndNote()?></td>
</tr>
<?
else:
$arFilter = array(
'SEARCHER_ID' => implode('|', array_keys($arSearchers)),
'DATE1' => ConvertTimeStamp(strtotime('-3 month'), false, $site_id),
'DATE2' => ConvertTimeStamp(time(), false, $site_id),
'URL' => 'http://'.$server_name.$back_url,
'URL_EXACT_MATCH' => 'Y',
'SITE_ID' => $site,
);
//echo '<pre>'; print_r($arFilter); echo '</pre>';
$last_ts = strtotime('-'.COption::GetOptionInt('statistic', 'SEARCHER_HIT_DAYS', 3).' days');
$total = 0;
$dbRes = CSearcherHit::GetList($by = 's_searcher_id', $order="asc", $arFilter, $is_filtered);
while ($arRes = $dbRes->Fetch())
{
$ts = MakeTimeStamp($arRes['DATE_HIT']);
$total++;
if ($ts < $last_ts) $last_ts = $ts;
$arSearcherHits[$arRes['SEARCHER_ID']]++;
}
$days_count = floor((time() - $last_ts)/86400);
?>
<tr class="heading">
<td colspan="2"><?echo str_replace('#COUNT#', $days_count, GetMessage('SEO_PAGE_STATS_INDEX'))?></td>
</tr>
<?
if ($total > 0):
foreach ($arSearcherHits as $key => $count):
if ($count > 0):
?>
<tr>
<td width="50%"><?echo htmlspecialchars($arSearchers[$key]['NAME'])?>: </td>
<td width="50%"><?echo $count;?></td>
</tr>
<?
endif;
endforeach;
else:
?>
<tr>
<td colspan="2" align="center">
<?
echo BeginNote(),GetMessage('SEO_PAGE_STATS_ERROR_NO_DATA'),EndNote();
?>
</td>
</tr>
<?
endif;
$arrDays = CSearcher::GetGraphArray(array(
"SEARCHER_ID" => $arFilter['SEARCHER_ID'],
"DATE1" => $arFilter['DATE1'],
"DATE2" => $arFilter['DATE2'],
"SUMMA" => 'N'
), $arrLegend
);
?>
<tr class="heading">
<td colspan="2"><?echo GetMessage('SEO_PAGE_STATS_SITE_INDEX')?></td>
</tr>
<?
if (count($arrLegend) > 0 && count($arrDays) > 1):
?>
<tr>
<td colspan="2"><img src="/bitrix/admin/searcher_graph.php?&lang=<?echo LANGUAGE_ID?>&find_date1_DAYS_TO_BACK=90<?foreach ($arSearchers as $key => $ar) echo '&find_searchers[]='.$key;?>&mode=list&find_summa=N&width=576&height=300" border="0" width="576" height="300" border="0" /><br /><br />
<table border="0" cellspacing="0" cellpadding="0" class="legend">
<?
foreach ($arrLegend as $keyL => $arrL):
$color = $arrL["COLOR"];
?>
<tr>
<td><img src="/bitrix/admin/graph_legend.php?color=<?=$color?>" width="45" height="2"></td>
<td nowrap="nowrap">[<a href="/bitrix/admin/searcher_list.php?lang=<?=LANGUAGE_ID?>&find_id=<?=$keyL?>&set_filter=Y"><?=$keyL?></a>] <a href="/bitrix/admin/searcher_dynamic_list.php?lang=<?=LANGUAGE_ID?>&find_searcher_id=<?=$keyL?>&find_date1=<?echo $arFilter["DATE1"]?>&find_date2=<?=$arFilter["DATE2"]?>&set_filter=Y"><?=$arrL["NAME"]?></a></td>
</tr>
<?
endforeach;
?>
</table></td>
</tr>
<?
else:
?>
<tr>
<td colspan="2" align="center">
<?
echo BeginNote(),GetMessage('SEO_PAGE_STATS_SITE_INDEX_ERROR_NO_DATA'),EndNote();
?>
</td>
</tr>
<?
endif;
endif;
endif;
/********************/
/* search words tab */
/********************/
$tabControl->BeginNextTab();
if (!CModule::IncludeModule('statistic')):
?>
<tr>
<td><?ShowError(GetMessage('SEO_PAGE_ERROR_NO_STATS'));?></td>
</tr>
<?
elseif ($APPLICATION->GetGroupRight("statistic") < 'R'):
?>
<tr>
<td><?ShowError(GetMessage('SEO_PAGE_ERROR_NO_STATS_RIGHTS'));?></td>
</tr>
<?
elseif (count($arSearchers) <= 0):
?>
<tr>
<td><?echo BeginNote(),GetMessage('SEO_PAGE_ERROR_NO_SEARCHERS'),EndNote()?></td>
</tr>
<?
else:
$arFilter = array(
'SEARCHER_ID' => implode('|', array_keys($arSearchers)),
'TO' => 'http://'.$server_name.$back_url,
'TO_EXACT_MATCH' => 'Y',
'GROUP' => 'P'
);
$dbRes = CPhrase::GetList($by = 's_quantity', $order = 'desc', $arFilter, $is_filtered, $total, $group_by, $max);
$dbRes->NavStart(50, false, 0);
$arWords = array();
while ($arRes = $dbRes->Fetch())
{
$arWords[$arRes['PHRASE']] = array(
'TOTAL' => $arRes['QUANTITY'],
'PERCENT' => $arRes['C_PERCENT'],
'SEARCHRS' => array(),
);
}
unset($arFilter['GROUP']);
$arFilter['PHRASE'] = implode('|', array_keys($arWords));
$arFilter['PHRASE_EXACT_MATCH'] = 'Y';
$dbRes = CPhrase::GetList($by = 's_phrase', $order = 'desc', $arFilter, $is_filtered, $total, $group_by, $max);
while ($arRes = $dbRes->Fetch())
{
if (!is_array($arWords[$arRes['PHRASE']]))
continue;
if (!is_array($arWords[$arRes['PHRASE']]['SEARCHERS'][$arRes['SEARCHER_ID']]))
$arWords[$arRes['PHRASE']]['SEARCHERS'][$arRes['SEARCHER_ID']] = array(
'SEARCHER_NAME' => $arRes['SEARCHER_NAME'],
'LAST_HIT' => 0,
'COUNT' => 0,
);
//$total++;
//$arWords[$arRes['PHRASE']]['TOTAL']++;
$arWords[$arRes['PHRASE']]['SEARCHERS'][$arRes['SEARCHER_ID']]['COUNT']++;
$ts = MakeTimeStamp($arRes['DATE_HIT']);
if ($ts > $arWords[$arRes['PHRASE']]['SEARCHERS'][$arRes['SEARCHER_ID']]['LAST_HIT'])
$arWords[$arRes['PHRASE']]['SEARCHERS'][$arRes['SEARCHER_ID']]['LAST_HIT'] = $ts;
}
//uasort($arWords, 'CMP');
if ($total > 0)
{
$cnt = count($arWords);
?>
<tr class="heading">
<td colspan="2"><?echo GetMessage('SEO_PAGE_PHRASES')?></td>
</tr>
<tr>
<td colspan="2" align="center"><table class="phrases-table">
<?
$color = null;
foreach ($arWords as $word => $arData)
{
$arData['ID'] = rand(0, 65535);
//$percent = intval(($arData['TOTAL']/$total) * 100);
$percent = $arData['PERCENT'];
?>
<tr>
<td align="left" width="30%"><a href="javascript:void(0)" onclick="BXToggle('bx_phrase_ex_<? echo $arData['ID']?>'); return false;" title="<?echo GetMessage('SEO_PAGE_REFERERS_SEO_PAGE_PHRASES_ALT')?>"><?echo htmlspecialchars($word)?></td>
<td width="70%">
<div style="height: 15px; border: solid 1px #<?echo $color = GetNextRGB($color, $cnt)?> !important; width: 100%; position: relative; cursor: pointer;" onclick="BXToggle('bx_phrase_ex_<? echo $arData['ID']?>'); return false;">
<div style="float: left; height: 15px; width: <?echo $percent?>%; background-color: #<?echo $color; ?>; white-space: nowrap; position: absolute;">
<?echo intval($arData['TOTAL'])?> (<?echo $percent?>%)
</div>
<?echo intval($arData['TOTAL'])?> (<?echo $percent?>%)
</div>
</td>
</tr>
<tr id="bx_phrase_ex_<? echo $arData['ID']?>" style="display: none;">
<td colspan="2" align="center"><table>
<tr class="bx-th">
<td><?echo GetMessage('SEO_PAGE_PHRASES_SEARCHER')?></td>
<td><?echo GetMessage('SEO_PAGE_PHRASES_HITS')?></td>
<td><?echo GetMessage('SEO_PAGE_PHRASES_LAST_HIT')?></td>
</tr>
<?
foreach ($arData['SEARCHERS'] as $searcher_id => $arSearcherData):
?>
<tr>
<td><? echo htmlspecialchars($arSearcherData['SEARCHER_NAME']);?></td>
<td align="center"><?echo intval($arSearcherData['COUNT']);?></td>
<td align="center"><?echo ConvertTimeStamp($arSearcherData['LAST_HIT'], "FULL");?></td>
</tr>
<?
endforeach;
?>
</table></td>
</tr>
<?
}
?>
</table></td>
</tr><tr>
<td colspan="2" align="right"><a href="/bitrix/admin/phrase_list.php?lang=<?echo LANGUAGE_ID?>"><?echo GetMessage('SEO_PAGE_GOTO_CP')?></a></td>
</tr>
<?
}
else
{
?>
<tr>
<td colspan="2" align="center">
<?
echo BeginNote(),GetMessage('SEO_PAGE_PHRASES_ERROR_NO_DATA'),EndNote();
?>
</td>
</tr>
<?
}
endif;
/****************/
/* referers tab */
/****************/
$tabControl->BeginNextTab();
if (!CModule::IncludeModule('statistic')):
?>
<tr>
<td><?ShowError(GetMessage('SEO_PAGE_ERROR_NO_STATS'));?></td>
</tr>
<?
elseif ($APPLICATION->GetGroupRight("statistic") < 'R'):
?>
<tr>
<td><?ShowError(GetMessage('SEO_PAGE_ERROR_NO_STATS_RIGHTS'));?></td>
</tr>
<?
else:
$arFilter = array(
'TO' => 'http://'.$server_name.$back_url,
'TO_EXACT_MATCH' => 'Y',
'GROUP' => 'S'
);
$dbRes = CReferer::GetList($by = 's_quantity', $order = 'desc', $arFilter, $is_filtered, $total, $group_by, $max);
$dbRes->NavStart(20, false, 0);
$arReferers = array();
while ($arRes = $dbRes->Fetch())
{
if (strlen($arRes['URL_FROM']) > 0)
{
if (!is_array($arReferers[$arRes['URL_FROM']]))
{
$arReferers[$arRes['URL_FROM']] = array(
'TOTAL' => $arRes['QUANTITY'],
'PERCENT' => $arRes['C_PERCENT'],
'URL_FROM' => array(),
);
}
}
}
unset($arFilter['GROUP']);
// damn ineffectively but there's now other way
foreach ($arReferers as $key => $arData)
{
$arFilter['FROM_DOMAIN'] = $key;
$arFilter['FROM_DOMAIN_EXACT_MATCH'] = 'Y';
$dbRes = CReferer::GetList($by = 's_url_from', $order = 'desc', $arFilter, $is_filtered, $total, $group_by, $max);
while ($arRes = $dbRes->Fetch())
{
if (strlen($arRes['URL_FROM']) > 0 && ($arUrl = parse_url($arRes['URL_FROM'])) && isset($arReferers[$arUrl['host']]))
{
if (!isset($arReferers[$arUrl['host']]['URL_FROM'][$arRes['URL_FROM']]))
$arReferers[$arUrl['host']]['URL_FROM'][$arRes['URL_FROM']] = 0;
$arReferers[$arUrl['host']]['URL_FROM'][$arRes['URL_FROM']]++;
}
}
}
//uasort($arReferers, 'CMP');
if ($total > 0)
{
$cnt = count($arReferers);
?>
<tr class="heading">
<td colspan="2"><?echo GetMessage('SEO_PAGE_REFERERS')?></td>
</tr>
<tr>
<td colspan="2" align="center"><table class="referers-table">
<?
$color = null;
foreach ($arReferers as $domain => $arData)
{
//$percent = intval(($arData['TOTAL']/$total) * 100);
$percent = $arData['PERCENT'];
?>
<tr>
<td width="30%" align="left"><a href="javascript:void(0)" onclick="BXToggle('bx_referer_ex_<?echo CUtil::JSEscape($domain)?>'); return false;" title="<?echo GetMessage('SEO_PAGE_REFERERS_SEO_PAGE_REFERERS_ALT')?>"><?echo htmlspecialchars($domain)?></td>
<td width="70%">
<div style="height: 15px; border: solid 1px #<?echo $color = GetNextRGB($color, $cnt)?> !important; width: 100%; position: relative; cursor: pointer;" onclick="BXToggle('bx_referer_ex_<?echo CUtil::JSEscape($domain)?>'); return false;">
<div style="float: left; height: 15px; width: <?echo $percent?>%; background-color: #<?echo $color; ?>; white-space: nowrap; position: absolute;">
<?echo intval($arData['TOTAL'])?> (<?echo $percent?>%)
</div>
<?echo intval($arData['TOTAL'])?> (<?echo $percent?>%)
</div>
</td>
</tr>
<tr id="bx_referer_ex_<?echo CUtil::JSEscape($domain)?>" style="display: none;">
<td colspan="2" align="center"><table>
<tr class="bx-th">
<td width="90%"><?echo GetMessage('SEO_PAGE_REFERERS_LINK')?></td>
<td width="10%"><?echo GetMessage('SEO_PAGE_REFERERS_COUNT')?></td>
</tr>
<?
asort($arData['URL_FROM']);
$ind = 0;
foreach ($arData['URL_FROM'] as $url => $count):
if (++$ind > 50) break;
?>
<tr>
<td><a href="<?echo $url?>"><? echo htmlspecialchars(TruncateText($url, 100));?></td>
<td align="center"><?echo intval($count);?></td>
</tr>
<?
endforeach;
?>
</table></td>
</tr>
<?
}
?>
</table></td>
</tr><tr>
<td colspan="2" align="right"><a href="/bitrix/admin/referer_list.php?lang=<?echo LANGUAGE_ID?>"><?echo GetMessage('SEO_PAGE_GOTO_CP')?></a></td>
</tr>
<?
}
else
{
?>
<tr>
<td colspan="2" align="center">
<?
echo BeginNote(),GetMessage('SEO_PAGE_REFERERS_ERROR_NO_DATA'),EndNote();
?>
</td>
</tr>
<?
}
endif;
$tabControl->Buttons(array("disabled"=>$bReadOnly));
$tabControl->End();
?>
</form>
<script type="text/javascript">
window.BXToggle = function(id)
{
with(document.getElementById(id)){if (style.display=='none')style.display='';else style.display='none';};
}
window.BXUpdateKeywordsStats = function(type, data)
{
CloseWaitWindow();
var obTable = document.getElementById('bx_seo_words_table_' + type).tBodies[0];
while (obTable.firstChild) obTable.removeChild(obTable.firstChild);
for (var i = 0; i < data.length; i++)
{
var obRow = obTable.insertRow(-1);
obRow.insertCell(-1).appendChild(document.createTextNode(data[i][0]));
obRow.insertCell(-1).appendChild(document.createTextNode(null != data[i][1].TOTAL ? data[i][1].TOTAL + '/' + data[i][1].CONTRAST : '-'));
obRow.insertCell(-1).appendChild(document.createTextNode(null != data[i][1].TITLE ? data[i][1].TITLE + '/' + data[i][1].H1 : '-'));
obRow.insertCell(-1).appendChild(document.createTextNode(null != data[i][1].BOLD ? data[i][1].BOLD + '/' + data[i][1].ITALIC : '-'));
obRow.insertCell(-1).appendChild(document.createTextNode(null != data[i][1].TOTAL ? data[i][1].DESCRIPTION + '/' + data[i][1].KEYWORDS : '-'));
obRow.insertCell(-1).appendChild(document.createTextNode(null != data[i][1].LINK ? data[i][1].LINK : '-'));
obRow.cells[0].style.textAlign = 'left';
}
}
<?
if (!$bReadOnly):
?>
window.BXCallUpdateKeywordsStats = function(keywords, callback_name)
{
ShowWaitWindow();
jsUtils.loadJSFile('/bitrix/tools/seo_page_parser.php?lang=<?=LANGUAGE_ID?>&site=<?=$site?>&url=<?echo CUtil::JSEScape(urlencode($back_url))?>&callback=' + jsUtils.urlencode(callback_name) + '&keywords=' + encodeURIComponent(keywords));
}
<?
endif;
?>
window.BXCallPageStats = function()
{
ShowWaitWindow();
var keywords = '<?echo CUtil::JSEscape(implode(', ', array_merge($arInnerKeywords['local'], $arInnerKeywords['section'])));?>';
jsUtils.loadJSFile('/bitrix/tools/seo_page_parser.php?lang=<?=LANGUAGE_ID?>&first=Y&site=<?=$site?>&url=<?echo CUtil::JSEScape(urlencode($back_url))?>&callback=window.BXSetStats&keywords=' + encodeURIComponent(keywords) + '&r=' + parseInt(Math.random() * 10000));
}
window.BXSetStats = function(data, stats, errors, extended)
{
var data_local = [], data_section = [];
for (var i = 0; i < data.length; i++)
{
if (i < <?echo count($arInnerKeywords['local'])?>)
data_local[data_local.length] = data[i];
else
data_section[data_section.length] = data[i];
}
BXUpdateKeywordsStats('local', data_local);
BXUpdateKeywordsStats('section', data_section);
BXUpdatePageStats(stats);
BXUpdatePageErrors(errors);
BXUpdatePageExtendedData(extended);
document.getElementById('bx_stats_loading_notify').style.display = 'none';
document.getElementById('bx_stats_table').style.display = '';
}
window.BXSetStatsError = function(error)
{
CloseWaitWindow();
document.getElementById('bx_stats_loading_notify').style.display = 'none';
document.getElementById('bx_stats_loading_error').style.display = '';
var err_str = '<?echo CUtil::JSEscape(BeginNote())?>';
err_str += error;
if (window.location.port && window.location.port != '80')
{
err_str += '<br /><br /><?echo CUtil::JSEscape(GetMessage('SEO_PAGE_CONNECTION_ERROR_HINT'))?>';
}
err_str += '<?echo CUtil::JSEscape(EndNote())?>';
document.getElementById('bx_seo_error_text').innerHTML = err_str;
}
window.BXUpdatePageExtendedData = function(extended)
{
window.__BXExtendedPageStat = extended;
var arList = ['HEADERS', 'TITLE', 'H', 'META_DESCRIPTION', 'META_KEYWORDS', 'BOLD', 'ITALIC', 'LINK', 'NOINDEX', 'NOFOLLOW'];
for (var i = 0; i < arList.length; i++)
{
if (null != extended[arList[i]] && extended[arList[i]].length > 0)
document.getElementById('bx_seo_link_' + arList[i]).innerHTML += ' [' + extended[arList[i]].length + ']';
}
BXShowExtendedStat(arList[0]);
}
window.BXSeoCurStat = '';
window.BXShowExtendedStat = function(stat)
{
var out = document.getElementById('bx_ex_out');
out.innerHTML = '';
if (window.BXSeoCurStat != '')
{
document.getElementById('bx_seo_link_' + window.BXSeoCurStat).style.fontWeight = 'normal';
}
window.BXSeoCurStat = stat;
document.getElementById('bx_seo_link_' + window.BXSeoCurStat).style.fontWeight = 'bold';
if (null != window.__BXExtendedPageStat[stat])
{
for (var i = 0; i < window.__BXExtendedPageStat[stat].length; i++)
{
out.appendChild(document.createElement('P')).appendChild(document.createTextNode(window.__BXExtendedPageStat[stat][i]));
}
}
}
window.BXUpdatePageStats = function(stats)
{
var obTable = document.getElementById('bx_stats_table').tBodies[0];
var index = document.getElementById('bx_page_stats_row').sectionRowIndex;
<?
$arStats = array('TOTAL_LENGTH', 'TOTAL_WORDS_COUNT', 'UNIQUE_WORDS_COUNT', 'META_DESCRIPTION', 'META_KEYWORDS');
foreach ($arStats as $stat):
?>
var obRow = obTable.insertRow(++index);
obRow.insertCell(-1).appendChild(document.createTextNode('<?echo CUtil::JSEscape(GetMessage('SEO_PAGE_STAT_'.$stat))?>: '));
obRow.insertCell(-1).appendChild(document.createTextNode(stats.<?echo $stat?>));
obRow.cells[0].className = 'field-name';
<?
endforeach;
?>
}
window.BXUpdatePageErrors = function(errors)
{
var obCell = document.getElementById('bx_page_errors');
obCell.innerHTML = '';
if (errors.length > 0)
{
var str = '<ol style="padding: 0px 0px 0px 25px;">';
for (var i = 0; i < errors.length; i++)
{
str += '<li>' + errors[i].TEXT + '</li>';
}
str += '</ol>';
obCell.innerHTML = str;
}
}
window.BXBlurProperty = function(element, propertyIndex)
{
var viewProperty = document.getElementById("bx_view_property_" + propertyIndex);
if (element.value == "" || element.value == viewProperty.innerHTML)
{
var editProperty = document.getElementById("bx_edit_property_" + propertyIndex);
viewProperty.style.display = "block";
editProperty.style.display = "none";
while (editProperty.firstChild)
editProperty.removeChild(editProperty.firstChild);
}
}
window.BXEditProperty = function(propertyIndex)
{
if (document.getElementById("bx_property_input_" + propertyIndex))
return;
var editProperty = document.getElementById("bx_edit_property_" + propertyIndex);
var viewProperty = document.getElementById("bx_view_property_" + propertyIndex);
viewProperty.style.display = "none";
editProperty.style.display = "block";
var input = document.createElement("INPUT");
input.type = "text";
input.name = "PROPERTY["+propertyIndex+"][VALUE]";
input.style.width = "90%";
input.style.padding = "2px";
input.id = "bx_property_input_" + propertyIndex;
input.onblur = function () {BXBlurProperty(input,propertyIndex)};
input.value = viewProperty.innerHTML;
editProperty.appendChild(input);
input.focus();
input.select();
return input;
}
window.onload = BXCallPageStats;
</script>
<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php");
?>