Issues (15)

Security Analysis    no request data  

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.

inc/media.php (4 issues)

Severity

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
 *
4
 * @package podium
5
 */
6
7
// Custom filter function to modify default gallery shortcode output
8
function podium_post_gallery($output, $attr)
0 ignored issues
show
The parameter $output is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
9
{
10
11
    // Initialize
12
    global $post, $wp_locale;
13
14
// Gallery instance counter
15
    /**
16
     * @var int
17
     */
18
    static $instance = 0;
19
    $instance++;
20
21
// Validate the author's orderby attribute
22
    if (isset($attr['orderby'])) {
23
        $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
24
        if (!$attr['orderby']) {
25
            unset($attr['orderby']);
26
        }
27
    }
28
29
    // Get attributes from shortcode
30
    extract(shortcode_atts([
31
        'order'      => 'ASC',
32
        'orderby'    => 'menu_order ID',
33
        'id'         => $post->ID,
34
        'itemtag'    => 'dl',
35
        'icontag'    => 'dt',
36
        'captiontag' => 'dd',
37
        'columns'    => 2,
38
        // 'size'       => 'gallery-thumb-2',
39
        'include'    => '',
40
        'exclude'    => ''
41
    ], $attr));
42
43
    $size = 'gallery-thumb-2';
44
45
// You need to add size for your gallery and use it
46
47
    // Initialize
48
    $id          = intval($id);
49
    $attachments = [];
50
51
    if ('RAND' == $order) {
52
        $orderby = 'none';
53
    }
54
55
    if (!empty($include)) {
56
        // Include attribute is present
57
        $include      = preg_replace('/[^0-9,]+/', '', $include);
58
        $_attachments = get_posts(['include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
59
60
// Setup attachments array
61
        foreach ($_attachments as $key => $val) {
62
            $attachments[$val->ID] = $_attachments[$key];
63
        }
64
    } elseif (!empty($exclude)) {
65
66
        // Exclude attribute is present
67
        $exclude = preg_replace('/[^0-9,]+/', '', $exclude);
68
69
        // Setup attachments array
70
        $attachments = get_children(['post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
71
    } else {
72
        // Setup attachments array
73
        $attachments = get_children(['post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby]);
74
    }
75
76
    if (empty($attachments)) {
77
        return '';
78
    }
79
80
// Filter gallery differently for feeds
81
    if (is_feed()) {
82
        $output = "\n";
83
        foreach ($attachments as $att_id => $attachment) {
84
            $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
85
        }
86
87
        return $output;
88
    }
89
90
    // Filter tags and attributes
91
    $itemtag    = tag_escape($itemtag);
92
    $captiontag = tag_escape($captiontag);
93
    $columns    = intval($columns);
94
    $itemwidth  = $columns > 0 ? floor(100 / $columns) : 100;
95
    $float      = is_rtl() ? 'right' : 'left';
96
    $selector   = "gallery-{$instance}";
97
98
    // Filter gallery CSS
99
    $output = apply_filters('gallery_style', "
100
        <style type='text/css'>
101
            #{$selector} {
102
                margin: auto;
103
            }
104
            #{$selector} .gallery-item {
105
                float: {$float};
106
                margin-top: 10px;
107
                text-align: center;
108
                width: {$itemwidth}%;
109
            }
110
            #{$selector} img {
111
                border: 2px solid #cfcfcf;
112
            }
113
            #{$selector} .gallery-caption {
114
                margin-left: 0;
115
            }
116
        </style>
117
        <!-- see gallery_shortcode() in wp-includes/media.php -->
118
        <div id='$selector' class='grid-x grid-padding-x small-up-1 large-up-{$columns} gallery galleryid-{$id}'>"
119
    );
120
121
    // Iterate through the attachments in this gallery instance
122
    $i = 0;
123
124
    foreach ($attachments as $id => $attachment) {
125
126
        // Attachment link
127
        $img = wp_prepare_attachment_for_js($id);
128
        $url = $img['sizes']['full']['url'];
129
        $alt = $img['alt'];
130
131
        // Start itemtag
132
        $output .= "<{$itemtag} class='cell gallery-item'>";
133
134
        // icontag
135
        $output .= "<{$icontag} class='gallery-icon'>";
136
137
        if (isset($attr['link']) && 'none' != $attr['link']) {
138
            $output .= '<a data-open="galleryModal' . $post->ID . $id . '" class="thumbnail-wrap">';
139
        }
140
141
        $output .= wp_get_attachment_image($id, $size);
142
143
        if (isset($attr['link']) && 'none' != $attr['link']) {
144
            $output .= '</a>';
145
        }
146
147
        $output .= "</{$icontag}>";
148
149
        if ($captiontag && trim($attachment->post_excerpt)) {
150
            // captiontag
151
            $output .= "
152
            <{$captiontag} class='gallery-caption'>
153
                " . wptexturize($attachment->post_excerpt) . "
154
            </{$captiontag}>";
155
        }
156
157
        // End itemtag
158
        $output .= "</{$itemtag}>";
159
160
        $output .= "<div class=\"gallery-reveal reveal large\" id=\"galleryModal{$post->ID}{$id}\" aria-labelledby=\"ModalHeader\" data-reveal>
161
                      <img src=\"{$url}\" alt=\"{$alt}\" />
162
                      <button class=\"close-button\" data-close aria-label=\"Close Modal\" type=\"button\">
163
                        <span aria-hidden=\"true\">&times;</span>
164
                      </button>
165
                </div>";
166
167
// Line breaks by columns set
168
        if ($columns > 0 && ++$i % $columns == 0) {
169
            $output .= '<br style="clear: both">';
170
        }
171
    }
172
173
    // End gallery output
174
    $output .= "
175
        <br style='clear: both;'>
176
    </div>\n";
177
178
    return $output;
179
}
180
181
// Apply filter to default gallery shortcode
182
add_filter('post_gallery', 'podium_post_gallery', 10, 2);
183
184
// Get featured image or placeholder
185
/**
186
 * @param $size
187
 */
188
function get_podium_featured_image($size)
189
{
190
    if (has_post_thumbnail()) {
191
        the_post_thumbnail($size);
192
    } else {
193
        ?>
194
    <img src="<?php echo get_template_directory_uri(); ?>/dist/images/placeholder.jpg" alt="placeholder image" />
195
    <?php 
196
    }
197
}
198
199
// Make embeds responsive
200
// Modest youtube player
201
add_filter('embed_oembed_html', 'podium_oembed_html', 99, 4);
202
/**
203
 * @param $html
204
 * @param $url
205
 * @param $attr
206
 * @param $post_id
207
 */
208
function podium_oembed_html($html, $url, $attr, $post_id)
0 ignored issues
show
The parameter $url is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $attr is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $post_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
209
{
210
    // Parameters for Modest youtube player:
211
    $html = str_replace('?feature=oembed', '?feature=oembed&html5=1&theme=light&color=white&autohide=2&modestbranding=1&showinfo=0&rel=0&iv_load_policy=3&cc_load_policy=1', $html);
212
213
// Add wrapper div with Foundation class
214
    // http://foundation.zurb.com/sites/docs/flex-video.html
215
    return '<div class="responsive-embed widescreen">' . $html . '</div>';
216
}
217
218
/**
219
 * @param  $svg_file
220
 * @return string
221
 */
222
function svg_get_contents($svg_file)
223
{
224
// Check if file exists
225
    if ($svg_file) {
226
        // Set user-agent
227
        ini_set('user_agent', 'Mozilla/5.0 (X11; OrcamServer; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0');
228
        // Get SVG contents
229
230
        $arrContextOptions = [
231
            'ssl'  => [
232
                'verify_peer'      => false,
233
                'verify_peer_name' => false
234
            ],
235
            'http' => [
236
                'header' => 'Authorization: Basic ' . base64_encode('OrCam:testingWebsite') // Auth for testing website
237
            ]
238
        ];
239
240
        $svg_file = file_get_contents($svg_file, false, stream_context_create($arrContextOptions));
241
        // Clean unnecessary meta and info
242
        $find_string  = '<svg';
243
        $position     = strpos($svg_file, $find_string);
244
        $svg_file_new = substr($svg_file, $position);
245
        // Restore user agent
246
        ini_restore('user_agent');
247
        return $svg_file_new;
248
    }
249
250
    return 'The file does not exist';
251
}
252