Skip to content

Commit e022993

Browse files
author
Your Name
committed
Upload
0 parents  commit e022993

File tree

349 files changed

+35098
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+35098
-0
lines changed

Client side.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pubnub.pnconfiguration import PNConfiguration
2+
from pubnub.pubnub import PubNub
3+
4+
pnconfig = PNConfiguration()
5+
pnconfig.subscribe_key = "sub-c-f8ee4c62-2497-11e8-a183-761142583d66"
6+
pnconfig.publish_key = "pub-c-89c7fbd5-76f5-4c6a-8511-c153e7517db4"
7+
pnconfig.ssl = False
8+
9+
pubnub = PubNub(pnconfig)

Listeners.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from pubnub.callbacks import SubscribeCallback
2+
from pubnub.enums import PNOperationType, PNStatusCategory
3+
4+
class MySubscribeCallback(SubscribeCallback):
5+
def status(self, pubnub, status):
6+
pass
7+
8+
if status.operation == PNOperationType.PNSubscribeOperation \
9+
or status.operation == PNOperationType.PNUnsubscribeOperation:
10+
if status.category == PNStatusCategory.PNConnectedCategory:
11+
pass
12+
13+
elif status.category == PNStatusCategory.PNReconnectedCategory:
14+
pass
15+
16+
elif status.category == PNStatusCategory.PNDisconnectedCategory:
17+
pass
18+
19+
elif status.category == PNStatusCategory.PNUnexpectedDisconnectCategory:
20+
pass
21+
22+
23+
elif status.category == PNStatusCategory.PNAccessDeniedCategory:
24+
pass
25+
26+
else:
27+
pass
28+
29+
elif status.operation == PNOperationType.PNSubscribeOperation:
30+
heartbeart config>
31+
if status.is_error():
32+
pass
33+
34+
else:
35+
pass
36+
37+
else:
38+
pass
39+
40+
41+
def presence(self, pubnub, presence):
42+
pass
43+
44+
def message(self, pubnub, message):
45+
pass
46+
47+
48+
pubnub.add_listener(MySubscribeCallback())

