collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [2.5.x] MochiMedia Hack 1.1  (Read 6257 times)

0 Members and 1 Guest are viewing this topic.

Offline nend

  • Friend
  • *
  • Posts: 161
  • Karma: 5
    • SICommunity
[2.5.x] MochiMedia Hack 1.1
« on: February 07, 2010, 11:39:29 PM »
Well if you installed the first one it was a little buggy.

Just replace these files in the sources until I can package one up. I will post the package here.  :thumb:

This will fix -
- Games failing to install right because of illegal characters in the filename. Converts these characters when storing the file.
- Time taken time is now fixed.
- Fixed the form submit to an exact url instead of index.php. This caused problems with some SEO mods.

ArcadeAutopost.php
Code: [Select]
<?php

if (!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_filenamefile_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_filenamefile_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_filenamefile_get_contents($mochigame['thumbnail_url']));
}
}
}
?>


Submit-mochimedia.php
Code: [Select]
<?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>'
;
}
?>

*edit

Sorry took so long for me to get this packaged. I have been working with other stuff lately and getting caught up in that.

Well here it is, I can't figure out though why there is no uninstall once the mod is applied. I think maybe because it only modifies the arcade files and no SMF files. HMM

Well here it is, attached below.

« Last Edit: March 02, 2010, 05:07:12 PM by nend »
SMF 2.0 RC2
SMF Arcade 2.5 RC1

SMF 1.1.11
E-Arcade 2.5.9
NEND
SMF Arcade Friend
ASII - PHP - MySql - JavaScript
My Games - My Mods

Offline Ken.

  • Beta Tester
  • *
  • Posts: 122
  • Karma: 2
  • Gender: Male
    • Our FamilyForum
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #1 on: February 08, 2010, 03:06:56 PM »
Sounds great nend, I've been wanting to reinstall this hack after my recent forum upgrade.  :thumb:

Offline Skhilled

  • Friend
  • *
  • Posts: 5260
  • Karma: 64
  • Gender: Male
  • Retro Gamer
    • Doc Skillz
  • Arcade Version: More than one version
  • SMF Version: More than 1 version
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #2 on: February 10, 2010, 05:10:55 PM »
Thanks for the fix, nend. :)

TinyPortal Beta Tester - LogoOff.net Team

Offline nend

  • Friend
  • *
  • Posts: 161
  • Karma: 5
    • SICommunity
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #3 on: February 13, 2010, 06:07:09 PM »
Updated the first post with the modification for any one who hasn't installed it before.

If you installed it before please just replace the contents of the said files.

I don't know why though there is no uninstall once the mod is applied. I am thinking since the mod does not touch any of the SMF core files SMF thinks there is no need for a uninstall. I don't know though. If anyone experience with packaging things up can take a look and see if I did something wrong in the package that would be greatly appreciated.
SMF 2.0 RC2
SMF Arcade 2.5 RC1

SMF 1.1.11
E-Arcade 2.5.9
NEND
SMF Arcade Friend
ASII - PHP - MySql - JavaScript
My Games - My Mods

Offline jeza

  • Arcade Support Staff
  • *
  • Posts: 1924
  • Karma: 63
  • Gender: Male
    • 1st Maryland Inf
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #4 on: February 13, 2010, 06:47:43 PM »
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.
« Last Edit: February 13, 2010, 06:49:29 PM by jeza »

Offline Skhilled

  • Friend
  • *
  • Posts: 5260
  • Karma: 64
  • Gender: Male
  • Retro Gamer
    • Doc Skillz
  • Arcade Version: More than one version
  • SMF Version: More than 1 version
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #5 on: February 14, 2010, 05:17:32 AM »
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>

That should do it. ;)

Also everythings in a folder inside the zip, it'll still work but sometimes that can cause issues.

That is true. The zip should not contain any extra folders such as:

/folder1/folder1/then the folders and files...

It should just contain the files and folders.

TinyPortal Beta Tester - LogoOff.net Team

Offline nend

  • Friend
  • *
  • Posts: 161
  • Karma: 5
    • SICommunity
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #6 on: March 02, 2010, 05:08:52 PM »
Shoot I take forever to get things done, lol. Well updated it with the uninstall information. Thanks Jeza for the SMF xml help. Those packages always get me.

New version 1.1.1, only change was a uninstall option for the mod/hack.
SMF 2.0 RC2
SMF Arcade 2.5 RC1

SMF 1.1.11
E-Arcade 2.5.9
NEND
SMF Arcade Friend
ASII - PHP - MySql - JavaScript
My Games - My Mods

Offline nend

  • Friend
  • *
  • Posts: 161
  • Karma: 5
    • SICommunity
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #7 on: March 15, 2010, 08:04:26 PM »
Please note this mod uses SWFObject 2.2 Alpha, it is still labeled 2.1 if you open the file and view it.

Well 2.2 final has been released about half a year ago, which is what I thought I used on the mod.

Please download it and replace your swf object with it.
http://code.google.com/p/swfobject/downloads/list

Your SWFObject file can be found in your default theme folder in the scripts folder. It should be named swfobject2.2.js, just open it with a text editor and replace the contents of the file with the contents of the js file at the download location above.

I will release a updated mod to reflect these changes soon.

I noticed this fixes one big problem. Some people using IE sometimes can not load games with the current SWFObject but this release fixes that.

SMF 2.0 RC2
SMF Arcade 2.5 RC1

SMF 1.1.11
E-Arcade 2.5.9
NEND
SMF Arcade Friend
ASII - PHP - MySql - JavaScript
My Games - My Mods

Offline Skhilled

  • Friend
  • *
  • Posts: 5260
  • Karma: 64
  • Gender: Male
  • Retro Gamer
    • Doc Skillz
  • Arcade Version: More than one version
  • SMF Version: More than 1 version
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #8 on: March 17, 2010, 12:01:18 PM »
Thanks, nend. :)

TinyPortal Beta Tester - LogoOff.net Team

Offline nend

  • Friend
  • *
  • Posts: 161
  • Karma: 5
    • SICommunity
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #9 on: March 17, 2010, 04:51:08 PM »
I would also like to add, if any of the devs here would like, they can use any of the code I have provided here. 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. :D

I have also been thinking about making it use Mochi to post the scores instead of using the JavaScript on the page. This way it would be harder to cheat the system, but no real need has arisen to do it this way. https://www.mochimedia.com/support/pub_docs#integrated_leaderboards_score
SMF 2.0 RC2
SMF Arcade 2.5 RC1

SMF 1.1.11
E-Arcade 2.5.9
NEND
SMF Arcade Friend
ASII - PHP - MySql - JavaScript
My Games - My Mods

Offline Skhilled

  • Friend
  • *
  • Posts: 5260
  • Karma: 64
  • Gender: Male
  • Retro Gamer
    • Doc Skillz
  • Arcade Version: More than one version
  • SMF Version: More than 1 version
Re: [2.5.x] MochiMedia Hack 1.1
« Reply #10 on: March 18, 2010, 11:59:06 AM »
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. :D
Having it as a default feature would be a great idea! :D

TinyPortal Beta Tester - LogoOff.net Team