Merge branch 'master' of https://github.com/NEUP-Net-Depart/NEUP-FleaMarket
This commit is contained in:
@@ -29,6 +29,9 @@ MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
MAIL_RPC_HOST=127.0.0.1
|
||||
MAIL_RPC_PORT=65525
|
||||
|
||||
ALLOW_REG=false
|
||||
# 大一同学的入学年份(两位),用来判断用户是否过期
|
||||
FRESH_YEAR=16
|
||||
|
||||
@@ -11,7 +11,7 @@ use App\User;
|
||||
use App\Announcement;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Ticket;
|
||||
|
||||
use JsonRpcClient;
|
||||
use App\Transaction;
|
||||
use Mews\Purifier\Purifier;
|
||||
|
||||
@@ -174,6 +174,20 @@ class AdminController extends Controller
|
||||
return Redirect::to('/admin');
|
||||
}
|
||||
|
||||
// This part gonna work with https://github.com/NEUP-Net-Depart/email-daemon/
|
||||
public function testEmail(Request $request)
|
||||
{
|
||||
$conn = new JsonRpcClient("127.0.0.1", 65525);
|
||||
$mailSettings = [];
|
||||
$mailSettings["Body"] = view('auth.checkLetter')->with(['host' => $request->server("HTTP_HOST"), 'token' => "sometesttokenhhhh"])->render();
|
||||
$mailSettings["To"] = "wangkule@cool2645.com";
|
||||
$mailSettings["FromName"] = "先锋市场";
|
||||
$mailSettings["Subject"] = "PHP 邮件测试";
|
||||
$mailSettings["SendID"] = "notify";
|
||||
$response = $conn->Call("Daemon.SendMail", $mailSettings);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function AdminController@getAnnouncement
|
||||
* @input Request $request
|
||||
|
||||
@@ -16,7 +16,7 @@ use App\Http\Requests\ResetPassRequest;
|
||||
use App\User;
|
||||
use App\CheckEmail;
|
||||
use App\PasswordReset;
|
||||
use Mail;
|
||||
use JsonRpcClient;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\AuthLog;
|
||||
use phpCAS;
|
||||
@@ -259,11 +259,16 @@ class AuthController extends Controller
|
||||
$time = time();
|
||||
$data['token'] = base64_encode($token . "#" . $time . "#" . $email . "#" . substr(sha1($time . $email . env('APP_KEY')), 0, 6));
|
||||
$data['host'] = $request->server("HTTP_HOST");
|
||||
if (env('APP_ENV') != "testing")
|
||||
Mail::send('auth.checkLetter', $data, function ($m) use ($user, $email) {
|
||||
$m->from(env('MAIL_USERNAME'), "先锋市场");
|
||||
$m->to($email, $user->username)->subject('验证你的邮箱');
|
||||
});
|
||||
if (env('APP_ENV') != "testing") {
|
||||
$conn = new JsonRpcClient(env('MAIL_RPC_HOST', "127.0.0.1"), env('MAIL_RPC_PORT', 65525));
|
||||
$mailSettings = [];
|
||||
$mailSettings["Body"] = view('auth.checkLetter')->with($data)->render();
|
||||
$mailSettings["To"] = $email;
|
||||
$mailSettings["FromName"] = "先锋市场";
|
||||
$mailSettings["Subject"] = "验证你的邮箱";
|
||||
$mailSettings["SendID"] = "service";
|
||||
$conn->Call("Daemon.SendMail", $mailSettings);
|
||||
}
|
||||
|
||||
self::log($user->id, "sendcheckletter", $request);
|
||||
}
|
||||
@@ -295,11 +300,16 @@ class AuthController extends Controller
|
||||
$time = time();
|
||||
$data['token'] = base64_encode($token . "#" . $time . "#" . $email . "#" . substr(sha1($time . $email . env('APP_KEY')), 0, 6));
|
||||
$data['host'] = $request->server("HTTP_HOST");
|
||||
if (env('APP_ENV') != "testing")
|
||||
Mail::send('auth.unbindLetter', $data, function ($m) use ($user, $email) {
|
||||
$m->from(env('MAIL_USERNAME'), "先锋市场");
|
||||
$m->to($email, $user->username)->subject('邮箱解绑请求');
|
||||
});
|
||||
if (env('APP_ENV') != "testing") {
|
||||
$conn = new JsonRpcClient(env('MAIL_RPC_HOST', "127.0.0.1"), env('MAIL_RPC_PORT', 65525));
|
||||
$mailSettings = [];
|
||||
$mailSettings["Body"] = view('auth.unbindLetter')->with($data)->render();
|
||||
$mailSettings["To"] = $email;
|
||||
$mailSettings["FromName"] = "先锋市场";
|
||||
$mailSettings["Subject"] = "邮箱解绑请求";
|
||||
$mailSettings["SendID"] = "service";
|
||||
$conn->Call("Daemon.SendMail", $mailSettings);
|
||||
}
|
||||
|
||||
self::log($user->id, "sendunbindletter", $request);
|
||||
}
|
||||
@@ -442,11 +452,16 @@ class AuthController extends Controller
|
||||
$time = time();
|
||||
$data['token'] = base64_encode($token . "#" . $time . "#" . substr(sha1($time . env('APP_KEY')), 0, 6));
|
||||
$data['host'] = $request->server("HTTP_HOST");
|
||||
if (env('APP_ENV') != "testing")
|
||||
Mail::send('auth.resetLetter', $data, function ($m) use ($user, $email) {
|
||||
$m->from(env('MAIL_USERNAME'), '先锋市场');
|
||||
$m->to($email, $user->username)->subject('重置密码');
|
||||
});
|
||||
if (env('APP_ENV') != "testing") {
|
||||
$conn = new JsonRpcClient(env('MAIL_RPC_HOST', "127.0.0.1"), env('MAIL_RPC_PORT', 65525));
|
||||
$mailSettings = [];
|
||||
$mailSettings["Body"] = view('auth.resetLetter')->with($data)->render();
|
||||
$mailSettings["To"] = $email;
|
||||
$mailSettings["FromName"] = "先锋市场";
|
||||
$mailSettings["Subject"] = "重置密码";
|
||||
$mailSettings["SendID"] = "service";
|
||||
$conn->Call("Daemon.SendMail", $mailSettings);
|
||||
}
|
||||
|
||||
$this->log($user->id, "sendpwdresetletter", $request);
|
||||
|
||||
|
||||
@@ -127,18 +127,6 @@ class GoodController extends Controller
|
||||
return view::make('good.goodList')->with($data);
|
||||
}
|
||||
|
||||
public function check(Request $request)
|
||||
{
|
||||
$data = [];
|
||||
$user_id = $request->session()->get('user_id');
|
||||
$data['goods'] = Transaction::where('seller_id',$user_id)->where('status',1)->get();
|
||||
$data['sells'] = Transaction::where('seller_id',$user_id)->where('status',2)->get();
|
||||
$data['mysells'] = Transaction::where('seller_id',$user_id)->where('status',4)->get();
|
||||
$data['users'] = Transaction::where('buyer_id',$user_id)->where('status',3)->get();
|
||||
$data['transactions'] = Transaction::where('buyer_id',$user_id)->where('status',2)->get();
|
||||
return view::make('good.goodCheck')->with($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function GoodController@getInfo
|
||||
* @input Request $request, $good_id
|
||||
|
||||
@@ -18,6 +18,7 @@ use App\Message;
|
||||
use App\User;
|
||||
use App\MessageContact;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Mews\Purifier\PurifierServiceProvider;
|
||||
|
||||
class MessageController extends Controller
|
||||
{
|
||||
@@ -83,7 +84,7 @@ class MessageController extends Controller
|
||||
//Create Message
|
||||
$message = new Message;
|
||||
$user_id = $sender;
|
||||
$message->content = $content;
|
||||
$message->content = clean($content);
|
||||
$message->sender_id = $user_id;
|
||||
$message->receiver_id = $receiver;
|
||||
$message->save();
|
||||
|
||||
@@ -142,6 +142,7 @@ Route::group(['middleware' => ['web']],function () {
|
||||
Route::delete('/notice/{ann_id}', "AdminController@delAnnouncement")->middleware('admin');
|
||||
|
||||
Route::get('/admin', "AdminController@adminIndex")->middleware('admin');
|
||||
Route::get('/test/email', "AdminController@testEmail")->middleware('su');
|
||||
|
||||
Route::post('/user/{user_id}/updatePriv', [
|
||||
"uses" => "AdminController@updateUserPriv",
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
// Copyright 2013 Leonardo Bartoli <leonardo.bartoli@gmail.com>.
|
||||
// All rights reserved.
|
||||
// This program comes with ABSOLUTELY NO WARRANTY;
|
||||
// Use of this source code is governed by a free software license,
|
||||
// for details visit http://www.gnu.org/licenses/lgpl.html
|
||||
|
||||
/*
|
||||
Simple PHP JsonRPC client through raw tcp connection.
|
||||
Socket connections follow lazy open pattern and are closed
|
||||
during object destruction.
|
||||
*/
|
||||
class JsonRpcException extends Exception {}
|
||||
|
||||
class JsonRpcClient {
|
||||
private $address;
|
||||
private $port;
|
||||
private $socket;
|
||||
|
||||
public function __construct($address, $port) {
|
||||
$this->address = $address;
|
||||
$this->port = $port;
|
||||
$this->socket = false;
|
||||
}
|
||||
|
||||
public function __desctructor() {
|
||||
if ($this->socket) {
|
||||
socket_close($this->socket);
|
||||
}
|
||||
}
|
||||
|
||||
public function __open() {
|
||||
if (($this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
|
||||
throw new JsonRpcException("socket_create() failed: reason: " . socket_strerror(socket_last_error()));
|
||||
}
|
||||
}
|
||||
|
||||
private function generateId() {
|
||||
$chars = array_merge(range('A', 'Z'), range('a', 'z'), range(0, 9));
|
||||
$id = '';
|
||||
for($c = 0; $c < 16; ++$c)
|
||||
$id .= $chars[mt_rand(0, count($chars) - 1)];
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function Call($name, $arguments=null) {
|
||||
$id = $this->generateId();
|
||||
|
||||
$request = array(
|
||||
'jsonrpc' => '2.0',
|
||||
'method' => $name,
|
||||
'params' => array($arguments),
|
||||
'id' => $id
|
||||
);
|
||||
|
||||
$jsonRequest = json_encode($request);
|
||||
|
||||
//echo $jsonRequest . PHP_EOL;
|
||||
$this->__open();
|
||||
|
||||
socket_bind($this->socket, $this->address);
|
||||
if (!socket_connect($this->socket, $this->address, $this->port)) {
|
||||
throw new JsonRpcException('unable to open socket', -32603);
|
||||
}
|
||||
|
||||
socket_write($this->socket, $jsonRequest);
|
||||
$jsonResponse = socket_read($this->socket, 4096);
|
||||
|
||||
if ($jsonResponse === false) {
|
||||
throw new JsonRpcException('file_get_contents failed', -32603);
|
||||
}
|
||||
|
||||
$response = json_decode($jsonResponse);
|
||||
if ($response === null) {
|
||||
throw new JsonRpcException('JSON cannot be decoded', -32603);
|
||||
}
|
||||
|
||||
if ($response->id != $id) {
|
||||
throw new JsonRPCException('Mismatched JSON-RPC IDs', -32603);
|
||||
}
|
||||
|
||||
if ($response->error) {
|
||||
throw new JsonRpcException($response->error);
|
||||
}
|
||||
|
||||
if (property_exists($response, 'result')) {
|
||||
return $response->result;
|
||||
} else {
|
||||
throw new JsonRpcException('Invalid JSON-RPC response', -32603);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+2
-1
@@ -23,7 +23,8 @@
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"database"
|
||||
"database",
|
||||
"app/JsonRpcClient.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
return [
|
||||
|
||||
'version' => '0.8',
|
||||
'version' => '0.9',
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ return [
|
||||
'HTML.Doctype' => 'HTML 4.01 Transitional',
|
||||
'HTML.Allowed' => 'div,b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
|
||||
'CSS.AllowedProperties' => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
|
||||
'AutoFormat.AutoParagraph' => true,
|
||||
'AutoFormat.AutoParagraph' => false,
|
||||
'AutoFormat.RemoveEmpty' => true,
|
||||
],
|
||||
'test' => [
|
||||
|
||||
Vendored
+7
-2
@@ -57,8 +57,7 @@
|
||||
height: 2em;
|
||||
padding-top: 0.2em;
|
||||
position: absolute;
|
||||
top: 0.3em;
|
||||
left: 5em;
|
||||
left: 0em;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
@@ -95,6 +94,12 @@
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.center-block {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.err-msg {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
@@ -299,6 +299,7 @@ var Message = new Vue({
|
||||
},
|
||||
methods: {
|
||||
startLoop: function () {
|
||||
$("#vue-error-msg").remove();
|
||||
var vm = this;
|
||||
vm.loadContact();
|
||||
vm.timer = window.setInterval(function() {
|
||||
@@ -104,8 +104,9 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="#repo{{$repo->id}}" data-toggle="modal">{{ $repo->id }}</a></td>
|
||||
<td><a href="#repo{{$repo->id}}" data-toggle="modal">{{ $repo->sender_id }}</a></td>
|
||||
<td><a href="#repo{{$repo->id}}" data-toggle="modal">{{ $repo->receiver_id }}</a></td>
|
||||
<td><a href="/user/{{ $repo->sender_id }}">{{ $repo->sender_id }}</a></td>
|
||||
<td><a href="/user/{{ $repo->receiver_id }}">{{ $repo->receiver_id }}</a></td>
|
||||
<td><a class="btn btn-primary" href="#repo{{$repo->id}}" data-toggle="modal">查看</a></td>
|
||||
<div class="modal fade" id="repo{{$repo->id}}" tabindex="-1" role="dialog" aria-labelledby="repo{{$repo->id}}Label">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
|
||||
@@ -4,8 +4,18 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
<div id="message">
|
||||
{{--<a v-on:click="refreshContact">???</a>--}}
|
||||
<div id="vue-error-msg" class="container hide">
|
||||
<div class="row col-xl-12 alert alert-danger" role="alert">
|
||||
<span class="fa fa-exclamation-circle" aria-hidden="true"></span>
|
||||
<p>
|
||||
如果您看到了这条消息,说明您使用的浏览器不兼容消息页面。建议您更换<strong>最新版Chrome浏览器</strong>
|
||||
以获得最佳浏览体验,给您带来的不便敬请谅解。
|
||||
</p>
|
||||
<img src="/img/sorry.png" class="img-responsive center-block"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="message" class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-8 col-12">
|
||||
<message-dialog ref="messageDialog" v-on:top-contact="topContactCallback" v-on:network-error="stopTimerCallback"></message-dialog>
|
||||
@@ -59,15 +69,13 @@
|
||||
<p v-if="messages.length == 0" style="text-align: center">暂无消息</p>
|
||||
<div :class="{ hide: isHidden }">
|
||||
<a href="javascript:void(0)" v-if="hasMore" v-on:click="getHistoryMessage(-1)">加载更多</a>
|
||||
<p v-else>没有更多了</p>
|
||||
<ul id="message-container" class="message-container">
|
||||
<transition-group name="message-list" tag="ul">
|
||||
<li :class="{ box: message.type !== 'history-info' }" class="msg message-list-item"
|
||||
v-for="message in messages" v-bind:key="message.id">
|
||||
<span v-if="message.type !== 'history-info'">
|
||||
<img class="mavatar" :src="'/avatar/' + message.sender_id + '/64/64'"/>
|
||||
<p v-if="contact_id == 0" class="message-content" v-html="message.content"></p>
|
||||
<p v-else class="message-content">@{{ message.content }}</p>
|
||||
<p class="message-content" v-html="message.content"></p>
|
||||
<br/><br/>
|
||||
<i class="time-tag">@{{ message.created_at }}</i>
|
||||
</span>
|
||||
@@ -87,9 +95,14 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script src="https://unpkg.com/vue@2.3.4/dist/vue.js"></script>
|
||||
<script src="https://unpkg.com/vue@2.3.4/dist/vue.min.js"></script>
|
||||
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
|
||||
<script src="/js/message.js"></script>
|
||||
<script src="/js/message-20170622.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
setTimeout("$('#vue-error-msg').removeClass('hide')", 3000);
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="/css/message.css">
|
||||
|
||||
@endsection
|
||||
Reference in New Issue
Block a user