17 커밋 ca3f2ae5af ... b41719c89e

작성자 SHA1 메시지 날짜
  Maksimus111 b41719c89e last changes 5 년 전
  Serge 4b652b6275 Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty eed4cd4ac6 middlware for admin 5 년 전
  Serge e964bc2bb9 Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty 1c8227edff calendar? 5 년 전
  Serge cf1b490faf Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty b7d4855586 fixed problem with saving positions 5 년 전
  Serge 1e24add234 Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty f3de2c93b1 tbots commands 5 년 전
  Serge a0f7f2a9eb Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty df9263b690 improved telegram post request 5 년 전
  Serge a26f532f07 Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty e2c373fa33 https force impruved, added command to config 5 년 전
  Serge 18eaaa3b04 Merge branch 'Kotenko' of gitgod/geolook into master 5 년 전
  Carello Qwerty 5b91016b9e https force 5 년 전
  Serge 09c26752a5 Merge branch 'Nikitin' of gitgod/geolook into master 5 년 전
  Serge 4f50e6ea32 Merge branch 'Nikitin' of gitgod/geolook into master 5 년 전

+ 65 - 0
app/Admin/Widgets/LogoutNav.php

@@ -0,0 +1,65 @@
+<?php
+
+namespace App\Admin\Widgets;
+
+use AdminTemplate;
+use SleepingOwl\Admin\Widgets\Widget;
+
+class LogoutNav extends Widget
+{
+
+    /**
+     * Если метод вернет false, блок не будет помещен в шаблон
+     * Данный метод не обязателен
+     *
+     * @return boolean
+     */
+    public function active()
+    {
+        return true;
+    }
+
+    /**
+     * При помещении в один блок нескольких виджетов они будут выведены в порядке их позиции
+     * Данный метод не обязателен
+     *
+     * @return integer
+     */
+    public function position()
+    {
+        return 1;
+    }
+
+    /**
+     * шаблон HTML который необходимо поместить
+     *
+     * @return string
+     */
+    public function toHtml()
+    {
+        return view('admin.navbar', [
+            'user' => auth()->user(),
+        ])->render();
+    }
+
+    /**
+     * Путь до шаблона, в который добавляем
+     *
+     * @return string|array
+     */
+    public function template()
+    {
+        // AdminTemplate::getViewPath('dashboard') == 'sleepingowl:default.dashboard'
+        return \AdminTemplate::getViewPath('_partials.header');
+    }
+
+    /**
+     * Блок в шаблоне, куда помещаем
+     *
+     * @return string
+     */
+    public function block()
+    {
+        return 'navbar.right';
+    }
+}

+ 67 - 0
app/Http/Controllers/Telegram.php

@@ -0,0 +1,67 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Location;
+use App\User;
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Log;
+
+class Telegram extends Controller
+{
+    public function locations(Request $request){
+
+        $message = $request['message'];
+
+        if (isset($message['text'])){
+            $text = substr($message['text'], 0, 1);
+
+            if($text == '/'){
+                \Telegram\Bot\Laravel\Facades\Telegram::commandsHandler(true);
+            }
+        }
+
+        if (isset($message['location'])) {
+            $user = User::where('telegram_id', $message['from']['id'])->first();
+
+            if ($user){
+                $lastLocation = $user->lastCoordinates;
+
+                if ($lastLocation){
+                    $minLat = $message['location']['latitude'] - 0.0005;
+                    $maxLat = $message['location']['latitude'] + 0.0005;
+                    $minLng = $message['location']['longitude'] - 0.0008;
+                    $maxLng = $message['location']['longitude'] + 0.0008;
+                    $newLat = false;
+                    $newLng = false;
+
+                    if ($lastLocation->lat < $minLat || $lastLocation->lat > $maxLat){
+                        $newLat = $message['location']['latitude'];
+                    }
+
+                    if ($lastLocation->lng < $minLng || $lastLocation->lng > $maxLng){
+                        $newLng = $message['location']['longitude'];
+                    }
+
+                    if($newLat || $newLng){
+                        $newLocation = new Location();
+                        $newLocation->lat = $newLat ?: $lastLocation->lat;
+                        $newLocation->lng = $newLng ?: $lastLocation->lng;
+                        $newLocation->user_id = $user->id;
+                        $newLocation->save();
+                        Log::info('я сохранил новую координату');
+                    }
+
+                } else {
+                    $newLocation = new Location();
+                    $newLocation->lat = $message['location']['latitude'];
+                    $newLocation->lng = $message['location']['longitude'];
+                    $newLocation->user_id = $user->id;
+                    $newLocation->save();
+                }
+            }
+        }
+    }
+
+    
+}

