Skip to content

Commit

Permalink
Convert project to Ice 3.7
Browse files Browse the repository at this point in the history
Change type references to backslash syntax

Update ServerInterface.php; Drop Ice 3.3 and 3.4 initialization.
  • Loading branch information
AtomicHaggis authored and Kissaki committed Jun 27, 2022
1 parent 44c65f9 commit 992fb7f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 68 deletions.
2 changes: 1 addition & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Check for running Ice with Murmur
try {
ServerInterface::getInstance();
} catch(Ice_UnknownLocalException $ex) {
} catch(Ice\UnknownLocalException $ex) {
MessageManager::addError(tr('error_noIce'));
MessageManager::echoAll();
exit();
Expand Down
6 changes: 3 additions & 3 deletions ajax/admin.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ function()
/*]]>*/
</script>
<?php
} catch(Murmur_ServerBootedException $exc) {
} catch(Murmur\ServerBootedException $exc) {
echo '<div class="error">Server is not running</div>';
}
}
Expand Down Expand Up @@ -701,7 +701,7 @@ function(event)
</script>
<?php
} // permission check: moderate
} catch(Murmur_ServerBootedException $exc) {
} catch(Murmur\ServerBootedException $exc) {
echo '<div class="error">Server is not running</div>';
}
}
Expand Down Expand Up @@ -825,7 +825,7 @@ public static function server_bans_show()
</p>
<?php
}
} catch(Murmur_ServerBootedException $exc) {
} catch(Murmur\ServerBootedException $exc) {
//TODO i18n
echo 'Server is not running.';
}
Expand Down
8 changes: 4 additions & 4 deletions classes/MurmurClasses.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class MurmurServer
{
/**
* @param Ice_ObjectPrx $iceObject
* @param Ice\ObjectPrx $iceObject
* @return MurmurServer
*/
public static function fromIceObject($iceObject)
Expand Down Expand Up @@ -104,7 +104,7 @@ public function getChannels()
}
/**
* @return MurmurTree
* @throws Murmur_ServerBootedException
* @throws Murmur\ServerBootedException
*/
public function getTree()
{
Expand Down Expand Up @@ -568,10 +568,10 @@ public function __construct($sessionId, $registrationId, $isMuted, $isDeafened,
}
/**
* Create a MurmurUser from an ice User
* @param Murmur_User $iceUser
* @param Murmur\User $iceUser
* @return MurmurUser
*/
public static function fromIceObject(Murmur_User $iceUser)
public static function fromIceObject(Murmur\User $iceUser)
{
return new self(
$iceUser->session,
Expand Down
73 changes: 16 additions & 57 deletions classes/ServerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,65 +74,24 @@ function __construct()
} else {
$this->contextVars = SettingsManager::getInstance()->getDbInterface_iceSecrets();

if (!function_exists('Ice_intVersion') || Ice_intVersion() < 30400) {
$this->initIce33();
} else {
$this->initIce34();
}

$this->initIce();
$this->connect();
}
}

private function initIce33()
{
// ice 3.3

//TODO it would be good to be able to add a check if slice file is loaded
//if (empty(ini_get('ice.slice'))) {
//MessageManager::addError(tr('error_noIceSliceLoaded'));

global $ICE;
Ice_loadProfile();
try
{
$conn = $ICE->stringToProxy(SettingsManager::getInstance()->getDbInterface_address());
$this->meta = $conn->ice_checkedCast("::Murmur::Meta");
// use IceSecret if set
if (!empty($this->contextVars)) {
$this->meta = $this->meta->ice_context($this->contextVars);
}
$this->meta = $this->meta->ice_timeout(10000);
}
catch (Ice_ProxyParseException $e)
{
MessageManager::addError(tr('error_invalidIceInterface_address'));
}
}

private function initIce34()
private function initIce()
{
// ice 3.4
$initData = new Ice_InitializationData;
$initData->properties = Ice_createProperties();
$initData = new Ice\InitializationData;
$initData->properties = Ice\createProperties();
$initData->properties->setProperty('Ice.ImplicitContext', 'Shared');
$initData->properties->setProperty('Ice.Default.EncodingVersion', '1.0');
$ICE = Ice_initialize($initData);
/*
* getImplicitContext() is not implemented for icePHP yet…
* $ICE->getImplicitContext();
* foreach ($this->contextVars as $key=>$value) {
* $ICE->getImplicitContext()->put($key, $value);
* }
* which should result in
* $ICE->getImplicitContext()->put('secret', 'ts');
* $ICE->getImplicitContext()->put('icesecret', 'ts');
*/
$ICE = Ice\initialize($initData);

try {
$this->meta = Murmur_MetaPrxHelper::checkedCast($ICE->stringToProxy(SettingsManager::getInstance()->getDbInterface_address()));
$this->meta = Murmur\MetaPrxHelper::checkedCast($ICE->stringToProxy(SettingsManager::getInstance()->getDbInterface_address()));
$this->meta = $this->meta->ice_context($this->contextVars);
//TODO: catch ProxyParseException, EndpointParseException, IdentityParseException from stringToProxy()
} catch (Ice_ConnectionRefusedException $exc) {
} catch (Ice\ConnectionRefusedException $exc) {
MessageManager::addError(tr('error_iceConnectionRefused'));
}
}
Expand All @@ -142,7 +101,7 @@ private function connect()
// to check the connection get the version (e.g. was a needed (context-)password not provided?)
try {
$this->version = $this->getVersion();
} catch (Ice_UnknownUserException $exc) {
} catch (Ice\UnknownUserException $exc) {
switch ($exc->unknown) {
case 'Murmur::InvalidSecretException':
//TODO i18n
Expand All @@ -155,7 +114,7 @@ private function connect()
MessageManager::addError('Unknown exception was thrown. Please report to the developer. Class: ' . get_class($exc) . isset($exc->unknown)?' ->unknown: '.$exc->unknown:'' . ' Stacktrage: <pre>' . $exc->getTraceAsString() . '</pre>');
break;
}
} catch (Ice_LocalException $exc) {
} catch (Ice\LocalException $exc) {
//TODO i18n
MessageManager::addError('Unknown exception was thrown. Please report to the developer. Class: ' . get_class($exc) . ' Stacktrage: <pre>' . $exc->getTraceAsString() . '</pre>');
}
Expand Down Expand Up @@ -468,13 +427,13 @@ function addUser($srvid, $name, $password, $email=null)
$tmpUid = $tmpServer->registerUser($reg->toArray());

echo TranslationManager::getInstance()->getText('doregister_success').'<br/>';
} catch(Murmur_InvalidServerException $exc) { // This is depreciated (murmur.ice)
} catch(Murmur\InvalidServerException $exc) { // This is depreciated (murmur.ice)
echo 'Invalid server. Please check your server selection.<br/><a onclick="history.go(-1); return false;" href="?page=register">go back</a><br/>If the problem persists, please contact a server admin or webmaster.<br/>';
} catch(Murmur_ServerBootedException $exc) {
} catch(Murmur\ServerBootedException $exc) {
echo 'Server is currently not running, but it has to to be able to register.<br/>Please contact a server admin';
} catch(Murmur_InvalidUserException $exc) {
} catch(Murmur\InvalidUserException $exc) {
echo 'The username you specified is probably already in use or invalid. Please try another one.<br/><a onclick="history.go(-1); return false;" href="?page=register">go back</a>';
} catch(Ice_UnknownUserException $exc) { // This should not happen
} catch(Ice\UnknownUserException $exc) { // This should not happen
echo $exc->unknown.'<br/>';
// echo '<pre>'; var_dump($exc); echo '</pre>';
}
Expand Down Expand Up @@ -530,7 +489,7 @@ function updateUserTexture($srvid, $uid, $newTexture)
}
$this->getServer($srvid)->setTexture($uid, $newTexture);
return true;
} catch(Murmur_InvalidTextureException $exc) {
} catch(Murmur\InvalidTextureException $exc) {
MessageManager::addError(tr('error_invalidTexture'));
return false;
}
Expand Down Expand Up @@ -580,7 +539,7 @@ function ban($serverId, $ip, $bits=32)

