first commit
This commit is contained in:
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/LoginController.php
Executable file
39
app/Http/Controllers/Auth/LoginController.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest', ['except' => 'logout']);
|
||||
}
|
||||
}
|
||||
71
app/Http/Controllers/Auth/RegisterController.php
Executable file
71
app/Http/Controllers/Auth/RegisterController.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
13
app/Http/Controllers/Controller.php
Executable file
13
app/Http/Controllers/Controller.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
209
app/Http/Controllers/Main.php
Executable file
209
app/Http/Controllers/Main.php
Executable file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: k
|
||||
* Date: 10.02.2017
|
||||
* Time: 20:10
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Paper\HtmlToPos;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
|
||||
use Mike42\Escpos\Printer;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use Mike42\Escpos\EscposImage;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Main extends Controller
|
||||
{
|
||||
|
||||
public function imagePrint(Request $request)
|
||||
{
|
||||
|
||||
if ($request->hasFile('photo')) {
|
||||
$file = $request->photo;
|
||||
} else {
|
||||
$file = $request->input('url');
|
||||
}
|
||||
|
||||
$image = Image::make($file);
|
||||
if ($image->width() > $image->height()) {
|
||||
$image->rotate(90);
|
||||
}
|
||||
|
||||
|
||||
$image = $image->greyscale()
|
||||
->resize(300, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
|
||||
|
||||
$fileName = storage_path('temp.png');
|
||||
$image->save($fileName, 100);
|
||||
|
||||
|
||||
$img = imagecreatefrompng($fileName);
|
||||
// imagefilter($img, IMG_FILTER_GRAYSCALE);
|
||||
$width = imagesx($img);
|
||||
$height = imagesy($img);
|
||||
$img_arr = array();
|
||||
|
||||
// Parse image (can be combined with dither stage, but combining them is slower.)
|
||||
|
||||
for ($y = 0; $y < $height; $y++) {
|
||||
for ($x = 0; $x < $width; $x++) {
|
||||
$img_arr[$x][$y] = imagecolorat($img, $x, $y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// make a b/w output image.
|
||||
$output = imagecreate($width, $height);
|
||||
$black = imagecolorallocate($output, 0, 0, 0); //background color.
|
||||
$white = imagecolorallocate($output, 0xff, 0xff, 0xff);
|
||||
|
||||
|
||||
for ($y = 1; $y < $height - 3; $y++) {
|
||||
for ($x = 1; $x < $width - 3; $x++) {
|
||||
$old = $img_arr[$x][$y];
|
||||
if ($old > 0xffffff * .5) { // This is the b/w threshold. Currently @ halfway between white and black.
|
||||
$new = 0xffffff;
|
||||
imagesetpixel($output, $x, $y, $white); // Only setting white pixels, because the image is already black.
|
||||
} else {
|
||||
$new = 0x000000;
|
||||
}
|
||||
$quant_error = $old - $new;
|
||||
$error_diffusion = (1 / 8) * $quant_error; //I can do this because this dither uses 1 value for the applied error diffusion.
|
||||
//dithering here.
|
||||
$img_arr[$x + 1][$y] += $error_diffusion;
|
||||
$img_arr[$x + 2][$y] += $error_diffusion;
|
||||
$img_arr[$x - 1][$y + 1] += $error_diffusion;
|
||||
$img_arr[$x][$y + 1] += $error_diffusion;
|
||||
$img_arr[$x + 1][$y + 1] += $error_diffusion;
|
||||
$img_arr[$x][$y + 2] += $error_diffusion;
|
||||
}
|
||||
}
|
||||
|
||||
// plop out a png of the dithered image.
|
||||
|
||||
// Header("Content-type: image/png");
|
||||
imagepng($output, $fileName, 9); //to print to screen
|
||||
|
||||
|
||||
$connector = new FilePrintConnector("/dev/usb/lp0");
|
||||
$printer = new Printer($connector);
|
||||
$img = EscposImage::load($fileName, false);
|
||||
$printer->bitImage($img);
|
||||
|
||||
$printer->feed(4);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function listView(Request $request)
|
||||
{
|
||||
$notes = DB::select('SELECT * FROM note ORDER BY updated_at DESC');
|
||||
return view('list', [
|
||||
'notes' => $notes,
|
||||
'title' => $request->old('title'),
|
||||
'text' => $request->old('text')
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Request $request)
|
||||
{
|
||||
return view('create', [
|
||||
'title' => $request->old('title'),
|
||||
'text' => $request->old('text')
|
||||
]);
|
||||
}
|
||||
|
||||
public function printText($id)
|
||||
{
|
||||
$note = DB::table('note')->where('id', $id)->first();
|
||||
$this->sendPrint($note->topic, $note->text);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id, $slug)
|
||||
{
|
||||
$note = DB::table('note')->where('id', $id)->first();
|
||||
if ($request->isMethod('post')) {
|
||||
if ($request->exists('save')) {
|
||||
DB::table('note')
|
||||
->where('id', $note->id)
|
||||
->update([
|
||||
'topic' => $request->input('title'),
|
||||
'topic_slug' => str_slug($request->input('title'), '_'),
|
||||
'text' => $request->input('text'),
|
||||
'updated_at' => time(),
|
||||
]);
|
||||
} elseif ($request->exists('delete')) {
|
||||
DB::table('note')
|
||||
->where('id', $note->id)
|
||||
->delete();
|
||||
|
||||
return redirect()->route('list');
|
||||
|
||||
} elseif ($request->exists('print')) {
|
||||
$this->sendPrint($request->input('title'), $request->input('text'));
|
||||
}
|
||||
return redirect()->route('edit', ['id' => $note->id, 'slug' => $note->topic_slug]);
|
||||
} else {
|
||||
return view('edit', [
|
||||
'title' => $note->topic,
|
||||
'text' => $note->text,
|
||||
'id' => $note->id,
|
||||
'topic_slug' => $note->topic_slug,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendPrint($title, $text)
|
||||
{
|
||||
$connector = new FilePrintConnector("/dev/usb/lp0");
|
||||
$printer = new Printer($connector);
|
||||
|
||||
|
||||
|
||||
// $printer->setFont(Printer::FONT_B);
|
||||
if (strlen($title)) {
|
||||
$printer->setDoubleStrike(true);
|
||||
$printer->setJustification(Printer::JUSTIFY_CENTER);
|
||||
$printer->setEmphasis(true);
|
||||
$printer->text($title . "\n\n");
|
||||
$printer->setEmphasis(false);
|
||||
$printer->setJustification(Printer::JUSTIFY_LEFT);
|
||||
$printer->setDoubleStrike(false);
|
||||
}
|
||||
$htmlToPos = new HtmlToPos();
|
||||
$printer->text($htmlToPos->convert($text));
|
||||
|
||||
$printer->feed(4);
|
||||
$printer->close();
|
||||
}
|
||||
|
||||
public function main(Request $request)
|
||||
{
|
||||
if ($request->exists('save')) {
|
||||
$id = DB::table('note')
|
||||
->insertGetId([
|
||||
'topic' => $request->input('title'),
|
||||
'topic_slug' => str_slug($request->input('title'), '_'),
|
||||
'text' => $request->input('text'),
|
||||
'created_at' => time(),
|
||||
'updated_at' => time()
|
||||
]);
|
||||
$note = DB::table('note')->where('id', $id)->first();
|
||||
return redirect()->route('edit', ['id' => $note->id, 'slug' => $note->topic_slug]);
|
||||
} else {
|
||||
$this->sendPrint($request->input('title'), $request->input('text'));
|
||||
return back()->withInput();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
218
app/Http/Controllers/Repertoire.php
Normal file
218
app/Http/Controllers/Repertoire.php
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use DiDom\Document;
|
||||
use App\Paper;
|
||||
|
||||
class Repertoire extends Controller
|
||||
{
|
||||
|
||||
private $main;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->main = new Main();
|
||||
}
|
||||
|
||||
|
||||
public function today_cinemacity()
|
||||
{
|
||||
$date = date('d/m/Y');
|
||||
$repertuarText = $this->cinemacityRepertuar($date);
|
||||
$this->main->sendPrint('', $repertuarText);
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
public function tomorrow_cinemacity()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
$date->modify('+1 day');
|
||||
$repertuarText = $this->cinemacityRepertuar($date->format('d/m/Y'));
|
||||
$this->main->sendPrint('', $repertuarText);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function cinemacityRepertuar($date)
|
||||
{
|
||||
$url = 'https://www.cinema-city.pl/scheduleInfo?locationId=1010308&date=' . $date . '&venueTypeId=0&hideSite=false&openedFromPopup=1';
|
||||
|
||||
$document = new Document($url, true);
|
||||
$text = "Repertuar Cinema-City\n";
|
||||
$text .= str_replace('/', '-', $date) . "\n\n";
|
||||
|
||||
$movies = $document->find('table tbody tr');
|
||||
foreach ($movies as $movie) {
|
||||
// dump($movie);
|
||||
$text .= $movie->find('.featureLink')[0]->text() . "\n";
|
||||
$hours = [];
|
||||
foreach ($movie->find('.prsnt a') as $projection) {
|
||||
$hours[] = trim($projection->text());
|
||||
}
|
||||
$text .= implode(', ', $hours) . "\n\n";
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
private function multikinoRepertuar($date)
|
||||
{
|
||||
|
||||
$text = '';
|
||||
$repertuar = json_decode(file_get_contents('https://multikino.pl/pl/repertoire/cinema/seances?id=4&from=' . $date));
|
||||
$text .= "Repertuar Multikino Gdańsk\n";
|
||||
$text .= $date . "\n\n";
|
||||
|
||||
foreach ($repertuar->results as $movie) {
|
||||
$text .= $movie->title . "\n";
|
||||
$text .= $movie->print_version . "\n";
|
||||
|
||||
$hours = [];
|
||||
foreach ($movie->seances as $seans) {
|
||||
$hours[] = date('H:i', strtotime($seans->beginning_date));
|
||||
}
|
||||
$text .= implode(', ', $hours) . "\n\n";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function today_multikino()
|
||||
{
|
||||
$multikino = new Paper\CinemaMultikino();
|
||||
$repertuarText = $multikino->convertToPrint(date('Y-m-d'), 4);
|
||||
$this->main->sendPrint('', $repertuarText);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function tomorrow_multikino()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
$date->modify('+1 day');
|
||||
|
||||
$multikino = new Paper\CinemaMultikino();
|
||||
$repertuarText = $multikino->convertToPrint($date->format('Y-m-d'), 4);
|
||||
$this->main->sendPrint('', $repertuarText);
|
||||
return back();
|
||||
|
||||
|
||||
|
||||
// $repertuarText = $this->multikinoRepertuar($date->format('Y-m-d'));
|
||||
// $this->main->sendPrint('', $repertuarText);
|
||||
// return back();
|
||||
}
|
||||
|
||||
|
||||
public function tomorrow_gdynskiecentrumfilmowe()
|
||||
{
|
||||
$date = new \DateTime();
|
||||
$date->modify('+1 day');
|
||||
|
||||
$repertuarText = $this->gdynskieCentrumFilmowe($date->format('d_m_Y'));
|
||||
$this->main->sendPrint('', $repertuarText);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function today_gdynskiecentrumfilmowe()
|
||||
{
|
||||
$date = date('d_m_Y');
|
||||
$repertuarText = $this->gdynskieCentrumFilmowe($date);
|
||||
$this->main->sendPrint('', $repertuarText);
|
||||
return back();
|
||||
}
|
||||
|
||||
public function today_helios()
|
||||
{
|
||||
$this->main->sendPrint('', $this->helios(0, 2));
|
||||
$this->main->sendPrint('', $this->helios(0, 49));
|
||||
return back();
|
||||
}
|
||||
|
||||
public function tomorrow_helios()
|
||||
{
|
||||
$this->main->sendPrint('', $this->helios(1, 2));
|
||||
$this->main->sendPrint('', $this->helios(1, 49));
|
||||
return back();
|
||||
}
|
||||
|
||||
public function today_repertoire()
|
||||
{
|
||||
|
||||
$this->today_multikino();
|
||||
$this->today_cinemacity();
|
||||
$this->today_helios();
|
||||
$this->today_gdynskiecentrumfilmowe();
|
||||
|
||||
}
|
||||
|
||||
public function tomorrow_repertoire()
|
||||
{
|
||||
|
||||
$this->tomorrow_multikino();
|
||||
$this->tomorrow_cinemacity();
|
||||
$this->tomorrow_helios();
|
||||
$this->tomorrow_gdynskiecentrumfilmowe();
|
||||
}
|
||||
|
||||
private function helios($day, $cinemaId)
|
||||
{
|
||||
$url = 'http://www.helios.pl/2,Gdansk/Repertuar/axRepertoire/?dzien=' . $day . '&kino=' . $cinemaId;
|
||||
|
||||
|
||||
$data = json_decode(file_get_contents($url));
|
||||
$document = new Document();
|
||||
$data->html = str_replace(["\n", "\t"], '', $data->html);
|
||||
$document->loadHtml($data->html);
|
||||
|
||||
|
||||
$cinemas = [2 => 'Helios Alfa', 49 => 'Helios Metropolia'];
|
||||
|
||||
$text = '';
|
||||
$text .= "Repertuar $cinemas[$cinemaId]\n";
|
||||
|
||||
$date = new \DateTime();
|
||||
$date->modify('+' . $day . ' day');
|
||||
|
||||
$text .= $date->format('d-m-Y') . "\n\n";
|
||||
|
||||
|
||||
foreach ($document->find('.seance') as $seans) {
|
||||
$text .= trim($seans->find('.movie-title')[0]->text()) . "\n";
|
||||
$hours = [];
|
||||
foreach ($seans->find('.time li') as $hour) {
|
||||
$hours[] = $hour->text();
|
||||
}
|
||||
$text .= implode(', ', array_unique($hours)) . "\n\n";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
private function gdynskieCentrumFilmowe($date)
|
||||
{
|
||||
|
||||
|
||||
$url = 'http://www.gdynskiecentrumfilmowe.pl/kino_studyjne/repertuar/,' . strtotime($date) . ',_' . $date . '.html';
|
||||
$document = new Document($url, true);
|
||||
$text = '';
|
||||
$text .= "Repertuar Gdyńskie Centrum Filmowe\n";
|
||||
$text .= str_replace('_', '-', $date) . "\n\n";
|
||||
|
||||
$movies = $document->find('.articles .article-item');
|
||||
foreach ($movies as $movie) {
|
||||
|
||||
$text .= $movie->find('.item-title-int')[0]->text() . "\n";
|
||||
$hours = [];
|
||||
foreach ($movie->find('.projection span') as $projection) {
|
||||
$hours[] = $projection->innerHtml();
|
||||
}
|
||||
$text .= implode(', ', array_unique($hours)) . "\n\n";
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user