Issues (1177)

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.

application/modules/share/share.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
use CMSFactory\assetManager;
4
use core\src\CoreFactory;
5
6
if (!defined('BASEPATH')) {
7
    exit('No direct script access allowed');
8
}
9
10
/**
11
 * Image CMS
12
 *
13
 * Comments component
14
 * @link http://api.yandex.ru/share/
15
 */
16
class Share extends MY_Controller
17
{
18
19
    /**
20
     * @var array|mixed
21
     */
22
    public $settings = [];
23
24
    public static $i;
25
26
    /**
27
     * Share constructor.
28
     */
29 View Code Duplication
    public function __construct() {
30
31
        parent::__construct();
32
        $lang = new MY_Lang();
33
        $lang->load('share');
34
        $this->load->module('core');
35
36
        $this->db->select('settings');
37
        $this->settings = unserialize(implode(',', $this->db->get_where('components', ['name' => 'share'])->row_array()));
38
    }
39
40
    /**
41
     * Default function to access module by URL
42
     */
43
    public function index() {
44
45
        $this->template->add_array(
46
            'ss',
47
            [
48
             'html' => $this->_make_share_form(),
49
            ]
50
        );
51
    }
52
53
    public function _install() {
54
55
        $this->load->dbforge();
56
        ($this->dx_auth->is_admin()) OR exit;
57
    }
58
59
    public function _deinstall() {
60
61
        $this->load->dbforge();
62
        ($this->dx_auth->is_admin()) OR exit;
63
    }
64
65
    /**
66
     * @param string $url
67
     * @return string
68
     */
69
    public function _make_share_form($url = '') {
70
71
        $url = $url ?: site_url(CoreFactory::getUrlParser()->getFullUrl(false));
72
73
        $settings = $this->settings;
74
        $services = '';
75
        if ($settings['yaru'] == 1) {
76
            $services .= 'yaru,';
77
        }
78
        if ($settings['vkcom'] == 1) {
79
            $services .= 'vkontakte,';
80
        }
81
        if ($settings['facebook'] == 1) {
82
            $services .= 'facebook,';
83
        }
84
        if ($settings['twitter'] == 1) {
85
            $services .= 'twitter,';
86
        }
87
        if ($settings['odnoclass'] == 1) {
88
            $services .= 'odnoklassniki,';
89
        }
90
        if ($settings['myworld'] == 1) {
91
            $services .= 'moimir,';
92
        }
93
        if ($settings['lj'] == 1) {
94
            $services .= 'lj,';
95
        }
96
        if ($settings['ff'] == 1) {
97
            $services .= 'friendfeed,';
98
        }
99
        if ($settings['mc'] == 1) {
100
            $services .= 'moikrug,';
101
        }
102
        if ($settings['gg'] == 1) {
103
            $services .= 'gplus,';
104
        }
105
106
        if ($settings['type'] == 'counter') {
107
            $type = ' data-counter=""';
108
        } elseif ($settings['type'] == 'button') {
109
            $type = '';
110
        } elseif ($settings['type'] == 'icon') {
111
            $type = ' data-limit="3"';
112
        }
113
114
        \CI_Controller::get_instance()
115
            ->template
116
            ->registerJsScript('<script async="async" type="text/javascript" src="//yastatic.net/es5-shims/0.0.2/es5-shims.min.js" charset="utf-8"></script>', 'before');
117
        \CI_Controller::get_instance()
118
            ->template
119
            ->registerJsScript('<script type="text/javascript" src="//yastatic.net/share2/share.js" charset="utf-8"></script>', 'before');
120
121
        $html = '<div class="ya-share2" data-lang="ru" data-url="' . $url . '"'
122
            . $type
123
            . ' data-services="' . $services . '"></div>';
124
125
        return $html;
126
    }
127
128
    /**
129
     * @param string $url
130
     * @return string
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
131
     */
132
    public function _make_like_buttons_fb($url = '') {
133
134
        $settings = $this->settings;
135
136
        if ($settings['facebook_like'] == 1) {
137
            $fbsrc = '(function(d, s, id) {
138
                        var js, fjs = d.getElementsByTagName(s)[0];
139
                        if (d.getElementById(id)) return;
140
                        js = d.createElement(s); js.id = id;
141
                        js.src = "//connect.facebook.net/en_EN/all.js#xfbml=1";
142
                        fjs.parentNode.insertBefore(js, fjs);
143
                        }(document, "script", "facebook-jssdk"));';
144
            assetManager::create()->registerJsScript($fbsrc, FALSE, 'before');
145
            return '<div id="fb-root"></div>
146
                <div class="fb-like" data-send="false" data-layout="button_count" data-width="60" data-show-faces="true" data-href="' . $url . '"></div>';
147
        }
148
    }
149
150
    public function _make_like_buttons_vk($url = '') {
151
152
        self::$i++;
153
        $settings = $this->settings;
154
155
        if ($settings['vk_like'] == 1 && $settings['vk_apiid']) {
156
            \CI_Controller::get_instance()->template->registerJsScript(
157
                "<script type='text/javascript' src='//vk.com/js/api/openapi.js?101'></script>
158
                        <script type='text/javascript'>
159
                          VK.init({apiId: '{$settings['vk_apiid']}', onlyWidgets: true});
160
                        </script>",
161
                'before'
162
            );
163
164
            return "<!-- Put this div tag to the place, where the Like block will be -->
165
                        <div id='vk_like" . self::$i . "'></div>
166
                        <script type='text/javascript'>
167
                        VK.Widgets.Like('vk_like" . self::$i . "', {
168
                                                    type: 'mini', 
169
                                                    height: 18,
170
                                                    pageUrl: '$url'
171
                                                    }
172
                                                );
173
                        </script>";
174
        }
175
    }
176
177 View Code Duplication
    public function _make_like_buttons_google($url = '') {
178
179
        $settings = $this->settings;
180
181
        if ($settings['gg_like'] == 1) {
182
            \CI_Controller::get_instance()->template->registerJsScript(
183
                "<script type='text/javascript' src='https://apis.google.com/js/plusone.js'>
184
                          {lang: 'ru', parsetags: 'explicit' }
185
                        </script>",
186
                'before'
187
            );
188
            return "<!-- Place this tag where you want the +1 button to render. -->
189
                        <div class='g-plusone' data-size='medium' data-href='$url'></div>
190
191
                        <!-- Place this render call where appropriate. -->
192
                        <script type='text/javascript'>gapi.plusone.go();</script>";
193
        }
194
    }
195
196 View Code Duplication
    public function _make_like_buttons_twitter($url = '') {
197
198
        $settings = $this->settings;
199
200
        if ($settings['twitter_like'] == 1) {
201
            \CI_Controller::get_instance()->template->registerJsScript(
202
                '<script async="async" defer="defer">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id))
203
                    {js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></li>',
204
                'before'
205
            );
206
            return '<a href="https://twitter.com/share" class="twitter-share-button" data-url="' . $url . '">Tweet</a>';
207
        }
208
    }
209
210
    public function _make_like_buttons($url = '') {
211
212
        $html = '<ul class="items items-social">'
213
            . '<li>' . $this->_make_like_buttons_fb($url) . '</li>'
214
            . '<li>' . $this->_make_like_buttons_vk($url) . '</li>'
215
            . '<li>' . $this->_make_like_buttons_google($url) . '</li>'
216
            . '<li>' . $this->_make_like_buttons_twitter($url) . '</li>' .
217
            '</ul>';
218
        return $html;
219
    }
220
221
}