Initial commit
[2ch-be.git] / dev-test / bak / choose.php
blob7434476df5be36e31dba65d977e92e8aa9254f89
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");
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 $list = file(ADB_PATH."class.log");
132 $em = "";
133 $err = true;
134 // print_r($list);
135 // echo ucfirst($id);
136 foreach ($list as $key => $value) {
137 $nameCat = within_str($value, "<classname>", "</classname>");
138 if($id==$nameCat){
139 $idest = within_str($value, "<id>", "</id>");
140 break;
143 return $idest;
147 function countClass($id) {
148 $list = file(ADB_PATH."imglist.log");
149 $id = (empty($id)) ? "" : $id;
150 $count = 0;
151 foreach ($list as $key => $value) {
152 $stats = within_str($value, "<stat>", "</stat>");
153 $nameCat = within_str($value, "<classid>", "</classid>");
154 $userID = within_str($value, "<id>", "</id>");
155 if($id==$nameCat && $stats!="deleted"){
156 $count++;
159 return $count;
163 <!DOCTYPE html>
164 <html lang="en">
165 <head>
166 <meta charset="UTF-8">
167 <meta http-equiv="X-UA-Compatible" content="IE=edge">
168 <meta name="viewport" content="width=device-width, initial-scale=1">
169 <title>選択アイコン</title>
170 <link rel="stylesheet" href="css/bootstrap.css">
171 <link rel="stylesheet" href="css/astyle.css">
172 <style>
173 .navbar-default .navbar-nav > .active > a{
174 color: #fff;
175 border-color: #357ebd;
176 background: #428bca;
179 .navbar-default .navbar-nav > .active > a:hover{
180 color: #fff;
181 border-color: #357ebd;
182 background: #357ebd;
184 </style>
185 </head>
186 <body>
187 <div class="container container-margin-top">
188 <nav class="navbar navbar-default" role="navigation">
189 <div class="container-fluid">
190 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu">
191 <span class="sr-only">Toggle Navigation</span>
192 <span class="icon-bar"></span>
193 <span class="icon-bar"></span>
194 <span class="icon-bar"></span>
195 </button>
196 <div class="collapse navbar-collapse" id="menu">
197 <ul class="nav navbar-nav">
198 <li <?php echo (!isset($_GET['pr']) && !isset($_GET['b'])) ? "class=\"active\"" : ""; ?>><a href="choose.php"><b>フリー</b></a></li>
199 <li <?php echo (isset($_GET['pr'])) ? "class=\"active\"" : ""; ?>><a href="?pr"><b>有給の</b></a></li>
200 <li <?php echo (isset($_GET['b'])) ? "class=\"active\"" : ""; ?>><a href="?b"><b>買った</b></a></li>
201 </ul>
202 <div class="navbar-right navbar-text"><strong>メロンポイント: <i><?=$points?></i></strong></div>
203 </div>
204 </div>
205 </nav>
206 <div class="container">
207 <div class="row">
210 <?php
211 if (!isset($_GET['pr']) && !isset($_GET['b'])) {
212 print "<center>";
213 #echo $livesitePath2;
214 #exit;
215 if (!isset($_GET['pr']) && !isset($_GET['b'])) {
216 $ico = file('ico.txt');
217 $c = count($ico)/20;
218 if(strpos($c,".")>0)
219 $c = $c+1;
220 $p = (isset($_GET['p'])&&is_numeric($_GET['p']))?($_GET['p']*20):20;
221 $s = (isset($_GET['p'])&&is_numeric($_GET['p']))?$p-20:0;
222 for ($i=$s; $i < $p; $i++)
223 if(isset($ico[$i])){
225 print "<div class=\"panel panel-default art\">";
226 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>";
227 print "</div>";
229 print "
230 <div class=\"clearfix\"></div>
231 <div style=\"max-width:500px;margin-top:30px;text-align:center\">";
232 for($t=1;$t<=$c;$t++)
233 print "<a href=\"choose.php?p=$t\" style=\"margin:5px;padding:5px;display:inline-block\">$t</a>";
234 print "</div>";
235 print "</center>";
239 </div>
240 <?php } elseif(isset($_GET['pr'])) {
242 if(detect_device2($_SERVER['HTTP_USER_AGENT']) != "PLSDISPLAY") {
243 die("NG");
246 <div class="col-md-3">
247 <div class="panel panel-default">
248 <div class="panel-heading"><b>カテゴリ</b></div>
249 <ul class="list-group">
250 <a href="?pr" class="list-group-item <?php echo (!isset($_GET['cat']) && isset($_GET['pr'])) ? "active" : ""; ?>">Others</a>
251 <?php
252 $category = file(ADB_PATH."class.log");
253 if(count($category)>0){
254 $getCat = (isset($_GET['cat'])) ? $_GET['cat'] : "";
255 foreach ($category as $key => $value) {
256 $name = within_str($value, "<classname>", "</classname>");
257 $id = within_str($value, "<id>", "</id>");
258 $current = ($getCat==$name) ? "active" : "";
259 if(countClass($id)>0){
260 echo '<a class="list-group-item '.$current.'" href="?pr&cat='.$name.'">'.ucfirst($name).' <span class="badge pull-right">'.countClass($id).'</span></a>';
265 </ul>
266 </div>
267 </div>
269 <div class="col-md-9">
270 <?php
271 if (!file_exists(ADB_PATH."/imglist.log")) {
272 echo "<center><h3>123No Available Avatars At The Moment</h3></center>";
273 exit;
275 // var_dump($file);
277 $classList = file(ADB_PATH."class.log");
278 $file = file(ADB_PATH."/imglist.log");
279 if(count($file) < 1){
280 echo "<center><h3>No Available Avatars At The Moment</h3></center>";
283 $classActive = (isset($_GET['cat']) ? FindClass($_GET['cat']) : "");
284 $premiumBreaker = 0;
285 echo '<div id="shuffle">';
286 foreach ($file as $key => $value) {
287 $class = within_str($value, "<classid>", "</classid>");
288 $disabled = "";
289 if(!$message->within_str($value, "<stat>", "</stat>") && $class==$classActive){
290 $nonasd = true;
292 $ngaun = $message->within_str(trim($value), "<name>", "</name>");
293 /*echo $ngaun."<br>";
294 exit;*/
296 if (isset($userbp)) {
297 foreach ($userbp as $key2 => $value2) {
298 $noon = within_str(trim($value2),"<filename>","</filename>");
299 $noon = explode(".gif", $noon);
300 /*echo "--".$noon[0]."--";
301 exit;*/
302 if (trim($noon[0]) == trim($ngaun)) {
303 /*echo trim($ngaun);
304 exit;*/
305 $disabled = "disabled";
309 $btn = '<button class="btn btn-success" data-toggle="modal" data-target="#'.$message->within_str($value, "<name>", "</name>") .'"'.$disabled.'>BUY</button>';
311 echo '<div class="panel panel-default art">
312 <a class="thumbnail">
313 <img src="'.$livesitePath.'/premium/'.$message->within_str($value, "<name>", "</name>") .'.gif" style="width:80px; height:80px;" alt="">
314 </a>
315 <center>
316 <span>'.$message->within_str($value, "<price>", "</price>").' MP</span><br><br>
317 '.$btn.'
318 <center><br>
319 </center>
320 <div class="clearfix"></div>
321 </div>';
323 // if($modalBreaker){
325 echo "<div id='".$message->within_str($value, "<name>", "</name>") ."' class='modal fade' tabindex='-1' role='dialog' aria-labelledby='buy' aria-hidden='true'>
326 <div class='modal-dialog'>
327 <div class='modal-content'>
328 <div class='modal-header'>
329 <button type='button' class='close' data-dismiss='modal'>
330 <span aria-hidden='true'>&times;</span><span class='sr-only'>Close</span>
331 </button>
332 <h3>これと同様にあなたがあなたの新しいBEアバターなるにはするか? </h3>
333 </div>
334 <div class='modal-body'>
335 これは価値がある ".$message->within_str($value, "<price>", "</price>")." メロンポイント
336 </div>
337 <div class='modal-footer'>
338 <a href='choose.php?pay=".$premiumBreaker."' onclick class='btn btn-success chooseModal'>購入</a>
339 </div>
340 </div>
341 </div>
342 </div>";
343 // }
345 $premiumBreaker++;
347 if (!isset($nonasd)) {
348 echo "<center><h3>ご利用いただけませんアバター</h3></center>";
351 </div>
352 <?php }elseif(isset($_GET['b'])){ ?>
353 <div class="body showcase sizecontrol">
354 <div style="margin-left:5%;">
355 <?php
356 $fdir = substr($email, 0, 1);
357 $sdir = substr($email, 1, 1);
358 $usrPath = UDB_PATH."{$fdir}/{$sdir}/{$email}/";
360 if(file_exists($usrPath."usrimg.log")){
361 $usrList = file($usrPath."usrimg.log");
362 foreach ($usrList as $key => $value) {
363 $loopedImg = explode("-", $message->within_str($value, "<filename>", "</filename>"));
364 echo '<div class="panel panel-default art">
365 <a href="status.php?bico='.$loopedImg[0].'" class="thumbnail">
366 <img src="'.$livesitePath.'/premium/'.$loopedImg[0].'" style="width:80px; height:80px;" alt="">
367 </a>
368 <center>
369 <span>'.$message->within_str($value, "<aid>", "</aid>").'</span><br><br>
370 </center>
371 <div class="clearfix"></div>
372 </div>';
375 }else{
376 echo "<h1>なし</h1>";
379 </div>
380 </div>
381 <?php }?>
383 </div>
384 </div>
385 </div>
387 <script src="js/jquery-1.9.1.js"></script>
388 <script src="js/bootstrap.js"></script>
389 <script>
390 (function($){
392 $.fn.shuffle = function() {
394 var allElems = this.get(),
395 getRandom = function(max) {
396 return Math.floor(Math.random() * max);
398 shuffled = $.map(allElems, function(){
399 var random = getRandom(allElems.length),
400 randEl = $(allElems[random]).clone(true)[0];
401 allElems.splice(random, 1);
402 return randEl;
405 this.each(function(i){
406 $(this).replaceWith($(shuffled[i]));
409 return $(shuffled);
413 })(jQuery);
415 $(document).ready(function(){
416 $("a.chooseModal").one("click", function() {
417 $(this).click(function () { return false; });
419 <?php if(isset($_GET['pr'])){ ?>
420 $('.art').shuffle();
421 <?php } ?>
423 </script>
424 </body>
425 </html>