function shortenPath($fileName) { preg_match('~.+/([a-zA-Z0-9]+)$~', $fileName, $hits); if (isset($hits[1])) { $result = $hits[1]; } else { $result = removeSlashes($fileName); } return $result; }
/** * Cгенерировать таблицу сайтов */ function generateSitesTable($node, $path) { global $SearchGrabber; global $navBar; $template = file_get_contents(TPL_SITE); $templateDesc = file_get_contents(TPL_DESC); ob_start(); print "<table>"; for ($i = 0; $i < $navBar->getItemsCount(); $i++) { $data = $SearchGrabber->items[$navBar->getStartItem() + $i]; list($sUrl, $sName, $sDescr) = $data; $sName = removeSlashes($sName); $sPath = validFileName(translitText(strip_tags($sName)), true); if (strlen($sPath) == 0) { continue; } $htmlPath = generateHtmlPath($node, true); //$sPath = $path . "/" . $sPath . FILES_EXT; $sPath = $sPath . FILES_EXT; //$metaTags = @get_meta_tags($sUrl); //if (isset($metaTags["description"])) { // $sMeta = autoDecode($metaTags["description"]); //} //else { $sMeta = $sDescr; //} print "<tr><td>"; print replaceSiteTags($template, $sUrl, $sName, $sDescr, $sMeta, $sPath, $htmlPath); print "</td></tr>"; //file_put_contents($sPath, // replaceSiteTags($template, $sUrl, $sName, $sDescr, $sMeta, $sPath)); file_put_contents($path . "/" . $sPath, replaceSiteTags($templateDesc, $sUrl, $sName, $sDescr, $sMeta, $sPath, $htmlPath)); } print "</table>"; return ob_get_clean(); }