Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.86 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require("mainconfig.php");
  4. $msg_type = "nothing";
  5.  
  6. if (isset($_SESSION['user'])) {
  7. $sess_username = $_SESSION['user']['username'];
  8. $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$sess_username'");
  9. $data_user = mysqli_fetch_assoc($check_user);
  10. if (mysqli_num_rows($check_user) == 0) {
  11. header("Location: ".$cfg_baseurl."logout.php");
  12. } else if ($data_user['status'] == "Suspended") {
  13. header("Location: ".$cfg_baseurl."logout.php");
  14. }
  15.  
  16. $check_order = mysqli_query($db, "SELECT SUM(price) AS total FROM orders WHERE user = '$sess_username'");
  17. $data_order = mysqli_fetch_assoc($check_order);
  18. $count_users = mysqli_num_rows(mysqli_query($db, "SELECT * FROM users"));
  19.  
  20. $total_pending = mysqli_num_rows(mysqli_query($db, "SELECT * FROM orders WHERE status = 'Pending' AND user = '$sess_username'"));
  21. $total_proses = mysqli_num_rows(mysqli_query($db, "SELECT * FROM orders WHERE status = 'Processing' AND user = '$sess_username'"));
  22. $total_partial = mysqli_num_rows(mysqli_query($db, "SELECT * FROM orders WHERE status = 'Partial' AND user = '$sess_username'"));
  23. $total_sukses = mysqli_num_rows(mysqli_query($db, "SELECT * FROM orders WHERE status = 'Success' AND user = '$sess_username'"));
  24. $total_error = mysqli_num_rows(mysqli_query($db, "SELECT * FROM orders WHERE status = 'Error' AND user = '$sess_username'"));
  25. $count_orders = mysqli_num_rows(mysqli_query($db, "SELECT * FROM orders WHERE user = '$sess_username'"));
  26.  
  27.  
  28. } else {
  29. if (isset($_POST['login'])) {
  30. $post_username = mysqli_real_escape_string($db, trim($_POST['username']));
  31. $post_password = mysqli_real_escape_string($db, trim($_POST['password']));
  32. if (empty($post_username) || empty($post_password)) {
  33. $msg_type = "error";
  34. $msg_content = "<b>Gagal:</b> Mohon mengisi semua input.";
  35. } else {
  36. $check_user = mysqli_query($db, "SELECT * FROM users WHERE username = '$post_username'");
  37. if (mysqli_num_rows($check_user) == 0) {
  38. $msg_type = "error";
  39. $msg_content = '<b>Gagal:</b> Username atau password salah.<script>swal("Error!", "Username atau password salah.", "error");</script>';
  40. } else {
  41. $data_user = mysqli_fetch_assoc($check_user);
  42. if ($post_password <> $data_user['password']) {
  43. $msg_type = "error";
  44. $msg_content = '<b>Gagal:</b> Username atau password salah.<script>swal("Error!", "Username atau password salah.", "error");</script>';
  45. } else if ($data_user['status'] == "Suspended") {
  46. $msg_type = "error";
  47. $msg_content = '<b>Gagal:</b> Akun Tidak Aktif.<script>swal("Error!", "Akun Suspended.", "error");</script>';
  48. } else if ($_POST['captcha'] !== "Manusia") {
  49. $msg_type = "error";
  50. $msg_content = '<script>swal("Error!", "Anda bukan manusia.", "error");</script>';
  51. } else {
  52. $_SESSION['user'] = $data_user;
  53. header("Location: ".$cfg_baseurl);
  54. }
  55. }
  56. }
  57. }
  58. }
  59.  
  60. include("lib/header.php");
  61. if (isset($_SESSION['user'])) {
  62. ?>
  63. <div class="content-page">
  64. <div class="content">
  65. <div class="container">
  66. <div class="row">
  67. <div class="col-xs-12">
  68. <div class="page-title-box">
  69. <h4 class="page-title">Halaman Utama</h4>
  70. <ol class="breadcrumb p-0 m-0">
  71. <li>
  72. <a href="#"><?php echo $cfg_webname; ?></a>
  73. </li>
  74. <li class="active">
  75. Halaman Utama
  76. </li>
  77. </ol>
  78. <div class="clearfix"></div>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="row">
  83. <div class="col-md-8">
  84. <div class="panel panel-color panel-info">
  85. <div class="panel-heading">
  86. <h3 class="panel-title"><i class="fa fa-line-chart"></i> Grafik Transaksi </h3>
  87. </div>
  88. <div class="panel-body">
  89. <canvas id="myChart"></canvas>
  90. <script>
  91. var ctx = document.getElementById("myChart");
  92. var myChart = new Chart(ctx, {
  93. type: 'line',
  94. data: {
  95. labels: ["Pending", "Error", "Sukses", "Processing", "Partial"],
  96. datasets: [{
  97. label: "Jumlah Transksi",
  98. fill: false,
  99. lineTension: 0.1,
  100. backgroundColor: "#10c469",
  101. borderColor: "#10c469",
  102. borderCapStyle: 'butt',
  103. borderDash: [],
  104. borderDashOffset: 0.0,
  105. borderJoinStyle: 'miter',
  106. pointBorderColor: "#10c469",
  107. pointBackgroundColor: "#fff",
  108. pointBorderWidth: 1,
  109. pointHoverRadius: 5,
  110. pointHoverBackgroundColor: "#10c469",
  111. pointHoverBorderColor: "#eef0f2",
  112. pointHoverBorderWidth: 2,
  113. pointRadius: 1,
  114. pointHitRadius: 10,
  115. data: [<?php echo $total_pending; ?>, <?php echo $total_error; ?>, <?php echo $total_sukses; ?>, <?php echo $total_proses; ?>, <?php echo $total_partial; ?>],
  116. }]
  117. },
  118. options: {
  119. scales: {
  120. yAxes: [{
  121. ticks: {
  122. beginAtZero: true
  123. }
  124. }]
  125. }
  126. }
  127. });
  128. </script>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="col-lg-4 col-md-4">
  133. <div class="card-box widget-box-three">
  134. <div class="bg-icon pull-left">
  135. <i class="ti-shopping-cart"></i>
  136. </div>
  137. <div class="text-right">
  138. <p class="text-success m-t-5 text-uppercase font-600 font-secondary">Total Pembelian</p>
  139. <h2 class="m-b-10"><span data-plugin="">Rp <?php echo number_format($data_order['total'],0,',','.'); ?></span></h2>
  140. </div>
  141. </div>
  142.  
  143. <div class="card-box widget-box-three">
  144. <div class="bg-icon pull-left">
  145. <i class="ti-money"></i>
  146. </div>
  147. <div class="text-right">
  148. <p class="text-pink m-t-5 text-uppercase font-600 font-secondary">Sisa Saldo</p>
  149. <h2 class="m-b-10"><span data-plugin="">Rp <?php echo number_format($data_user['balance'],0,',','.'); ?></span></h2>
  150. </div>
  151. </div>
  152. <div class="card-box widget-box-three">
  153. <div class="bg-icon pull-left">
  154. <i class="mdi mdi-cart"></i>
  155. </div>
  156. <div class="text-right">
  157. <p class="text-pink m-t-5 text-uppercase font-600 font-secondary">Total Transaksi</p>
  158. <h2 class="m-b-10"><span data-plugin=""><?php echo $count_orders; ?> Transaksi</span></h2>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. <div class="row">
  164. <div class="col-md-12">
  165. <div class="panel panel-color panel-info">
  166. <div class="panel-heading">
  167. <h3 class="panel-title"><i class="mdi mdi-information-variant"></i> Berita & Informasi</h3>
  168. </div>
  169. <div class="panel-body">
  170. <div class="table-responsive">
  171. <table class="table table-striped table-bordered table-hover m-0">
  172. <thead>
  173. <tr>
  174. <th>#</th>
  175. <th>Tanggal</th>
  176. <th>Isi</th>
  177. </tr>
  178. </thead>
  179. <tbody>
  180. <?php
  181. $check_news = mysqli_query($db, "SELECT * FROM news ORDER BY id DESC LIMIT 5");
  182. $no = 1;
  183. while ($data_news = mysqli_fetch_assoc($check_news)) {
  184. ?>
  185. <tr>
  186. <th scope="row"><?php echo $no; ?></th>
  187. <td><?php echo $data_news['date']; ?></td>
  188. <td><?php echo $data_news['content']; ?></td>
  189. </tr>
  190. <?php
  191. $no++;
  192. }
  193. ?>
  194. </tbody>
  195. </table>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. <!-- end row -->
  202. <?php
  203. } else {
  204. ?>
  205. <div class="content-page">
  206. <div class="content">
  207. <div class="container">
  208. <div class="row">
  209. <div class="col-xs-12">
  210. <div class="page-title-box">
  211. <h4 class="page-title">Masuk</h4>
  212. <ol class="breadcrumb p-0 m-0">
  213. <li>
  214. <a href="#"><?php echo $cfg_webname; ?></a>
  215. </li>
  216. <li class="active">
  217. Masuk
  218. </li>
  219. </ol>
  220. <div class="clearfix"></div>
  221. </div>
  222. </div>
  223. </div>
  224.  
  225. <div class="row">
  226. <div class="col-md-7">
  227. <div class="panel panel-color panel-info">
  228. <div class="panel-heading">
  229. <h3 class="panel-title"><i class="mdi mdi-import"></i> Masuk</h3>
  230. </div>
  231. <div class="panel-body">
  232. <?php
  233. if ($msg_type == "error") {
  234. ?>
  235. <div class="alert alert-danger">
  236. <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  237. <i class="fa fa-times-circle"></i>
  238. <?php echo $msg_content; ?>
  239. </div>
  240. <?php
  241. }
  242. ?>
  243. <form class="form-horizontal" role="form" method="POST">
  244. <div class="form-group">
  245. <label class="col-md-2 control-label">Username</label>
  246. <div class="col-md-10">
  247. <input type="text" name="username" class="form-control" placeholder="Username">
  248. </div>
  249. </div>
  250. <div class="form-group">
  251. <label class="col-md-2 control-label">Password</label>
  252. <div class="col-md-10">
  253. <input type="password" name="password" class="form-control" placeholder="Password">
  254. </div>
  255. </div>
  256. <div class="form-group">
  257. <label class="col-md-2 control-label">Captcha</label>
  258. <div class="col-md-10">
  259. <select class="form-control" id="captcha" name="captcha">
  260. <option selected="true" style="display:none;">Apakah Anda Manusia?</option>
  261. <option value="Manusia">Saya Manusia</option>
  262.  
  263. </select>
  264. </div>
  265. </div>
  266. <div class="form-group">
  267. <div class="col-md-offset-2 col-md-10">
  268. <button type="submit" name="login" class="btn btn-info waves-effect waves-light"> Masuk</button>
  269. <button type="reset" class="btn btn-default waves-effect waves-light"> Ulangi</button>
  270. </div>
  271. </form>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. <div class="col-md-5">
  277. <div class="panel panel-color panel-info">
  278. <div class="panel-heading">
  279. <h3 class="panel-title"><i class="mdi mdi-information-outline"></i> Tentang Kami</h3>
  280. </div>
  281. <div class="panel-body">
  282. <p><?php echo $cfg_desc; ?></p>
  283. <ul>
  284. <li>Instant & Auto processing.</li>
  285. <li>Cheapest price.</li>
  286. <li>Layanan lengkap.</li>
  287. <li>24 Hours support.</li>
  288. <li>Deposit via Bank & Pulsa.</li>
  289. </ul><hr>
  290. <center><a href="//www.dmca.com/Protection/Status.aspx?ID=0e3f1e93-5f14-4ec9-a0c9-ea1f67e1ced2" title="DMCA.com Protection Status" class="dmca-badge" target="_top"> <img src="//images.dmca.com/Badges/dmca-badge-w200-5x1-06.png?ID=0e3f1e93-5f14-4ec9-a0c9-ea1f67e1ced2" alt="DMCA.com Protection Status"></a> <script src="//images.dmca.com/Badges/DMCABadgeHelper.min.js"> </script></center>
  291. </div>
  292. </div>
  293. </div>
  294. </div>
  295.  
  296.  
  297. <?php
  298. }
  299. include("lib/footer.php");
  300. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement