当前位置: 首页>>代码示例>>PHP>>正文


PHP Network::runcmd方法代码示例

本文整理汇总了PHP中Network::runcmd方法的典型用法代码示例。如果您正苦于以下问题:PHP Network::runcmd方法的具体用法?PHP Network::runcmd怎么用?PHP Network::runcmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Network的用法示例。


在下文中一共展示了Network::runcmd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: while

 while ($row_unf = mysql_fetch_array($result_unf)) {
     $this_tpl = $row_unf['id'];
     $this_netid = $row_unf['netid'];
     $cur_status = $row_unf['status'];
     // Set orig id first run
     if ($cntr == 1) {
         $orig_netid = $this_netid;
     }
     // New net server or last in output; SSH into previous and run all tpl ids
     if ($orig_netid != $this_netid && $cntr >= 1) {
         // SSH into previous net server
         $tpl_list = substr($tpl_list, 0, -1);
         // Lose last comma
         $net_arr = $Network->netinfo($orig_netid);
         $net_cmd = "CheckTemplates -i \"{$tpl_list}\"";
         $cmd_out = $Network->runcmd($orig_netid, $net_arr, $net_cmd, true);
         // Decode JSON response
         $out_arr = json_decode($cmd_out, true);
         foreach ($out_arr as $this_tplid => $this_status) {
             if ($this_status != 'running' && $this_status != 'complete') {
                 continue;
             }
             // Skip if bad syntax
             // Only if newer
             if ($cur_status != $this_status) {
                 $updated = true;
                 @mysql_query("UPDATE templates SET status = '{$this_status}' WHERE id = '{$this_tplid}'") or die('Failed to update template check!');
             }
         }
         // Save new netid and tplid for later
         $orig_netid = $this_netid;
开发者ID:milecar91,项目名称:GamePanelX-V3,代码行数:31,代码来源:template_actions.php

示例2: create_newdir

 public function create_newdir($srvid, $dir_name)
 {
     if (empty($dir_name)) {
         return 'No directory name 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);
     // Get real server info
     require DOCROOT . '/includes/classes/servers.php';
     $Servers = new Servers();
     $srvinfo = $Servers->getinfo($srvid);
     $net_game_ip = $netinfo['game_ip'];
     $net_local = $netinfo['is_local'];
     $net_gameuser = $srvinfo[0]['username'];
     $net_game_port = $srvinfo[0]['port'];
     // Add full path to dir
     if (isset($_SESSION['curdir'])) {
         $dir_name = $_SESSION['curdir'] . '/' . $dir_name;
     }
     // Get userdir
     if ($net_local) {
         $localdir = DOCROOT . '/_SERVERS/';
         $game_dir = $localdir . '/accounts/' . $net_gameuser . '/' . $net_game_ip . '.' . $net_game_port . '/' . $dir_name;
         // Check existing
         if (file_exists($game_dir)) {
             die('Sorry, that directory already exists!');
         }
         // Create directory
         if (!mkdir($game_dir)) {
             return 'Failed to create the directory (' . $game_dir . ')!';
         } else {
             return 'success';
         }
     } else {
         // Save File
         $run_cmd = "CreateDirectory -u {$net_gameuser} -i {$net_game_ip} -p {$net_game_port} -d \"{$dir_name}\"";
         // Run the command, return output
         return $Network->runcmd($this_netid, $netinfo, $run_cmd, true, $srvid);
     }
 }
开发者ID:fritz-net,项目名称:GamePanelX-V3,代码行数:48,代码来源:files.php

示例3: delete

 public function delete($userid)
 {
     if (empty($userid)) {
         return 'No User ID given!';
     }
     // Check if user even exists
     $result_uex = @mysql_query("SELECT username FROM users WHERE id = '{$userid}' LIMIT 1");
     $row_uex = mysql_fetch_row($result_uex);
     $uex_username = $row_uex[0];
     if (empty($uex_username)) {
         return 'That user account no longer exists!';
     }
     // Not if they have servers
     $result_net = @mysql_query("SELECT netid FROM servers WHERE userid = '{$userid}' ORDER BY id DESC LIMIT 1");
     $row_net = mysql_fetch_row($result_net);
     $latest_netid = $row_net[0];
     if ($latest_netid) {
         return 'This user has server(s) on their account!  Move the server(s) to another user or delete them and try again.';
     }
     // Admins only
     if (isset($_SESSION['gpx_admin'])) {
         @mysql_query("UPDATE users SET deleted = '1' WHERE id = '{$userid}'") or die('Failed to delete the user');
     } else {
         return 'You are not authorized to do this!';
     }
     #############################################
     // Delete SSO account
     $result_net = @mysql_query("SELECT id FROM network WHERE parentid = '0' AND is_local = '0' ORDER BY ip ASC");
     require DOCROOT . '/includes/classes/network.php';
     $Network = new Network();
     while ($row_net = mysql_fetch_array($result_net)) {
         $netid = $row_net['id'];
         $net_arr = $Network->netinfo($netid);
         // Setup delete command
         $net_cmd = "DeleteUser -u '{$uex_username}'";
         $delete_result = $Network->runcmd($netid, $net_arr, $net_cmd, true);
         // Account didn't exist...don't warn
         if ($delete_result == 'That user does not exist, exiting.') {
             return 'success';
         } elseif ($delete_result != 'success') {
             return 'Failed to delete user on network server ' . $netid . ': ' . $delete_result;
         }
     }
     #############################################
     return 'success';
 }
开发者ID:milecar91,项目名称:GamePanelX-V3,代码行数:46,代码来源:users.php

示例4: delete

 public function delete($tplid)
 {
     if (empty($tplid)) {
         return 'Delete: No template ID provided!';
     }
     // Get netid
     $result_nid = @mysql_query("SELECT netid FROM templates WHERE id = '{$tplid}' LIMIT 1");
     $row_nid = mysql_fetch_row($result_nid);
     $netid = $row_nid[0];
     // Delete from DB
     @mysql_query("DELETE FROM templates WHERE id = '{$tplid}'") or die('Failed to delete the template row!');
     // Run network deletion
     require DOCROOT . '/includes/classes/network.php';
     $Network = new Network();
     $net_arr = $Network->netinfo($netid);
     $net_cmd = 'DeleteTemplate -i ' . $tplid;
     // Run command
     $cmd_out = $Network->runcmd($netid, $net_arr, $net_cmd, true);
     return $cmd_out;
 }
开发者ID:milecar91,项目名称:GamePanelX-V3,代码行数:20,代码来源:templates.php

示例5: configupdate


//.........这里部分代码省略.........
         $net_local = $net_info['is_local'];
         // Clients dont access port/maxplayers, so replace with current known ones
         if (!isset($_SESSION['gpx_admin'])) {
             $url_port = $orig_port;
             $url_maxpl = $orig_maxpl;
         }
         // Local Server
         if ($net_local) {
             $cfg_file = DOCROOT . '/_SERVERS/' . $_SESSION['gamesrv_root'] . '/' . stripslashes($config_file);
             if (GPXDEBUG) {
                 echo 'DEBUG: Opening config file for reading: ' . $cfg_file . '<br>';
             }
             $fh = fopen($cfg_file, 'r');
             $file_lines = fread($fh, 4096);
             fclose($fh);
             if (GPXDEBUG) {
                 echo 'DEBUG: Config lines: ' . $file_lines . '<br>';
             }
             // Lose excess newlines
             $file_lines = preg_replace("/\n+/", "\n", $file_lines);
             $arr_lines = explode("\n", $file_lines);
             $new_file = '';
             foreach ($arr_lines as $file_lines) {
                 // XML Configs (such as Multi-Theft Auto/MTA).  Set "Config Separator" to "X" (caps matters) in default games to make it work with XML.
                 if ($config_sepa == 'X') {
                     if (!empty($cfg_ip)) {
                         $file_lines = preg_replace("/<{$cfg_ip}>.*/", "<{$cfg_ip}>{$orig_ip}</{$cfg_ip}>", $file_lines);
                     }
                     if (!empty($cfg_port)) {
                         $file_lines = preg_replace("/<{$cfg_port}>.*/", "<{$cfg_port}>{$orig_port}</{$cfg_port}>", $file_lines);
                     }
                     if (!empty($cfg_map)) {
                         $file_lines = preg_replace("/<{$cfg_map}>.*/", "<{$cfg_map}>{$orig_map}</{$cfg_map}>", $file_lines);
                     }
                     if (!empty($cfg_maxpl)) {
                         $file_lines = preg_replace("/<{$cfg_maxpl}>.*/", "<{$cfg_maxpl}>{$orig_maxpl}</{$cfg_maxpl}>", $file_lines);
                     }
                     if (!empty($cfg_hostn)) {
                         $file_lines = preg_replace("/<{$cfg_hostn}>.*/", "<{$cfg_hostn}>{$orig_hostname}</{$cfg_hostn}>", $file_lines);
                     }
                     if (!empty($cfg_rcon)) {
                         $file_lines = preg_replace("/<{$cfg_rcon}>.*/", "<{$cfg_rcon}>{$orig_rcon}</{$cfg_rcon}>", $file_lines);
                     }
                     if (!empty($cfg_passw)) {
                         $file_lines = preg_replace("/<{$cfg_passw}>.*/", "<{$cfg_passw}>{$orig_sv_pass}</{$cfg_passw}>", $file_lines);
                     }
                 } else {
                     // Setup all changes
                     if (!empty($cfg_ip)) {
                         $file_lines = preg_replace("/^{$cfg_ip}.*/", $cfg_ip . $config_sepa . $orig_ip, $file_lines);
                     }
                     if (!empty($cfg_port)) {
                         $file_lines = preg_replace("/^{$cfg_port}.*/", $cfg_port . $config_sepa . $orig_port, $file_lines);
                     }
                     if (!empty($cfg_map)) {
                         $file_lines = preg_replace("/^{$cfg_map}.*/", $cfg_map . $config_sepa . $orig_map, $file_lines);
                     }
                     if (!empty($cfg_maxpl)) {
                         $file_lines = preg_replace("/^{$cfg_maxpl}.*/", $cfg_maxpl . $config_sepa . $orig_maxpl, $file_lines);
                     }
                     if (!empty($cfg_hostn)) {
                         $file_lines = preg_replace("/^{$cfg_hostn}.*/", $cfg_hostn . $config_sepa . $orig_hostname, $file_lines);
                     }
                     if (!empty($cfg_rcon)) {
                         $file_lines = preg_replace("/^{$cfg_rcon}.*/", $cfg_rcon . $config_sepa . $orig_rcon, $file_lines);
                     }
                     if (!empty($cfg_passw)) {
                         $file_lines = preg_replace("/^{$cfg_passw}.*/", $cfg_passw . $config_sepa . $orig_sv_pass, $file_lines);
                     }
                     // Minecraft - force query to true
                     if ($orig_intname == 'mcraft') {
                         $file_lines = preg_replace("/^enable\\-query.*/", 'enable-query=true', $file_lines);
                     }
                 }
                 // Finish with newline
                 $new_file .= $file_lines . "\n";
             }
             // Write changes to file
             $fh = fopen($cfg_file, 'w') or die('Failed to open local config (' . $cfg_file . ') for writing.');
             fwrite($fh, $new_file);
             fclose($fh);
         } else {
             // Double-escape some stuff
             $orig_hostname = addslashes(stripslashes($orig_hostname));
             // Add exhaustive list of config options to this script (no, the option letters dont make sense, they are random because there are so many)
             $ssh_cmd = "ConfigUpdate -x \"{$orig_port}\" -u \"{$orig_username}\" -i \"{$orig_ip}\" -p \"{$orig_port}\" -c \"{$config_file}\" -s \"{$config_sepa}\" ";
             $ssh_cmd .= "-d \"{$cfg_ip}\" -e \"{$cfg_port}\" -f \"{$cfg_map}\" -g \"{$cfg_maxpl}\" -h \"{$cfg_rcon}\" -j \"{$cfg_hostn}\" -r \"{$cfg_passw}\" ";
             $ssh_cmd .= "-k \"{$orig_ip}\" -m \"{$orig_map}\" -n \"{$orig_maxpl}\" -O \"{$orig_rcon}\" -q \"{$orig_hostname}\" -t \"{$orig_sv_pass}\"";
             require_once DOCROOT . '/includes/classes/network.php';
             $Network = new Network();
             $result_update = $Network->runcmd($orig_netid, $net_info, $ssh_cmd, true, $srvid);
             if ($result_update != 'success') {
                 return $result_update;
             } else {
                 return true;
             }
         }
     }
     return 'success';
 }
开发者ID:milecar91,项目名称:GamePanelX-V3,代码行数:101,代码来源:servers.php


注:本文中的Network::runcmd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。