示例#1
0
function sex_sense_schedule_add($options)
{
    if (!isset($options['id'])) {
        throw new Exception('Missing parameter id for sex_sense_schedule_add()!');
    }
    $release = schedule_release_get(array('type' => 'sex_sense'));
    $data = serialize(array('fetch_item_options' => array('id' => $options['id'], 'ignore_no_posts_found_error' => true, 'is_released' => 0), 'url' => $options['url'], 'title' => $options['title']));
    schedule_event_add(array('data' => $data, 'type' => 'sex_sense', 'release' => $release, 'item_id' => $options['id']));
}
示例#2
0
/**
* 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;
}
示例#3
0
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;
}
示例#4
0
/**
* 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;
}
示例#5
0
         $data['alternate_spellings']['artist'] = $_POST['artist3'];
     }
     if (strlen($_POST['song1']) > 0) {
         $data['alternate_spellings']['artist'] = $_POST['song1'];
     }
     if (strlen($_POST['song2']) > 0) {
         $data['alternate_spellings']['artist'] = $_POST['song2'];
     }
     if (strlen($_POST['song3']) > 0) {
         $data['alternate_spellings']['artist'] = $_POST['song3'];
     }
     copy($hp_path . 'music_guess/mp3/' . $_POST['file_id'] . '_' . $_POST['file_version'] . '.mp3', '/mnt/images/music_guess_mp3/' . $data['secret_id'] . '.mp3');
     $schedule['type'] = 'music_guess';
     $schedule['data'] = serialize($data);
     $schedule['release'] = schedule_release_get(array('type' => 'music_guess'));
     schedule_event_add($schedule);
     rename('/mnt/amuse/music_guess/' . $_POST['original_filename'], '/mnt/amuse/music_guess/_KLAR_' . $_POST['original_filename']);
     echo '<h1>Sparat! <a href="/admin/music_guess.php">Lägg in en ny låt</a></h1>' . "\n";
 } else {
     echo '<ul style="list-style-type: none;">' . "\n";
     $dir = opendir('/mnt/amuse/music_guess/');
     while ($filename = readdir($dir)) {
         if ($filename != '.' && $filename != '..') {
             $filenames[] = $filename;
         }
     }
     sort($filenames);
     foreach ($filenames as $filename) {
         echo '<li style="line-height: 25px;"><a href="?filename=' . urlencode($filename) . '">' . utf8_encode($filename) . '</a></li>' . "\n";
     }
     echo '<ul>' . "\n";