$srv = $this->getServer(intval($serverId));
$bans = $srv->getBans();
$ban = new Murmur_Ban();
$ban = new Murmur\Ban();
$ban->address = $ip;
$ban->bits = $bits;
$bans[] = $ban;
Expand Down
2 changes: 1 addition & 1 deletion themes/user/default/profile.template.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
if (isset($_GET['remove_texture'])) {
try {
ServerInterface::getInstance()->updateUserTexture($_SESSION['serverid'], $_SESSION['userid'], array());
} catch(Murmur_InvalidTextureException $exc) {
} catch(Murmur\InvalidTextureException $exc) {
MessageManager::addWarning(tr('profile_removetexturefailed'));
}
}
Expand Down
2 changes: 1 addition & 1 deletion user/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// Check for running Ice with Murmur
try {
ServerInterface::getInstance();
} catch(Ice_UnknownLocalException $ex) {
} catch(Ice\UnknownLocalException $ex) {
MessageManager::addError(tr('error_noIce'));
MessageManager::echoAll();
exit();
Expand Down
2 changes: 1 addition & 1 deletion viewer/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// Check for running Ice with Murmur
try {
ServerInterface::getInstance();
} catch(Ice_UnknownLocalException $ex) {
} catch(Ice\UnknownLocalException $ex) {
MessageManager::addError(tr('error_noIce'));
MessageManager::echoAll();
exit();
Expand Down

0 comments on commit 992fb7f

Please sign in to comment.