function discussion_create($options) { /* Required info title author discussion_type category (A tag label) Optional info timestamp owner (Mainly for group-discussions where the group owns the discussion and the user id is stored as author) handle (This will be generated from the title if omitted) parent_discussion tags (Must be an array) desired_quality (range -1 to +1) */ $category = tag_exists($options['category']); if ($category['status'] != 'exists') { $category['id'] = 0; } else { $options['tags'][] = $options['category']; } $handle = isset($options['handle']) ? $options['handle'] : discussions_create_handle($options['title']); $timestamp = isset($options['timestamp']) ? $options['timestamp'] : time(); $title = htmlspecialchars(shorten_string($options['title'])); $query = 'INSERT INTO discussions (timestamp, author, owner, title, handle, discussion_type, parent_discussion, category_tag, desired_quality)'; $query .= ' VALUES("' . $timestamp . '", "' . $options['author'] . '", "' . $options['owner'] . '", "' . $options['title'] . '"'; $query .= ', "' . $handle . '", "' . $options['discussion_type'] . '", "' . $options['parent_discussion'] . '", "' . $category['id'] . '", "' . $options['desired_quality'] . '")'; mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); $discussion_id = mysql_insert_id(); tag_set_wrap(array('tag_label' => $options['tags'], 'object_type' => 'discussion', 'item_id' => $discussion_id)); unset($return); $return['id'] = $discussion_id; $return['handle'] = $handle; $return['category_handle'] = $category['handle']; return $return; }
/** * 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 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; }
/** * Saves an entertain item from POST form to database * options new a new item update update an existing item * @return handle, the items handle */ function entertain_item_save($options) { $_SESSION['new_entertain_temp']['extension'] = strtolower($_SESSION['new_entertain_temp']['extension']); global $entertain_categories; global $entertain_types; global $entertain_type_categories; // Make handle from title if ($options['new']) { $handle = entertain_get_handle($_POST['title']); } else { $item_id = $_POST['item_id']; } $release = isset($_POST['release_now']) ? time() : strtotime($_POST['release']); $entertain_type = $options['entertain_type']; // Make array of controls $controls = array(); for ($i = 0; $i < 8; $i++) { if (isset($_POST['key_' . $i])) { $controls[$i]['combination'] = $_POST['key_' . $i]; $controls[$i]['description'] = $_POST['action_' . $i]; } } if ($options['new']) { $mode = 'new'; $query = 'INSERT INTO entertain_items (handle, title, entertain_type, category_id, `release`, extension, use_special_code, html, trailer_id, description, controls, link, uploader)'; $query .= ' VALUES ("' . $handle . '", "' . $_POST['title'] . '", "' . $entertain_type . '", "' . $_POST['entertain_category'] . '", "' . $release . '", "' . (isset($_SESSION['new_entertain_temp']['extension']) ? $_SESSION['new_entertain_temp']['extension'] : '') . '", "' . (isset($_POST['use_special_code']) ? '1' : '0') . '", "' . addslashes(html_entity_decode($_POST['special_code'])) . '", "' . $_POST['trailer_id'] . '", "' . $_POST['description'] . '", "' . mysql_real_escape_string(serialize($controls)) . '", "' . (isset($_POST['link']) ? $_POST['link'] : '') . '", ' . (isset($_SESSION['login']['id']) ? $_SESSION['login']['id'] : 0) . ')'; //error (one line up?) } elseif ($options['update']) { $mode = 'update'; $query = 'UPDATE entertain_items SET title = "' . $_POST['title'] . '"'; $query .= ', entertain_type = "' . $entertain_type . '"'; $query .= ', `release` = "' . $release . '"'; $query .= ', trailer_id = "' . $_POST['trailer_id'] . '"'; $query .= ', category_id = "' . $_POST['entertain_category'] . '"'; $query .= $options['update_file'] ? ', extension = "' . $_SESSION['new_entertain_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 .= ', description = "' . $_POST['description'] . '"'; $query .= count($controls) > 0 ? ', controls = "' . mysql_real_escape_string(serialize($controls)) . '"' : ''; $query .= isset($_POST['link']) ? ', link = "' . $_POST['link'] . '"' : ''; $query .= ' WHERE id = "' . $item_id . '"'; } $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if ($mode == 'new') { $item_id = mysql_insert_id(); } $query = 'SELECT * FROM entertain_items WHERE id = "' . $item_id . '"'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if ($data = mysql_fetch_assoc($result)) { $item = $data; $handle = $data['handle']; } else { return false; } if ($mode == 'new') { $schedule['item_id'] = $item_id; $schedule['type'] = 'new_' . $entertain_type; $_POST['url'] = '/' . $entertain_types[$entertain_type]['url_handle'] . '/' . $handle . '.html'; $schedule['data'] = serialize($_POST); $schedule['release'] = $release; schedule_event_add($schedule); } unset($save); $save['item_id'] = $item_id; $save['object_type'] = $entertain_type; $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) { $command = 'convert ' . $_FILES['thumbnail']['tmp_name'] . ' -resize 120!x90! ' . IMAGE_PATH . 'entertain/' . $handle . '.png'; system($command, $return_var); } //This is done instead of calling the distribute library as is done for clips, flash films and games. if ($entertain_type == 'image' || $entertain_type == 'software') { if (!isset($options['update']) || $options['update'] && $options['update_file']) { $command = 'convert ' . ENTERTAIN_TEMP_PATH . $_SESSION['new_entertain_temp']['hash'] . '.' . $_SESSION['new_entertain_temp']['extension'] . ' -resize 120!x90! ' . IMAGE_PATH . 'entertain/' . $handle . '.png'; system('convert ' . ENTERTAIN_TEMP_PATH . $_SESSION['new_entertain_temp']['hash'] . '.' . $_SESSION['new_entertain_temp']['extension'] . ' -resize 120!x90! ' . IMAGE_PATH . 'entertain/' . $handle . '.png'); // system('convert ' . ENTERTAIN_TEMP_PATH . $_SESSION['new_entertain_temp']['hash'] . '.' . $_SESSION['new_entertain_temp']['extension'] . // ' -resize 460x345 ' . IMAGE_PATH . 'fun_images/' . $handle . '.jpg'); } } /* elseif($entertain_type == 'background') { //todo! lägg till alla önskade storlekar system('convert ' . ENTERTAIN_TEMP_PATH . $_SESSION['new_entertain_temp']['hash'] . '.' . $_SESSION['new_entertain_temp']['extension'] . ' -resize 1024x768 ' . IMAGE_PATH . 'fun_images/' . $handle . '.jpg'); } */ // This is a safety output that the user will see if the redirect (done in entertain.php) does not happen. echo '<p>Nu är din/ditt ' . $entertain_types[$entertain_type]['label'] . ' sparad/sparat och dess handle är: ' . $handle . '</p>' . "\n"; $item['url'] = '/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/' . $item['handle'] . '.html'; echo '<p>Direktlänken blir då <a href="' . $item['url'] . '">' . $item['url'] . '</a>' . '</p>'; return $item; }
google_ad_type = "text"; //2007-10-03: Tävlingsfliken google_ad_channel = "6075720464"; google_color_border = "EEEEEE"; google_color_bg = "FFFFFF"; google_color_link = "000000"; google_color_text = "000000"; google_color_url = "333333"; google_ui_features = "rc:6"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>