Last active
April 18, 2019 02:16
-
-
Save lineharo/b9f9f8ef3d1a288adf5dfe4f60e03696 to your computer and use it in GitHub Desktop.
Get bitrix pages content from sitemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die(); | |
if (!is_array($arResult["arMap"]) || count($arResult["arMap"]) < 1) | |
return; | |
$resArr = []; | |
$tmpArr = []; | |
foreach($arResult["arMap"] as $index => $arItem){ | |
$a_fullPath = htmlspecialcharsbx($arItem["FULL_PATH"], ENT_COMPAT, false); | |
if (strpos($a_fullPath, 'http://') !== FALSE) continue; | |
if (strpos($a_fullPath, 'vote/') !== FALSE) continue; | |
if (strpos($a_fullPath, 'feedback/') !== FALSE) continue; | |
$a_fullPath = ltrim(str_replace('?clear_cache=Y', '', $a_fullPath),'/'); | |
$a_name = htmlspecialcharsbx($arItem["NAME"], ENT_COMPAT, false); | |
if (is_file($a_fullPath)) { | |
} elseif (is_file($a_fullPath . 'index.php')) { | |
$a_fullPath = $a_fullPath . 'index.php'; | |
} else { | |
continue; | |
} | |
if (array_search($a_fullPath, $tmpArr) !== FALSE) continue; | |
$tmpArr[] = $a_fullPath; | |
$resArr[] = [ | |
'path' => $a_fullPath, | |
'name' => $a_name, | |
]; | |
} | |
$fp = fopen('dump.txt', 'a'); | |
foreach ($resArr as $pPage) { | |
$fdata = file_get_contents ($pPage['path']); | |
preg_match_all('/\(\"description\"\, \"(.*)\"\)/m', $fdata,$out); | |
$p_desc = $out[1]; | |
preg_match_all('/\(\"keywords\"\, \"(.*)\"\)/m', $fdata,$out); | |
$p_key = $out[1]; | |
$fdata = preg_replace('/<\?[\s\S]*\?>/U', '', $fdata); | |
$fdata = str_replace(PHP_EOL, '', $fdata); | |
$fields = $pPage['path'] . '$%$%$'; | |
$fields .= $pPage['name'] . '$%$%$'; | |
$fields .= $p_desc . '$%$%$'; | |
$fields .= $p_key . '$%$%$'; | |
$fields .= $fdata . '$%$%$' . PHP_EOL; | |
fwrite ($fp, $fields); | |
} | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment