require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DYNAMIC_SITEMAP);
$category_status_check = '';
$check_query = tep_db_query("select * from " . TABLE_CATEGORIES);
$check = tep_db_fetch_array($check_query);
if (isset($check['status_categ'])) { // skip if this is not set to avoid SQL error
$category_status_check = ' and status_categ = 1';
} elseif (isset($check['categories_status'])) { // skip if this is not set to avoid SQL error
$category_status_check = ' and categories_status = 1';
}
function getFileName($file, $define) //retrieve the defined filename
{
$fp = file($file);
for ($idx = 0; $idx < count($fp); ++$idx)
{
if (!(strpos($fp[$idx], $define) === FALSE))
{
$parts = explode("'", $fp[$idx]);
return $parts[3];
}
}
return NULL;
}
function getBoxText($file, $define) //retrieve the defined box name
{
$fp = file($file);
for ($idx = 0; $idx < count($fp); ++$idx)
{
if (!(strpos($fp[$idx], $define) === FALSE))
{
$fp[$idx] = stripslashes($fp[$idx]);
$p_start = strpos($fp[$idx], ",");
$p_start = strpos($fp[$idx], "'", $p_start);
$p_stop = strrpos($fp[$idx], '\'');
return str_replace('%s', '', ucfirst(substr($fp[$idx], $p_start + 1, $p_stop - $p_start - 1)));
}
}
return NULL;
}
function IsViewable($file)
{
$fp = file($file);
for ($idx = 0; $idx < count($fp); ++$idx)
{
if (!(strpos($fp[$idx], "") === FALSE))
return true;
}
return false;
}
function get_subcats($parent, $children = '') {
global $category_status_check;
if (!is_array($children)) $children = array($parent);
$query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = " . (int)$parent . $category_status_check);
while ($cats = tep_db_fetch_array($query)) {
$children[] = $cats['categories_id'];
$children = get_subcats($cats['categories_id'], $children);
}
return $children;
}
function get_cat_paths($categories_array = '', $parent_id = '0', $path='') {
global $languages_id, $category_status_check;
if (!is_array($categories_array)) $categories_array = array();
$categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id " . $category_status_check . " and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
while ($categories = tep_db_fetch_array($categories_query)) {
// hide empty categories hack
$check = tep_db_query("select count(p2c.products_id) as total from " . TABLE_PRODUCTS . " p join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = 1 and p2c.products_id = p.products_id and (p2c.categories_id in (" . implode(',', get_subcats($categories['categories_id'])) . "))");
$numproducts = tep_db_fetch_array($check); // save number of products for display
if ($numproducts['total'] > 0) {
// hide empty categories hack
if ($parent_id=='0') {
$categories_array[] = array('id' => $categories['categories_id'],
'text' => $categories['categories_name'],
'numprods' => $numproducts['total']);
} else {
$categories_array[] = array('id' => $path . $parent_id . '_' .$categories['categories_id'],
'text' => $categories['categories_name'],
'numprods' => $numproducts['total']);
}
if ($categories['categories_id'] != $parent_id) {
$this_path=$path;
if ($parent_id != '0') $this_path = $path . $parent_id . '_';
$categories_array = get_cat_paths($categories_array, $categories['categories_id'], $this_path);
}
// hide empty categories hack
}
// hide empty categories hack
}
return $categories_array;
}
$path = DIR_WS_INCLUDES.'boxes';
$pathFileName = DIR_WS_INCLUDES . 'filenames.php';
$pathLanguage = DIR_WS_LANGUAGES . $language . '.php';
$boxText = array();
/********************* Find the infoboxes to add ***********************/
if ($handle = opendir($path))
{
if (!tep_session_is_registered('customer_id'))
$excluded_query = tep_db_query('select exclude_file from '.TABLE_SITEMAP_EXCLUDE.' where exclude_type != "0" and is_box="1"');
else
$excluded_query = tep_db_query('select exclude_file from '.TABLE_SITEMAP_EXCLUDE.' where exclude_type = "1" and is_box="1"');
$excluded_array = array();
if (tep_db_num_rows($excluded_query))
while($ex = tep_db_fetch_array($excluded_query))
$excluded_array[] = $ex['exclude_file'];
$found = false;
$ctr = 0;
while ($file = readdir($handle))
{
if (strtolower(substr($file, -4, 4)) != ".php")
continue;
elseif (in_array($file, $excluded_array))
continue;
$file = $path . '/' . $file;
$fp = file($file);
for ($idx = 0; $idx < count($file); ++$idx)
{
$parts = explode(" ", $fp[$idx]);
for ($i = 0; $i < count($file); ++$i)
{
$boxHeading[$ctr]['filename'][$ctr] = ucwords(basename(str_replace(".php", "", str_replace("_", " ", str_replace("bm_", "", $file)))));
$boxHeading[$ctr]['heading'][$ctr] = ucwords(basename(str_replace(".php", "", str_replace("_", " ", str_replace("bm_", "", $file)))));
}
}
$ctr++;
}
closedir($handle);
}
/********************* Find the pages to add ***********************/
$ctr = 0;
($dir = opendir('.')) || die("Failed to open dir");
$files = array();
if (!tep_session_is_registered('customer_id'))
$excluded_query = tep_db_query('select exclude_file from '.TABLE_SITEMAP_EXCLUDE.' where exclude_type != "0" and is_box="0"');
else
$excluded_query = tep_db_query('select exclude_file from '.TABLE_SITEMAP_EXCLUDE.' where exclude_type = "1" and is_box="0"');
$excluded_array = array();
if (tep_db_num_rows($excluded_query))
while($ex = tep_db_fetch_array($excluded_query))
$excluded_array[] = $ex['exclude_file'];
while($file = readdir($dir))
{
if((!is_dir($file) && strtolower(substr($file, -4, 4)) === ".php") && !in_array($file ,$excluded_array))//only look at php files and skip that are excluded
{
$engFile = DIR_WS_LANGUAGES . $language . '/' . $file;
if (file_exists($engFile) && IsViewable($file))
{
$fp = file($engFile);
for ($idx = 0; $idx < count($fp); ++$idx)
{
if (!(strpos($fp[$idx], "define('HEADING_TITLE") === FALSE))
{
$fp[$idx] = stripslashes($fp[$idx]);
$p_start = strpos($fp[$idx], ",");
$p_start = strpos($fp[$idx], "'", $p_start);
$p_stop = strrpos($fp[$idx], '\'');
$files['name'][] = str_replace('%s', '', ucfirst(substr($fp[$idx], $p_start + 1, $p_stop - $p_start - 1)));
$files['path'][] = $file;
break;
}
}
}
}
}
$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_DYNAMIC_SITEMAP));
// require(DIR_WS_INCLUDES . 'template_top.php');
?>