Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dantheta committed Aug 24, 2019
1 parent 517d486 commit 2f0f510
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 6 deletions.
25 changes: 19 additions & 6 deletions api/1.2/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1602,8 +1602,8 @@ function result_callback($msg, $queue) {

$url = $app['db.url.load']->load(normalize_url($data['url']));

if (!(count($data['networks']) == 1 && $data['networks'][0] == 'ORG')) {
// we are submittingt to ISPs, not feedback to ORG
if (!(count($data['networks']) == 1 && ($data['networks'][0] == 'ORG' || $data['networks'][0] == "BBFC"))) {
// we are submittingt to ISPs, not feedback to ORG or BBFC
if ($app['db.blacklist.load']->check($url['url'])) {
error_log("{$url['url']} is blacklisted; not submitting");
return $app->json(array('success' => false, 'message' => 'domain rejected'));
Expand All @@ -1621,8 +1621,8 @@ function result_callback($msg, $queue) {
error_log("Unreported: " . implode(",", $data['networks']));
}

if (!$contact['verified'] && !(count($data['networks']) == 1 && $data['networks'][0] == 'ORG')) {
// reports sent to ORG only are exempt from validation
if (!$contact['verified'] && !(count($data['networks']) == 1 && ($data['networks'][0] == 'ORG' || $data['networks'][0] == 'BBFC') )) {
// reports sent to ORG or BBFC only are exempt from validation
$token = "B" . md5($contact['id'] . "-" .
Middleware::generateSharedSecret(10));

Expand All @@ -1645,7 +1645,7 @@ function result_callback($msg, $queue) {

// check latest status
// special case for the pseudo-isp ORG
if ($network_name != "ORG") {
if ($network_name != "ORG" && $network_name != "BBFC") {
$q = $app['service.db']->query("select id, (now()-created) > interval '14 days' as age_limit
from url_latest_status
where urlID = ? and network_name = ? and status = 'blocked'",
Expand Down Expand Up @@ -1688,7 +1688,7 @@ function result_callback($msg, $queue) {
);
# send email here

if (($contact['verified'] || $network_name == 'ORG') && $age_limit == false) {
if (($contact['verified'] || $network_name == 'ORG') && $network_name != 'BBFC' && $age_limit == false) {
sendISPReport(
$mailname,
$data['reporter']['name'],
Expand All @@ -1701,6 +1701,19 @@ function result_callback($msg, $queue) {
$app['service.template']
);
}
if ($network_name == "BBFC") {
sendBBFCReport($mailname,
$data['reporter']['name'],
$data['reporter']['email'],
$data['original_network'],
$url['url'],
$data['message'],
$data['previous'],
$data['additional_contact']
);


}


} else {
Expand Down
4 changes: 4 additions & 0 deletions api/1.2/libs/config.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@

define('ELASTIC_ADULT_FILTER', 'escort~ OR fetish OR stripper~ OR porn~ OR blowjob~ OR femdom~ OR fuck~');

# https://bbfc.co.uk/what-classification/mobile-content/appeals/mobile-complaint-form
define('BBFC_FORM_URL', 'https://bbfc.co.uk/what-classification/mobile-content/appeals/mobile-complaint-form');
define('BBFC_SUBMIT_URL', 'https://bbfc.co.uk/what-classification/mobile-content/appeals/mobile-complaint-form');

$REQUEUE_EXCLUDE_SOURCES = array();
65 changes: 65 additions & 0 deletions api/1.2/libs/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,71 @@ function sendISPReport($mailname, $name, $email, $network, $url, $message, $repo
return true;
}

function sendBBFCReport($mailname, $name, $email, $network, $url, $message, $previous, $additional_contact) {

# <option value="" selected="selected">- Select -</option>
# <option value="3">3</option>
# <option value="EE">EE</option>
# <option value="EE Strict">EE Strict (for EE customers under the age of 12)</option>
# <option value="O2">O2</option>
# <option value="Vodafone">Vodafone</option>
# <option value="Other">Other</option>

if ($network == "Three") {
$network = "3";
}


$req = new HTTP_Request2(BBFC_FORM_URL);

$rsp = $req->send();


$rsp = $req->setMethod(HTTP_Request2::METHOD_POST)
->setBody(json_encode($search))
->setHeader('Content-type: application/json')
->send();

$form_html = $rsp->getBody();

preg_match('/form_build_id" value="(.*)"/', $form_html, $matches);
$form_build_id = $matches[1];
preg_match('/form_id" value="(.*)"/', $form_html, $matches);
$form_id = $matches[1];

// $form_build_id = 'ABCDEF';
// $form_id = 'ABC';

$data = array(
"submitted[who_is_your_mobile_network_operator]" => $network,
"submitted[please_specify]" => "", # other ISP
"submitted[have_you_contacted_your_mobile_operator]" => "01", # yes "01"
"submitted[what_was_your_mobile_operators_response_to_your_complaint]" => $previous, # multine
"submitted[your_name]" => $name,
"submitted[your_email]" => $mailname . '@' . MAIL_DOMAIN,
"submitted[additional_contact_information]" => $additional_contact,
"submitted[url_of_the_content_in_question]" => $url,
"submitted[nature_of_the_complaint]" => $message,
# "details[sid]"
"details[page_num]" => "1",
"details[page_count]" => "1",
"details[finished]" => "0",

"form_build_id" => $form_build_id,
"form_id" => $form_id,
"op" => "Submit"
);


$req = new HTTP_Request2(BBFC_SUBMIT_URL);
$rsp = $req->setMethod(HTTP_Request2::METHOD_POST)
->addPostParameter($data)
->send();
$body = $rsp->getBody();

return true;
}

function sendUserVerification($email, $name, $token, $attempt, $renderer) {
$msg = new PHPMailer();
$msg->setFrom(SITE_EMAIL, SITE_NAME);
Expand Down

0 comments on commit 2f0f510

Please sign in to comment.