Initial commit
[2ch-be.git] / dev-test / artist / bak / artist2.php
blob192bf65887188af1a721132945536527a98cebe7
1 <?php
2 if (!isset($_COOKIE['ADMDM']) && !isset($_COOKIE['AMDMD'])) {
3 header('location:artist_login.php');
4 exit;
6 include("a_cont.php");
7 if (!isset($_SESSION['utype'])) {
8 header("location: a_out.php");
11 $email = Decrypt($_COOKIE['ADMDM'],AKEY);
12 $dir = loggedEmail($email, "adb/");
13 // echo $dir;
14 $howmany = file(ADB_PATH."/transaction.log");
15 $dirFull = loggedEmail($email, ADB_PATH);
17 <!DOCTYPE html>
18 <html lang="en">
19 <head>
20 <meta charset="UTF-8">
21 <meta http-equiv="X-UA-Compatible" content="IE=edge">
22 <meta name="viewport" content="width=device-width, initial-scale=1">
23 <title>Artist Page</title>
24 <link rel="stylesheet" href="css/bootstrap.css">
25 <link rel="stylesheet" href="css/astyle.css">
26 </head>
27 <body>
28 <div class="container body">
29 <div class="row">
30 <div class="col-md-12">
31 <div class="panel panel-default">
32 <div class="panel-heading">
33 <center>
34 <img src="css/img/2ch_logo.gif" alt="">
35 </center>
36 </div>
37 <div class="main">
38 <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>
39 <div class="pull-left" style="margin:10px 0px;">
40 <h4><i>Welcome,</i><b>
41 <?php
42 $artistname = explode ("@", $_SESSION['aname']);
43 echo $artistname[0];
44 ?>!</b></h4>
45 </div>
46 <div class="clearfix"></div>
47 <div class="row">
48 <div class="col-md-3">
49 <div class="panel panel-default">
50 <div class="panel-heading">
51 <center>
52 <b>Options</b>
53 </center>
54 </div>
55 <ul id="al" style="list-style:none; display:inline;">
56 <?php if ($_SESSION['utype'] == "admin") { ?>
57 <li><a href="?crar">Create Artist Account</a>&nbsp;&nbsp;&nbsp;</li>
58 <li><a href="?vtrans">View Transactions</a>&nbsp;&nbsp;&nbsp;</li>
59 <li><a href="?alist">Artist List</a></li>
60 <?php } elseif ($_SESSION['utype'] == "user") { ?>
61 <li><a href="?art">Art List</a></li>
62 <li><a href="?upload">Upload Image</a>&nbsp;&nbsp;&nbsp;</li>
63 <?php } ?>
64 </ul>
65 </div>
66 </div>
67 <div class="col-md-9">
69 <?php
70 if(empty($_GET)){
71 echo "<h3><b>Artist Area!</b></h3>";
73 if(isset($_SESSION['msg'])){
74 echo $_SESSION['msg'];
75 $_SESSION['msg'] = '';
79 <?php if(isset($_GET['art'])){
80 echo "<div class=\"panel panel-default optionlistview\"><div class=\"panel-heading\"><center><b>Artworks</b></center></div><br>";
82 if(file_exists("/home/adb/imglist.log")){
83 $file = file("/home/adb/imglist.log");
84 if(isset($_GET['c'])){
85 if($_GET['c']=="delete"){
86 $id = $_GET['id'];
87 $filename = within_str($file[$id], "<name>", "</name>");
88 $file[$id]= str_replace("<stat></stat>","<stat>deleted</stat>",$file[$id]);
89 $data = implode("", $file);
90 $handler = fopen("/home/adb/imglist.log", "w");
91 fwrite($handler, $data);
92 fclose($handler);
93 /*$test = unlink("/home/auth/public_html/premium/".$filename.".jpg");*/
94 /*if($test){
95 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
96 header("Location: artist.php?art");
97 exit;
98 }else{
99 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to delete file. Either file doesn't exists</div>";
100 header("Location: artist.php?art");
101 exit;
103 $_SESSION['msg'] = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>We've successfully deleted the file.</div>";
104 header("Location: artist.php?art");
107 $i = 0;
108 foreach ($file as $key => $value) {
109 $img = within_str($value, "<name>", "</name>").".gif";
110 $stat = within_str($value, "<stat>", "</stat>");
111 $id = within_str($value, "<id>", "</id>");
112 if(!$stat && $id==$_SESSION['artistid']){
113 $hmctr = 0;
114 $hmimg = explode(".gif", trim($img));
115 foreach ($howmany as $key9 => $value9) {
116 if (within_str(trim($value9), "<name>", "</name>") == trim($hmimg[0])) {
117 $hmctr++;
119 /*echo within_str(trim($value9), "<name>", "</name>");*/
121 echo "<div class=\"panel panel-default alist_art\">";
122 echo "<a href=\"#\" class=\"thumbnail\" style=\"margin-bottom: 1em!important;\">";
123 echo "<img src=\"{$livesitePath}premium/{$img}\" style=\"height:80px;\" alt=\"\">";
124 echo "</a>";
125 echo "<center>";
126 echo "<span>" .within_str($value, "<price>", "</price>"). " MP<br>{$hmctr} time/s bought</span><br>";
127 echo "<a href=\"artist.php?art&c=delete&id={$i}\">delete </a>";
128 echo "<a href=\"artist.php?edit={$i}\">edit </a></center>";
129 echo "<div class=\"clearfix\"></div>";
130 echo " </div>";
132 $i++;
133 // if($i%4==0) { echo "<div class=\"clearfix\"></div>"; }
136 echo "<div class=\"clearfix\"></div>";
137 }else{
138 echo "Please upload your work";
141 echo "</div>";
143 }else if(isset($_GET['upload'])){ ?>
145 <?php
148 if(isset($_POST['submitupload'])){
149 if($_POST['price'] == 0 || !isset($_POST['price'])){
150 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>MP amount is 0.</div>";
151 header("Location: artist.php?upload");
152 exit;
154 if($_FILES['uploadedfile']['size']<100000){
155 if(is_numeric($_POST['price'])){
157 $price = (int) $_POST['price'];
158 $price = round(abs($price));
159 $name = $_POST['name'];
161 $tmpName = $_FILES['uploadedfile']['tmp_name'];
163 $fdir = substr($email, 0, 1);
164 $sdir = substr($email, 1, 1);
165 $path = ADB_PATH."{$fdir}/{$sdir}/{$email}";
166 if (!file_exists($path)) {
167 @mkdir(ADB_PATH."{$fdir}");
168 @mkdir(ADB_PATH."{$fdir}/{$sdir}");
169 @mkdir(ADB_PATH."{$fdir}/{$sdir}/{$udir}");
171 // echo $_FILES["file"]["type"];
172 // die;
173 if($_FILES["uploadedfile"]["type"] == "image/gif"){
174 $dirPath = "/home/auth/public_html/premium/";
175 $name = rand(1000000,9999999);
176 $fname = $name.".gif";
177 if(!file_exists($dirPath.$fname)){
178 if(move_uploaded_file($tmpName, $dirPath.$fname)) {
179 $uploadedFile = true;
181 } else{
182 $uploadedFile = false;
184 }else{
185 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>File already exist.</div>";
186 header("Location: artist.php?upload");
187 exit;
189 }else{
190 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>Please upload GIF image only.</div>";
191 header("Location: artist.php?upload");
192 exit;
196 // if($uploadedFile){
197 // $time = time();
198 // $writeData = "<time>{$time}</time><name>{$name}_".rand(00000,99999)."</name><price>{$price}</price>\n";
199 // $filename = $path."/imagelist.txt";
201 // if (!file_exists($filename)) {
202 // if(!file_put_contents($filename,$writeData)) {
203 // $writeSuccess = false;
204 // }
205 // $writeSuccess = true;
206 // } else {
207 // $handle = fopen($filename, "a");
208 // if(!fwrite($handle, $writeData)) {
209 // $writeSuccess = false;
210 // }
211 // fclose($handle);
212 // $writeSuccess = true;
213 // }
214 // }
216 if($uploadedFile){
217 $handle = fopen("/home/adb/imglist.log", "a+");
218 fwrite($handle, "<id>".$_SESSION['artistid']."</id><name>{$name}</name><price>{$price}</price><stat></stat>\n");
219 fclose($handle);
221 $_SESSION['msg'] = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>File successfully uploaded.</div>";
222 header("Location: artist.php?art");
223 exit;
224 }else{
225 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>Unable to upload file. Please contact admin.</div>";
226 header("Location: artist.php?upload");
227 exit;
230 }else{
231 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>Price must be numeric.</div>";
232 header("Location: artist.php?upload");
233 exit;
235 }else{
236 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>File size is more than 100kb.</div>";
237 header("Location: artist.php?upload");
238 exit;
244 <div class="panel panel-default optionlistview">
245 <div class="panel-heading">
246 <center><b>Upload Artwork</b></center>
247 </div><br>
248 <form role="form" style="width:50%;" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>?upload" method="POST">
249 <div class="form-group">
250 <label for="price">Price:</label> <br>
251 <input name="price" type="text" class="form-control" placeholder="Price" required/><br />
252 </div>
253 <div class="form-group">
254 <label for="price">Uploaded File: </label> <br>
255 <input name="uploadedfile" class="form-control" type="file" placeholder="Price" required/>
256 <span style="font-size:12px;margin-top:3px;" class="pull-right">(only .gif image is accepted)</span>
257 <div class="clearfix"></div>
258 </div>
259 <input type="submit" class="btn btn-primary" name="submitupload" value="Upload File" />
260 <input type="reset" class="btn btn-danger" name="submit" value="Reset" />
261 </form>
262 </div>
265 <?php }else if(isset($_GET['edit'])){
267 echo "<div class=\"panel panel-default optionlistview\">";
268 if(empty($_GET['edit'])){
269 echo "aa";
270 exit;
271 // $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button></div>";
272 header("Location: artist.php?art");
273 exit;
276 $file = file(ADB_PATH."imglist.log");
277 // print_r(expression)
278 $index = $_GET['edit'];
279 $file[$index];
280 /*var_dump($index);
281 var_dump($file);
282 exit;*/
283 if($file[$index]){
284 $value = $file[$index];
285 $name = within_str($value, "<name>", "</name>");
286 $price = within_str($value, "<price>", "</price>");
287 $time = within_str($value, "<time>", "</time>");
288 $idVal = within_str($value, "<id>", "</id>");
291 if(isset($_POST['submitedit'])){
292 if($_POST['price'] == 0 || !isset($_POST['price'])){
293 $_SESSION['msg'] = "<div class=\"alert alert-danger\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>MP amount is 0.</div>";
294 header("Location: artist.php?art");
295 exit;
297 $index = $_GET['edit'];
298 // $newName = rand(1000000,9999999);
299 $newPrice = round(abs($_POST['price']));
300 unset($file[$index]);
302 $file[$index] = "<id>".$idVal."</id><name>{$name}</name><price>{$newPrice}</price><stat></stat>\n";
303 $data = implode("", $file);
304 $handler = fopen(ADB_PATH."imglist.log", "w");
305 fwrite($handler, $data);
306 fclose($handler);
307 // rename("/home/auth/public_html/premium/".$name.".gif", "/home/auth/public_html/premium/".$newName.".gif");
308 $_SESSION['msg'] = "<div class=\"alert alert-success\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>Successfully edit.</div>";
309 header("Location: artist.php?art");
310 exit;
313 }else{
314 header("Location: artist.php?art");
315 exit;
318 <div class="panel panel-default alist_art">
319 <a href="#" class="thumbnail">
320 <img src="<?php echo $livesitePath ?>premium/<?php echo $name ?>" style="height:80px;" alt="">
321 </a>
322 </div>
323 <div class="clearfix"></div>
324 <br>
325 <form role="form" action="<?php echo $_SERVER['PHP_SELF'] ?>?edit=<?=$index?>" style="width:50%;" method="POST">
326 <div class="form-group">
327 <label for="price">Price:</label> <br>
328 <input name="price" type="text" class="form-control" value="<?php echo within_str($value, "<price>", "</price>") ?>" placeholder="Price" required/><br />
329 </div>
330 <input type="submit" class="btn btn-primary" name="submitedit" value="Submit" />
331 </form>
332 <?php echo "</div>";} ?>
334 <!-- nakadisplay none to option for create artist account -->
335 <?php if (isset($_GET['crar'])) {
336 if ($_SESSION['utype'] != "admin")
337 die("NG");
339 <div class="panel panel-default optionlistview">
340 <div class="panel-heading">
341 <center><b>Add New Artist</b></center>
342 </div><br>
343 <center>
344 <form role="form" method="post" style="width:50%;">
345 <div class="form-group">
346 <label for="email" class="pull-left">Email address</label>
347 <input type="email" class="form-control" id="email" name="user" placeholder="Enter email">
348 </div>
349 <div class="form-group">
350 <label for="password" class="pull-left">Password</label>
351 <input type="password" class="form-control" id="password" name="pass" placeholder="Password">
352 </div>
353 <div class="form-group">
354 <label for="confirmpassword" class="pull-left">Confirm Password</label>
355 <input type="password" class="form-control" id="confirmpassword" name="cpass" placeholder="Confirm Password">
356 </div>
357 <input type="submit" class="btn btn-primary pull-left" name="asub" value="Create Artist">
358 <div class="clearfix"></div>
359 </form>
360 </center>
361 </div>
362 <?php } ?>
363 <!-- END nakadisplay none to option for create artist account -->
365 <!-- option for view transaction -->
366 <?php if (isset($_GET['vtrans'])) {
367 if ($_SESSION['utype'] != "admin")
368 die("NG");
370 <div class="panel panel-default optionlistview">
371 <div class="panel-heading">
372 <center><b>Transactions</b></center>
373 </div><br>
374 <?php
375 if (!file_exists(ADB_PATH."artistlist.log")) {
376 echo "No transactions";
377 } else {
378 if (!file_exists(ADB_PATH."transaction.log")) {
379 echo "No transactions";
380 exit;
381 } else {
382 echo "<table class=\"table table-striped\" style=\"background:white;\">
383 <tr>
384 <td><b>User</b></td>
385 <td><b>Total Sold (MP)</b></td>
386 </tr>";
387 $arus = file(ADB_PATH."artistlist.log");
388 $i = 0;
389 foreach ($arus as $key => $value) {
390 $tmar = explode("<><>", $value);
391 $usemail[$i] = $tmar[1];
392 $arid[$i] = $tmar[0];
393 $i++;
395 $vtrans = file(ADB_PATH."transaction.log");
396 foreach ($vtrans as $key2 => $value2) {
397 $arr = within_str($value2,"<id>","</id>");
398 $val = within_str($value2,"<price>","</price>");
399 $kk = array_search($arr, $arid);
400 /*echo $arr."-".$val."-".$kk."<br>";*/
401 if (isset($arval[$kk])) {
402 $arval[$kk] = $arval[$kk]+$val;
403 } else {
404 $arval[$kk] = $val;
407 foreach ($arid as $key => $value) {
408 if ($value!=66666666) {
409 $kk = array_search($value, $arid);
410 /*if ($arval[$kk] != "" || $arval[$kk] != NULL) {*/
411 if (isset($arval[$kk])) {
412 echo "<tr>
413 <td>".$usemail[$kk]."</td>
414 <td>".@$arval[$kk]." Melon Points</td>
415 </tr>";
422 </table>
423 </div>
424 <?php } ?>
425 <!-- END option for view transaction -->
426 <?php if (isset($_GET['alist'])) {
427 if ($_SESSION['utype'] != "admin")
428 die("NG");
430 <div class="row">
431 <div class="col-md-3">
432 <div class="panel panel-default">
433 <center>
434 <h4>Artist List</h4>
435 </center>
436 <ul id="al" class="wordwrap_" style="list-style:none; display:inline;">
437 <?php include("a_list.php"); ?>
438 </ul>
439 </div>
440 </div>
441 <div class="col-md-9">
442 <div class="panel panel-default optionlistview">
443 <div class="panel-heading"><center><b>Artworks</b></center></div><br>
444 <?php
445 if (isset($_GET['v'])) {
446 error_reporting(E_ALL); ini_set("display_errors", 1);
447 if (!file_exists(ADB_PATH."imglist.log")) {
448 # code...
449 } else {
450 $__utmp = file(ADB_PATH."imglist.log");
451 foreach ($__utmp as $key => $value) {
452 if (trim($_GET['v']) == trim(within_str($value,"<id>","</id>")) && trim(within_str($value,"<stat>","</stat>")) != "deleted") {
453 echo "<div class=\"panel panel-default alist_art\">
454 <a href=\"#\" class=\"thumbnail\" style=\"margin-bottom: 1em!important;\">
455 <img src=\"http://be.2ch.net/premium/".within_str($value,"<name>","</name>")."\" style=\"height:80px;\" alt=\"\">
456 </a>
457 <span class=\"pull-right\">".within_str($value, "<price>", "</price>")."MP</span>
458 <div class=\"clearfix\"></div>
459 </div>";
463 } else {
464 echo "Select Artist";
467 <div class="clearfix"></div>
468 </div>
470 </div>
471 </div>
472 <?php } ?>
473 <div class="clearfix"></div>
474 <!-- </div> -->
475 </div>
476 </div>
477 </div>
478 </div>
479 </div>
480 </div>
481 </div>
482 <script src="js/jquery-1.9.1.js"></script>
483 <script src="js/bootstrap.js"></script>
484 </body>
485 </html>