function entertain_get_handle($title) { $handle_original = url_secure_string($title); for ($i = 0; $i < 50; $i++) { $handle = $i == 0 ? $handle_original : $handle_original . '_' . $i; $fetch_result = entertain_fetch(array('handle' => $handle)); $items = $fetch_result['items']; if (count($items) == 0) { return $handle; } } die('<h1>Fatal error, som man säger. Kunde inte hitta något ledigt handle!</h5>'); }
function groups_create($options) { $options['founder'] = !isset($options['founder']) ? $_SESSION['login']['id'] : $options['founder']; $options['handle'] = !isset($options['handle']) ? url_secure_string($options['name']) : $options['handle']; $query = 'INSERT INTO groups(handle, name, description, member_count, created_timestamp, founder, forum_id, auto_join, visible)' . "\n"; $query .= 'VALUES("' . $options['handle'] . '", "' . $options['name'] . '", "' . $options['description'] . '", 0, ' . time() . ', "' . $options['founder'] . '", 0, "' . $options['auto_join'] . '", "' . $options['visible'] . '")'; mysql_query($query) or report_sql_error($query); $options['id'] = mysql_insert_id(); if ($options['disable_founder_join'] != true) { groups_add_user_to_group(array('group_id' => $options['id'], 'user_id' => $options['founder'])); } return $options; }
function knowledge_database_get_handle($options) { switch ($options['action']) { case 'new': $secured_string = url_secure_string($title); $handle = $secured_string; $query = 'SELECT id FROM knowledge_database WHERE handle LIKE "' . $handle . '" LIMIT 1'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); for ($i = 2; mysql_num_rows($result) > 0; $i++) { $handle = $secured_string . '_' . $i; $query = 'SELECT id FROM knowledge_database WHERE handle LIKE "' . $handle . '" LIMIT 1'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } return $handle; break; case 'fetch': return 'Not completed yet...'; break; } }
function discussions_create_handle($title) { $handle = url_secure_string($title); for ($i = 0; $i < 50; $i++) { $new_handle = $i == 0 ? $handle : $handle . '_' . $i; $query = 'SELECT id FROM discussions WHERE handle LIKE "' . $new_handle . '" LIMIT 1'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if (mysql_num_rows($result) == 0) { return $new_handle; } } /* If no free handle could be found */ log_to_file('forum', LOGLEVEL_ERROR, __FILE__, __LINE__, 'Could not find any free discussion handles, giving up', serialize(array($title))); return md5(rand(0, 99999999999)); }
echo '<h5>Bild</h5>' . "\n"; echo '<input type="file" name="image" />' . "\n"; echo '<h5>Webbsajt</h5>' . "\n"; echo '<input type="text" name="website" class="textbox" />' . "\n"; echo '<h5>Direktlänk</h5>' . "\n"; echo '<input type="text" name="direct_link" class="textbox" />' . "\n"; echo '<h5>Licens</h5>' . "\n"; echo '<select name="license">' . "\n"; echo '<option value="shareware">Shareware</option>' . "\n"; echo '<option value="open_source">Open Source</option>' . "\n"; echo '<option value="trial">Testversion</option>' . "\n"; echo '</select>' . "\n"; echo '<input type="submit" value="spara" class="button_50" />' . "\n"; echo '</form>' . "\n"; if (isset($_POST['title'])) { $handle = url_secure_string($_POST['title']); /* Scale and move the image */ system('convert ' . $_FILES['image']['tmp_name'] . ' -resize 120!x90! ' . IMAGE_PATH . 'downloads/icons/' . $handle . '.png'); /* Database */ $query = 'INSERT INTO downloads(handle, title, category, description, website, direct_link, license)'; $query .= ' VALUES("' . $handle . '", "' . $_POST['title'] . '" , "' . $_POST['category'] . '", "' . $_POST['description'] . '", "' . $_POST['website'] . '", "' . $_POST['direct_link'] . '", "' . $_POST['license'] . '")'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); $query = 'INSERT INTO recent_updates(type, label, timestamp, url) VALUES("new_software", "' . $_POST['title'] . '", "' . time() . '", "/mattan/ladda_ner_program.php#' . $handle . '")'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } } echo '</div>' . "\n"; ui_bottom(); ?>
function discussion_forum_parse_request($url) { $url = strtolower($url); $url_query_parts = explode('?', $url); $url_anchor_parts = explode('#', $url_query_parts[0]); $url = $url_anchor_parts[0]; if (substr($url, -1) == '/') { $url = substr($url, 0, -1); } if ($url == '/diskussionsforum') { $request['action'] = 'index'; } elseif ($url == '/diskussionsforum/flytta_traad.php' && is_numeric($_POST['new_category'])) { $request['action'] = 'move_thread'; $request['thread'] = array_pop(discussion_forum_post_fetch(array('post_id' => $_POST['thread_id']))); $request['new_category'] = array_pop(discussion_forum_categories_fetch(array('id' => $_POST['new_category']))); } elseif ($url == '/diskussionsforum/nytt_inlaegg.php') { $request['action'] = 'new_post'; } elseif ($url == '/diskussionsforum/soek.php') { $request['action'] = 'search'; $request['freetext'] = substr($url_query_parts[1], 9); } elseif ($url == '/diskussionsforum/nya_traadar.php') { $request['action'] = 'latest_threads'; } elseif ($url == '/diskussionsforum/dina_traadar.php') { $request['action'] = 'threads_by_user'; $request['user_id'] = $_SESSION['login']['id']; } elseif ($url == '/diskussionsforum/notiser.php') { $request['action'] = 'view_notices'; } elseif ($url == '/diskussionsforum/notiser.new.php') { $request['action'] = 'view_new_notices'; } elseif (substr($url, -4) == '.php' && substr($url, strrpos($url, '/'), 11) != '/traadsida_') { // Note: This does NOT have to be a thread, it could also be a help-page such as regler.php // AND, the url might be fomatted like this: /discussionsforum/traad_handtag/sida_1.php $explosion = explode('/', $url); $page_count_start = strrpos($url, '/sida_') + 6; $page_count_end = strrpos($url, '.'); $page_count_length = $page_count_end - $page_count_start; $request['page_num'] = substr($url, $page_count_start, $page_count_length); $request['action'] = 'view_thread'; $request['thread_handle'] = $explosion[count($explosion) - 2]; /*//trace('datamirk', print_r($explosion, true)); $request['category'] = array_pop(discussion_forum_categories_fetch(array('handle' => $explosion[count($explosion)-3]))); if(!in_array($explosion[count($explosion)-3], array('hamsterpaj', 'nyheter', 'buggar_och_fel', 'spel_och_film', 'mellan_himmel_och_jord', 'mat', 'klaeder_och_utseende', 'djur_och_husdjur', 'historier_och_skaemt', 'mobiltelefoner', 'tonaaring', 'relationer', 'kropp_och_pubertet', 'sex', 'familjen', 'vaenner', 'skola', 'pengar', 'fritid', 'sport', 'traening', 'foereningsliv', 'motor', 'musik', 'film_och_tv', 'foto', 'litteratur', 'spel', 'datorspel', 'counter_strike', 'world_of_warcraft', 'xbox', 'playstation', 'nintendo', 'retrokonsoller', 'lajv_och_rollspel', 'datorer', 'support_och_hjaelp', 'haardvara', 'mjukvara', 'operativsystem', 'lan_och_naetverk', 'programmering', 'php_scripting', 'webbdesign', 'min_hemsida', 'vetenskap', 'fysik', 'kemi', 'biologi', 'matematik', 'teknik', 'elektronik', 'astronomi', 'psykologi', 'debatt', 'politik', 'religion', 'jaemstaelldhet', 'miljoe', 'filosofi', 'alkohol_tobak_droger', 'historia', 'oevrigt', 'koep_och_saelj', 'efterlysningar', 'forumlekar', 'listor_omroestningar', 'skraep_och_spam', 'teknik', 'kaerlek', 'open_source', 'presentationsteman', 'forum_error', 'ordningsvaktsforum'))) { if($explosion[count($explosion)-3] != 'diskussionsforum') { trace('extreme_datamirk', $_SESSION['login']['username'] . ':' . $explosion[count($explosion)-3] . ' = ' . print_r($explosion, true)); } }*/ } else { $request['action'] = 'view_category'; $explosion = explode('/', $url); $last_piece = $explosion[count($explosion) - 1]; if (substr($last_piece, 0, 10) == 'traadsida_' && substr($last_piece, -4) == '.php' && is_numeric(substr($last_piece, 10, -4)) && intval(substr($last_piece, 10, -4)) > 0) { $request['page_offset'] = intval(substr(array_pop($explosion), 10, -4)) - 1; } else { $request['page_offset'] = 0; } $handle = array_pop($explosion); if ($handle == url_secure_string($handle)) { $viewers_userlevel = login_checklogin() ? $_SESSION['login']['userlevel'] : 0; $request['category'] = array_pop(discussion_forum_categories_fetch(array('handle' => $handle, 'viewers_userlevel' => $viewers_userlevel, 'disable_query_caching' => true))); $request['category_handle'] = $handle; if (count($request['category']) < 1) { $request['action'] = 'forum_not_found'; } } else { $request['action'] = 'forum_not_found'; } } return $request; }
function sex_sense_update_handle($options) { for ($i = 0; $i > 150 || !($result = @mysql_query('UPDATE sex_questions SET handle = "' . url_secure_string($options['title_to_serialize']) . ($i != 0 ? '_' . $i : '') . '" WHERE id = ' . $options['id'])); $i++) { } }
function poll_create($poll) { $handle = url_secure_string($poll['question']); if (empty($handle)) { $handle = md5(time() . rand(0, 9999)); } for ($i = 1; $i < 100; $i++) { $query = 'SELECT id FROM poll WHERE handle LIKE "' . $handle . '" LIMIT 1'; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { break; } $handle = url_secure_string($poll['question']) . '_' . $i; } $query = 'INSERT INTO poll (handle, question, description, author, type, force_logon, timestamp, alt_1, alt_2, alt_3, alt_4, alt_5, alt_6, alt_7)'; $query .= ' VALUES("' . $handle . '", "' . $poll['question'] . '", "' . $poll['description'] . '", "' . ($poll['type'] == 'daily' ? 2348 : $_SESSION['login']['id']) . '", "' . $poll['type'] . '", "' . $poll['force_logon'] . '", "' . time() . '"'; for ($i = 1; $i <= 7; $i++) { $query .= ', "' . $poll['alt_' . $i] . '"'; } $query .= ')'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); return $handle; }
$result = mysql_query($sql); while ($data = mysql_fetch_assoc($result)) { $questions[] = $data; } $options['show_answer_textarea'] = true; $options['rounded_corners'] = true; $output .= render_sex_sense_question($questions, $options); break; case 'compose': $output .= sex_sense_form(); break; case 'edit': break; case 'create': if (login_checklogin()) { $secue_url = url_secure_string($_POST['title']); $sql = 'SELECT handle FROM sex_questions WHERE handle = "' . $_POST['title'] . '" LIMIT 1'; $result = mysql_query($sql); $data = mysql_fetch_assoc($result); if (strlen($data['handle']) > 0) { $handle_exists_already = true; } } break; case 'update': break; case 'index': default: $ui_options['menu_path'] = array('sex_sense'); $output .= '<img src="http://images.hamsterpaj.net/sexosinne.png" />' . "\n"; $void['color'] = 'orange_deluxe';
/** * Saves a film from POST form to database * options new a new film update update an existing film * @return handle, the films handle */ function films_film_save($options) { if ($_POST['film_type'] == 'bilder') { unset($_SESSION['new_film_temp']); } global $film_categories; // Make handle from title $handle = isset($_POST['handle']) ? $_POST['handle'] : url_secure_string($_POST['title']); $release = isset($_POST['release_now']) ? time() : strtotime($_POST['release']); $film_type = $_POST['film_type']; if (isset($options['new'])) { $query = 'INSERT INTO film (handle, title, film_type, category_id, `release`, extension, use_special_code, html, trailer_id)'; $query .= ' VALUES ("' . $handle . '", "' . $_POST['title'] . '", "' . $film_type . '", "' . $_POST['film_category'] . '", "' . $release . '", "' . (isset($_SESSION['new_film_temp']['extension']) ? $_SESSION['new_film_temp']['extension'] : '') . '", "' . (isset($_POST['use_special_code']) ? '1' : '0') . '", "' . addslashes(html_entity_decode($_POST['special_code'])) . '", "' . $_POST['trailer_id'] . '")'; $schedule['type'] = 'new_' . $film_type; $_POST['url'] = '/' . $film_type . '/' . $film_categories[$_POST['film_category']]['handle'] . '/' . $handle . '.html'; $schedule['data'] = serialize($_POST); $schedule['release'] = $release; schedule_event_add($schedule); } elseif (isset($options['update'])) { $query = 'UPDATE film SET title = "' . $_POST['title'] . '"'; $query .= ', film_type = "' . $film_type . '"'; $query .= ', `release` = "' . $release . '"'; $query .= ', trailer_id = "' . $_POST['trailer_id'] . '"'; $query .= ', category_id = "' . $_POST['film_category'] . '"'; $query .= isset($_SESSION['new_film_temp']['extension']) ? ', extension = "' . $_SESSION['new_film_temp']['extension'] . '"' : ''; $query .= ', use_special_code = "' . (isset($_POST['use_special_code']) ? '1' : '0') . '"'; $query .= isset($_POST['use_special_code']) ? ', html="' . addslashes(html_entity_decode($_POST['special_code'])) . '"' : ''; $query .= ' WHERE handle = "' . $handle . '"'; } // echo '<p>' . $query . '</p>'; log_to_file('films', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'query: ' . $query); mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); $query = 'SELECT id, handle FROM film WHERE handle = "' . $handle . '"'; $result = mysql_query($query) or die(report_sql_error($query)); if ($data = mysql_fetch_assoc($result)) { $film_id = $data['id']; $film_handle = $data['handle']; } unset($save); $save['item_id'] = $game_id; $save['object_type'] = 'film'; $save['add'] = true; foreach (explode(',', $_POST['tags']) as $keyword) { $keyword = trim($keyword); $save['tag_label'][] = $keyword; } tag_set_wrap($save); /* Resize, convert and save the uploaded thumbnail */ if (strlen($_FILES['thumbnail']['tmp_name']) > 1) { system('convert ' . $_FILES['thumbnail']['tmp_name'] . ' -resize 120!x90! ' . IMAGE_PATH . 'film/' . $film_handle . '.png'); } if ($film_type == 'bilder') { system('convert ' . $_FILES['thumbnail']['tmp_name'] . ' -resize 460x345 ' . IMAGE_PATH . 'fun_images/' . $film_handle . '.jpg'); } // echo '<p>Nu är filmen sparad och filmens handle är: ' . $film_handle . '</p>' . "\n"; // echo '<p>Direktlänken blir då <a href="http://www.hamsterpaj.net/' . $film_type . '/' . $film_categories[$_POST['film_category']]['handle'] . '/' . $film_handle . '.html">' . // 'http://www.hamsterpaj.net/' . $film_type . '/' . $film_categories[$_POST['film_category']]['handle'] . '/' . $film_handle . '.html</a' . "\n"; $film['handle'] = $handle; $film['extension'] = $_SESSION['new_film_temp']['extension']; $film['url'] = 'http://www.hamsterpaj.net/' . $film_type . '/' . $film_categories[$_POST['film_category']]['handle'] . '/' . $film_handle . '.html'; return $film; }
function tests_generate_test_handler($title) { // In case of escaped HTML and so on... if (strlen($title) > 50) { $title = substr($title, 0, 50); } $secured_string = url_secure_string($title); $handle = $secured_string; $query = 'SELECT id FROM tests WHERE handle LIKE "' . $handle . '" LIMIT 1'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); for ($i = 2; mysql_num_rows($result) > 0; $i++) { $handle = $secured_string . '_' . $i; $query = 'SELECT id FROM tests WHERE handle LIKE "' . $handle . '" LIMIT 1'; $result = mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); } return $handle; }
function poll_create($poll) { $handle = url_secure_string($poll['question']); for ($i = 1; $i < 100; $i++) { $query = 'SELECT id FROM poll WHERE handle LIKE "' . $handle . '" LIMIT 1'; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { break; } $handle = url_secure_string($poll['question']) . '_' . $i; } if (!is_privilegied('frontpage_poll_admin') && $poll['type'] == 'daily') { header('Location: /logout.php'); exit; exit; exit; // !!! } $query = 'INSERT INTO poll (handle, question, description, author, type, force_logon, timestamp, alt_1, alt_2, alt_3, alt_4, alt_5, alt_6, alt_7)'; $query .= ' VALUES("' . $handle . '", "' . $poll['question'] . '", "' . $poll['description'] . '", "' . $_SESSION['login']['id'] . '", "' . $poll['type'] . '", "' . $poll['force_logon'] . '", "' . time() . '"'; for ($i = 1; $i <= 7; $i++) { $query .= ', "' . $poll['alt_' . $i] . '"'; } $query .= ')'; mysql_query($query) or report_sql_error($query, __FILE__, __LINE__); return $handle; }
function games_game_save($options) { // Make handle from title $handle = isset($_POST['handle']) ? $_POST['handle'] : url_secure_string($_POST['title']); // Make array of controls $controls = array(); for ($i = 0; $i < 8; $i++) { $controls[$i]['combination'] = $_POST['key_' . $i]; $controls[$i]['description'] = $_POST['action_' . $i]; } $release = isset($_POST['release_now']) ? time() : strtotime($_POST['release']); $query_insert = 'INSERT INTO games (handle, title, description, controls, `release`, highscore_gname)'; $query_insert .= ' VALUES ("' . $handle . '", "' . $_POST['title'] . '", "' . $_POST['description'] . '", "' . mysql_real_escape_string(serialize($controls)) . '", ' . $release . ', "' . $_POST['highscore_gname'] . '")'; $query_update = 'UPDATE games SET title = "' . $_POST['title'] . '"'; $query_update .= ', description = "' . $_POST['description'] . '", controls = "' . mysql_real_escape_string(serialize($controls)) . '"'; $query_update .= ', `release` = "' . $release . '"'; $query_update .= ', highscore_gname = "' . $_POST['highscore_gname'] . '"'; $query_update .= ' WHERE handle = "' . $handle . '"'; log_to_file('games', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'query_insert: ' . $query_insert); if (!mysql_query($query_insert)) { log_to_file('games', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'query_update: ' . $query_update); mysql_query($query_update) or die(report_sql_error($query_update)); } else { jscript_alert('Scheduling release'); $schedule['item_id'] = mysql_insert_id(); $schedule['type'] = 'new_game'; $schedule['data'] = serialize($_POST); $schedule['release'] = $release; schedule_event_add($schedule); } $query = 'SELECT id, handle FROM games WHERE handle = "' . $handle . '"'; $result = mysql_query($query) or die(report_sql_error($query)); if ($data = mysql_fetch_assoc($result)) { $game_id = $data['id']; $game_handle = $data['handle']; } //save tags global $game_tags; foreach ($game_tags as $handle) { if (isset($_POST['chk_tag_' . $handle])) { $save['tag_handle'][] = $handle; } } $save['item_id'] = $game_id; $save['object_type'] = 'game'; tag_set_wrap($save); unset($save); $save['item_id'] = $game_id; $save['object_type'] = 'game'; $save['add'] = true; foreach (explode(',', $_POST['tags']) as $keyword) { $keyword = trim($keyword); $save['tag_label'][] = $keyword; } tag_set_wrap($save); /* Resize, convert and save the uploaded thumbnail */ if (strlen($_FILES['thumbnail']['tmp_name']) > 1) { system('convert ' . $_FILES['thumbnail']['tmp_name'] . ' -resize 120x90! /mnt/images/games/' . $game_handle . '.png'); echo 'Running: convert ' . $_FILES['thumbnail']['tmp_name'] . ' -resize 120x90! /mnt/images/games/' . $game_handle . '.png'; } echo '<p>Nu är spelet sparat och spelets handle är: ' . $game_handle . '</p>' . "\n"; echo 'game_id = ' . $game_id . '<br />' . "\n"; return $game_handle; }
function tag_set_wrap($options) { /* Obs! Removes all old tags options array support possible values item_id no object_type no 'discussion', 'post', 'wallpaper', 'article', 'survey', 'game', 'clip', 'a1' tag_handle yes handle_type_values tag_label yes Free text values tag_id yes 1, 2, 3.. add no set to true if tags should be added to old tags */ if (644314 == $_SESSION['login']['id']) { preint_r($options); } $keys = array('tag_handle', 'tag_label', 'tag_id'); foreach ($keys as $key) { if (isset($options[$key])) { $options[$key] = is_array($options[$key]) ? $options[$key] : array($options[$key]); $keytype = $key; } } if ($keytype == 'tag_label') { foreach ($options['tag_label'] as $label) { if (!($tag = tag_get_by_handle(url_secure_string($label)))) { $tag_id = tag_create($label); } else { $tag_id = $tag['id']; } $tag_ids[] = $tag_id; } } elseif ($keytype == 'tag_handle') { $tags = tag_get_by_handle($options['tag_handle']); unset($tag_ids); foreach ($tags as $tag) { $tag_ids[] = $tag['id']; } } if (!isset($options['add'])) { $query = 'DELETE FROM object_tags WHERE object_type = "' . $options['object_type'] . '" AND reference_id = "' . $options['item_id'] . '"'; mysql_query($query); } foreach ($tag_ids as $tag_id) { $query = 'INSERT INTO object_tags (tag_id, object_type, reference_id)'; $query .= ' VALUES ("' . $tag_id . '", "' . $options['object_type'] . '", "' . $options['item_id'] . '")'; mysql_query($query); //todo! annan felhantering här då det kan hända att man försöker sätta redan satta taggar, or die(report_sql_error($query, __FILE__, __LINE__)); } }
</div> <div class="right"> <div class="player_playlist" id="music_library_player_playlist"> PLAYLIST </div> <div class="player_player" id="music_library_player_player">PLAYER</div> </div> <?php echo '</div>' . "\n"; foreach ($music as $artist_name => $artist) { echo '<a name="' . url_secure_string($artist_name) . '"></a>' . "\n"; echo '<h2 style="margin-top: 20px;">' . $artist_name . '</h2>' . "\n"; echo '<ul>' . "\n"; foreach ($artist['tracks'] as $track) { $url = isset($track['url']) ? $track['url'] : 'http://music.t67.se/mp3/' . url_secure_string($artist_name) . '_-_' . url_secure_string($track['title']) . '.mp3'; echo '<li>'; if (isset($_GET['fisk'])) { echo ' <a href="' . $url . '" onclick="hp.music_library.fetch_artist_data(\'' . base64_encode($artist_name) . '\', this.href);return false;">' . $track['title'] . '</a>'; } else { echo '<a href="' . $url . '">' . $track['title'] . '</a>'; } echo '</li>' . "\n"; } echo '</ul>' . "\n"; } ui_bottom(); } ?>