Initial commit
[2ch-be.git] / dev-test / artistbak / artist_steve.php
blob20bcd0875fac0963fa48ca54b82e64065c1edbb3
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 $email = Decrypt($_COOKIE['ADMDM'],AKEY);
13 $dir = loggedEmail($email, "adb/");
14 // echo $dir;
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>Welcome,<b>
41 <?php
42 $artistname = explode ("@", $_SESSION['aname']);
43 echo $artistname[0];
45 !</b></h4>
46 </div>
47 <div class="clearfix"></div>
48 <div class="row">
49 <div class="col-md-3">
50 <div class="panel panel-default">
51 <div class="panel-heading">
52 <center>
53 <b>Options</b>
54 </center>
55 </div>
56 <ul id="al" style="list-style:none; display:inline;">
57 <?php if ($_SESSION['utype'] == "admin") { ?>
58 <li><a href="?crar">Create Artist Account</a>&nbsp;&nbsp;&nbsp;</li>
59 <li><a href="?vtrans">View Transactions</a>&nbsp;&nbsp;&nbsp;</li>
60 <li><a href="?alist">Artist List</a></li>
61 <?php } elseif ($_SESSION['utype'] == "user") { ?>
62 <li><a href="?art">Art List</a></li>
63 <li><a href="?upload">Upload Image</a>&nbsp;&nbsp;&nbsp;</li>
64 <?php } ?>
65 </ul>
66 </div>
67 </div>
68 <div class="col-md-9">
70 <?php
71 if(empty($_GET)){
72 echo "<h3><b>Artist Area!</b></h3>";
74 if(isset($_SESSION['msg'])){
75 echo $_SESSION['msg'];
76 $_SESSION['msg'] = '';
80 <?php if(isset($_GET['art'])){
81 echo "<div class=\"panel panel-default optionlistview\"><div class=\"panel-heading\"><center><b>Artworks</b></center></div><br>";
83 if(file_exists("/home/adb/imglist.log")){
84 $file = file("/home/adb/imglist.log");
85 if(isset($_GET['c'])){
86 if($_GET['c']=="delete"){
87 $id = $_GET['id'];
88 $filename = within_str($file[$id], "<name>", "</name>");
89 $file[$id]= str_replace("<stat></stat>","<stat>deleted</stat>",$file[$id]);
90 $data = implode("", $file);
91 $handler = fopen("/home/adb/imglist.log", "w");
92 fwrite($handler, $data);
93 fclose($handler);
94 /*$test = unlink("/home/auth/public_html/dev-test/premium/".$filename.".jpg");*/
95 /*if($test){
96 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
97 header("Location: artist.php?art");
98 exit;
99 }else{
100 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to delete file. Either file doesn't exists</div>";
101 header("Location: artist.php?art");
102 exit;
104 $_SESSION['msg'] = "<div class=\"alert alert-success\">We've successfully deleted the file.</div>";
105 header("Location: artist.php?art");
108 $i = 0;
109 foreach ($file as $key => $value) {
110 $img = within_str($value, "<name>", "</name>").".gif";
111 $stat = within_str($value, "<stat>", "</stat>");
112 $id = within_str($value, "<id>", "</id>");
113 if(!$stat && $id==$_SESSION['artistid']){
114 echo "<div class=\"panel panel-default alist_art\">";
115 echo "<a href=\"#\" class=\"thumbnail\">";
116 echo "<img src=\"{$livesitePath}dev-test/premium/{$img}\" style=\"width:80px; height:80px;\" alt=\"\">";
117 echo "</a>";
118 echo "<center><br>";
119 echo "<span>" .within_str($value, "<price>", "</price>"). " MP</span><br>";
120 echo "<a href=\"artist.php?art&c=delete&id={$i}\">delete </a>";
121 echo "<a href=\"artist.php?edit={$i}\">edit </a></center>";
122 echo "<div class=\"clearfix\"></div>";
123 echo " </div>";
125 $i++;
126 // if($i%4==0) { echo "<div class=\"clearfix\"></div>"; }
129 echo "<div class=\"clearfix\"></div>";
130 }else{
131 echo "Please upload your work";
134 echo "</div>";
136 }else if(isset($_GET['upload'])){ ?>
138 <?php
141 if(isset($_POST['submitupload'])){
142 if(is_numeric($_POST['price'])){
144 $price = (int) $_POST['price'];
145 $price = abs($price);
146 $name = $_POST['name'];
147 var_dump($_FILES);
148 exit;
149 $tmpName = $_FILES['uploadedfile']['tmp_name'];
151 $fdir = substr($email, 0, 1);
152 $sdir = substr($email, 1, 1);
153 $path = ADB_PATH."{$fdir}/{$sdir}/{$email}";
154 if (!file_exists($path)) {
155 @mkdir(ADB_PATH."{$fdir}");
156 @mkdir(ADB_PATH."{$fdir}/{$sdir}");
157 @mkdir(ADB_PATH."{$fdir}/{$sdir}/{$udir}");
159 // echo $_FILES["file"]["type"];
160 // die;
161 if($_FILES["uploadedfile"]["type"] == "image/gif"){
162 $dirPath = "/home/auth/public_html/dev-test/premium/";
163 $name = rand(1000000,9999999);
164 $fname = $name.".gif";
165 if(!file_exists($dirPath.$fname)){
166 if(move_uploaded_file($tmpName, $dirPath.$fname)) {
167 $uploadedFile = true;
169 } else{
170 $uploadedFile = false;
172 }else{
173 $_SESSION['msg'] = "<div class=\"alert alert-danger\">File already exist.</div>";
174 header("Location: artist.php?upload");
175 exit;
177 }else{
178 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Please upload GIF image only.</div>";
179 header("Location: artist.php?upload");
180 exit;
184 // if($uploadedFile){
185 // $time = time();
186 // $writeData = "<time>{$time}</time><name>{$name}_".rand(00000,99999)."</name><price>{$price}</price>\n";
187 // $filename = $path."/imagelist.txt";
189 // if (!file_exists($filename)) {
190 // if(!file_put_contents($filename,$writeData)) {
191 // $writeSuccess = false;
192 // }
193 // $writeSuccess = true;
194 // } else {
195 // $handle = fopen($filename, "a");
196 // if(!fwrite($handle, $writeData)) {
197 // $writeSuccess = false;
198 // }
199 // fclose($handle);
200 // $writeSuccess = true;
201 // }
202 // }
204 if($uploadedFile){
205 $handle = fopen("/home/adb/imglist.log", "a+");
206 fwrite($handle, "<id>".$_SESSION['artistid']."</id><name>{$name}</name><price>{$price}</price><stat></stat>\n");
207 fclose($handle);
209 $_SESSION['msg'] = "<div class=\"alert alert-success\">File successfully uploaded.</div>";
210 header("Location: artist.php?art");
211 exit;
212 }else{
213 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Unable to upload file. Please contact admin.</div>";
214 header("Location: artist.php?upload");
215 exit;
218 }else{
219 $_SESSION['msg'] = "<div class=\"alert alert-danger\">Price must be numeric.</div>";
220 header("Location: artist.php?upload");
221 exit;
227 <div class="panel panel-default optionlistview">
228 <div class="panel-heading">
229 <center><b>Upload Artwork</b></center>
230 </div><br>
231 <form role="form" style="width:50%;" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'] ?>?upload" method="POST">
232 <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
233 <div class="form-group">
234 <label for="price">Price:</label> <br>
235 <input name="price" type="text" class="form-control" placeholder="Price"/><br />
236 </div>
237 <div class="form-group">
238 <label for="price">Uploaded File: </label> <br>
239 <input name="uploadedfile" class="form-control" type="file" placeholder="Price"/>
240 <span style="font-size:12px;margin-top:3px;" class="pull-right">(only .gif image is accepted)</span>
241 <div class="clearfix"></div>
242 </div>
243 <input type="submit" class="btn btn-primary" name="submitupload" value="Upload File" />
244 <input type="reset" class="btn btn-danger" name="submit" value="Reset" />
245 </form>
246 </div>
249 <?php }else if(isset($_GET['edit'])){
250 echo "<div class=\"panel panel-default optionlistview\">";
252 $file = file(ADB_PATH."imglist.log");
253 // print_r(expression)
254 $index = $_GET['edit'];
255 $value = $file[$index];
256 $name = within_str($value, "<name>", "</name>");
257 $price = within_str($value, "<price>", "</price>");
258 $time = within_str($value, "<time>", "</time>");
259 $idVal = within_str($value, "<id>", "</id>");
262 if(isset($_POST['submitedit'])){
263 $index = $_GET['edit'];
264 // $newName = rand(1000000,9999999);
265 $newPrice = abs($_POST['price']);
266 unset($file[$index]);
268 $file[$index] = "<id>".$idVal."</id><name>{$name}</name><price>{$newPrice}</price><stat></stat>\n";
269 $data = implode("", $file);
270 $handler = fopen(ADB_PATH."imglist.log", "w");
271 fwrite($handler, $data);
272 fclose($handler);
273 // rename("/home/auth/public_html/dev-test/premium/".$name.".gif", "/home/auth/public_html/dev-test/premium/".$newName.".gif");
274 $_SESSION['msg'] = "Successfully edit.";
275 header("Location: artist.php?art");
276 exit;
281 <form role="form" action="<?php echo $_SERVER['PHP_SELF'] ?>?edit=<?=$index?>" style="width:50%;" method="POST">
282 <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
283 <div class="form-group">
284 <label for="price">Price:</label> <br>
285 <input name="price" type="text" class="form-control" value="<?php echo within_str($value, "<price>", "</price>") ?>" placeholder="Price"/><br />
286 </div>
287 <input type="submit" class="btn btn-primary" name="submitedit" value="Submit" />
288 </form>
289 <?php echo "</div>";} ?>
291 <!-- nakadisplay none to option for create artist account -->
292 <?php if (isset($_GET['crar'])) { ?>
293 <div class="panel panel-default optionlistview">
294 <div class="panel-heading">
295 <center><b>Add New Artist</b></center>
296 </div><br>
297 <center>
298 <form role="form" method="post" style="width:50%;">
299 <div class="form-group">
300 <label for="email" class="pull-left">Email address</label>
301 <input type="email" class="form-control" id="email" name="user" placeholder="Enter email">
302 </div>
303 <div class="form-group">
304 <label for="password" class="pull-left">Password</label>
305 <input type="password" class="form-control" id="password" name="pass" placeholder="Password">
306 </div>
307 <div class="form-group">
308 <label for="confirmpassword" class="pull-left">Confirm Password</label>
309 <input type="password" class="form-control" id="confirmpassword" name="cpass" placeholder="Confirm Password">
310 </div>
311 <input type="submit" class="btn btn-primary pull-left" name="asub" value="Create Artist">
312 <div class="clearfix"></div>
313 </form>
314 </center>
315 </div>
316 <?php } ?>
317 <!-- END nakadisplay none to option for create artist account -->
319 <!-- option for view transaction -->
320 <?php if (isset($_GET['vtrans'])) { ?>
321 <div class="panel panel-default optionlistview">
322 <div class="panel-heading">
323 <center><b>Transactions</b></center>
324 </div><br>
325 <?php
326 if (!file_exists(ADB_PATH."artistlist.log")) {
327 echo "No transactions";
328 } else {
329 if (!file_exists(ADB_PATH."transaction.log")) {
330 echo "No transactions";
331 exit;
332 } else {
333 echo "<table class=\"table table-striped\" style=\"background:white;\">
334 <tr>
335 <td><b>User</b></td>
336 <td><b>Total Sold (MP)</b></td>
337 </tr>";
338 $arus = file(ADB_PATH."artistlist.log");
339 $i = 0;
340 foreach ($arus as $key => $value) {
341 $tmar = explode("<><>", $value);
342 $usemail[$i] = $tmar[1];
343 $arid[$i] = $tmar[0];
344 $i++;
346 $vtrans = file(ADB_PATH."transaction.log");
347 foreach ($vtrans as $key2 => $value2) {
348 $arr = within_str($value2,"<id>","</id>");
349 $val = within_str($value2,"<price>","</price>");
350 $kk = array_search($arr, $arid);
351 /*echo $arr."-".$val."-".$kk."<br>";*/
352 if (isset($arval[$kk])) {
353 $arval[$kk] = $arval[$kk]+$val;
354 } else {
355 $arval[$kk] = $val;
358 foreach ($arid as $key => $value) {
359 if ($value!=66666666) {
360 $kk = array_search($value, $arid);
361 /*if ($arval[$kk] != "" || $arval[$kk] != NULL) {*/
362 if (isset($arval[$kk])) {
363 echo "<tr>
364 <td>".$usemail[$kk]."</td>
365 <td>".@$arval[$kk]." Melon Points</td>
366 </tr>";
373 </table>
374 </div>
375 <?php } ?>
376 <!-- END option for view transaction -->
377 <?php if (isset($_GET['alist'])) { ?>
378 <div class="row">
379 <div class="col-md-3">
380 <div class="panel panel-default">
381 <center>
382 <h4>Artist List</h4>
383 </center>
384 <ul id="al" class="wordwrap_" style="list-style:none; display:inline;">
385 <?php include("a_list.php"); ?>
386 </ul>
387 </div>
388 </div>
389 <div class="col-md-9">
390 <div class="panel panel-default optionlistview">
391 <div class="panel-heading"><center><b>Artworks</b></center></div><br>
392 <?php
393 if (isset($_GET['v'])) {
394 error_reporting(E_ALL); ini_set("display_errors", 1);
395 if (!file_exists(ADB_PATH."imglist.log")) {
396 # code...
397 } else {
398 $__utmp = file(ADB_PATH."imglist.log");
399 foreach ($__utmp as $key => $value) {
400 if (trim($_GET['v']) == trim(within_str($value,"<id>","</id>")) && trim(within_str($value,"<stat>","</stat>")) != "deleted") {
401 echo "<div class=\"panel panel-default alist_art\">
402 <a href=\"#\" class=\"thumbnail\">
403 <img src=\"http://be.2ch.net/dev-test/premium/".within_str($value,"<name>","</name>")."\" style=\"width:80px; height:80px;\" alt=\"\">
404 </a>
405 <span class=\"pull-right\">".within_str($value, "<price>", "</price>")."MP</span>
406 <div class=\"clearfix\"></div>
407 </div>";
411 } else {
412 echo "Select Artist";
415 <div class="clearfix"></div>
416 </div>
418 </div>
419 </div>
420 <?php } ?>
421 <div class="clearfix"></div>
422 <!-- </div> -->
423 </div>
424 </div>
425 </div>
426 </div>
427 </div>
428 </div>
429 </div>
430 <!--script src="js/jquery-1.9.1.js"></script>
431 <script src="js/bootstrap.js"></script-->
432 </body>
433 </html>