initial commit

This commit is contained in:
root
2024-06-03 16:43:53 +03:00
commit 21e3fd0797
1535 changed files with 60499 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
#include "auth.h"
ld
toRadians(ld degree){
ld one_deg = (M_PI)/180;
return (one_deg * degree);
}
ld
sq_root(ld value){
ld err = 1e-10;
ld ans = 0;
ld low = 0 , high = 0;
if(value < 1){
low = value , high = 1;
}
else{
low = 1 , high = value;
}
for(int i = 1 ; i <= 67 ; i++ ){
ld mid = low + (high - low)/2.0;
if( mid*mid <= value ){
ans = mid;
low = mid + err;
}
else{
high = mid - err;
}
}
return ans;
}
ld
orthodromic_distance(ld stu_lat,ld stu_long,ld teach_lat,ld teach_long){
stu_lat = toRadians(stu_lat);
stu_long = toRadians(stu_long);
teach_lat = toRadians(teach_lat);
teach_long = toRadians(teach_long);
ld diff_lat = teach_lat - stu_lat;
ld diff_long = teach_long - stu_long;
ld ans = pwr2(sin(diff_lat/2)) +
cos(stu_lat) * cos(teach_lat) *
pwr2(sin(diff_long/2));
ans = 2 * asin(sq_root(ans));
// Radius of Earth in
// Kilometers, R = 6371
// Use R = 3956 for miles
ld R = 6371;
//ans in meter...
ans = ans * R * (ld)1000;
return ans;
}
ld
altitude_difference(ld teach_alti, ld stu_alti)
{
ld diff_alti = teach_alti - stu_alti;
return diff_alti;
}
bool
check_range(ld dist, ld alti){
//better implementation for future....
// the 100 needs to be changed to (db.Room.length)
return dist <= (ld)100 && (alti >= -3 && alti <= 4);
}

View File

@@ -0,0 +1,30 @@
#ifndef __AUTH__
#define __AUTH__
#ifndef _MATH_H_
#include <math.h>
#endif
#ifndef _STDBOOL_H
#include <stdbool.h>
#endif
#define ld long double
#define pwr2(x) (x * x)
ld
sq_root(ld x);
ld
toRadians( ld degree );
ld
orthodromic_distance(ld stu_lat, ld stu_long, ld teach_lat, ld teach_long);
ld
altitude_difference(ld teach_alti, ld stu_alti);
bool
check_range(ld dist, ld alti);
#endif // __AUTH__

View File

@@ -0,0 +1,93 @@
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<mysql.h>
#include "auth.h"
void
error_found(MYSQL *con){
printf("%s\n",mysql_error(con));
mysql_close(con);
}
int
main(int argv , char **argc){
//Pass the Teacher latitude and longitude from command line argument.
//Teacher latitude and longitude...
ld teach_lat = strtold(argc[1],NULL) , teach_long = strtold(argc[2],NULL);
//Altitude as the 3rd argument.
ld teach_alti = strtold(argc[2],NULL);
MYSQL *con = mysql_init(NULL);
if( con == NULL ){
printf("mysql_init() failed\n");
return 0;
}
if( mysql_real_connect(con,"localhost","usr","admin@1224"
,"bpitattendance", 0,NULL,0) == NULL ){
error_found(con);
}
if( mysql_query(con, "SELECT * FROM attendance") ){
error_found(con);
}
MYSQL_RES *result = mysql_store_result(con);
if( result == NULL ){
error_found(con);
}
int num_fields = mysql_num_fields(result);
MYSQL_ROW row;
int enroll = 0;
long double stu_lat = 0 , stu_long = 0;
long double dist = 0;
char en_num[15];
char query[150]="";
while( (row = mysql_fetch_row(result) ) ){
enroll = (int)strtoll(row[0],NULL,10);
stu_lat = strtold(row[1],NULL);
stu_long = strtold(row[2],NULL);
stu_alti = strtold(row[3], NULL);
strcpy(query,"");
sprintf(en_num,"%d",enroll);
dist = orthodromic_distance(stu_lat,stu_long,teach_lat,teach_long);
alti = altitude_difference(teach_alti,stu_alti);
if( check_range(dist,alti) ){
strcat(query,"UPDATE attendance SET is_present = true WHERE enroll_num =");
strcat(query,en_num);
strcat(query,";");
if( mysql_query(con, query ) ){
error_found(con);
}
printf("%ld is present\n",enroll);
}
else{
strcat(query,"UPDATE attendance SET is_present = false WHERE enroll_num =");
strcat(query,en_num);
strcat(query,";");
if( mysql_query(con,query ) ){
error_found(con);
}
printf("%ld is absent\n",enroll);
}
}
mysql_free_result(result);
mysql_close(con);
return 0;
}