+ 16 - 9
app/Http/Controllers/UserController.php

@@ -16,7 +16,10 @@ class UserController extends Controller
     }
 
     public function show(User $id){
-       return $id->locations;
+       $userse = $id->locations;
+       //return view('user',compact('userse'));
+       return view('user',['uss' => $id, 'userse' =>$userse]);
+       //return $id->locations;
     }
 
     public function showLast(User $id){
@@ -26,19 +29,23 @@ class UserController extends Controller
     }
 
 
- public function action() {
-            $users=User::all();
+    public function action() {
+        $users=User::all();
                  
         return view('allpositions',compact('users'));
     }
-    
-    
 
     public function userdata(User $id, $date) {
       //$dates = [];
-    $dates = $id->locations()->whereDate('created_at', $date)->get();
-    //return $id->locations()->whereDate('created_at', $date)->get();
-    return view('userdate',compact('dates'));
-   //return $dates[0]["lat"]." ".$dates[0]["lng"];
+        if($id){
+            $dates = $id->locations()->whereDate('created_at', $date)->get();
+            //return $id->locations()->whereDate('created_at', $date)->get();
+
+            return view('userdate',['user' => $id, 'dates' => $dates]);
+            //return $dates[0]["lat"]." ".$dates[0]["lng"];
+        }
+
+        return abort(404);
     }
+
 }

+ 2 - 0
app/Http/Kernel.php

@@ -19,6 +19,7 @@ class Kernel extends HttpKernel
         \App\Http\Middleware\TrimStrings::class,
         \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
         \App\Http\Middleware\TrustProxies::class,
+        \App\Http\Middleware\HttpsProtocol::class
     ];
 
     /**
@@ -60,6 +61,7 @@ class Kernel extends HttpKernel
         'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
         'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
         'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
+        'admin' => \App\Http\Middleware\Admin::class,
     ];
 
     /**

+ 37 - 0
app/Http/Middleware/Admin.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
+
+class Admin
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+
+    public function handle($request, Closure $next, $guard = null)
+    {
+        $auth = Auth::guard($guard);
+
+        if (Auth::guard($guard)->guest()) {
+            if ($request->ajax() || $request->wantsJson()) {
+                return response('Unauthorized.', 401);
+            } else {
+                return redirect()->guest('/');
+            }
+        }
+
+        if ($auth->user()->email != 'admin@geolook.com') {
+            return abort(404);
+        }
+
+        return $next($request);
+    }
+}

+ 17 - 0
app/Http/Middleware/HttpsProtocol.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+
+class HttpsProtocol {
+
+    public function handle($request, Closure $next)
+    {
+        if (@$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+            \URL::forceScheme('https');
+        }
+
+        return $next($request);
+    }
+}

+ 7 - 7
app/Http/Middleware/VerifyCsrfToken.php

@@ -19,13 +19,13 @@ class VerifyCsrfToken extends Middleware
      * @var array
      */
     protected $except = [
-       // '869244226:'
+        '/tbot/869244226:AAG1K-ku_c7q-8TgaaEKR9k14kEWZ7AqfCs'
     ];
 
-     public function __construct(\Illuminate\Foundation\Application $app, \Illuminate\Contracts\Encryption\Encrypter $encrypter)
-    {
-        $this->app = $app;
-        $this->encrypter = $encrypter;
-        $this->except[] = \Telegram::getAccessToken();
-    }
+//     public function __construct(\Illuminate\Foundation\Application $app, \Illuminate\Contracts\Encryption\Encrypter $encrypter)
+//    {
+//        $this->app = $app;
+//        $this->encrypter = $encrypter;
+//        $this->except[] = \Telegram::getAccessToken();
+//    }
 }

+ 9 - 1
app/Providers/AppServiceProvider.php

@@ -2,10 +2,14 @@
 
 namespace App\Providers;
 
