sunnysideup /
silverstripe-contactus
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | class ContactUsPageControllerExtension extends Extension |
||
|
0 ignored issues
–
show
|
|||
| 4 | { |
||
| 5 | |||
| 6 | private static $add_placeholders = false; |
||
|
0 ignored issues
–
show
|
|||
| 7 | |||
| 8 | private static $allowed_actions = array( |
||
|
0 ignored issues
–
show
|
|||
| 9 | 'ContactUsForm' => true, |
||
| 10 | 'docontactusform' => true |
||
| 11 | ); |
||
| 12 | |||
| 13 | protected $contactUsProcessingForm = false; |
||
| 14 | |||
| 15 | function ContactUsProcessingForm() { |
||
|
0 ignored issues
–
show
|
|||
| 16 | return $this->contactUsProcessingForm; |
||
| 17 | } |
||
| 18 | |||
| 19 | function ContactUsForm() |
||
|
0 ignored issues
–
show
|
|||
| 20 | { |
||
| 21 | $m = Member::currentUser(); |
||
| 22 | if(!$m) { |
||
| 23 | $m = new Member(); |
||
| 24 | } |
||
| 25 | $fields = new FieldList( |
||
| 26 | TextField::create('FirstName',_t('ContactUsPageControllerExtension.FIRST_NAME', 'First Name'), $m->FirstName), |
||
| 27 | TextField::create('Surname', _t('ContactUsPageControllerExtension.SURNAME', 'Surname'), $m->Surname), |
||
| 28 | EmailField::create('Email',_t('ContactUsPageControllerExtension.EMAIL', 'Email'), $m->Email), |
||
| 29 | TextField::create('Phone', _t('ContactUsPageControllerExtension.PHONE', 'Phone')), |
||
| 30 | TextareaField::create('Enquiry', SiteConfig::current_site_config()->ContactUsFormEnquiryLabel) |
||
| 31 | ); |
||
| 32 | if(Config::inst()->get('ContactUsPageControllerExtension', 'add_placeholders')) { |
||
| 33 | foreach($fields as $field) { |
||
| 34 | $field->setAttribute('placeholder', $field->Title()); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | $actions = FieldList::create( |
||
| 38 | FormAction::create('docontactusform', SiteConfig::current_site_config()->ContactUsFormSendLabel) |
||
| 39 | ); |
||
| 40 | $form = new Form( |
||
| 41 | $this->owner, |
||
| 42 | 'ContactUsForm', |
||
| 43 | $fields, |
||
| 44 | $actions, |
||
| 45 | RequiredFields::create( |
||
| 46 | array("Email", "Enquiry") |
||
| 47 | ) |
||
| 48 | ); |
||
| 49 | // Update the form to add the protecter field to it |
||
| 50 | |||
| 51 | return $form; |
||
| 52 | |||
| 53 | } |
||
| 54 | |||
| 55 | function docontactusform ($data, $form) |
||
|
0 ignored issues
–
show
|
|||
| 56 | { |
||
| 57 | $data = Convert::raw2sql($data); |
||
| 58 | $obj = ContactUsFormEntry::create_enquiry($data, $this->owner->dataRecord); |
||
| 59 | $subject = _t('ContactUsPageControllerExtension.THANK_YOU_SUBJECT', 'Thank you for your enquiry').' - '.Director::absoluteBaseURL(); |
||
| 60 | $body = "<strong>$subject</strong><br /><br />"; |
||
| 61 | foreach($data as $key => $value) { |
||
|
0 ignored issues
–
show
The expression
$data of type array|string is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
Loading history...
|
|||
| 62 | if($key == "url") { |
||
| 63 | $value = Director::absoluteURL($value); |
||
| 64 | $value = trim($value, "ContactUsForm"); |
||
| 65 | } |
||
| 66 | if($key == "SecurityID" || $key == "Send" || $key == "Captcha" || $key == 'action_docontactusform') { |
||
|
0 ignored issues
–
show
This
if statement is empty and can be removed.
This check looks for the bodies of These if (rand(1, 6) > 3) {
//print "Check failed";
} else {
print "Check succeeded";
}
could be turned into if (rand(1, 6) <= 3) {
print "Check succeeded";
}
This is much more concise to read. Loading history...
|
|||
| 67 | //do nothing |
||
| 68 | }else { |
||
| 69 | $body .= "<br /><br />".$key.': '.strip_tags($value).''; |
||
| 70 | } |
||
| 71 | } |
||
| 72 | $adminEmailAddress = SiteConfig::current_site_config()->ContactUsFormEmail; |
||
| 73 | $customerEmailAddress = $data["Email"]; |
||
| 74 | $email = Email::create( |
||
| 75 | $from = $customerEmailAddress, |
||
| 76 | $to = $adminEmailAddress, |
||
| 77 | $subject, |
||
| 78 | $body |
||
| 79 | ); |
||
| 80 | $obj->SentToAdmin = $email->send(); |
||
|
0 ignored issues
–
show
The property
SentToAdmin does not exist on object<ContactUsFormEntry>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 81 | $obj->AdminEmail = $adminEmailAddress; |
||
|
0 ignored issues
–
show
The property
AdminEmail does not exist on object<ContactUsFormEntry>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 82 | |||
| 83 | $email = Email::create( |
||
| 84 | $from = $adminEmailAddress, |
||
| 85 | $to = $customerEmailAddress, |
||
| 86 | $subject, |
||
| 87 | $body |
||
| 88 | ); |
||
| 89 | $obj->SentToCustomer = $email->send(); |
||
|
0 ignored issues
–
show
The property
SentToCustomer does not exist on object<ContactUsFormEntry>. Since you implemented __set, maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 90 | $this->contactUsProcessingForm = true; |
||
| 91 | $obj->write(); |
||
| 92 | |||
| 93 | return array(); |
||
| 94 | } |
||
| 95 | } |
||
| 96 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.