function viewPosts($mode = 'normal', $criteria = NULL) { //Visar alla inlägg $query = makeQuery($mode, $criteria); $result = mysql_query($query) or die('Ett fel har upstått:<br/>' . mysql_error()); $genderlabels['P'] = 'Pojke'; $genderlabels['F'] = 'Flicka'; while ($data = mysql_fetch_assoc($result)) { $userage = date_get_age($data['birthday']); if ($data['gender'] == 'P') { $divbg = 'blue_faded_div'; } elseif ($data['gender'] == 'F') { $divbg = 'pink_faded_div'; } else { $divbg = 'grey_faded_div'; } if (isset($_SESSION['login']['username'])) { if (preg_match("/" . $_SESSION['login']['username'] . "/i", $data['text'])) { $divbg = 'orange_faded_div'; } elseif ($_SESSION['login']['username'] == $data['username']) { $divbg = 'green_faded_div'; } } echo '<div class="' . $divbg . '" style="repeat-x; margin-top: 10px; border: 1px solid #CCCCCC;">' . "\n"; echo '<table class="body" style="width: 100%;"><tr><td style="vertical-align: top; width: 75px;">' . "\n"; if ($data['image'] == 1 || $data['image'] == 2) { echo insert_avatar($data['userid']); } else { echo '<img src="/images/noimage.png" style="width: 75px; height: 75px; border: 1px solid #cccccc;" alt="Ingen visningsbild"/>' . "\n"; } echo '</td><td style="vertical-align: top;">'; echo fix_time($data['timestamp']) . ' (inlägg #' . $data['id'] . ') <a style="text-decoration:none;" href="javascript:#;" onclick="javascript:document.gbform.message.value=document.gbform.message.value+\'' . $data['username'] . ' : \';document.gbform.message.focus();">[^]</a><br/>' . "\n"; echo '<a href="' . $hp_url . '/traffa/profile.php?id=' . $data['userid'] . '">' . "\n"; echo '<b>' . $data['username'] . '</b></a> ' . "\n"; echo birthdaycake($data['birthday']) . ' ' . "\n"; echo $genderlabels[$data['gender']]; if ($userage > 1) { echo ' ' . $userage . 'år' . "\n"; } if (strlen($data['geo_location']) > 1) { echo ' från ' . htmlentities($data['geo_location']) . "\n"; } echo '<br/>' . "\n"; echo setsmilies($data['text']) . "\n"; echo '</td></tr></table>' . "\n"; echo '</div>' . "\n"; } //while-satsen för att skriva ut inlägg }
$divbg = 'pink_faded_div'; } else { $divbg = 'grey_faded_div'; } echo '<div class="' . $divbg . '" style="repeat-x; margin-top: 10px; border: 1px solid #CCCCCC;">'; echo '<table class="body" style="width: 100%;"><tr><td style="vertical-align: top; width: 75px;">'; if ($data['image'] == 1 || $data['image'] == 2) { echo insert_avatar($data['userid']); } else { echo '<img src="' . IMAGE_URL . 'images/noimage.png" style="width: 75px; height: 75px; border: 1px solid #cccccc;" alt="Ingen visningsbild"/>'; } echo '</td><td style="vertical-align: top;">'; echo fix_time($data['tstamp']) . '<br/>'; echo '<a href="/traffa/profile.php?id=' . $data['userid'] . '">'; echo '<strong>' . $data['username'] . '</strong></a> '; echo birthdaycake($data['birthday']) . ' '; if ($data['gender'] == 'P') { echo ' Kille, '; } elseif ($data['gender'] == 'F') { echo ' Tjej, '; } if ($data['birthday'] > '0000-00-00') { $age = date_get_age($data['birthday']); echo $age . ' år '; } if (strlen($data['geo_location']) > 0) { echo 'från ' . $data['geo_location']; } echo '<br/><br/>'; if (strlen($data['contact1']) > 0) { $contact1 = parseContact($data['contact1']);
function discussion_forum_post_render($data, $parent_post = array(), $options = array()) { $options['post'] = $data; /* [id] => 2 [handle] => normal_vikt [author] => 3 [timestamp] => 1200341971 [parent_post] => 0 [forum_id] => 0 [forum_type] => public_forum [title] => Normal vikt? [content] => Denna post har skapats av en funktion! [score] => 0 [verified] => 0 [removed] => 0 [removal_comment] => [remover] => 0 [child_count] => 1 [locked] => 0 [sticky] => 0 [last_post] => 0 [anonymous] => 0 [username] => Johan [birthday] => 1988-09-10 [gender] => m [spot] => Göteborg */ $warned = 0; $options['show_post_controls'] = isset($options['show_post_controls']) ? $options['show_post_controls'] : true; $options['show_removed_posts_content'] = isset($options['show_removed_posts_content']) ? $options['show_removed_posts_content'] : false; $return = '<a name="post_' . $data['id'] . '"></a>' . "\n"; $return .= '<input type="hidden" id="post_' . $data['id'] . '_author_username" value="' . $data['username'] . '" />' . "\n"; $return .= '<div class="forum_post_container">' . "\n"; if ($data['removed'] == 1 && $options['show_removed_posts_content'] != true) { $return .= '<div class="forum_post_removed">Inlägget har tagits bort' . "\n"; $return .= $options['show_post_controls'] == true && forum_security(array('action' => 'unremove_post')) ? '<button value="' . $data['id'] . '" class="forum_unremove_button">trob At</button>, Borttaget av <a href="/traffa/profile.php?id=' . $data['remover'] . '">' . $data['remover'] . '</a>.' . "\n" : ''; $return .= '</div>'; } else { $return .= strpos(strtolower($data['content']), strtolower($_SESSION['login']['username'])) ? '<div class="highlight">' . "\n" : ''; $return .= '<div class="forum_post_top"></div>' . "\n"; $return .= '<div class="forum_post" id="forum_post_' . $data['id'] . '">' . "\n"; $return .= '<div class="author">' . "\n"; $return .= '<a class="username" href="/traffa/profile.php?id=' . $data['author'] . '">' . $data['username']; $return .= '</a>' . "\n"; $return .= $data['author'] == 2 ? ' <a href="/diskussionsforum/hamsterpaj/veckans_ros/" title="Veckans ros"><img src="http://images.hamsterpaj.net/ros.png" alt="Ros" style="width: 11px; height: 17px;border:0;" /></a><br style="clear: both;" />' . "\n" : ''; $return .= '<div class="passepartout">' . "\n"; $return .= ui_avatar($data['author']); if ($data['author'] == 625058) { $return .= '<img class="bars" src="http://images.hamsterpaj.net/discussion_forum/bars.gif" />' . "\n"; } $return .= '</div>' . "\n"; if ($data['gender'] == 'f') { $return .= '<span class="gender">F</span>' . "\n"; } elseif ($data['gender'] == 'm') { $return .= '<span class="gender">P</span>' . "\n"; } if ($data['birthday'] != '0000-00-00') { $return .= '<span class="age">' . date_get_age($data['birthday']) . '</span>' . "\n"; } if (strlen($data['spot']) > 0) { $return .= ' <span class="location">' . $data['spot'] . '</span>' . "\n"; } if ($data['last_warning'] > time() - 604800) { $return .= '<span class="warned">Varnad ' . '</span>' . "\n"; } elseif (strlen($data['forum_userlabel']) > 0) { $return .= '<span class="userlevel">' . $data['forum_userlabel'] . '</span>' . "\n"; } elseif ($data['regtimestamp'] < time() - 86400 * 356 * 2.5) { $return .= '<span class="userlevel">Veteran</span>' . "\n"; } elseif ($data['regtimestamp'] < time() - 86400 * 356) { $return .= '<span class="userlevel">Stammis</span>' . "\n"; } elseif ($data['regtimestamp'] > time() - 86400 * 7) { $return .= '<span class="userlevel">Nykomling</span>' . "\n"; } if ($data['quality_level'] == 1) { $return .= '<span class="post_count">' . cute_number($data['author_spam_count']) . ' spam</span>' . "\n"; } else { if ($data['author'] == 15) { $author_post_count = 'Några osöta'; } elseif ($data['author'] == 87926) { $author_post_count = 'Många söta'; } elseif ($data['author'] == 774586) { $author_post_count = 'Inte många'; } else { $author_post_count = cute_number($data['author_post_count']); } $return .= '<span class="post_count">' . $author_post_count . ' inlägg</span>' . "\n"; } if ($data['lastaction'] > time() - 600) { $return .= '<span class="online_status">Online</span>' . "\n"; } $return .= birthdaycake($data['birthday']) . "\n"; $return .= '</div>' . "\n"; $return .= '<div class="post_info">' . "\n"; $return .= '<span class="post_timestamp">' . fix_time($data['timestamp']) . '</span>' . "\n"; $return .= $data['parent_post'] == 0 ? '<h3>' . $data['title'] . '</h3>' : ''; $return .= '</div>' . "\n"; $return .= '<div class="post_content">' . "\n"; $return .= $data['removed'] == 1 ? '<strong>Inlägget är borttaget!</strong><br />' . "\n" : ''; $return .= discussion_forum_parse_output($data['content'], $options); if (strlen($data['user_status']) > 0) { $return .= '<p class="user_status">' . $data['user_status'] . '</p>' . "\n"; } $return .= '</div>' . "\n"; $return .= '<div class="controls">' . "\n"; if ($options['show_post_controls'] == true) { $return .= '<input type="text" class="forum_direct_link_input" id="forum_direct_link_input_' . $data['id'] . '" />'; $return .= '<button id="forum_direct_link_button_' . $data['id'] . '" class="forum_direct_link_button">Länk</button>' . "\n"; $return .= forum_security(array('action' => 'remove_post')) ? '<button value="' . $data['id'] . '" class="forum_remove_button">Ta bort</button>' . "\n" : ''; $return .= forum_security(array('action' => 'edit_post', 'post' => $data)) || forum_security(array('action' => 'post_addition', 'post' => $data)) ? '<button id="forum_edit_button_' . $data['id'] . '" class="forum_edit_button">Ändra</button>' . "\n" : ''; $return .= forum_security() ? '<button id="post_reply_' . $data['id'] . '" class="forum_reply_button">Citera</button>' . "\n" : ''; $return .= forum_security(array('action' => 'reply', 'post' => $parent_post)) === true ? '<button id="post_reply_' . $data['id'] . '" class="forum_reply_button">Svara</button>' . "\n" : ''; $return .= login_checklogin() ? '<button id="post_comment_' . $data['author'] . '" class="forum_comment_button" value="' . $data['id'] . '">Gästbok</button>' . "\n" : ''; if (forum_security()) { $return .= '<input type="checkbox" class="post_move_check" name="post[]" value="' . $data['id'] . '" id="forum_move_check_' . $data['id'] . '" />'; $return .= '<label for="forum_move_check_' . $data['id'] . '">Flytta</label>' . "\n"; } $return .= forum_security(array('action' => 'user_ro')) ? '<button value="' . $data['username'] . '" class="forum_user_ro">QL</button>' . "\n" : ''; $return .= forum_security(array('action' => 'report')) ? '<a href="/hamsterpaj/abuse.php?report_type=forum_post&reference_id=' . $data['id'] . '" class="abuse_button"><img src="http://images.hamsterpaj.net/abuse.png" /></a>' . "\n" : ''; $return .= guestbook_form(array('recipient' => $data['author'], 'form_id' => 'forum_comment_' . $data['id'])); } else { $return .= '<small>Knappar har inaktiverats</small>'; } $return .= '</div>' . "\n"; $return .= '</div>' . "\n"; $return .= '<div class="forum_post_bottom"> </div>' . "\n"; $return .= strpos(strtolower($data['content']), strtolower($_SESSION['login']['username'])) ? '</div>' . "\n" : ''; } $return .= '</div>' . "\n"; return $return; }
function posts_list($posts, $discussions = null, $options) { $options['quality_level'] = isset($options['quality_level']) ? $options['quality_level'] : 0; $options['mode'] = isset($options['mode']) ? $options['mode'] : 'forum'; echo '<input type="hidden" id="debug_input" />'; foreach ($posts as $i => $post) { /* Shall we display any discussion splits before the post? */ $display_discussions = array(); foreach ($discussions as $key => $discussion) { if ($discussion['timestamp'] <= $post['timestamp']) { $display_discussions[] = $discussion; unset($discussions[$key]); } } if (count($display_discussions) > 0) { discussions_list_splits($display_discussions); } if (in_array('private_gb', $post['flags'])) { echo '<h5 class="private_header">Privat inlägg</h5>' . "\n"; if ($_SESSION['login']['id'] != $post['author'] && $_SESSION['login']['id'] != $options['gb_recipient']) { continue; } } echo '<!-- Post #' . $post['post_id'] . ' at ' . date('Y-m-d H:i:s', $post['timestamp']) . '-->' . "\n"; echo '<a name="post_' . $post['post_id'] . '_anchor"></a>' . "\n"; if (in_array('removed', $post['flags'])) { echo '<div class="removed_post">' . "\n"; echo '<h2>Borttaget inlägg, skrevs ' . fix_time($post['timestamp']) . ' av <a href="/traffa/profile.php?id=' . $post['author'] . '">' . $post['username'] . '</a></h2>' . "\n"; echo '</div>' . "\n"; $displayed_posts[] = $post['post_id']; continue; } // todo! /* detta skall användas för Skräpklassade inlägg, inlägg flaggade med junk $rounded_corners_color = in_array('junk', $post['flags']) ? 'orange' : ((login_checklogin() && strpos( $post['content'], $_SESSION['login']['username'])) ? 'orange' : 'blue'); */ $rounded_corners_color = login_checklogin() && strpos($post['content'], $_SESSION['login']['username']) ? 'orange' : 'blue'; echo rounded_corners_top(array('id' => 'post_' . $post['post_id'], 'color' => $rounded_corners_color)); echo '<div class="post">' . "\n"; /* Head section */ echo '<div class="head">' . "\n"; echo ' <span class="date_time">Skrevs ' . fix_time($post['timestamp']) . '</span>' . "\n"; echo ' <a href="/traffa/profile.php?id=' . $post['author'] . '">' . $post['username'] . '</a>' . "\n"; if ($post['gender'] == 'm') { echo ' kille'; } elseif ($post['gender'] == 'f') { echo ' tjej'; } echo date_get_age($post['birthday']) > 0 ? ' ' . date_get_age($post['birthday']) . ' år' : ''; echo strlen($post['spot']) > 0 ? ' från ' . $post['spot'] . "\n" : ''; $onlinestatus = login_onlinestatus($post['lastaction'], $post['lastrealaction']); echo ' <span class="user_label_' . $onlinestatus['handle'] . '">' . $onlinestatus['label'] . '</span>' . "\n"; echo '</div>' . "\n"; /* Author pane */ echo '<div class="author_pane">' . "\n"; if ($post['image'] == 1 || $post['image'] == 2) { echo user_avatar($post['author']) . "\n"; } echo ' '; echo birthdaycake($post['birthday']); echo '</div>' . "\n"; echo '<div id="post_content_' . $post['post_id'] . '" class="content">' . "\n"; $options_markup['post_id'] = $post['post_id']; $options_markup['context'] = 'forum'; if ($post['no_smilies'] != 1) { echo setsmilies(markup_parse($post['content'], $options_markup)); } else { echo markup_parse($post['content'], $options_markup); } if (strlen($post['forum_signature']) > 0) { echo '<div class="signature">' . $post['forum_signature'] . '</div>' . "\n"; } if (strlen($post['user_status']) > 0) { echo '<p class="user_status">' . $post['user_status'] . '</p>' . "\n"; } echo '</div>' . "\n"; echo '<div class="controls">' . "\n"; if (login_checklogin()) { $control_buttons['answer'] = '<input type="button" class="post_answer_button" id="post_answer_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Svara" />'; $control_buttons['comment'] = '<input type="button" class="post_comment_button" id="post_comment_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Kommentera" />'; $control_buttons['quote'] = '<input type="button" class="post_quote_button" id="post_quote_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Citera" />'; $control_buttons['history'] = '<input type="button" class="post_history_button" id="post_history_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Historik" />'; $control_buttons['delete'] = '<input type="button" class="post_delete_button" id="post_delete_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Ta bort" />'; $control_buttons['censor'] = '<input type="button" class="post_censor_button" id="post_censor_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Censurera" />'; $control_buttons['addition'] = '<input type="button" class="post_addition_button" id="post_addition_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Tillägg" />'; $control_buttons['link'] = '<input type="button" class="post_link_button" id="post_link_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Direktlänk" />'; $control_buttons['report'] = '<input type="button" class="post_report_button" value="Rapport" onclick="abuse_report(\'post\', \'' . $post['post_id'] . '\');" />'; $control_buttons['edit'] = '<input type="button" class="post_edit_button" id="post_edit_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Ändra"/>'; $control_buttons['junk'] = '<input type="button" class="post_junk_button" id="post_junk_button_' . $post['post_id'] . '_' . $post['username'] . '" value="Skräp!"/>'; $control_set['forum'] = array('answer', 'comment', 'quote', 'link'); $control_set['guestbook'] = array('answer', 'quote', 'history'); // $control_set['game_comment'] = array(); $control_set['admin'] = array('delete', 'censor', 'addition'); // todo! Aktivera Skräpknappen när färgspecen är klar, 'junk'); // $control_set['game_admin'] = array('delete'); foreach ($control_set[$options['mode']] as $button) { echo $control_buttons[$button] . "\n"; } if (posts_admin_check($post)) { if ($options['mode'] == 'game_comment') { $control_set['admin'] = $control_set['game_admin']; } foreach ($control_set['admin'] as $button) { echo $control_buttons[$button] . "\n"; } } if ($post['author'] == $_SESSION['login']['id']) { if (!posts_admin_check($post)) { echo $control_buttons['addition'] . "\n"; } if (time() < $post['timestamp'] + 20 * 60) { echo $control_buttons['edit'] . "\n"; } } if ($_SESSION['login']['userlevel'] == 2) { echo $control_buttons['report']; } } echo '</div>' . "\n"; echo '<div class="post_addition" id="post_addition_' . $post['post_id'] . '">' . "\n"; echo ' <textarea id="post_addition_content_' . $post['post_id'] . '" rows="3" cols="50" ></textarea>' . "\n"; echo ' <button class="button_60" id="post_addition_submit_' . $post['post_id'] . '" value="post_addition_' . $post['post_id'] . '">Spara</button>' . "\n"; echo '</div>' . "\n"; echo '<div class="post_link" id="post_link_' . $post['post_id'] . '">' . "\n"; echo '<h5>Länken nedan går direkt till detta inlägg.</h5>' . "\n"; echo '<input type="text" class="post_link_input" value="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '#post_' . $post['post_id'] . '_anchor" />' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; echo rounded_corners_bottom(array('color' => $rounded_corners_color)); echo "\n\n"; $displayed_posts[] = $post['post_id']; } if (login_checklogin()) { /* Remove all notices and answer notices for read posts */ $query = 'DELETE FROM notices WHERE post_id IN("' . implode('", "', $displayed_posts) . '") AND user_id = "' . $_SESSION['login']['id'] . '"'; mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); } /* List the remaining discussions */ if (count($discussions) > 0) { discussions_list_splits($discussions); } }
function group_list_messages($options) { $groupid = $options['group_id']; /* Fetch the total messages in group */ $selectquery = 'SELECT message_count AS total, owner FROM groups_list WHERE groupid = ' . $groupid; $result = mysql_query($selectquery) or die(report_sql_error($selectquery)); $data = mysql_fetch_assoc($result); $total_msg = $data['total']; $new_messages = $data['total']; /* Get the group owner */ $owner = $data['owner']; /* Fetch read_msg for this user */ $selectquery = 'SELECT read_msg AS total_read FROM groups_members WHERE groupid = ' . $groupid . ' AND userid = ' . $_SESSION['login']['id']; $result = mysql_query($selectquery) or die(report_sql_error($selectquery)); $data = mysql_fetch_assoc($result); $query = 'UPDATE groups_members SET read_msg = ' . $total_msg . ' WHERE userid = ' . $_SESSION['login']['id'] . ' AND groupid = ' . $groupid; mysql_query($query) or die(report_sql_error($query)); $new_messages = $new_messages - $data['total_read']; /* Update the read_msg */ $query = 'SELECT login.username, groups_scribble.userid, groups_scribble.timestamp, groups_scribble.text, groups_scribble.id, userinfo.image, userinfo.birthday FROM login, groups_scribble, userinfo WHERE login.id = groups_scribble.userid AND groups_scribble.groupid = ' . $groupid . ' AND userinfo.userid = groups_scribble.userid AND groups_scribble.deleted = 0 ORDER BY groups_scribble.id DESC LIMIT ' . ($options['page'] - 1) * 100 . ', 100'; //Lef hackar via råd från heggan. Maskroskisseporr ska inte synas för hennes söta ögon. if ($_SESSION['login']['id'] == '148153') { /* Fetch the total messages in group */ $query = 'SELECT login.username, groups_scribble.userid, groups_scribble.timestamp, groups_scribble.text, groups_scribble.id, userinfo.image, userinfo.birthday FROM login, groups_scribble, userinfo WHERE groups_scribble.text NOT LIKE "%maskrosp0rn%" AND login.id = groups_scribble.userid AND groups_scribble.groupid = ' . $groupid . ' AND userinfo.userid = groups_scribble.userid AND groups_scribble.deleted = 0 ORDER BY groups_scribble.id DESC LIMIT ' . ($options['page'] - 1) * 100 . ', 100'; } //Död åt lef $result = mysql_query($query) or die(report_sql_error($query)); /* $count_read - Hur många msg har gruppen */ $count_read = 0; while ($data = mysql_fetch_assoc($result)) { for ($i = 0; $i < count($surveys); $i++) { if ($surveys[$i]['start_time'] >= $data['timestamp']) { echo survey_draw_frame($surveys[$i]); unset($surveys[$i]); } } $div_code = $count_read < $new_messages ? 'orange' : 'blue'; if (preg_match("/(" . $_SESSION['login']['username'] . "|Magic word: igotgodmodeigotgubbmode)/i", $data['text'])) { $div_code = 'red_alert_deluxe'; } echo rounded_corners_top(array('color' => $div_code)); echo '<table class="body" style="width: 95%;"><tr><td style="vertical-align: top; width: 75px;">'; if ($data['image'] == 1 || $data['image'] == 2) { echo ui_avatar($data['userid']); } else { echo '<img src="http://images.hamsterpaj.net/user_no_image.png" alt="Ingen visninsbild"/>'; } echo '</td><td style="vertical-align: top;">'; echo fix_time($data['timestamp']) . ' <a href="javascript:void(0);" onclick="javascript:document.postform.group_message.value=document.postform.group_message.value + \'' . $data['username'] . ': \';document.postform.group_message.focus();">[^]</a><br/>'; echo '<a href="' . $hp_url . '/traffa/profile.php?id=' . $data['userid'] . '">'; echo '<b>' . ($data['userid'] == 43273 ? '<span style="color: #FF60B6">SuwpahGhey</span>' : $data['username']) . '</b></a> '; if ($owner == $_SESSION['login']['id']) { echo '<a href="' . $_SERVER['PHP_SELF'] . '?action=remove_post&groupid=' . $groupid . '&postid=' . $data['id'] . '">[Ta bort]</a>'; } echo birthdaycake($data['birthday']) . ' '; echo '<br/>'; echo setSmilies(discussion_forum_parse_output($data['text'])); echo '</td></tr></table>'; echo rounded_corners_bottom(array('color' => $div_code)); $count_read++; } }