function getTree($parentID, $level) { global $config; $childCount = 0; $cCounter = 1; if ($children = findChildren($parentID)) { $childCount = count($children); $cCounter = 1; foreach ($children as $value) { for ($x = 0; $x < $level; $x++) { //echo " "; } $galleryNameText = $_SESSION['galleriesData'][$value]['name']; //$galleryNameText = str_replace("'",'\'',$galleryNameText); //$galleryNameText = str_replace('"','"',$galleryNameText); $galleryNameText = str_replace('\\', '', $galleryNameText); $galleryNameText = htmlspecialchars($galleryNameText); // New in 4.4.7 /* $galleryNameText = str_replace('(','',$galleryNameText); $galleryNameText = str_replace(')','',$galleryNameText); $galleryNameText = str_replace('/','',$galleryNameText); $galleryNameText = str_replace(')','',$galleryNameText); */ //$galleryNameText = cleanString($galleryNameText); if ($config['settings']['gallery_count'] and $_SESSION['galleriesData'][$value]['gallery_count']) { $galleryNameText .= " (" . $_SESSION['galleriesData'][$value]['gallery_count'] . ")"; } if ($_SESSION['galleriesData'][$value]['password']) { $galleryNameText .= " <span class='treeLock'> </span>"; } $linkto = $_SESSION['galleriesData'][$value]['linkto']; echo "{ \r\n\t\t\t\t\t\"attr\" : { \"id\" : \"galleryTree{$value}\" }, \r\n\t\t\t\t\t\"data\" : { \r\n\t\t\t\t\t\t\"title\" : \"{$galleryNameText}\", \r\n\t\t\t\t\t\t\"level\" : \"{$level}\", \r\n\t\t\t\t\t\t\"attr\" : { \"href\" : \"{$linkto}\" }, \r\n\t\t\t\t\t\t\"icon\" : \"\" \r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"children\" : [ "; if ($value) { getTree($value, $level + 1); } echo " ]"; // ,\"state\" : \"closed\" echo "}"; //echo "<br /><br />"; // For testing if ($cCounter < $childCount) { echo ","; } $cCounter++; } } }
function findChildren($forum, $childArray = "") { if (!isset($childArray)) { global $children; } if (!isset($children)) { $children = array(); } $child_res = dbquery("select * from " . DB_PREFIX . "fb_forums f\n\t\tleft join " . DB_PREFIX . "forums f2 on f2.forum_id=f.forum_id\n\t\twhere " . groupaccess("f2.forum_access") . " and f.forum_parent='{$forum}'"); if (dbrows($child_res)) { while ($child_data = dbarray($child_res)) { array_push($children, $child_data['forum_id']); findChildren($child_data['forum_id']); } } }
} echo "<img src='{$sfimage2}' alt='' style='vertical-align:middle;'> \n\t\t\t\t\t<a href='" . FORUM . "viewforum.php?forum_id=" . $c_data['forum_id'] . "' class='small'>" . $c_data['forum_name'] . "</a><br />"; $counter++; } echo "</td></tr></table>"; } } echo "</td>\n"; echo "<td class='tbl2' style='white-space:nowrap; padding:5px;' width='1%' nowrap='nowrap'>"; $posts = $data['forum_postcount']; $threads = $data['forum_threadcount']; $children = array(); if (dbrows($c_res)) { while ($child_data = dbarray($c_res)) { array_push($children, $child_data['forum_id']); findChildren($child_data['forum_id']); } } if (count($children)) { $where = ""; $counter = count($children); $normalWhere = ""; foreach ($children as $child) { $where .= "t.forum_id='{$child}' " . ($counter > 1 ? "OR " : ""); $normalWhere .= "forum_id='{$child}' " . ($counter > 1 ? "OR " : ""); $counter--; } $posts = $posts + dbcount("(post_id)", DB_POSTS, $normalWhere); $threads = $threads + dbcount("(thread_id)", DB_THREADS, $normalWhere); $childrenForums = dbquery("select * from " . $db_prefix . "threads t\n\t\t\tleft join " . $db_prefix . "users u on u.user_id=t.thread_lastuser\n\t\t\tleft join " . $db_prefix . "posts p on p.post_id=t.thread_lastpostid\n\t\t\twhere ({$where} OR t.forum_id='" . $data['forum_id'] . "') \n\t\t\torder by t.thread_lastpost desc limit 1"); $childrenData = dbarray($childrenForums);