10
vansh/Auth/Makefile Normal file
View File

@@ -0,0 +1,10 @@
TARGET: auth_exe
auth_exe: auth.o main.o
gcc auth.o main.o -o auth_exe `mysql_config --cflags --libs` -lm
auth.o: auth.c
gcc -c auth.c -o auth.o
main.o: main.c
gcc -c main.c -o main.o `mysql_config --cflags --libs`
clean:
rm auth.o
rm main.o

71
vansh/Auth/auth.c Normal file
View File

@@ -0,0 +1,71 @@
#include "auth.h"
ld
toRadians(ld degree){
ld one_deg = (M_PI)/180;
return (one_deg * degree);
}
ld
sq_root(ld value){
ld err = 1e-10;
ld ans = 0;
ld low = 0 , high = 0;
if(value < 1){
low = value , high = 1;
}
else{
low = 1 , high = value;
}
for(int i = 1 ; i <= 67 ; i++ ){
ld mid = low + (high - low)/2.0;
if( mid*mid <= value ){
ans = mid;
low = mid + err;
}
else{
high = mid - err;
}
}
return ans;
}
ld
orthodromic_distance(ld stu_lat,ld stu_long,ld teach_lat,ld teach_long){
stu_lat = toRadians(stu_lat);
stu_long = toRadians(stu_long);
teach_lat = toRadians(teach_lat);
teach_long = toRadians(teach_long);
ld diff_lat = teach_lat - stu_lat;
ld diff_long = teach_long - stu_long;
ld ans = pwr2(sin(diff_lat/2)) +
cos(stu_lat) * cos(teach_lat) *
pwr2(sin(diff_long/2));
ans = 2 * asin(sq_root(ans));
// Radius of Earth in
// Kilometers, R = 6371
// Use R = 3956 for miles
ld R = 6371;
//ans in meter...
ans = ans * R * (ld)1000;
return ans;
}
bool
check_range(ld dist){
//better implementation for future....
return dist <= (ld)100;
}

27
vansh/Auth/auth.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef __AUTH__
#define __AUTH__
#ifndef _MATH_H_
#include <math.h>
#endif
#ifndef _STDBOOL_H
#include <stdbool.h>
#endif
#define ld long double
#define pwr2(x) (x * x)
ld
sq_root(ld x);
ld
toRadians( ld degree );
ld
orthodromic_distance(ld stu_lat, ld stu_long, ld teach_lat, ld teach_long);
bool
check_range(ld dist);
#endif // __AUTH__

BIN
vansh/Auth/auth_exe Normal file

Binary file not shown.

86
vansh/Auth/main.c Normal file
View File

