Example #1
0
/**
 * Request to join the specified shard
 */
function joinSessionFromId($userId, $domainId, $destSessionId)
{
    $domainId = -1;
    if (!validateCookie($userId, $domainId, $charId)) {
        echo "Invalid cookie !";
        die;
    } else {
        echo "Welcome user {$userId}<BR>";
        $domainInfo = getDomainInfo($domainId);
        $addr = split(":", $domainInfo["session_manager_address"]);
        $RSMHost = $addr[0];
        $RSMPort = $addr[1];
        // ask join to the session manager
        $joinSession = new JoinSessionCb();
        $res = "";
        $joinSession->connect($RSMHost, $RSMPort, $res);
        //		$rsmProxy = new CRingSessionManagerWebProxy;
        //		$charSlot = getCharSlot(); // if ingame (!=15), the RSM will check if this character has the right to connect to the specified session
        //		$charId = ($userId<<4) + $charSlot;
        echo $charId . " of user " . $userId . " joigning session " . $destSessionId . "<br>";
        $joinSession->joinSession($charId, $destSessionId, $domainInfo["domain_name"]);
        // wait the the return message
        //		$rsmSkel = new CRingSessionManagerWebSkel;
        if ($joinSession->waitCallback() == false) {
            echo "No response from server, joinSession failed<br>";
        }
        die;
    }
}
Example #2
0
function inviteOwnerInSession($charId, $domainId, $sessionId)
{
    global $SessionId, $DomainId, $SessionToolsResult;
    // first, set the result to false
    $SessionToolsResult = false;
    $domainInfo = getDomainInfo($domainId);
    $addr = split(":", $domainInfo["session_manager_address"]);
    $RSMHost = $addr[0];
    $RSMPort = $addr[1];
    global $rsmProxy, $rsmSkel, $userId, $charId, $callbackClient, $RingDBName, $SessionToolsResult;
    $SessionId = $sessionId;
    $DomainId = $domainId;
    mysql_select_db($RingDBName) or die("Can't access to the db dbname:{$RingDBName}");
    $query = "select session_type from sessions where session_id=" . $sessionId;
    $result = mysql_query($query) or die("Can't execute the query: " . $query);
    if (mysql_num_rows($result) != 1) {
        echo "Can't find 1 row for ring session " . $sessionId . "<br>";
        die;
    }
    $row = mysql_fetch_row($result);
    $session_type = $row[0];
    $mode = $session_type == "st_edit" ? "sps_edit_invited" : "sps_anim_invited";
    echo "Inviting character " . $charId . " of user " . $userId . " in session " . $sessionId . "<br>";
    $inviteOwner = new InviteOwnerCb();
    $res = "";
    $inviteOwner->connect($RSMHost, $RSMPort, $res);
    $inviteOwner->inviteCharacter($charId, $sessionId, $charId, $mode);
    // wait the the return message
    if ($inviteOwner->waitCallback() == false) {
        echo "No response from server, invite failed<br>";
        die;
    }
}
Example #3
0
function validateCookie(&$userId, &$domainId, &$charId)
{
    $domainInfo = getDomainInfo($domainId);
    global $DBHost, $RingDBUserName, $RingDBPassword, $AcceptUnknownUser;
    if (!isset($_COOKIE["ryzomId"])) {
        echo "Cookie not found<BR>";
        return false;
    }
    // read the ip and compare with client ip
    $cookie = $_COOKIE["ryzomId"];
    echo "Cookie is {$cookie}<BR>";
    sscanf($cookie, "%02X%02X%02X%02X", $b0, $b1, $b2, $b3);
    $addr = $b0 + ($b1 << 8) + ($b2 << 16) + ($b3 << 24);
    printf("Addr is %X<BR>", $addr);
    $addrStr = long2ip($addr);
    echo "addrStr is {$addrStr}<br>";
    if ($_SERVER["REMOTE_ADDR"] != $addrStr) {
        echo "Client ip don't match cookie<BR>";
        return false;
    }
    // check the cookie in the database
    $link = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die("Can't connect to database host:{$DBHost} user:{$RingDBUserName}");
    mysqli_select_db($link, $domainInfo['ring_db_name']) or die("Can't access to the table dbname:" . $domainInfo['ring_db_name']);
    $cookie = mysqli_real_escape_string($link, $cookie);
    $query = "SELECT user_id, current_status, current_domain_id FROM ring_users where cookie='{$cookie}'";
    $result = mysqli_query($link, $query) or die("Can't execute the query: " . $query);
    if (mysqli_num_rows($result) == 0) {
        echo "Can't find cookie {$cookie} in database<BR>";
        return false;
    }
    $row = mysqli_fetch_assoc($result);
    if ($row["current_status"] != "cs_logged" && $row["current_status"] != "cs_online") {
        echo "User {$row['user_id']} is not looged or online<BR>";
        return false;
    }
    $userId = $row["user_id"];
    $domainId = $row["current_domain_id"];
    //		$charId = ($userId*16) + (getCharSlot()) & 0xf;
    $charId = $userId * 16 + getCharSlot();
    return true;
}
Example #4
0
        if ($resultCode != 0) {
            echo "<h1>Error " . $resultCode . " : '" . $resultString . "' will trying to close the session " . $_POST["sessionId"] . "</h1>";
            echo '<p><p><a href="web_start.php">Back to menu</a>';
        } else {
            // ok, the session is closed (or almost to close)
            echo "<h1>Session " . $_POST["sessionId"] . " is begin closed</h1>";
            echo '<p><a href="web_start.php">Return to main</a> </p>';
        }
    }
}
$domainId = -1;
if (!validateCookie($userId, $domainId, $charId)) {
    echo "Invalid cookie !";
    die;
} else {
    $domainInfo = getDomainInfo($domainId);
    $addr = split(":", $domainInfo["session_manager_address"]);
    $RSMHost = $addr[0];
    $RSMPort = $addr[1];
    // ask to start the session
    $closeSession = new CloseSessionCb();
    $res = "";
    $closeSession->connect($RSMHost, $RSMPort, $res);
    //		$rsmProxy = new CRingSessionManagerWebProxy;
    $closeSession->closeSession($charId, $_POST["sessionId"]);
    // wait the the return message
    //		$rsmSkel = new CRingSessionManagerWebSkel;
    $closeSession->waitCallback();
    die;
}
?>
Example #5
0
/**
 * Auto-join a shard.
 * Returns true in case of success, and the FSHost address in $FSHostResultStr.
 * Returns false in case of error, and an explanatory string in $FSHostResultStr.
 */
