本文整理汇总了PHP中Network::sso_info方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::sso_info方法的具体用法?PHP Network::sso_info怎么用?PHP Network::sso_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::sso_info方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_newfile
public function save_newfile($srvid, $file, $content)
{
if (empty($file)) {
return 'No filename given!';
}
// Get network ID
$result_nid = @mysql_query("SELECT netid FROM servers WHERE id = '{$srvid}'");
$row_nid = mysql_fetch_row($result_nid);
$this_netid = $row_nid[0];
if (empty($this_netid)) {
return 'Failed to get network ID!';
}
require DOCROOT . '/includes/classes/network.php';
$Network = new Network();
$netinfo = $Network->netinfo($this_netid);
#$net_game_ip = $netinfo['game_ip'];
#$net_game_port = $netinfo['game_port'];
#$net_gameuser = $netinfo['username'];
$net_local = $netinfo['is_local'];
// Get real server info
require DOCROOT . '/includes/classes/servers.php';
$Servers = new Servers();
$srvinfo = $Servers->getinfo($srvid);
$net_game_ip = $srvinfo[0]['ip'];
$net_gameuser = $srvinfo[0]['username'];
$net_game_port = $srvinfo[0]['port'];
// Add full path to file
if (isset($_SESSION['curdir'])) {
$file = $_SESSION['curdir'] . '/' . $file;
}
// Get userdir
if ($net_local) {
$localdir = DOCROOT . '/_SERVERS/';
$game_dir = $localdir . '/accounts/' . $net_gameuser . '/' . $net_game_ip . '.' . $net_game_port . '/' . $file;
// Stupid newlines, this took forever to figure out '\\\n/' - either jquery caused this or the textarea did, no idea
$content = preg_replace('/\\\\n/', "\n", $content);
$content = stripslashes($content);
// Write to file
$fh = fopen($game_dir, "w") or die('Failed to open file for writing!');
fwrite($fh, $content);
fclose($fh);
return 'success';
} else {
#$file_path = $netinfo['ssh_homedir'] . "/accounts/$net_gameuser/$net_game_ip\.$net_game_port/$file";
// Get SSO info
$sso_info = $Network->sso_info($srvid);
$file_path = $sso_info['game_path'] . '/' . $file;
// Save File
$run_cmd = 'FileSave -f ' . $file_path . ' -c "' . $content . '"';
// Run the command, return output
return $Network->runcmd($this_netid, $netinfo, $run_cmd, true, $srvid);
}
}
示例2: create
//.........这里部分代码省略.........
} else {
$def_maxplayers = mysql_real_escape_string($row_dfts[0]);
}
// Generate random rcon password if not specified
if (empty($rcon_password)) {
$rcon_password = $Core->genstring('8');
}
#########################################################################################
// If local, ensure we can write to the _SERVERS/accounts directory
$result_loc = @mysql_query("SELECT is_local FROM network WHERE id = '{$netid}' LIMIT 1");
$row_loc = mysql_fetch_row($result_loc);
$net_local = $row_loc[0];
if ($net_local && !is_writable(DOCROOT . '/_SERVERS/accounts')) {
die('Error: Unable to write to the "' . DOCROOT . '/_SERVERS/accounts" directory. Check that this directory is recursively owned by your webserver user, and try again.');
}
#########################################################################################
// Insert into db
@mysql_query("INSERT INTO servers (userid,netid,defid,port,maxplayers,status,date_created,token,working_dir,pid_file,update_cmd,description,map,rcon,hostname,sv_password) VALUES('{$ownerid}','{$netid}','{$gameid}','{$port}','{$def_maxplayers}','installing',NOW(),'{$remote_token}','{$def_working_dir}','{$def_pid_file}','{$def_update_cmd}','{$description}','{$def_map}','{$rcon_password}','{$def_hostname}','{$private_password}')") or die('Failed to insert server: ' . mysql_error());
$srv_id = mysql_insert_id();
// Insert default srv settings
$result_smp = @mysql_query("SELECT * FROM default_startup WHERE defid = '{$gameid}' ORDER BY sort_order ASC");
$total_strt = mysql_num_rows($result_smp);
$insert_new = 'INSERT INTO servers_startup (srvid,sort_order,single,usr_edit,cmd_item,cmd_value) VALUES ';
$simplecmd = '';
while ($row_smp = mysql_fetch_array($result_smp)) {
$cmd_sort = $row_smp['sort_order'];
$cmd_single = $row_smp['single'];
$cmd_usred = $row_smp['usr_edit'];
$cmd_item = $row_smp['cmd_item'];
$cmd_val = $row_smp['cmd_value'];
$insert_new .= "('{$srv_id}','{$cmd_sort}','{$cmd_single}','{$cmd_usred}','{$cmd_item}','{$cmd_val}'),";
// Replace %vars% for simplecmd
$cmd_val = str_replace('%IP%', $this_ip, $cmd_val);
$cmd_val = str_replace('%PORT%', $port, $cmd_val);
$cmd_val = str_replace('%MAP%', $def_map, $cmd_val);
$cmd_val = str_replace('%MAXPLAYERS%', $def_maxplayers, $cmd_val);
$cmd_val = str_replace('%HOSTNAME%', $def_hostname, $cmd_val);
// Update simplecmd
$simplecmd .= $cmd_item . ' ';
if ($cmd_val || $cmd_val == '0') {
$simplecmd .= $cmd_val . ' ';
}
}
// Run multi-insert (only if there were default startup items)
if ($total_strt) {
// Remove last comma
$insert_new = substr($insert_new, 0, -1);
@mysql_query($insert_new) or die('Failed to insert startup items: ' . mysql_error());
}
// Add simplecmd
if (empty($simplecmd)) {
$simplecmd = $def_simple_cmd;
}
@mysql_query("UPDATE servers SET simplecmd = '{$simplecmd}' WHERE id = '{$srv_id}'");
############################################################################################
// Get callback page
$this_url = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
$this_page = str_replace('ajax/ajax.php', '', $this_url);
$this_page = str_replace('api/api.php', '', $this_page);
$this_page .= '/includes/callback.php?token=' . $remote_token . '&id=' . $srv_id;
$this_page = preg_replace('/\\/+/', '/', $this_page);
// Remove extra slashes
$this_page = 'http://' . $this_page;
############################################################################################
//
// Create on Remote server
//
// Check via 'gpx' user if account exists, create if needed, THEN run CreateServer. Cannot add this functionality to CreateServer as CreateServer is run by the gpxblah accounts.
if (!$net_local) {
$sso_info = $Network->sso_info($srv_id);
$sso_user = substr($sso_info['sso_user'], 3);
// Lose the 'gpx' prefix
$sso_pass = $sso_info['sso_pass'];
// Remote: Create the system user account if needed. Okay if it already exists.
$crypt_pass = crypt($sso_pass);
$net_cmd = "CreateUser -u '{$sso_user}' -p '{$crypt_pass}'";
$create_result = $Network->runcmd($netid, $net_arr, $net_cmd, true);
// Proceed if the user exists, or it was successfully created
if ($create_result == 'success') {
// Allow GPXManager to create the account
sleep(4);
} elseif (!preg_match('/That user already exists/', $create_result)) {
// Failed, delete this server
$this->delete_soft($srv_id);
die('Failed to create the user account for this server (' . $create_result . ') exiting.');
}
}
$net_cmd = "CreateServer -u {$this_usrname} -i {$this_ip} -p {$port} -x {$this_tplid} -c \"{$this_page}\"";
$result_net_create = $Network->runcmd($netid, $net_arr, $net_cmd, true, $srv_id);
#################
if ($result_net_create != 'success') {
// Failed on Remote Creation; delete this server
#@mysql_query("DELETE FROM servers WHERE id = '$srv_id'") or die('Failed to delete the server from the database');
#@mysql_query("DELETE FROM servers_startup WHERE srvid = '$srv_id'") or die('Failed to delete the server startups from the database');
$this->delete_soft($srv_id);
return 'Remote Failed: ' . $result_net_create;
} else {
return 'success';
}
}