最初コミット

This commit is contained in:
守矢諏訪子 2022-02-05 14:05:00 +09:00
commit 6ea53e2c31
787 changed files with 31017 additions and 0 deletions

68
.env.example Normal file
View File

@ -0,0 +1,68 @@
APP_NAME=076Server
APP_ENV=local
APP_KEY=
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=http://localhost
ONION_HOST=jkdasfhfdhndsfnklhjfdsknjfdgsjk.onion
SESSION_SECURE_COOKIE=false
SESSION_HTTP_ONLY=true
THEME="techsuwa"
CSSENGINE="lolita"
CSSMINIFY=true
ENABLE_REGISTER=false
HAS_ADMIN=false
OWNER_NAME=""
OWNER_PASS=""
ADMIN_NAME=""
ADMIN_PASS=""
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=127.0.0.1
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_NOREPLY_USER=null
MAIL_NOREPLY_PASS=null
MAIL_ENCRYPTION=null
MAIL_OWNER_ADDRESS=null
MAIL_OWNER_NAME="${APP_NAME}"
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
GMO_KEY=""
GMO_SECRET=""
CONOHA_DENANT_ID=""
CONOHA_DENANT_NAME=""
CONOHA_USER_NAME=""
CONOHA_USER_PASS=""
YOUTUBE_API=""
LBRY_URI=""
PEER_URI=""
PEER_USER=""
PEER_PASS=""

5
.gitattributes vendored Normal file
View File

