Issues (661)

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.

contact.php (12 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
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 *
14
 * Tell a friend form generator / send email
15
 *
16
 * @copyright ::  {@link http://xoops.org/ XOOPS Project}
17
 * @license   ::    {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
18
 * @package   ::    mylinks
19
 */
20
include_once __DIR__ . '/header.php';
21
include_once $GLOBALS['xoops']->path('header.php');
22
include_once __DIR__ . '/class/utility.php';
23
include_once $GLOBALS['xoops']->path('class' . DIRECTORY_SEPARATOR . 'xoopsformloader.php');
24
25
xoops_loadLanguage('main', $GLOBALS['xoopsModule']->getVar('dirname'));
26
$myts = MyTextSanitizer::getInstance();
27
28
if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) && !$GLOBALS['xoopsModuleConfig']['anontellafriend']) {
0 ignored issues
show
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
29
    redirect_header('index.php', 3, _NOPERM);
30
    exit();
31
}
32
33
if (!isset($_POST['submit'])) {
34
    if (!empty($_GET['contents'])) {
35
        // coming back from failed attempt at filling out form
36
        $form_contents = unserialize($myts->stripSlashesGPC($_GET['contents']));
37
        $lid           = !empty($form_contents['lid']) ? (int)$form_contents['lid'] : 0;
38
        $comments      = !empty($form_contents['comments']) ? strip_tags(html_entity_decode($form_contents['comments'])) : '';
39
        $frname        = !empty($form_contents['frname']) ? $myts->htmlSpecialChars($form_contents['frname']) : '';
40
        $fremail       = !empty($form_contents['fremail']) ? $myts->htmlSpecialChars($form_contents['fremail']) : '';
41
        $sname         = !empty($form_contents['sname']) ? $myts->htmlSpecialChars($form_contents['sname']) : '';
42
        $semail        = !empty($form_contents['semail']) ? $myts->htmlSpecialChars($form_contents['semail']) : '';
43
    } else {
44
        $lid      = MylinksUtility::mylinks_cleanVars($_GET, 'lid', 0, 'int', array('min' => 0));
0 ignored issues
show
'lid' is of type string, but the function expects a object<unknown_type>.

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);
Loading history...
45
        $comments = $frname = $fremail = $sname = $semail = '';
46
    }
47
48
    // make sure that the link the user is sharing is valid & active
49
    $result = $GLOBALS['xoopsDB']->query("SELECT title FROM {$GLOBALS['xoopsDB']->prefix('mylinks_links')} WHERE `lid` = '{$lid}' AND status>0 LIMIT 0,1");
50 View Code Duplication
    if ($result) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
51
        list($linktitle) = $GLOBALS['xoopsDB']->fetchRow($result);
52
        $linktitle = $myts->stripSlashesGPC($linktitle);
53
    } else {
54
        // invalid (or inactive) link, can't send this to a friend
55
        redirect_header('index.php', 3, _MD_MYLINKS_INVALIDORINACTIVELNK);
56
        exit();
57
    }
58
59
    $tfform = new XoopsThemeForm(_MD_MYLINKS_TELLAFRIEND, 'tfform', $_SERVER['PHP_SELF'], 'post', true);
60
    $tfform->addElement(new XoopsFormText(_MD_MYLINKS_FRIEND . ' ' . _MD_MYLINKS_NAME, 'frname', 50, 50, trim($frname)), true);
61
    $tfform->addElement(new XoopsFormText(_MD_MYLINKS_FRIEND . ' ' . _MD_MYLINKS_EMAIL, 'fremail', 50, 50, trim($fremail)), true);
62
    if (!$GLOBALS['xoopsUser'] instanceof XoopsUser) {
0 ignored issues
show
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
63
        $tfform->addElement(new XoopsFormText(_MD_MYLINKS_SENDER . ' ' . _MD_MYLINKS_NAME, 'sname', 50, 50, trim($sname)), true);
64
        $tfform->addElement(new XoopsFormText(_MD_MYLINKS_SENDER . ' ' . _MD_MYLINKS_EMAIL, 'semail', 50, 50, trim($semail)), true);
65
    }
66
    $tfform->addElement(new XoopsFormLabel(_MD_MYLINKS_TITLE, $linktitle));
67
    $tfform->addElement(new XoopsFormTextArea(_COMMENTS, 'comments', trim($comments)));
68
    $tfform->addElement(new XoopsFormHidden('lid', $lid));
69
    $tfform->addElement(new XoopsFormCaptcha());
70
    //    $tfform->addElement(new XoopsFormCaptcha(null, null, false, array('maxattempts'=>4)));
71
    $tfform->addElement(new XoopsFormButtonTray('submit', _SUBMIT));
72
    $tfform->display();
73
    include_once $GLOBALS['xoops']->path('footer.php');
74
} else {
75
    if ($GLOBALS['xoopsSecurity'] instanceof XoopsSecurity) {
0 ignored issues
show
The class XoopsSecurity does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
76
        if (!$GLOBALS['xoopsSecurity']->check()) {
77
            // failed xoops security check
78
            redirect_header('index.php', 3, $GLOBALS['xoopsSecurity']->getErrors(true));
79
            exit();
80
        }
81
    } else {
82
        redirect_header('index.php', 3, _MD_MYLINKS_INVALID_SECURITY_TOKEN);
83
    }
84
85
    $lid      = MylinksUtility::mylinks_cleanVars($_POST, 'lid', 0, 'int', array('min' => 0));
0 ignored issues
show
'lid' is of type string, but the function expects a object<unknown_type>.

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);
Loading history...
86
    $comments = strip_tags(html_entity_decode($myts->stripSlashesGPC($_POST['comments'])));
87
    $frname   = MylinksUtility::mylinks_cleanVars($_POST, 'frname', '', 'string');