+use Illuminate\Support\Facades\URL;
 use Illuminate\Support\ServiceProvider;
 
 class AppServiceProvider extends ServiceProvider
 {
+    protected $widgets = [
+        \App\Admin\Widgets\LogoutNav::class,
+    ];
     /**
      * Register any application services.
      *
@@ -23,6 +27,10 @@ class AppServiceProvider extends ServiceProvider
      */
     public function boot()
     {
-        //
+        $widgetsRegistry = $this->app[\SleepingOwl\Admin\Contracts\Widgets\WidgetsRegistryInterface::class];
+
+        foreach ($this->widgets as $widget) {
+            $widgetsRegistry->registerWidget($widget);
+        }
     }
 }

+ 80 - 0
app/TCommands/MyEmail.php

@@ -0,0 +1,80 @@
+<?php
+
+namespace App\TCommands;
+
+use App\ExternalUser;
+use App\User;
+use Illuminate\Support\Facades\Log;
+use Telegram\Bot\Actions;
+use Telegram\Bot\Commands\Command;
+
+/**
+ * Class SearchCommand.
+ */
+class MyEmail extends Command
+{
+    /**
+     * @var string Command Name
+     */
+    protected $name = 'my_email';
+
+    /**
+     * @var array Command Aliases
+     */
+    protected $aliases = ['listcommands'];
+
+    /**
+     * @var string Command Description
+     */
+    protected $description = 'Привязать почту';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function handle($arguments)
+    {
+        $telegram_message = \Telegram::getWebhookUpdates()['message'];
+        $textOfMessage = $telegram_message['text'];
+        $updateId = \Telegram::getWebhookUpdates()['update_id']+1;
+        \Telegram::getWebhookUpdates(['offset'=>$updateId]);
+
+        $email = substr($textOfMessage, 9);
+
+        if ($email){
+            $trimedEmail = trim($email);
+
+            if (filter_var($trimedEmail, FILTER_VALIDATE_EMAIL)){
+                $userId = $telegram_message['from']['id'];
+                $user = User::where('email', $trimedEmail)->first();
+                Log::info('User->'. $user);
+
+                if ($user){
+
+                    if($user->telegram_id){
+                        $telegramId = $user->telegram_id == $telegram_message['from']['id'] ? true : false;
+                    } else {
+                        $telegramId = false;
+                    }
+
+                    if (!$telegramId){
+                        $user->telegram_id = $userId;
+                        $user->save();
+                    }
+
+                    $text = $telegramId ? 'Поштова скринька вже приєднана до цього номеру Telegram' : 'Вітаємо, ви приєднали скриньку';
+                } else {
+                    $text = 'користувача не зареєстровано на сайті proj.geolook.php.a-level.com.ua';
+                }
+            } else {
+                $text = 'email вказано невірно';
+            }
+
+        } else {
+            $text = 'Для приєднання поштової скриньки, вкажіть її назву через пробіл після команди /my_email.'.PHP_EOL.'Шаблон:'.PHP_EOL.'/my_email \'назва скриньки\'';
+        }
+
+        $this->replyWithMessage(compact('text'));
+
+        //Log::info(trim($email));
+    }
+}

+ 1 - 1
app/TCommands/TestCommand.php

@@ -31,7 +31,7 @@ class TestCommand extends Command
      */
     public function handle($arguments)
     {
-        Log::info($arguments);
+        Log::info(['tbot' => $arguments]);
         $text = 'Привет';
         $this->replyWithMessage(compact('text'));
 

+ 1 - 1
config/sleeping_owl.php

@@ -50,7 +50,7 @@ return [
     |
     */
 
-    'middleware' => ['web'],
+    'middleware' => ['web', 'admin'],
 
     /*
     |--------------------------------------------------------------------------

+ 2 - 0
config/telegram.php

@@ -57,5 +57,7 @@ return [
     */
     'commands' => [
         Telegram\Bot\Commands\HelpCommand::class,
+        \App\TCommands\TestCommand::class,
+        \App\TCommands\MyEmail::class
     ],
 ];

+ 32 - 0
database/migrations/2019_04_17_104050_alter_default_value_for_role_id_column_in_users_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class AlterDefaultValueForRoleIdColumnInUsersTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            $table->unsignedInteger('role_id')->after('google_id')->nullable()->change();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('users', function (Blueprint $table) {
+            //
+        });
+    }
+}

