Please read the FAQ in the Wiki:http://wiki.smfarcade.info/SMF_Arcade/FAQ
0 Members and 1 Guest are viewing this topic.
<?phpif (!defined('SMF')) die('Hacking attempt...');function autopost() { global $modSettings; if (isset($_REQUEST['game_tag']) && $_REQUEST['key'] == $modSettings['mochiAutopostPass']) { $urlrequest = 'http://www.mochimedia.com/feeds/games/'.$modSettings['mochiPubID'].'/'.$_REQUEST['game_tag'].'/?format=json'; $mochigamearr = json_decode(file_get_contents($urlrequest),true); $mochigame = $mochigamearr['games'][0]; if (isset($mochigame['swf_url'])) { $xx = explode('/', str_replace('http://', '', $mochigame['swf_url'])); $xx = array_reverse($xx); $swf_filename = $xx[0]; $swf_filename = urldecode($swf_filename); mkdir($modSettings['gamesDirectory'].'/'.$mochigame['slug'], 0755); file_put_contents($modSettings['gamesDirectory'].'/'.$mochigame['slug'].'/__metadata__.json', file_get_contents($urlrequest)); file_put_contents($modSettings['gamesDirectory'].'/'.$mochigame['slug'].'/'.$swf_filename, file_get_contents($mochigame['swf_url'])); } if (isset($mochigame['thumbnail_large_url'])) { $xx = explode('/', str_replace('http://', '', $mochigame['thumbnail_large_url'])); $xx = array_reverse($xx); $thumbnail_filename = $xx[0]; file_put_contents($modSettings['gamesDirectory'].'/'.$mochigame['slug'].'/'.$thumbnail_filename, file_get_contents($mochigame['thumbnail_large_url'])); } if (isset($mochigame['thumbnail_url'])) { $xx = explode('/', str_replace('http://', '', $mochigame['thumbnail_url'])); $xx = array_reverse($xx); $thumbnail_filename = $xx[0]; file_put_contents($modSettings['gamesDirectory'].'/'.$mochigame['slug'].'/'.$thumbnail_filename, file_get_contents($mochigame['thumbnail_url'])); } }}?>
<?php/*********************************************************************************** Submit-mochimedia.php ************************************************************************************* SMF Arcade ** =============================================================================== ** Software Version: SMF Arcade 2.5 RC1 ** Software by: Niko Pahajoki (http://www.madjoki.com) ** Copyright 2004-2009 by: Niko Pahajoki (http://www.madjoki.com) ** Support, News, Updates at: http://www.smfarcade.info ************************************************************************************* This program is free software; you may redistribute it and/or modify it under ** the terms of the provided license as published by Simple Machines LLC. ** ** This program is distributed in the hope that it is and will be useful, but ** WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY ** or FITNESS FOR A PARTICULAR PURPOSE. ** ** See the "license.txt" file for details of the Simple Machines license. ** The latest version can always be found at http://www.simplemachines.org. ***********************************************************************************/if (!defined('SMF')) die('Hacking attempt...');function ArcadeMochiMediaGetGame(){ global $scripturl, $txt, $db_prefix, $context, $sourcedir, $modSettings, $smcFunc; return getGameInfo($_POST['game']);}function ArcadeMochiMediaSubmit(&$game, $session_info){ global $scripturl, $txt, $db_prefix, $context, $sourcedir, $modSettings, $smcFunc; if (isset($_POST['score']) && is_numeric($_POST['score'])) $score = (float) $_POST['score']; else return false; $cheating = CheatingCheck(); return array( 'cheating' => $cheating, 'score' => $score, 'start_time' => $session_info['start_time'], 'duration' => time() - $session_info['start_time'], 'end_time' => time(), );}function ArcadeMochiMediaPlay(&$game, &$session_info){ global $scripturl, $txt, $db_prefix, $context, $sourcedir, $modSettings, $smcFunc, $settings; $smcFunc['db_query']('', ' UPDATE {db_prefix}arcade_games SET num_plays = num_plays + 1 WHERE id_game = {int:game}', array( 'game' => $context['game']['id'], ) ); $context['html_headers'] .= ' <script type="text/javascript" src="'.$settings['default_theme_url'].'/scripts/swfobject2.2.js"></script> <script type="text/javascript"> var flashvars = { }; var params = { menu: "false" }; var attributes = { }; swfobject.embedSWF("'.$game['url']['flash'].'", "game", "' . $game['extra_data']['width'] . '", "' . $game['extra_data']['height'] . '", "9.0.0", "'.$settings['default_theme_url'].'/scripts/expressInstall.swf", flashvars, params, attributes); </script>'; // We store this session to check cheating later $session_info = array( 'game' => $game['internal_name'], 'id' => $game['id'], 'start_time' => time(), 'done' => false, 'score' => 0, 'end_time' => 0, );}function ArcadeMochiMediaXMLPlay(&$game, &$session_info){ global $scripturl, $txt, $db_prefix, $context, $smcFunc; // We store this session to check cheating later $session_info = array( 'game' => $game['internal_name'], 'id' => $game['id'], 'start_time' => time(), 'done' => false, 'score' => 0, 'end_time' => 0, ); return true;}function ArcadeMochiMediaHtml(&$game, $auto_start = true){ global $scripturl, $txt, $context, $settings, $scripturl, $modSettings; echo ' <div id="leaderboard_bridge"></div> <script src="http://xs.mochiads.com/static/pub/swf/leaderboard.js" type="text/javascript"></script> <script type="text/javascript"> var options = {partnerID: "' . $modSettings['mochiPubID'] . '", id: "leaderboard_bridge"}; options.userID = "'.$context['user']['id'].'"; options.username = "'.$context['user']['name'].'"; options.callback = function (params) { document.mochiscore.score.value = params.score; document.forms[\'mochiscore\'].submit(); } options.userPrefix = "' . $scripturl . '?action=profile;u='.$context['user']['id'].'"; options.siteURL = "' . $scripturl . '"; options.siteName = "' . $context['forum_name'] . '"; options.denyFriends = "true"; options.denyChallenges = "true"; Mochi.addLeaderboardIntegration(options); </script> <form name="mochiscore" action="' . $scripturl . '" method="POST"> <input type="hidden" name="game" value="'.$game['internal_name'].'"> <input type="hidden" name="score" value="0"> <input type="hidden" name="mochimedia" value="0"> </form> <div id="game"> ', $txt['arcade_no_flash'], ' </div>';}?>
<uninstall> <modification reverse="true">install.xml</modification> <remove-file name="$sourcedir/ArcadeAutopost.php" /> <remove-file name="$sourcedir/Submit-mochimedia.php" /> <remove-file name="$themedir/scripts/expressInstall.swf" /> <remove-file name="$themedir/scripts/swfobject2.2.js" /> </uninstall>
Code: [Select] <uninstall> <modification reverse="true">install.xml</modification> <remove-file name="$sourcedir/ArcadeAutopost.php" /> <remove-file name="$sourcedir/Submit-mochimedia.php" /> <remove-file name="$themedir/scripts/expressInstall.swf" /> <remove-file name="$themedir/scripts/swfobject2.2.js" /> </uninstall>Place that after the </install>
Also everythings in a folder inside the zip, it'll still work but sometimes that can cause issues.
Hopefully someday this will be a default feature in SMF Arcade and if you need any help, I am a pro at Mochi's API.