function render_entries($entries, $options) { $content .= '<ul class="group_entries">' . "\n"; foreach ($entries as $entry) { $options['user_id'] = $entry['user_id']; $content .= message_top($options); $content .= '<div style="border-bottom: 1px solid #ababab;">' . "\n"; $content .= '<span class="timestamp">' . fix_time($entry['timestamp']) . '</span>' . "\n"; $content .= '<h2 style="display: inline;">' . $entry['header'] . '</h2> - <a href="/traffa/profile.php?id=' . $entry['user_id'] . '">' . $entry['username'] . '</a> ' . "\n"; $content .= $entry['gender']; $content .= date_get_age($entry['birthday']); $content .= '<p>' . "\n"; $content .= nl2br(html_entity_decode($entry['content'])) . "\n"; $content .= '</p>' . "\n"; $content .= '</div>' . "\n"; // ----START---- $content .= $_GET['action'] != 'show' ? '<a href="/hamsterpaj/hamsterblogg.php?action=show&id=' . $entry['id'] . '">Kommentera »</a>' : '<a href="/hamsterpaj/hamsterblogg.php">« Tillbaka</a>'; // ----END------ $content .= message_bottom(); if ($options['enable_comments'] == true) { $content .= rounded_corners_top(); $content .= '<label>Kommentera:</label>' . "\n"; $content .= comments_input_draw($entry['id'], 'hamsterblog'); $content .= rounded_corners_bottom(); $content .= '<div style="clear: both;"></div>' . "\n"; $content .= comments_list($entry['id'], 'hamsterblog'); } } $content .= '</ul>' . "\n"; return $content; }
function films_film_play_draw($film, $options) { event_log_log('new_' . $film['film_type'] . '_watch'); film_view_count($film['id']); echo '<div class="film_play" id="film_play">' . "\n"; rounded_corners_top(); $related_films = films_fetch(array('released' => true, 'film_type' => $film['film_type'], 'exclude' => array($film['id']), 'limit' => 3, 'order' => 'random')); films_list($related_films, array('list_type' => 'film_list_compact', 'headline' => 'Fler ' . $film['film_type'])); echo '<h1 class="film_header">' . $film['title'] . '</h1>' . "\n"; echo '<div class="film_statistics">' . "\n"; echo '<div class="film_view_count">' . "\n"; echo cute_number($film['view_count'] + 1) . ' visningar' . "\n"; echo '</div>' . "\n"; // film_view_count echo rank_draw($film['rank_average'], array('size' => 'medium')); // echo '<div class="film_rank_count">' . "\n"; // echo cute_number($film['rank_count']) . ' röster' . "\n"; // echo '</div>' . "\n"; if (5 == $_SESSION['login']['userlevel']) { echo '<a class="film_edit" href="/film/admin/' . $film['handle'] . '.html">[Redigera]</a>' . "\n"; } echo '</div>' . "\n"; // film_statistics echo '<div class="film_player">' . "\n"; if ($film['trailer_id'] > 0) { echo '<!-- Play Networks - Embeddable Flash Player -->' . "\n"; echo '<div id="playnw" class="playnw">' . "\n"; echo '<script src="http://se.player.playnetworks.net/player.php?mid=' . $film['trailer_id'] . '&channel_user_id=4601100020-1&width=460&height=345"></script><br>' . "\n"; echo '</div>' . "\n"; echo '<!-- Play Networks - Embeddable Flash Player -->' . "\n"; } elseif ($film['use_special_code'] == 1) { echo stripslashes($film['html']); } elseif ($film['extension'] == 'swf') { //todo! Här skall anpassas till distribute-systemet. distribute_server_get skall anropas för att f? en adress // adress skall byggas med server . type . handle . '.' . extension echo '<object type="application/x-shockwave-flash" data="http://amuse.hamsterpaj.net/distribute/film/' . $film['handle'] . '.swf" > <param name="movie" value="http://amuse.hamsterpaj.net/distribute/film/' . $film['handle'] . '.swf" /></object>'; } elseif ($film['extension'] == 'flv') { //todo! Här skall anpassas till distribute-systemet. distribute_server_get skall anropas för att f? en adress // adress skall byggas med server . type . handle . '.' . extension echo '<p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Installera Flash Player</a> för att kunna se den här filmen.</p> <script type="text/javascript"> var s1 = new SWFObject("/film/flvplayer.swf","single","460","345","7"); s1.addParam("allowfullscreen","true"); s1.addVariable("file","http://amuse.hamsterpaj.net/distribute/film/' . $film['handle'] . '.flv"); s1.addVariable("image","' . IMAGE_URL . '/film/' . $film['handle'] . '.png"); s1.addVariable("width","460"); s1.addVariable("height","345"); s1.write("player1"); </script>'; } elseif ($film['film_type'] == 'bilder') { //todo! Här skall anpassas till distribute-systemet. distribute_server_get skall anropas för att f? en adress // adress skall byggas med server . type . handle . '.' . extension echo '<img src="http://images.hamsterpaj.net/fun_images/' . $film['handle'] . '.jpg" class="fun_images_big" />' . "\n"; } echo '</div>' . "\n"; // film_player echo '<br style="clear: both;" />' . "\n"; echo '<div class="film_description">' . "\n"; if (strlen($film['description']) > 0) { echo '<p>' . $film['description'] . '</p>' . "\n"; } if ($film['trailer_id'] > 0) { echo '<p>Filmtrailers visas i samarbete med Play Networks</p>' . "\n"; } echo '</div>' . "\n"; // end film_description echo '<div class="film_comments">' . "\n"; echo '<input type="hidden" id="film_id" value="' . $film['id'] . '" />' . "\n"; echo '<h2 class="rank_input_header">Din poäng</h2>' . "\n"; echo '<h2 class="comment_input_header">Din kommentar</h2>' . "\n"; echo '<br style="clear: both;" />' . "\n"; $query = 'SELECT rank FROM user_ranks WHERE user_id = "' . $_SESSION['login']['id'] . '" AND item_id = "' . $film['id'] . '" AND item_type = "film"'; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $data = mysql_fetch_assoc($result); } unset($rank_options); $rank_options['previous'] = $data['rank']; rank_input_draw($film['id'], 'film', $rank_options); comments_input_draw($film['id'], 'film'); echo '<br style="clear: both;" />' . "\n"; echo '</div>' . "\n"; // film_comments rounded_corners_bottom(); $options['comments'] = isset($options['comments']) ? $options['comments'] : 'yes'; if ($options['comments'] == 'yes') { rounded_corners_top(); echo comments_list($film['id'], 'film'); rounded_corners_bottom(); } echo '</div>' . "\n"; // film_play }
function photo_display_full($parameters) { event_log_log('photo_display'); $next_by_day = photo_get_photos(array('limit' => 1, 'photo_taken' => $parameters['image']['photo_taken'], 'order_direction' => 'ASC', 'internal_id_min' => $parameters['image']['internal_id'])); $next_by_album = photo_get_photos(array('limit' => 1, 'album' => $parameters['image']['album'], 'order_direction' => 'ASC', 'internal_id_min' => $parameters['image']['internal_id'])); $previous_by_day = photo_get_photos(array('limit' => 1, 'photo_taken' => $parameters['image']['photo_taken'], 'order_direction' => 'DESC', 'internal_id_max' => $parameters['image']['internal_id'])); $previous_by_album = photo_get_photos(array('limit' => 1, 'album' => $parameters['image']['album'], 'order_direction' => 'DESC', 'internal_id_max' => $parameters['image']['internal_id'])); echo '<div class="photo_full">' . "\n"; echo '<div class="head">' . "\n"; echo '<span class="date">' . $parameters['image']['photo_taken'] . '</span>' . "\n"; if (strlen($parameters['image']['description']) > 0) { echo '<p class="photo_description">' . "\n"; echo $parameters['image']['description'] . "\n"; echo '</p>' . "\n"; } echo '</div>' . "\n"; // Photo with passepartout echo '<div class="photo_passepartout_outer">' . "\n"; echo '<div class="photo_passepartout_inner">' . "\n"; echo '<img src="' . PHOTO_FULL_IMAGE_URL . floor($parameters['image']['internal_id'] / 5000) . '/' . $parameters['image']['external_id'] . '.jpg" />' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; echo '<div class="foot">' . "\n"; echo '<div class="next">' . "\n"; if ($next_by_day[0]['internal_id'] > 0) { echo '<a href="/fotoalbum/bild.php?photo=' . $next_by_day[0]['external_id'] . '"><button class="button_110">Samma dag »</button></a>' . "\n"; } if ($next_by_album[0]['internal_id'] > 0) { echo '<a href="/fotoalbum/bild.php?photo=' . $next_by_album[0]['external_id'] . '"><button class="button_110">Samma album »</button></a>' . "\n"; } echo '</div>' . "\n"; echo '<div class="previous">' . "\n"; if ($previous_by_day[0]['internal_id'] > 0) { echo '<a href="/fotoalbum/bild.php?photo=' . $previous_by_day[0]['external_id'] . '"><button class="button_110">« Samma dag</button></a>' . "\n"; } if ($previous_by_album[0]['internal_id'] > 0) { echo '<a href="/fotoalbum/bild.php?photo=' . $previous_by_album[0]['external_id'] . '"><button class="button_110">« Samma album</button></a>' . "\n"; } echo '</div>' . "\n"; echo '</div>' . "\n"; echo '</div>' . "\n"; $query = 'UPDATE photos SET unread_comments = 0 WHERE internal_id = "' . $parameters['image']['internal_id'] . '" LIMIT 1'; mysql_query($query); echo '<h2>Kommentarer</h2>' . "\n"; echo '<h5>Här kan du lämna din kommentar</h5>' . "\n"; echo comments_input_draw($parameters['image']['internal_id'], 'photo'); rounded_corners_top(); echo comments_list($parameters['image']['internal_id'], 'photo'); rounded_corners_bottom(); // Count views if (!in_array($parameters['image']['internal_id'], $_SESSION['photos']['viewed_photos'])) { $_SESSION['photos']['viewed_photos'][] = $parameters['image']['internal_id']; $query = 'UPDATE photos SET view_count = view_count + 1 WHERE internal_id = "' . $parameters['image']['internal_id'] . '" LIMIT 1'; mysql_query($query); } }
} echo '<h2>Hur lik är hamburgaren reklambilden?</h2>' . "\n"; $labels[0] = 'Oigenkännlig'; $labels[1] = 'Inte alls lik'; $labels[2] = 'Igenkännbar'; $labels[3] = 'Ganska lik'; $labels[4] = 'Identisk'; for ($i = 0; $i < 5; $i++) { echo '<button value="' . $i . '" class="button_100" style="margin-right: 20px;" onclick="window.location = \'/hamburgare/test.php?burger_vote=' . $i . '&burger=' . $_SESSION['burger']['current_burger'] . '\';">' . $labels[$i] . '</button>' . "\n"; } echo '<div id="burger_compare">' . "\n"; echo '<img src="' . IMAGE_URL . 'hamburgers/' . $_SESSION['burger']['current_burger'] . '_ad.jpg" />' . "\n"; echo '<img src="' . IMAGE_URL . 'hamburgers/' . $_SESSION['burger']['current_burger'] . '_real.jpg" />' . "\n"; echo '</div>' . "\n"; echo '<h2>Kommentera burgaren</h2>' . "\n"; echo comments_input_draw($_SESSION['burger']['current_burger'], 'burger'); rounded_corners_top(); echo comments_list($_SESSION['burger']['current_burger'], 'burger'); rounded_corners_bottom(); } else { echo '<p>Går det att känna igen hamburgarna från kedjornas reklambilder? Gissa dig igenom och sätt betyg på 14 hamburgare i vårt hamburger-test!</p>' . "\n"; if (isset($_GET['burger']) && isset($_GET['burger_vote']) && in_array($_GET['burger_vote'], array(0, 1, 2, 3, 4))) { $query = 'UPDATE burgers SET votes = votes + 1, score = score + ' . $_GET['burger_vote'] . ', average_score = score/votes WHERE id = "' . $_GET['burger'] . '"'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } $query = 'SELECT id FROM burgers WHERE id NOT IN("' . implode('", "', $_SESSION['burger']['seen_burgers']) . '") ORDER BY RAND() LIMIT 1'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); if (mysql_num_rows($result) == 1) { $data = mysql_fetch_assoc($result); $_SESSION['burger']['current_burger'] = $data['id']; $_SESSION['burger']['seen_burgers'][] = $data['id'];
function entertain_item_draw($item, $options) { global $entertain_types; entertain_item_viewed($item['id'], $item['entertain_type'], $item['view_count']); $output .= '<span class="' . $item['entertain_type'] . '">' . "\n"; $output .= '<div class="entertain_item">' . "\n"; // Item title $output .= '<h1 class="entertain_header">' . $item['title'] . '</h1>' . "\n"; /* The entertainment items are displayed in different ways for different types. Games have full width while movie clips, flash films and images are displayed in 3/4 width, whith a few thumbnails on the side. */ switch ($item['entertain_type']) { case 'software': case 'clip': case 'flash': case 'image': $fetch_result = entertain_fetch(array('released' => true, 'entertain_type' => $item['entertain_type'], 'exclude' => array($item['id']), 'limit' => 3, 'order' => 'random')); $related_items = $fetch_result['items']; $output .= entertain_list($related_items, array('list_style' => 'thumbnails', 'headline' => 'Fler ' . $entertain_types[$item['entertain_type']]['label_plural'])); break; case 'game': break; } // Item rank, counter and release date $output .= '<div class="entertain_statistics">' . "\n"; $output .= '<div class="entertain_rank">' . "\n"; $output .= rank_draw($item['rank_average'], array('size' => 'medium')); $output .= '</div>' . "\n"; // end entertain_rank $output .= '<div class="entertain_view_count">' . "\n"; $output .= cute_number($item['view_count'] + 1) . ' visningar sedan ' . "\n"; $output .= date('Y-m-d', $item['release']); //fix_time($item['release']); $output .= '</div>' . "\n"; // end entertain_date $output .= '</div>' . "\n"; // end entertain_statistics $output .= '<div class="entertain_player" id="entertain_player">' . "\n"; /* Now we shall display the entertainment item itself. This is done in different ways for different types and also different depending on special properties like use_special_code or trailer_id. */ if ($_SESSION['login']['id'] == 87926) { preint_r($item); } //First, we consider a bunch of special cases, that is film trailers, items with their own special html, images and software links if ($item['trailer_id'] > 0) { $output .= '<!-- Play Networks - Embeddable Flash Player -->' . "\n"; $output .= '<div id="playnw" class="playnw">' . "\n"; $output .= '<script src="http://se.player.playnetworks.net/player.php?mid=' . $item['trailer_id'] . '&channel_user_id=4601100020-1&width=474&height=355"></script><br>' . "\n"; $output .= '</div>' . "\n"; $output .= '<!-- Play Networks - Embeddable Flash Player -->' . "\n"; } elseif ($item['use_special_code'] == 1) { $output .= stripslashes($item['html']); } elseif (strlen($item['link']) > 2 && $item['entertain_type'] == 'image') { $server = distribute_server_get(array('item_handle' => $item['handle'], 'type' => $item['entertain_type'])); $address = 'http://' . $server['address'] . '/distribute/' . $item['entertain_type'] . '/' . $item['handle'] . '.' . $item['extension']; $output .= '<a href="' . $item['link'] . '"><img src="' . $address . '" class="entertain_' . $item['entertain_type'] . '" /></a>' . "\n"; } elseif ($item['entertain_type'] == 'software') { $output .= '<button onclick="window.location=\'' . $item['link'] . '\';" class="button_150">Ladda ner</button><br />' . "\n"; $output .= '<p>Alla filer är givetvis gratis att ladda ner och innehåller inga virus!</p>' . "\n"; } else { $server = distribute_server_get(array('item_handle' => $item['handle'], 'type' => $item['entertain_type'])); $address = 'http://' . $server['address'] . '/distribute/' . $item['entertain_type'] . '/' . $item['handle'] . '.' . $item['extension']; switch ($item['extension']) { case 'swf': $wrapper = ''; $output .= '<object type="application/x-shockwave-flash" data="' . $wrapper . $address . '" > <param name="movie" value="' . $wrapper . $address . '" /></object>'; $item['entertain_type'] == 'clip' || $item['entertain_type'] == 'flash' ? event_log_log('jc_ad_after') : ''; break; case 'flv': $player_url = '/entertain/flvplayer.swf'; // On end of J-store campaign, set width to 456 and height to 355 on both places $output .= '<div id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Installera Flash Player</a> för att kunna se den här grejen.</div> <script type="text/javascript"> var s1 = new SWFObject("' . $player_url . '","single","466","336","7"); s1.addParam("allowfullscreen","true"); s1.addVariable("file","' . $address . '"); s1.addVariable("image","' . IMAGE_URL . '/entertain/' . $item['handle'] . '.png"); s1.addVariable("width","466"); s1.addVariable("height","336"); s1.write("player1"); </script>'; break; case 'jpg': case 'png': case 'gif': $server = distribute_server_get(array('item_handle' => $item['handle'], 'type' => $item['entertain_type'])); $address = 'http://' . $server['address'] . '/distribute/' . $item['entertain_type'] . '/' . $item['handle'] . '.' . $item['extension']; $output .= '<img src="' . $address . '" class="entertain_' . $item['entertain_type'] . '" />' . "\n"; } } $output .= '<div class="entertain_item_buttons">' . "\n"; if ($item['entertain_type'] == 'image') { $query = 'SELECT id, handle FROM entertain_items WHERE id < "' . $item['id'] . '"'; $query .= ' AND `release` < ' . time(); $query .= ' AND entertain_type = "' . $item['entertain_type'] . '"'; $query .= ' ORDER BY id DESC'; $query .= ' LIMIT 1'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if ($data = mysql_fetch_assoc($result)) { $output .= '<a href="/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/' . $data['handle'] . '.html">'; $output .= '<button id="entertain_previous" class="button_90">'; $output .= 'Föregående'; $output .= '</button></a>' . "\n"; } $query = 'SELECT id, handle FROM entertain_items WHERE id > "' . $item['id'] . '"'; $query .= ' AND `release` < ' . time(); $query .= ' AND entertain_type = "' . $item['entertain_type'] . '"'; $query .= ' ORDER BY id ASC'; $query .= ' LIMIT 1'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if ($data = mysql_fetch_assoc($result)) { $output .= '<a href="/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/' . $data['handle'] . '.html">'; $output .= '<button id="entertain_next" class="button_90">'; $output .= 'Nästa'; $output .= '</button></a>' . "\n"; } } if ($item['extension'] == 'swf') { $output .= '<button id="entertain_fullscreen" onclick="javascript: open_fullscreen_window(\'' . $address . '\');">'; $output .= 'Spela i fullskärm'; $output .= '</button>' . "\n"; } $output .= '</div>' . "\n"; // end entertain_item_buttons $output .= '</div>' . "\n"; // end entertain_player // Description and game controls $output .= '<div class="entertain_description">' . "\n"; if (strlen($item['description']) > 0) { $output .= $item['description'] . "\n"; } if ($item['trailer_id'] > 0) { $output .= '<p>Filmtrailers visas i samarbete med Play Networks</p>' . "\n"; } $output .= '</div>' . "\n"; // end entertain_description if (!is_array($item['controls'])) { $item['controls'] = unserialize(utf8_decode($item['controls'])); $utf8_mupp = true; } if (is_array($item['controls']) && count($item['controls']) > 0) { $output .= '<h2>Kontroller</h2>' . "\n"; $output .= '<table class="entertain_controls">' . "\n"; $num_of_rows = ceil(count($item['controls']) / 2); for ($i = 0; $i < $num_of_rows; $i++) { $output .= '<tr>' . "\n"; if (!$utf8_mupp) { $output .= '<td class="combination">' . $item['controls'][$i]['combination'] . '</td>' . "\n"; $output .= '<td class="description">' . $item['controls'][$i]['description'] . '</td>' . "\n"; } else { $output .= '<td class="combination">' . utf8_encode($item['controls'][$i]['combination']) . '</td>' . "\n"; $output .= '<td class="description">' . utf8_encode($item['controls'][$i]['description']) . '</td>' . "\n"; } $output .= '</tr>' . "\n"; } $output .= '</table>' . "\n"; } if (is_privilegied('entertain_update')) { $output .= '<a class="entertain_edit" href="/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/admin/' . $item['handle'] . '.html">[Redigera]</a>' . "\n"; } if (is_privilegied('entertain_add')) { $output .= 'Personen som laddat upp det här objektet är: <a href="/traffa/profile.php?id=' . $item['uploader'] . '">' . $item['uploader'] . '</a>'; } //todo! connect with javascript // Comments - Users can rank and leave a comment. These are handled by separate libraries but are connected // by javascript so that users submit rank and comment together. $output .= '<div class="entertain_comments">' . "\n"; $output .= '<input type="hidden" id="entertain_item_id" value="' . $item['id'] . '" />' . "\n"; $output .= '<h2 class="rank_input_header">Din poäng</h2>' . "\n"; $output .= '<h2 class="comment_input_header">Din kommentar</h2>' . "\n"; $output .= '<br style="clear: both;" />' . "\n"; if (login_checklogin()) { $query = 'SELECT rank FROM user_ranks WHERE user_id = "' . $_SESSION['login']['id'] . '" AND item_id = "' . $item['id'] . '" AND item_type = "entertain"'; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $data = mysql_fetch_assoc($result); } } unset($rank_options); $rank_options['previous'] = $data['rank']; $output .= rank_input_draw($item['id'], 'entertain', $rank_options); $output .= comments_input_draw($item['id'], 'entertain'); $output .= '<br style="clear: both;" />' . "\n"; $output .= '</div>' . "\n"; // end entertain_comments $options['comments'] = isset($options['comments']) ? $options['comments'] : 'yes'; if ($options['comments'] == 'yes') { $output .= comments_list($item['id'], 'entertain'); } $output .= '</div>' . "\n"; // end entertainment_item $output .= '</span>' . "\n"; // end $entertain_type return $output; }
function tests_calculate_score($options) { $options['source'] = isset($options['source']) ? $options['source'] : $_POST; if (!isset($options['handle'])) { tests_index(array('error_message' => 'Inget handle skickat till tests_calculate_score()!')); return; } $answers = array(); $answers_to_fetch = array(); foreach ($_POST as $post_variable_key => $post_variable) { if (preg_match('/^tests_save_answer_([0-9]+)_([0-9r]+)$/', $post_variable_key, $matches)) { // $matches[1] = question id $answers[$matches[1]][] = $post_variable; //$answers[question_id][x] = answer $unique_questions_answered[$matches[1]] = $matches[1]; } } $answers_points = array(); $answers_to_fetch_sql = ''; foreach ($answers_to_fetch as $answer) { $answers_to_fetch_sql .= ' OR q.question_id = ' . $answer; } if (count($answers) > 0) { $query = 'SELECT id, custom_css, custom_score_phrases'; $query .= ' FROM tests'; $query .= ' WHERE handle = "' . $options['handle'] . '"'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); if (mysql_num_rows($result) != 1) { tests_index(array('error_message' => 'Testet du postade till finns inte eller fanns två gånger!')); return; } $data = mysql_fetch_assoc($result); $test_custom_css = $data['custom_css']; $test_custom_score_phrases = $data['custom_score_phrases']; $test_id = $data['id']; $query = 'SELECT q.answers, q.answer_type, q.question_id'; $query .= ' FROM tests_questions AS q, tests AS t'; $query .= ' WHERE t.handle = "' . $options['handle'] . '" AND t.id = q.test_id'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); $total_score = 0; $max_score = 0; $answers_to_save_sql = array(); while ($data = mysql_fetch_assoc($result)) { $question_answers = unserialize(stripslashes($data['answers'])); $this_question_max_score = 0; foreach ($question_answers as $question_answer_key => $question_answer) { /* question_answer[0] = answer, question_answer[1] = points/score (<--That's what we're going to use!). */ if (in_array($question_answer_key, $answers[$data['question_id']])) { if (login_checklogin()) { // %TESTID% is replaced with the tests ID below... // (user_id, test_id, question_id, answer_id) $answers_to_save_sql[] = '(' . $_SESSION['login']['id'] . ', %TESTID%, ' . $data['question_id'] . ', ' . $question_answer_key . ')'; } $total_score = $total_score + $question_answer[1]; } if ($data['answer_type'] == 'single_answer') { if ($this_question_max_score < $question_answer[1]) { $this_question_max_score = $question_answer[1]; } } elseif ($data['answer_type'] == 'multiple_answers' && $question_answer[1] > 0) { $this_question_max_score = $this_question_max_score + $question_answer[1]; } } $max_score = $max_score + $this_question_max_score; } if ($max_score > 0 && $total_score > 0) { $score_percents_right = round($total_score / $max_score * 100); if ($max_score == $total_score) { $score_text_index = 'all'; } else { $score_text_index = round($total_score / $max_score * 4) + 1; // 1-5 } $score_color_index = round($total_score / $max_score * 4) + 1; // 1-5 } else { $percents_right = 0; $score_color_index = 1; $score_text_index = 'zero'; /*if($total_score < 0) { $score_text_index = 'below_zero'; }*/ } $score_texts = array(); //$score_texts['below_zero'] = 'Men du, det här gick inte så bra alls! Minuspoäng! %TOTAL_SCORE% av %MAX_SCORE%.'; $score_texts['zero'] = 'Men du... Du fick noll poäng, dags att öva?'; $score_texts['all'] = 'Gratulerar! Du fick alla rätt! (%MAX_SCORE% var max).'; $score_texts[1] = 'Nä, det här var du inte så bra på. Du fick bara %TOTAL_SCORE% av %MAX_SCORE% poäng.'; $score_texts[2] = 'Det gick väl sådär, du fick %TOTAL_SCORE% poäng av %MAX_SCORE% möjliga.'; $score_texts[3] = 'Bättre kan du! Av %MAX_SCORE% fick du %TOTAL_SCORE%, alltså ungefär hälften.'; $score_texts[4] = 'Du fick hyfast bra poäng, men ändå inte jättebra. Om du övar lite så kanske dina %TOTAL_SCORE% poäng blir maxpoäng (%MAX_SCORE%p).'; $score_texts[5] = 'Gratulerar! Du fick %TOTAL_SCORE% poäng, vilket är nästan alla rätt. På det här testet kunde man som mest få %MAX_SCORE%.'; if (!empty($custom_score_phrases)) { $score_texts = unserialize(stripslashes($custom_score_phrases)); } $score_text = str_replace(array('%TOTAL_SCORE%', '%MAX_SCORE%'), array($total_score, $max_score), $score_texts[$score_text_index]); global $ui_options; $ui_options['stylesheets'][] = 'tests.css'; $ui_options['stylesheets'][] = 'comments.css'; $ui_options['javascripts'][] = 'comments.js'; if ($custom_css == 'yes') { $ui_options['stylesheets'][] = $options['handle']; } ui_top($ui_options); //echo '<h1>Resultat av test</h1>'; echo '<h2>' . $score_text . '</h2>'; echo '<div class="score_meter"><div class="color_' . $score_color_index . '" style="width: ' . $score_percents_right * 3 . 'px"> </div></div>'; echo '<div class="score_meter_right">Din poäng: ' . $total_score . ' (' . $score_percents_right . '% av max)<br />Maxpoäng: ' . $max_score . '</div>'; echo '<br style="clear: both" />'; if (login_checklogin()) { if (count($answers_to_save_sql) > 0) { $query = 'SELECT id FROM tests WHERE handle = "' . $options['handle'] . '" LIMIT 1'; $result = mysql_query($query) or report_sql_error($query); $data = mysql_fetch_assoc($result); $test_id = $data['id']; $query = 'INSERT INTO tests_user_score (user_id, test_id, score, timestamp) VALUES'; $query .= ' (' . $_SESSION['login']['id'] . ', ' . $test_id . ', ' . $total_score . ', ' . time() . ')'; $result = @mysql_query($query); // ... if ($result) { $query = 'INSERT INTO tests_user_answers (user_id, test_id, question_id, answer_id) VALUES'; $query .= ' ' . str_replace('%TESTID%', $test_id, implode(', ', $answers_to_save_sql)); } else { echo 'Poängen sparades inte eftersom att du redan gjort testet en gång.'; } } else { echo 'Du måste svara på någon av frågorna!'; } } else { echo 'Om du loggar in så kan vi spara dina poäng också!'; } echo '</p><br /><br />' . "\n"; echo '<h2>Folk som gjort testet</h2>'; echo rounded_corners_top(); echo tests_get_last_test_completers(array('test_id' => $test_id, 'limit' => 4)); echo '<br style="clear: both" />'; echo rounded_corners_bottom(); echo rounded_corners_top(); echo 'Kommentera testet: ' . comments_input_draw($test_id, 'tests'); echo comments_list($test_id, 'tests'); echo rounded_corners_bottom(); echo '<p>'; echo '<a href="/tests/">Tillbaka till testernas förstasida.</a>'; echo '</p>'; } else { global $ui_options; ui_top($ui_options); jscript_go_back(); } }
function games_game_draw($game, $options = null) { echo '<input type="hidden" id="game_handle" value="' . $game['handle'] . '"/>' . "\n"; echo '<div class="game_play">' . "\n"; echo '<h1>' . $game['title'] . '</h1>' . "\n"; echo '<div id="game_header">' . "\n"; rounded_corners_top(); echo '<div id="game_header_main">' . "\n"; echo '<p>' . $game['description'] . '</p>' . "\n"; echo '<div id="game_buttons" >' . "\n"; echo '<button id="game_fullscreen" onclick="javascript: open_fullscreen_window(\'http://amuse.hamsterpaj.net/distribute/game/' . $game['handle'] . '.swf\');">'; echo 'Spela i fullskärm'; echo '</button>' . "\n"; /* if(5 == $_SESSION['login']['userlevel']) */ /* { */ echo '<button id="game_challenge_button" >Utmana en kompis</button>' . "\n"; /* } */ if (login_checklogin()) { $query = 'SELECT * FROM user_favorites AS uf, games AS g WHERE uf.type = "game" AND uf.item_id = g.id AND g.handle = "' . $game['handle'] . '" AND uf.user_id = "' . $_SESSION['login']['id'] . '"'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); $is_favorite = mysql_fetch_assoc($result) ? true : false; } echo '<div id="game_vote_div" class="vote">' . "\n"; echo '</div>' . "\n"; //end vote echo '</div>' . "\n"; //end game_buttons echo '</div>' . "\n"; //end game_header_main echo '<div id="game_header_info">' . "\n"; games_game_popularity_draw($game); //a div with class game_popularity games_list_tags(tag_get_by_handle(array_keys($game['tags']))); if (3 <= $_SESSION['login']['userlevel']) { echo '<a href="/spel/redigera/' . $game['handle'] . '.php" >Redigera spelet</a>' . "\n"; } echo '</div>' . "\n"; //end game_header_info echo '<br style="clear: both;" />' . "\n"; rounded_corners_bottom(); echo '</div>' . "\n"; //end game_header //Challenge a friend echo '<input type="hidden" id="game_handle" value="' . $game['handle'] . '"/>'; echo '<input type="hidden" id="game_title" value="' . $game['title'] . '"/>'; echo '<div id="game_challenge">' . "\n"; rounded_corners_top(); echo '<a name="challenge"></a>' . "\n"; //alternativ A - hamsterpaj //todo! kolla att användaren är inloggad annars visa snabbregistrering if (login_checklogin()) { echo '<div class="challenge_alternative_a">' . "\n"; echo '<h3>Skicka utmaning här på Hamsterpaj</h3>' . "\n"; echo '<div class="challenge_recievers">' . "\n"; for ($i = 1; $i < 4; $i++) { echo '<h5>Kompis #' . $i . '</h5>' . "\n"; echo '<input type="text" name="game_challenge_username_' . $i . '" id="game_challenge_username_' . $i . '"/>' . "\n"; } echo '</div>' . "\n"; echo '<div class="challenge_message">' . "\n"; echo '<h5>Hälsning (skriv gärna hur långt du kom i spelet)</h5>' . "\n"; echo '<textarea name="game_challenge_hp_message" id="game_challenge_hp_message" ></textarea>' . "\n"; echo '<button id="game_challenge_hp_submit">Skicka!</button>' . "\n"; echo '</div>' . "\n"; //end challenge_message; echo '<br />' . "\n"; echo '</div>' . "\n"; //end challenge_alternative } else { echo '<div class="challenge_alternative_a_not_member">' . "\n"; echo '<h3>Skicka utmaning här på Hamsterpaj</h3>' . "\n"; echo '<div class="register_info">' . "\n"; echo '<p>Man kan bara skicka meddelanden på hamsterpaj om man är medlem men det blir du på två sekunder tryck bara på knappen.</p>' . "\n"; echo '<button onclick="javascript: tiny_reg_form_show();" >Bli medlem!</button>' . "\n"; echo '</div>' . "\n"; //end register_info echo '</div>' . "\n"; //end challenge_alternative_a_not_member } echo '<hr />' . "\n"; //alternativ B - e-post echo '<div class="challenge_alternative_b">' . "\n"; echo '<h3>Skicka utmaning med e-post</h3>' . "\n"; echo '<div class="challenge_recievers">' . "\n"; for ($i = 1; $i < 4; $i++) { echo '<h5>e-post till kompis #' . $i . '</h5>' . "\n"; echo '<input type="text" name="game_challenge_email_' . $i . '" id="game_challenge_email_' . $i . '"/>' . "\n"; } echo '</div>' . "\n"; echo '<div class="challenge_message">' . "\n"; echo '<h5>Hälsning (skriv gärna hur långt du kom i spelet)</h5>' . "\n"; echo '<textarea name="game_challenge_mail_message" id="game_challenge_mail_message" ></textarea>' . "\n"; if (!isset($_SESSION['tip_security_code'])) { $_SESSION['tip_security_code'] = rand(10000, 9999999); } echo '<div class="input_a">' . "\n"; echo '<div class="security_code">' . "\n"; echo '<img src="/security_code.tip.png.php" id="regfrm_security_code_img" />' . "\n"; echo '</div>' . "\n"; //end security_code echo '<div class="input_b">' . "\n"; echo '<div class="security_input">' . "\n"; echo '<h5>Skriv av numret här ovanför</h5>' . "\n"; echo '<input type="text" name="security_code" id="security_code" />' . "\n"; echo '</div>' . "\n"; //end security_input echo '<div class="challenge_sender_name"><h5>Ditt namn</h5><input type="text" name="challenge_sender_name" id="challenge_sender_name" /></div>' . "\n"; echo '<button id="game_challenge_mail_submit">Skicka!</button>' . "\n"; echo '</div>' . "\n"; //end input_b echo '</div>' . "\n"; //end input_a echo '<p>' . "\n"; echo 'Vi vill inte få problem med datorprogram som skickar mail via Hamsterpaj, så därför' . "\n"; echo 'måster du du skriva av siffrorna i bilden, datorprogram är nämnligen inte så bra på att läsa bilder.' . "\n"; echo '</p>' . "\n"; echo '</div>' . "\n"; //end challenge_message; echo '<br />' . "\n"; echo '</div>' . "\n"; //end challenge_alternative echo '<hr />' . "\n"; //alternativ C - kopiera länk echo '<div class="challenge_alternative_c">' . "\n"; echo '<h3>Skicka en länk</h3>' . "\n"; echo '<p>Kopiera länken och skicka till din kompis</p>' . "\n"; echo '<div class="challenge_link">http://www.hamsterpaj.net/spel/' . $game['handle'] . '.html</div>' . "\n"; echo '</div>' . "\n"; //end challenge_alternative rounded_corners_bottom(); echo '</div>' . "\n"; //end game_challenge echo '<div id="game_challenge_result"></div>' . "\n"; //The game! echo '<div id="game" class="game">' . "\n"; //todo! Här skall anpassas till distribute-systemet. distribute_server_get skall anropas för att f? en adress // adress skall byggas med server . type . handle . '.' . extension echo '<object type="application/x-shockwave-flash" data="http://amuse.hamsterpaj.net/distribute/game/' . $game['handle'] . '.swf" > <param name="movie" value="http://amuse.hamsterpaj.net/distribute/game/' . $game['handle'] . '.swf" /></object>'; echo '</div>' . "\n"; //end game if (strlen($game['controls'][0]['combination']) > 0) { rounded_corners_top(); echo '<div class="game_instructions">' . "\n"; echo '<h3>Så här spelar du</h3>' . "\n"; games_game_controls_draw($game); echo '</div>' . "\n"; //end game_instructions rounded_corners_bottom(); } if (in_array('highscore', array_keys($game['tags']))) { rounded_corners_top(); echo '<h3>Topplista</h3>' . "\n"; $query = 'SELECT gh.score, gh.user AS user_id, l.username FROM game_highscores AS gh, login AS l WHERE gh.game = "' . $game['highscore_gname'] . '" AND l.id = gh.user ORDER BY gh.score DESC LIMIT 5'; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { while ($data = mysql_fetch_assoc($result)) { $topten[] = $data; } echo '<table style="float: left; width: 300px;">' . "\n"; $rank = 1; foreach ($topten as $entry) { $style = $entry['user_id'] == $_SESSION['login']['id'] ? ' style="font-weight: bold;"' : ''; echo '<tr' . $style . '>' . "\n"; echo '<td>' . $rank . '</td>' . "\n"; echo '<td><a href="/traffa/profile.php?id=' . $entry['user_id'] . '">' . $entry['username'] . '</a></td>' . "\n"; echo '<td>' . $entry['score'] . 'p</td>' . "\n"; echo '</tr>' . "\n"; $rank++; } echo '</table>' . "\n"; if (login_checklogin()) { $query = 'SELECT score FROM game_highscores WHERE user = "******" AND game = "' . $game['highscore_gname'] . '"'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if (mysql_num_rows($result) == 1) { $data = mysql_fetch_assoc($result); $user_score = $data['score']; /* Find out the users position */ $query = 'SELECT COUNT(*) AS position FROM game_highscores WHERE score > "' . $user_score . '" AND game = "' . $game['highscore_gname'] . '"'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); $data = mysql_fetch_assoc($result); $user_position = $data['position'] + 1; $i = 1; /* Fetch the two users with higher score */ $query = 'SELECT gh.score, gh.user AS user_id, l.username FROM game_highscores AS gh, login AS l WHERE gh.game = "' . $game['highscore_gname'] . '" AND l.id = gh.user AND gh.score > "' . $user_score . '" ORDER BY gh.score ASC LIMIT 2'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); while ($data = mysql_fetch_assoc($result)) { $data['position'] = $user_position - (mysql_num_rows($result) - $i); $score_table[] = $data; $i = 0; } $score_table = array_reverse($score_table); $score_table[] = array('user_id' => $_SESSION['login']['id'], 'username' => $_SESSION['login']['username'], 'position' => $user_position, 'score' => $user_score); $i = 1; /* Fetch the two users with lower score */ $query = 'SELECT gh.score, gh.user AS user_id, l.username FROM game_highscores AS gh, login AS l WHERE gh.game = "' . $game['highscore_gname'] . '" AND gh.user != "' . $_SESSION['login']['id'] . '" AND l.id = gh.user AND gh.score <= "' . $user_score . '" ORDER BY gh.score DESC LIMIT 2'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); while ($data = mysql_fetch_assoc($result)) { $data['position'] = $user_position + $i; $score_table[] = $data; $i++; } /* Phew, only the output left */ echo '<table style="width: 300px;">' . "\n"; foreach ($score_table as $entry) { $style = $entry['user_id'] == $_SESSION['login']['id'] ? ' style="font-weight: bold;"' : ''; echo '<tr' . $style . '>' . "\n"; echo '<td>' . $entry['position'] . '</td>' . "\n"; echo '<td><a href="/traffa/profile.php?id=' . $entry['user_id'] . '">' . $entry['username'] . '</a></td>' . "\n"; echo '<td>' . $entry['score'] . 'p</td>' . "\n"; echo '</tr>' . "\n"; } echo '</table>' . "\n"; } } } rounded_corners_bottom(); } rounded_corners_top(); // rounded_corners_top(array('color' => 'white')); /* echo '<div class="game_comments">' . "\n"; echo '<h3>Snacka om spelet</h3>' . "\n"; if(login_checklogin()) { echo '<textarea id="game_comment_textarea"></textarea>' . "\n"; echo '<button id="comment_submit_button">Skicka</button>' . "\n"; } else { echo '<p>Man kan bara skriva kommentarer om man är medlem. Men det blir du jättelätt, tryck bara på knappen och välj användarnamn och lösenord, inget mer!</p>'; echo '<button onclick="javascript: tiny_reg_form_show();" >Bli medlem!</button>' . "\n"; } $comments_fetch['type'] = 'game_comments'; $comments_fetch['handle'] = $game['handle']; $discussions = discussions_fetch($comments_fetch); if(count($discussions) > 0) { $discussion = $discussions[0]; } else { $create['handle'] = $game['handle']; $create['title'] = $game['title']; $create['author'] = 2348; $create['discussion_type'] = 'game_comments'; $discussion = discussion_create($create); $post_create['content'] = 'Skriv här vad du tycker om spelet!'; $post_create['discussion_id'] = $discussion['id']; $post_create['author'] = 2348; $post_id = posts_create($post_create); } $posts = posts_fetch(array('discussion_id' => $discussion['id'], 'limit' => '10', 'order' => array(array('field' => 'p.id', 'direction' => 'desc')))); echo '<div id="game_comments_list">' . "\n"; echo games_comments_list($posts); echo '</div>' . "\n"; echo '</div>' . "\n"; // rounded_corners_bottom(array('color' => 'white')); */ echo '<h2 class="rank_input_header">Din poäng</h2>' . "\n"; echo '<h2 class="comment_input_header">Din kommentar</h2>' . "\n"; echo '<br style="clear: both;" />' . "\n"; echo '<div class="game_comments">' . "\n"; $query = 'SELECT rank FROM user_ranks WHERE user_id = "' . $_SESSION['login']['id'] . '" AND item_id = "' . $game['id'] . '" AND item_type = "game"'; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $data = mysql_fetch_assoc($result); } unset($rank_options); $rank_options['previous'] = $data['rank']; rank_input_draw($game['id'], 'game', $rank_options); comments_input_draw($game['id'], 'game'); echo '<br style="clear: both;" />' . "\n"; echo '</div>' . "\n"; // game_comments rounded_corners_bottom(); rounded_corners_top(); echo comments_list($game['id'], 'game'); rounded_corners_bottom(); echo '</div>' . "\n"; //end game_play echo '<h1>Andra spel</h1>' . "\n"; }
// Lef-91 adds photos from the same date $photos = photos_fetch(array('date' => $data['date'], 'user' => $user_id)); if (isset($photos)) { $entry .= rounded_corners_top(); $entry .= '<h2 style="margin-top: 0;">Foton från samma datum</h2>' . "\n"; $entry .= photos_list_mini($photos); $entry .= '<div style="clear: both;"></div>' . "\n"; $entry .= rounded_corners_bottom(); } $entry .= '<p>' . nl2br($data['text']) . '</p>' . "\n"; if ($user_id == $_SESSION['login']['id'] || is_privilegied('remove_diary_post')) { $entry .= '<a href="?user_id=' . $user_id . '&action=remove&id=' . $data['id'] . '">Ta bort dagboksinlägget</a>' . "\n"; } // Comments $entry .= rounded_corners_top(array('color' => 'blue_deluxe')); $entry .= comments_input_draw($data['id'], 'blog'); $entry .= '<div style="clear: both;"></div>' . "\n"; $entry .= rounded_corners_bottom(array('color' => 'blue_deluxe')); $entry .= comments_list($data['id'], 'blog'); } $short_months = array(1 => 'Jan', 2 => 'Feb', 3 => 'Mar', 4 => 'Apr', 5 => 'Maj', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sept', 10 => 'Okt', 11 => 'Nov', 12 => 'Dec'); $query = 'SELECT id, date, title FROM blog WHERE user = "******" AND is_removed = 0 ORDER BY id DESC'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); while ($data = mysql_fetch_assoc($result)) { $entries[$data['date']] = $data; $month = $short_months[date('n', strtotime($data['date']))] . date(' -y', strtotime($data['date'])); if (!in_array($month, $months)) { $months[date('Y-m', strtotime($data['date']))] = $month; } } $output .= rounded_corners_top(array('color' => 'blue_deluxe'));
function render_full_article($article) { if (empty($article)) { $out .= rounded_corners_top(array('color' => 'red')); $out .= '<h1>Den här artikeln kunde tyvärr inte hittas</h1>' . "\n"; $out .= '<a href="?action=list"><< Gå till listan över artiklar</a>' . "\n"; $out .= rounded_corners_bottom(array('color' => 'red')); } else { $out .= render_article($article); if ($article['photo_category_id'] > 0) { $options['category'] = $article['photo_category_id']; $photos = photos_fetch($options); $out .= '<h2>Tillhörande bilder</h2>' . "\n"; $out .= photos_list($photos); } if ($article['showauthor'] == 1) { $out .= render_author($article['author']); } if (isset($article['forum_category_id']) && $article['forum_category_id'] != 0) { $all_categories_list = discussion_forum_categories_fetch(array('id' => $article['forum_category_id'])); $category = array_pop($all_categories_list); $forum_security = forum_security(array('action' => 'view_category', 'category' => $category)); if ($forum_security == true) { $path_to_category = discussion_forum_path_to_category(array('id' => $category['id'])); $locator_options['categories'] = $path_to_category; unset($options); $options['max_levels'] = 0; $options['parent'] = $category['id']; $categories = discussion_forum_categories_fetch($options); $out .= discussion_forum_categories_list($categories); $out .= '<h2>Trådar</h2>' . "\n"; $post_options['forum_id'] = $category['id']; $post_options['threads_only'] = true; $post_options['order_by_sticky'] = true; $post_options['page_offset'] = $request['page_offset']; $post_options['url_lookup'] = true; $threads = discussion_forum_post_fetch($post_options); //$threads['url'] = $path_to_trailing_category = array_pop($path_to_category) . '/' . $thread['handle'] . '/sida_1.php'; $out .= discussion_forum_thread_list($threads); $path_to_trailing_category = array_pop($path_to_category); $out .= '<a href="' . $path_to_trailing_category['url'] . '">Skapa en egen tråd länkad till artikeln</a>' . '<br style="clear: both;" />'; forum_update_category_session(array('category' => $category, 'threads' => $threads)); } } if ($article['commentable'] == 1) { $out .= rounded_corners_top(array('color' => 'blue_deluxe')); if ($article['rankable'] == 1) { $out .= rank_input_draw($article['id'], 'articles'); } $out .= comments_input_draw($article['id'], 'articles'); $out .= '<div style="clear: both;"></div>' . "\n"; $out .= rounded_corners_bottom(); $out .= comments_list($article['id'], 'articles'); } } if (is_privilegied('articles_admin')) { $out .= '<a href="/artiklar/index.php?action=admin&article=edit&id=' . $article['id'] . '">Ändra i artikeln</a>' . "\n"; } return $out; }
function photos_display($photos, $wait_for_image_to_load) { foreach ($photos as $photo) { $output .= '<div class="photo_full">' . "\n"; $output .= '<div class="passepartout">' . "\n"; $output .= '<p>' . $photo['date'] . ': <a href="/traffa/photos.php?ajax&user_id=' . $photo['user'] . '&image_id=' . $photo['id'] . '#photo" title="Länk till bilden">' . $photo['description'] . '</a>'; if ($_SESSION['login']['id'] == 774586) { $output .= ' <img src="http://images.hamsterpaj.net/abuse.png" alt="Din mamma ;)" onclick=" /><br style="clear:both;" />'; } $output .= '</p>' . "\n"; $output .= '<span class="loading" id="loading"></span>' . "\n"; $output .= '<img id="tha_image" src="' . IMAGE_URL . 'photos/full/' . floor($photo['id'] / 5000) . '/' . $photo['id'] . '.jpg" />'; $output .= '</div>' . "\n"; $output .= '</div>' . "\n"; $comment_list_options = array(); $comment_list_options['photo_owner'] = $photo['user']; if ($_SESSION['login']['id'] == $photo['user']) { //$comment_list_options['show_admin_controls'] = true; $categories = photos_get_categories(array('user' => $photo['user'])); $output .= rounded_corners_top(array('color' => 'blue_deluxe'), true); $output .= '<form class="photo_edit" method="post">' . "\n"; $output .= '<input type="hidden" name="action" value="update" />' . "\n"; $output .= '<input type="hidden" name="photo_id" value="' . $photo['id'] . '" />' . "\n"; $output .= '<input type="text" name="description" value="' . addslashes($photo['description']) . '" class="textbox" />' . "\n"; $output .= '<select name="category" class="photo_category_selector">' . "\n"; foreach ($categories as $category) { $selected = $photo['category'] == $category['id'] ? ' selected="selected"' : ''; $output .= '<option value="' . $category['name'] . '"' . $selected . '>' . $category['name'] . '</option>' . "\n"; } $output .= '<option value="new_category">Ny kategori</option>' . "\n"; $output .= '</select>' . "\n"; $output .= '<input type="submit" value="Uppdatera" class="button_80" />' . "\n"; $output .= '</form>' . "\n"; $output .= '<form class="photo_delete" method="post" action="/traffa/photos.php">' . "\n"; $output .= '<input type="hidden" name="action" value="delete" />' . "\n"; $output .= '<input type="hidden" name="photo_id" value="' . $photo['id'] . '" />' . "\n"; $output .= '<input type="submit" value="Radera" class="photo_delete" />' . "\n"; $output .= '</form>' . "\n"; $output .= rounded_corners_bottom(array('color' => 'blue_deluxe'), true); // KOMMENTERING FÖR ÄGAREN $output .= rounded_corners_top(array('color' => 'blue_deluxe'), true); $output .= 'Kommentera: '; $output .= comments_input_draw($photo['id'], 'photos'); $output .= rounded_corners_bottom(array('color' => 'blue_deluxe'), true); // BILDTÄVLINGEN //$output .= rounded_corners_top(array('color' => 'blue_deluxe'), true); //$output .= '<span style="">Rita av en Sysop i paint! kolla in tävlingen <a href="/tavling.php">HÄR</a></span><span style="float: right; margin-top: -14px;">Bild-id: '.$photo['id'].'</span>'; //$output .= rounded_corners_bottom(array('color' => 'blue_deluxe'), true); // END $query = 'UPDATE user_photos SET unread_comments = 0 WHERE id = "' . $photo['id'] . '" LIMIT 1'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); cache_update_photo_comments(); } else { if (is_privilegied('remove_photo')) { $output .= '<form class="photo_delete" method="post" action="/traffa/photos.php">' . "\n"; $output .= '<input type="hidden" name="action" value="delete" />' . "\n"; $output .= '<input type="hidden" name="photo_id" value="' . $photo['id'] . '" />' . "\n"; $output .= '<input type="submit" value="Ta bort bild" class="photos_remove" />' . "\n"; $output .= '</form>' . "\n"; /* $output .= ''; $output .= '<button class="button_90">Ta bort bild</button>' . "\n"; */ } $output .= rounded_corners_top(array('color' => 'blue_deluxe'), true); $output .= 'Kommentera: '; $output .= comments_input_draw($photo['id'], 'photos'); $output .= rounded_corners_bottom(array('color' => 'blue_deluxe'), true); } $output .= comments_list($photo['id'], 'photos', $comment_list_options); } return $output; }
require PATHS_INCLUDE . 'libraries/schedule.lib.php'; $ui_options['menu_path'] = array('chat', 'statistik'); $ui_options['title'] = 'Undersökningar på Hamsterpaj'; $ui_options['stylesheets'][] = 'comments.css'; $ui_options['javascripts'][] = 'comments.js'; $request = poll_get_action($_SERVER['REQUEST_URI']); switch ($request['action']) { case 'view_poll': $output .= poll_render($request['poll']); $output .= '<h2>Visa undersökningen i forumet</h2>' . "\n"; $output .= '<p>Använd detta ID-nummer om du vill infoga undersökningen i vårt forum: <strong>' . $request['poll']['id'] . '</strong></p>' . "\n"; $output .= '<h2>Lägg till på din blogg eller websida</h2>' . "\n"; $output .= '<p>Du kan lägga till denna omröstning på din blogg eller hemsida. Kopiera bara koden nedanför och klistra in den där du vill ha undersökningen. <strong>Denna kod fungerar inte i vårt forum!</strong></p>' . "\n"; $output .= '<input type="text" class="poll_embed_code" value=\'<script type="text/javascript" language="javascript" src="http://www.hamsterpaj.net/poll/embed.php?poll=' . $request['poll']['id'] . '"></script>\' />' . "\n"; $output .= '<h2>Kommentera omröstningen</h2>' . "\n"; $output .= comments_input_draw($request['poll']['id'], 'poll'); $output .= comments_list($request['poll']['id'], 'poll'); break; case 'index': $output .= '<h1>Här kan man göra sina enga undersökningar</h1>' . "\n"; if (login_checklogin()) { $output .= '<h2>Gör en ny undersökning</h2>'; $output .= poll_form(); $polls = poll_fetch(array('author' => $_SESSION['login']['id'], 'limit' => 100)); if (count($polls) > 0) { $output .= '<h1>Dina undersökningar</h1>' . "\n"; $output .= '<ul class="poll_list">' . "\n"; foreach ($polls as $poll) { $output .= '<li>' . date('Y-m-d', $poll['timestamp']) . ' <a href="/poll/' . $poll['handle'] . '.html">' . $poll['question'] . '</a></li>' . "\n"; } $output .= '</ul>' . "\n";