+ 22 - 0
resources/views/admin/navbar.blade.php

@@ -0,0 +1,22 @@
+<!-- Authentication Links -->
+@if (Auth::guest())
+    <li><a href="{{ url('/login') }}">Login</a></li>
+    <li><a href="{{ url('/register') }}">Register</a></li>
+@else
+    <li class="dropdown">
+        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
+            {{ Auth::user()->name }} <span class="caret"></span>
+        </a>
+
+        <ul class="dropdown-menu" role="menu">
+            <li><a class="scroll" href="{{ route('logout') }}"
+                   onclick="event.preventDefault();
+                                                 document.getElementById('logout-form').submit();">
+                    <i class="fa fa-btn fa-sign-out"></i>Вихід
+                </a></li>
+            <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
+                @csrf
+            </form>
+        </ul>
+    </li>
+@endif

+ 11 - 0
resources/views/admin/telegram.blade.php

@@ -40,4 +40,15 @@
     <form id="getwebhookinfo" action="{{ route('admin.setting.getwebhookinfo') }}" method="POST" style="display: none">
         @csrf
     </form>
+
+    <form>
+  <fieldset>
+    <legend>Вычисление координат</legend>
+    <p><label for="longtitude">longtitude <em></em></label><input name="latitude" type="text" ></p>
+    <p><label for="latitude">latitude</label><input name="longtitude" type="text" ></p>
+    <p><label for="telegram">telegram_id</label><input name="telegram_id" value="555433712"></p>
+  </fieldset>
+<p><input type="submit" value="Отправить"></p>
+</form>
+
 </div>

+ 4 - 29
resources/views/allpositions.blade.php

@@ -4,38 +4,14 @@
 <head>
     <meta charset="utf-8">
     <title>Document</title>
-<style>
-      /* Always set the map height explicitly to define the size of the div
-       * element that contains the map. */
-      #map {
-        height: 100%;
-	
-      }
-      /* Optional: Makes the sample page fill the window. */
-      html, body {
-        height: 100%;
-        margin: 0;
-        padding: 0;
-      }
-    </style>
+
 
 </head>
 <body>
 
 	  
-    <div id="map"></div>
-    <script>
-      var map;
-      function initMap() {
-        map = new google.maps.Map(document.getElementById('map'), { /*
-          center: {lat: 36.84975, lng: 49.97095},*/
-          zoom: 15
-        });
-
-        
-      
-      }
-    </script>
+   
+   
 
 
     <ul>
@@ -51,8 +27,7 @@
     </ul>
 
 	
-<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB8gUrKIK6UryDcJOEZD9V3fxpdDk8s4Lo&callback=initMap"
-    async defer></script>
+
 </body>
 
    

+ 191 - 0
resources/views/calendar.blade.php

