public function show($id, Request $request)
 {
     $user = User::findOrFail($id);
     $prefectures = Util::getPrefectures();
     $prefecture = $prefectures[$user->prefecture];
     $line = Util::getLineNameFromLineIndex($user->line);
     $station = Util::getStationNameFromStationIndex($user->station);
     $active = ['list' => '', 'favorites' => '', 'followers' => '', 'follows' => ''];
     $url = ['list' => "href=/writers/{$id}", 'favorites' => "href=/writers/{$id}/favorites", 'followers' => "href=/writers/{$id}/followers", 'follows' => "href=/writers/{$id}/follows"];
     $path = $request->path();
     $writers = [];
     $articles = [];
     $follow = $user->checkFollow();
     switch ($path) {
         case "writers/{$id}/followers":
             $writers = $user->followedUsers()->paginate(10);
             $url['followers'] = '';
             $active['followers'] = 'active';
             break;
         default:
             $articles = $user->articles()->latest('published_at')->published()->paginate(10);
             $active['list'] = 'active';
             $url['list'] = '';
             break;
     }
     return view('users.show', compact('user', 'prefecture', 'line', 'station', 'articles', 'writers', 'active', 'url', 'follow'));
 }
示例#2
0
 public function push($lat, $long, $user_id)
 {
     $arr = null;
     try {
         $location = new Location();
         $location->latitude = $lat;
         $location->longitude = $long;
         $location->date = Util::dateTimeNow();
         $location->user_id = $user_id;
         $location->save();
         $arr = ['status' => 'OK'];
     } catch (\Exception $e) {
         $arr = ['status' => 'ERROR'];
         Log::error('ERROR: ' . $e->getmessage());
     }
     return json_encode($arr);
 }
