function discussions_list_splits($discussions) { echo '<!-- Discussion split list with ' . count($discussions) . ' items -->' . "\n"; echo '<div class="discussion_split_list">' . "\n"; echo '<h2>Här startar ' . count($discussions) . ' diskussioner</h2>' . "\n"; echo '<ul>' . "\n"; foreach ($discussions as $discussion) { echo '<li>' . "\n"; echo '<a href="/forum/' . forum_get_parent_category($discussion['category_handle']) . '/' . $discussion['category_handle'] . '/' . $discussion['handle'] . '/">' . $discussion['title'] . '</a>' . "\n"; echo ', ' . fix_time($discussion['timestamp']) . ' (' . $discussion['posts'] . ' inlägg)' . "\n"; echo '</li>' . "\n\n"; } echo '</ul>' . "\n"; echo '</div>' . "\n\n\n"; }
function schedule_releases_do($options) { /* option array support comment item_id yes type yes release_after no */ //trace('schedule', 'Init'); $options['release_before'] = time(); $options['released'] = 0; $events = schedule_event_fetch($options); foreach ($events as $event) { //trace('schedule', 'Releasing ' . $event['type']); $data = unserialize($event['data']); switch ($event['type']) { case 'todays_discussion': $discussion = schedule_release_todays_discussion($event); $url = '/forum/' . forum_get_parent_category($discussion['category_handle']) . '/' . $discussion['category_handle'] . '/' . $discussion['handle'] . '/'; $label = $discussion['title']; break; case 'contest': contests_create($data); $url = '/taevlingar/'; $label = $data['title']; break; case 'poll': // Fulhaxx... $old_session_id = isset($_SESSION['login']['id']) ? $_SESSION['login']['id'] : 0; $_SESSION['login']['id'] = 2348; $poll_handle = poll_create($data); if ($old_session_id == 0) { $_SESSION['login']['id'] = 0; unset($_SESSION['login']['id']); } else { $_SESSION['login']['id'] = $old_session_id; } $poll = poll_fetch(array('handle' => $poll_handle)); $post['content'] = '[poll:' . $poll[0]['id'] . ']'; $post['forum_id'] = 78; $post['title'] = 'Undersökning: ' . $poll[0]['question']; $post['mode'] = 'new_thread'; $post['author'] = 2348; // Webmaster $thread_id = discussion_forum_post_create($post); $comment_url = forum_get_url_by_post($thread_id); $query = 'UPDATE poll SET comment_url = "' . $comment_url . '" WHERE id = "' . $poll[0]['id'] . '"'; mysql_query($query); $url = '/index.php#poll'; $label = $data['question']; break; /* Old sex and sense case 'sex_sense': $entry_id = sex_sense_create($data); $entry = sex_sense_fetch(array('id' => $entry_id)); $url = '/sex_och_sinne/' . $entry[0]['category'] . '/' . $entry[0]['handle'] . '.html'; $label = $entry[0]['title']; break;*/ /* Old sex and sense case 'sex_sense': $entry_id = sex_sense_create($data); $entry = sex_sense_fetch(array('id' => $entry_id)); $url = '/sex_och_sinne/' . $entry[0]['category'] . '/' . $entry[0]['handle'] . '.html'; $label = $entry[0]['title']; break;*/ case 'sex_sense': try { $entries = sex_sense_fetch_posts($data['fetch_item_options']); if (count($entries) != 1) { throw new Exception('Fel 1 i schedule_releae! Base64(serialize): ' . base64_encode(serialize($data))); } $entry = array_pop($entries); $query = 'UPDATE sex_questions SET is_released = 1 WHERE id = ' . $entry['id']; $label = $entry['title']; $url = '/sex_och_sinne/'; $categories = sex_sense_fetch_categories(array('category_id' => $entry['category_id'])); foreach ($categories as $category_tree) { $category = array_pop($category_tree); $url .= $category['category_handle'] . '/'; } $url .= $entry['handle'] . '.html'; // Forum thread creation (main thread) unset($thread); $thread['author'] = '876354'; $thread['title'] = $entry['title']; $thread['mode'] = 'new_thread'; $thread['forum_id'] = '102'; $thread['content'] = $entry['question']; $thread_id = discussion_forum_post_create($thread); $query = 'UPDATE sex_questions SET forum_post_id = ' . $thread_id . ', is_released = 1 WHERE id = ' . $entry['id']; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); // Create forum posts and guestbook notifications for all answers. sex_sense_answer_distribute(array('post_id' => $entry['id'])); } catch (Exception $error) { trace('sex_sense_schedule', $error->getMessage()); } break; case 'music_guess': $query = 'INSERT INTO music_guess_songs (secret_id, artist, song, alternate_spellings, timestamp, artist_score, song_score)' . "\n"; $query .= ' VALUES("' . $data['secret_id'] . '", "' . $data['artist'] . '", "' . $data['song'] . '", "' . addslashes(serialize($data['alternate_spellings'])) . '", "' . time() . '", "' . $data['artist_score'] . '", "' . $data['song_score'] . '")'; mysql_query($query) or trace('sql_error', $query . ' ' . mysql_error()); $url = '/mattan/gissa_laaten.php'; $label = 'Ny låt!'; break; case 'survey': survey_create($data); $survey = survey_fetch(array('type' => 'front_page')); cache_save('fp_survey', $survey); $url = '/index.php#survey'; $label = $data['question']; break; case 'new_image': case 'new_clip': case 'new_flash': case 'new_background': case 'new_software': case 'new_prank': case 'new_music': case 'new_game': $url = $data['url']; $label = $data['title']; break; } $query = 'INSERT INTO recent_updates (type, label, timestamp, url)' . ' VALUES("' . $event['type'] . '", "' . $label . '", "' . $event['release'] . '", "' . $url . '")'; $query . '<br />'; if (!mysql_query($query)) { report_sql_error($query, __FILE__, __LINE__); } else { $query = 'UPDATE scheduled_events SET released = 1 WHERE id="' . $event['id'] . '"'; if (!mysql_query($query)) { report_sql_error($query, __FILE__, __LINE__); } else { log_to_file('scheduled_events', LOGLEVEL_INFO, __FILE__, __LINE__, 'released ' . $event['type'] . ' id: ' . $event['id'] . ' ' . date('Y-m-d H:i', $release)); } } } }
function forum_tag_cloud($tags = null) { if (!isset($tags)) { $query = 'SELECT DISTINCT t.label, t.handle FROM tags AS t, object_tags AS o'; $query .= ' WHERE t.id = o.tag_id AND o.object_type = "discussion"'; $query .= ' ORDER BY t.popularity DESC LIMIT 75'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); $count = 0; while ($data = mysql_fetch_assoc($result)) { if (!forum_get_parent_category($data['handle'])) { $tags[] = $data; $count++; } } shuffle($tags); $tags = array_slice($tags, 0, 25); echo '<h3>Populära taggar</h3>' . "\n"; } echo '<div class="forum_tag_cloud">' . "\n"; echo '<ul>' . "\n"; $class = 'odd'; foreach ($tags as $tag) { echo '<li class="' . $class . '"><a href="/forum/' . $tag['handle'] . '/">' . $tag['label'] . '</a></li>' . "\n"; $class = $class == 'odd' ? 'even' : 'odd'; } echo '</ul>' . "\n"; echo '<br style="clear: both;" />' . "\n"; echo '</div>' . "\n"; echo "\n\n"; }
function posts_url_get($post_id) { $query = 'SELECT p1.*, (count(p2.discussion_id) - 1) as number, d.handle as discussion_handle, t.handle as category_handle, d.category_tag as category_tag_id'; $query .= ' FROM posts as p1, posts as p2, discussions as d, tags as t'; $query .= ' WHERE p1.id = ' . $post_id . ' AND p2.discussion_id = p1.discussion_id AND p2.id <= ' . $post_id . ' AND d.id = p1.discussion_id AND d.category_tag = t.id'; $query .= ' GROUP BY p2.discussion_id'; $result = mysql_query($query) or die(report_sql_error($query)); if ($data = mysql_fetch_assoc($result)) { $page = ceil($data['number'] / POSTS_PER_PAGE); $main_category = forum_get_parent_category($data['category_handle']); return '/forum/' . $main_category . '/' . $data['category_handle'] . '/' . $data['discussion_handle'] . '/sida_' . $page . '.html#post_' . $post_id . '_anchor'; } else { return '/forum/'; } }