function joinMainland($userId, $domainId)
{
    $domainInfo = getDomainInfo($domainId);
    $addr = split(":", $domainInfo["session_manager_address"]);
    $RSMHost = $addr[0];
    $RSMPort = $addr[1];
    // request get to the session manager
    $joinsShard = new JoinShardCb();
    $res = "";
    $joinsShard->connect($RSMHost, $RSMPort, $res);
    // set the shard Id to allow any character (by using the special value '15')
    $charId = ($userId << 4) + 15;
    global $FSHostLuaMode, $verbose;
    if ($FSHostLuaMode && $verbose) {
        echo "Joining a mainland shard for {$charId}...<br>";
    }
    $joinsShard->joinMainland($charId, $domainInfo["domain_name"]);
    // wait the the return message
    if ($joinsShard->waitCallback() == false) {
        global $FSHostResultStr;
        $FSHostResultStr = "No response from server for joinMainland<br>";
        return false;
    }
    global $FSHostResult;
    return $FSHostResult;
}
Example #6
0
function checkUserValidity($login, $password, $clientApplication, $cp, &$id, &$reason, &$priv, &$extended, &$domainId, $lang)
{
    global $DBHost, $DBUserName, $DBPassword, $DBName, $AcceptUnknownUser;
    setMsgLanguage($lang);
    $link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die(errorMsgBlock(3004, 'main', $DBHost, $DBUserName));
    mysqli_select_db($link, $DBName) or die(errorMsgBlock(3005, 'main', $DBName, $DBHost, $DBUserName));
    // we map the client application to the domain name
    $domainName = mysqli_real_escape_string($link, $clientApplication);
    // retreive the domain id
    $query = "SELECT domain_id FROM domain WHERE domain_name='{$domainName}'";
    $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
    if (mysqli_num_rows($result) == 0) {
        // unrecoverable error, we must giveup
        $reason = errorMsg(3007, $domainName);
        mysqli_close($link);
        return false;
    }
    $row = mysqli_fetch_array($result);
    $domainId = $row[0];
    // retreive the domain info
    $domainInfo = getDomainInfo($domainId);
    // convert the domain status enum into the privilege access set
    $accessPriv = strtoupper(substr($domainInfo['status'], 3));
    // now, retrieve the user infos
    $login = mysqli_real_escape_string($link, $login);
    $query = "SELECT * FROM user where Login='******'";
    $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
    if (mysqli_num_rows($result) == 0) {
        if ($AcceptUnknownUser) {
            // login doesn't exist, create it
            $password = mysqli_real_escape_string($link, $password);
            $query = "INSERT INTO user (Login, Password) VALUES ('{$login}', '{$password}')";
            $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
            // get the user to have his UId
            $query = "SELECT * FROM user WHERE Login='******'";
            $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
            if (mysqli_num_rows($result) == 1) {
                $reason = errorMsg(3008, $login);
                $row = mysqli_fetch_assoc($result);
                $id = $row["UId"];
                $priv = $row["Privilege"];
                $extended = $row["ExtendedPrivilege"];
                // add the default permission
                $query = "INSERT INTO permission (UId, DomainId, AccessPrivilege) VALUES ('{$id}', '{$domainId}', '{$accessPriv}')";
                $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
                $res = false;
            } else {
                $reason = errorMsg(3009, $login);
                $res = false;
            }
        } else {
            $reason = errorMsg(2001, $login, 'checkUserValidity');
        }
    } else {
        $row = mysqli_fetch_assoc($result);
        $salt = get_salt($row["Password"]);
        if ($cp && $row["Password"] == $password || !$cp && $row["Password"] == crypt($password, $salt)) {
            // Store the real login (with correct case)
            $_GET['login'] = $row['Login'];
            // check if the user can use this application
            $clientApplication = mysqli_real_escape_string($link, $clientApplication);
            $query = "SELECT * FROM permission WHERE UId='" . $row["UId"] . "' AND DomainId='{$domainId}'";
            $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
            if (mysqli_num_rows($result) == 0) {
                if ($AcceptUnknownUser) {
                    // add default permission
                    $query = "INSERT INTO permission (UId, DomainId, ShardId, AccessPrivilege) VALUES ('" . $row["UId"] . "', '{$domainId}', -1, '{$domainStatus}')";
                    $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
                    $reason = errorMsg(3010);
                    $res = false;
                } else {
                    // no permission
                    $reason = errorMsg(3011, $clientApplication, $domainName);
                    $res = false;
                }
            } else {
                // check that the access privilege for the domain
                $permission = mysqli_fetch_assoc($result);
                if (!strstr($permission['AccessPrivilege'], $accessPriv)) {
                    // no right to connect
                    if ($AcceptUnknownUser) {
                        // set an additionnal privilege for this player
                        $query = "UPDATE permission set AccessPrivilege='" . $permission['AccessPrivilege'] . ",{$accessPriv}' WHERE PermissionId=" . $permission['PermissionId'];
                        $result = mysqli_query($link, $query) or die(errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link)));
                        $reason = errorMsg(3012, $accessPriv);
                        $res = false;
                    } else {
                        // no permission
                        $reason = errorMsg(3013, $clientApplication, $domainName, $accessPriv);
                        $res = false;
                    }
                } else {
                    //						// check if the user not already online
                    //
                    //						if ($row["State"] != "Offline")
                    //						{
                    //							$reason = "$login is already online and ";
                    //							// ask the LS to remove the client
                    //							if (disconnectClient ($row["ShardId"], $row["UId"], $tempres))
                    //							{
                    //								$reason =  $reason."was just disconnected. Now you can retry the identification (error code 54)";
                    //
                    //								$query = "update shard set NbPlayers=NbPlayers-1 where ShardId=".$row["ShardId"];
                    //								$result = mysqli_query ($link, $query) or die ("Can't execute the query: '$query' errno:".mysqli_errno($link).": ".mysqli_error($link));
                    //
                    //								$query = "update user set ShardId=-1, State='Offline' where UId=".$row["UId"];
                    //								$result = mysqli_query ($link, $query) or die ("Can't execute the query: '$query' errno:".mysqli_errno($link).": ".mysqli_error($link));
                    //							}
                    //							else
                    //							{
                    //								$reason = $reason."can't be disconnected: $tempres (error code 55)";
                    //							}
                    //							$res = false;
                    //						}
                    //						else
                    //						{
                    $id = $row["UId"];
                    $priv = $row["Privilege"];
                    $extended = $row["ExtendedPrivilege"];
                    $res = true;
                    //						}
                }
            }
        } else {
            $reason = errorMsg(2004, 'user');
            $res = false;
        }
    }
    mysqli_close($link);
    return $res;
}
}
function getDomainInfo()
{
    $url = 'https://dnsapi.cn/Domain.List';
    $config = array('login_email' => '*****@*****.**', 'login_password' => 'pdcxaje127', 'format' => 'json', 'lang' => 'cn', 'error_on_empty' => 'no');
    $post_data = post_data($url, $config);
    return json_decode($post_data, true);
}
function getIp()
{
    $myip = file_get_contents('http://ip.taobao.com/service/getIpInfo2.php?ip=myip');
    $ipInfo = json_decode($myip, true);
    $ip = $ipInfo['data']['ip'];
    return $ip;
}
$domainInfo = getDomainInfo();
$domianId = $domainInfo['domains'][0]['id'];
$records = domainList($domainInfo['domains'][0]['id']);
$myIp = getIp();
foreach ($records['records'] as $k => $v) {
    if (in_array($v['name'], array('pi-phpmyadmin', 'pi-order', 'www')) && $v['value'] !== $myIp) {
        $para = array('domain_id' => $domainInfo['domains'][0]['id'], 'record_id' => $v['id'], 'sub_domain' => $v['name'], 'value' => $myIp, 'record_type' => $v['type'], 'record_line' => $v['line']);
        $status = updateDomain($para);
        if (intval($status['status']['code']) === 1) {
            echo $v['name'] . '修改成功! 原因:ip不一致原始绑定IP:' . $v['value'] . ', 当前服务器IP:' . $myIp, PHP_EOL;
        }
    } else {
        if (in_array($v['name'], array('pi-phpmyadmin', 'pi-order', 'www')) && $v['value'] === $myIp) {
            echo '子域名:' . $v['name'] . '不需要进行修改!', PHP_EOL;
        }
    }
Example #8
0
                return JText::_('no matching record.');
                break;
            case "Queried interval is too short.":
                return JText::_('Queried interval is too short.');
                break;
            case "the domain you want to register is reserved.":
                return JText::_('the domain you want to register is reserved.');
                break;
                //未定义的输出语句项目直接输出
            //未定义的输出语句项目直接输出
            default:
                return $response;
                break;
        }
    }
    //域名信息为复句时
    return $response;
}
//
$name = JRequest::getVar('name');
$suffixs = JRequest::getVar('suffixs');
//
if ($suffixs && $name) {
    echo "" . '<dl>';
    foreach ($suffixs as $key => $suffix) {
        echo "\n  " . '<dt>' . $name . '.' . $suffix . '</dt>';
        $info = "" . getDomainInfo($name . '.' . $suffix, 'whois.cnnic.net.cn');
        echo "\n  " . '<dd><pre>' . $info . '</pre></dd>';
    }
    echo "\n" . '</dl>';
}
Example #9
0
#!/usr/bin/php
<?php 
define("FROXLOR_HOME", "/var/www/froxlor");
define("SCRIPT_HOME", "/etc/nginx/scripts");
define("NGINX_VHOST_PATH", "/etc/nginx/sites-enabled");
// Load Userdata
require_once FROXLOR_HOME . '/lib/userdata.inc.php';
// Set vars
$froxlor_db = $sql['db'];
$froxlor_host = $sql['host'];
$froxlor_user = $sql['user'];
$froxlor_pass = $sql['password'];
// Include info functions
require_once SCRIPT_HOME . '/get_infos.php';
// Include vhost function
require_once SCRIPT_HOME . '/create_vhosts.php';
create_vhosts(getDomainInfo());