Initial commit
[2ch-be.git] / dev-test / artist / bak / artist.orig.php
blob176882a7b84899698ec4be748b46b99e5b38cabf
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 <!DOCTYPE html>
17 <html lang="en">
18 <head>
19 <meta charset="UTF-8">
20 <meta http-equiv="X-UA-Compatible" content="IE=edge">
21 <meta name="viewport" content="width=device-width, initial-scale=1">
22 <title>Artist Page</title>
23 <link rel="stylesheet" href="css/bootstrap.css">
24 <link rel="stylesheet" href="css/astyle.css">
25 </head>
26 <body>
27 <div class="container body">
28 <div class="row">
29 <div class="col-md-12">
30 <div class="panel panel-default">
31 <div class="panel-heading">
32 <center>
33 <img src="css/img/2ch_logo.gif" alt="">
34 </center>
35 </div>
36 <div class="main">
37 <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>
38 <div class="pull-left" style="margin:10px 0px;">
39 <h4><i>Welcome,</i><b>
40 <?php
41 $artistname = explode ("@", $_SESSION['aname']);
42 echo $artistname[0];
43 ?>!</b></h4>
44 </div>
45 <div class="clearfix"></div>
46 <div class="row">
47 <div class="col-md-3">
48 <div class="panel panel-default">
49 <div class="panel-heading">
50 <center>
51 <b>Options</b>
52 </center>
53 </div>
54 <ul id="al" style="list-style:none; display:inline;">
55 <?php if ($_SESSION['utype'] == "admin") { ?>
56 <li><a href="?crar">Create Artist Account</a>&nbsp;&nbsp;&nbsp;</li>
57 <li><a href="?vtrans">View Transactions</a>&nbsp;&nbsp;&nbsp;</li>
58 <li><a href="?alist">Artist List</a></li>
59 <?php } elseif ($_SESSION['utype'] == "user") { ?>
60 <li><a href="?art">Art List</a></li>
61 <li><a href="?upload">Upload Image</a>&nbsp;&nbsp;&nbsp;</li>
62 <?php } ?>
63 </ul>
64 </div>
65 </div>
66 <div class="col-md-9">
68 <?php
69 if(empty($_GET)){
70 echo "<h3><b>Artist Area!</b></h3>";
72 if(isset($_SESSION['msg'])){
73 echo $_SESSION['msg'];
74 $_SESSION['msg'] = '';
78 <?php if(isset($_GET['art'])){
79 echo "<div class=\"panel panel-default optionlistview\"><div class=\"panel-heading\"><center><b>Artworks</b></center></div><br>";
81 if(file_exists("/home/adb/imglist.log")){
82 $file = file("/home/adb/imglist.log");
83 if(isset($_GET['c'])){
84 if($_GET['c']=="delete"){
85 $id = $_GET['id'];
86 $filename = within_str($file[$id], "<name>", "</name>");
87 $file[$id]= str_replace("<stat></stat>","<stat>deleted</stat>",$file[$id]);
88 $data = implode("", $file);
89 $handler = fopen("/home/adb/imglist.log", "w");
90 fwrite($handler, $data);
91 fclose($handler);
92 /*$test = unlink("/home/auth/public_html/premium/".$filename.".jpg");*/
93 /*if($test){
94 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
95 header("Location: artist.php?art");
96 exit;
97 }else{
98 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to delete file. Either file doesn't exists</div>";
99 header("Location: artist.php?art");
100 exit;
102 $_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>";
103 header("Location: artist.php?art");
106 $i = 0;
107 foreach ($file as $key => $value) {
108 $img = within_str($value, "<name>", "</name>").".gif";
109 $stat = within_str($value, "<stat>", "</stat>");
110 $id = within_str($value, "<id>", "</id>");
111 if(!$stat && $id==$_SESSION['artistid']){
112 echo "<div class=\"panel panel-default alist_art\">";
113 echo "<a href=\"#\" class=\"thumbnail\" style=\"margin-bottom: 1em!important;\">";
114 echo "<img src=\"{$livesitePath}premium/{$img}\" style=\"height:80px;\" alt=\"\">";
115 echo "</a>";
116 echo "<center>";
117 echo "<span>" .within_str($value, "<price>", "</price>"). " MP</span><br>";
118 echo "<a href=\"artist.php?art&c=delete&id={$i}\">delete </a>";
119 echo "<a href=\"artist.php?edit={$i}\">edit </a></center>";
120 echo "<div class=\"clearfix\"></div>";
121 echo " </div>";
123 $i++;
124 // if($i%4==0) { echo "<div class=\"clearfix\"></div>"; }
127 echo "<div class=\"clearfix\"></div>";
128 }else{
129 echo "Please upload your work";
132 echo "</div>";
134 }else if(isset($_GET['upload'])){ ?>
136 <?php
139 if(isset($_POST['submitupload'])){
140 if($_POST['price'] == 0 || !isset($_POST['price'])){
141 $_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>";
142 header("Location: artist.php?upload");
143 exit;
145 if($_FILES['uploadedfile']['size']<100000){
146 if(is_numeric($_POST['price'])){
148 $price = (int) $_POST['price'];
149 $price = round(abs($price));
150 $name = $_POST['name'];
152 $tmpName = $_FILES['uploadedfile']['tmp_name'];
154 $fdir = substr($email, 0, 1);
155 $sdir = substr($email, 1, 1);
156 $path = ADB_PATH."{$fdir}/{$sdir}/{$email}";
157 if (!file_exists($path)) {
158 @mkdir(ADB_PATH."{$fdir}");
159 @mkdir(ADB_PATH."{$fdir}/{$sdir}");
160 @mkdir(ADB_PATH."{$fdir}/{$sdir}/{$udir}");
162 // echo $_FILES["file"]["type"];
163 // die;
164 if($_FILES["uploadedfile"]["type"] == "image/gif"){
165 $dirPath = "/home/auth/public_html/premium/";
166 $name = rand(1000000,9999999);
167 $fname = $name.".gif";
168 if(!file_exists($dirPath.$fname)){
169 if(move_uploaded_file($tmpName, $dirPath.$fname)) {
170 $uploadedFile = true;
172 } else{
173 $uploadedFile = false;
175 }else{
176 $_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>";
177 header("Location: artist.php?upload");
178 exit;
180 }else{
181 $_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>";
182 header("Location: artist.php?upload");
183 exit;
187 // if($uploadedFile){
188 // $time = time();
189 // $writeData = "<time>{$time}</time><name>{$name}_".rand(00000,99999)."</name><price>{$price}</price>\n";
190 // $filename = $path."/imagelist.txt";
192 // if (!file_exists($filename)) {
193 // if(!file_put_contents($filename,$writeData)) {
194 // $writeSuccess = false;
195 // }
196 // $writeSuccess = true;
197 // } else {
198 // $handle = fopen($filename, "a");
199 // if(!fwrite($handle, $writeData)) {
200 // $writeSuccess = false;
201 // }
202 // fclose($handle);
203 // $writeSuccess = true;
204 // }
205 // }
207 if($uploadedFile){
208 $handle = fopen("/home/adb/imglist.log", "a+");
209 fwrite($handle, "<id>".$_SESSION['artistid']."</id><name>{$name}</name><price>{$price}</price><stat></stat>\n");
210 fclose($handle);
212 $_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>";
213 header("Location: artist.php?art");
214 exit;
215 }else{
216 $_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>";
217 header("Location: artist.php?upload");
218 exit;
221 }else{
222 $_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>";
223 header("Location: artist.php?upload");
224 exit;
226 }else{
227 $_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>";
228 header("Location: artist.php?upload");
229 exit;
235 <div class="panel panel-default optionlistview">
236 <div class="panel-heading">
237 <center><b>Upload Artwork</b></center>
238 </div><br>
239 <form role="form" style="width:50%;" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>?upload" method="POST">
240 <div class="form-group">
241 <label for="price">Price:</label> <br>
242 <input name="price" type="text" class="form-control" placeholder="Price" required/><br />
243 </div>
244 <div class="form-group">
245 <label for="price">Uploaded File: </label> <br>
246 <input name="uploadedfile" class="form-control" type="file" placeholder="Price" required/>
247 <span style="font-size:12px;margin-top:3px;" class="pull-right">(only .gif image is accepted)</span>
248 <div class="clearfix"></div>
249 </div>
250 <input type="submit" class="btn btn-primary" name="submitupload" value="Upload File" />
251 <input type="reset" class="btn btn-danger" name="submit" value="Reset" />
252 </form>
253 </div>
256 <?php }else if(isset($_GET['edit'])){
258 echo "<div class=\"panel panel-default optionlistview\">";
259 if(empty($_GET['edit'])){
260 echo "aa";
261 exit;
262 // $_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>";
263 header("Location: artist.php?art");
264 exit;
267 $file = file(ADB_PATH."imglist.log");
268 // print_r(expression)
269 $index = $_GET['edit'];
270 $file[$index];
271 /*var_dump($index);
272 var_dump($file);
273 exit;*/
274 if($file[$index]){
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 if($_POST['price'] == 0 || !isset($_POST['price'])){
284 $_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>";
285 header("Location: artist.php?art");
286 exit;
288 $index = $_GET['edit'];
289 // $newName = rand(1000000,9999999);
290 $newPrice = round(abs($_POST['price']));
291 unset($file[$index]);
293 $file[$index] = "<id>".$idVal."</id><name>{$name}</name><price>{$newPrice}</price><stat></stat>\n";
294 $data = implode("", $file);
295 $handler = fopen(ADB_PATH."imglist.log", "w");
296 fwrite($handler, $data);
297 fclose($handler);
298 // rename("/home/auth/public_html/premium/".$name.".gif", "/home/auth/public_html/premium/".$newName.".gif");
299 $_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>";
300 header("Location: artist.php?art");
301 exit;
304 }else{
305 header("Location: artist.php?art");
306 exit;
309 <div class="panel panel-default alist_art">
310 <a href="#" class="thumbnail">
311 <img src="<?php echo $livesitePath ?>premium/<?php echo $name ?>" style="height:80px;" alt="">
312 </a>
313 </div>
314 <div class="clearfix"></div>
315 <br>
316 <form role="form" action="<?php echo $_SERVER['PHP_SELF'] ?>?edit=<?=$index?>" style="width:50%;" method="POST">
317 <div class="form-group">
318 <label for="price">Price:</label> <br>
319 <input name="price" type="text" class="form-control" value="<?php echo within_str($value, "<price>", "</price>") ?>" placeholder="Price" required/><br />
320 </div>
321 <input type="submit" class="btn btn-primary" name="submitedit" value="Submit" />
322 </form>
323 <?php echo "</div>";} ?>
325 <!-- nakadisplay none to option for create artist account -->
326 <?php if (isset($_GET['crar'])) {
327 if ($_SESSION['utype'] != "admin")
328 die("NG");
330 <div class="panel panel-default optionlistview">
331 <div class="panel-heading">
332 <center><b>Add New Artist</b></center>
333 </div><br>
334 <center>
335 <form role="form" method="post" style="width:50%;">
336 <div class="form-group">
337 <label for="email" class="pull-left">Email address</label>
338 <input type="email" class="form-control" id="email" name="user" placeholder="Enter email">
339 </div>
340 <div class="form-group">
341 <label for="password" class="pull-left">Password</label>
342 <input type="password" class="form-control" id="password" name="pass" placeholder="Password">
343 </div>
344 <div class="form-group">
345 <label for="confirmpassword" class="pull-left">Confirm Password</label>
346 <input type="password" class="form-control" id="confirmpassword" name="cpass" placeholder="Confirm Password">
347 </div>
348 <input type="submit" class="btn btn-primary pull-left" name="asub" value="Create Artist">
349 <div class="clearfix"></div>
350 </form>
351 </center>
352 </div>
353 <?php } ?>
354 <!-- END nakadisplay none to option for create artist account -->
356 <!-- option for view transaction -->
357 <?php if (isset($_GET['vtrans'])) {
358 if ($_SESSION['utype'] != "admin")
359 die("NG");
361 <div class="panel panel-default optionlistview">
362 <div class="panel-heading">
363 <center><b>Transactions</b></center>
364 </div><br>
365 <?php
366 if (!file_exists(ADB_PATH."artistlist.log")) {
367 echo "No transactions";
368 } else {
369 if (!file_exists(ADB_PATH."transaction.log")) {
370 echo "No transactions";
371 exit;
372 } else {
373 echo "<table class=\"table table-striped\" style=\"background:white;\">
374 <tr>
375 <td><b>User</b></td>
376 <td><b>Total Sold (MP)</b></td>
377 </tr>";
378 $arus = file(ADB_PATH."artistlist.log");
379 $i = 0;
380 foreach ($arus as $key => $value) {
381 $tmar = explode("<><>", $value);
382 $usemail[$i] = $tmar[1];
383 $arid[$i] = $tmar[0];
384 $i++;
386 $vtrans = file(ADB_PATH."transaction.log");
387 foreach ($vtrans as $key2 => $value2) {
388 $arr = within_str($value2,"<id>","</id>");
389 $val = within_str($value2,"<price>","</price>");
390 $kk = array_search($arr, $arid);
391 /*echo $arr."-".$val."-".$kk."<br>";*/
392 if (isset($arval[$kk])) {
393 $arval[$kk] = $arval[$kk]+$val;
394 } else {
395 $arval[$kk] = $val;
398 foreach ($arid as $key => $value) {
399 if ($value!=66666666) {
400 $kk = array_search($value, $arid);
401 /*if ($arval[$kk] != "" || $arval[$kk] != NULL) {*/
402 if (isset($arval[$kk])) {
403 echo "<tr>
404 <td>".$usemail[$kk]."</td>
405 <td>".@$arval[$kk]." Melon Points</td>
406 </tr>";
413 </table>
414 </div>
415 <?php } ?>
416 <!-- END option for view transaction -->
417 <?php if (isset($_GET['alist'])) {
418 if ($_SESSION['utype'] != "admin")
419 die("NG");
421 <div class="row">
422 <div class="col-md-3">
423 <div class="panel panel-default">
424 <center>
425 <h4>Artist List</h4>
426 </center>
427 <ul id="al" class="wordwrap_" style="list-style:none; display:inline;">
428 <?php include("a_list.php"); ?>
429 </ul>
430 </div>
431 </div>
432 <div class="col-md-9">
433 <div class="panel panel-default optionlistview">
434 <div class="panel-heading"><center><b>Artworks</b></center></div><br>
435 <?php
436 if (isset($_GET['v'])) {
437 error_reporting(E_ALL); ini_set("display_errors", 1);
438 if (!file_exists(ADB_PATH."imglist.log")) {
439 # code...
440 } else {
441 $__utmp = file(ADB_PATH."imglist.log");
442 foreach ($__utmp as $key => $value) {
443 if (trim($_GET['v']) == trim(within_str($value,"<id>","</id>")) && trim(within_str($value,"<stat>","</stat>")) != "deleted") {
444 echo "<div class=\"panel panel-default alist_art\">
445 <a href=\"#\" class=\"thumbnail\" style=\"margin-bottom: 1em!important;\">
446 <img src=\"http://be.2ch.net/premium/".within_str($value,"<name>","</name>")."\" style=\"height:80px;\" alt=\"\">
447 </a>
448 <span class=\"pull-right\">".within_str($value, "<price>", "</price>")."MP</span>
449 <div class=\"clearfix\"></div>
450 </div>";
454 } else {
455 echo "Select Artist";
458 <div class="clearfix"></div>
459 </div>
461 </div>
462 </div>
463 <?php } ?>
464 <div class="clearfix"></div>
465 <!-- </div> -->
466 </div>
467 </div>
468 </div>
469 </div>
470 </div>
471 </div>
472 </div>
473 <script src="js/jquery-1.9.1.js"></script>
474 <script src="js/bootstrap.js"></script>
475 </body>
476 </html>