Example #1
0
function openinviter_validation()
{
    global $services, $validation_displayed;
    if ($validation_displayed) {
        return;
    }
    $validation_displayed = true;
    $inviter = new OpenInviter();
    if (empty($inviter->settings['username']) or empty($inviter->settings['private_key'])) {
        return;
    }
    $display_openinviter = false;
    $ers = array();
    $oks = array();
    $procedure = '';
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        if (isset($_POST['inviter_submit'])) {
            $display_openinviter = true;
            $procedure = 'inviter';
            if (!empty($_POST['send_invites'])) {
                $step = 'send_invites';
            } else {
                $step = 'get_contacts';
            }
            if ($step == 'send_invites') {
                if (empty($_POST['inviter_service_box'])) {
                    $ers['service'] = __("Service missing");
                } else {
                    $inviter->startPlugin($_POST['inviter_service_box']);
                    if (empty($_POST['inviter_email_box'])) {
                        $ers['inviter'] = 'Inviter information missing';
                    }
                    if (empty($_POST['cookie_file'])) {
                        $ers['cookie'] = 'Could not find cookie file';
                    }
                    $settings = get_option('openinviter_settings');
                    global $openinviter_options;
                    $message = empty($settings['message_body']) ? $openinviter_options['message_body'] : $settings['message_body'];
                    $subject = empty($settings['message_subject']) ? $openinviter_options['message_subject'] : $settings['message_subject'];
                    $message = array('subject' => $subject, 'message' => $message);
                    $contacts = array();
                    $selected_contacts = array();
                    foreach ($_POST as $key => $val) {
                        if (strpos($key, 'check_') !== false) {
                            $selected_contacts[$_POST['email_' . $val]] = $_POST['name_' . $val];
                        } elseif (strpos($key, 'email_') !== false) {
                            $temp = explode('_', $key);
                            $counter = $temp[1];
                            $contacts[$val] = $_POST['name_' . $temp[1]];
                        }
                    }
                    if (count($selected_contacts) == 0) {
                        $ers['no_selected'] = __("You have not selected any contacts to invite");
                    }
                }
                if (count($ers) == 0) {
                    $sendMessage = $inviter->sendMessage($_POST['cookie_file'], $message, $selected_contacts);
                    $inviter->logout();
                    if ($sendMessage === -1) {
                        if (!function_exists("wp-mail")) {
                            require_once ABSPATH . 'wp-includes/pluggable.php';
                        }
                        $message_footer = "\r\n\r\nThis invite was sent using OpenInviter technology.";
                        $message_headers = 'From: "' . get_option('blogname') . '" <wordpress@' . get_option('siteurl') . '>';
                        $temp = $message . $message_footer;
                        foreach ($contacts as $email => $name) {
                            wp_mail($email, sprintf($subject, $_POST['inviter_email_box']), $temp, $message_headers);
                        }
                        $oks['sent'] = __("Invites sent successfully");
                    } elseif ($sendMessage === false) {
                        $ers['internal'] = "There were errors while sending your invites.<br>Please try again later!";
                    } else {
                        $oks['internal'] = "Invites sent successfully!";
                    }
                }
            } elseif ($step == 'get_contacts') {
                if (empty($_POST['inviter_email_box'])) {
                    $ers['email'] = __("Email missing");
                }
                if (empty($_POST['inviter_password_box'])) {
                    $ers['password'] = __("Password missing");
                }
                if (empty($_POST['inviter_service_box'])) {
                    $ers['service'] = __("Service missing");
                }
                if (count($ers) == 0) {
                    $inviter->startPlugin($_POST['inviter_service_box']);
                    $internal = $inviter->getInternalError();
                    if ($internal) {
                        $ers['inviter'] = $internal;
                    } elseif (!$inviter->login($_POST['inviter_email_box'], $_POST['inviter_password_box'])) {
                        $internal = $inviter->getInternalError();
                        $ers['login'] = $internal ? $internal : "Login failed. Please check the email and password you have provided and try again later";
                    } elseif (false === ($contacts = $inviter->getMyContacts())) {
                        $ers['contacts'] = __("Unable to get contacts.");
                    } else {
                        $inviter->stopPlugin(true);
                        $step = 'send_invites';
                        $_POST['cookie_file'] = $inviter->plugin->cookie;
                    }
                }
            }
        }
    }
    if ($display_openinviter !== false) {
        $title = get_option('openinviter_title');
        if (empty($title)) {
            global $openinviter_options;
            $title = $openinviter_options['title'];
        }
        $contents = "<br /><div style='width:90%;margin:0px auto;border:1px dashed black;background:white;color:black;'><center><h2 style='margin-top:5px;'>{$title}</h2></center>";
        if (count($ers) != 0) {
            $contents .= "<center>" . ers($ers) . "</center><br />";
        }
        if (count($oks) != 0) {
            $contents .= "<center>" . oks($oks) . "</center><br />";
        } elseif ($procedure == 'inviter' and $step = 'send_invites') {
            $contents .= "<form action='' method='POST'>\n\t\t\t\t<input type='hidden' name='inviter_service_box' value='{$_POST['inviter_service_box']}'>\n\t\t\t\t<input type='hidden' name='inviter_email_box' value='{$_POST['inviter_email_box']}'>\n\t\t\t\t<input type='hidden' name='cookie_file' value='{$_POST['cookie_file']}'>\n\t\t\t\t<input type='hidden' name='send_invites' value='send_invites'>\n\t\t\t\t<table align='center'>\n\t\t\t\t\t<tr><td colspan='2'>&nbsp;</td></tr>\n\t\t\t\t\t<tr><td colspan='2' align='center'><input type='submit' name='inviter_submit' value='" . __("Send Invites") . "' /></td></tr>";
            if ($inviter->showContacts()) {
                if (empty($contacts)) {
                    $ers['contacts'] = __("You do not have any contacts that you can invite!");
                    $contents .= "<center>" . ers($ers) . "</center><br />";
                } else {
                    $counter = 0;
                    foreach ($contacts as $email => $name) {
                        $counter++;
                        $contents .= "<tr><td><input type='checkbox' name='check_{$counter}' checked value='{$counter}' /><input type='hidden' name='name_{$counter}' value='{$name}' /><input type='hidden' name='email_{$counter}' value='{$name}' /></td><td>{$email}</td></tr>";
                    }
                    $contents .= "<tr><td colspan='2' align='center'><input type='submit' name='inviter_submit' value='" . __("Send Invites") . "' /></td></tr>";
                }
            }
            $contents .= "</table></form>";
        }
        $contents .= "</div>";
        echo $contents;
    }
}
Example #2
0
                 } elseif (strpos($key, 'email_') !== false) {
                     $temp = explode('_', $key);
                     $counter = $temp[1];
                     if (is_numeric($temp[1])) {
                         $contacts[$val] = $_POST['name_' . $temp[1]];
                     }
                 }
             }
             if (count($selected_contacts) == 0) {
                 $ers['contacts'] = "You haven't selected any contacts to invite !";
             }
         }
     }
 }
 if (count($ers) == 0) {
     $sendMessage = $inviter->sendMessage($_POST['oi_session_id'], $message, $selected_contacts);
     $inviter->logout();
     if ($sendMessage === -1) {
         $message_footer = "\r\n\r\nThis invite was sent using OpenInviter technology.";
         $message_subject = $_POST['email_box'] . $message['subject'];
         $message_body = $message['body'] . $message['attachment'] . $message_footer;
         $headers = "From: {$_POST['email_box']}";
         foreach ($selected_contacts as $email => $name) {
             mail($email, $message_subject, $message_body, $headers);
         }
         $oks['mails'] = "Mails sent successfully";
     } elseif ($sendMessage === false) {
         $internal = $inviter->getInternalError();
         $ers['internal'] = $internal ? $internal : "There were errors while sending your invites.<br>Please try again later!";
     } else {
         $oks['internal'] = "Invites sent successfully!";
Example #3
0
    $member = new Member($_POST['id'], $_SESSION['yel']['member']['sid']);
    $subject = htmlspecialchars_decode(urldecode($member->get_name())) . ' writing on behalf of Yellow Elevator - a job referral system';
    $header = 'From: ' . $_POST['username'] . "\n" . 'Reply-To: ' . $_POST['username'];
    $lines = file(dirname(__FILE__) . '/../private/mail/member_tell_a_friend.txt');
    $message = '';
    foreach ($lines as $line) {
        $message .= $line;
    }
    $message = str_replace('%member_name%', htmlspecialchars_decode(urldecode($member->get_name())), $message);
    $message = str_replace('%member_email_addr%', $_POST['username'], $message);
    $message = str_replace('%message%', stripslashes(urldecode($_POST['message'])), $message);
    $message = str_replace('%protocol%', $GLOBALS['protocol'], $message);
    $message = str_replace('%root%', $GLOBALS['root'], $message);
    $invitation = array('subject' => $subject, 'body' => $message);
    // send to social services
    $sendMessage = $inviter->sendMessage($_POST['oi_session_id'], $invitation, $contacts);
    $inviter->logout();
    // if not, send via email
    if ($sendMessage === -1) {
        foreach ($contacts as $email => $name) {
            mail($email, $subject, $message, $header);
        }
    } elseif ($sendMessage === false) {
        echo 'ko';
        exit;
    }
    echo 'ok';
    exit;
}
if ($_POST['action'] == 'get_contacts_from_vcard') {
    if (!isset($_FILES['my_file'])) {