@@ -0,0 +1,191 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Document</title>
+
+    @yield('styles')
+
+</head>
+<body>
+    <?php
+
+    $date=date("Y-m-d");
+
+    $sd = explode("-", $date);
+    $year 	= $sd[0];
+    $month = $sd[1];
+    $day 	= $sd[2];
+
+    // Вычисляем число дней в текущем месяце
+    $dayofmonth = date('t',
+        mktime(0, 0, 0, $month, 1, $year));
+    //Готовим запрос к БД
+    $todate = "$year-$month-$dayofmonth";
+    $fromdate = "$year-$month-01";
+    //$query = "SELECT date,enddate from sobytia WHERE startdate<='$todate' AND enddate>=$fromdate";
+    //$res_db = $db->sql($query);
+    //$d = array();$k=array();
+    //for($i = 1; $i<=$dayofmonth; $i++){
+    //    $k[$i] = $i;
+    //}
+    //$i=0;
+    //while ($a = mysqli_fetch_row($res_db))
+    //{
+    //    //for($i = 1; $i<=$dayofmonth; $i++){
+    //    foreach ($k	as $i)
+    //    {	//Добавление 0 к дате
+    //        if($i<10) $cd = "$year-$month-0".$i; else $cd = "$year-$month-$i";
+    //        if ($cd >= $a[0] && $cd <= $a[1])
+    //        {
+    //            $d[$i] = $cd;
+    //            unset($k[$i]);
+    //        }
+    //    }
+    //}
+    // Счётчик для дней месяца
+    $day_count = 1;
+
+    // 1. Первая неделя
+    $num = 0;
+    for($i = 0; $i < 7; $i++)
+    {
+        // Вычисляем номер дня недели для числа
+        $dayofweek = date('w',
+            mktime(0, 0, 0, $month, $day_count, $year));
+        // Приводим к числа к формату 1 - понедельник, ..., 6 - суббота
+        $dayofweek = $dayofweek - 1;
+        if($dayofweek == -1) $dayofweek = 6;
+
+        if($dayofweek == $i)
+        {
+            // Если дни недели совпадают,
+            // заполняем массив $week
+            // числами месяца
+            $week[$num][$i] = $day_count > 9 ? $day_count : '0'.$day_count;
+            $day_count++;
+        }
+        else
+        {
+            $week[$num][$i] = "";
+        }
+    }
+
+    // 2. Последующие недели месяца
+    while(true)
+    {
+        $num++;
+        for($i = 0; $i < 7; $i++)
+        {
+            $week[$num][$i] = $day_count > 9 ? $day_count : '0'.$day_count;
+            $day_count++;
+            // Если достигли конца месяца - выходим
+            // из цикла
+            if($day_count > $dayofmonth) break;
+        }
+        // Если достигли конца месяца - выходим
+        // из цикла
+        if($day_count > $dayofmonth) break;
+    }
+
+    // 3. Выводим содержимое массива $week
+    // в виде календаря
+    // Выводим таблицу
+    echo '<table id="calendar">';
+    //заголовок
+    $rusdays = array('ПН','ВТ','СР','ЧТ','ПТ','СБ','ВС');
+    $rusmonth = array('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь');
+    echo '<thead>
+			<tr>
+				<td onclick="monthf(\'prev\');"><</td>
+				<td colspan="5">'.$rusmonth[$month-1].', '.$year.'</td>
+				<td onclick="monthf(\'next\');">></td>
+			</tr>';
+    echo '<tr>';
+    foreach ($rusdays as $rusday){
+        echo '<td>'.$rusday.'</td>';
+    }
+    echo '</tr>';
+    echo '</thead>';
+    //тело календаря
+    for($i = 0; $i < count($week); $i++)
+    {
+        echo "<tr>";
+        for($j = 0; $j < 7; $j++)
+        {
+            if(!empty($week[$i][$j]))
+            {
+
+                // Если имеем дело с выбраной датой подсвечиваем ee
+                if($week[$i][$j]==$day)
+                {
+                    echo '<td class="today">';
+                }
+                else
+                {
+                    echo '<td>';
+                }
+
+                // Если запись в базе за текущую дату есть, делаем ссылку
+//            if($d[$week[$i][$j]])
+//            {
+                echo '<a href="'.route('user.date', [$user->id, $year.'-'.$month.'-'.$week[$i][$j]]).'">'.$week[$i][$j].'</a>';
+//            }
+//            else
+//            {
+//                echo $week[$i][$j];
+//            }
+
+                echo '</td>';
+            }
+            else echo "<td> </td>";
+        }
+        echo "</tr>";
+    }
+    ?>
+
+@yield('map')
+    <script>
+        var mon = parseInt("<?php echo $month; ?>");
+        console.log('sdfsdfsdfsdf', mon);
+        var year = parseInt(<?php echo $year; ?>);
+        function monthf(pn){
+            if (pn == 'next'){
+                mon++;
+            }else if (pn == 'prev'){
+                mon--;
+            }else{
+                alert('Неправильный параметр');
+                return false;
+            }
+            if (mon > 12){
+                year ++;
+                mon = 1;
+            }
+            if (mon < 1){
+                year --;
+                mon = 12;
+            }
+            if ((mon < 10) && (mon >= 1)){
+                mon = '0'+mon;
+            }
+            var nextDate = year+'-'+mon+'-00';
+
+            // var ajaxaddr = "путь_к_текущему_скрипту?date='+nextDate;
+            // var http = new XMLHttpRequest();
+            // if (http) {
+            //     http.open('get', ajaxaddr);
+            //     http.onreadystatechange = function () {
+            //         if(http.readyState == 4){
+            //             if (http.status == 200) {
+            //                 document.getElementById('calendar').innerHTML = http.responseText;
+            //             }
+            //         }
+            //     }
+            //     http.send(null);
+            // }
+        }
+    </script>
+@yield('scripts')
+
+</body>

