retrieve link url from database rather than request url
increases robustness and solve issues with sloppy redirect interpretation across browsers
This commit is contained in:
parent
661813b349
commit
697ed3ce19
|
@ -183,21 +183,15 @@ class UserController extends Controller
|
|||
public function clickNumber(request $request)
|
||||
{
|
||||
$link = $request->link;
|
||||
$query = $request->query();
|
||||
$linkId = $request->id;
|
||||
|
||||
if(empty($link && $linkId))
|
||||
{
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
if(!empty($query)) {
|
||||
$qs = [];
|
||||
foreach($query as $qk => $qv) { $qs[] = $qk .'='. $qv; }
|
||||
$link = $link .'?'. implode('&', $qs);
|
||||
}
|
||||
|
||||
Link::where('id', $linkId)->increment('click_number', 1);
|
||||
$link = Link::select('link')->where('id', $linkId)->get()[0]['link'];
|
||||
|
||||
return redirect()->away($link);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue