Example #1
0
function _compo2_misc_links($params)
{
    if (isset($params['ratedivs']) && trim($params['ratedivs']) !== "") {
        $ratedivs = explode(";", $params['ratedivs']);
    } else {
        $ratedivs = ["compo", "open"];
    }
    $ratedivs_out = implode(",", array_map('add_quotes', $ratedivs));
    $r = compo2_query("select * from c2_entry where cid = ? and active = 1 AND etype IN ({$ratedivs_out})", array($params["cid"]));
    usort($r, "_compo2_preview_sort");
    echo "<p><a href='?action=default'>Back ...</a></p>";
    echo "<table><tr><th>Entry<th>User<th>Links ...<th># Votes<th>Coolness<th>Entry Type\n";
    foreach ($r as $ce) {
        $ue = unserialize($ce["get_user"]);
        echo "<tr>";
        echo "<td><a href='?action=preview&uid={$ce["uid"]}'>" . htmlentities($ce["title"]) . "</a>";
        echo "<td>" . htmlentities($ue["display_name"]);
        echo "<td>";
        _compo2_preview_show_links($ce);
        echo "<td>" . htmlentities($ce["rate_in"]);
        echo "<td>" . htmlentities($ce["rate_out"]);
        echo "<td>" . htmlentities($ce["etype"]);
        echo "\n";
    }
    echo "</table>";
}
Example #2
0
function _compo2_results_top($params)
{
    $NUM_RESULTS = 100;
    $cat = $_REQUEST["cat"];
    $params["cats"][] = "Coolness";
    if (!in_array($cat, $params["cats"])) {
        $cat = $params["topcat"];
    }
    // HACK: why overall? who knows!
    // show user their link options here ..
    echo "<p>";
    echo "<a href='./'>Back to results</a> | ";
    echo "<a href='?action=preview'>Browse all Entries</a> | ";
    $ce = compo2_entry_load($params["cid"], $params["uid"]);
    if ($ce["id"]) {
        echo "<a href='?action=edit'>Edit your entry</a> | ";
    }
    if ($ce["id"]) {
        echo "<a href='?action=preview&uid=" . urlencode($ce["uid"]) . "'>View your entry</a> |";
    }
    echo "</p>";
    // CACHING ///////////////
    unset($_REQUEST["more"]);
    if (($cres = compo2_cache_read($params["cid"], $ckey = "results_top:{$cat}")) !== false) {
        echo $cres;
        return;
    }
    ob_start();
    //     $r = _compo2_get_top($params);
    $r = _compo2_get_results($params);
    // also, this now ignores the nice counting of trophes done earlier ..
    $_cat = $cat;
    // backup for later
    /*
    if (strlen($cat)) {
        foreach ($r as $k=>$e) {
            $r[$k]["v"] = -$e["places"][$cat];
        }
        usort($r,"_compo2_results_sort");
    }
    */
    foreach ($r as $k => $ce) {
        $r[$k]["v"] = -$ce["places"][$cat];
        $r[$k]["place"] = $ce["places"][$cat];
        $r[$k]["value"] = $ce["values"][$cat];
    }
    $r = _compo2_results_sort2($r);
    //     usort($r,"_compo2_results_sort");
    echo "<h3>Top Entries - " . htmlentities($cat) . "</h3>";
    $myurl = get_bloginfo("url") . "/wp-content/plugins/compo2/images";
    $t = 1;
    $ties = array();
    foreach ($r as $e) {
        $n = intval($e["places"][$_cat]);
        @($ties[$n] += 1);
    }
    $last = -1;
    echo "<table class='results-top'>";
    $row = 0;
    foreach ($r as $e) {
        //         $ce = $e["info"];
        $ce = $e;
        $shots = unserialize($ce["shots"]);
        $fname = array_shift($shots);
        $link = "?action=preview&uid={$ce["uid"]}";
        //         $n = intval($e["places"][$_cat]);
        $n = $e["place"];
        if ($n == 0) {
            continue;
        }
        // get rid of un-judged items
        if ($last != -1 && $last != $n) {
            break;
        }
        // allow several last-places to show up
        $klass = "class='alt-" . (1 + $row++ % 2) . "'";
        echo "<tr>";
        echo "<td valign=top align=center {$klass}><b>{$n}.</b>";
        if ($ties[$n] > 1) {
            echo "<br/><i>TIE</i>";
        }
        echo "<td align=center valign=top {$klass}>";
        echo "<a href='{$link}'><img src='" . compo2_thumb($fname, 160, 160) . "' class='screenshot'></a>";
        echo "<td valign=top {$klass}>";
        echo "<div><a href='{$link}'><b>" . htmlentities($ce["title"]) . "</b> - " . htmlentities($ce["user"]["display_name"]) . "</a></div>";
        echo "<p>";
        _compo2_preview_show_links($ce);
        echo "</p>";
        echo "<div class='notes'>" . str_replace("\n", "<br/>", htmlentities(substr($ce["notes"], 0, 140))) . " ...</div>";
        echo "<td valign=top {$klass}>";
        asort($e["places"]);
        foreach ($e["places"] as $cat => $nn) {
            if ($nn <= $NUM_RESULTS && $nn != 0) {
                $img = "inone.gif";
                echo "<div><nobr>";
                if ($nn <= 3) {
                    $map = array("1" => "igold.gif", "2" => "isilver.gif", "3" => "ibronze.gif");
                    $img = $map[$nn];
                    echo "<img src='{$myurl}/{$img}' align=absmiddle> - {$cat}";
                } else {
                    echo "#{$nn} - {$cat}";
                }
                echo "</nobr></div>";
            }
        }
        if ($t >= $NUM_RESULTS && !strlen($_REQUEST["more"])) {
            $last = $n;
        }
        $t += 1;
        //         echo "<tr><td>&nbsp;";
    }
    echo "</table>";
    $cres = ob_get_contents();
    ob_end_clean();
    compo2_cache_write($params["cid"], $ckey, $cres);
    echo $cres;
}
Example #3
0
function _compo2_preview_show($params, $uid, $comments = true)
{
    $ce = compo2_entry_load($params["cid"], $uid);
    echo "<p>";
    echo "<a href='?action=preview'>Back to Browse Entries</a>";
    if (isset($params["uid"]) && $params["uid"]) {
        if (current_user_can('edit_others_posts')) {
            //			$ce = compo2_entry_load($params["cid"],intval($_REQUEST["uid"]));
            echo " | <strong><a href='?action=edit&uid=" . $ce["uid"] . "&admin=1'>ADMIN EDIT</a></strong>";
        }
        if (intval($params["uid"]) === intval($uid)) {
            // If the entry exists //
            if ($ce["id"]) {
                echo " | <a href='?action=edit'>Edit Entry</a>";
            }
        }
    }
    echo "</p>";
    if (!$ce["id"]) {
        echo "<p>Sorry, this person does not have an Entry.</p>";
        return;
    }
    $shots = unserialize($ce["shots"]);
    $settings = unserialize($ce["settings"]);
    $is_nsfw = $settings["NSFL"];
    $baseurl = get_bloginfo("url") . "/wp-content";
    $has_embed = isset($settings["EMBED"]["url"]) && $settings["EMBED"]["url"] !== "";
    if ($has_embed) {
        $url = $settings["EMBED"]["url"];
        $width = $settings["EMBED"]["width"];
        $height = $settings["EMBED"]["height"];
        $imagefile = array_values($shots)[0];
        $shot_url = c2_thumb($imagefile, 900, 500, false, true);
        $play_code = "<div id='embed' onclick='c2_play_game();' style='width:{$width}px;height:{$height}px'><img class='embed-icon' src='{$shot_url}'><div class='embed-overlay'></div><img class='embed-icon' src='/compo/wp-content/plugins/compo2/art/play.png' /></div>";
        ?>
		<script>
			function c2_toggle_fullscreen() {
				var elem = document.getElementById('embed');
					if (elem.requestFullscreen) {
						elem.requestFullscreen();
					} else if (elem.msRequestFullscreen) {
						elem.msRequestFullscreen();
					} else if (elem.mozRequestFullScreen) {
						elem.mozRequestFullScreen();
					} else if (elem.webkitRequestFullscreen) {
						elem.webkitRequestFullscreen();
				}
			}
			
			function c2_play_game() {
				var elm = document.getElementById('embed-frame');
				elm.innerHTML = "<?php 
        echo "<iframe id='embed' src='{$url}' width='{$width}' height='{$height}' frameborder='0' allowfullscreen></iframe>";
        ?>
";
			}
			
			function c2_exit_game() {
				var elm = document.getElementById('embed-frame');
				elm.innerHTML = "<?php 
        echo $play_code;
        ?>
";
				//"<div id='embed' onclick='c2_play_game();'><?php 
        echo "<img id='embed' src='{$shot_url}'>";
        ?>
</div>";
			}
		</script>
		<style>
			#embed {
				margin:10px auto;
				display:block;
				position:relative;
				text-align:center;
			}
			
			:-webkit-full-screen #embed {
				width: 100%;
				height: 100%;
			}
			#embed:-ms-fullscreen {
				position:absolute;
				left:0px;
				top:0px;
				width: 100%;
				height: 100%;
			}					
			
			.embed-overlay {
				position:absolute;
				background:url('/compo/wp-content/plugins/compo2/art/TiledBars.png');
				left:0;
				top:0;
				width:100%;
				height:100%;
			}
			.embed-icon {
				position:absolute;
				left:50%;
				top:50%;
				-ms-transform: translate(-50%,-50);
				-webkit-transform: translate(-50%,-50%);
				transform: translate(-50%,-50%);				
			}
			
			.embed-controls {
				text-align:center;
			}
			.embed-controls img {
				cursor:pointer;
				opacity:0.3;
			}
			.embed-controls img:hover {
				opacity:1.0;
			}
		</style>
