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 traffa_draw_user_div($userid, $info = null) { /* If you already have information from the database, please pass it on in the $info parameter. The information should be formatted like this: $info['login']['username'] = '******'; $info['userinfo']['birthday'] = '1970-01-01'; Note that it isn't necessary to have complete info, the script will fetch all info not sent. Please note that this function returns all the data used, you may use it further in your script. Return will look like this: $return['status'] = 'success'/'fail'; $return['reason'] = null or error explanation. $return['login']['lastaction'] = 118371272; */ /* $info is unset further down and the snyggve-info isn't fetched in this function. */ if ($info['snyggve'] == 1) { $snyggve = 1; } if ($userid < 1) { to_logfile('error', __FILE__, __LINE__, 'traffa_draw_user_div() was called without userid', print_r(debug_backtrace(), true)); } $fetch['login'] = array('username', 'lastaction', 'lastrealaction', 'lastlogon', 'regtimestamp', 'userlevel'); $fetch['userinfo'] = array('contact1', 'contact2', 'gender', 'birthday', 'zip_code', 'image', 'current_action', 'cell_phone', 'user_status'); $fetch['traffa'] = array('firstname', 'color_theme'); $fetch['preferences'] = array('activate_current_action'); /* Remove already known fields from the fetch array */ foreach ($info as $table) { foreach ($table as $row) { unset($fetch[$table][$row]); } } $userinfo = login_load_user_data($userid, $fetch); if (!is_array($userinfo)) { to_logfile('error', 'userinfo was not an array, as expected.', __FILE__, __LINE__); die('<p class="error">Ett internt fel orsakades. Visningen av sidan har stoppats och hamsterpajs utvecklingsavdelning har underrättats.</p>'); } /* Inject already known fields to the userinfo array */ foreach ($info as $table) { foreach ($table as $row) { $userinfo[$table][$row] = $info[$table][$row]; } } unset($info); switch ($userinfo['traffa']['color_theme']) { case '1': $profile_colors['light'] = '#edf4fd'; $profile_colors['background'] = '#c9ddf9'; $profile_colors['dark'] = '#7ba0cf'; $profile_colors['border'] = '#3f5879'; break; case '2': $profile_colors['light'] = '#f1edfd'; $profile_colors['background'] = '#d1c9f9'; $profile_colors['dark'] = '#897bcf'; $profile_colors['border'] = '#493f79'; break; case '3': $profile_colors['light'] = '#faedfd'; $profile_colors['background'] = '#efc9f9'; $profile_colors['dark'] = '#bb7bcf'; $profile_colors['border'] = '#6b3f79'; break; case '4': $profile_colors['light'] = '#fdedf7'; $profile_colors['background'] = '#f9c9e7'; $profile_colors['dark'] = '#cf7bb0'; $profile_colors['border'] = '#793f64'; break; case '5': $profile_colors['light'] = '#fdeeed'; $profile_colors['background'] = '#f9c9c9'; $profile_colors['dark'] = '#cf7b7d'; $profile_colors['border'] = '#793f40'; break; case '6': $profile_colors['light'] = '#fdf7ed'; $profile_colors['background'] = '#f9e6c9'; $profile_colors['dark'] = '#cfaa7b'; $profile_colors['border'] = '#79603f'; break; case '7': $profile_colors['light'] = '#fafded'; $profile_colors['background'] = '#f0f9c9'; $profile_colors['dark'] = '#c1cf7b'; $profile_colors['border'] = '#6f793f'; break; case '8': $profile_colors['light'] = '#f0fded'; $profile_colors['background'] = '#d4f9c9'; $profile_colors['dark'] = '#8dcf7b'; $profile_colors['border'] = '#4b793f'; break; case '9': $profile_colors['light'] = '#edfdf4'; $profile_colors['background'] = '#c9f9dc'; $profile_colors['dark'] = '#7bcf9a'; $profile_colors['border'] = '#3f7954'; break; case '10': $profile_colors['light'] = '#edfdfd'; $profile_colors['background'] = '#c9f9f8'; $profile_colors['dark'] = '#7bcfcd'; $profile_colors['border'] = '#3f7978'; break; default: $profile_colors['light'] = '#edf4fd'; $profile_colors['background'] = '#c9ddf9'; $profile_colors['dark'] = '#7ba0cf'; $profile_colors['border'] = '#3f5879'; break; } if ($userinfo['userinfo']['image'] == 1 || $userinfo['userinfo']['image'] == 2) { $image_code = ui_avatar($userid, array('style' => 'float: left; margin: 5px; border: 1px solid #3f657a;')); } elseif ($userid == $_SESSION['login']['id']) { $image_code = '<div class="avatar" style="float: left;"><img src="http://images.hamsterpaj.net/images/noimage.png" /><input type="button" class="button" value="Fixa bild" onclick="window.location=\'/avatar-settings.php\';" /></div>' . "\n"; } else { $image_code = '<img src="http://images.hamsterpaj.net/images/noimage.png" class="avatar" style="float: left; margin: 5px;" />'; } $gender = ''; if ($userinfo['userinfo']['gender'] == 'm') { $gender = 'pojke '; } elseif ($userinfo['userinfo']['gender'] == 'f') { $gender = 'flicka '; } $location = strlen($userinfo['userinfo']['geo_location']) > 0 ? 'från ' . $userinfo['userinfo']['geo_location'] : ''; if ($_SESSION['userinfo']['x_rt90'] > 0 && $userinfo['userinfo']['x_rt90'] > 0 && $userinfo['userinfo']['zip_code'] != $_SESSION['userinfo']['zip_code']) { $location .= ', ' . rt90_readable(rt90_distance($_SESSION['userinfo']['x_rt90'], $_SESSION['userinfo']['y_rt90'], $userinfo['userinfo']['x_rt90'], $userinfo['userinfo']['y_rt90'])); } if ($userinfo['userinfo']['x_rt90'] > 0) { /* Note RT90 Y and X values are flipped, due to a "bug" at hitta.se */ /* Reference: daniel.eklund@hitta.se */ $hittapunktse_url = 'http://www.hitta.se/LargeMap.aspx?ShowSatellite=false&pointX=' . $userinfo['userinfo']['y_rt90']; $hittapunktse_url .= '&pointY=' . $userinfo['userinfo']['x_rt90'] . '&z=4&name=' . $userinfo['login']['username']; $hittapunktse_url .= '&cy=' . $userinfo['userinfo']['x_rt90'] . '&cx' . $userinfo['userinfo']['y_rt90']; $hittapunktse_url = 'http://www.hitta.se/LargeMap.aspx?ShowSatellite=false&pointX=' . $userinfo['userinfo']['y_rt90']; $hittapunktse_url .= '&pointY=' . $userinfo['userinfo']['x_rt90'] . '&cx=' . $userinfo['userinfo']['y_rt90']; $hittapunktse_url .= '&cy=' . $userinfo['userinfo']['x_rt90'] . '&z=6&name=' . $userinfo['login']['username']; $location_button = '<input type="button" value="Visa på karta" class="button_90" onclick="'; $location_button .= "window.open('{$hittapunktse_url}', 'user_map_{$userid}', 'location=false, width=750, height=500');"; $location_button .= '" style="float: right;"/>' . "\n"; } if ($userid == 20702) { $location = 'från Internet '; } $age = ''; if ($userinfo['userinfo']['birthday'] != '0000-00-00') { $age = date_get_age($userinfo['userinfo']['birthday']) . ' år '; } $status = login_onlinestatus($userinfo['login']['lastaction'], $userinfo['login']['lastrealaction']); // $onlinestatus = '<span style="color: grey;">Offline</span>'; // $onlinestatus = '<span style="font-size: 14px;">Loggade senast in ' . fix_time($userinfo['login']['lastlogon']) . '</span>' . "\n"; switch ($status['handle']) { case 'offline': if ($userinfo['login']['lastrealaction'] == 0) { $onlinestatus = '<span style="font-size: 14px;">Sågs senast ' . fix_time($userinfo['login']['lastlogon']) . '</span>' . "\n"; } else { $onlinestatus = '<span style="font-size: 14px;">Sågs senast ' . fix_time($userinfo['login']['lastrealaction']) . '</span>' . "\n"; } break; case 'online': $hours = floor(($userinfo['login']['lastaction'] - $userinfo['login']['lastlogon']) / 3600); $minutes = floor(($userinfo['login']['lastaction'] - $userinfo['login']['lastlogon'] - $hours * 3600) / 60); $onlinestatus = '<span style="color: green; font-size: 14px;">Online </span><span style="font-size: 14px;"> sedan '; $onlinestatus .= $hours > 0 ? $hours . ' timmar och ' : null; $onlinestatus .= $minutes . ' minuter</span>'; break; case 'idle': $onlinestatus = $status['label'] . ' sedan ' . date('H:i', $userinfo['login']['lastrealaction']); break; } $contact1 = strlen($userinfo['userinfo']['contact1']) > 0 ? parseContact($userinfo['userinfo']['contact1']) : array('label' => 'Kontaktsätt', 'link' => '-'); $contact2 = strlen($userinfo['userinfo']['contact2']) > 0 ? parseContact($userinfo['userinfo']['contact2']) : array('label' => 'Kontaktsätt', 'link' => '-'); $firstname = strlen($userinfo['traffa']['firstname']) > 0 ? $userinfo['traffa']['firstname'] : '-'; $right_now = strlen($userinfo['userinfo']['current_action']) > 0 ? $userinfo['userinfo']['current_action'] : 'Okänt'; if ($userinfo['login']['lastlogon'] > strtotime(date('Y-m-d'))) { $lastlogon = 'Idag ' . date('H:i', $userinfo['login']['lastlogon']); } elseif ($userinfo['login']['lastlogon'] > strtotime(date('Y-m-d')) - 86400) { $lastlogon = 'Igår ' . date('H:i', $userinfo['login']['lastlogon']); } elseif ($userinfo['login']['lastlogon'] > strtotime(date('Y-m-d')) - 518400) { $weekdays = array('Söndags', 'Måndags', 'Tisdags', 'Onsdags', 'Torsdags', 'Fredags', 'Lördags'); $lastlogon = 'I ' . $weekdays[date('w', $userinfo['login']['lastlogon'])] . ' klockan ' . date('H:i', $userinfo['login']['lastlogon']); } else { $lastlogon = date('Y-m-d H:i', $userinfo['login']['lastlogon']); } echo '<div style="height: 120px; margin: -3px; margin-bottom: 3px; background: ' . $profile_colors['background'] . '; border-bottom: 1px solid ' . $profile_colors['border'] . '; padding: 3px;">' . "\n"; if (strlen($userinfo['userinfo']['user_status']) > 0) { echo '<h3>' . $userinfo['userinfo']['user_status'] . '</h3>' . "\n"; } echo $image_code . "\n"; echo '<div style="width: 545px; float: left;">' . "\n"; echo '<div style="background: white;">' . "\n"; echo '<h2 style="margin: 0px; font-size: 19px;">' . $userinfo['login']['username'] . ' - ' . $gender . $age . $location . $location_button . '</h2>' . "\n"; echo '<h3>' . $onlinestatus . '</h3>' . "\n"; echo '</div>' . "\n"; echo '<div style="width: 400px;">' . "\n"; echo '<div style="float: left; clear: right; width: 50%;"><span style="font-weight: bold;">Förnamn</span><br />' . $firstname . '</div>'; echo '<div style="float: left; clear: right; width: 50%;"><span style="font-weight: bold;">Blev medlem: </span><br/> ' . date('Y-m-d', $userinfo['login']['regtimestamp']) . '</div><br />' . "\n"; echo '<div style="float: left; clear: both; width: 50%;"><span style="font-weight: bold;">' . $contact1['label'] . '</span><br />' . $contact1['link'] . '</div>' . "\n"; echo '<div style="float: left; clear: right; width: 50%;"><span style="font-weight: bold;">' . $contact2['label'] . '</span><br />' . $contact2['link'] . '</div>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; echo '<div style="margin: -3px; border-bottom: 1px solid ' . $profile_colors['border'] . '; background: ' . $profile_colors['dark'] . '; height: 25px; font-weight: bold; color: white;">' . "\n"; $links[] = array('width' => 95, 'label' => 'Presentation', 'uri' => '/traffa/profile.php?id=' . $userid); $links[] = array('width' => 85, 'label' => 'Gästbok', 'uri' => '/traffa/guestbook.php?view=' . $userid); if ($_SESSION['login']['id'] == $userid) { $links[] = array('width' => 150, 'label' => 'Mina meddelanden', 'uri' => '/traffa/messages.php'); $links[] = array('width' => 100, 'label' => 'Mina besök', 'uri' => '/traffa/my_visitors_joel.php'); } else { $links[] = array('width' => 185, 'label' => 'Skicka privatmeddelande', 'uri' => '/traffa/messages.php?action=compose&recipient_username='******'login']['username'] . '&recipient_id=' . $userid); } foreach ($links as $current) { echo '<div style="float: left; width: ' . $current['width'] . 'px; line-height: 25px; border-right: 1px solid #3f657a; height: 25px; text-align: center;"><a href="' . $current['uri'] . '" style="color: white;">' . $current['label'] . '</a></div>' . "\n"; } if ($userid != $_SESSION['login']['id'] && login_checklogin()) { echo '<input type="button" class="button_80" style="float: right; margin-right: 5px; margin-top: 3px;" value="Kompis" onclick="window.open(\'/traffa/friends_popup.php?user_id=' . $userid . '\', \'cpinternetexplorer\', \'location=no, width=200, height=100\');" />' . "\n"; echo '<input type="button" class="button_100" style="float: right; margin-right: 5px; margin-top: 3px;" value="Rapportera" onclick="abuse_report(\'user\', ' . $userid . ');" />' . "\n"; } if ($_SERVER['REQUEST_URI'] == '/traffa/my_visitors.php') { treasure_item(9); } echo '</div>' . "\n"; }