0 ignored issues
show
'frname' is of type string, but the function expects a object<unknown_type>.

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);
Loading history...
88
    $fremail  = MylinksUtility::mylinks_cleanVars($_POST, 'fremail', '', 'email');
0 ignored issues
show
'fremail' is of type string, but the function expects a object<unknown_type>.

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);
Loading history...
89
    $sname    = MylinksUtility::mylinks_cleanVars($_POST, 'sname', '', 'string');
0 ignored issues
show
'sname' is of type string, but the function expects a object<unknown_type>.

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);
Loading history...
90
    $semail   = MylinksUtility::mylinks_cleanVars($_POST, 'semail', '', 'email');
0 ignored issues
show
'semail' is of type string, but the function expects a object<unknown_type>.

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);
Loading history...
91
92
    //Check captcha
93
    xoops_load('XoopsCaptcha');
94
    $xoopsCaptcha = XoopsCaptcha::getInstance();
95
    if (!$xoopsCaptcha->verify()) {
96
        if ($_SESSION['xoopscaptcha_attempt'] < $_SESSION['_maxattempts']) {
97
            $form_contents = array(
98
                'lid'      => $lid,
99
                'frname'   => $frname,
100
                'fremail'  => $fremail,
101
                'sname'    => $sname,
102
                'semail'   => $semail,
103
                'comments' => $comments
104
            );
105
            $contents      = serialize($form_contents);
106
            redirect_header($_SERVER['PHP_SELF'] . "?contents={$contents}", 2, $xoopsCaptcha->getMessage());
107
            exit();
108
        } else {
109
            redirect_header('index.php', 2, $xoopsCaptcha->getMessage());
110
            exit();
111
        }
112
    }
113
114
    $xadminmail = $GLOBALS['xoopsConfig']['adminmail'];    //setting from to server in case of SPF=>will admin config this as well
115
    $xsitename  = $GLOBALS['xoopsConfig']['sitename'];     //adding site title as sender (mod config this?)
116
117
    // set from name / email for registered user
118
    if ($GLOBALS['xoopsUser'] instanceof XoopsUser) {
0 ignored issues
show
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
119
        $semail = $GLOBALS['xoopsUser']->getVar('email');
120
        $sname  = ucfirst($GLOBALS['xoopsUser']->getVar('uname'));
121
        $sname  = ('' == $sname) ? $GLOBALS['xoopsUser']->getVar('name') : $sname;
122
    }
123
    // check to see if email for recipient and sender are 'sane'
124
    if (!filter_var($fremail, FILTER_VALIDATE_EMAIL) || !filter_var($semail, FILTER_VALIDATE_EMAIL)) {
125
        redirect_header('index.php', 2, _MD_MYLINKS_INVALIDEMAIL);
126
    }
127
    // set the url to the link
128
    if ($lid > 0) {
129
        $linkurl = $GLOBALS['xoops']->url('modules/' . $GLOBALS['xoopsModule']->getVar('dirname') . "/singlelink.php?lid={$lid}");
130
        // now check to make sure that the link the user is sharing is valid
131
        $result = $GLOBALS['xoopsDB']->query("SELECT title FROM {$GLOBALS['xoopsDB']->prefix('mylinks_links')} WHERE `lid` = '{$lid}' AND status>0 LIMIT 0,1");
132 View Code Duplication
        if ($result) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
133
            list($linktitle) = $GLOBALS['xoopsDB']->fetchRow($result);
134
            $linktitle = $myts->stripSlashesGPC($linktitle);
135
        } else {
136
            // invalid (or inactive) link, can't send this to a friend
137
            redirect_header('index.php', 3, _MD_MYLINKS_INVALIDORINACTIVELNK);
138
            exit();
139
        }
140
    } else {
141
        redirect_header('index.php', 3, _MD_MYLINKS_INVALIDORINACTIVELNK);
142
        exit();
143
    }
144
145
    $subject = sprintf(_MD_MYLINKS_EMAIL_SUBJECT, $xsitename, $sname);
146
147
    //now send mail to friend
148
    $xMailer =& xoops_getMailer();
149
    $xMailer->useMail(); // Set it to use email (as opposed to PM)
150
    $xMailer->setTemplateDir($GLOBALS['xoops']->path('modules' . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $GLOBALS['xoopsModule']->getVar('dirname') . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR . $GLOBALS['xoopsConfig']['language'] . DIRECTORY_SEPARATOR . 'mail_template'
151
                                                     . DIRECTORY_SEPARATOR));
152
    $xMailer->setTemplate('tellafriend_mail.tpl');
153
154
    // set common mail template variables
155
    $xMailer->assign(array(
156
                         'SNAME'        => $sname,
157
                         'SEMAIL'       => $semail,
158
                         'X_ADMINMAIL'  => $xadminmail,
159
                         'X_SITENAME'   => $xsitename,
160
                         'X_SITEURL'    => $GLOBALS['xoops']->url('/'),
161
                         'X_LINK_TITLE' => strip_tags(html_entity_decode($linktitle)),
162
                         'X_LINK'       => $linkurl,
163
                         'FRNAME'       => $frname,
164
                         'COMMENTS'     => strip_tags(html_entity_decode($comments))
165
                     ));
166
167
    $xMailer->setToEmails($fremail);
168
    $xMailer->setFromEmail($xadminmail);
169
    $xMailer->setFromName($xsitename);
170
    $xMailer->setSubject($subject);
171
172
    if ($xMailer->send()) {
173
        //send was successful
174
        redirect_header('index.php', 2, _MD_MYLINKS_MESSEND);
175
        exit();
176
    } else {
177
        redirect_header('index.php', 2, $xMailer->getErrors(true));
178
        exit();
179
    }
180
}
181