// different environments. usleep(rand(50, 100000)); // 100 000 usec = 10% of a second $query = 'SELECT thread_id FROM fp_modules WHERE id = "' . $module['id'] . '"'; $result = mysql_query($query); $data = mysql_fetch_assoc($result); if ($data['thread_id'] > 0) { $module['thread_id'] = $data['thread_id']; } else { $thread_options['forum_id'] = 114; $thread_options['title'] = $module['name']; $thread_options['content'] = 'Det h채r 채r en kommenteringstr책d f철r modulen \\"' . $module['name'] . '\\" p책 f철rstasidan. Egentligen skall sj채lva modulen visas h채r i forumet, typ ovanf철r tr책den. Men det 채r vi inte klara med 채n, s책 tillsvidare f책r man kommentera utan att se modulen :)'; $thread_options['mode'] = 'new_thread'; $thread_options['author'] = 57100; $thread_options['fp_module_id'] = $module['id']; $module['thread_id'] = discussion_forum_post_create($thread_options); $query = 'UPDATE fp_modules SET thread_id = "' . $module['thread_id'] . '" WHERE id = "' . $module['id'] . '"'; mysql_query($query); } } $out .= '<p style="margin-top: 2px;"><a style="color: #565656; text-decoration: underline;" href="' . forum_get_url_by_post($module['thread_id']) . '" class="fp_moudle_commenting">Kommentera i forumet</a></p>' . "\n"; } if ($module['piraja'] == 'true') { $out .= '<p style="margin-top: 2px;"><a style="color: #565656; text-decoration: underline;" href="/piraja/prylar.php">Flera prylar</a></p>' . "\n"; } $out .= '<br style="font-size: 0px; height: 0px; clear: both; line-height: 0px;" />' . "\n"; if ($module['commenting'] == 'true' || $module['published'] == 'true' || $module['grading'] == 'true') { $out .= '<div class="controls">' . "\n"; if ($module['published'] == 'true') { $out .= '<p class="fp_module_published">Upplagd ' . date('Y-m-d', $module['launch']) . '</p>' . "\n"; }
echo '<input type="submit" value="Redigera" class="button">'; echo '</form></div>'; } else { if (isset($_GET['update']) && is_privilegied('news_admin')) { $query = 'UPDATE nyheter SET title="' . $_POST['title'] . '",body="' . $_POST['body'] . '",who="'; $query .= $_POST['who'] . '" WHERE id="' . $_GET['update'] . '" LIMIT 1'; mysql_query($query) or die('Error while updating data, used query:<br />' . $query); echo 'Nyheten har redigerats.<br />'; echo '<a href="' . $_SERVER['PHP_SELF'] . '"><<Tillbaka</a>'; } else { if (isset($_GET['add']) && is_privilegied('news_admin')) { $thread_options['forum_id'] = 2; $thread_options['content'] = $_POST['body']; $thread_options['title'] = $_POST['title']; $thread_options['mode'] = 'new_thread'; $thread_id = discussion_forum_post_create($thread_options); $thread_url = forum_get_url_by_post($thread_id); $query = 'INSERT INTO nyheter (who, tstamp, title, body, thread_url) VALUES ("' . $_SESSION['login']['username'] . '",'; $query .= 'UNIX_TIMESTAMP(),"' . $_POST['title'] . '","' . nl2br($_POST['body']) . '","' . $thread_url . '")'; mysql_query($query) or die(report_sql_error($query)); echo 'Nyheten har lagts in i databasen.<br />'; echo '<a href="' . $_SERVER['PHP_SELF'] . '"><<Tillbaka</a>'; // write_cache(); $query = 'INSERT INTO recent_updates (type, timestamp, url, label) VALUES ("text_news", "' . time() . '", "' . $thread_url . '", "' . $_POST['title'] . '")'; mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); msnbot_queue_add_everyone(array('message' => 'Nyhet på www.hamsterpaj.net!' . "\r\n\r\n" . $_POST['body'] . "\r\n\r\n" . 'Klicka på den här länken för att kommentera nyheten:' . "\r\n" . 'http://www.hamsterpaj.net/' . $thread_url)); } else { if (is_privilegied('news_admin')) { echo '<div id="contentPostbox">'; echo '<form action="' . $_SERVER['PHP_SELF'] . '?add" method="post">'; echo 'Titel:<input type="text" name="title" length="40" cols="40" class="textbox"><br />';
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); } } }
$thread = array_pop(discussion_forum_post_fetch(array('post_id' => $thread_id))); $_SESSION['forum']['subscriptions'][$thread_id] = $thread; } header('Location: ' . $redirect_url); } elseif ($_POST['mode'] == 'sub_thread') { } else { $forum_security = forum_security(array('action' => 'new_post', 'forum_id' => $_POST['forum_id'], 'parent_post' => $_POST['parent'], 'content' => $_POST['content'])); if ($forum_security !== true) { $output .= $forum_security; break; } $post['content'] = $_POST['content']; $post['parent_post'] = $_POST['parent']; $post['forum_id'] = $_POST['forum_id']; $post['mode'] = 'new_post'; $post_id = discussion_forum_post_create($post); if ($_SESSION['preferences']['forum_subscribe_on_post'] == 1) { $query = 'UPDATE forum_read_posts SET subscribing = "true" WHERE user_id = "' . $_SESSION['login']['id'] . '" AND thread_id = "' . $_POST['parent'] . '" LIMIT 1'; mysql_query($query); $thread = array_pop(discussion_forum_post_fetch(array('post_id' => $_POST['parent']))); $_SESSION['forum']['subscriptions'][$_POST['parent']] = $thread; } $redirect_url = forum_get_url_by_post($post_id); } header('Location: ' . $redirect_url); break; case 'threads_by_user': $ui_options['menu_path'][] = 'user_threads'; $output .= '<h2>Dina 50 senaste trådar</h2>' . "\n"; $post_options['threads_only'] = true; $post_options['order-by'] = 'p.id';
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 update_article($content, $id) { if (!isset($content['forum_category_id']) && $content['create_forum_category'] == 1 || $content['forum_category_id'] == 0 && $content['create_forum_category'] == 1) { $category['title'] = $content['title']; $category['parent'] = 90; $category['quality_level'] = 4; $category['title'] = $content['title']; $category['description'] = 'För diskussioner länkade till artikeln: ' . $content['title']; $forum_category_id = discussion_forum_category_create($category); $post['author'] = '2348'; $post['title'] = 'Vad tycker du om artikeln?'; $post['mode'] = 'new_thread'; $post['forum_id'] = $forum_category_id; $post['content'] = 'Vad tycker du om artikeln: ' . $content['title'] . '?'; discussion_forum_post_create($post); } else { $forum_category_id = $content['forum_category_id']; } $query = 'UPDATE articles SET '; $query .= 'title = "' . $content['title'] . '", '; $query .= 'summary = "' . $content['summary'] . '", '; $query .= 'author = "' . $content['author'] . '", '; $query .= 'category_id = "' . $content['category'] . '", '; $query .= 'published = "' . $content['published'] . '", '; $query .= 'commentable = "' . $content['commentable'] . '", '; $query .= 'rankable = "' . $content['rankable'] . '", '; $query .= 'showauthor = "' . $content['showauthor'] . '", '; $query .= 'listed = "' . $content['listed'] . '", '; $query .= 'breaklayout = "' . $content['breaklayout'] . '", '; $query .= 'forum_category_id = "' . $forum_category_id . '" '; $query .= 'WHERE id = "' . $id . '"'; mysql_query($query) or die(report_sql_error($query)); $content = html_entity_decode(stripslashes($content['content'])); $file = fopen(PATHS_INCLUDE . 'articles/' . $id . '.php', 'w'); fwrite($file, $content); fclose($file); jscript_location('/artiklar/?action=show&id=' . $id); }