Guest User

Bukget in Bgpanel #2

a guest
Aug 30th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.28 KB | None | 0 0
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5. * LICENSE:
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. *
  20. * @categories Games/Entertainment, Systems Administration
  21. * @package Bright Game Panel
  22. * @author warhawk3407 <warhawk3407@gmail.com> @NOSPAM
  23. * @copyleft 2013
  24. * @license GNU General Public License version 3.0 (GPLv3)
  25. * @version (Release 0) DEVELOPER BETA 9
  26. * @link http://www.bgpanel.net/
  27. */
  28.  
  29.  
  30.  
  31. $page = 'server';
  32. $tab = 2;
  33. $isSummary = TRUE;
  34.  
  35. if ( !isset($_GET['id']) || !is_numeric($_GET['id']) )
  36. {
  37. header( 'Location: index.php' );
  38. die();
  39. }
  40.  
  41. $return = 'server.php';
  42.  
  43.  
  44. require("configuration.php");
  45. require("include.php");
  46. require("./libs/lgsl/lgsl_class.php");
  47.  
  48. require("./includes/func.ssh2.inc.php");
  49. require_once("./libs/phpseclib/Crypt/AES.php");
  50.  
  51.  
  52. $title = T_('Server Summary');
  53.  
  54. $serverid = mysql_real_escape_string($_GET['id']);
  55.  
  56.  
  57. if (query_numrows( "SELECT `name` FROM `".DBPREFIX."server` WHERE `serverid` = '".$serverid."'" ) == 0)
  58. {
  59. exit('Error: ServerID is invalid.');
  60. }
  61.  
  62.  
  63. $rows = query_fetch_assoc( "SELECT * FROM `".DBPREFIX."server` WHERE `serverid` = '".$serverid."' LIMIT 1" );
  64. $serverIp = query_fetch_assoc( "SELECT `ip` FROM `".DBPREFIX."boxIp` WHERE `ipid` = '".$rows['ipid']."' LIMIT 1" );
  65. $box = query_fetch_assoc( "SELECT * FROM `".DBPREFIX."box` WHERE `boxid` = '".$rows['boxid']."' LIMIT 1" );
  66. $type = query_fetch_assoc( "SELECT `querytype` FROM `".DBPREFIX."game` WHERE `gameid` = '".$rows['gameid']."' LIMIT 1");
  67. $game = query_fetch_assoc( "SELECT `game` FROM `".DBPREFIX."game` WHERE `gameid` = '".$rows['gameid']."' LIMIT 1" );
  68. $group = query_fetch_assoc( "SELECT `name` FROM `".DBPREFIX."group` WHERE `groupid` = '".$rows['groupid']."' LIMIT 1" );
  69. $logs = mysql_query( "SELECT * FROM `".DBPREFIX."log` WHERE `serverid` = '".$serverid."' ORDER BY `logid` DESC LIMIT 15" );
  70.  
  71.  
  72. //---------------------------------------------------------+
  73.  
  74.  
  75. $checkGroup = checkClientGroup($rows['groupid'], $_SESSION['clientid']);
  76.  
  77. if ($checkGroup == FALSE)
  78. {
  79. $_SESSION['msg1'] = T_('Error!');
  80. $_SESSION['msg2'] = T_('This is not your server!');
  81. $_SESSION['msg-type'] = 'error';
  82. header( 'Location: index.php' );
  83. die();
  84. }
  85.  
  86.  
  87. //---------------------------------------------------------+
  88.  
  89.  
  90. include("./bootstrap/header.php");
  91.  
  92.  
  93. /**
  94. * Notifications
  95. */
  96. include("./bootstrap/notifications.php");
  97.  
  98.  
  99. ?>
  100. <div class="tabbable">
  101. <ul class="nav nav-tabs">
  102. <li <?php if(!isset($_GET['s']) || empty($_GET['s'])){ ?>class="active"<?php }?>><a href="#1" data-toggle="tab"><?php echo T_('Server Summary'); ?></a></li>
  103. <li><a href="#2" data-toggle="tab"><?php echo T_('Server Control Panel'); ?></a></li>
  104. <?php
  105.  
  106. if ($type['querytype'] != 'none')
  107. {
  108. echo "\t\t\t\t\t<li><a href=\"#3\" data-toggle=\"tab\">LGSL</a></li>";
  109. }
  110.  
  111. ?>
  112.  
  113. <?php
  114.  
  115. if ($rows['panelstatus'] == 'Started')
  116. {
  117. echo "\t\t\t\t\t<li><a href=\"utilitiesrcontool.php?serverid=".$serverid."\">".T_('RCON Tool')."</a></li>";
  118. }
  119.  
  120. if($rows['panelstatus'] != 'Started' && strcmp($game['game'], "Minecraft") == 0)
  121. {
  122. if(!isset($_GET['s']) || empty($_GET['s']))
  123. echo "\t\t\t\t\t<li><a href=\"#6\" data-toggle=\"tab\">Bukkit Plugins</a></li>";
  124. else
  125. echo "\t\t\t\t\t<li class=\"active\"><a href=\"#6\" data-toggle=\"tab\">Bukkit Plugins</a></li>";
  126. }
  127. ?>
  128.  
  129. <li><a href="#5" data-toggle="tab"><?php echo T_('Activity Logs'); ?></a></li>
  130. </ul>
  131. <div class="tab-content">
  132. <div class="tab-pane <?php if(!isset($_GET['s']) || empty($_GET['s'])){ ?>active<?php } ?>" id="1">
  133. <div class="row-fluid">
  134. <div class="span6">
  135. <div class="well">
  136. <div style="text-align: center; margin-bottom: 5px;">
  137. <span class="label label-info"><?php echo T_('Server Information'); ?></span>
  138. </div>
  139. <table class="table table-striped table-bordered table-condensed">
  140. <tr>
  141. <td><?php echo T_('Name'); ?></td>
  142. <td><?php echo htmlspecialchars($rows['name'], ENT_QUOTES); ?></td>
  143. </tr>
  144. <tr>
  145. <td><?php echo T_('Status'); ?></td>
  146. <td><?php echo formatStatus($rows['status']); ?></td>
  147. </tr>
  148. <tr>
  149. <td><?php echo T_('Owner Group'); ?></td>
  150. <td><?php echo htmlspecialchars($group['name'], ENT_QUOTES); ?></td>
  151. </tr>
  152. <tr>
  153. <td><?php echo T_('Game'); ?></td>
  154. <td><?php echo htmlspecialchars($game['game'], ENT_QUOTES); ?></td>
  155. </tr>
  156. <tr>
  157. <td><?php echo T_('IP Address'); ?></td>
  158. <td><?php echo $serverIp['ip']; ?></td>
  159. </tr>
  160. <tr>
  161. <td><?php echo T_('Port'); ?></td>
  162. <td><?php echo $rows['port']; ?></td>
  163. </tr>
  164. <tr>
  165. <td><?php echo T_('Query Port'); ?></td>
  166. <td><?php echo $rows['queryport']; ?></td>
  167. </tr>
  168. <tr>
  169. <td><?php echo T_('Slots'); ?></td>
  170. <td><?php echo $rows['slots']; ?></td>
  171. </tr>
  172. </table>
  173. </div>
  174. </div>
  175. <div class="span6">
  176. <div class="well">
  177. <div style="text-align: center; margin-bottom: 5px;">
  178. <span class="label label-info"><?php echo T_('Server Configuration'); ?></span>
  179. </div>
  180. <table class="table table-striped table-bordered table-condensed">
  181. <tr>
  182. <td><?php echo T_('Priority'); ?></td>
  183. <td colspan="2"><?php echo $rows['priority']; ?></td>
  184. </tr>
  185. <tr>
  186. <td><?php echo T_('Start Command'); ?></td>
  187. <td colspan="2"><?php echo htmlspecialchars($rows['startline'], ENT_QUOTES); ?></td>
  188. </tr>
  189. <tr>
  190. <td><?php echo T_('Directory'); ?></td>
  191. <td colspan="2"><?php echo htmlspecialchars(dirname($rows['path']), ENT_QUOTES); ?></td>
  192. </tr>
  193. <tr>
  194. <td><?php echo T_('Executable'); ?></td>
  195. <td colspan="2"><?php echo htmlspecialchars(basename($rows['path']), ENT_QUOTES); ?></td>
  196. </tr>
  197. <tr>
  198. <td><?php echo T_('Screen Name'); ?></td>
  199. <td colspan="2"><?php echo $rows['screen']; ?></td>
  200. </tr>
  201. <?php
  202.  
  203. $n = 1;
  204. while ($n < 10)
  205. {
  206. if (!empty($rows['cfg'.$n.'name']) || !empty($rows['cfg'.$n]))
  207. {
  208. ?>
  209. <tr>
  210. <td><?php echo htmlspecialchars($rows['cfg'.$n.'name'], ENT_QUOTES); ?></td>
  211. <td><?php echo htmlspecialchars($rows['cfg'.$n.''], ENT_QUOTES); ?></td>
  212. <td>{cfg<?php echo $n; ?>}</td>
  213. </tr>
  214. <?php
  215. }
  216. ++$n;
  217. }
  218. unset($n);
  219.  
  220. ?>
  221. </table>
  222. </div>
  223. </div>
  224. </div>
  225. <div class="row">
  226. <div class="span6">
  227. <div class="well">
  228. <div style="text-align: center; margin-bottom: 5px;">
  229. <span class="label label-info"><?php echo T_('Server Monitoring'); ?></span>
  230. </div>
  231. <table class="table table-striped table-bordered table-condensed">
  232. <tr>
  233. <td><?php echo T_('Query Type'); ?></td>
  234. <td><?php echo $type['querytype']; ?></td>
  235. </tr>
  236. <tr>
  237. <td><?php echo T_('Panel Status'); ?></td>
  238. <td><?php echo formatStatus($rows['panelstatus']); ?></td>
  239. </tr>
  240. <?php
  241.  
  242. if (($rows['status'] == 'Active') && ($rows['panelstatus'] == 'Started'))
  243. {
  244. //---------------------------------------------------------+
  245. //Querying the server
  246. $server = lgsl_query_live($type['querytype'], $serverIp['ip'], NULL, $rows['queryport'], NULL, 's');
  247. //
  248. //---------------------------------------------------------+
  249. }
  250.  
  251. ?>
  252. <tr>
  253. <td><?php echo T_('Net Status'); ?></td>
  254. <td><?php
  255.  
  256. if (@$server['b']['status'] == '1')
  257. {
  258. echo formatStatus('Online');
  259. }
  260. else
  261. {
  262. echo formatStatus('Offline');
  263. }
  264.  
  265. ?></td>
  266. </tr>
  267. <tr>
  268. <td><?php echo T_('Map'); ?></td>
  269. <td><?php echo @$server['s']['map']; ?></td>
  270. </tr>
  271. <tr>
  272. <td><?php echo T_('Players'); ?></td>
  273. <td><?php echo @$server['s']['players']; ?> / <?php echo @$server['s']['playersmax']; ?></td>
  274. </tr>
  275. </table>
  276. </div>
  277. </div>
  278. </div>
  279. </div>
  280. <div class="tab-pane" id="2">
  281. <div class="row">
  282. <div class="span12">
  283. <div class="well">
  284. <div style="text-align: center; margin-bottom: 5px;">
  285. <span class="label label-info"><?php echo T_('Server Control Panel'); ?></span>
  286. </div>
  287. <?php
  288.  
  289. if ($rows['status'] == 'Pending')
  290. {
  291. ?>
  292. <div class="alert alert-info">
  293. <h4 class="alert-heading"><?php echo T_('Server not validated !'); ?></h4>
  294. <p>
  295. <?php echo T_('An administrator must validate the server in order to use it.'); ?>
  296. </p>
  297. </div>
  298. <?php
  299. }
  300. else if ($rows['status'] == 'Inactive')
  301. {
  302. ?>
  303. <div class="alert alert-block" style="text-align: center;">
  304. <h4 class="alert-heading"><?php echo T_('The server has been disabled !'); ?></h4>
  305. </div>
  306. <?php
  307. }
  308. else if ($rows['status'] == 'Active')
  309. {
  310.  
  311. //---------------------------------------------------------+
  312.  
  313. ?>
  314. <table class="table">
  315. <tr>
  316. <td><?php echo T_('Path'); ?></td>
  317. <td><?php echo T_('Screen Name'); ?></td>
  318. <td><?php echo T_('Box'); ?></td>
  319. <td><?php echo T_('IP:Port'); ?></td>
  320. <td><?php echo T_('Panel Status'); ?></td>
  321. <td><?php echo T_('Net Status'); ?></td>
  322. </tr>
  323. <tr>
  324. <td><?php echo htmlspecialchars($rows['path'], ENT_QUOTES); ?></td>
  325. <td><?php echo $rows['screen']; ?></td>
  326. <td><?php echo htmlspecialchars($box['name'], ENT_QUOTES); ?></td>
  327. <td><?php echo $serverIp['ip'].':'.$rows['port']; ?></td>
  328. <td><?php echo formatStatus($rows['panelstatus']); ?></td>
  329. <td><?php
  330.  
  331. if (@$server['b']['status'] == '1')
  332. {
  333. echo formatStatus('Online');
  334. }
  335. else
  336. {
  337. echo formatStatus('Offline');
  338. }
  339. unset($server);
  340.  
  341. ?></td>
  342. </tr>
  343. </table>
  344. <div style="text-align: center;">
  345. <?php
  346.  
  347. if ($rows['panelstatus'] == 'Stopped') //The server has been validated and is marked as offline, the only available action is to start it
  348. {
  349. ?>
  350. <a href="serverprocess.php?task=serverstart&serverid=<?php echo $serverid; ?>" class="btn btn-primary"><i class="icon-play icon-white"></i>&nbsp;<?php echo T_('Start'); ?></a>
  351. <?php
  352. }
  353. else if ($rows['panelstatus'] == 'Started') //The server has been validated and is marked as online, the available actions are to restart or to stop it
  354. {
  355. ?>
  356. <a href="serverprocess.php?task=serverstop&serverid=<?php echo $serverid; ?>" class="btn btn-warning"><i class="icon-stop icon-white"></i>&nbsp;<?php echo T_('Stop'); ?></a>
  357. <a href="serverprocess.php?task=serverreboot&serverid=<?php echo $serverid; ?>" class="btn btn-primary"><i class="icon-repeat icon-white"></i>&nbsp;<?php echo T_('Restart'); ?></a>
  358. <?php
  359. }
  360.  
  361. ?>
  362. <a href="#" class="btn btn-primary" onclick="dlScrLog();return false;"><i class="icon-download-alt icon-white"></i>&nbsp;<?php echo T_('Download Screenlog'); ?></a>
  363. <?php
  364.  
  365. //---------------------------------------------------------+
  366.  
  367. }
  368.  
  369. ?>
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="tab-pane" id="3">
  376. <div class="well">
  377. <?php
  378.  
  379. if ($type['querytype'] != 'none')
  380. {
  381.  
  382. /*----------------------------------------------------------------------------------------------------------\
  383. | |
  384. | [ LIVE GAME SERVER LIST ] [ © RICHARD PERRY FROM GREYCUBE.COM ] |
  385. | |
  386. | Released under the terms and conditions of the GNU General Public License Version 3 (http://gnu.org) |
  387. | |
  388. \-----------------------------------------------------------------------------------------------------------*/
  389.  
  390. //------------------------------------------------------------------------------------------------------------+
  391. // THIS CONTROLS HOW THE PLAYER FIELDS ARE DISPLAYED
  392.  
  393. $fields_show = array("name", "score", "kills", "deaths", "team", "ping", "bot", "time"); // ORDERED FIRST
  394. $fields_hide = array("teamindex", "pid", "pbguid"); // REMOVED
  395. $fields_other = TRUE; // FALSE TO ONLY SHOW FIELDS IN $fields_show
  396.  
  397. //------------------------------------------------------------------------------------------------------------+
  398. // GET THE SERVER DETAILS AND PREPARE IT FOR DISPLAY
  399.  
  400. global $output;
  401. $output = "";
  402. global $lgsl_server_id;
  403. $lgsl_server_id = $serverid;
  404.  
  405. $server = lgsl_query_cached("", "", "", "", "", "sep", $lgsl_server_id);
  406.  
  407. //if (!$server) { $output .= "<div style='margin:auto; text-align:center'> {$lgsl_config['text']['mid']} </div>"; return; }
  408.  
  409. $fields = lgsl_sort_fields($server, $fields_show, $fields_hide, $fields_other);
  410. $server = lgsl_sort_players($server);
  411. $server = lgsl_sort_extras($server);
  412. $misc = lgsl_server_misc($server);
  413. $server = lgsl_server_html($server);
  414.  
  415. //------------------------------------------------------------------------------------------------------------+
  416. // SHOW THE STANDARD INFO
  417.  
  418. $output .= "
  419. <table class='table table-bordered table-striped'>
  420. <thead>
  421. <tr>
  422. <th colspan='6' style='text-align: center;'> {$server['s']['name']} </th>
  423. <th colspan='2' style='text-align: center;'> <a href='{$misc['software_link']}'>{$lgsl_config['text']['slk']}</a> </th>
  424. </tr>
  425. </thead>
  426. <tbody>
  427. <tr>
  428. <td><b> {$lgsl_config['text']['sts']} </b></td>
  429. <td><b> {$lgsl_config['text']['adr']} </b></td>
  430. <td><b> {$lgsl_config['text']['cpt']} </b></td>
  431. <td><b> {$lgsl_config['text']['qpt']} </b></td>
  432. <td><b> {$lgsl_config['text']['typ']} </b></td>
  433. <td><b> {$lgsl_config['text']['gme']} </b></td>
  434. <td><b> {$lgsl_config['text']['map']} </b></td>
  435. <td><b> {$lgsl_config['text']['plr']} </b></td>
  436. </tr>
  437. <tr>
  438. <td> {$misc['text_status']} </td>
  439. <td> {$server['b']['ip']} </td>
  440. <td> {$server['b']['c_port']} </td>
  441. <td> {$server['b']['q_port']} </td>
  442. <td> {$server['b']['type']} </td>
  443. <td> {$server['s']['game']} </td>
  444. <td> {$server['s']['map']} </td>
  445. <td> {$server['s']['players']} / {$server['s']['playersmax']} </td>
  446. </tr>
  447. </tbody>
  448. </table>";
  449.  
  450. //------------------------------------------------------------------------------------------------------------+
  451.  
  452. $output .= "\r\n\r\n\t\t\t<hr>\r\n";
  453.  
  454. //------------------------------------------------------------------------------------------------------------+
  455. // SHOW THE PLAYERS
  456.  
  457. if (empty($server['p']) || !is_array($server['p']))
  458. {
  459. $output .= "\r\n\t\t\t<div style='text-align: center;'><span class='label'> {$lgsl_config['text']['npi']} </span></div>";
  460. }
  461. else
  462. {
  463. $output .= "
  464. <table class='table table-striped'>
  465. <thead>
  466. <tr>";
  467.  
  468. foreach ($fields as $field)
  469. {
  470. $field = ucfirst($field);
  471. $output .= "
  472. <td><b> {$field} </b></td>\r\n";
  473. }
  474.  
  475. $output .= "
  476. </tr>
  477. </thead>
  478. <tbody>";
  479.  
  480. foreach ($server['p'] as $player_key => $player)
  481. {
  482. $output .= "
  483. <tr>";
  484.  
  485. foreach ($fields as $field)
  486. {
  487. $output .= "
  488. <td> {$player[$field]} </td>";
  489. }
  490.  
  491. $output .= "
  492. </tr>";
  493. }
  494.  
  495. $output .= "
  496. </tbody>
  497. </table>";
  498. }
  499.  
  500. //------------------------------------------------------------------------------------------------------------+
  501.  
  502. $output .= "\r\n\r\n\t\t\t<hr>\r\n";
  503.  
  504. //------------------------------------------------------------------------------------------------------------+
  505. // SHOW THE SETTINGS
  506.  
  507. if (empty($server['e']) || !is_array($server['e']))
  508. {
  509. $output .= "\r\n\t\t\t<div style='text-align: center;'><span class='label'> {$lgsl_config['text']['nei']} </span></div>";
  510. }
  511. else
  512. {
  513. $output .= "
  514. <table class='table table-striped'>
  515. <thead>
  516. <tr>
  517. <td><b> {$lgsl_config['text']['ehs']} </b></td>
  518. <td><b> {$lgsl_config['text']['ehv']} </b></td>
  519. </tr>
  520. </thead>
  521. <tbody>";
  522.  
  523. foreach ($server['e'] as $field => $value)
  524. {
  525. $output .= "
  526. <tr>
  527. <td> {$field} </td>
  528. <td> {$value} </td>
  529. </tr>";
  530. }
  531.  
  532. $output .= "
  533. </tbody>
  534. </table>";
  535. }
  536.  
  537. echo $output;
  538.  
  539. unset($output);
  540.  
  541. }
  542.  
  543. ?>
  544. </div>
  545. </div>
  546. <div class="tab-pane" id="5">
  547. <div class="row">
  548. <div class="span6 offset3">
  549. <div class="well">
  550. <div style="text-align: center; margin-bottom: 5px;">
  551. <span class="label label-info"><?php echo T_('Last 15 Actions'); ?></span>
  552. </div>
  553. <table class="table table-bordered">
  554. <?php if (mysql_num_rows($logs) == 0){ ?>
  555. <tr>
  556. <td>
  557. <div style="text-align: center;"><span class="label label-warning"><?php echo T_('No Logs Found'); ?></span></div>
  558. </td>
  559. </tr>
  560. <?php
  561. }
  562. while ($rowsLogs = mysql_fetch_assoc($logs)){
  563. ?>
  564. <tr>
  565. <td>
  566. <div style="text-align: center;"><?php echo formatDate($rowsLogs['timestamp']); ?> - <?php echo htmlspecialchars($rowsLogs['message']); ?></div>
  567. </td>
  568. </tr>
  569. <?php
  570. }
  571. unset($logs);
  572. ?>
  573. </table>
  574. </div>
  575. </div>
  576. </div>
  577. </div>
  578.  
  579. <div class="tab-pane <?php if(isset($_GET['s']) && !empty($_GET['s'])){ ?>active<?php } ?>" id="6">
  580. <div class="row">
  581. <div class="span6 offset3">
  582. <div class="well">
  583. <?php
  584. require_once("./libs/phpseclib/SFTP.php");
  585.  
  586. $aes = new Crypt_AES();
  587. $aes->setKeyLength(256);
  588. $aes->setKey(CRYPT_KEY);
  589.  
  590. // Get SFTP
  591. $sftp = new Net_SFTP($box['ip'], $box['sshport']);
  592. if (!$sftp->login($box['login'], $aes->decrypt($box['password'])))
  593. {
  594. $_SESSION['msg1'] = T_('Connection Error!');
  595. $_SESSION['msg2'] = '';
  596. $_SESSION['msg-type'] = 'error';
  597. header( "Location: index.php");
  598. die();
  599. }
  600.  
  601. $plugins = array();
  602.  
  603. foreach($sftp->rawlist(dirname($rows['path']).'/plugins/') as $filename => $attr) {
  604. if ($attr['type'] == NET_SFTP_TYPE_REGULAR) {
  605. $ch = curl_init();
  606. curl_setopt($ch, CURLOPT_URL,"http://api.bukget.org/3/search/versions.0.filename/equals/".$filename);
  607. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  608. curl_setopt($ch, CURLOPT_USERAGENT, 'RedstonePower (BGP custom)');
  609. $server_output = curl_exec($ch);
  610.  
  611. curl_close ($ch);
  612.  
  613. $info = json_decode($server_output, true);
  614.  
  615. $plugins[] = array($filename, $info[0]);
  616. }else{
  617. continue;
  618. }
  619. }
  620.  
  621. if(isset($_GET['s']) && !empty($_GET['s']))
  622. {
  623. $ch = curl_init();
  624. curl_setopt($ch, CURLOPT_URL,"http://api.bukget.org/3/search/plugin_name/like/".$_GET['s']."?fields=plugin_name,versions,slug");
  625. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  626. curl_setopt($ch, CURLOPT_USERAGENT, 'RedstonePower (BGP custom)');
  627. $server_output = curl_exec($ch);
  628.  
  629. curl_close ($ch);
  630. $info = json_decode($server_output, true);
  631. ?>
  632. <div style="text-align: center; margin-bottom: 5px;">
  633. <span class="label label-info">Search plugins</span>
  634. </div>
  635. <table class="table table-bordered">
  636. <?php
  637. foreach($info as $key => $value)
  638. {
  639. if(!(preg_match("@CB 1\.7\.[9,10]-(.*?)@", $value['versions'][0]['game_versions'][0]) == 1) && isset($_GET['comp'])) continue;
  640. ?>
  641. <tr>
  642. <td>
  643. <div style="text-align: center;"><a href="http://dev.bukkit.org/bukkit-plugins/<?php echo $value['slug']; ?>/"><?php echo $value['plugin_name']; ?></a></div>
  644. </td>
  645. <?php
  646. if(false !== $plug = array_search($value['plugin_name'], $plugins))
  647. {
  648. ?>
  649. <td>
  650. <div style="text-align: center;"><a href="serverprocess.php?task=rmBukkitPlug&serverid=<?php echo $serverid; ?>&id=<?php echo $value['slug']; ?>" title="Remove <?php echo $value['plugin_name']; ?>"><span class="icon icon-remove"></span></a></div>
  651. </td>
  652. </tr>
  653. <?php
  654. }else{
  655. ?>
  656. <td>
  657. <?php
  658. if(preg_match("@CB 1\.7\.[9,10]-(.*?)@", $value['versions'][0]['game_versions'][0]) == 1)
  659. {
  660. ?>
  661. <div style="text-align: center;"><a href="serverprocess.php?task=addBukkitPlug&serverid=<?php echo $serverid; ?>&id=<?php echo $value['slug']; ?>" title="Install <?php echo $value['plugin_name']; ?>"><span class="icon icon-ok"></span></a></div>
  662. <?php
  663. }else{
  664. ?>
  665. <div style="text-align: center;"><span class="label label-warning" title="There is no version available for your version of bukkit">Not compatible</span></div>
  666. <?php
  667. }
  668. ?>
  669. </td>
  670. </tr>
  671. <?php
  672. }
  673. }
  674. ?>
  675. </table>
  676. <?php
  677. }else{
  678. ?>
  679. <div style="text-align: center; margin-bottom: 5px;">
  680. <span class="label label-info">Installed</span>
  681. </div>
  682. <table class="table table-bordered">
  683. <?php
  684. if(empty($plugins) && sizeof($plugins) == 0)
  685. {
  686. ?>
  687. <tr>
  688. <td>
  689. <div style="text-align: center;"><span class="label label-warning"><?php echo T_('No plugins installed'); ?></span></div>
  690. </td>
  691. </tr>
  692. <?php
  693. }else{
  694. foreach($plugins as $name)
  695. {
  696. ?>
  697. <tr>
  698. <td>
  699. <div style="text-align: center;"><a href="http://dev.bukkit.org/bukkit-plugins/<?php echo $name[1]['slug']; ?>/"><?php echo $name[1]['plugin_name']; ?></a></div>
  700. </td>
  701. <td>
  702. <div style="text-align: center;"><a href="serverprocess.php?task=rmBukkitPlug&serverid=<?php echo $serverid; ?>&id=<?php echo $name[1]['slug']; ?>" title="Remove <?php echo $name[1]['plugin_name']; ?>"><span class="icon icon-remove"></span></a></div>
  703. </td>
  704. </tr>
  705. <?php
  706. }
  707. }
  708.  
  709. $sftp->disconnect();
  710. ?>
  711. </table>
  712. <div style="text-align: center; margin-bottom: 5px;">
  713. <span class="label label-success">15 Popular plugins this Month</span>
  714. </div>
  715. <table class="table table-bordered">
  716. <?php
  717. $ch = curl_init();
  718. curl_setopt($ch, CURLOPT_URL,"http://api.bukget.org/3/plugins?size=15&sort=popularity.monthly");
  719. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  720. curl_setopt($ch, CURLOPT_USERAGENT, 'RedstonePower (BGP custom)');
  721. $server_output = curl_exec($ch);
  722.  
  723. curl_close ($ch);
  724.  
  725. $info = json_decode($server_output, true);
  726.  
  727. foreach($info as $key => $value)
  728. {
  729. echo "<tr><td><div style=\"text-align: center;\"><a href=\"http://dev.bukkit.org/bukkit-plugins/".$value['slug']."\">".$value['plugin_name'] . "</a></div></td>";
  730. $ch = curl_init();
  731. curl_setopt($ch, CURLOPT_URL,"http://api.bukget.org/3/plugins/bukkit/".$info[0]['slug']."/latest");
  732. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  733. curl_setopt($ch, CURLOPT_USERAGENT, 'RedstonePower (BGP custom)');
  734. $server_output = curl_exec($ch);
  735. curl_close ($ch);
  736. $info2 = json_decode($server_output, true);
  737. if((preg_match("@CB 1\.7\.[9,10]-(.*?)@", $info2['versions'][0]['game_versions'][0]) == 1))
  738. {
  739. echo "<td><div style=\"text-align: center;\"><a href=\"serverprocess.php?task=addBukkitPlug&serverid=".$serverid."&id=".$info[0]['slug']."\" title=\"Install ".$value['plugin_name']."\"><span class=\"icon icon-ok\"></span></a></div></td>
  740. </tr>";
  741. }
  742. }
  743. ?>
  744. </table>
  745. <?php } ?>
  746. <div style="text-align: center; margin-bottom: 5px;">
  747. <span class="label label-info">Search</span>
  748. </div>
  749. <table class="table table-bordered">
  750. <form method="get">
  751. <input type="hidden" name="id" value="<?php echo $serverid; ?>" />
  752. <tr>
  753. <td><input type="text" name="s" placeholder="Search.." value="<?php echo htmlentities($_GET['s']); ?>" /></td>
  754. <td>Only compatible: <input type="checkbox" name="comp" <?php if(isset($_GET['comp'])){ ?>checked<?php } ?> /></td>
  755. <td><input type="submit" value="Search" /></td>
  756. </tr>
  757. </form>
  758. </table>
  759. </div>
  760. </div>
  761. </div>
  762. </div>
  763.  
  764. </div>
  765. </div>
  766. <div style="text-align: center;">
  767. <ul class="pager">
  768. <li>
  769. <a href="index.php"><?php echo T_('Back to Home'); ?></a>
  770. </li>
  771. </ul>
  772. </div>
  773. <script>
  774. function dlScrLog()
  775. {
  776. if (confirm("<?php echo T_('Download SCREENLOG ?'); ?>"))
  777. {
  778. window.location.href='serverprocess.php?task=getserverlog&serverid=<?php echo $serverid; ?>';
  779. }
  780. }
  781. </script>
  782. <?php
  783.  
  784.  
  785. include("./bootstrap/footer.php");
  786. ?>
Add Comment
Please, Sign In to add comment