@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
/public/storage
/storage/*.key
/vendor
package-lock.json
composer.lock
.env
/storage/app/public/store

79
README.md Normal file
View File

@ -0,0 +1,79 @@
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p>
<p align="center">
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
</p>
## About Laravel
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
- [Simple, fast routing engine](https://laravel.com/docs/routing).
- [Powerful dependency injection container](https://laravel.com/docs/container).
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
- [Robust background job processing](https://laravel.com/docs/queues).
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
Laravel is accessible, powerful, and provides tools required for large, robust applications.
## Learning Laravel
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
## Laravel Sponsors
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
- **[Vehikl](https://vehikl.com/)**
- **[Tighten Co.](https://tighten.co)**
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
- **[64 Robots](https://64robots.com)**
- **[Cubet Techno Labs](https://cubettech.com)**
- **[Cyber-Duck](https://cyber-duck.co.uk)**
- **[Many](https://www.many.co.uk)**
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
- **[DevSquad](https://devsquad.com)**
- [UserInsights](https://userinsights.com)
- [Fragrantica](https://www.fragrantica.com)
- [SOFTonSOFA](https://softonsofa.com/)
- [User10](https://user10.com)
- [Soumettre.fr](https://soumettre.fr/)
- [CodeBrisk](https://codebrisk.com)
- [1Forge](https://1forge.com)
- [TECPRESSO](https://tecpresso.co.jp/)
- [Runtime Converter](http://runtimeconverter.com/)
- [WebL'Agence](https://weblagence.com/)
- [Invoice Ninja](https://www.invoiceninja.com)
- [iMi digital](https://www.imi-digital.de/)
- [Earthlink](https://www.earthlink.ro/)
- [Steadfast Collective](https://steadfastcollective.com/)
- [We Are The Robots Inc.](https://watr.mx/)
- [Understand.io](https://www.understand.io/)
- [Abdel Elrafa](https://abdelelrafa.com)
- [Hyper Host](https://hyper.host)
- [Appoly](https://www.appoly.co.uk)
- [OP.GG](https://op.gg)
- [云软科技](http://www.yunruan.ltd/)
## Contributing
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
## Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
## Security Vulnerabilities
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
## License
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

41
app/Console/Kernel.php Normal file
View File

@ -0,0 +1,41 @@
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController {
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

View File

@ -0,0 +1,111 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
class Engine {
public $user = 0;
public $err = '';
public $warn = '';
public $info = '';
public $suc = '';
public $css = '';
public function __construct () {
$this->err = '';
$this->warn = '';
$this->info = '';
$this->suc = '';
if (isset($_COOKIE['language'])) app()->setLocale($_COOKIE['language']);
$this->id = checkLegit((isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : ''));
$this->user = $this->getLoggedUser((isset($_COOKIE['kero_token']) ? $_COOKIE['kero_token'] : ''));
$this->css = env('CSSENGINE');
if ($this->user && $this->user->profile->gender != 0) $this->css .= '_'.($this->user->profile->gender == 1 ? 'm' : 'f');
if (env('CSSMINIFY')) $this->css .= '.min';
$this->css .= '.css';
}
function getLoggedUser ($kero) {
$check = checkLegit($kero);
if ($check == 0) return 0;
// $cols = getGroupColours();
$get = $this->getUser($check);
return $get;
}
public function getUser ($id) {
$get = DB::table('users')->where('id', $id)->first();
unset($get->password); unset($get->salt); unset($get->remember_token);
$get->profile = DB::table('usr_profile')->where('user_id', $get->id)->first();
$get->profile->showname = (!empty($get->profile->display_name) && !is_null($get->profile->display_name) ? $get->profile->display_name : $get->username);
$perm_id = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $get->id)->first()->perm_id;
$get->perm_module = DB::table('usr_perm_module')->where('usr_perm_id', $perm_id)->first();
$get->details = DB::table('usr_details')->where('user_id', $get->id)->first();
$get->contacts = DB::table('usr_contacts')->where('user_id', $get->id)->first();
$ucol = DB::table('usr_perm_module')->select('id', 'name', 'colour_m', 'colour_f', 'colour_u')->get();
if (!empty($get->profile->name_style)) $get->profile->name_style = $get->profile->name_style;
else {
foreach ($ucol as $j3) {
if ($j3->id == $perm_id) {
if ($get->profile->gender == 1) $get->profile->name_style = $j3->colour_m;
else if ($get->profile->gender == 2) $get->profile->name_style = $j3->colour_f;
else $get->profile->name_style = $j3->colour_u;
}
}
}
if ($get->profile->gender == 1) $get->profile->gender_name = '男性';
else if ($get->profile->gender == 2) $get->profile->gender_name = '女性';
else $get->profile->gender_name = '不明';
$get->perm = $this->getPermissions($get->kero_token);
if (empty($get->profile->avatar) || $get->profile->avatar == '') $get->profile->avatar = 'img/noicon.jpg';
$get->profile->avatar = '/'.$get->profile->avatar;
return $get;
}
public function getPermissionGroup($mdl, $id) { return DB::table($mdl.'_permissions')->where('id', $id)->get(); }
public function getPermissionUser($mdl, $id) { return DB::table($mdl.'_user_permissions')->where('user_id', $id)->get(); }
public function getPermissions ($token) {
$check = checkLegit($token);
$perm = DB::table('usr_perm_id')->select('perm_id')->where('user_id', $check)->first();
$perm = json_decode(json_encode($perm), true);
if ($check != 0) {
$grouppermblg = $this->getPermissionGroup('blg', $perm['perm_id']);
$userpermblg = $this->getPermissionUser('blg', $check);
$grouppermusr = $this->getPermissionGroup('usr', $perm['perm_id']);
$userpermusr = $this->getPermissionUser('usr', $check);
$blgarr = array();
$usrarr = array();
if (!empty($userpermblg[0])) $blgarr = (array)$userpermblg[0];
else $blgarr = (array)$grouppermblg[0];
$blgarr = array_combine(array_map(function($k){ return 'blg_'.$k; }, array_keys($blgarr)), $blgarr);
if (!empty($userpermusr[0])) $usrarr = (array)$userpermusr[0];
else $usrarr = (array)$grouppermusr[0];
$usrarr = array_combine(array_map(function($k){ return 'usr_'.$k; }, array_keys($usrarr)), $usrarr);
return array_merge($blgarr, $usrarr);
}
else {
$grouppermblg = $this->getPermissionGroup('blg', 6);
$grouppermusr = $this->getPermissionGroup('usr', 6);
(array)$grouppermblg[0] = array_combine(array_map(function($k){ return 'blg_'.$k; }, array_keys((array)$grouppermblg[0])), (array)$grouppermblg[0]);
(array)$grouppermusr[0] = array_combine(array_map(function($k){ return 'usr_'.$k; }, array_keys((array)$grouppermusr[0])), (array)$grouppermusr[0]);
return array_merge((array)$grouppermblg[0], (array)$grouppermusr[0]);
}
}
}

View File

@ -0,0 +1,74 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\Log;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
class MailerController extends Controller {
public function __construct() {}
public function compose ($val, $form=false) {
mb_language('japanese');
mb_internal_encoding('UTF-8');
$mail = new PHPMailer(true);
try {
// $mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = config('mail.mailers.smtp.host');
$mail->Port = config('mail.mailers.smtp.port');
$mail->SMTPSecure = config('mail.mailers.smtp.encryption');
$mail->SMTPAuth = true;
$mail->From = config('mail.'.($form ? 'owner' : 'from').'.address');
$mail->FromName = mb_encode_mimeheader(config('mail.mailers.smtp.'.($form ? 'fromname' : 'noreplyfrom')), 'JIS');
$mail->Username = config('mail.mailers.smtp.'.($form ? 'username' : 'noreplyuser'));
$mail->Password = config('mail.mailers.smtp.'.($form ? 'password' : 'noreplypass'));
$mail->AddAddress(config('mail.'.($form ? 'owner' : 'from').'.address'));
if ($form) $mail->addReplyTo(config('mail.owner.address'), config('mail.owner.name'));
else $mail->addReplyTo($val['adr']);
$mail->SMTPOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
];
if (isset($val['attach'])) {
for ($i=0; $i < count($val['attach']); $i++) {
$mail->AddAttachment($val['attach'][$i], $val['attachname'][$i]);
}
}
if (isset($val['gpg'])) {
$mail->AddStringAttachment($val['gpg'], $val['filename']);
$mail->AddStringAttachment($val['bunsyo'], $val['adr'].'.gpg');
}
$mail->isHTML(false);
$mail->Subject = mb_encode_mimeheader('【'.$val['catname'].'】'.$val['kenmei'], 'JIS');
if ($form) $mail->Body = mb_convert_encoding($val['bunsyo'], 'UTF-8');
else $mail->Body = mb_convert_encoding($val['bunsyo'], 'JIS');
if (!$mail->send()) {
Log::critical('Mailer error: ' . $mail->ErrorInfo);
return false;
}
} catch (Exception $e) {
Log::critical($e);
return false;
}
return true;
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class About extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
$res = [
'page' => 'about',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Account extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index ($id, $cat='video-channels') {
$res = [
'page' => 'account',
'style' => 'account',
'cat' => $cat,
'userinfo' => $this->common->user,
];
$res['owner'] = $this->getOwner($id);
if (!empty($res['owner'])) $res['owner']->totalVideo = 0;
$res['channel'] = $this->getChannel($id);
if (!empty($res['owner'])) {
foreach ($res['channel']->data as $k => $v) {
$res['channel']->data[$k]->video = $this->getVideo($v->name.'@'.$v->host);
$res['owner']->totalVideo += $res['channel']->data[$k]->video->total;
}
}
return view('pages.peertube.a', ['res' => $res]);
}
function getOwner ($id) {
return $this->ptapi('/api/v1/accounts/'.$id);
}
function getChannel ($id) {
return $this->ptapi('/api/v1/accounts/'.$id.'/video-channels?start=0&count=20&sort=-updatedAt&withStats=false');
}
function getVideo ($id) {
return $this->ptapi('/api/v1/video-channels/'.$id.'/videos?start=0&count=5&sort=-publishedAt&nsfw=both');
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers\Peertube\Admin;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Users extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
if ($this->common->user['me']->adminFlags != 1) {
return redirect('/peertube/videos/local');
}
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller, Session;
use Illuminate\Http\Request;
trait AuthTrait {
public function getsession () {
if (!Session::has('ptsess')) {
$user = [];
$user['local'] = $this->getLocal();
$user['me'] = $this->getMe($user['local']);
$user['config'] = $this->getConfig();
$user['notify'] = $this->getNotify();
Session::put('ptsess', $user);
$this->user = $user;
}
else {
$this->user = Session::get('ptsess');
}
return $user;
}
}

View File

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Channel extends Common {
private $common;
private $count;
public function __construct () {
$this->common = new Common;
$this->count = 25;
}
public function index ($id, $cat='videos', $page=0) {
$res = [
'page' => 'channel',
'style' => 'channel',
'cat' => $cat,
'paginate' => $page,
'pagetotal' => 500,
'userinfo' => $this->common->user,
];
$res['channel'] = $this->getChannel($id);
$res['video'] = $cat == 'video-playlists' ? $this->getPlaylist($id, ($page*$this->count), $this->count) : $this->getVideo($id, ($page*$this->count), $this->count);
$res['pagetotal'] = $res['video']->total;
return view('pages.peertube.c', ['res' => $res]);
}
function getChannel ($id) {
return $this->ptapi('/api/v1/video-channels/'.$id);
}
function getVideo ($id, $start, $count) {
return $this->ptapi('/api/v1/video-channels/'.$id.'/videos?start='.$start.'&count='.$count.'&sort=-publishedAt&skipCount=false&nsfw=both');
}
function getPlaylist ($id, $start, $count) {
return $this->ptapi('/api/v1/video-channels/'.$id.'/video-playlists?start='.$start.'&count='.$count);
}
}

View File

@ -0,0 +1,119 @@
<?php
namespace App\Http\Controllers\Peertube;
use App\Http\Controllers\Controller, Session;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Engine;
use Illuminate\Support\Facades\Log;
class Common extends Engine {
// use AuthTrait;
public $user = [];
private $engine;
private $access_token;
private $refresh_token;
public function __construct () {
$this->access_token = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : null;
$this->refresh_token = isset($_COOKIE['refresh_token']) ? $_COOKIE['refresh_token'] : null;
if (!Session::has('ptsess')) {
$user = [];
$user['local'] = $this->getLocal();
$user['me'] = $this->getMe($user['local']);
$user['config'] = $this->getConfig();
$user['notify'] = $this->getNotify();
Session::put('ptsess', $user);
$this->user = $user;
}
else {
$this->user = Session::get('ptsess');
}
$this->engine = new Engine;
}
public function getLocal () {
return $this->ptapi('/api/v1/oauth-clients/local');
}
public function getMe ($param) {
if (!isset($_COOKIE['access_token']) && isset($_COOKIE['refresh_token'])) {
$r = new Request;
$login = new \App\Http\Controllers\Peertube\Login;
$r->client_id = $param->client_id;
$r->client_secret = $param->client_secret;
$r->refresh_token = $this->refresh_token;
$this->login($r);
$this->access_token = $_COOKIE['access_token'];
$this->refresh_token = $_COOKIE['refresh_token'];
}
if (isset($_COOKIE['access_token']) && isset($_COOKIE['refresh_token'])) return $this->ptapi('/api/v1/users/me');
return null;
}
public function getConfig () {
return $this->ptapi('/api/v1/config/');
}
public function getNotify () {
if (isset($_COOKIE['access_token']) && isset($_COOKIE['refresh_token'])) return $this->ptapi('/api/v1/users/me/notifications?start=0&count=0&unread=true');
return null;
}
public function ptapi ($url, $param='', $method='get', $contenttype='json') {
set_time_limit(0);
$this->access_token = isset($_COOKIE['access_token']) ? $_COOKIE['access_token'] : null;
$this->refresh_token = isset($_COOKIE['refresh_token']) ? $_COOKIE['refresh_token'] : null;
$header = ['Content-Type: application/'.$contenttype, 'Host: '.str_replace('https://', '', env('PEER_URI'))];
if (!is_null($this->access_token)) {
$header[] = 'Authorization: Bearer '.$this->access_token;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, env('PEER_URI').$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ($method == 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
if ($param != '') curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$get = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if (!$get) return $err;
$get = json_decode($get);
if (isset($get->status) && $get->status == 404) return [];
return $get;
}
public function vidlist ($get) {
$res = [
'today' => [],
'week' => [],
'month' => [],
'lastmonth' => [],
'moreearly' => [],
];
foreach ($get->data as $g) {
$ud = strtotime($g->createdAt);
if ($ud > time() - 86400 && $ud < time() + 86400) $res['today'][] = $g;
else if ($ud > time() - 604800 && $ud < time() + 604800) $res['week'][] = $g;
else if ($ud > time() - 2629800 && $ud < time() + 2629800) $res['month'][] = $g;
else if ($ud > time() - 5259600 && $ud < time() + 5259600) $res['lastmonth'][] = $g;
else $res['moreearly'][] = $g;
}
return $res;
}
}

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Home extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
$res = [
'page' => 'home',
'style' => 'videoslist',
'userinfo' => $this->common->user,
];
$res['new'] = $this->getNewest();
$res['hot'] = $this->getPopularest();
return view('pages.peertube.home', ['res' => $res]);
}
function getNewest () {
return $this->ptapi('/api/v1/videos?start=0&count=8&sort=-publishedAt&skipCount=true&isLocal=true&nsfw=both');
}
function getPopularest () {
return $this->ptapi('/api/v1/videos?start=0&count=8&sort=-trending&skipCount=true&isLocal=true&nsfw=both');
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Login extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index ($err=null) {
if (isset($this->common->user['me']) && !is_null($this->common->user['me'])) {
return redirect('/peertube/home');
}
$res = [
'page' => 'login',
'style' => 'login',
'userinfo' => $this->common->user,
'err' => $err
];
return view('pages.peertube.login', ['res' => $res]);
}
public function login (Request $r) {
if (isset($this->common->user['me']) && !is_null($this->common->user['me'])) {
return redirect('/peertube/videos/local');
}
$param = [
'client_id' => $this->common->user['local']->client_id,
'client_secret' => $this->common->user['local']->client_secret,
'grant_type' => 'password',
];
if (isset($r->username) && isset($r->password)) {
$param['username'] = $r->username;
$param['password'] = $r->password;
}
else if (isset($r->refresh_token)) {
$param['refresh_token'] = $r->refresh_token;
}
$res = $this->ptapi('/api/v1/users/token', http_build_query($param), 'post', 'x-www-form-urlencoded');
$err = null;
if (isset($res->access_token) && isset($res->refresh_token)) {
setcookie('access_token', $res->access_token, time()+(int)$res->expires_in, '/', $_SERVER['HTTP_HOST'], 0, 1); // 24時間
setcookie('refresh_token', $res->refresh_token, time()+(int)$res->refresh_token_expires_in, '/', $_SERVER['HTTP_HOST'], 0, 1); // 14日間
return redirect('/peertube/videos/local');
}
return $this->index(isset($res->error) ? $res->error : '不正なエラー');
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Logout extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function logout () {
$this->ptapi('/api/v1/users/revoke-token', '', 'post');
unset($_COOKIE['access_token']);
unset($_COOKIE['refresh_token']);
setcookie('access_token', '', time() - 3600, '/', $_SERVER['HTTP_HOST'], 0, 1);
setcookie('refresh_token', '', time() - 3600, '/', $_SERVER['HTTP_HOST'], 0, 1);
return redirect('/peertube/home');
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Myaccount extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Controllers\Peertube\Myaccount;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Abuses extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
if ($this->common->user['me']->adminFlags != 1) {
return redirect('/peertube/videos/local');
}
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions?start=0&count=10
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Myaccount;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Applications extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions?start=0&count=10
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Myaccount\Blocklist;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Accounts extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions?start=0&count=10
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Myaccount\Blocklist;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Servers extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions?start=0&count=10
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace App\Http\Controllers\Peertube\Myaccount;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Notification extends Common {
private $common;
private $count;
public function __construct () {
$this->common = new Common;
$this->count = 20;
}
public function index ($page=0) {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'notification',
'style' => 'myaccount',
'paginate' => $page,
'pagetotal' => 500,
'userinfo' => $this->common->user,
];
$res['notification'] = $this->getNotification(($page*$this->count), $this->count);
return view('pages.peertube.my-account.notifications', ['res' => $res]);
}
function getNotification ($start, $count) {
return $this->ptapi('/api/v1/users/me/notifications?start='.$start.'&count='.$count.'&sort=-createdAt');
}
public function read (Request $r) {
$this->ptapi('/api/v1/users/me/notifications/read', json_encode(['ids' => [(int)$r->id]]), 'post');
return redirect('/peertube/my-account/notifications');
}
public function readAll () {
$this->ptapi('/api/v1/users/me/notifications/read-all', '', 'post');
return redirect('/peertube/my-account/notifications');
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Myaccount;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Settings extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions?start=0&count=10
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Mylibrary extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Mylibrary\History;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Videos extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/history/videos?start=0&count=5
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Mylibrary;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Subscriptions extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions?start=0&count=10
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Mylibrary;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Videochannels extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/accounts/techsuwako/video-channels?start=0&count=20&sort=-updatedAt&withStats=true
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Mylibrary;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Videoplaylists extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/subscriptions/videos?start=0&count=25&sort=-publishedAt&skipCount=true
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Mylibrary;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Videos extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) {
return redirect('/peertube/login');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
//https://video.076.ne.jp/api/v1/users/me/videos?start=0&count=10&sort=-publishedAt
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Controllers\Peertube;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Signup extends Common {
private $common;
public function __construct () {
$this->common = new Common;
}
public function index () {
if (isset($this->common->user['me']) && !is_null($this->common->user['me'])) {
return redirect('/peertube/videos/local');
}
$res = [
'page' => 'dummy',
'style' => 'dummy',
'userinfo' => $this->common->user,
];
// $res['owner'] = $this->getOwner($id);
return view('pages.peertube.notyet', ['res' => $res]);
}
function getOwner ($id) {
return $this->ptapi('/api/v1/accounts/'.$id);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Http\Controllers\Peertube\Videos;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Peertube\Common;
// use Illuminate\Support\Facades\Log;
class Local extends Common {
private $common;
private $count;
public function __construct () {
$this->common = new Common;
$this->count = 50;
}
public function index ($page=0) {
$res = [
'page' => 'local',
'style' => 'videoslist',
'paginate' => $page,
'pagetotal' => 500,
'userinfo' => $this->common->user,
];
$res['video'] = $this