2016-10-22 01:08:26 -04:00
<? php
class ReportActions extends Actions
{
2018-05-21 11:49:15 -04:00
public static function executeDmca ()
2016-10-22 01:08:26 -04:00
{
2018-05-21 11:49:15 -04:00
Response :: setHeader ( Response :: HEADER_CROSS_ORIGIN , "*" );
if ( ! Request :: isPost ()) {
return [ 'report/dmca' ];
}
$values = [];
$errors = [];
foreach ([ 'name' , 'email' , 'rightsholder' , 'identifier' ] as $field ) {
$value = Request :: getPostParam ( $field );
if ( ! $value ) {
$errors [ $field ] = __ ( 'form_error.required' );
} elseif ( $field == 'email' && ! filter_var ( $value , FILTER_VALIDATE_EMAIL )) {
$errors [ $field ] = __ ( 'form_error.invalid' );
}
$values [ $field ] = $value ;
}
2019-03-21 14:34:28 -04:00
if ( $_GET [ 'claim_id' ] && ! $values [ 'identifier' ]) {
$values [ 'identifier' ] = htmlspecialchars ( $_GET [ 'claim_id' ]);
}
2018-05-21 11:49:15 -04:00
if ( ! $errors ) {
$values [ 'report_id' ] = Encoding :: base58Encode ( random_bytes ( 6 ));
Mailgun :: sendDmcaReport ( $values );
Session :: setFlash ( 'success' , '<h3>Report Submitted</h3><p>We will respond shortly.</p><p>This ID for this report is <strong>' . $values [ 'report_id' ] . '</strong>. Please reference this ID when contacting us regarding this report.</p>' );
return Controller :: redirect ( Request :: getRelativeUri (), 303 );
}
2019-03-21 14:34:28 -04:00
return [ 'report/dmca' , [
'errors' => $errors ,
'values' => $values
]];
2016-10-22 01:08:26 -04:00
}
2018-05-21 11:49:15 -04:00
}