@@ -0,0 +1,86 @@
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#include<mysql.h>
#include "auth.h"
void
error_found(MYSQL *con){
printf("%s\n",mysql_error(con));
mysql_close(con);
}
int main(int argv , char **argc){
//Pass the Teacher latitude and longitude from command line argument.
//Teacher latitude and longitude...
ld teach_lat = strtold(argc[1],NULL) , teach_long = strtold(argc[2],NULL);
MYSQL *con = mysql_init(NULL);
if( con == NULL ){
printf("mysql_init() failed\n");
return 0;
}
if( mysql_real_connect(con,"localhost","root","4r57ZeBEzR5b"
,"bpitattendance", 0,NULL,0) == NULL ){
error_found(con);
}
if( mysql_query(con, "SELECT * FROM attendance") ){
error_found(con);
}
MYSQL_RES *result = mysql_store_result(con);
if( result == NULL ){
error_found(con);
}
int num_fields = mysql_num_fields(result);
MYSQL_ROW row;
int enroll = 0;
long double stu_lat = 0 , stu_long = 0;
long double dist = 0;
char en_num[15];
char query[150]="";
while( (row = mysql_fetch_row(result) ) ){
enroll = (int)strtoll(row[0],NULL,10);
stu_lat = strtold(row[1],NULL);
stu_long = strtold(row[2],NULL);
strcpy(query,"");
sprintf(en_num,"%d",enroll);
dist = orthodromic_distance(stu_lat,stu_long,teach_lat,teach_long);
if( check_range(dist) ){
strcat(query,"UPDATE attendance SET is_present = true WHERE enroll_num =");
strcat(query,en_num);
strcat(query,";");
if( mysql_query(con, query ) ){
error_found(con);
}
printf("%ld is present\n",enroll);
}
else{
strcat(query,"UPDATE attendance SET is_present = false WHERE enroll_num =");
strcat(query,en_num);
strcat(query,";");
if( mysql_query(con,query ) ){
error_found(con);
}
printf("%ld is absent\n",enroll);
}
}
mysql_free_result(result);
mysql_close(con);
return 0;
}

View File

@@ -0,0 +1,8 @@
<?php
$servername="localhost";
$username="usr";
$password="admin@1224";
$dbname="main_bpitattendance_db";
$con = mysqli_connect($servername,$username,$password,$dbname) or die(myslq_error());
?>

View File

@@ -0,0 +1,60 @@
<?php
include("db.php");
include("../../junet/html/encrypt_password.inc.php");
include ("../../junet/html/hash_gen.inc.php");
include ("../../junet/html/decrypt_password.inc.php");
// Check if the connection is successful
if ($con === false) {
echo "Connection failed"; // Display message if connection fails
} else {
// Check if enrollment number is provided in the GET request
//if (isset($_GET['enrollment_no'])) {
// $enrollment_no = $_GET['enrollment_no']; // Get enrollment number from GET request
// Prepare the SQL SELECT query
$enrollment_no="14320802721";//to be commented out. for testing.
$sem1_query = "SELECT enrollment_no,course_id,curr_attendance,total_session FROM sem_1_crs_attend_recd where enrollment_no = $enrollment_no";
// Execute the query
$result = mysqli_query($con, $sem1_query);
// Check if any records were returned
if (mysqli_num_rows($result) > 0) {
// Output table header with CSS styles
echo "<table border='1' style='margin: 0 auto; text-align: center;'>";
echo "<tr><th colspan='5'>Attendance for: $enrollment_no</th></tr>";
echo "<tr><th>Course ID</th><th>Current Attendance</th><th>Total Sessions</th><th>Progress</th></tr>";
echo "<h2>Subject-wise Attendance</h2>";
//Attendance Trends & Attendance Alerts
// Loop through each row of the result set
while ($row = mysqli_fetch_assoc($result)) {
// Calculate progress ratio
$progress_ratio = ($row['curr_attendance'] / $row['total_session']) * 100;
// Output table row
echo "<tr>";
echo "<td>" . $row['course_id'] . "</td>";
echo "<td>" . $row['curr_attendance'] . "</td>";
echo "<td>" . $row['total_session'] . "</td>";
// Output progress bar with padding
echo "<td style='padding: 5px;'><progress value='$progress_ratio' max='100'></progress></td>";
echo "</tr>";
}
echo "</table>";
} else {
// No records found
echo "No records found";
}
// Free result set
mysqli_free_result($result);
/*} else {
echo "Enrollment number not provided"; // Output message if enrollment number is not provided in the GET request
}*/
// Close connection
mysqli_close($con);
}
?>

View File

