Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
/**
*	The default behavior is to list the four latest comments. The selection and number of 
*	comments can be changed thru settings in $options
	item_id
	item_type
	options			array_support	description
	user_id				yes				include these users comments first in the array
	limit_offset		no
	limit				no
*/
function comments_list($item_id, $item_type, $options)
{
    log_to_file('comments', LOGLEVEL_DEBUG, __FILE__, __LINE__, 'comments_list', $item_type . ' ' . $item_id);
    $query = 'SELECT c.id, c.user_id, c.timestamp, c.comment, c.answer, l.username, lo.username AS answerer_username, u.image, u.gender, u.birthday, ur.rank, u.image FROM login l, userinfo u, user_comments c';
    $query .= ' LEFT OUTER JOIN user_ranks ur';
    $query .= ' ON ur.user_id = c.user_id';
    $query .= ' AND ur.item_id="' . $item_id . '" AND ur.item_type="' . $item_type . '"';
    $query .= ' LEFT OUTER JOIN login lo';
    $query .= ' ON lo.id = c.answerer_id';
    $query .= ' WHERE c.user_id = l.id AND u.userid = l.id AND c.item_type="' . $item_type . '" AND c.item_id="' . $item_id . '" AND c.item_type="' . $item_type . '" AND removed="0"';
    $query .= ' ORDER BY c.timestamp DESC';
    if (isset($options['limit']) && $options['limit'] != 'no_limit') {
        $query .= ' LIMIT ' . $options['limit'];
        if (isset($options['limit_offset'])) {
            $query .= ', ' . $options['limit_offset'];
        }
    } elseif ($options['limit'] != 'no_limit') {
        $query .= ' LIMIT 6';
    }
    $options['style'] = isset($options['style']) ? $options['style'] : 'normal';
    $result = mysql_query($query) or die(report_sql_error($query));
    if ($options['list_style'] == 'compact') {
        $output = '<div style="width: 575px; height: 590px; scroll: auto; overflow: auto;" id="comments_list" class="comments_list_compact">' . "\n";
        $output .= '<dl>' . "\n";
        while ($data = mysql_fetch_assoc($result)) {
            $output .= '<dt>' . $data['username'] . '</dt>' . "\n";
            $output .= '<dd style="margin-left: 70px;">' . $data['comment'] . '</dd>' . "\n";
        }
        $output .= '</dl>' . "\n";
    } else {
        $output = '<div id="comments_list" class="comments_list">' . "\n";
        while ($data = mysql_fetch_assoc($result)) {
            $output .= '<div class="comment_' . $options['style'] . '" id="comment_' . $data['id'] . '">' . "\n";
            if ($options['style'] == 'normal') {
                $output .= ui_avatar($data['user_id']) . "\n";
            }
            $output .= '<div class="comment_main_';
            if (($data['image'] == 1 || $data['image'] == 2) && $options['style'] == 'normal') {
                $output .= 'normal';
            } else {
                $output .= $options['style'];
            }
            $output .= '">' . "\n";
            if (isset($data['rank'])) {
                $output .= rank_draw($data['rank']);
            }
            $output .= '<div class="comment_author_name"><a href="/traffa/profile.php?id=' . $data['user_id'] . '">' . $data['username'] . '</a> ';
            $genders = array('m' => 'P', 'f' => 'F');
            $output .= $genders[$data['gender']];
            $output .= date_get_age($data['birthday']) > 0 ? date_get_age($data['birthday']) : '';
            $output .= '</div>' . "\n";
            $output .= '<span class="comment_time">(' . fix_time($data['timestamp']) . ')';
            if (login_checklogin() && ($_SESSION['login']['id'] == $data['user_id'] || is_privilegied('comments_admin') || is_privilegied('comments_admin', 'entertain') && $item_type == 'entertain' || $_SESSION['login']['id'] == $options['photo_owner'])) {
                $output .= ' <strong><a href="#img_full" onclick="comment_remove(' . $data['id'] . ')">[X]</a></strong>' . "\n";
            }
            $output .= '</span><p class="comment_text">' . $data['comment'] . '</p>' . "\n";
            // Shows a answer
            if (strlen($data['answer']) > 1) {
                $output .= '<span class="comment_answerer">' . $data['answerer_username'] . '\'s svar:</span> <p class="comment_answer">' . $data['answer'] . '</p>' . "\n";
            } elseif ($_SESSION['login']['id'] == $options['photo_owner'] && login_checklogin()) {
                $output .= '<button type="submit" onclick="comment_answer(' . $data['id'] . ', ' . $item_id . ')" class="button_60">Svara</button>' . "\n";
            }
            $output .= '</div>' . "\n";
            $output .= '</div>' . "\n";
        }
        $output .= '<br style="clear: both" />' . "\n";
        if (mysql_num_rows($result) == 6) {
            $output .= '<button class="button_150" id="comments_view_all_button">Visa alla kommentarer</button>' . "\n";
        }
    }
    $output .= '</div>' . "\n";
    // comments_list
    return $output;
}
Ejemplo n.º 3
0
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;
}