+ 191 - 0
resources/views/calendar2.blade.php

@@ -0,0 +1,191 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title>Document</title>
+
+    @yield('styles')
+
+</head>
+<body>
+    <?php
+
+    $date=date("Y-m-d");
+
+    $sd = explode("-", $date);
+    $year 	= $sd[0];
+    $month = $sd[1];
+    $day 	= $sd[2];
+
+    // Вычисляем число дней в текущем месяце
+    $dayofmonth = date('t',
+        mktime(0, 0, 0, $month, 1, $year));
+    //Готовим запрос к БД
+    $todate = "$year-$month-$dayofmonth";
+    $fromdate = "$year-$month-01";
+    //$query = "SELECT date,enddate from sobytia WHERE startdate<='$todate' AND enddate>=$fromdate";
+    //$res_db = $db->sql($query);
+    //$d = array();$k=array();
+    //for($i = 1; $i<=$dayofmonth; $i++){
+    //    $k[$i] = $i;
+    //}
+    //$i=0;
+    //while ($a = mysqli_fetch_row($res_db))
+    //{
+    //    //for($i = 1; $i<=$dayofmonth; $i++){
+    //    foreach ($k	as $i)
+    //    {	//Добавление 0 к дате
+    //        if($i<10) $cd = "$year-$month-0".$i; else $cd = "$year-$month-$i";
+    //        if ($cd >= $a[0] && $cd <= $a[1])
+    //        {
+    //            $d[$i] = $cd;
+    //            unset($k[$i]);
+    //        }
+    //    }
+    //}
+    // Счётчик для дней месяца
+    $day_count = 1;
+
+    // 1. Первая неделя
+    $num = 0;
+    for($i = 0; $i < 7; $i++)
+    {
+        // Вычисляем номер дня недели для числа
+        $dayofweek = date('w',
+            mktime(0, 0, 0, $month, $day_count, $year));
+        // Приводим к числа к формату 1 - понедельник, ..., 6 - суббота
+        $dayofweek = $dayofweek - 1;
+        if($dayofweek == -1) $dayofweek = 6;
+
+        if($dayofweek == $i)
+        {
+            // Если дни недели совпадают,
+            // заполняем массив $week
+            // числами месяца
+            $week[$num][$i] = $day_count > 9 ? $day_count : '0'.$day_count;
+            $day_count++;
+        }
+        else
+        {
+            $week[$num][$i] = "";
+        }
+    }
+
+    // 2. Последующие недели месяца
+    while(true)
+    {
+        $num++;
+        for($i = 0; $i < 7; $i++)
+        {
+            $week[$num][$i] = $day_count > 9 ? $day_count : '0'.$day_count;
+            $day_count++;
+            // Если достигли конца месяца - выходим
+            // из цикла
+            if($day_count > $dayofmonth) break;
+        }
+        // Если достигли конца месяца - выходим
+        // из цикла
+        if($day_count > $dayofmonth) break;
+    }
+
+    // 3. Выводим содержимое массива $week
+    // в виде календаря
+    // Выводим таблицу
+    echo '<table id="calendar">';
+    //заголовок
+    $rusdays = array('ПН','ВТ','СР','ЧТ','ПТ','СБ','ВС');
+    $rusmonth = array('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь');
+    echo '<thead>
+			<tr>
+				<td onclick="monthf(\'prev\');"><</td>
+				<td colspan="5">'.$rusmonth[$month-1].', '.$year.'</td>
+				<td onclick="monthf(\'next\');">></td>
+			</tr>';
+    echo '<tr>';
+    foreach ($rusdays as $rusday){
+        echo '<td>'.$rusday.'</td>';
+    }
+    echo '</tr>';
+    echo '</thead>';
+    //тело календаря
+    for($i = 0; $i < count($week); $i++)
+    {
+        echo "<tr>";
+        for($j = 0; $j < 7; $j++)
+        {
+            if(!empty($week[$i][$j]))
+            {
+
+                // Если имеем дело с выбраной датой подсвечиваем ee
+                if($week[$i][$j]==$day)
+                {
+                    echo '<td class="today">';
+                }
+                else
+                {
+                    echo '<td>';
+                }
+
+                // Если запись в базе за текущую дату есть, делаем ссылку
+//            if($d[$week[$i][$j]])
+//            {
+                echo '<a href="'.route('user.date', [$uss->id, $year.'-'.$month.'-'.$week[$i][$j]]).'">'.$week[$i][$j].'</a>';
+//            }
+//            else
+//            {
+//                echo $week[$i][$j];
+//            }
+
+                echo '</td>';
+            }
+            else echo "<td> </td>";
+        }
+        echo "</tr>";
+    }
+    ?>
+
+@yield('map')
+    <script>
+        var mon = parseInt("<?php echo $month; ?>");
+        console.log('sdfsdfsdfsdf', mon);
+        var year = parseInt(<?php echo $year; ?>);
+        function monthf(pn){
+            if (pn == 'next'){
+                mon++;
+            }else if (pn == 'prev'){
+                mon--;
+            }else{
+                alert('Неправильный параметр');
+                return false;
+            }
+            if (mon > 12){
+                year ++;
+                mon = 1;
+            }
+            if (mon < 1){
+                year --;
+                mon = 12;
+            }
+            if ((mon < 10) && (mon >= 1)){
+                mon = '0'+mon;
+            }
+            var nextDate = year+'-'+mon+'-00';
+
+            // var ajaxaddr = "путь_к_текущему_скрипту?date='+nextDate;
+            // var http = new XMLHttpRequest();
+            // if (http) {
+            //     http.open('get', ajaxaddr);
+            //     http.onreadystatechange = function () {
+            //         if(http.readyState == 4){
+            //             if (http.status == 200) {
+            //                 document.getElementById('calendar').innerHTML = http.responseText;
+            //             }
+            //         }
+            //     }
+            //     http.send(null);
+            // }
+        }
+    </script>
+@yield('scripts')
+
+</body>

