Issues (2687)

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/Eccube/Repository/PageLayoutRepository.php (1 issue)

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
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\Repository;
26
27
use Doctrine\ORM\EntityRepository;
28
use Doctrine\ORM\Query\Expr;
29
use Eccube\Entity\Master\DeviceType;
30
use Eccube\Entity\PageLayout;
31
use Symfony\Component\Filesystem\Filesystem;
32
use Symfony\Component\Finder\Finder;
33
34
/**
35
 * PageLayoutRepository
36
 *
37
 * This class was generated by the Doctrine ORM. Add your own custom
38
 * repository methods below.
39
 */
40
class PageLayoutRepository extends EntityRepository
41
{
42
    protected $app;
43
44 286
    public function setApplication($app)
45
    {
46 286
        $this->app = $app;
47
    }
48
49 7
    public function findUnusedBlocks(DeviceType $DeviceType, $pageId)
50
    {
51
        $em = $this
52 7
            ->getEntityManager();
53 7
        $blockRepo = $em->getRepository('Eccube\Entity\Block');
54 7
        $ownBlockPositions = $this->get($DeviceType, $pageId)->getBlockPositions();
55 7
        $ids = array();
56 7
        foreach ($ownBlockPositions as $ownBlockPosition) {
57 7
            $ids[] = $ownBlockPosition->getBlock()->getId();
58
        }
59
60
        # $idsが空配列だと、$ids以外のblockを取得するSQLが生成されないため、存在しないidを入れる
0 ignored issues
show
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Loading history...
61 7
        if (empty($ids)) {
62
            $ids[] = \Eccube\Entity\Block::UNUSED_BLOCK_ID;
63
        }
64
65 7
        return $blockRepo->createQueryBuilder('b')
66 7
            ->where('b.id not in (:ids)')
67 7
            ->setParameter(':ids', $ids)
68 7
            ->getQuery()
69 7
            ->getResult();
70
    }
71
72 12
    public function get(DeviceType $DeviceType, $pageId)
73
    {
74 12
        $qb = $this->createQueryBuilder('p')
75 12
            ->select('p, bp, b')
76 12
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
77 12
            ->leftJoin('bp.Block', 'b')
78 12
            ->andWhere('p.DeviceType = :DeviceType AND p.id = :pageId')
79 12
            ->addOrderBy('bp.target_id', 'ASC')
80 12
            ->addOrderBy('bp.block_row', 'ASC');
81
82
        $ownResult = $qb
83 12
            ->getQuery()
84 12
            ->setParameters(array(
85 12
                'DeviceType'  => $DeviceType,
86 12
                'pageId'        => $pageId,
87
            ))
88 12
            ->getSingleResult();
89
90 12
        $qb = $this->createQueryBuilder('p')
91 12
            ->select('p, bp, b')
92 12
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
93 12
            ->leftJoin('bp.Block', 'b')
94 12
            ->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1')
95 12
            ->addOrderBy('bp.target_id', 'ASC')
96 12
            ->addOrderBy('bp.block_row', 'ASC');
97
98
        $anyResults = $qb
99 12
            ->getQuery()
100 12
            ->setParameters(array(
101 12
                'DeviceType' => $DeviceType,
102
            ))
103 12
            ->getResult();
104
105 12
        $OwnBlockPosition = $ownResult->getBlockPositions();
106 12
        foreach ($anyResults as $anyResult) {
107 12
            $BlockPositions = $anyResult->getBlockPositions();
108 12
            foreach ($BlockPositions as $BlockPosition) {
109 12
                if (!$OwnBlockPosition->contains($BlockPosition)) {
110 12
                    $ownResult->addBlockPosition($BlockPosition);
111
                }
112
            }
113
        }
114
115 12
        return $ownResult;
116
117
    }
118
119 261
    public function getByUrl(DeviceType $DeviceType, $url)
120
    {
121 261
        $options = $this->app['config']['doctrine_cache'];
122 261
        $lifetime = $options['result_cache']['lifetime'];
123
124 261
        $qb = $this->createQueryBuilder('p')
125 261
            ->select('p, bp, b')
126 261
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
127 261
            ->leftJoin('bp.Block', 'b')
128 261
            ->andWhere('p.DeviceType = :DeviceType AND p.url = :url')
129 261
            ->addOrderBy('bp.target_id', 'ASC')
130 261
            ->addOrderBy('bp.block_row', 'ASC');
131
132
        $ownResult = $qb
133 261
            ->getQuery()
134 261
            ->useResultCache(true, $lifetime)
135 261
            ->setParameters(array(
136 261
                'DeviceType' => $DeviceType,
137 261
                'url'  => $url,
138
            ))
139 261
            ->getSingleResult();
140
141 116
        $qb = $this->createQueryBuilder('p')
142 116
            ->select('p, bp, b')
143 116
            ->leftJoin('p.BlockPositions', 'bp', 'WITH', 'p.id = bp.page_id')
144 116
            ->leftJoin('bp.Block', 'b')
145 116
            ->andWhere('p.DeviceType = :DeviceType AND bp.anywhere = 1')
146 116
            ->addOrderBy('bp.target_id', 'ASC')
147 116
            ->addOrderBy('bp.block_row', 'ASC');
148
149
        $anyResults = $qb
150 116
            ->getQuery()
151 116
            ->useResultCache(true, $lifetime)
152 116
            ->setParameters(array(
153 116
                'DeviceType' => $DeviceType,
154
            ))
155 116
            ->getResult();
156
157 116
        $OwnBlockPosition = $ownResult->getBlockPositions();
158 116
        foreach ($anyResults as $anyResult) {
159 116
            $BlockPositions = $anyResult->getBlockPositions();
160 116
            foreach ($BlockPositions as $BlockPosition) {
161 116
                if (!$OwnBlockPosition->contains($BlockPosition)) {
162 116
                    $ownResult->addBlockPosition($BlockPosition);
163
                }
164
            }
165
        }
166
167 116
        return $ownResult;
168
    }
169
170 147
    public function newPageLayout(DeviceType $DeviceType)
171
    {
172 147
        $PageLayout = new \Eccube\Entity\PageLayout();
173
        $PageLayout
174 147
            ->setDeviceType($DeviceType)
175 147
            ->setEditFlg(PageLayout::EDIT_FLG_USER);
176
177 147
        return $PageLayout;
178
    }
179
180 6
    public function findOrCreate($page_id, DeviceType $DeviceType)
181
    {
182 6
        if (is_null($page_id)) {
183
            $PageLayout = $this
184 2
                ->newPageLayout($DeviceType);
185 2
            return $PageLayout;
186
        } else {
187 4
            return $this->get($DeviceType, $page_id);
188
        }
189
    }
190
191
    /**
192
     * ページの属性を取得する.
193
     *
194
     * この関数は, dtb_pagelayout の情報を検索する.
195
     * $deviceTypeId は必須. デフォルト値は DEVICE_TYPE_PC.
196
     *
197
     * @access public
198
     * @param  \Eccube\Entity\Master\DeviceType  $DeviceType 端末種別ID
199
     * @param  string                            $where 追加の検索条件
200
     * @param  string[]                          $parameters 追加の検索パラメーター
201
     * @return array                             ページ属性の配列
202
     */
203 3 View Code Duplication
    public function getPageList(DeviceType $DeviceType, $where = null, $parameters = array())
204
    {
205 3
        $qb = $this->createQueryBuilder('l')
206 3
            ->orderBy('l.id', 'DESC')
207 3
            ->where('l.DeviceType = :DeviceType')
208 3
            ->setParameter('DeviceType', $DeviceType)
209 3
            ->andWhere('l.id <> 0')
210 3
            ->orderBy('l.id', 'ASC');
211 3
        if (!is_null($where)) {
212
            $qb->andWhere($where);
213
            foreach ($parameters as $key => $val) {
214
                $qb->setParameter($key, $val);
215
            }
216
        }
217
218
        $PageLayouts = $qb
219 3
            ->getQuery()
220 3
            ->getResult();
221
222 3
        return $PageLayouts;
223
    }
224
225
    /**
226
     * 書き込みパスの取得
227
     * User定義の場合: /html/user_data
228
     * そうでない場合: /app/template/{template_code}
229
     *
230
     * @param  boolean $isUser
231
     * @return string
232
     */
233 8
    public function getWriteTemplatePath($isUser = false)
234
    {
235 8
        return ($isUser) ? $this->app['config']['user_data_realdir'] : $this->app['config']['template_realdir'];
236
    }
237
238
    /**
239
     * 読み込みファイルの取得
240
     *
241
     * 1. template_realdir
242
     *      app/template/{template_code}
243
     * 2. template_default_readldir
244
     *      src/Eccube/Resource/template/default
245
     *
246
     * @param string $fileName
247
     * @param  boolean $isUser
248
     *
249
     * @return array
250
     */
251 6
    public function getReadTemplateFile($fileName, $isUser = false)
252
    {
253 6
        if ($isUser) {
254
            $readPaths = array(
255 1
                $this->app['config']['user_data_realdir'],
256
            );
257
        } else {
258
            $readPaths = array(
259 5
                $this->app['config']['template_realdir'],
260 5
                $this->app['config']['template_default_realdir'],
261
            );
262
        }
263
264 6 View Code Duplication
        foreach ($readPaths as $readPath) {
265 6
            $filePath = $readPath . '/' . $fileName . '.twig';
266 6
            $fs = new Filesystem();
267 6
            if ($fs->exists($filePath)) {
268
                return array(
269 6
                    'file_name' => $fileName,
270 6
                    'tpl_data' => file_get_contents($filePath),
271
                );
272
            }
273
        }
274
    }
275
}
276