} else {
    echo "Success";
}
#create sns client
$sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1']);
#print_r($result);
//echo "sns Topic";
//to list topics
$resultsns = $sns->listTopics(array());
foreach ($resultsns['Topics'] as $key => $value) {
    if (preg_match("/ImageTopicSK/", $resultsns['Topics'][$key]['TopicArn'])) {
        $topicARN = $resultsns['Topics'][$key]['TopicArn'];
    }
}
//extra code
$resultsub = $sns->listSubscriptionsByTopic(array('TopicArn' => $topicARN));
foreach ($resultsub['Subscriptions'] as $key => $value) {
    if (preg_match($emailtemp, $resultsub['Subscriptions'][$key]['endpoint']) && preg_match("PendingConfirmation", $resultsub['Subscriptions'][$key]['SubscriptionArn'])) {
        $alertmsg = 'true';
        $_SESSION['alertmsg'] = $alertmsg;
    } else {
        $alertmsg = 'false';
        $_SESSION['alertmsg'] = $alertmsg;
    }
}
$uname = $_POST['firstname'];
$email = $_POST['useremail'];
$phoneforsms = $_POST['phone'];
$raws3url = $url;
$finisheds3url = $finishedurl;
$jpegfilename = basename($_FILES['userfile']['name']);
Exemplo n.º 2
0
if ($num_rows[0] > 0) {
    ##already in db assumed sub
    $uname = $_POST['username'];
    #$email = $_POST['useremail'];
    $phone = $_POST['phone'];
    $s3rawurl = $url;
    //  $result['ObjectURL']; from above
    $filename = basename($_FILES['userfile']['name']);
    $s3finishedurl = $finurl;
    $status = 0;
    $issubscribed = 0;
    mysqli_query($link, "INSERT INTO comments (ID, uname,email,phone,rs3URL,fs3URL,jpgfile,state,date) VALUES (NULL, '{$uname}', '{$email}', '{$phone}', '{$s3rawurl}', '{$s3finishedurl}', '{$filename}', '{$status}', NULL)");
    $results = $link->insert_id;
    ##echo $link->error;
    ##echo $results;
    $resultsubArns = $sn->listSubscriptionsByTopic(['TopicArn' => $AppArn]);
    print $resultsubArns;
    $resulstPub = $sn->publish(['Message' => 'An image has been posted to the gallery', 'TopicArn' => $AppArn]);
} else {
    #not in db add and send sns
    $resultSub = $sn->subscribe(['Endpoint' => $email, 'Protocol' => 'email', 'TopicArn' => $AppArn]);
    $uname = $_POST['username'];
    #$email = $_POST['useremail'];
    $phone = $_POST['phone'];
    $s3rawurl = $url;
    //  $result['ObjectURL']; from above
    $filename = basename($_FILES['userfile']['name']);
    $s3finishedurl = $finurl;
    $status = 0;
    $issubscribed = 0;
    mysqli_query($link, "INSERT INTO comments (ID, uname,email,phone,rs3URL,fs3URL,jpgfile,state,date) VALUES (NULL, '{$uname}', '{$email}', '{$phone}', '{$s3rawurl}', '{$s3finishedurl}', '{$filename}', '{$status}', NULL)");