This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace App\Http\Controllers; |
||
4 | |||
5 | use App\Http\Models\Actors; |
||
6 | use App\Http\Models\Comments; |
||
7 | use App\Http\Models\Movies; |
||
8 | use App\Http\Models\Sessions; |
||
9 | use App\Http\Models\User; |
||
10 | use Illuminate\Http\Request; |
||
11 | use Illuminate\Support\Facades\Validator; |
||
12 | use Netshell\Paypal\Facades\Paypal; |
||
13 | |||
14 | /** |
||
15 | * Class MainController. |
||
16 | */ |
||
17 | class MainController extends Controller |
||
18 | { |
||
19 | /** |
||
20 | * Fo Page. |
||
21 | * |
||
22 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
23 | */ |
||
24 | public function index() |
||
25 | { |
||
26 | return view('Main/index'); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Ajax Movies. |
||
31 | * |
||
32 | * @param Request $request |
||
33 | * |
||
34 | * @return mixed |
||
35 | */ |
||
36 | public function ajaxmovies(Request $request) |
||
37 | { |
||
38 | $validator = Validator::make( |
||
39 | $request->all(), //request all : tous les elements de requetses |
||
40 | [ |
||
41 | 'title' => 'required|min:10', |
||
42 | ], [ |
||
43 | 'title.required' => 'Votre titre est obligatoire', |
||
44 | 'title.min' => 'Votre titre est trop court', |
||
45 | ]); |
||
46 | |||
47 | if ($validator->fails()) { // si mon validateur échoue |
||
48 | return $validator->errors()->all(); |
||
49 | } else { |
||
50 | Movies::create([ |
||
51 | 'title' => $request->title, |
||
52 | 'description' => $request->description, |
||
53 | 'categories_id' => $request->categories_id, |
||
54 | ]); |
||
55 | |||
56 | return $request->title; |
||
57 | } |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Done Payment. |
||
62 | * |
||
63 | * @param Request $request |
||
64 | * |
||
65 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
66 | */ |
||
67 | View Code Duplication | public function done(Request $request) |
|
0 ignored issues
–
show
|
|||
68 | { |
||
69 | $id = $request->get('paymentId'); |
||
70 | $payer_id = $request->get('PayerID'); |
||
71 | |||
72 | $payment = PayPal::getById($id, $this->_apiContext); |
||
0 ignored issues
–
show
The property
_apiContext does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
73 | |||
74 | $paymentExecution = PayPal::PaymentExecution(); |
||
75 | |||
76 | $paymentExecution->setPayerId($payer_id); |
||
77 | $executePayment = $payment->execute($paymentExecution, $this->_apiContext); |
||
0 ignored issues
–
show
$executePayment is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
78 | |||
79 | // Clear the shopping cart, write to database, send notifications, etc. |
||
80 | $request->session()->pull('likes', []); |
||
0 ignored issues
–
show
array() is of type array , but the function expects a string|null .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
81 | |||
82 | return view('Main/index'); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Page Dashboard. |
||
87 | */ |
||
88 | public function dashboard() |
||
89 | { |
||
90 | $nbacteurs = Actors::count(); |
||
91 | $nbcommentaires = Comments::count(); |
||
92 | $nbmovies = Movies::count(); |
||
93 | $nbseances = Sessions::count(); |
||
94 | |||
95 | $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017'); |
||
96 | $collection = new \MongoDB\Collection($manager, 'laravel', 'videos'); |
||
97 | $videos = collect($collection->find()->toArray())->shuffle(); |
||
98 | |||
99 | $collection = new \MongoDB\Collection($manager, 'laravel', 'stats'); |
||
100 | $youtubeinfo = collect($collection->find(['origin' => 'Youtube'])->toArray())->first(); |
||
101 | |||
102 | $collection = new \MongoDB\Collection($manager, 'laravel', 'stats'); |
||
103 | $tweeterinfo = collect($collection->find(['origin' => 'Twitter', 'type' => 'infos'])->toArray())->first(); |
||
104 | |||
105 | $actor = new Actors(); // Je récpere mon modèle |
||
106 | $comment = new Comments(); // Je récpere mon modèle |
||
107 | $movie = new Movies(); // Je récpere mon modèle |
||
108 | $session = new Sessions(); // Je récpere mon modèle |
||
109 | $user = new User(); // Je récpere mon modèle |
||
110 | |||
111 | $avgacteurs = $actor->getAvgActors(); |
||
112 | $avgnotecommentaire = $comment->getAvgNote(); |
||
113 | $avgnotepresse = $movie->getAvgNotePresse(); |
||
114 | $avghour = $session->getAvgHourDate(); |
||
115 | |||
116 | $seances = $session->getNextSession(); |
||
117 | $users = $user->getLastUsers(); |
||
118 | |||
119 | return view('Main/dashboard', [ |
||
120 | 'avgnotecommentaire' => $avgnotecommentaire->avgnote, |
||
121 | 'avgnotepresse' => $avgnotepresse->avgpress, |
||
122 | 'avgacteurs' => $avgacteurs->age, |
||
123 | 'videos' => $videos, |
||
124 | 'video' => $videos[0], |
||
125 | 'youtubeinfo' => $youtubeinfo->data, |
||
126 | 'tweeterinfo' => $tweeterinfo['data'][0], |
||
127 | 'youtubeinfodateupdated' => $youtubeinfo->created, |
||
128 | 'tweeterinfodateupdated' => $tweeterinfo['created_at'], |
||
129 | 'avghour' => $avghour->avghour, |
||
130 | 'nbacteurs' => $nbacteurs, |
||
131 | 'nbcommentaires' => $nbcommentaires, |
||
132 | 'nbmovies' => $nbmovies, |
||
133 | 'nbseances' => $nbseances, |
||
134 | 'seances' => $seances, |
||
135 | 'users' => $users, |
||
136 | ]); |
||
137 | } |
||
138 | } |
||
139 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.