Initial commit
[2ch-be.git] / dev-test / choose.php.bak
blobc8f647505ee8778524c3c6b33f3b725624d83152
1 <?php
2 if (!isset($_COOKIE['DMDM']) && !isset($_COOKIE['MDMD'])) {
3   header('location:index.php');
4         exit;
6 include('config.php');
7 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");
18                                 
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(ADBD_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  = ADBD_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;
48                                         }
49                                 } else {
50                                         $handle = fopen($filename, "a");
51                                         if(!fwrite($handle, $writeData)) {
52                                                 echo "Error!";
53                                                 return false;
54                                         }
55                                         fclose($handle);
56                                 }
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 ="";
64                                 }
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
71                                 {
72                       echo "412";
73                       exit;
74                                 }
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]);
82                                 }
83                                 
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}");
96                                 }
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;
105                                                 }
106                                                 fclose($handle);
107                                                         $writeSuccess = true;
108                                 }
109                                 //end
110                         file_put_contents(DB_PATH."$fdir/$sdir/$email", $writeData);
111                                                 header('location:status.php');
112                                                 exit;
113                                         
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;
118                         }
119                         
120                 }
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;
125         }
128 <!DOCTYPE html>
129 <html lang="en">
130 <head>
131         <meta charset="UTF-8">
132         <meta http-equiv="X-UA-Compatible" content="IE=edge">
133         <meta name="viewport" content="width=device-width, initial-scale=1">
134         <link rel="stylesheet" href="css/bootstrap.css">
135         <link rel="stylesheet" href="css/astyle.css">   
136 </head>
137 <body>
138         
139         <div class="container body">
140                 <div class="row">
141                         <div class="col-md-12">
142                                 <center>
143                                         <!-- <button class="btn btn-lg btn-default">FREE</button>
144                                         <button class="btn btn-lg btn-primary">PAID</button> -->
145                                         <a href="choose.php" class="btn btn-lg btn-default" style="<?php echo $hide; ?>">フリー</a>
146                                         <a href="choose.php?pr" class="btn btn-lg btn-primary" style="<?php echo $hide; ?>">有給の</a>
147                                         <a href="choose.php?b" class="btn btn-lg btn-primary" style="<?php echo $hide; ?>">買った</a>
148                                         <?php 
149                                                 if(isset($_GET['pr'])){
150                                                                 echo "<h3 style=\"$hide\">有料のアバター</h3>";
151                                                         } elseif (isset($_GET['b'])) {
152                                                                 echo "<h3 style=\"$hide\">アバターは買った</h3>";
153                                                         } else {
154                                                                 echo "<h3 style=\"$hide\">無料アバター</h3>";
155                                                         }
156                                         ?>
157                                 </center>
158                                 <?php
159                                         print "<center>";
160                                         #echo $livesitePath2;
161                                         #exit;
162                                         if (!isset($_GET['pr']) && !isset($_GET['b'])) {
163                                         $ico = file('ico.txt');
164                                         $c = count($ico)/20;
165                                         if(strpos($c,".")>0)
166                                                 $c = $c+1;
167                                         $p = (isset($_GET['p'])&&is_numeric($_GET['p']))?($_GET['p']*20):20;
168                                         $s = (isset($_GET['p'])&&is_numeric($_GET['p']))?$p-20:0;
169                                         print "<div style=\"margin-top:100px\">";
170                                         for ($i=$s; $i < $p; $i++) 
171                                                 if(isset($ico[$i]))
172                                                         echo "<a href=\"status.php?ico=".$ico[$i]."\"><img src=\"".$livesitePath2."/ico/".$ico[$i]."\" height=\"30\" style=\"margin:5px;\"></a>";
173                                         print "</div>";
174                                         print "<div style=\"max-width:500px;margin-top:30px;text-align:center\">";
175                                         for($t=1;$t<=$c;$t++)
176                                                 print "<a href=\"choose.php?p=$t\" style=\"margin:5px;padding:5px;display:inline-block\">$t</a>";
177                                         print "</div>";
178                                         print "</center>";
179                                         } elseif(isset($_GET['pr'])) {
181                                                 if(detect_device2($_SERVER['HTTP_USER_AGENT']) != "PLSDISPLAY") {
182                                                         die("NG");
183                                                 }
184                                         ?>
186                                 <div class="body showcase">
187                                         <div style="margin-left:5%;">
188                                                 <?php
189                                                         $points = file_get_contents("http://tpol27.nttec.com/melon.php?email=".$email); 
190                                                         echo "<h1>メロンポイント: {$points}</h1>";
192                                                         if (!file_exists(ADBD_PATH."/imglist.log")) {
193                                                                 echo "<center><h3>No Available Avatars At The Moment</h3></center>";
194                                                                 exit;
195                                                         }
197                                                         $file   = file(ADBD_PATH."/imglist.log");
198                                                         if(count($file) < 1){
199                                                                 echo "<center><h3>No Available Avatars At The Moment</h3></center>";
201                                                         }
202                                                         
203                                                         $premiumBreaker = 0;
205                                                         // $fdir    = substr($email, 0, 1);
206                                                         // $sdir    = substr($email, 1, 1);
207                                                         // $usrPath = UDB_PATH."{$fdir}/{$sdir}/{$email}/";
208                                                         // if(file_exists($usrPath."usrimg.log")){
209                                                         //      $usrList        = file($usrPath."usrimg.log");
210                                                         //      $usrListBreaker = TRUE;
211                                                         // }
212 #shuffle($file);
213                                                         echo '<div id="shuffle">';
214                                                         foreach ($file as $key => $value) {
215                                                                 $disabled = "";
216                                                                 if(!$message->within_str($value, "<stat>", "</stat>")){
217                                                                         $nonasd = true;
219                                                                         $ngaun = $message->within_str(trim($value), "<name>", "</name>");
220                                                                         /*echo $ngaun."<br>";
221                                                                         exit;*/
223                                                                         if (isset($userbp)) {
224                                                                                 foreach ($userbp as $key2 => $value2) {
225                                                                                         $noon = within_str(trim($value2),"<filename>","</filename>");
226                                                                                         $noon = explode(".gif", $noon);
227                                                                                         /*echo "--".$noon[0]."--";
228                                                                                         exit;*/
229                                                                                         if (trim($noon[0]) == trim($ngaun)) {
230                                                                                                 /*echo trim($ngaun);
231                                                                                                 exit;*/
232                                                                                                 $disabled = "disabled";
233                                                                                         }
234                                                                                 }
235                                                                         }
236                                                                         //<time>1413275692</time><filename>3906600.gif-PREM</filename><aid>87532632</aid>
237                                                                         //<id>40689640</id><name>6812020</name><price>50</price><stat>deleted</stat>
239                                                                 // if($usrListBreaker){
240                                                                 //      if(count($usrList)>0){
241                                                                 //              foreach ($usrList as $key2 => $value2) {
242                                                                 //                      if($message->within_str($value2, "<filename>", "</filename>")==$message->within_str($value, "<name>", "</name>") .'.gif-PREM'){
243                                                                 //                              echo $value2;
244                                                                 //                              $btn          = '<button class="btn btn-success" disabled data-toggle="modal">BOUGHT</button>';
245                                                                 //                              $modalBreaker = FALSE;
246                                                                 //                      }else{
247                                                                 //                              $btn          = '<button class="btn btn-success" data-toggle="modal" data-target="#'.$message->within_str($value, "<name>", "</name>") .'">BUY</button>';
248                                                                 //                              $modalBreaker = TRUE;
249                                                                 //                      }
250                                                                 //              }
251                                                                 //      }else{
252                                                                 //              $modalBreaker = TRUE;
253                                                                 //              $btn          = '<button class="btn btn-success" data-toggle="modal" data-target="#'.$message->within_str($value, "<name>", "</name>") .'">BUY</button>';
255                                                                 //      }
256                                                                 // }else{
257                                                                 //      $modalBreaker = TRUE;
258                                                                 $btn          = '<button class="btn btn-success" data-toggle="modal" data-target="#'.$message->within_str($value, "<name>", "</name>") .'"'.$disabled.'>BUY</button>';
259                                                                 // }
261                                                                 echo    '<div class="panel panel-default art">
262                                                                                         <a class="thumbnail">
263                                                                                                 <img src="'.$livesitePath.'dev-test/premium/'.$message->within_str($value, "<name>", "</name>") .'.gif" style="width:80px; height:80px;" alt="">
264                                                                                         </a>
265                                                                                         <center>
266                                                                                         <span>'.$message->within_str($value, "<price>", "</price>").' MP</span><br><br>
267                                                                                         '.$btn.'
268                                                                                         <center><br>
269                                                                                         </center>
270                                                                                         <div class="clearfix"></div>
271                                                                                 </div>';
272                                                 
273                                                                                 // if($modalBreaker){
275                                                                                         echo "<div id='".$message->within_str($value, "<name>", "</name>") ."' class='modal fade' tabindex='-1' role='dialog' aria-labelledby='buy' aria-hidden='true'>
276                                                                                                         <div class='modal-dialog'>
277                                                                                                                 <div class='modal-content'>
278                                                                                                                         <div class='modal-header'>
279                                                                                                                                 <button type='button' class='close' data-dismiss='modal'>
280                                                                                                                                         <span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span>
281                                                                                                                                 </button>
282                                                                                                                                 <h3>これと同様にあなたがあなたの新しいBEアバターなるにはするか? </h3>
283                                                                                                                         </div>
284                                                                                                                         <div class='modal-body'>
285                                                                                                                                 これは価値がある ".$message->within_str($value, "<price>", "</price>")." メロンポイント
286                                                                                                                         </div>
287                                                                                                                         <div class='modal-footer'>
288                                                                                                                                 <a href='choose.php?pay=".$premiumBreaker."' onclick class='btn btn-success chooseModal'>購入</a>
289                                                                                                                         </div>
290                                                                                                                 </div>
291                                                                                                         </div>
292                                                                                                 </div>";
293                                                                                 // }
294                                                                 }
295                                                                         $premiumBreaker++;
296                                                         }
297                                                         if (!isset($nonasd)) {
298                                                                 echo "<center><h3>ご利用いただけませんアバター</h3></center>";
299                                                         }
300                                                 ?>
301                                                 </div>  
302                                         </div>  
303                                 </div>
304                                 <?php }elseif(isset($_GET['b'])){ ?>
305                                                 <div class="body showcase sizecontrol">
306                                                         <div style="margin-left:5%;">
307                                                                 <?php 
308                                                                         $fdir    = substr($email, 0, 1);
309                                                                         $sdir    = substr($email, 1, 1);
310                                                                         $usrPath = UDB_PATH."{$fdir}/{$sdir}/{$email}/";
311                                                                         
312                                                                         if(file_exists($usrPath."usrimg.log")){
313                                                                                 $usrList = file($usrPath."usrimg.log");
314                                                                                 foreach ($usrList as $key => $value) {
315                                                                                         $loopedImg = explode("-", $message->within_str($value, "<filename>", "</filename>"));
316                                                                                         echo    '<div class="panel panel-default art">
317                                                                                                                 <a href="status.php?bico='.$loopedImg[0].'" class="thumbnail">
318                                                                                                                         <img src="'.$livesitePath.'dev-test/premium/'.$loopedImg[0].'" style="width:80px; height:80px;" alt="">
319                                                                                                                 </a>
320                                                                                                                 <center>
321                                                                                                                 <span>'.$message->within_str($value, "<aid>", "</aid>").'</span><br><br>
322                                                                                                                 </center>
323                                                                                                                 <div class="clearfix"></div>
324                                                                                                         </div>';
326                                                                                 }
327                                                                         }else{
328                                                                                 echo "<h1>なし</h1>";
329                                                                         }
330                                                                 ?>
331                                                         </div>  
332                                                 </div>
333                                 <?php }?>
334                         </div>
335                 </div>
336         </div>
339         <script src="js/jquery-1.9.1.js"></script>
340         <script src="js/bootstrap.js"></script>
341         <script>
342         (function($){
343          
344             $.fn.shuffle = function() {
345          
346                 var allElems = this.get(),
347                     getRandom = function(max) {
348                         return Math.floor(Math.random() * max);
349                     },
350                     shuffled = $.map(allElems, function(){
351                         var random = getRandom(allElems.length),
352                             randEl = $(allElems[random]).clone(true)[0];
353                         allElems.splice(random, 1);
354                         return randEl;
355                    });
356          
357                 this.each(function(i){
358                     $(this).replaceWith($(shuffled[i]));
359                 });
360          
361                 return $(shuffled);
362          
363             };
364          
365         })(jQuery);
367         $(document).ready(function(){
368                 $("a.chooseModal").one("click", function() {
369                     $(this).click(function () { return false; });
370                 });
371                 <?php if(isset($_GET['pr'])){ ?>
372                 $('.art').shuffle();
373                 <?php } ?>
374         })
375         </script>
376 </body>
377 </html>