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