Site->Path.'/~design/'.$_GET['style_id'].'/'; $style = $GLOBALS['Conf']->Site->Path.'/~design/style.css'; $target = $GLOBALS['Conf']->Site->Path.'/'; /** * Build index.html */ $GLOBALS['level'] = 0; $filename = $target.'index.html'; if (file_exists($filename)) unlink( $filename ); $handle = fopen( $filename, 'w' ); if (file_exists('~data/categorys.inc')) include($GLOBALS['Conf']->Site->Path.'/~data/categorys.inc'); else $category = array(); $links_themes = array(); foreach($category as $key => $val) { if (file_exists('~data/theme'.$key.'.inc')) { include($GLOBALS['Conf']->Site->Path.'/~data/theme'.$key.'.inc'); $themename = 'theme'.$key; $th = &$$themename; $temp = array(); $i = 0; foreach($th as $theme_id => $theme) { if (count($theme) > 0) $temp[] = array( $theme_id, $theme[1] ); if (++$i > 3) break; } $links_themes[$key] = $temp; unset($th); unset($temp); } } $TML->clear_all_assign(); $TML->assign('contentfile', $templates.'index.html'); $TML->assign('records', $category ); $TML->assign('links_themes', $links_themes ); $TML->assign('color1', $_GET['color1']); $TML->assign('color2', $_GET['color2']); $TML->assign('color3', $_GET['color3']); $TML->assign('title', 'Other sites links'); fwrite( $handle, $TML->fetch( $templates.'design.html' )); fclose( $handle ); chmod($filename, 0777); unset($links_themes); /** * Build themes html */ foreach($category as $cat_id => $cat) { $GLOBALS['level'] = 1; $themetarget = $target.'/'.title_encode($cat[1]).'/'; if (!file_exists($themetarget)) { mkdir( clearslash($themetarget), 0777 ); chmod( clearslash($themetarget), 0777); } $filename = $themetarget.'index.html'; if (file_exists($filename)) unlink( $filename ); $handle = fopen( $filename, 'w' ); if (file_exists('~data/theme'.$cat_id.'.inc')) { include($GLOBALS['Conf']->Site->Path.'/~data/theme'.$cat_id.'.inc'); $themename = 'theme'.$cat_id; $th = &$$themename; foreach($th as $theme_id => $theme) { if (file_exists($GLOBALS['Conf']->Site->Path.'/~data/link'.$theme_id.'.inc')) { include($GLOBALS['Conf']->Site->Path.'/~data/link'.$theme_id.'.inc'); $linkname = 'link'.$theme_id; $ln = &$$linkname; $th[ $theme_id ][3] = count( $ln ); unset($$linkname); } else { $th[ $theme_id ][3] = 0; } } } $TML->clear_all_assign(); $TML->assign('th', $th ); $TML->assign('links_category', array('title' => $cat[1] )); $TML->assign('contentfile', $templates.'theme.html'); $TML->assign('color1', $_GET['color1']); $TML->assign('color2', $_GET['color2']); $TML->assign('color3', $_GET['color3']); $TML->assign('title', $cat[1] ); fwrite( $handle, $TML->fetch( $templates.'design.html' )); fclose( $handle ); chmod($filename, 0777); /** * Build links html */ foreach($th as $theme_id => $theme) { $GLOBALS['level'] = 2; $linktarget = $target.'/'.title_encode($cat[1]).'/'.title_encode($theme[1]).'/'; if (!file_exists($linktarget)) { mkdir( clearslash($linktarget), 0777 ); chmod( clearslash($linktarget), 0777); } if (file_exists('~data/link'.$theme_id.'.inc')) include($GLOBALS['Conf']->Site->Path.'/~data/link'.$theme_id.'.inc'); $linkname = 'link'.$theme_id; $ln = &$$linkname; $link_count = count( $ln ); for ($page = 0; $page < ceil($link_count / $GLOBALS['Conf']->Pager->LinkRecPerPage); $page ++) { if ($page == 0) $filename = $linktarget.'index.html'; else $filename = $linktarget.'page'.$page.'.html'; if (file_exists($filename)) unlink( $filename ); $handle = fopen( $filename, 'w' ); $links_arr = array_slice( $ln, $GLOBALS['Conf']->Pager->LinkRecPerPage * $page, $GLOBALS['Conf']->Pager->LinkRecPerPage); $TML->clear_all_assign(); $TML->assign('records', $links_arr ); $TML->assign('links_theme', array( 'links_theme_title' => $theme[1], 'links_category_title' => $cat[1] ) ); $TML->assign('pagerfile', $templates.'pager.html' ); linkpager( &$TML, $page, $link_count, array( 'theme_title' => $theme[1], 'category_title' => $cat[1] ) ); $TML->assign('contentfile', $templates.'link.html'); $TML->assign('color1', $_GET['color1']); $TML->assign('color2', $_GET['color2']); $TML->assign('color3', $_GET['color3']); $TML->assign('title', $cat[1].' > '.$theme[1] ); fwrite( $handle, $TML->fetch( $templates.'design.html' )); fclose( $handle ); chmod($filename, 0777); } unset($ln); } unset($th); } /* function cmp_category($a, $b) { if ((int)$a[0] == (int)$b[0]) { if ($a[1] == $b[1]) { return 0; } return ($a[1] < $b[1]) ? -1 : 1; } return ((int)$a[0] < (int)$b[0]) ? -1 : 1; } */ ?>