示例#3
0
});
$app->get('/start2/archives', function () {
    $files = Storage::disk('local')->files('start2');
    $list = [];
    $matches = [];
    foreach ($files as $file) {
        preg_match('/\\d{8,12}/', $file, $matches);
        if (count($matches) > 0) {
            array_push($list, $matches[0]);
        }
    }
    return response()->json($list);
});
$app->get('/start2/prev', function () {
    $files = Storage::disk('local')->files('start2');
    if (count($files) < 1) {
        return Util::errorResponse('There is no start2 data in server');
    }
    $file = $files[max(count($files) - 2, 0)];
    $data = Storage::disk('local')->get($file);
    return response($data)->header('Content-Type', 'application/json');
});
$app->get('/start2/{version:\\d{8,12}}', function ($version) {
    $file = 'start2/' . $version . '.json';
    try {
        $data = Util::read($file);
        return response($data)->header('Content-Type', 'application/json');
    } catch (FileNotFoundException $e) {
        return Util::errorResponse("start2({$version}) not found in server");
    }
});
示例#4
0
                $item['scene'] = Util::$vcScenes[$voiceId];
                $item['voiceId'] = $voiceId;
                array_push($result, $item);
            }
        }
        $results[$id] = $result;
    }
    return response()->json($results);
}]);
$app->get('/subtitle/detail/{id:\\d{1,4}}', ['middleware' => 'cache', function ($id) {
    $subtitlesRaw = Util::remember('subtitles/distinct', function () {
        return json_decode(Storage::disk('local')->get('subtitles/subtitles_distinct.json'), true);
    });
    $subtitles = $subtitlesRaw['zh'];
    $subtitlesJP = $subtitlesRaw['jp'];
    $ship = json_decode(Util::getShipById($id), true);
    $id = $ship['id'];
    $result = [];
    if (!array_key_exists($id, $subtitles) && !array_key_exists($id, $subtitlesJP)) {
        return response()->json($result);
    }
    for ($voiceId = 1; $voiceId < 54; $voiceId++) {
        if (array_key_exists($id, $subtitles) && array_key_exists($voiceId, $subtitles[$id])) {
            $item = [];
            $item['zh'] = $subtitles[$id][$voiceId];
            if (array_key_exists($id, $subtitlesJP) && array_key_exists($voiceId, $subtitlesJP[$id])) {
                $item['jp'] = $subtitlesJP[$id][$voiceId];
            }
            $wikid = $ship['wiki_id'];
            $alias = Util::$vcScenesAlias[$voiceId];
            $filename = "{$wikid}-{$alias}.mp3";
 /**
  * Show the form for editing the specified resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function edit()
 {
     $prefectures = Util::getPrefectures();
     return view('users.edit')->with('prefectures', $prefectures);
 }
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     $prefectures = Util::getPrefectures();
     return view('auth.register')->with('prefectures', $prefectures);
 }
 private function handleTyku()
 {
     $results = [];
     $rows = DB::select('select mapId,mapAreaId,cellId,count(*) as count from tyku group by mapId,mapAreaId,cellId order by mapId,mapAreaId,cellId');
     foreach ($rows as $r) {
         $maxTyku = DB::select("select max(maxTyku) as max,count(*) as count from tyku where (seiku=0 or seiku=3 or seiku=4) and mapId=:mapId and mapAreaId=:mapAreaId and cellId=:cellId", ['mapId' => $r->mapId, 'mapAreaId' => $r->mapAreaId, 'cellId' => $r->cellId]);
         $minTyku = DB::select("select min(maxTyku) as min,count(*) as count from tyku where (seiku=1 or seiku=2) and mapId=:mapId and mapAreaId=:mapAreaId and cellId=:cellId", ['mapId' => $r->mapId, 'mapAreaId' => $r->mapAreaId, 'cellId' => $r->cellId]);
         if ($maxTyku[0]->count == 0 && $minTyku[0]->count == 0) {
             $tyku = -1;
         } else {
             if ($maxTyku[0]->count == 0) {
                 $tyku = $minTyku[0]->min;
             } else {
                 if ($minTyku[0]->count == 0) {
                     $tyku = $maxTyku[0]->max + 1;
                 } else {
                     if ($maxTyku[0]->max + 1 > $minTyku[0]->min) {
                         $tyku = $maxTyku[0]->max + 1;
                     } else {
                         $tyku = $minTyku[0]->min;
                     }
                 }
             }
         }
         array_push($results, ['mapId' => $r->mapId, 'mapAreaId' => $r->mapAreaId, 'cellId' => $r->cellId, 'tyku' => $tyku, 'count' => $r->count]);
     }
     Util::dump('report/tyku.json', $results);
 }
示例#8
0
 /**
  * @param mixed $srcJson
  * @param mixed $dstJson
  * @return bool
  */
 public static function compareJson($srcJson, $dstJson)
 {
     if (!is_array($srcJson) && !is_array($dstJson)) {
         return $srcJson === $dstJson;
     }
     if (!is_array($srcJson) && is_array($dstJson) || is_array($srcJson) && !is_array($dstJson)) {
         return false;
     }
     foreach ($srcJson as $key => $value) {
         if (!array_key_exists($key, $dstJson)) {
             return false;
         }
         if (is_array($value)) {
             if (!is_array($dstJson[$key])) {
                 return false;
             }
             if (Util::compareJson($srcJson[$key], $dstJson[$key])) {
                 continue;
             } else {
                 return false;
             }
         }
         if ($value !== $dstJson[$key]) {
             return false;
         }
     }
     return true;
 }
示例#9
0
    }
    $inputs = $request->all();
    $dantan = array_key_exists('dantan', $inputs) ? $inputs['dantan'] : false;
    foreach ($inputs['eventId'] as $eventno => $event) {
        MapEvent::create(['mapAreaId' => $inputs['mapAreaId'], 'mapId' => $inputs['mapId'], 'cellId' => $inputs['cellId'], 'eventId' => $event, 'eventType' => $inputs['eventType'], 'count' => $inputs['count'][$eventno], 'dantan' => $dantan]);
    }
    return response()->json(['result' => 'success']);
}]);
$app->get('/map/max/hp', ['middleware' => 'report-cache', function (Request $request) {
    $rules = ['mapAreaId' => 'required|digits_between:1,3', 'mapId' => 'required|digits_between:1,3', 'maxHp' => 'required|digits_between:1,10', 'lv' => 'required|digits_between:1,4'];
    $validator = Validator::make($request->all(), $rules);
    if ($validator->fails()) {
        return response()->json(['result' => 'error', 'reason' => 'Data invalid']);
    }
    $inputs = $request->all();
    MapMaxHp::create(['mapAreaId' => $inputs['mapAreaId'], 'mapId' => $inputs['mapId'], 'maxHp' => $inputs['maxHp'], 'lv' => $inputs['lv']]);
    return response()->json(['result' => 'success']);
}]);
// Report Results
$app->get('/report/enemies', ['middleware' => 'cache', function () {
    $raw = Util::load('report/enemy.json');
    return $raw;
}]);
$app->get('/report/new', ['middleware' => 'cache', function () {
    $raw = Util::load('report/new.json');
    return $raw;
}]);
$app->get('/report/tyku', ['middleware' => 'cache', function () {
    $raw = Util::load('report/tyku.json');
    return $raw;
}]);