Permalink
Browse files

New Feature: Submit games to the public GPX Cloud

  • Loading branch information...
Ryan G
Ryan G committed Aug 26, 2013
1 parent b1c000d commit 2ecd851879df11415fe044ae9fec2e9776489a7b
Showing with 137 additions and 4 deletions.
  1. +16 −0 admin/gamesedit.php
  2. +83 −3 ajax/games_actions.php
  3. +38 −1 scripts/internal/games.js
@@ -54,6 +54,7 @@ function gamesedit_showsect(area)
$def_cfg_rcon = $row['cfg_rcon'];
$def_cfg_passw = $row['cfg_password'];
$def_cloudid = $row['cloudid'];
$def_port = $row['port'];
$def_startup = $row['startup'];
$def_steam = $row['steam'];
@@ -344,6 +345,21 @@ function gamesedit_showsect(area)
<tr>
<td colspan="2"><?php echo $lang['banned_start_desc']; ?></td>
</tr>

<tr>
<td colspan="2">&nbsp;</td>
</tr>

<tr>
<td><b><?php echo $lang['cloud_games']; ?></b>:</td>
<td>
<?php
// Allow submission to GPX Cloud Games if not already there
if(!$def_cloudid) echo '<span class="links" onClick="javascript:game_submit_cloudgames_confirm(' . $url_id . ');">Submit this game to GamePanelx Cloud Games</span>';
else echo '<i>Already in Cloud Games</i>';
?>
</td>
</tr>
</table>

</div></div>
@@ -190,7 +190,7 @@
// Update simplecmd with most recent order
$simplecmd = '';
$result_smp = @mysql_query("SELECT cmd_item,cmd_value FROM default_startup WHERE srvid = '$url_id' ORDER BY sort_order ASC");
$result_smp = @mysql_query("SELECT cmd_item,cmd_value FROM default_startup WHERE defid = '$url_id' ORDER BY sort_order ASC") or die('Failed to get item/vals!');
while($row_smp = mysql_fetch_array($result_smp))
{
@@ -202,7 +202,7 @@
}
// Update new simplecmd
@mysql_query("UPDATE default_games SET simplecmd = '$simplecmd' WHERE id = '$url_id'");
@mysql_query("UPDATE default_games SET simplecmd = '$simplecmd' WHERE id = '$url_id'") or die('Failed to update simplecmd!');
echo 'success';
}
@@ -275,8 +275,88 @@
</table>
<div class="button" onClick="javascript:game_create();">'.$lang['save'].'</div>';
}
// Allow submission to GPX Cloud Games for review
elseif($url_do == 'submit_cloudgames')
{
// Get game info
$result_info = @mysql_query("SELECT * FROM default_games WHERE id = '$url_id' ORDER BY id DESC LIMIT 1") or die('Failed to query for game info!');
$game_arr = array();
$total_info = mysql_num_rows($result_info);
if(!$total_info) die('No information found for this game!');
while($row_info = mysql_fetch_assoc($result_info))
{
$game_arr[] = $row_info;
}
// Check json support
if(!function_exists('json_encode')) die('No JSON support found (json_encode)! Exiting.');
if(empty($game_arr)) die('No information found for this game (empty array)!');
else $json_game_info = json_encode($game_arr);
###################################################
// Get game startup items
$result_strt = @mysql_query("SELECT * FROM default_startup WHERE defid = '$url_id' ORDER BY sort_order ASC") or die('Failed query for game setup items!');
$strt_arr = array();
$total_info = mysql_num_rows($result_strt);
// Only run this if this game has startup items
if($total_info)
{
while($row_strt = mysql_fetch_assoc($result_strt))
{
$strt_arr[] = $row_strt;
}
$json_startup_items = json_encode($strt_arr);
}
else
{
$json_startup_items = '';
}
###################################################
// Compress the data
if(!function_exists('curl_init')) die('No curl support found (curl_init)! Exiting.');
#if(!function_exists('gzcompress')) die('No gzip compression support (gzcompress)! Exiting.');
#$gzip_info = gzcompress($json_game_info, 9);
#$gzip_startup = gzcompress($json_startup_items, 9);
###################################################
// Get basic info so we know who submitted
#require(DOCROOT.'/includes/classes/core.php');
#$Core = new Core;
$gpxcfg = $Core->getsettings();
$gpx_email = strip_tags($gpxcfg['default_email_address']);
$gpx_company = strip_tags($gpxcfg['company']);
$gpx_version = strip_tags($gpxcfg['version']);
$postfields = array();
$postfields['email'] = base64_encode($gpx_email);
$postfields['company'] = base64_encode($gpx_company);
$postfields['version'] = base64_encode($gpx_version);
$postfields['gameinfo'] = $json_game_info;
$postfields['gamestartups'] = $json_startup_items;
// Connect to gamepanelx cloud site
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://gamepanelx.com/cloud/cloudsubmit.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$data = curl_exec($ch);
curl_close($ch);
if($data == 'success') echo 'success';
else echo 'Failed: '.$data;
}
?>
@@ -326,7 +326,7 @@ function game_showcreate()
{
$.ajax({
url: ajaxURL,
data: 'a=game_actions&do=show_creategame',
data: 'a=games_actions&do=show_creategame',
success:function(html){
// Show modal with info
$("#modal").html(html).modal({overlayClose:true,opacity:70,overlayCss:{backgroundColor:"#000"},onClose: function (dialog) {
@@ -335,3 +335,40 @@ function game_showcreate()
}
});
}





// Submit a new game to Cloud Games for review and potential addition
function game_submit_cloudgames_confirm(gameID)
{
if(gameID == "")
{
alert("No game provided!");
return false;
}

var answer = confirm("Are you sure?\n\nThis will submit this custom game to the public GamePanelX Cloud Games for review and addition. By submitting this game, you certify you have personally tested this server and that it is working to the best of your knowledge.\n\nBy submitting, you also show your understanding and agreement that we will receive the following Settings from your GamePanelX installation: Company Name, Email and GamePanelX Version.\n\nContinue with submission?");

if(answer) game_submit_cloudgames(gameID);
else return false;
}

function game_submit_cloudgames(gameID)
{
if(gameID == "")
{
alert("Submit: No game provided!");
return false;
}

$.ajax({
url: ajaxURL,
data: 'a=games_actions&do=submit_cloudgames&id='+gameID,
success:function(html){
if(html == 'success') infobox('s','');
else infobox('f','Failed: '+html);
}
});
}

0 comments on commit 2ecd851

Please sign in to comment.