<?php 
        echo "<div id='embed-view'>";
        echo "<div id='embed-frame'>";
        echo $play_code;
        echo "</div>";
        echo "<div class='embed-controls'>";
        if ($settings["EMBED"]["fullscreen"]) {
            echo "<img src='{$baseurl}/plugins/compo2/art/Maximize.png' onclick='c2_toggle_fullscreen();'>";
        }
        echo "<img src='{$baseurl}/plugins/compo2/art/Power.png' onclick='if (confirm(\"Are you sure you want to Shutdown the game? All progress will be lost!\")) { c2_exit_game(); }'>";
        echo "</div>";
        echo "</div>";
    }
    echo "\n\t\t<style>\n\t\t\t#shotview {\n\t\t\t\ttext-align:center;\n\t\t\t\tmargin-bottom:10px;\n\t\t\t}\n\t\t\t#shotview img {\n\t\t\t\tmax-width:900px;\n\t\t\t}\n\t\t</style>\n\t";
    // Screenshot Viewer //
    echo "<div id='shotview' class='" . ($has_embed ? "hidden" : "") . "'>";
    $imagefile = array_values($shots)[0];
    $link = $baseurl . '/compo2/' . $imagefile;
    $preview = c2_thumb($imagefile, 900, 500, false, true);
    echo "<a id='shotview_link' href='{$link}' target='_blank'><img id='shotview_img' src='{$preview}'></a>";
    echo "</div>";
    // Game Name and Developer //
    echo "<div style='overflow:auto;'>";
    echo "<div style='float:right;'>";
    $user = unserialize($ce["get_user"]);
    echo get_avatar($user['user_email'], '56');
    echo "</div>";
    echo "<h2 style='font-size:28px'>" . htmlentities($ce["title"]) . "</h2>";
    echo "by <a href=\"../author/{$user['user_nicename']}/\" target='_blank'><strong>{$user['display_name']}</strong></a>";
    $div = $ce["etype"];
    echo " - <i>{$params["{$div}_title"]} Entry</i>";
    echo "</div>";
    ?>
	<style>
		.shot-nav {
			text-align:center;
			width:940px;
			left:-20px;
			position:relative;
			margin-top:10px;
		}
		
		.shot-nav .sn-item {
			display:inline-block;
			opacity:0.4;
			padding:3px;
			position:relative;
		}
		.shot-nav .sn-item:hover {
			opacity:1.0;
		}

		.shot-nav .sn-item .sn-img {
			border-radius:7px;
			cursor:pointer;
		}
		
		.shot-nav .sn-item .sn-overlay {
			border-radius:7px;
			position:absolute;
			background:url('/compo/wp-content/plugins/compo2/art/TiledBars.png');
			left:0;
			top:0;
			width:100%;
			height:100%;
		}
		
		.shot-nav .sn-item .sn-icon {
			position:absolute;
			left:50%;
			top:50%;
			-ms-transform: translate(-50%,-50);
			-webkit-transform: translate(-50%,-50%);
			transform: translate(-50%,-50%);
		}
		
		.shot-nav .sn-selected {
			opacity:0.8;
			border:3px solid #000;
			background:#000;
			border-radius:10px;
			padding:0;
		}
		
		.links {
			margin:0;
		}
		
		.links ul {
			list-style:none;
			margin:0;
		}
		.links ul li:before {
			content:'';
		}
		
		#compo-nsfw {
			cursor:pointer;
			background:#900;
			border-radius:10px;
			padding:20px;
			color:#FF0;
			text-align:center;
		}
		
		#compo-nsfw h2 {
			text-align:center;
			font-size:40px;
			color:#F80;
		}
		
	</style>
	
	<script>
		function c2_addclass( el, className ) {
			if ( el ) {
				if (el.classList)
					el.classList.add(className);
				else
					el.className += ' ' + className;
			}
		}
		function c2_removeclass( el, className ) {
			if ( el ) {
				if (el.classList)
					el.classList.remove(className);
				else
					el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
			}
		}

		// Global Variable //
		window.c2_ShotIndex = 0;
		
		function c2_show_embed() {
			c2_removeclass( document.getElementById('embed-view'), 'hidden');
		}
		function c2_hide_embed() {
			c2_addclass( document.getElementById('embed-view'), 'hidden');
		}
		
		function c2_show_image( _img, _link ) {
			c2_removeclass( document.getElementById('shotview'), 'hidden');
			document.getElementById('shotview_img').setAttribute('src', _img);
			document.getElementById('shotview_link').setAttribute('href', _link);
		}
		function c2_hide_image() {
			c2_addclass( document.getElementById('shotview'), 'hidden');
		}
		
		function c2_highlight_nav( id ) {
			c2_removeclass( document.getElementById('shot-nav-'+window.c2_ShotIndex), 'sn-selected');
			c2_addclass( document.getElementById('shot-nav-'+id), 'sn-selected');
			
			window.c2_ShotIndex = id;		
		}

		function c2_select_embed( id ) {
			c2_hide_image();
			
			c2_highlight_nav(id);
			
			c2_show_embed();
		}
		function c2_select_image( id, _img, _link ) {
			c2_hide_embed();
		
			c2_highlight_nav(id);

			c2_show_image( _img, _link );
		}
	</script>

