Пример #1
0
 $app->setCookie('album', $album);
 $app->setCookie('subscribe', $subscribe);
 // Make sure the Honey Pot field is empty.
 if (!empty($address)) {
     $app->flash('error', 'Your form submission has an error.');
     // Push them back to the main screen with generic error message
     $app->redirect($app->urlFor('home'));
 } elseif (!empty($code) && !empty($email)) {
     // Clean up the form submissions
     $cleanCode = filter_var($code, FILTER_SANITIZE_STRING);
     $cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL);
     $cleanAlbum = filter_var($album, FILTER_SANITIZE_STRING);
     // validate the email format
     $validEmail = filter_var($cleanEmail, FILTER_VALIDATE_EMAIL);
     // Validate the code entered
     $validCode = $dl->validate_code($album, $code);
     // Check if the code and email entered are valid
     if ($validEmail && $validCode === 200) {
         // Subscribe the user if they kept the subscribe option checked
         if ($subscribe) {
             $addUser = $mail->newsletterSignup($cleanEmail);
             print_r($addUser);
         }
         $albumInfo = $dl->get_album_info($cleanAlbum);
         // Send the verification email via Mandrill
         $verificationEmail = $mail->sendMail($cleanCode, $cleanEmail, $albumInfo['artist'], $album, $albumInfo['title'], $albumInfo['thumbnail']);
         // Make sure the email was received and properly sent
         if ($verificationEmail[0]['status'] === 'sent' || $verificationEmail[0]['status'] === 'queued') {
             // Redirect to the redeem download page
             $app->redirect('./redeem/' . $cleanAlbum . '/' . $cleanCode);
         } else {