@@ -0,0 +1,35 @@
<?php
include("db.php");
// Check if the connection is successful
if ($con === false) {
echo "Connection failed"; // Display message if connection fails
} else {
// Check if enrollment number is provided in the GET request
//if (isset($_GET['enrollment_no'])) {
// $enrollment_no = $_GET['enrollment_no']; // Get enrollment number from GET request
$enrollment_no="14320802721";//to be commented out. for testing.
// Prepare the SQL SELECT query
$name_query = "SELECT stud_first_name FROM student_record WHERE enrollment_no = $enrollment_no";
$name_result = mysqli_query($con, $name_query);
if ($name_result) {
if (mysqli_num_rows($name_result) > 0) {
// Student found, fetch and display the name
$name_row = mysqli_fetch_assoc($name_result);
$student_name = $name_row['stud_first_name'];
} else {
echo "No student found with the given enrollment number.";
}
} else {
echo "Error: " . mysqli_error($con);
}
} /*else {
echo "Enrollment number not provided.";
}*/
// Close connection
mysqli_close($con);
//}
?>

View File

@@ -0,0 +1,64 @@
<head>
<link rel="stylesheet" href="./styles.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<div class="Navbar">
<?php
include("fetch_name.php");
?>
<ul>
<li><a href="#Login/Logout">Login/Logout</a></li>
<li>
<a href="#" class="notification">
<span>Notifications </span>
<span class="badge">3</span>
</a>
</li>
<li><a href="#Register">Register</a></li>
<li><a href="#Aboutus">About us</a></li>
</ul>
</div>
<div id="content">
<div id="content-header">
<div class="clearfix">
<div class="float-left">
<div class="mini-nav">
<span class="user-img"><img src="link_to_user_IMAGE"></span><span class="user-name"><?php echo $student_name; ?></span><i class="fa fa-angle-down" aria-hidden="true"></i>
<a><i class="fa fa-navicon" aria-hidden="true"></i></a>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="banner blue">
<div class="clearfix">
<div class="float-left">
<h4>Welcome, <?php echo $student_name; ?></h4>
<h5>Let's take a look at your progress.</h5>
</div>
<br>
<br>
</div>
<div class="donut instalment1" style="float: right; margin-right: 5px">
<div style="float: right; margin-right: 200px" style="display: inline;">Attendance Percentage:</div>
<div class="donut-default"></div>
<div class="donut-line"></div>
<div class="donut-text">
<span>check</span>
</div>
<div class="donut-case"></div>
</div>
</div>
<?php
include("fetch_data.php");
?>
</body>

View File