<?php 
    //echo "NSFW Test:".(($is_nsfw=='1')?"YES":"nope");
    //<script>window.compo_game_nsfw = true;</script>
    if ($is_nsfw == '1') {
        echo "<script>window.compo_game_nsfw = true;</script>";
    }
    // Screenshots //
    echo "<div class='shot-nav'><span>";
    $idx = 0;
    if ($has_embed) {
        $imagefile = array_values($shots)[0];
        $link = $baseurl . '/compo2"/' . $imagefile;
        $thumb = c2_thumb($imagefile, 180, 140);
        $selected = $idx === 0 ? "sn-selected" : "";
        //		echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}'><a href='' target='_blank'><img src='{$thumb}' width='180' height='140'></a></div>";
        echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}' onclick='c2_select_embed({$idx});'>\n\t\t\t<img class='sn-img' src='{$thumb}' width='180' height='140'>\n\t\t\t<div class='sn-overlay'></div>\n\t\t\t<img class='sn-icon' id='embed-mode' src='/compo/wp-content/plugins/compo2/art/play-sm.png' />\n\t\t</div>";
        $idx++;
    }
    foreach ($shots as $imagefile) {
        if ($idx === 5) {
            break;
        }
        $link = $baseurl . '/compo2/' . $imagefile;
        $thumb = c2_thumb($imagefile, 180, 140);
        $preview = c2_thumb($imagefile, 900, 500, false, true);
        $selected = $idx === 0 ? "sn-selected" : "";
        //		echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}'><a href='{$link}' target='_blank'><img src='{$thumb}' width='180' height='140'></a></div>";
        echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}'><img class='sn-img' src='{$thumb}' width='180' height='140' onclick='c2_select_image({$idx},\"{$preview}\",\"{$link}\");'></div>";
        $idx++;
    }
    echo "</span></div>";
    // Description //
    echo "<p>" . str_replace("\n", "<br/>", htmlentities($ce["notes"])) . "</p>";
    // Links and Downloads //
    echo "<h2>Downloads and Links</h2>";
    echo "<div class='links'>";
    _compo2_preview_show_links($ce);
    echo "</div>";
    echo "<br />";
    echo '<meta name="twitter:card" content="summary" />';
    echo '<meta name="twitter:site" content="@ludumdare" />';
    $twitter = get_the_author_meta('twitter', (string) $uid);
    //get_the_author_meta('twitter', $user["ID"]);
    if ($twitter != null && $twitter != '') {
        echo '<meta name="twitter:creator" content="@' . $twitter . '" />';
    }
    echo '<meta name="twitter:title" content="' . substr(htmlentities($ce["title"]), 0, 70) . '" />';
    echo '<meta name="twitter:description" content="' . substr(htmlentities($ce["notes"]), 0, 200) . '" />';
    if ($firstshot != null && $firstshot != '') {
        echo '<meta name="twitter:image" content="' . get_bloginfo("url") . '/wp-content/compo2/' . htmlentities($firstshot) . '" />';
    }
    echo '<script>';
    echo 'var Elm = document.getElementsByTagName("title")[0];';
    echo 'Elm.innerHTML = "' . htmlentities($ce["title"]) . ' by ' . $user["display_name"] . ' | " + Elm.innerHTML;';
    echo '</script>';
    // Rating Results //
    if ($params["state"] == "results" || $params["state"] == "admin") {
        if (!isset($params["{$div}_judged"]) || $params["{$div}_judged"] !== "0") {
            _compo2_results_ratings($params, $uid);
        }
    }
    // Comments ?? //
    if ($comments) {
        _compo2_preview_comments($params, $uid, true);
    }
}