Initial commit
[2ch-be.git] / dev-test / artistbak / artiststeve.php
blobaa301d0ef27196195f456fd5a1e21ec2a7c8931d
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 $dirFull = loggedEmail($email, ADB_PATH);
16 function FindUser($id) {
17 $list = file("/home/adb/artistlist.log");
18 $em = "";
19 $err = true;
20 foreach ($list as $key => $value) {
21 if (substr(trim($value), 0, 9) == $id) {
22 $r = explode("<><>", $value);
23 $em = trim($r[1]);
24 $err = false;
27 if ($err) {
28 return false;
30 return $em;
35 <!DOCTYPE html>
36 <html lang="en">
37 <head>
38 <meta charset="UTF-8">
39 <meta http-equiv="X-UA-Compatible" content="IE=edge">
40 <meta name="viewport" content="width=device-width, initial-scale=1">
41 <title>Artist Page</title>
42 <link rel="stylesheet" href="css/bootstrap.css">
43 <link rel="stylesheet" href="css/astyle.css">
44 </head>
45 <body>
46 <div class="container body">
47 <div class="row">
48 <div class="col-md-12">
49 <div class="panel panel-default">
50 <div class="panel-heading">
51 <center>
52 <img src="css/img/2ch_logo.gif" alt="">
53 </center>
54 </div>
55 <div class="main">
56 <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>
57 <div class="pull-left" style="margin:10px 0px;">
58 <h4><i>Welcome,</i><b>
59 <?php
60 $artistname = explode ("@", $_SESSION['aname']);
61 echo $artistname[0];
62 ?>!</b></h4>
63 </div>
64 <div class="clearfix"></div>
65 <div class="row">
66 <div class="col-md-3">
67 <div class="panel panel-default">
68 <div class="panel-heading">
69 <center>
70 <b>Options</b>
71 </center>
72 </div>
73 <ul id="al" style="list-style:none; display:inline;">
74 <?php if ($_SESSION['utype'] == "admin") { ?>
75 <li><a href="?crar">Create Artist Account</a>&nbsp;&nbsp;&nbsp;</li>
76 <li><a href="?vtrans">View Transactions</a>&nbsp;&nbsp;&nbsp;</li>
77 <li><a href="?alist">Artist List</a></li>
78 <?php } elseif ($_SESSION['utype'] == "user") { ?>
79 <li><a href="?art">Art List</a></li>
80 <li><a href="?upload">Upload Image</a>&nbsp;&nbsp;&nbsp;</li>
81 <?php } ?>
82 </ul>
83 </div>
84 </div>
85 <div class="col-md-9">
87 <?php
88 if(empty($_GET)){
89 echo "<h3><b>Artist Area!</b></h3>";
91 if(isset($_SESSION['msg'])){
92 echo $_SESSION['msg'];
93 $_SESSION['msg'] = '';
97 <?php if(isset($_GET['art'])){
98 echo "<div class=\"panel panel-default optionlistview\"><div class=\"panel-heading\"><center><b>Artworks</b></center></div><br>";
100 if(file_exists("/home/adb/imglist.log")){
101 $file = file("/home/adb/imglist.log");
102 if(isset($_GET['c'])){
103 if($_GET['c']=="delete"){
104 $id = $_GET['id'];
105 $filename = within_str($file[$id], "<name>", "</name>");
106 $file[$id]= str_replace("<stat></stat>","<stat>deleted</stat>",$file[$id]);
107 $data = implode("", $file);
108 $handler = fopen("/home/adb/imglist.log", "w");
109 fwrite($handler, $data);
110 fclose($handler);
111 /*$test = unlink("/home/auth/public_html/dev-test/premium/".$filename.".jpg");*/
112 /*if($test){
113 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
114 header("Location: artist.php?art");
115 exit;
116 }else{
117 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to delete file. Either file doesn't exists</div>";
118 header("Location: artist.php?art");
119 exit;
121 $_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>";
122 header("Location: artist.php?art");
125 $i = 0;
126 foreach ($file as $key => $value) {
127 $img = within_str($value, "<name>", "</name>").".gif";
128 $stat = within_str($value, "<stat>", "</stat>");
129 $id = within_str($value, "<id>", "</id>");
130 if(!$stat && $id==$_SESSION['artistid']){
131 echo "<div class=\"panel panel-default alist_art\">";
132 echo "<a href=\"#\" class=\"thumbnail\" style=\"margin-bottom: 1em!important;\">";
133 echo "<img src=\"{$livesitePath}dev-test/premium/{$img}\" style=\"height:80px;\" alt=\"\">";
134 echo "</a>";
135 echo "<center>";
136 echo "<span>" .within_str($value, "<price>", "</price>"). " MP</span><br>";
137 echo "<a href=\"artist.php?art&c=delete&id={$i}\">delete </a>";
138 echo "<a href=\"artist.php?edit={$i}\">edit </a></center>";
139 echo "<div class=\"clearfix\"></div>";
140 echo " </div>";
142 $i++;
143 // if($i%4==0) { echo "<div class=\"clearfix\"></div>"; }
146 echo "<div class=\"clearfix\"></div>";
147 }else{
148 echo "Please upload your work";
151 echo "</div>";
153 }else if(isset($_GET['upload'])){ ?>
155 <?php
158 if(isset($_POST['submitupload'])){
159 if($_FILES['uploadedfile']['size']<100000){
160 if(is_numeric($_POST['price'])){
162 $price = (int) $_POST['price'];
163 $price = abs($price);
164 $name = $_POST['name'];
166 $tmpName = $_FILES['uploadedfile']['tmp_name'];
168 $fdir = substr($email, 0, 1);
169 $sdir = substr($email, 1, 1);
170 $path = ADB_PATH."{$fdir}/{$sdir}/{$email}";
171 if (!file_exists($path)) {
172 @mkdir(ADB_PATH."{$fdir}");
173 @mkdir(ADB_PATH."{$fdir}/{$sdir}");
174 @mkdir(ADB_PATH."{$fdir}/{$sdir}/{$udir}");
176 // echo $_FILES["file"]["type"];
177 // die;
178 if($_FILES["uploadedfile"]["type"] == "image/gif"){
179 $dirPath = "/home/auth/public_html/dev-test/premium/";
180 $name = rand(1000000,9999999);
181 $fname = $name.".gif";
182 if(!file_exists($dirPath.$fname)){
183 if(move_uploaded_file($tmpName, $dirPath.$fname)) {
184 $uploadedFile = true;
186 } else{
187 $uploadedFile = false;
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>File already exist.</div>";
191 header("Location: artist.php?upload");
192 exit;
194 }else{
195 $_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>";
196 header("Location: artist.php?upload");
197 exit;
201 // if($uploadedFile){
202 // $time = time();
203 // $writeData = "<time>{$time}</time><name>{$name}_".rand(00000,99999)."</name><price>{$price}</price>\n";
204 // $filename = $path."/imagelist.txt";
206 // if (!file_exists($filename)) {
207 // if(!file_put_contents($filename,$writeData)) {
208 // $writeSuccess = false;
209 // }
210 // $writeSuccess = true;
211 // } else {
212 // $handle = fopen($filename, "a");
213 // if(!fwrite($handle, $writeData)) {
214 // $writeSuccess = false;
215 // }
216 // fclose($handle);
217 // $writeSuccess = true;
218 // }
219 // }
221 if($uploadedFile){
222 $handle = fopen("/home/adb/imglist.log", "a+");
223 fwrite($handle, "<id>".$_SESSION['artistid']."</id><name>{$name}</name><price>{$price}</price><stat></stat>\n");
224 fclose($handle);
226 $_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>";
227 header("Location: artist.php?art");
228 exit;
229 }else{
230 $_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>";
231 header("Location: artist.php?upload");
232 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>Price must be numeric.</div>";
237 header("Location: artist.php?upload");
238 exit;
240 }else{
241 $_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>";
242 header("Location: artist.php?upload");
243 exit;
249 <div class="panel panel-default optionlistview">
250 <div class="panel-heading">
251 <center><b>Upload Artwork</b></center>
252 </div><br>
253 <form role="form" style="width:50%;" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>?upload" method="POST">
254 <div class="form-group">
255 <label for="price">Price:</label> <br>
256 <input name="price" type="text" class="form-control" placeholder="Price"/><br />
257 </div>
258 <div class="form-group">
259 <label for="price">Uploaded File: </label> <br>
260 <input name="uploadedfile" class="form-control" type="file" placeholder="Price"/>
261 <span style="font-size:12px;margin-top:3px;" class="pull-right">(only .gif image is accepted)</span>
262 <div class="clearfix"></div>
263 </div>
264 <input type="submit" class="btn btn-primary" name="submitupload" value="Upload File" />
265 <input type="reset" class="btn btn-danger" name="submit" value="Reset" />
266 </form>
267 </div>
270 <?php }else if(isset($_GET['edit'])){
271 echo "<div class=\"panel panel-default optionlistview\">";
273 $file = file(ADB_PATH."imglist.log");
274 // print_r(expression)
275 $index = $_GET['edit'];
276 $value = $file[$index];
277 $name = within_str($value, "<name>", "</name>");
278 $price = within_str($value, "<price>", "</price>");
279 $time = within_str($value, "<time>", "</time>");
280 $idVal = within_str($value, "<id>", "</id>");
283 if(isset($_POST['submitedit'])){
284 $index = $_GET['edit'];
285 // $newName = rand(1000000,9999999);
286 $newPrice = abs($_POST['price']);
287 unset($file[$index]);
289 $file[$index] = "<id>".$idVal."</id><name>{$name}</name><price>{$newPrice}</price><stat></stat>\n";
290 $data = implode("", $file);
291 $handler = fopen(ADB_PATH."imglist.log", "w");
292 fwrite($handler, $data);
293 fclose($handler);
294 // rename("/home/auth/public_html/dev-test/premium/".$name.".gif", "/home/auth/public_html/dev-test/premium/".$newName.".gif");
295 $_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>";
296 header("Location: artist.php?art");
297 exit;
301 <div class="panel panel-default alist_art">
302 <a href="#" class="thumbnail">
303 <img src="<?php echo $livesitePath ?>dev-test/premium/<?php echo $name ?>" style="height:80px;" alt="">
304 </a>
305 </div>
306 <div class="clearfix"></div>
307 <br>
308 <form role="form" action="<?php echo $_SERVER['PHP_SELF'] ?>?edit=<?=$index?>" style="width:50%;" method="POST">
309 <div class="form-group">
310 <label for="price">Price:</label> <br>
311 <input name="price" type="text" class="form-control" value="<?php echo within_str($value, "<price>", "</price>") ?>" placeholder="Price"/><br />
312 </div>
313 <input type="submit" class="btn btn-primary" name="submitedit" value="Submit" />
314 </form>
315 <?php echo "</div>";} ?>
317 <!-- nakadisplay none to option for create artist account -->
318 <?php if (isset($_GET['crar'])) { ?>
319 <div class="panel panel-default optionlistview">
320 <div class="panel-heading">
321 <center><b>Add New Artist</b></center>
322 </div><br>
323 <center>
324 <form role="form" method="post" style="width:50%;">
325 <div class="form-group">
326 <label for="email" class="pull-left">Email address</label>
327 <input type="email" class="form-control" id="email" name="user" placeholder="Enter email">
328 </div>
329 <div class="form-group">
330 <label for="password" class="pull-left">Password</label>
331 <input type="password" class="form-control" id="password" name="pass" placeholder="Password">
332 </div>
333 <div class="form-group">
334 <label for="confirmpassword" class="pull-left">Confirm Password</label>
335 <input type="password" class="form-control" id="confirmpassword" name="cpass" placeholder="Confirm Password">
336 </div>
337 <input type="submit" class="btn btn-primary pull-left" name="asub" value="Create Artist">
338 <div class="clearfix"></div>
339 </form>
340 </center>
341 </div>
342 <?php } ?>
343 <!-- END nakadisplay none to option for create artist account -->
345 <!-- option for view transaction -->
346 <?php if (isset($_GET['vtrans'])) { ?>
347 <div class="panel panel-default optionlistview">
348 <div class="panel-heading">
349 <center><b>Transactions</b></center>
350 </div><br>
351 <?php
352 if (!file_exists(ADB_PATH."artistlist.log")) {
353 echo "No transactions";
354 } else {
355 if (!file_exists(ADB_PATH."transaction.log")) {
356 echo "No transactions";
357 exit;
358 } else {
359 echo "<div class=\"panel-group\" id=\"accordion\">
360 <div class=\"panel panel-default\">
362 $arus = file(ADB_PATH."artistlist.log");
363 $i = 0;
364 foreach ($arus as $key => $value) {
365 $tmar = explode("<><>", $value);
366 $usemail[$i] = $tmar[1];
367 $arid[$i] = $tmar[0];
368 $i++;
370 $vtrans = file(ADB_PATH."transaction.log");
371 foreach ($vtrans as $key2 => $value2) {
372 $arr = within_str($value2,"<id>","</id>");
373 $val = within_str($value2,"<price>","</price>");
374 $kk = array_search($arr, $arid);
375 /*echo $arr."-".$val."-".$kk."<br>";*/
376 if (isset($arval[$kk])) {
377 $arval[$kk] = $arval[$kk]+$val;
378 } else {
379 $arval[$kk] = $val;
382 $breakerArid = 0;
383 $ownnow = array();
384 foreach ($arid as $key => $value) {
385 if ($value!=66666666) {
386 $kk = array_search($value, $arid);
387 if (isset($arval[$kk])) {
389 $ownnow[trim($usemail[$kk])] = $arval[$kk];
390 /*var_dump($usemail);*/
391 /*echo "<div class=\"panel-heading\">
392 <a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#".$breakerArid."\">
393 <strong>".$usemail[$kk]."</strong> -
394 <strong>".@$arval[$kk]." Melon Points</strong>
395 </a>
396 </div>
397 <div id=\"".$breakerArid."\" class=\"panel-collapse collapse\">
398 <div class=\"panel-body\">
400 foreach ($test as $key2 => $value2) {
403 echo "
404 </div>
405 </div>
406 ";*/
408 $breakerArid++;
413 /*var_dump($ownnow);*/
415 $breaker = 0;
416 foreach ($vtrans as $key => $value) {
417 $test[within_str($value,"<id>","</id>")][$breaker] = $value;
418 $breaker++;
421 // echo "<pre>";
422 // print_r($test);
423 // echo "</pre>";
424 $count = 0;
425 $array = "";
427 foreach ($test as $key => $value) {
428 foreach ($value as $key2 => $value2) {
429 $array[within_str($value2, "<name>", "</name>")] = 0;
432 /*var_dump($test);*/
433 foreach ($test as $key => $value) {
435 echo "<div class=\"panel-heading\">
436 <a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#".$key."\">
437 ".FindUser($key)." ".$ownnow[trim(FindUser($key))]."</a></div>
438 <div id=\"".$key."\" class=\"panel-collapse collapse\">
440 foreach ($value as $key2 => $value2) {
441 echo "<img width='30px' height='30px' src=\"".$livesitePath."premium/".within_str($value2, "<name>", "</name>").".gif\">".within_str($value2, "<price>", "</price>")."ASD<br>";
443 echo "</div></div>";
446 // foreach ($arid as $key => $value) {
447 // if ($value!=66666666) {
448 // $kk = array_search($value, $arid);
449 // /*if ($arval[$kk] != "" || $arval[$kk] != NULL) {*/
450 // if (isset($arval[$kk])) {
454 // echo "<div class=\"panel-heading\">
455 // <a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#".$breakerArid."\">
456 // <strong>".$usemail[$kk]."</strong> -
457 // <strong>".@$arval[$kk]." Melon Points</strong>
458 // </a>
459 // </div>
460 // <div id=\"".$breakerArid."\" class=\"panel-collapse collapse\">
461 // <div class=\"panel-body\">
462 // ";
463 // foreach ($test as $key2 => $value2) {
465 // }
466 // echo "
467 // </div>
468 // </div>
469 // ";
471 // $breakerArid++;
472 // }
473 // }
474 // }
475 // }
479 </div>
480 </div>
481 </div>
484 <?php } ?>
485 <!-- END option for view transaction -->
486 <?php if (isset($_GET['alist'])) { ?>
487 <div class="row">
488 <div class="col-md-3">
489 <div class="panel panel-default">
490 <center>
491 <h4>Artist List</h4>
492 </center>
493 <ul id="al" class="wordwrap_" style="list-style:none; display:inline;">
494 <?php include("a_list.php"); ?>
495 </ul>
496 </div>
497 </div>
498 <div class="col-md-9">
499 <div class="panel panel-default optionlistview">
500 <div class="panel-heading"><center><b>Artworks</b></center></div><br>
501 <?php
502 if (isset($_GET['v'])) {
503 error_reporting(E_ALL); ini_set("display_errors", 1);
504 if (!file_exists(ADB_PATH."imglist.log")) {
505 # code...
506 } else {
507 $__utmp = file(ADB_PATH."imglist.log");
508 foreach ($__utmp as $key => $value) {
509 if (trim($_GET['v']) == trim(within_str($value,"<id>","</id>")) && trim(within_str($value,"<stat>","</stat>")) != "deleted") {
510 echo "<div class=\"panel panel-default alist_art\">
511 <a href=\"#\" class=\"thumbnail\" style=\"margin-bottom: 1em!important;\">
512 <img src=\"http://be.2ch.net/dev-test/premium/".within_str($value,"<name>","</name>")."\" style=\"height:80px;\" alt=\"\">
513 </a>
514 <span class=\"pull-right\">".within_str($value, "<price>", "</price>")."MP</span>
515 <div class=\"clearfix\"></div>
516 </div>";
520 } else {
521 echo "Select Artist";
524 <div class="clearfix"></div>
525 </div>
527 </div>
528 </div>
529 <?php } ?>
530 <div class="clearfix"></div>
531 <!-- </div> -->
532 </div>
533 </div>
534 </div>
535 </div>
536 </div>
537 </div>
538 </div>
539 <script src="js/jquery-1.9.1.js"></script>
540 <script src="js/bootstrap.js"></script>
541 </body>
542 </html>