@@ -0,0 +1,305 @@
@import url('https://fonts.googleapis.com/css?family=PT+Sans:400,700');
@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700');
body {
font-family: 'Roboto', sans-serif;
font-size: 16px;
}
.logo {
text-align: center;
}
.logo a {
font-family: 'PT Sans', sans-serif;
padding: 20px 30px;
display: block;
font-weight: 16px;
}
/* #sidebar {
z-index: 2001;
position: fixed;
width: 220px;
background-color: #2F2E33;
border-color: #2f4050;
-webkit-transition: all 0.4s;
-moz-transition: all 0.4s;
-o-transition: all 0.4s;
transition: all 0.4s;
height: 100%;
} */
.row {
display: flex;
flex-wrap: wrap;
}
.attendance-box {
width: 300px; /* Adjust width as per your requirement */
box-sizing: border-box;
margin-top: 20px;
border: 1px solid #ccc;
padding: 10px;
background-color: #ffffff; /* Set background color to pure white */
}
.attendance-bar {
margin-bottom: 10px;
}
.attendance-bar progress {
width: 100%;
}
.attendance-bar .subject {
display: block;
margin-bottom: 5px;
font-weight: bold;
font-size: 14px;
}
.donut {
position: relative;
width: 200px;
height: 200px;
}
.donut-default {
width: 100%;
height: 100%;
border-radius: 50%;
}
.donut-white {
width: 70%;
height: 70%;
border-radius: 50%;
background: #fff;
top: 50%;
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
}
.donut-line {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.donut-text {
top: 25px;
left: 25px;
width: 150px;
height: 150px;
background: #fff;
position: absolute;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
z-index: 3;
}
.donut-text span {
color: #48b2c1;
}
.instalment1 .donut-case {
width: 100%;
height: 100%;
border-radius: 50%;
background: #48b2c1;
position: absolute;
top: 0;
left: 0;
background-clip: border-box;
overflow: hidden;
}
.instalment1 .donut-case::before {
content: "";
clip: rect(0 200px 100px 0);
-webkit-transform: rotate(90deg);
transform: rotate(180deg);
background: #cbcb41;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.instalment1 .donut-case::after {
content: "";
clip: rect(0 100px 200px 0);
-webkit-transform: rotate(327.6deg);
transform: rotate(360deg);
background: #cbcb41;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.instalment1 .donut-line::before {
content: "";
width: 1px;
height: 100%;
position: absolute;
top: -25px;
left: 50%;
background: #fff;
z-index: 2;
}
.instalment1 .donut-line::after {
content: "";
width: 100%;
height: 1px;
position: absolute;
top: 50%;
left: 25px;
background: #fff;
border-bottom: 1px solid #fff;
z-index: 2;
}
.notification {
background-color: #555;
color: white;
text-decoration: none;
padding: 15px 26px;
position: relative;
display: inline-block;
border-radius: 2px;
}
.notification:hover {
background: red;
}
.notification .badge {
position: absolute;
top: -8px; /* Adjust the top position */
right: -8px; /* Adjust the right position */
padding: 6px 8px; /* Adjust the padding */
border-radius: 50%;
background: red;
color: white;
font-size: 12px; /* Adjust the font size */
line-height: 1; /* Ensure the line height matches the font size */
box-sizing: border-box; /* Include padding in the total width */
width: 25px; /* Ensure the badge has enough width */
text-align: center; /* Center the text horizontally */
}
.Navbar{
ul {
list-style-type: none;
margin: 0;
padding: 20px 0; /* Adjust the top and bottom padding */
overflow: hidden;
background-color: #333;
}
li {
float: right;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Change the link color to #111 (black) on hover */
li a:hover {
background-color: #111;
}
}
.sidebar-nav .menu>li>a {
color: #9EA6AF;
font-weight: 400;
font-family: 'Roboto', sans-serif;
padding: 20px 10px 20px 40px;
}
.sidebar-nav li:hover a {
background: #2A292E;
color: #fff;
}
.sidebar-nav a i {
width: 30px;
text-align: center;
padding-right: 10px;
}
#content {
background: none repeat scroll 0 0 #eeeeee;
position: relative;
min-height: 100%;
width: auto;
-webkit-transition: all 0.4s;
-moz-transition: all 0.4s;
-o-transition: all 0.4s;
transition: all 0.4s;
}
#content-header {
background: #fff;
padding: 10px;
}
.mini-nav {
font-size: 24px;
padding: 7px 10px;
display: flex;
justify-content: right;
}
.user-header .user-name {
padding: 0 10px;
list-style-type: none;
}
.user-header .user-img img {
margin-top: 4px;
border-radius: 5px;
max-width: 45px;
max-height: 45px;
}
.banner.blue {
display: flex;
justify-content:space-between;
background: #04a1dc;
background: -moz-linear-gradient(left, #04a1dc 1%, #0cb2ca 100%);
background: -webkit-linear-gradient(left, #04a1dc 1%,#0cb2ca 100%);
background: linear-gradient(to right, #04a1dc 1%,#0cb2ca 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#04a1dc', endColorstr='#0cb2ca',GradientType=1 );
background: #0f4375;
background: -moz-linear-gradient(left, #0f4375 0%, #2989d8 49%, #0f4375 100%);
background: -webkit-linear-gradient(left, #0f4375 0%,#2989d8 49%,#0f4375 100%);
background: linear-gradient(to right, #0f4375 0%,#2989d8 49%,#0f4375 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0f4375', endColorstr='#0f4375',GradientType=1 );
padding: 40px;
color: #fff;
}
.banner h4 {
font-weight: 400;
font-family: 'Roboto', sans-serif;
}
.banner h5 {
font-weight: 300;
font-size: 16px;
font-family: 'Roboto', sans-serif;
}
.content-inner {
padding: 15px 0;
}