{ $part_1 = substr($cat, 0, 6); $part_2 = substr($cat, 7); $out .= $part_1 . ' selected="selected"' . $part_2; } else { $out .= $cat; } } $out .= '</select>';*/ $out .= '<select name="sex_category" id="sex_category">' . "\n"; $categories = array_pop(sex_sense_fetch_categories(array('parent_category' => 0))); foreach ($categories as $category) { $out .= '<optgroup label="' . $category['category_title'] . '">' . "\n"; $child_categories = array_pop(sex_sense_fetch_categories(array('parent_category' => $category['category_id']))); foreach ($child_categories as $child_category) { $selected = $question['category'] == $child_category['category_id'] ? ' selected="selected"' : ''; $out .= "\t" . '<option value="' . $child_category['category_id'] . '"' . $selected . '>' . $child_category['category_title'] . '</option>' . "\n"; } $out .= '</optgroup>' . "\n"; } $out .= '</select>'; $out .= '</h3>' . "\n"; $out .= sex_sense_dark_container_bottom(); $out .= '<textarea name="question" style="width: 550px; height: 200px;">' . $question['question'] . '</textarea><br style="clear: both;" />' . "\n"; foreach ($question['answers'] as $answer) { $out .= ui_avatar($answer['user_id']); $out .= sex_sense_bubble_top(); $out .= '<h4>' . $answer['username'] . ' svarar:</h4>' . "\n"; $out .= '<p>' . nl2br($answer['answer']) . '</p>' . "\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': trace('todays_discussion_break', 'Tried to release todays_discussion in ' . __FILE__ . ' on line ' . __LINE__); break; case 'contest': contests_create($data); $url = '/taevlingar/'; $label = $data['title']; break; case 'poll': $poll_handle = poll_create($data); $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 sex_sense_answer_distribute($options) { $options['id'] = $options['post_id']; $options['ignore_no_posts_found_error'] = true; $posts = sex_sense_fetch_posts($options); if (count($posts) < 1) { $options['is_answered'] = 0; $posts = sex_sense_fetch_posts($options); } $post = array_pop($posts); if ($post['forum_post_id'] == 0) { return false; } foreach ($post['answers'] as $answer) { if (isset($options['answer_id']) && $answer['id'] == $options['answer_id'] || !isset($options['answer_id'])) { $forum_post['forum_id'] = '102'; $forum_post['author'] = $answer['user_id']; $forum_post['parent_post'] = $post['forum_post_id']; $forum_post['content'] = $answer['answer']; discussion_forum_post_create($forum_post); $direct_link = '/sex_och_sinne/'; $categories = sex_sense_fetch_categories(array('category_id' => $post['category_id'])); foreach ($categories as $category_tree) { $category = array_pop($category_tree); $direct_link .= $category['category_handle'] . '/'; } $direct_link .= $post['handle'] . '.html'; $entry['recipient'] = $post['user_id']; $entry['sender'] = 2348; $entry['is_private'] = 1; $message = 'En av dina frågor i Sex och sinne är besvarad.' . "\n"; $message .= 'Klicka här för att komma till frågan :) ' . "\n"; $message .= '<a href="' . $direct_link . '">http://hamsterpaj.net' . $direct_link . '</a>' . "\n"; $entry['message'] = mysql_real_escape_string($message); guestbook_insert($entry); } } }
} break; case 'save_new_question': if (login_checklogin()) { sex_sense_new_question_create(array('user_id' => $_SESSION['login']['id'], 'question' => $_POST['question'])); jscript_alert('Tack för din fråga! Du kommer att få ett privat gästboksinlägg så fort din fråga är besvarad :)'); jscript_location('/sex_och_sinne/'); exit; } else { $out .= '<h2>Din fråga kunde inte skapas!</h2><pre>' . $_POST['question'] . '</pre>'; throw new Exception('Du måste vara inloggad för att skapa nya frågor.'); } break; case 'latest': $ui_options['menu_path'] = array('sex_sense', 'latest'); $category = array_pop(sex_sense_fetch_categories(array('parent_category' => 0))); $out .= sex_sense_render_category($category); $out .= '<h2>Senast besvarade frågorna</h2>'; $options['order'] = 'DESC'; $options['order_by'] = 'last_answer'; $options['is_answered'] = 1; $options['is_released'] = 1; $question = sex_sense_fetch_posts($options); $out .= sex_sense_render_posts($question); break; case 'admin': break; } } catch (Exception $error) { $out .= '<div class="warning">' . "\n"; $out .= '<h2>Ett systemfel har inträffat!</h2>' . "\n";