PHP pages/Fourth.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
include('_con.php');
3+
// Create connection
4+
// Check connection
5+
if ($dbcon->connect_error) {
6+
die("Connection failed: " . $dbcon->connect_error);
7+
}
8+
9+
$sql = "SELECT Date,Credits FROM user";
10+
$result = $dbcon->query($sql);
11+
if ($result->num_rows > 0) {
12+
// output ,data of each row
13+
echo "<table><th>Date Credit</th>";
14+
while($row = $result->fetch_assoc()) {
15+
16+
echo "<tr><td>";
17+
echo $row['Date'];
18+
echo "</td><td>";
19+
echo $row['Credits'];
20+
echo "</td></tr>";
21+
}
22+
echo"</table>";
23+
} else {
24+
echo "0 results";

PHP pages/Third.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
<html>
3+
4+
5+
<?php
6+
7+
if($_POST["Select"]=="Credits")
8+
{
9+
echo "<h2>Your Latest credits for Waste</h2>";
10+
echo "<li class=n3><a href='result.php'>Click to check your score</a></li></ul>";
11+
}
12+
13+
14+
else
15+
{
16+
echo "<h2>Your Current History </h2>";
17+
echo "<li class=n3><a href='Fourth.php'> Check Your Credit History Here</a></li></ul>";
18+
}
19+
20+
?>
21+
</html>

PHP pages/_con.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
DEFINE ('DB_HOST','localhost');
3+
4+
DEFINE ('DB_USER','id3718151_iotdata');
5+
6+
DEFINE('DB_PSWD','12345');
7+
8+
DEFINE('DB_NAME','id3718151_iotdata');
9+
10+
$dbcon = mysqli_connect(DB_HOST,DB_USER,DB_PSWD,DB_NAME);
11+
12+
?>

PHP pages/index.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Transparent Login Form</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
<div class="loginBox">
10+
<img src="user.png" class="user">
11+
<h2>Log In Here</h2>
12+
<form action="second.php" method="post">
13+
<p>Username</p>
14+
<input type="text" name="UserName" placeholder="Enter Username" value="UserName">
15+
<p>Password</p>
16+
<input type="password" name="Password" placeholder="••••••" value="Password">
17+
<input type="submit" name="submit" value="submit">
18+
<a href="#">Forget Password</a>
19+
</form>
20+
</div>
21+
</body>
22+
</html>

PHP pages/results.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<body>
3+
4+
<b>Your Credit for this cycle is 17.0 </b>;
5+
6+
<h1>Thank you and keep recycling</h1>;
7+
8+
</body>
9+
</html>

PHP pages/second.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<html>
2+
<body>
3+
<?php
4+
include('_con.php');
5+
if (isset($_POST['submit'])){
6+
$sql = "SELECT * FROM login WHERE UserName='$_POST[UserName]' AND Password='$_POST[Password]'";
7+
$res = mysqli_query($dbcon, $sql) or die('error');
8+
if(mysqli_num_rows($res)==1)
9+
{
10+
echo "<form action='Third.php' method='post'>";
11+
echo "<div class=loginBox>";
12+
echo "<h2>Please Select:</h2>";
13+
echo "<br/><br/>";
14+
15+
echo "Credits:<input type='radio' name='Select' value='Credits' /><br/>";
16+
echo "History:<input type='radio' name='Select' value='History' /><br/>";
17+
echo "<button type='submit' name='submit' >Submit</button>";
18+
echo "</div>";
19+
echo "</form>";
20+
}
21+
else
22+
{
23+
echo "Wrong information";
24+
}
25+
}
26+
else
27+
{
28+
echo" sorry";
29+
}
30+
mysqli_close($dbcon);
31+
?>
32+
</body>
33+
</html>

PHP pages/style.css

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
body
2+
{
3+
margin: 0;
4+
padding: 0;
5+
font-family: sans-serif;
6+
}
7+
.loginBox
8+
{
9+
position: absolute;
10+
top: 50%;
11+
left: 50%;
12+
transform: translate(-50%,-50%);
13+
width: 350px;
14+
height: 420px;
15+
padding: 80px 40px;
16+
box-sizing: border-box;
17+
background: rgba(0,0,0,.5);
18+
}
19+
.user
20+
{
21+
width: 100px;
22+
height: 100px;
23+
border-radius: 50%;
24+
overflow: hidden;
25+
position: absolute;
26+
top: calc(-100px/2);
27+
left: calc(50% - 50px);
28+
}
29+
h2
30+
{
31+
margin: 0;
32+
padding: 0 0 20px;
33+
color: #efed40;
34+
text-align: center;
35+
}
36+
.loginBox p
37+
{
38+
margin: 0;
39+
padding: 0;
40+
font-weight: bold;
41+
color: #fff;
42+
}
43+
.loginBox input
44+
{
45+
width: 100%;
46+
margin-bottom: 20px;
47+
}
48+
.loginBox input[type="text"],
49+
.loginBox input[type="password"]
50+
{
51+
border: none;
52+
border-bottom: 1px solid #fff;
53+
background: transparent;
54+
outline: none;
55+
height: 40px;
56+
color: #fff;
57+
font-size: 16px;
58+
}
59+
::placeholder
60+
{
61+
color: rgba(255,255,255,.5);
62+
}
63+
.loginBox input[type="submit"]
64+
{
65+
border: none;
66+
outline: none;
67+
height: 40px;
68+
color: #fff;
69+
font-size: 16px;
70+
background: #ff267e;
71+
cursor: pointer;
72+
border-radius: 20px;
73+
}
74+
.loginBox input[type="radio"]
75+
{
76+
77+
78+
79+
display: block;
80+
position: relative;
81+
font-weight: 300;
82+
font-size: 1.35em;
83+
padding: 25px 25px 25px 80px;
84+
margin: 10px auto;
85+
height: 30px;
86+
z-index: 9;
87+
cursor: pointer;
88+
-webkit-transition: all 0.25s linear;
89+
90+
91+
}
92+
.loginBox input[type="submit"]:hover
93+
{
94+
background: #efed40;
95+
color: #262626;
96+
}
97+
.loginBox a
98+
{
99+
color: #fff;
100+
font-size: 14px;
101+
font-weight: bold;
102+
text-decoration: none;
103+
}

Procedure call.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
from pubnub.callbacks import SubscribeCallback
2+
from pubnub.enums import PNStatusCategory
3+
from pubnub.pnconfiguration import PNConfiguration
4+
from pubnub.pubnub import PubNub
5+
pnconfig = PNConfiguration()
6+
7+
8+
import os
9+
import numpy as np
10+
from sklearn import preprocessing, cross_validation, neighbors , svm
11+
import pandas as pd
12+
13+
pnconfig = PNConfiguration()
14+
15+
pnconfig.subscribe_key = 'sub-c-f8ee4c62-2497-11e8-a183-761142583d66'
16+
pnconfig.publish_key = 'pub-c-89c7fbd5-76f5-4c6a-8511-c153e7517db4'
17+
18+
pubnub = PubNub(pnconfig)
19+
20+
df=pd.read_csv('data.csv')
21+
df.replace('?',-9999, inplace=True)
22+
X = np.array(df.drop(['Metal'],1))
23+
y = np.array(df['Metal'])
24+
25+
X_train,X_test,y_train,y_test = cross_validation.train_test_split(X,y,test_size=0.3)
26+
27+
clf = neighbors.KNeighborsClassifier()
28+
clf.fit(X_train,y_train)
29+
30+
def my_publish_callback(envelope, status):
31+
if not status.is_error():
32+
pass
33+
else:
34+
pass
35+
36+
accuracy = clf.score(X_test,y_test)
37+
a = str(accuracy)
38+
example_measures = np.array([[12],[75],[140]])
39+
example_measures = example_measures.reshape(3,-1)
40+
predictions = clf.predict(example_measures)
41+
np.savetxt("output1.txt",predictions, newline=",")
42+
file = open("output.txt","w")
43+
file.write(a)
44+
file.close()
45+
y=np.loadtxt("output1.txt",delimiter=",",usecols=(0,2),unpack=True)
46+
fout=open("result.php","w")
47+
out = 0
48+
for i in y:
49+
if(i==1):
50+
out += i*5
51+
elif(i==2):
52+
out += i*6
53+
else:
54+
out += i*7
55+
fout.write(str(out))
56+
fout.close()
57+
print(accuracy)
58+
print(predictions)
59+
60+
def status(self, pubnub, status):
61+
if status.category == PNStatusCategory.PNUnexpectedDisconnectCategory:
62+
pass
63+
64+
elif status.category == PNStatusCategory.PNConnectedCategory:
65+
66+
pubnub.publish().channel("Dear User,Thanks for user PubNub IoT Recycle").message("Hello!!").async(my_publish_callback)
67+
elif status.category == PNStatusCategory.PNReconnectedCategory:
68+
pass
69+
70+
elif status.category == PNStatusCategory.PNDecryptionErrorCategory:
71+
pass
72+
73+
74+
def message(self, pubnub, message):
75+
pass
76+
77+
pubnub.add_listener(MySubscribeCallback())
78+
pubnub.subscribe().channels('Dear User,Thanks for user PubNub IoT Recycle').execute()
79+
#out = (a*5)+(b*4)+(c*3)
80+
81+
82+
#np.savetxt("output.txt",(accuracy,predictions), fmt="%d")
83+

0 commit comments

Comments
 (0)