From bd6d5c38f8f46f24af8f4bcd5616af06d0ca69e3 Mon Sep 17 00:00:00 2001
From: suren_s <surenkumar2105@gmail.com>
Date: Wed, 12 Oct 2022 11:34:38 +0000
Subject: [PATCH] Third Commit

---
 css/pricing.css           | 40 ++++++++++++++++++++++++++
 index.php                 |  4 +++
 lib/Database.class.php    | 13 +++++----
 lib/Userdeatils.class.php |  8 +++---
 lib/load.php              | 47 +++++++++++++++---------------
 lib/user.class.php        |  1 -
 login.php                 |  4 +--
 pricing.php               | 60 ++++++++++++++++++++++++++-------------
 signup.php                |  1 -
 9 files changed, 122 insertions(+), 56 deletions(-)

diff --git a/css/pricing.css b/css/pricing.css
index 5378c5e..0b32e81 100644
--- a/css/pricing.css
+++ b/css/pricing.css
@@ -9,4 +9,44 @@ body {
   .pricing-header {
     max-width: 700px;
   }
+
+  /* From uiverse.io by @alexroumi */
+.butt {
+  padding: 12px 35px;
+  border: unset;
+  border-radius: 15px;
+  color: #e8e8e8;
+  z-index: 1;
+  background: #0D6EFD;
+  position: relative;
+  font-weight: 1000;
+  font-size: 17px;
+  -webkit-box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
+  box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
+  transition: all 250ms;
+  overflow: hidden;
+ }
+ 
+ .butt::before {
+  content: "";
+  position: absolute;
+  top: 0;
+  left: 0;
+  height: 100%;
+  width: 0;
+  border-radius: 15px;
+  background-color: blue;
+  z-index: -1;
+  -webkit-box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
+  box-shadow: 4px 8px 19px -3px rgba(0,0,0,0.27);
+  transition: all 250ms
+ }
+ 
+ .butt:hover {
+  color: white;
+ }
+ 
+ .butt:hover::before {
+  width: 100%;
+ }
   
\ No newline at end of file
diff --git a/index.php b/index.php
index 70f29d0..1679d00 100644
--- a/index.php
+++ b/index.php
@@ -1,3 +1,6 @@
+<?php 
+// include 'lib/load.php';
+?>
 <!doctype html>
 <html lang="en">
   <head>
@@ -108,6 +111,7 @@
           </a>
           <ul class="dropdown-menu text-small" style="">
             <li><a class="dropdown-item" href="profile.php">Profile</a></li>
+            <li><a class="dropdown-item" href="admin.php">Dashboard</a></li>
         
             <li><hr class="dropdown-divider"></li>
             <li><a class="dropdown-item" href="login.php">Sign out</a></li>
diff --git a/lib/Database.class.php b/lib/Database.class.php
index 861bc18..1a1b20b 100644
--- a/lib/Database.class.php
+++ b/lib/Database.class.php
@@ -1,5 +1,4 @@
 <?
-include 'lib/load.php';
 
 class Database
 {
@@ -7,11 +6,15 @@ class Database
 
     public static function getconnection()
     {
+        $__site_config_path = "/home/suren_s/htdocs/cred/cred.json";
+        $__site_config = file_get_contents($__site_config_path);
+        $array = json_decode($__site_config, true);
+
         if (Database::$conn == null) {
-            $servername = loaders::get_config('db_server');
-            $username = loaders::get_config('db_username');
-            $password = loaders::get_config('db_password');
-            $db = loaders::get_config('db_name');
+            $servername = $array['db_server'];
+            $username = $array['db_username'];
+            $password = $array['db_password'];
+            $db = $array['db_name'];
             
             $connection = new mysqli($servername, $username, $password, $db);
             
diff --git a/lib/Userdeatils.class.php b/lib/Userdeatils.class.php
index b61163d..67e1c41 100644
--- a/lib/Userdeatils.class.php
+++ b/lib/Userdeatils.class.php
@@ -1,5 +1,5 @@
 <?php
-// include 'lib/Database.class.php';
+include 'lib/Database.class.php';
 
 class Userdetails{
     public function __construct($id){
@@ -25,15 +25,15 @@ class Userdetails{
 
     public function recharge($plan,$val,$plantype){
 
-        print("i am work from ud");
+        // print("i am work from ud");
 
         $sql = "INSERT INTO `plan` (`uid`, `status`, `plan`, `validity`, `plantype`)
         VALUES ('$this->id', 'Active', '$plan', '$val', '$plantype');";
 
-        $result = $this->query($sql);
+        $result = $this->db->query($sql);
 
         if($result){
-            return true;
+          
         }else{
             print("Something went Wrong");
         }
diff --git a/lib/load.php b/lib/load.php
index 73a5bbf..9473c6e 100644
--- a/lib/load.php
+++ b/lib/load.php
@@ -1,27 +1,28 @@
 <?
 include_once 'lib/Database.class.php';
-// include_once 'User.class.php';
-// include_once 'Session.class.php';
-// include_once 'UserSession.class.php';
-// include_once 'WebApi.class.php';
-class loaders{
-
-    public function __construct(){
-        $__site_config_path = "/home/suren_s/htdocs/cred/cred.json";
-        $__site_config = file_get_contents($__site_config_path);
-        Database::getconnection();
-    }
+include_once 'lib/user.class.php';
+include_once 'lib/Userdeatils.class.php';
+include_once 'pricing.php';
+include_once 'login.php';
+include_once 'signup.php';
+
+// include_once 'includes/Session.class.php';
+// include_once 'includes/UserSession.class.php';
+// include_once 'includes/WebApi.class.php';
+
+
+
+
+
+
 
-    public static function get_config($key, $default=null)
-    {
-        $__site_config_path = "/home/suren_s/htdocs/cred/cred.json";
-        $__site_config = file_get_contents($__site_config_path);
-        $array = json_decode($__site_config, true);
-        if (isset($array[$key])) {
-            return $array[$key];
-        } else {
-            return $default;
-        }
+function get_config($key, $default=null)
+{
+    global $__site_config;
+    $array = json_decode($__site_config, true);
+    if (isset($array[$key])) {
+        return $array[$key];
+    } else {
+        return $default;
     }
-    
-}
+}
\ No newline at end of file
diff --git a/lib/user.class.php b/lib/user.class.php
index 5e454ea..feede70 100644
--- a/lib/user.class.php
+++ b/lib/user.class.php
@@ -1,6 +1,5 @@
 <?php
 
-include 'lib/Database.class.php';
 
 class User
 {
diff --git a/login.php b/login.php
index 05f0ec2..af25b35 100644
--- a/login.php
+++ b/login.php
@@ -1,7 +1,5 @@
 <?php
 
-include 'lib/user.class.php';
-include "lib/Userdeatils.class.php";
 
 $login = false;
 if (isset($_POST['username']) and isset($_POST['password'])) {
@@ -23,7 +21,7 @@ if (isset($_POST['username']) and isset($_POST['password'])) {
 
 if($login){ 
 
-  header("Location: https://iot.selfmade.technology/home.html");
+  header("Location: https://iot.selfmade.technology/index.php");
   exit();
 
 }else{?>
diff --git a/pricing.php b/pricing.php
index ed08473..e61d77b 100644
--- a/pricing.php
+++ b/pricing.php
@@ -21,6 +21,8 @@ include 'lib/Userdeatils.class.php';
 
 <link href="../assets/dist/css/bootstrap.min.css" rel="stylesheet">
 
+
+
     <style>
       .bd-placeholder-img {
         font-size: 1.125rem;
@@ -76,7 +78,7 @@ include 'lib/Userdeatils.class.php';
 
     
     <!-- Custom styles for this template -->
-    <link href="pricing.css" rel="stylesheet">
+    <link href="css/pricing.css" rel="stylesheet">
   </head>
   <body>
     
@@ -119,28 +121,48 @@ include 'lib/Userdeatils.class.php';
           <div class="card-body">
             <h1 class="card-title pricing-card-title">₹179<small class="text-muted fw-light">/mo</small></h1>
             <ul class="list-unstyled mt-3 mb-4">
-              <li>Validity 28</li>
+              <li>Pack Validity 28</li>
               <li>Voice Unlimited</li>
               <li>100 SMS/day</li>
               <li>Help center access</li>
             </ul>
-            <form method="post">
-            <input type="submit" name="button2"
-                class="w-100 btn btn-lg btn-primary" value="Recharge" />
-            <!-- <button type="button" class="w-100 btn btn-lg btn-primary">Recharge</button> -->
-
-            </form>
-            
-            <?php 
-
-            function recharge_now(){
-              print('hello');
-              $r = new Userdetails($_COOKIE['id']);
-              $r->recharge('Basic','28','1.5');
-            }
-               
-
-            ?>
+            <?php
+        if(array_key_exists('button1', $_POST)) {
+            button1();
+        }
+        else if(array_key_exists('button2', $_POST)) {
+            button2();
+        }
+        function button1() {
+
+          // print_r($_COOKIE['id']);
+          $r = new Userdetails($_COOKIE['id']);
+
+          $r->recharge('Basic','28','1.5');
+          // print('helo');
+
+          header("Location: https://iot.selfmade.technology/index.php");
+          exit();
+
+        }
+        function button2() {
+            echo "This is Button2 that is selected";
+        }
+    ?>
+  
+    <form method="post">
+        <input type="submit" name="button1"
+                class="butt" value="Button1" />
+    </form>
+  
+    <!-- <form method="post">
+        
+
+                <button name='button1' type="button" class="w-100 btn btn-lg btn-primary">Recharge</button>
+    </form> -->
+
+           
+
           </div>
         </div>
       </div>
diff --git a/signup.php b/signup.php
index fca9037..b1bdf3e 100644
--- a/signup.php
+++ b/signup.php
@@ -1,6 +1,5 @@
 <?php
 
-include 'lib/user.class.php';
 ?>
 <html lang="en">
 <head>
-- 
GitLab