QExecute(' SELECT id, pos, title, htmltitle FROM category WHERE visible = '.VISIBLE.' AND point >= "'.$point.'" ORDER BY pos, title '); if ($new_categorys->RecordCount() > 0) { $new_categorys = $new_categorys->GetArray(); $target = '~data/categorys.inc'; if (!file_exists($target)) { $category = array(); } else { //$category[id]=array(pos,title,htmltitle); include($target); } foreach($new_categorys as $key => $new_category) { $category[ $new_category['id'] ] = array( $new_category['pos'], $new_category['title'], $new_category['htmltitle'] ); } sortarray( &$category ); reset($category); write_to_inc($target, arrofarr_to_str( 'category', $category ) ); unset($category); } /** * Get and store new ad updated themes */ $new_themes = $DB->QExecute(' SELECT id, pos, title, htmltitle, category_id FROM theme WHERE visible = '.VISIBLE.' AND point >= "'.$point.'" ORDER BY category_id, pos, title '); if ($new_themes->RecordCount() > 0 ) { $new_themes = $new_themes->GetArray(); $category_id = $new_themes[0]['category_id']; $themename = 'theme'.$category_id; $target = '~data/'.$themename.'.inc'; $th = &$$themename; if (!file_exists($target)) { $th = array(); } else { include($target); } foreach($new_themes as $key => $new_theme) { if ($new_theme['category_id'] != $category_id) { sortarray( &$th ); reset($th); write_to_inc($target, arrofarr_to_str( $themename, $th ) ); unset($th); $category_id = $new_theme['category_id']; $themename = 'theme'.$category_id; $target = '~data/'.$themename.'.inc'; $th = &$$themename; if (!file_exists($target)) { $th = array(); } else { include($target); } } $th[ $new_theme['id'] ] = array( $new_theme['pos'], $new_theme['title'], $new_theme['htmltitle'] ); } sortarray( &$th ); reset($th); write_to_inc($target, arrofarr_to_str( $themename, $th ) ); unset($th); } /** * Get and store new ad updated link */ $themesids = $DB->QExecute(' SELECT id FROM theme WHERE visible = '.VISIBLE.' ORDER BY id '); if ($themesids->RecordCount() > 0 ) $themesids = $themesids->GetArray(); else $themesids = array(); foreach($themesids as $key => $themeid) { $rsnew_links = $DB->QExecute(' SELECT id, title, url, description, theme_id FROM link WHERE visible = '.VISIBLE.' AND point >= "'.$point.'" AND theme_id = '.$themeid['id'].' ORDER BY title '); if ($rsnew_links->RecordCount() > 0 ) { $new_links = $rsnew_links->GetArray(); unset($rsnew_links); $theme_id = $themeid['id']; $linkname = 'link'.$theme_id; $target = '~data/'.$linkname.'.inc'; $ln = &$$linkname; if (!file_exists($target)) { $ln = array(); } else { include($target); } foreach($new_links as $key => $new_link) { $ln[ $new_link['id'] ] = array( $new_link['title'], $new_link['url'], $new_link['description'] ); } ksort($ln); reset($ln); $str = arrofarr_to_str( $linkname, $ln ); write_to_inc($target, &$str ); unset($ln); unset($$linkname); unset($str); } unset($new_links); } /** * Array Sor Function */ function sortarray( &$arr ) { $temp = array(); foreach($arr as $ak => $av) { array_unshift($av, $ak); $temp[] = $av; } usort( &$temp, 'cmpbypos'); $arr = array(); foreach($temp as $ak => $av) { $ak = $av[0]; array_shift($av); $arr[$ak] = $av; } } function cmpbypos($a, $b) { if ($a[1] == $b[1]) { return 0; } return ($a[1] < $b[1]) ? -1 : 1; } ?>