-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileCreator2.php
201 lines (191 loc) · 11.3 KB
/
FileCreator2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
session_start();
echo 'How R U';
if(!isset($_SESSION["FileCreatorFlag"]))
{
header('Location: ./index.php');
}
else if(isset($_SESSION["FileCreatorFlag"])&& $_SESSION["FileCreatorFlag"]===TRUE)
{
echo ' Hello';
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mysql";
$maxsize = 2* 1024 * 1024;
$difference = new mysqli($servername, $username, $password, $dbname); // connection name is difference
if($difference->connect_error)
{
die("Connection Problem" . $conn->connect_error);
}
$TopicName1=$_SESSION["TopicName1"];
$TopicName2=$_SESSION["TopicName2"];
$ArticleName=$_SESSION["ArticleName"];
$fileString="Difference-".$TopicName1."-".$TopicName2."-".$_SESSION["AuthorId"];
echo $fileString;
$myPage=$fileString.".php";
echo file_exists($myPage);
$OpenReference= fopen($myPage, "w");
fwrite($OpenReference,"<?php");
fwrite($OpenReference,"session_start();");
fwrite($OpenReference,"?>");
fwrite($OpenReference,"<!DOCTYPE html>");
fwrite($OpenReference,'<html lang="en">');
fwrite($OpenReference,"<head>");
fwrite($OpenReference,"<title>Differencing.org</title>");
fwrite($OpenReference,'<meta charset="utf-8">');
fwrite($OpenReference,'<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/mystyle.css">
<link rel="stylesheet" href="css/TableStyle.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/main.css">
<script src="js/vendor/modernizr-2.8.3-respond-1.4.2.min.js"></script>
<style>
</style>');
fwrite($OpenReference,"</head>");
fwrite($OpenReference,"<body>");
fwrite($OpenReference,'<div class="navbar navbar-inverse">
<header>
<img src="images/dd.png" height="100" width="200" align="left">
<h1 color="green">Differencing.org</h1>
</header>
</div>');
fwrite($OpenReference,'<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Logo</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Programming</a></li>
<li><a href="#">Data Mining</a></li>
<li><a href="#">Basic Sciences</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
</ul>
</div>
</div>
</nav>
');
fwrite($OpenReference,'<div class="container-fluid text-center">
<div class="row content">
<div class="col-sm-2 sidenav">
<p><a href="#">Link</a></p>
<p><a href="#">Link</a></p>
<p><a href="#">Link</a></p>
<p><a href="#">
</a></p>
</div> ');
fwrite($OpenReference,'<div class="col-sm-8 text-left">');//Table Content Start.
$ExtractQuerry="select *from ".$ArticleName."";
$result = $difference->query($ExtractQuerry);
fwrite($OpenReference, ' <div class=" row container-fluid text-center" ><h2>Difference between '.$TopicName1.' and '.$TopicName2.'.</h2></div>');
fwrite($OpenReference,'<div class=" row container-fluid">');
fwrite($OpenReference,'<table>');
$rowcount=mysqli_num_rows($result);
//fwrite($OpenReference,'<tr><td>00000001'.$rowcount.'</td></tr>');
if ($rowcount> 0)
{
//fwrite($OpenReference,'<tr><td>1111111111</td></tr>');
fwrite($OpenReference,'<tr>');
fwrite($OpenReference,'<th>S.N.</th>');
fwrite($OpenReference,'<th>'.$TopicName1.'</th>');
fwrite($OpenReference,'<th>'.$TopicName2.'</th>');
fwrite($OpenReference,'</tr>');
//fwrite($OpenReference,'<tr><td>22222222</td></tr>');
while($row = mysqli_fetch_assoc($result))
{
//fwrite($OpenReference,'<tr>');
// fwrite($OpenReference,'<td>333333333</td>');
//fwrite($OpenReference,'</tr>');
if(($row['topic1']!=='' && $row['topic2']!=='')&& ($row['imgname1']!=='' && $row['imgname2']!==''))
{
fwrite($OpenReference,'<tr>');
fwrite($OpenReference,'<td>'.$row['sn'].'</td>');
fwrite($OpenReference,'<td><p>'.$row['topic1'].'</p><img src="upload/'.$row['imgname1'].'" alt="Differencing.org" class="img-responsive img-rounded"></td>');
fwrite($OpenReference,'<td><p>'.$row['topic2'].'</p><img src="upload/'.$row['imgname2'].'" alt="Differencing.org" class="img-responsive img-rounded"></td>');
fwrite($OpenReference,'</tr>');
}
else if(($row[topic1]!=='' && $row['topic2']!==''))
{
fwrite($OpenReference,'<tr>');
fwrite($OpenReference,'<td>'.$row['sn'].'</td>');
fwrite($OpenReference,'<td><p>'.$row['topic1'].'</p></td>');
fwrite($OpenReference,'<td><p>'.$row['topic2'].'</p></td>');
fwrite($OpenReference,'</tr>');
}
else if(($row[topic1]==='' && $row['topic2']==='')&&($row['imgname1']!=='' && $row['imgname2']!==''))
{
fwrite($OpenReference,'<tr>');
fwrite($OpenReference,'<td>'.$row['sn'].'</td>');
fwrite($OpenReference,'<td><img src="upload/'.$row['imgname1'].'" alt="Differencing.org" class="img-responsive img-rounded"></td>');
fwrite($OpenReference,'<td><img src="upload/'.$row['imgname2'].'" alt="Differencing.org" class="img-responsive img-rounded"></td>');
fwrite($OpenReference,'</tr>');
}
}
}
else
{
echo "0 results";
}
fwrite($OpenReference,'</table>');
fwrite($OpenReference,'</div>');
fwrite($OpenReference,'<div class=" row container-fluid text-right color1" ><h5><a href=""><i>By:</i> Mahendra Gupta (M.Tech,JNU New Delhi) </a></h5></div>');
fwrite($OpenReference,'<div class=" row container-fluid text-left"><h4><i>References:</i></h4></div>');
fwrite($OpenReference,'<div class=" row container-fluid">');
$ExtractQuerry="select *from ".$ArticleName."";
$result = $difference->query($ExtractQuerry);
$rowcount=mysqli_num_rows($result);
if ($rowcount> 0)
{
fwrite($OpenReference,'<ol>');
while($row = mysqli_fetch_assoc($result))
{
//fwrite($OpenReference,'<tr>');
// fwrite($OpenReference,'<td>333333333</td>');
//fwrite($OpenReference,'</tr>');
if(($row['referencename']!=='' && $row['referenceurl']!==''))
{
fwrite($OpenReference,'<li><a href="'.$row['referenceurl'].'" target="_blank">'.$row['referencename'] .'.</li>');
}
else if(($row['referencename']!=='' && $row['referenceurl']===''))
{
fwrite($OpenReference,'<li><a href="#">'.$row['referencename'] .'.</li>');
}
else if(($row['referencename']==='' && $row['referenceurl']!==''))
{
fwrite($OpenReference,'<li><a href="'.$row['referenceurl'].'" target="_blank">'.$row['referenceurl'].'.</li>');
}
}
}
$difference->close();
fwrite($OpenReference,'</div>');
fwrite($OpenReference,'</div>');//Table Content Ends.
fwrite($OpenReference,'<div class="col-sm-2 sidenav">
<div class="well">
<p>ADS</p>
</div>
<div class="well">
<p>ADS</p>
</div>
</div>
</div>
</div>
<footer class="container-fluid text-center">
<p>Footer Text</p>
</footer>
</body>
</html>
');
header('Location: ./'.$myPage.'');
}