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 }
if (in_array($data['userid'], $alreadyshowed)) { continue; } array_push($alreadyshowed, $data['userid']); $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'; } 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']);
alert(\'Men fy på dig, du måste läsa reglerna igen ordentligt!\'); return false; } } </script> <input name="submit" type="submit" value="Ladda upp" onclick="return verify_checkboxes();" class="button_80" />'; if (isset($_GET['registerproccess'])) { $out .= '<input type="hidden" name="registerproccess" value="1" /> <br /><br /> <input type="button" class="button" value="Nej tack, jag vill inte ladda upp en bild »" onclick="location.href=\'/register.php?nextstep=3\'">'; } $out .= '</form>'; $avatar_full_filename = $avatar_path_full . $_SESSION['login']['id'] . '.jpg'; if (is_file($avatar_full_filename)) { $out .= '<h2 style="margin: 0px; ">Din nuvarande bild:</h2>'; $out .= insert_avatar($_SESSION['login']['id'], 'style="border: 1px solid #333333;"'); $out .= '<br /><b><a href="' . $_SERVER['PHP_SELF'] . '?action=delete">» Ta bort bilden</a></b>'; } } elseif ($_GET['step'] == '2') { if (!is_file($avatar_tmp_orginal_filename)) { jscript_alert('Någonting blev fel vid uppladdningen av bilden, försök igen!'); jscript_go_back(); die; } $copy_data = read_copy_protection($avatar_tmp_orginal_filename); if ($copy_data['copyright'] == 1 && $_SESSION['login']['id'] != $copy_data['userid']) { jscript_alert('Den gubben gick inte'); jscript_go_back(); die; } $avatar_height = intval(exec('identify ' . $avatar_tmp_orginal_filename . ' | cut -f3 -d" " | cut -f2 -d"x" | cut -f1 -d"+"'));
function list_entries($recipient, $entries, $offset = 0, $filter = 0) { global $hp_includepath; if ($offset < 1 || !is_numeric($offset)) { $offset = 0; } $list_sql = 'SELECT gb.id, gb.timestamp, gb.message, gb.sender, gb.read, gb.answered, gb.forum_post, login.username, info.image, '; $list_sql .= 'info.birthday, info.gender, is_private, zip_codes.* '; $list_sql .= 'FROM traffa_guestbooks AS gb, login, userinfo AS info, zip_codes '; if ($filter > 0) { $list_sql .= 'WHERE ('; $list_sql .= '(gb.recipient ="' . $recipient . '" AND gb.sender = "' . $filter . '") '; $list_sql .= 'OR (gb.recipient = "' . $filter . '" AND gb.sender = "' . $recipient . '") '; $list_sql .= ') AND login.id = gb.sender AND info.userid = gb.sender AND zip_codes.zip_code = info.zip_code '; } else { $list_sql .= 'WHERE gb.recipient = "' . $recipient . '" AND zip_codes.zip_code = info.zip_code '; } $list_sql .= 'AND login.id = gb.sender AND info.userid = gb.sender AND deleted = 0 '; if (isset($_SESSION['login']['id'])) { $list_sql .= 'AND (gb.is_private = 0 OR gb.sender = ' . $_SESSION['login']['id'] . ' OR gb.recipient = ' . $_SESSION['login']['id'] . ') '; } else { $list_sql .= 'AND gb.is_private = 0 '; } if ($filter > 0) { $list_sql .= 'ORDER BY gb.id DESC'; } else { $list_sql .= 'ORDER BY gb.id DESC LIMIT ' . $offset . ', ' . GUESTBOOK_MESSAGES_PER_PAGE; } $list_result = mysql_query($list_sql) or die(report_sql_error($list_sql)); if ($filter == 0) { echo '<p class="subtitle">Gästbok - ' . cute_number($entries) . ' inlägg</p>' . "\n"; } else { echo '<p class="subtitle">Gästbok - Visar historik</p>' . "\n"; } if ($offset > 0) { echo ' - sida ' . intval($offset / GUESTBOOK_MESSAGES_PER_PAGE + 1) . ' av ' . intval($entries / GUESTBOOK_MESSAGES_PER_PAGE + 1); } echo '</p>' . "\n"; $unread = array(); if (true) { while ($entry = mysql_fetch_assoc($list_result)) { if ($entry['read'] != 1) { rounded_corners_top(array('color' => 'orange_deluxe', 'id' => 'gb_entry_' . $entry['id'])); } else { rounded_corners_top(array('color' => 'blue_deluxe', 'id' => 'gb_entry_' . $entry['id'])); $button_color = 'blue_'; } echo '<div class="entry_picture">' . "\n"; if ($entry['image'] == 1 || $entry['image'] == 2) { echo ui_avatar($entry['sender']); } echo '</div>' . "\n"; echo '<div class="entry_main">' . "\n"; echo '<div class="entry_info">' . "\n"; echo '<span class="gb_private" id="gb_private_' . $entry['id'] . '_label">'; echo $entry['is_private'] == 1 ? 'Detta inlägg är privat' : ''; echo '</span>' . "\n"; echo '<span class="gb_unanswered" id="gb_unanswered_' . $entry['id'] . '_label">'; echo $entry['answered'] != 'Y' ? 'Obesvarat' : ''; echo '</span>' . "\n"; echo '<span class="timestamp">Skrevs ' . fix_time($entry['timestamp']) . '</span>'; echo '<a href="/traffa/profile.php?id=' . $entry['sender'] . '">' . $entry['username'] . '</a>' . "\n"; echo $entry['gender'] == 'm' ? ' Pojke' : ''; echo $entry['gender'] == 'f' ? ' Flicka' : ''; echo $entry['birthday'] != '0000-00-00' ? ' ' . date_get_age($entry['birthday']) . ' år' : ''; echo strlen($entry['spot']) > 0 ? ' från <a style="cursor: pointer;" onclick="window.open(\'http://www.hitta.se/LargeMap.aspx?ShowSatellite=false&pointX=' . $entry['y_rt90'] . '&pointY=' . $entry['x_rt90'] . '&cx=' . $entry['y_rt90'] . '&cy=' . $entry['x_rt90'] . '&z=6&name=' . $entry['username'] . '%20i%20' . urlencode($entry['spot']) . '\', \'user_map_3\', \'location=false, width=750, height=500\');">' . $entry['spot'] . '</a>' : ''; echo '</div>' . "\n"; echo '<p>' . "\n"; echo setsmilies(nl2br($entry['message'])); // preint_r($entry); echo '</p>' . "\n"; echo '</div>' . "\n"; echo '<div class="entry_controls">' . "\n"; echo $recipient == $_SESSION['login']['id'] && $entry['sender'] != $_SESSION['login']['id'] ? '<a href="/hamsterpaj/abuse.php?report_type=guestbook_entry&reference_id=' . $entry['id'] . '" class="abuse_button"><img src="http://images.hamsterpaj.net/abuse.png" /></a> ' . "\n" : ''; echo $recipient == $_SESSION['login']['id'] && $entry['sender'] != $_SESSION['login']['id'] ? '<button class="' . $button_color . 'button_70" onclick="gb_block_user(\'' . $entry['username'] . '\');">Blockera</button> ' . "\n" : ''; echo $recipient == $_SESSION['login']['id'] || $entry['sender'] == $_SESSION['login']['id'] ? '<button id="gb_private_' . $entry['id'] . '" class="' . $button_color . 'button_80" onclick="gb_private(' . $entry['id'] . ');"' . ($entry['is_private'] == 1 ? ' style="display: none;"' : '') . '>Privatisera</button> ' . "\n" : ''; echo $recipient == $_SESSION['login']['id'] && $entry['sender'] != $_SESSION['login']['id'] ? '<button id="gb_unprivate_' . $entry['id'] . '" class="' . $button_color . 'button_90" onclick="gb_unprivate(' . $entry['id'] . ');"' . ($entry['is_private'] == 1 ? '' : ' style="display: none;"') . '>Avprivatisera</button> ' . "\n" : ''; echo '<button class="' . $button_color . 'button_70" onclick="gb_history(' . $recipient . ', ' . $entry['sender'] . ');">Historik</button> ' . "\n"; echo '<button class="' . $button_color . 'button_60" onclick="gb_goto(' . $entry['sender'] . ');">Gå till</button> ' . "\n"; echo $recipient == $_SESSION['login']['id'] && $entry['sender'] != $_SESSION['login']['id'] ? '<button class="' . $button_color . 'button_60" onclick="gb_remove(' . $entry['id'] . ', \'' . $entry['username'] . '\', \'' . fix_time($entry['timestamp']) . '\');">Ta bort</button> ' . "\n" : ''; echo $recipient == $_SESSION['login']['id'] && $entry['sender'] != $_SESSION['login']['id'] ? '<button class="' . $button_color . 'button_50" onclick="gb_answer(\'' . $entry['username'] . '\', ' . $entry['sender'] . ', ' . $entry['id'] . ');">Svara</button> ' . "\n" : ''; echo '</div>' . "\n"; if ($entry['read'] != 1) { rounded_corners_bottom(array('color' => 'orange_deluxe')); } else { rounded_corners_bottom(array('color' => 'blue_deluxe')); } if ($entry['read'] == 0) { array_push($unread, $entry['id']); } } } else { while ($list_data = mysql_fetch_assoc($list_result)) { if ($list_data['read'] == 1) { echo '<div style="background: #f7f7f7">' . "\n"; } else { echo '<div style="background: #ffc777">' . "\n"; } echo '<table class="body"><tr><td style="width: 80px; vertical-align: top;">' . "\n"; if ($list_data['image'] == 1 || $list_data['image'] == 2) { echo insert_avatar($list_data['sender']); } echo '</td>' . "\n" . '<td style="vertical-align: top; width: 650px;">' . "\n"; if ($list_data['is_private'] == 1) { echo '<b>Detta inlägg är privat</b>' . "\n"; } if ($list_data['forum_post'] > 0) { echo '<div class="orange_faded_div" style="width: auto;">Detta är en kommentar på ett forumsinlägg. <a href="javascript: void(0);" onclick="window.open(\'/forum_new/read_post_popup.php?id=' . $list_data['forum_post'] . '\', Math.random(), \'width=600, height=450, scrollbars=yes\');">Läs inlägget i en popup</a> eller <a href="/forum_new/index.php?action=redirect_to_post&post_id=' . $list_data['forum_post'] . '">gå till tråden i forumet</a>.</div>'; } if ($_SESSION['login']['id'] == $recipient) { $reply_status = $list_data['answered'] == 'Y' ? null : ' Obesvarat'; } echo '<p style="color: grey;">'; echo $list_data['read'] == 0 ? '<strong>' : null; echo '(skrevs ' . fix_time($list_data['timestamp']) . $reply_status . ')'; echo $list_data['read'] == 0 ? '</strong>' : null; echo '<br />' . "\n"; echo '<a href="/traffa/profile.php?id=' . $list_data['sender'] . '"><b>' . $list_data['username'] . '</b></a> '; if ($list_data['gender'] == 'm') { echo 'Kille '; } elseif ($list_data['gender'] == 'f') { echo 'Tjej '; } $userage = date_get_age($list_data['birthday']); if ($userage > 0) { echo $userage . ' år '; } if (strlen($list_data['spot']) > 0) { echo 'från ' . $list_data['spot'] . ' '; } echo '</p>' . "\n"; echo '<p>'; echo setSmilies(nl2br($list_data['message'])); echo '</p>' . "\n"; echo '<p style="text-align: right;">' . "\n"; echo '<form action="/traffa/userblocks.php" method="post" style="display: inline; float: right;">' . "\n"; if ($_SESSION['login']['id'] == $recipient && $filter == 0) { echo '<input type="submit" value="Blockera" class="button_70" style="display: inline;" onclick="return confirm(\'Du är på väg att blockera avsändaren från att skicka fler gästboksinlägg och meddelanden till dig\');" />' . "\n"; } if ($filter == 0) { echo '<input type="button" onClick="window.location=\'' . $_SERVER['PHP_SELF'] . '?action=history&view=' . $recipient . '&remote=' . $list_data['sender'] . '\';" class="button_70" value="Historik" /> ' . "\n"; } echo '<input type="button" onclick="window.location=\'' . $_SERVER['PHP_SELF'] . '?view=' . $list_data['sender'] . '\';" class="button_60" value="Gå till" /> ' . "\n"; if ($_SESSION['login']['id'] == $recipient) { echo '<input type="button" onclick="window.open(\'/traffa/gb-reply.php?action=reply&username='******'username'] . '&userid=' . $list_data['sender'] . '&answereid=' . $list_data['id']; echo '\',\'\' ,\'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width=250, height=200\');" value="Svara" class="button_50" /> ' . "\n"; if ($filter == 0) { echo '<input type="button" onclick="var name=confirm(\'Vill du verkligen ta bort inlägget?\'); if(name==true){ window.location=\'' . $_SERVER['PHP_SELF'] . '?action=delete&entry_id=' . $list_data['id'] . '&return_offset=' . $_GET['offset'] . '\'; }" value="Ta bort" class="button_70" />' . "\n"; echo '<input type="hidden" name="addblock" value="' . $list_data['username'] . '" />' . "\n"; } } echo '</form>' . "\n"; if ($_SESSION['login']['id'] == $recipient && $filter == 0) { echo '<button class="button_80" style="display: inline;" onclick="idiot_report(\'' . $list_data['sender'] . '\');" />Rapportera</button>' . "\n"; } echo '</p>' . "\n"; echo '</td></tr>' . "\n" . '</table>' . "\n"; echo '</div>' . "\n"; echo '<br />' . "\n"; if ($list_data['read'] == 0) { array_push($unread, $list_data['id']); } } } if ($offset > 0) { echo '<input type="button" onclick="window.location=\'' . $_SERVER['PHP_SELF'] . '?offset=' . intval($offset - GUESTBOOK_MESSAGES_PER_PAGE) . '&view=' . $recipient . '\';" value="<<Föregående sida" class="button" style="float: left;" />'; } if ($offset + GUESTBOOK_MESSAGES_PER_PAGE < $entries && $entries > GUESTBOOK_MESSAGES_PER_PAGE) { echo '<input type="button" onclick="window.location=\'' . $_SERVER['PHP_SELF'] . '?offset=' . intval($offset + GUESTBOOK_MESSAGES_PER_PAGE) . '&view=' . $recipient . '\';" value="Nästa sida>>" class="button" style="float: right;" />'; } echo '<div style="text-align: center; margin-bottom: 15px;">'; for ($pages = 1; $pages < intval($entries / GUESTBOOK_MESSAGES_PER_PAGE + 1) && $pages < 32; $pages++) { echo '<a href="' . $_SERVER['PHP_SELF'] . '?view=' . $recipient . '&offset=' . ($pages - 1) * GUESTBOOK_MESSAGES_PER_PAGE . '">' . $pages . '</a> '; } echo '</div>'; if ($recipient == $_SESSION['login']['id'] && $filter == 0) { $read_sql = 'UPDATE traffa_guestbooks SET `read` = 1 WHERE id = 1 '; //Bara för att göra foreach-loopen smidigare :P foreach ($unread as $current) { $read_sql .= 'OR id = ' . $current . ' '; } mysql_query($read_sql) or die(report_sql_error($read_sql, __FILE__, __LINE__)); } }
echo '<p class="error">Denna användare existerar inte!</p>'; ui_bottom(); exit; } /* Fix municipal/city info */ if (strlen($userdata['userinfo']['geo_location']) > 0 && $userdata['userinfo']['geo_location'] != $userdata['userinfo']['geo_municipal']) { $userdata['userinfo']['geo_municipal'] = $userdata['userinfo']['geo_municipal'] . ' (' . $userdata['userinfo']['geo_location'] . ')'; } if ($userdata['login']['lastusernamechange'] > time() - 604800) { echo '<div class="pink_faded_div" style="font-weight: bold;">Denna användare hette tidigare ' . $userdata['login']['lastusername'] . '</div>'; } traffaDrawUserDiv($userid, $userdata['login']['username'], $userdata['userinfo']['gender'], $userdata['userinfo']['birthday'], $userdata['login']['lastaction'], $userdata['userinfo']['geo_municipal'], $userdata['login']['lastip']); echo '<div class="contentPostbox" style="background-image: url(\'/images/traffatablebg.png\'); height: 110px;">'; if ($userdata['userinfo']['image'] == 1 || $userdata['userinfo']['image'] == 2) { echo '<div style="float: left; height: 100px; margin: 2px; width: 93px;">'; echo insert_avatar($userid); echo '</div>'; } else { echo '<div style="float: left; height: 100px; width: 75px; margin: 2px; background: #000; color: #FFF;">Ingen bild</div>'; } $contactlabel1 = 'Kontaktsätt'; $contactalias1 = '-'; $contactlabel2 = 'Kontaktsätt'; $contactalias2 = '-'; if (strlen($userdata['userinfo']['contact1']) > 0) { $usercontact1 = parseContact($userdata['userinfo']['contact1']); if ($usercontact1['label'] != NULL) { $contactlabel1 = $usercontact1['label']; $contactalias1 = $usercontact1['link']; } }
} else { $out .= '<div id="radio_sending_inactive">' . "\n"; // Displays "Ingen sändning $out .= '</div>' . "\n"; } } $options['broadcasting'] = false; // It shouldn't be broadcasting right now $options['limit'] = 1; // We only want the coming one $options['order-direcion'] = 'DESC'; // We want the coming one $radio_next_program = radio_schedule_fetch($options); if (isset($radio_next_program[0])) { $out .= '<div id="radio_next_program">' . "\n"; $out .= insert_avatar($radio_next_program[0]['user_id']) . "\n"; $out .= '<div class="radio_about">' . "\n"; $out .= '<h2>' . $radio_next_program[0]['name'] . '</h2>' . "\n"; $out .= '<strong>DJ: ' . $radio_next_program[0]['username'] . '</strong><br />' . "\n"; $out .= '<span>' . $radio_next_program[0]['sendtime'] . '</span>' . "\n"; $out .= '</div>' . "\n"; $out .= '</div>' . "\n"; } else { $out .= '<div id="radio_next_program_inactive">' . "\n"; // Displays a "Inget inplanerat" box $out .= '</div>' . "\n"; } if ($radioinfo['status'] == 1) { $out .= '<ul id="choose_player"> <li> <a id="choose_player_01" href="/radio/lyssna/pls" title="Den här länken fungerar i de flesta spelare. Exempelvis: iTunes, Real player, Winamp, VLC, foobar.">Spela upp radio i normala spelare</a>
traffa_draw_user_div($_SESSION['login']['id'], $_SESSION); $query = 'SELECT uel.remote_user_id AS user_id, uel.timestamp, l.lastaction, l.username, l.lastlogon, u.image, u.birthday, u.gender, z.spot '; $query .= 'FROM user_event_log AS uel, login AS l, userinfo AS u, zip_codes AS z '; $query .= 'WHERE uel.user = "******" AND l.id = uel.remote_user_id AND u.userid = uel.remote_user_id '; $query .= 'AND uel.action = "profile_visit" AND z.zip_code = u.zip_code '; $query .= 'ORDER BY uel.timestamp DESC LIMIT 80'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); while ($data = mysql_fetch_assoc($result)) { /* Only display each user one time, should be done with DISTINCT in query, but I can't ger it to work */ if (in_array($data['user_id'], $duplicates)) { continue; } $duplicates[] = $data['user_id']; $entry = '<div class="visitor">' . "\n"; if (in_array($data['image'], array(1, 2))) { $entry .= insert_avatar($data['user_id']); } $entry .= fix_time($data['timestamp']); $entry .= '<div>' . "\n"; $entry .= '<h3><a href="/traffa/profile.php?id=' . $data['user_id'] . '">' . $data['username'] . '</a></h3>' . "\n"; $entry .= '<h4>'; $entry .= $data['birthday'] != '0000-00-00' ? date_get_age($data['birthday']) . 'år ' : ''; $entry .= strlen($data['spot']) > 0 ? 'från ' . $data['spot'] : ''; $entry .= '</h4>' . "\n"; $entry .= $data['lastaction'] > time() - 600 ? 'Online nu!' : 'Loggade senast in ' . date('Y-m-d', $data['lastlogon']) . "\n"; $entry .= '</div>'; $entry .= '</div>' . "\n"; switch ($data['gender']) { case 'm': $output_boys .= $entry; break;
function tests_get_last_test_completers($options) { if (!isset($options['test_id'], $options['limit'])) { return 'tests_get_last_test_completers - Not enough parameters...'; } if (!is_numeric($options['test_id']) || !is_numeric($options['limit'])) { return 'Wrong parameter format for tests_get_last_test_completers.'; } $query = 'SELECT tus.score AS score, l.id AS userid, l.username AS username, u.image AS image'; $query .= ' FROM tests_user_score AS tus, login AS l, userinfo AS u'; $query .= ' WHERE tus.test_id = ' . $options['test_id'] . ' AND tus.user_id = l.id AND u.userid = l.id'; $query .= ' ORDER BY tus.timestamp DESC'; $query .= ' LIMIT ' . $options['limit']; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); $return = mysql_num_rows($result) > 0 ? '' : 'Ingen inloggad användare har gjort testet ännu!'; while ($data = mysql_fetch_assoc($result)) { $return .= '<div class="tests_completer">'; $return .= '<h3>' . $data['score'] . ' poäng</h3>' . "\n"; $return .= '<a href="/traffa/profile.php?id=' . $data['userid'] . '">' . ucfirst($data['username']) . '</a><br />' . "\n"; $return .= (in_array((int) $data['image'], array(1, 2)) ? insert_avatar($data['userid']) : '<img src="' . IMAGE_URL . '/images/noimage.png" style="border: 1px solid #cccccc;" alt="Ingen visningsbild" />') . '<br />' . "\n"; $return .= '</div>'; } return $return; }
$allowedExts = array("gif", "jpeg", "jpg", "png", "bmp"); $extension = end(explode(".", $_FILES["file"]["name"])); if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/png" || $_FILES["file"]["type"] == "image/bmp") && $_FILES["file"]["size"] < 65536 && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . $_FILES["file"]["size"] / 1024 . " kB<br>"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>"; if (file_exists("/tmp/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { // move_uploaded_file($_FILES["file"]["tmp_name"],"/tmp/" . $_FILES["file"]["name"]); // echo "Stored in: " . "/tmp/" . $_FILES["file"]["name"]; $results = insert_avatar($_FILES["file"]["tmp_name"], $_SESSION['username']); echo $results . "<br>"; } } } else { echo "Invalid file, please check file and retry.<br>"; echo "Possible problems could be file type or size.<br>"; } ?> </td> </tr> </table> </body> </html>
$usersname = $_SESSION['name']; } ?> <tr> <td colspan="2" align="center"> <?php $uploaddir = '/tmp/'; $maxsize = 64000; if ($_FILES['userfile']['size'] >= $maxsize) { echo "File to large, File must be less than 64k"; exit; } $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); echo "<p>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded.\n"; $imagename = $uploadfile; $results = insert_avatar($imagename, $usersname); include update_avatar . php; } else { echo "Upload failed.\n The file is either not of a supported file type (jpg) or is too large (64KB max)."; } ?> </td> </tr> <td align="center"><a href="logout.php">Logout</a></td> </tr> </table> </body> </html>