+ 55 - 0
resources/views/user.blade.php

@@ -0,0 +1,55 @@
+@extends('calendar2')
+@section('styles')
+    <style>
+          /* Always set the map height explicitly to define the size of the div
+           * element that contains the map. */
+          #map {
+            height: 50%;
+
+          }
+          /* Optional: Makes the sample page fill the window. */
+          html, body {
+            height: 100%;
+            margin: 0;
+            padding: 0;
+          }
+        </style>
+    </head>
+@endsection
+
+@section('map')
+    <div id="map"></div>
+@endsection
+
+@section('scripts')
+    <script>
+
+        var map;
+        function initMap() {
+
+            map = new google.maps.Map(document.getElementById('map'), { /*
+          center: {lat:{{ $userse  }} , lng:{{ $userse  }}  },*/
+                zoom: 15
+            });
+
+            var marker = new Array();
+            @foreach ($userse as $data)
+
+            map.setCenter({lat:{{ $data->lat  }} , lng:{{ $data->lng  }}  });
+            marker = new google.maps.Marker({
+                map:map,
+                position:{lat:{{ $data->lat  }} , lng:{{ $data->lng  }}  }
+
+            });
+
+            @endforeach
+        }
+    </script>
+
+    <ul>
+        <li></li> 
+    </ul>
+
+    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB8gUrKIK6UryDcJOEZD9V3fxpdDk8s4Lo&callback=initMap"
+            async defer></script>
+@endsection

+ 45 - 56
resources/views/userdate.blade.php

@@ -1,69 +1,58 @@
-
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="utf-8">
-    <title>Document</title>
-
-<style>
-      /* Always set the map height explicitly to define the size of the div
-       * element that contains the map. */
-      #map {
-        height: 100%;
-	
-      }
-      /* Optional: Makes the sample page fill the window. */
-      html, body {
-        height: 100%;
-        margin: 0;
-        padding: 0;
-      }
-    </style>
-</head>
-<body>
-	
-
-<div id="map"></div>
+@extends('calendar')
+@section('styles')
+    <style>
+          /* Always set the map height explicitly to define the size of the div
+           * element that contains the map. */
+          #map {
+            height: 50%;
+
+          }
+          /* Optional: Makes the sample page fill the window. */
+          html, body {
+            height: 100%;
+            margin: 0;
+            padding: 0;
+          }
+        </style>
+    </head>
+@endsection
+
+@section('map')
+    <div id="map"></div>
+@endsection
+
+@section('scripts')
     <script>
 
