Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. <?php include 'header.php'; if ( $_GET['action'] === 'deletetcg' && isset($_GET['id']) ) {
  2.  
  3. $tcgid = intval($_GET['id']);
  4. if ( $database->num_rows("SELECT * FROM `tcgs` WHERE `id`='$tcgid'") == 0 ) { $error[] = "The TCG no longer exists."; }
  5. else {
  6.  
  7. $result = $database->query("DELETE FROM `tcgs` WHERE `id` = '$tcgid' LIMIT 1");
  8. if ( !$result ) { $error[] = "Could not remove the TCG entry in tcgs table."; }
  9. else {
  10.  
  11. $tables = array(additional, cards, collecting, trades);
  12.  
  13. foreach ( $tables as $table ) {
  14. $result = $database->query("DELETE FROM `$table` WHERE `tcg` = '$tcgid'");
  15. if ( !$result ) { $error[] = "Could not remove the TCG's entry in tcgs table."; }
  16. }
  17.  
  18. }
  19.  
  20. if ( !isset($error) ) {
  21. if ( $tcgid == $_SESSION['currTCG'] ) { $_SESSION['currTCG'] = ""; }
  22. $success[] = "The TCG and all related items have been removed.";
  23. }
  24.  
  25. }
  26.  
  27. }
  28.  
  29. // GitHub API
  30. $options = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT']));
  31. $context = stream_context_create($options);
  32. $response = file_get_contents('https://api.github.com/repos/tooblue/etcg/releases', false, $context);
  33. $releases = json_decode($response, true);
  34.  
  35. ?>
  36.  
  37. <?php if ( isset($error) ) { foreach ( $error as $msg ) { ?>
  38. <div class="alert alert-danger alert-dismissible" role="alert">
  39. <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  40. <strong>Error!</strong> <?php echo $msg; ?>
  41. </div>
  42. <?php } } ?>
  43. <?php if ( isset($success) ) { foreach ( $success as $msg ) { ?>
  44. <div class="alert alert-success alert-dismissible" role="alert">
  45. <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  46. <strong>Success!</strong> <?php echo $msg; ?>
  47. </div>
  48. <?php } } ?>
  49.  
  50. <div class="content col-12 col-sm-12 col-lg-12">
  51. <h1>Dashboard</h2>
  52.  
  53. <div class="row row-notices clearfix">
  54. <div class="col-md-7 panel panel-primary">
  55. <div class="panel-body">
  56. <h2><i class="fa fa-exclamation-triangle"></i> Latest eTCG Releases</h2>
  57. <?php $i = 0; foreach( $releases as $release ) { if ( $i > 4 ) { break; } ?>
  58. <p><strong><a href="<?php echo $release['html_url']; ?>" alt=""><?php echo $release['tag_name']; ?>: <?php echo $release['name']; ?></a></strong> @ <?php echo date("F j, Y, g:i a", strtotime($release['published_at'])); ?></p>
  59. <?php $i++; } ?>
  60. </div>
  61. </div>
  62.  
  63. <div class="col-md-4 panel panel-default">
  64. <div class="panel-body">
  65. <h2><i class="fa fa-question-circle"></i> Need Help?</h2>
  66. <ul>
  67. <li><a href="https://github.com/tooblue/etcg/wiki" alt="">Documentation</a></li>
  68. <li><a href="https://github.com/tooblue/etcg/issues" alt="">Report Issues</a></li>
  69. <li><a href="http://filler00.com/forum/viewforum.php?f=13" alt="">Support Forums</a></li>
  70. <li><a href="http://filler00.com/forum/viewforum.php?f=16">Script Mods</a></li>
  71. </ul>
  72. </div>
  73. </div>
  74. </div>
  75.  
  76. <table class="table table-striped">
  77. <thead>
  78. <tr>
  79. <th>TCG</th>
  80. <th>URL</th>
  81. <th>Status</th>
  82. <th>Updated</th>
  83. </tr>
  84. </thead>
  85. <tbody>
  86. <?php
  87. $database = new Database;
  88. $result = $database->query("SELECT * FROM `tcgs` ORDER BY `name`");
  89. $count = mysqli_num_rows($result);
  90.  
  91. if ( $count > 0 ) {
  92. $i = 0;
  93. while ( $row = mysqli_fetch_assoc($result) ) { $i++; ?>
  94. <tr <?php if ( $row['status'] == 'inactive' ) { echo 'class="danger"'; } else if ( $row['status'] == 'hiatus' ) { echo 'class="warning"'; } ?>>
  95. <td><strong><a href="cards.php?id=<?php echo $row['id']; ?>"><?php echo $row['name']; ?></a></strong></td>
  96. <td><a href="<?php echo $row['url']; ?>" target="_blank"><?php echo $row['url']; ?></a></td>
  97. <td><em><?php echo $row['status']; ?></em></td>
  98. <td><?php echo date('F j, Y', strtotime($row['lastupdated'])); ?></td>
  99. </tr>
  100. <?php }
  101. }
  102. else {
  103. echo '<tr><td align="center" colspan="4">No active TCGs found.</td></tr>';
  104. }
  105. ?>
  106. </tbody>
  107. </table>
  108. </div><!--/span-->
  109.  
  110. <?php include 'footer.php'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement