Initial commit
[2ch-be.git] / dev-test / artistbak / artist2.php
blobd1736811c5b15b6205e7b177870a90e399e93f47
1 <?php
2 if (!isset($_COOKIE['ADMDM']) && !isset($_COOKIE['AMDMD'])) {
3 header('location:artist_login.php');
4 exit;
6 include("a_cont.php");
8 if (!isset($_SESSION['utype'])) {
9 header("location: a_out.php");
12 echo $_SESSION['artistid'];
14 $email = Decrypt($_COOKIE['ADMDM'],AKEY);
15 $dir = loggedEmail($email, "adb/");
16 // echo $dir;
17 $dirFull = loggedEmail($email, ADB_PATH);
19 <!DOCTYPE html>
20 <html lang="en">
21 <head>
22 <meta charset="UTF-8">
23 <meta http-equiv="X-UA-Compatible" content="IE=edge">
24 <meta name="viewport" content="width=device-width, initial-scale=1">
25 <title>Artist Page</title>
26 <link rel="stylesheet" href="css/bootstrap.css">
27 <link rel="stylesheet" href="css/astyle.css">
28 </head>
29 <body>
30 <div class="container body">
31 <div class="row">
32 <div class="col-md-12">
33 <div class="panel panel-default">
34 <div class="panel-heading">
35 <center>
36 <img src="css/img/2ch_logo.gif" alt="">
37 </center>
38 </div>
39 <div class="main">
40 <div class="pull-right" style="margin:10px 0px;"><a href="a_out.php" class="btn btn-danger btn-sm" style="color:white;">LOGOUT</a></div>
41 <div class="clearfix"></div>
42 <div class="row">
43 <div class="col-md-3">
44 <div class="panel panel-default">
45 <div class="panel-heading">
46 <center>
47 <b>Options</b>
48 </center>
49 </div>
50 <ul id="al" style="list-style:none; display:inline;">
51 <?php if ($_SESSION['utype'] == "admin") { ?>
52 <li><a href="?crar">Create Artist Account</a>&nbsp;&nbsp;&nbsp;</li>
53 <li><a href="?vtrans">View Transactions</a>&nbsp;&nbsp;&nbsp;</li>
54 <li><a href="?alist">Artist List</a></li>
55 <?php } elseif ($_SESSION['utype'] == "user") { ?>
56 <li><a href="?art">Art List</a></li>
57 <li><a href="?upload">Upload Image</a>&nbsp;&nbsp;&nbsp;</li>
58 <?php } ?>
59 </ul>
60 </div>
61 </div>
62 <div class="col-md-9">
63 <?php
64 if(isset($_SESSION['msg'])){
65 echo $_SESSION['msg'];
66 $_SESSION['msg'] = '';
69 <div class="panel panel-default optionlistview" style="background:#f5f5f5;">
71 <?php if(isset($_GET['art'])){
73 if(file_exists("/home/adb/imglist.log")){
74 $file = file("/home/adb/imglist.log");
75 if(isset($_GET['c'])){
76 if($_GET['c']=="delete"){
77 $id = $_GET['id'];
78 $filename = within_str($file[$id], "<name>", "</name>");
79 $file[$id]= str_replace("<stat></stat>","<stat>deleted</stat>",$file[$id]);
80 $data = implode("", $file);
81 $handler = fopen("/home/adb/imglist.log", "w");
82 fwrite($handler, $data);
83 fclose($handler);
84 /*$test = unlink("/home/auth/public_html/dev-test/premium/".$filename.".jpg");*/
85 /*if($test){
86 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
87 header("Location: artist.php?art");
88 exit;
89 }else{
90 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to delete file. Either file doesn't exists</div>";
91 header("Location: artist.php?art");
92 exit;
93 }*/
94 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
95 header("Location: artist.php?art");
98 $i = 0;
99 foreach ($file as $key => $value) {
100 $img = within_str($value, "<name>", "</name>").".jpg";
101 $stat = within_str($value, "<stat>", "</stat>");
102 if(!$stat){
103 echo "<div class=\"thumbnail pull-left\" >";
104 echo "<img width=\"100px\" src=\"{$livesitePath}dev-test/premium/{$img}\" alt=\"{$key}\"><br><br>";
105 echo "<center>".within_str($value, "<name>", "</name>")." <br> "
106 .within_str($value, "<price>", "</price>"). " MELON <br> <a href=\"artist.php?art&c=delete&id={$i}\">delete </a></center>" ;
107 echo "</div>";
109 $i++;
110 if($i%4==0) { echo "<div class=\"clearfix\"></div>"; }
112 }else{
113 echo "Please upload your work";
117 }else if(isset($_GET['upload'])){ ?>
119 <?php
120 if(isset($_POST['submitupload'])){
121 if(is_numeric($_POST['price'])){
123 $price = (int) $_POST['price'];
124 $name = $_POST['name'];
126 $tmpName = $_FILES['uploadedfile']['tmp_name'];
128 $fdir = substr($email, 0, 1);
129 $sdir = substr($email, 1, 1);
130 $path = ADB_PATH."{$fdir}/{$sdir}/{$email}";
131 if (!file_exists($path)) {
132 @mkdir(ADB_PATH."{$fdir}");
133 @mkdir(ADB_PATH."{$fdir}/{$sdir}");
134 @mkdir(ADB_PATH."{$fdir}/{$sdir}/{$udir}");
136 if($_FILES["file"]["type"] == "image/gif"){
137 $dirPath = "/home/auth/public_html/dev-test/premium/";
138 $name = lcfirst($_POST['name'])."_".rand(10000,99999);
139 $fname = $name."gif";
140 if(!file_exists($dirPath.$fname)){
141 if(move_uploaded_file($tmpName, $dirPath.$fname)) {
142 $uploadedFile = true;
144 } else{
145 $uploadedFile = false;
147 }else{
148 $_SESSION['msg'] = "<div class=\"alert alert-danger\">File already exist.</div>";
149 header("Location: artist.php?upload");
150 exit;
152 }else{
153 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Please upload GIF image only.</div>";
154 header("Location: artist.php?upload");
155 exit;
159 // if($uploadedFile){
160 // $time = time();
161 // $writeData = "<time>{$time}</time><name>{$name}_".rand(00000,99999)."</name><price>{$price}</price>\n";
162 // $filename = $path."/imagelist.txt";
164 // if (!file_exists($filename)) {
165 // if(!file_put_contents($filename,$writeData)) {
166 // $writeSuccess = false;
167 // }
168 // $writeSuccess = true;
169 // } else {
170 // $handle = fopen($filename, "a");
171 // if(!fwrite($handle, $writeData)) {
172 // $writeSuccess = false;
173 // }
174 // fclose($handle);
175 // $writeSuccess = true;
176 // }
177 // }
179 if($uploadedFile){
180 $handle = fopen("/home/adb/imglist.log", "a+");
181 fwrite($handle, "<id>".$_SESSION['artistid']."</id><name>{$name}</name><price>{$price}</price><stat></stat>\n");
182 fclose($handle);
184 $_SESSION['msg'] = "<div class=\"alert alert-success\">File successfully uploaded.</div>";
185 header("Location: artist.php?art");
186 exit;
187 }else{
188 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to upload file. Please contact admin.</div>";
189 header("Location: artist.php?upload");
190 exit;
193 }else{
194 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Price must be numeric.</div>";
195 header("Location: artist.php?upload");
196 exit;
201 <form role="form" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>?upload" method="POST">
202 <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
203 <div class="form-group">
204 <label for="name">Name:</label> <br>
205 <input name="name" type="text" class="form-control" placeholder="Name"/><br />
206 </div>
207 <div class="form-group">
208 <label for="price">Price:</label> <br>
209 <input name="price" type="text" class="form-control" placeholder="Price"/><br />
210 </div>
211 <div class="form-group">
212 <label for="price">Uploaded File:</label> <br>
213 <input name="uploadedfile" class="form-control" type="file" placeholder="Price"/><br />
214 </div>
215 <input type="submit" class="btn btn-primary" name="submitupload" value="Upload File" />
216 <input type="reset" class="btn btn-danger" name="submit" value="Reset" />
217 </form>
220 <?php }else if(isset($_GET['edit'])){
221 $file = file(ADB_PATH."imglist.log");
222 // print_r(expression)
223 $index = $_GET['edit'];
224 $value = $file[$index];
225 $name = within_str($value, "<name>", "</name>");
226 $price = within_str($value, "<price>", "</price>");
227 $time = within_str($value, "<time>", "</time>");
228 $idVal = within_str($value, "<id>", "</id>");
231 if(isset($_POST['submitedit'])){
232 $index = $_GET['edit'];
233 $newName = lcfirst($_POST['name'])."_".rand(10000,99999);
234 $newPrice = $_POST['price'];
235 unset($file[$index]);
237 $file[$index] = "<id>".$idVal."</id><name>{$newName}</name><price>{$newPrice}</price><stat></stat>\n";
238 $data = implode("", $file);
239 $handler = fopen(ADB_PATH."imglist.log", "w");
240 fwrite($handler, $data);
241 fclose($handler);
242 rename("/home/auth/public_html/dev-test/premium/".$name.".gif", "/home/auth/public_html/dev-test/premium/".$newName.".gif");
243 $_SESSION['msg'] = "{$name} is changed into {$newName}.";
244 header("Location: artist.php?art");
245 exit;
250 <form role="form" action="<?php echo $_SERVER['PHP_SELF'] ?>?edit=<?=$index?>" method="POST">
251 <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
252 <div class="form-group">
253 <label for="name">Name:</label> <br>
254 <input name="name" type="text" class="form-control" value="<?php echo $name ?>" placeholder="Name"/><br />
255 </div>
256 <div class="form-group">
257 <label for="price">Price:</label> <br>
258 <input name="price" type="text" class="form-control" value="<?php echo within_str($value, "<price>", "</price>") ?>" placeholder="Price"/><br />
259 </div>
260 <input type="submit" class="btn btn-primary" name="submitedit" value="Submit" />
261 <input type="reset" class="btn btn-danger" name="submit" value="Reset" />
262 </form>
263 <?php } ?>
265 <!-- nakadisplay none to option for create artist account -->
266 <?php if (isset($_GET['crar'])) { ?>
267 <form role="form" method="post">
268 <div class="form-group">
269 <label for="email">Email address</label>
270 <input type="email" class="form-control" id="email" name="user" placeholder="Enter email">
271 </div>
272 <div class="form-group">
273 <label for="password">Password</label>
274 <input type="password" class="form-control" id="password" name="pass" placeholder="Password">
275 </div>
276 <div class="form-group">
277 <label for="confirmpassword">Confirm Password</label>
278 <input type="password" class="form-control" id="confirmpassword" name="cpass" placeholder="Confirm Password">
279 </div>
280 <input type="submit" class="btn btn-primary" name="asub" value="Create Artist">
281 </form>
282 <?php } ?>
283 <!-- END nakadisplay none to option for create artist account -->
285 <!-- option for view transaction -->
286 <?php if (isset($_GET['vtrans'])) { ?>
287 <table class="table table-striped" style="background:white;">
288 <tr>
289 <td>Number</td>
290 <td>Artist Name</td>
291 <td>Transaction</td>
292 <td>Date</td>
293 </tr>
294 <tr>
295 <td>1</td>
296 <td>Example Name</td>
297 <td>Melon Points</td>
298 <td>September 24, 2014</td>
299 </tr>
300 <tr>
301 <td>2</td>
302 <td>Example Name</td>
303 <td>Melon Points</td>
304 <td>September 24, 2014</td>
305 </tr>
306 <tr>
307 <td>3</td>
308 <td>Example Name</td>
309 <td>Melon Points</td>
310 <td>September 24, 2014</td>
311 </tr>
312 <tr>
313 <td>4</td>
314 <td>Example Name</td>
315 <td>Melon Points</td>
316 <td>September 24, 2014</td>
317 </tr>
318 </table>
319 <?php } ?>
320 <!-- END option for view transaction -->
321 <?php if (isset($_GET['alist'])) { ?>
322 <div class="row">
323 <div class="col-md-3">
324 <div class="panel panel-default">
325 <center>
326 <h4>Artist List</h4>
327 </center>
328 <ul id="al" style="list-style:none; display:inline;">
329 <?php include("a_list.php"); ?>
330 </ul>
331 </div>
332 </div>
333 <div class="col-md-9">
334 <div class="panel panel-default optionlistview">
335 <?php
336 if (isset($_GET['v'])) {
337 error_reporting(E_ALL); ini_set("display_errors", 1);
338 $__utmp = file(ADB_PATH."imglist.log");
339 foreach ($__utmp as $key => $value) {
340 if (trim($_GET['v']) == trim(within_str($value,"<id>","</id>")) && trim(within_str($value,"<stat>","</stat>")) != "deleted") {
341 echo "<div class=\"panel panel-default alist_art\">
342 <a href=\"#\" class=\"thumbnail\">
343 <img src=\"http://be.2ch.net/dev-test/premium/".within_str($value,"<name>","</name>")."\" style=\"width:80px; height:80px;\" alt=\"\">
344 </a>
345 <span class=\"pull-right\">MP</span>
346 <span class=\"pull-left\">Artist ID</span>
347 <div class=\"clearfix\"></div>
348 </div>";
353 <div class="clearfix"></div>
354 </div>
356 </div>
357 </div>
358 <?php } ?>
359 </div>
360 </div>
361 </div>
362 </div>
363 </div>
364 </div>
365 </div>
366 </div>
367 <!--script src="js/jquery-1.9.1.js"></script>
368 <script src="js/bootstrap.js"></script-->
369 </body>
370 </html>