-      var map;
-      function initMap() {
+        var map;
+        function initMap() {
 
-        map = new google.maps.Map(document.getElementById('map'), { /*
+            map = new google.maps.Map(document.getElementById('map'), { /*
           center: {lat:{{ $dates  }} , lng:{{ $dates  }}  },*/
-          zoom: 15
-        });
-	
-	var marker = new Array();
-  @foreach ($dates as $data)
+                zoom: 15
+            });
 
-        map.setCenter({lat:{{ $data->lat  }} , lng:{{ $data->lng  }}  });
-         marker = new google.maps.Marker({
-          map:map,
-          position:{lat:{{ $data->lat  }} , lng:{{ $data->lng  }}  }
-          
-        });
+            var marker = new Array();
+            @foreach ($dates as $data)
 
-       @endforeach
-      }
-    </script>
+            map.setCenter({lat:{{ $data->lat  }} , lng:{{ $data->lng  }}  });
+            marker = new google.maps.Marker({
+                map:map,
+                position:{lat:{{ $data->lat  }} , lng:{{ $data->lng  }}  }
 
-    <ul>
-     
+            });
 
+            @endforeach
+        }
+    </script>
 
+    <ul>
         <li>
-		
-        	{{ $dates }}
-        </li>
-
 
-   
+            
+        </li>
     </ul>
 
-<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB8gUrKIK6UryDcJOEZD9V3fxpdDk8s4Lo&callback=initMap"
-    async defer></script>
-</body>
-
-   
-</html>
+    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB8gUrKIK6UryDcJOEZD9V3fxpdDk8s4Lo&callback=initMap"
+            async defer></script>
+@endsection

+ 5 - 8
resources/views/welcome.blade.php

@@ -81,17 +81,14 @@
 
             <div class="content">
                 <div class="title m-b-md">
-                    Laravel
+                    Слежение API
                 </div>
 
                 <div class="links">
-                    <a href="https://laravel.com/docs">Docs</a>
-                    <a href="https://laracasts.com">Laracasts</a>
-                    <a href="https://laravel-news.com">News</a>
-                    <a href="https://blog.laravel.com">Blog</a>
-                    <a href="https://nova.laravel.com">Nova</a>
-                    <a href="https://forge.laravel.com">Forge</a>
-                    <a href="https://github.com/laravel/laravel">GitHub</a>
+                    <a href="{{ route('users')}}">Пользователи</a>
+                    <a href="admin">Админ панель</a>
+                   
+                   
                 </div>
             </div>
         </div>

+ 8 - 7
routes/web.php

@@ -19,14 +19,15 @@ Auth::routes();
 
 Route::get('/home', 'HomeController@index')->name('home');
 
-Route::get('/user','UserController@action');
+Route::get('/user','UserController@action')->name('users');
 Route::get('/user/{id}', 'UserController@show')->where('id', '[0-9]+')->name('user.position');
 Route::get('/user/{id}/{date}', 'UserController@userdata')->where(['id'=>'[0-9]+','date'=>'[0-9]{4}-[0-9]{2}-[0-9]{2}'])->name('user.date');
 Route::get('/user/{id}/last', 'UserController@showLast')->where('id', '[0-9]+')->name('last.position');
-Route::post('/tbot/'.Telegram::getAccessToken(), function(){
-    Telegram::commandsHandler(true);
-});
+//Route::post('/tbot/'.Telegram::getAccessToken(), function(){
+//    Telegram::commandsHandler(true);
+//});
+Route::post('/tbot/'.Telegram::getAccessToken(), 'Telegram@locations');
 
-Route::post(Telegram::getAccessToken(), function () {
-	Telegram::commandsHandler(true);
-});
+//Route::post(Telegram::getAccessToken(), function () {
+//	Telegram::commandsHandler(true);
+//});