Initial commit
[2ch-be.git] / choose.php
blob7e663ac3fb4a681800cf5920aaa2807487b5317b
1 <?php
3 if (!isset($_COOKIE['DMDM']) && !isset($_COOKIE['MDMD'])) {
4 header('location:index.php');
5 exit;
7 include('config.php');
8 include('encrypt_artist.php');
9 $message = new Message;
10 $email = Decrypt($_COOKIE['DMDM'],KEY);
11 $userDataID = $message->GetID($_COOKIE['DMDM'], $id_mail_path);
13 $fdir = substr($email, 0, 1);
14 $sdir = substr($email, 1, 1);
15 if (file_exists(UDB_PATH."$fdir/$sdir/$email/usrimg.log")) {
16 $userbp = @file(UDB_PATH."$fdir/$sdir/$email/usrimg.log");
19 /*var_dump($userbp);
20 exit;*/
22 if(detect_device2($_SERVER['HTTP_USER_AGENT']) != "PLSDISPLAY"){
23 $hide = "display:none;";
24 } else {
25 $hide = "";
28 if(isset($_GET['pay'])){
29 $premiumList = file(ADB_PATH."/imglist.log");
30 $stat = $message->within_str($premiumList[$_GET['pay']], "<stat>", "</stat>");
32 if(isset($premiumList[$_GET['pay']])){
33 if(!$stat){
34 $buyerID = trim($message->GetID($_COOKIE['DMDM'],$id_mail_path));
35 $time = time();
36 $id = $message->within_str($premiumList[$_GET['pay']], "<id>", "</id>");
37 $name = $message->within_str($premiumList[$_GET['pay']], "<name>", "</name>");;
38 $price = $message->within_str($premiumList[$_GET['pay']], "<price>", "</price>");;
39 $writeData = "<time>{$time}</time><uid>{$userDataID}</uid><id>{$id}</id><name>{$name}</name><price>{$price}</price>\n";
40 $filename = ADB_PATH."/transaction.log";
41 $points = file_get_contents("http://tpol27.nttec.com/dev/melon.php?conv=".$price."&usr=".$email."&ip=".$_SERVER['REMOTE_ADDR']."&trans=premium&puid=".$buyerID);
43 if($points){
44 if (!file_exists($filename)) {
45 if(!file_put_contents($filename,$writeData)) {
46 echo "Error!";
47 return false;
49 } else {
50 $handle = fopen($filename, "a");
51 if(!fwrite($handle, $writeData)) {
52 echo "Error!";
53 return false;
55 fclose($handle);
57 $_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>You\'re new avatar is updated!</div>';
60 $ico = $name.".gif";
61 $ico = trim($ico);
62 if(preg_match('/[^a-z_\-0-9._]/i', $ico)){
63 $ico ="";
66 $type = Array(1 => 'gif'); //store all the image extension types in array
67 $ext = explode(".",$ico); //explode and find value after dot
69 if (strlen($ext[0]) <= 0 ) $ico = "nida.gif";
70 if(!(in_array($ext[1],$type))) //check image extension not in the array $type
72 echo "412";
73 exit;
76 $fdir = substr($email, 0, 1);
77 $sdir = substr($email, 1, 1);
78 $userData = file(DB_PATH."$fdir/$sdir/$email");
80 for ($i=0; $i < count($userData); $i++) {
81 $userData[$i] = trim($userData[$i]);
84 $userData[5] = $ico."-PREM";
85 $writeData = implode("\n",$userData);
86 $_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>You\'re new avatar is updated!</div>';
88 $fdir = substr($email, 0, 1);
89 $sdir = substr($email, 1, 1);
90 $udb_path = UDB_PATH."{$fdir}/{$sdir}/{$email}";
92 if(!is_dir($udb_path)){
93 @mkdir(UDB_PATH."{$fdir}");
94 @mkdir(UDB_PATH."{$fdir}/{$sdir}");
95 @mkdir(UDB_PATH."{$fdir}/{$sdir}/{$email}");
97 $insertUsr = '<time>'.time().'</time><filename>'.$userData[5].'</filename><aid>'.$id.'</aid>'.PHP_EOL;
98 //start
99 if(!file_exists($udb_path."/usrimg.log")){
100 file_put_contents($udb_path."/usrimg.log",$insertUsr);
101 }else{
102 $handle = fopen($udb_path."/usrimg.log", "a");
103 if(!fwrite($handle, $insertUsr)) {
104 $writeSuccess = false;
106 fclose($handle);
107 $writeSuccess = true;
109 //end
110 file_put_contents(DB_PATH."$fdir/$sdir/$email", $writeData);
111 header('location:status.php');
112 exit;
114 }else{
115 $_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>Not enough points</div>';
116 header("Location: status.php");
117 exit;
121 }else{
122 $_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>Doesn\'t Exist</div>';
123 header("Location: status.php");
124 exit;
127 $points = file_get_contents("http://tpol27.nttec.com/melon.php?email=".$email);
130 function FindClass($id) {
131 if(isset($id) && $id != "popular"){
132 $list = file(ADB_PATH."class.log");
133 $em = "";
134 $err = true;
135 // print_r($list);
136 // echo ucfirst($id);
137 foreach ($list as $key => $value) {
138 $nameCat = within_str($value, "<classname>", "</classname>");
139 if($id==$nameCat ){
140 $idest = within_str($value, "<id>", "</id>");
141 break;
144 return $idest;
145 }else{
146 return NULL;
151 function countClass($id) {
152 $list = file(ADB_PATH."imglist.log");
153 $id = (empty($id)) ? "" : $id;
154 $count = 0;
155 foreach ($list as $key => $value) {
156 $stats = within_str($value, "<stat>", "</stat>");
157 $nameCat = within_str($value, "<classid>", "</classid>");
158 $userID = within_str($value, "<id>", "</id>");
159 if($id==$nameCat && $stats!="deleted"){
160 $count++;
163 return $count;
167 <!DOCTYPE html>
168 <html lang="en">
169 <head>
170 <meta charset="UTF-8">
171 <meta http-equiv="X-UA-Compatible" content="IE=edge">
172 <meta name="viewport" content="width=device-width, initial-scale=1">
173 <title>Choose Icon</title>
174 <link rel="stylesheet" href="css/bootstrap.css">
175 <link rel="stylesheet" href="css/astyle.css">
176 <style>
177 .navbar-default .navbar-nav > .active > a{
178 color: #fff;
179 border-color: #357ebd;
180 background: #428bca;
183 .navbar-default .navbar-nav > .active > a:hover{
184 color: #fff;
185 border-color: #357ebd;
186 background: #357ebd;
188 </style>
189 </head>
190 <body>
191 <div class="container container-margin-top">
192 <nav class="navbar navbar-default" role="navigation">
193 <div class="container-fluid">
194 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu">
195 <span class="sr-only">Toggle Navigation</span>
196 <span class="icon-bar"></span>
197 <span class="icon-bar"></span>
198 <span class="icon-bar"></span>
199 </button>
200 <div class="collapse navbar-collapse" id="menu">
201 <ul class="nav navbar-nav">
202 <li <?php echo (!isset($_GET['pr']) && !isset($_GET['b'])) ? "class=\"active\"" : ""; ?>><a href="choose.php"><b>フリー</b></a></li>
203 <li <?php echo (isset($_GET['pr'])) ? "class=\"active\"" : ""; ?>><a href="?pr"><b>有給の</b></a></li>
204 <li <?php echo (isset($_GET['b'])) ? "class=\"active\"" : ""; ?>><a href="?b"><b>買った</b></a></li>
205 </ul>
206 <div class="navbar-right navbar-text"><strong>メロンポイント: <i><?=$points?></i></strong></div>
207 </div>
208 </div>
209 </nav>
210 <div class="container">
211 <div class="row">
214 <?php
215 if (!isset($_GET['pr']) && !isset($_GET['b'])) {
216 print "<center>";
217 #echo $livesitePath2;
218 #exit;
219 if (!isset($_GET['pr']) && !isset($_GET['b'])) {
220 $ico = file('ico.txt');
221 $c = count($ico)/20;
222 if(strpos($c,".")>0)
223 $c = $c+1;
224 $p = (isset($_GET['p'])&&is_numeric($_GET['p']))?($_GET['p']*20):20;
225 $s = (isset($_GET['p'])&&is_numeric($_GET['p']))?$p-20:0;
226 for ($i=$s; $i < $p; $i++)
227 if(isset($ico[$i])){
229 print "<div class=\"panel panel-default art\">";
230 echo "<a class=\"thumbnail\" style=\"margin-bottom: 0;\" href=\"status.php?ico=".$ico[$i]."\"><img src=\"".$livesitePath2."/ico/".$ico[$i]."\" style=\"width:80px; height:80px;\"> </a>";
231 print "</div>";
233 print "
234 <div class=\"clearfix\"></div>
235 <div style=\"max-width:500px;margin-top:30px;text-align:center\">";
236 for($t=1;$t<=$c;$t++)
237 print "<a href=\"choose.php?p=$t\" style=\"margin:5px;padding:5px;display:inline-block\">$t</a>";
238 print "</div>";
239 print "</center>";
243 </div>
244 <?php } elseif(isset($_GET['pr'])) {
246 if(detect_device2($_SERVER['HTTP_USER_AGENT']) != "PLSDISPLAY") {
247 die("NG");
250 <div class="col-md-3">
251 <div class="panel panel-default">
252 <div class="panel-heading"><b>Categories</b></div>
253 <ul class="list-group">
254 <a href="?pr&cat=popular" class="list-group-item <?php echo ($_GET['cat']=="popular") ? "active" : ""; ?>">Popular</a>
255 <?php
256 $category = file(ADB_PATH."class.log");
257 if(count($category)>0){
258 $getCat = (isset($_GET['cat'])) ? $_GET['cat'] : "";
259 foreach ($category as $key => $value) {
260 $name = within_str($value, "<classname>", "</classname>");
261 $id = within_str($value, "<id>", "</id>");
262 $current = ($getCat==$name) ? "active" : "";
263 if(countClass($id)>0){
264 echo '<a class="list-group-item '.$current.'" href="?pr&cat='.$name.'">'.ucfirst($name).' <span class="badge pull-right">'.countClass($id).'</span></a>';
269 <a href="?pr" class="list-group-item <?php echo (!isset($_GET['cat']) && isset($_GET['pr'])) ? "active" : ""; ?>">Others</a>
270 </ul>
271 </div>
272 </div>
274 <div class="col-md-9">
275 <?php
276 if (!file_exists(ADB_PATH."/imglist.log")) {
277 echo "<center><h3>No Available Avatars At The Moment</h3></center>";
278 exit;
281 $classList = file(ADB_PATH."class.log");
282 $file = file(ADB_PATH."/imglist.log");
283 $transaction = file(ADB_PATH."/transaction.log");
284 // echo "<pre>";
285 // print_r($transaction);
286 // echo "</pre>";
288 if(count($file) < 1){
289 echo "<center><h3>No Available Avatars At The Moment</h3></center>";
292 // if(isset($_GET['cat'])){
293 switch ($_GET['cat']) {
294 case 'popular':
295 $classActive = "popular";
296 break;
298 default:
299 $classActive = FindClass($_GET['cat']);
300 break;
302 // }
303 // $classActive = (isset($_GET['cat']) ? FindClass($_GET['cat']) : "");
304 $premiumBreaker = 0;
308 if ($classActive=="popular") {
309 echo '<div>';
310 foreach ($transaction as $key => $value) {
311 $imgName = $message->within_str($value, "<name>", "</name>");
312 $imgList[$imgName] = ["count" => 0];
314 // var_dump($message);
316 foreach ($transaction as $key => $value) {
317 $countTransaction[] = [ "name" => $message->within_str($value,"<name>","</name>"), "artist_id" => $message->within_str($value,"<id>","</id>") ];
320 $sumList = array_count_values(array_map(function($countTransaction) {
321 return $countTransaction['name'];
322 }, $countTransaction));
323 arsort($sumList);
324 $countBreaker = 0;
325 // echo "<pre>";
326 // print_r($sumList);
327 // echo "</pre>";
328 foreach ($file as $key => $value) {
329 foreach ($sumList as $key2 => $count) {
330 $name = $message->within_str($value, "<name>", "</name>");
331 if( $name==$key2 && $countBreaker != 10){
333 $class = within_str($value, "<classid>", "</classid>");
334 $disabled = "";
336 if($message->within_str($value, "<stat>", "</stat>")!="deleted"){
337 // echo within_str($value, "<name>", "</name>")."<br>";
338 $nonasd = true;
339 $ngaun = $message->within_str(trim($value), "<name>", "</name>");
340 if (isset($userbp)) {
341 foreach ($userbp as $key2 => $value2) {
342 $noon = within_str(trim($value2),"<filename>","</filename>");
343 $noon = explode(".gif", $noon);
344 /*echo "--".$noon[0]."--";
345 exit;*/
346 if (trim($noon[0]) == trim($ngaun)) {
347 /*echo trim($ngaun);
348 exit;*/
349 $disabled = "disabled";
353 $btn = '<button class="btn btn-success" data-toggle="modal" data-target="#'.$message->within_str($value, "<name>", "</name>") .'"'.$disabled.'>BUY</button>';
355 echo '
357 <div class="panel panel-default art">
358 <div class="panel-body">
359 <a class="thumbnail">
360 <img src="'.$livesitePath.'/premium/'.$message->within_str($value, "<name>", "</name>") .'.gif" style="width:80px; height:80px;" alt="">
361 </a>
362 <center>
363 <span>'.$message->within_str($value, "<price>", "</price>").' MP</span><br><br>
364 '.$btn.'
365 <center><br>
366 </center>
367 <div class="clearfix"></div>
368 </div>
369 </div>';
371 echo "<div id='".$message->within_str($value, "<name>", "</name>") ."' class='modal fade' tabindex='-1' role='dialog' aria-labelledby='buy' aria-hidden='true'>
372 <div class='modal-dialog'>
373 <div class='modal-content'>
374 <div class='modal-header'>
375 <button type='button' class='close' data-dismiss='modal'>
376 <span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span>
377 </button>
378 <h3>これと同様にあなたがあなたの新しいBEアバターなるにはするか? </h3>
379 </div>
380 <div class='modal-body'>
381 これは価値がある ".$message->within_str($value, "<price>", "</price>")." メロンポイント
382 </div>
383 <div class='modal-footer'>
384 <a href='choose.php?pay=".$premiumBreaker."' onclick class='btn btn-success chooseModal'>購入</a>
385 </div>
386 </div>
387 </div>
388 </div>";
390 $countBreaker++;
394 $premiumBreaker++;
396 }else{
397 echo '<div id="shuffle">';
398 foreach ($file as $key => $value) {
399 $class = within_str($value, "<classid>", "</classid>");
400 $disabled = "";
401 if(!$message->within_str($value, "<stat>", "</stat>") && $class==$classActive){
402 $nonasd = true;
403 $ngaun = $message->within_str(trim($value), "<name>", "</name>");
404 if (isset($userbp)) {
405 foreach ($userbp as $key2 => $value2) {
406 $noon = within_str(trim($value2),"<filename>","</filename>");
407 $noon = explode(".gif", $noon);
408 /*echo "--".$noon[0]."--";
409 exit;*/
410 if (trim($noon[0]) == trim($ngaun)) {
411 /*echo trim($ngaun);
412 exit;*/
413 $disabled = "disabled";
417 $btn = '<button class="btn btn-success" data-toggle="modal" data-target="#'.$message->within_str($value, "<name>", "</name>") .'"'.$disabled.'>BUY</button>';
419 echo '<div class="panel panel-default art">
420 <a class="thumbnail">
421 <img src="'.$livesitePath.'/premium/'.$message->within_str($value, "<name>", "</name>") .'.gif" style="width:80px; height:80px;" alt="">
422 </a>
423 <center>
424 <span>'.$message->within_str($value, "<price>", "</price>").' MP</span><br><br>
425 '.$btn.'
426 <center><br>
427 </center>
428 <div class="clearfix"></div>
429 </div>';
431 echo "<div id='".$message->within_str($value, "<name>", "</name>") ."' class='modal fade' tabindex='-1' role='dialog' aria-labelledby='buy' aria-hidden='true'>
432 <div class='modal-dialog'>
433 <div class='modal-content'>
434 <div class='modal-header'>
435 <button type='button' class='close' data-dismiss='modal'>
436 <span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span>
437 </button>
438 <h3>これと同様にあなたがあなたの新しいBEアバターなるにはするか? </h3>
439 </div>
440 <div class='modal-body'>
441 これは価値がある ".$message->within_str($value, "<price>", "</price>")." メロンポイント
442 </div>
443 <div class='modal-footer'>
444 <a href='choose.php?pay=".$premiumBreaker."' onclick class='btn btn-success chooseModal'>購入</a>
445 </div>
446 </div>
447 </div>
448 </div>";
450 $premiumBreaker++;
455 if (!isset($nonasd)) {
456 echo "<center><h3>ご利用いただけませんアバター</h3></center>";
459 </div>
460 <?php }elseif(isset($_GET['b'])){ ?>
461 <div class="body showcase sizecontrol">
462 <div style="margin-left:5%;">
463 <?php
464 $fdir = substr($email, 0, 1);
465 $sdir = substr($email, 1, 1);
466 $usrPath = UDB_PATH."{$fdir}/{$sdir}/{$email}/";
468 if(file_exists($usrPath."usrimg.log")){
469 $usrList = file($usrPath."usrimg.log");
470 foreach ($usrList as $key => $value) {
471 $loopedImg = explode("-", $message->within_str($value, "<filename>", "</filename>"));
472 echo '<div class="panel panel-default art">
473 <a href="status.php?bico='.$loopedImg[0].'" class="thumbnail">
474 <img src="'.$livesitePath.'/premium/'.$loopedImg[0].'" style="width:80px; height:80px;" alt="">
475 </a>
476 <center>
477 <span>'.$message->within_str($value, "<aid>", "</aid>").'</span><br><br>
478 </center>
479 <div class="clearfix"></div>
480 </div>';
483 }else{
484 echo "<h1>なし</h1>";
487 </div>
488 </div>
489 <?php }?>
491 </div>
492 </div>
493 </div>
495 <script src="js/jquery-1.9.1.js"></script>
496 <script src="js/bootstrap.js"></script>
497 <script>
498 (function($){
500 $.fn.shuffle = function() {
502 var allElems = this.get(),
503 getRandom = function(max) {
504 return Math.floor(Math.random() * max);
506 shuffled = $.map(allElems, function(){
507 var random = getRandom(allElems.length),
508 randEl = $(allElems[random]).clone(true)[0];
509 allElems.splice(random, 1);
510 return randEl;
513 this.each(function(i){
514 $(this).replaceWith($(shuffled[i]));
517 return $(shuffled);
521 })(jQuery);
523 $(document).ready(function(){
524 $("a.chooseModal").one("click", function() {
525 $(this).click(function () { return false; });
527 <?php if(isset($_GET['pr'])){ ?>
528 $('.art').shuffle();
529 <?php } ?>
531 </script>
532 </body>
533 </html>