Issues (20)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/controllers/AdController.php (2 issues)

Upgrade to new PHP Analysis Engine

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 zacksleo\yii2\ad\controllers;
4
5
use Yii;
6
use zacksleo\yii2\ad\models\Ad;
7
use yii\data\ActiveDataProvider;
8
use yii\web\Controller;
9
use yii\web\NotFoundHttpException;
10
use yii\filters\VerbFilter;
11
use zacksleo\yii2\ad\models\AdPosition;
12
13
/**
14
 * AdController implements the CRUD actions for Ad model.
15
 */
16
class AdController extends Controller
17
{
18
    /**
19
     * @inheritdoc
20
     */
21
    public function behaviors()
22
    {
23
        return [
24
            'verbs' => [
25
                'class' => VerbFilter::className(),
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
26
                'actions' => [
27
                    'delete' => ['POST'],
28
                ],
29
            ],
30
        ];
31
    }
32
33
    /**
34
     * Lists all Ad models.
35
     * @return mixed
36
     */
37
    public function actionIndex()
38
    {
39
        $slug = Yii::$app->request->get('slug');
40
        $query = Ad::find()->orderBy('order');
41
        $this->view->title = '广告列表: ';
42
        if (!empty($slug) && ($position = AdPosition::findOne(['slug' => $slug])) != null) {
43
            $query = $query->andWhere(['position_id' => $position->id]);
44
            $this->view->title .= $position->name;
45
        }
46
        $dataProvider = new ActiveDataProvider([
47
            'query' => $query
48
        ]);
49
50
        return $this->render('index', [
51
            'dataProvider' => $dataProvider,
52
        ]);
53
    }
54
55
    /**
56
     * Displays a single Ad model.
57
     * @param integer $id
58
     * @return mixed
59
     */
60
    public function actionView($id)
61
    {
62
        return $this->render('view', [
63
            'model' => $this->findModel($id),
64
        ]);
65
    }
66
67
    /**
68
     * Creates a new Ad model.
69
     * If creation is successful, the browser will be redirected to the 'view' page.
70
     * @return mixed
71
     */
72
    public function actionCreate()
73
    {
74
        $model = new Ad();
75
        $slug = Yii::$app->request->get('slug');
76
        if (!empty($slug) && ($position = AdPosition::findOne(['slug' => $slug])) != null) {
77
            $model->position_id = $position->id;
78
        }
79
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
80
            return $this->redirect(['view', 'id' => $model->id]);
81
        } else {
82
            return $this->render('create', [
83
                'model' => $model,
84
            ]);
85
        }
86
    }
87
88
    /**
89
     * Updates an existing Ad model.
90
     * If update is successful, the browser will be redirected to the 'view' page.
91
     * @param integer $id
92
     * @return mixed
93
     */
94
    public function actionUpdate($id)
95
    {
96
        $model = $this->findModel($id);
97
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
98
            return $this->redirect(['view', 'id' => $model->id]);
99
        } else {
100
            return $this->render('update', [
101
                'model' => $model,
102
            ]);
103
        }
104
    }
105
106
    /**
107
     * Deletes an existing Ad model.
108
     * If deletion is successful, the browser will be redirected to the 'index' page.
109
     * @param integer $id
110
     * @return mixed
111
     */
112
    public function actionDelete($id)
113
    {
114
        $this->findModel($id)->delete();
115
116
        return $this->redirect(['index']);
117
    }
118
119
    /**
120
     * Finds the Ad model based on its primary key value.
121
     * If the model is not found, a 404 HTTP exception will be thrown.
122
     * @param integer $id
123
     * @return Ad the loaded model
124
     * @throws NotFoundHttpException if the model cannot be found
125
     */
126
    protected function findModel($id)
127
    {
128
        if (($model = Ad::findOne($id)) !== null) {
0 ignored issues
show
Bug Compatibility introduced by
The expression \zacksleo\yii2\ad\models\Ad::findOne($id); of type yii\db\ActiveRecordInterface|array|null adds the type array to the return on line 131 which is incompatible with the return type documented by zacksleo\yii2\ad\control...AdController::findModel of type zacksleo\yii2\ad\models\Ad.
Loading history...
129
            $model->available_from = date('Y-m-d H:i', $model->available_from);
130
            $model->available_to = date('Y-m-d H:i', $model->available_to);
131
            return $model;
132
        } else {
133
            throw new NotFoundHttpException('The requested page does not exist.');
134
        }
135
    }
136
}
137