Example #1
0
 } else {
     if (empty($_POST['email_box'])) {
         $ers['inviter'] = 'Inviter information missing !';
     }
     if (empty($_POST['oi_session_id'])) {
         $ers['session_id'] = 'No active session !';
     }
     if (empty($_POST['message_box'])) {
         $ers['message_body'] = 'Message missing !';
     } else {
         $_POST['message_box'] = strip_tags($_POST['message_box']);
     }
     $selected_contacts = array();
     $contacts = array();
     $message = array('subject' => $inviter->settings['message_subject'], 'body' => $inviter->settings['message_body'], 'attachment' => "\n\rAttached message: \n\r" . $_POST['message_box']);
     if ($inviter->showContacts()) {
         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];
                 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 !";
         }
     }
Example #2
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 #3
0
 function invit()
 {
     if (isset($_SESSION['user_id'])) {
         $user_id = $_SESSION['user_id'];
         $ers = array();
         $oks = array();
         $import_ok = false;
         if (isset($_POST['message']) && isset($_POST['friends_email'])) {
             $emails = explode(",", $_POST['friends_email']);
             $message = tools::filter($_POST['message']);
             foreach ($emails as $email) {
                 tools::sendMail($email, 'Invitation', $message);
             }
             $oks['emails_sent'] = "message(s) envoyé(s)";
         }
         include _DIR_ . '/tools/openinviter/openinviter.php';
         $inviter = new OpenInviter();
         $oi_services = $inviter->getPlugins();
         if (isset($_POST['provider_box'])) {
             if (isset($oi_services['email'][$_POST['provider_box']])) {
                 $plugType = 'email';
             } elseif (isset($oi_services['social'][$_POST['provider_box']])) {
                 $plugType = 'social';
             } else {
                 $plugType = '';
             }
         } else {
             $plugType = '';
         }
         if (isset($_POST['email_box']) && isset($_POST['password_box']) && isset($_POST['provider_box'])) {
             if (empty($_POST['email_box'])) {
                 $ers['email'] = "Email missing!";
             }
             if (empty($_POST['password_box'])) {
                 $ers['password'] = "******";
             }
             if (empty($_POST['provider_box'])) {
                 $ers['provider'] = "Provider missing!";
             }
             if (count($ers) == 0) {
                 $inviter->startPlugin($_POST['provider_box']);
                 $internal = $inviter->getInternalError();
                 if ($internal) {
                     $ers['inviter'] = $internal;
                 } elseif (!$inviter->login($_POST['email_box'], $_POST['password_box'])) {
                     $internal = $inviter->getInternalError();
                     $ers['login'] = $internal ? $internal : "Erreur lors de la connexion. Vérifiez votre email et votre mot de passe puis essayez de nouveau";
                 } elseif (false === ($contacts = $inviter->getMyContacts())) {
                     $ers['contacts'] = "Impossible d'importer les contacts!";
                 } else {
                     $import_ok = true;
                     $_POST['oi_session_id'] = $inviter->plugin->getSessionID();
                     $_POST['message_box'] = '';
                 }
             }
         }
         $contents = '';
         if ($import_ok) {
             if ($inviter->showContacts()) {
                 if (count($contacts) == 0) {
                     $contents .= "Vous n'avez pas de contacts dans votre carnet d'adresses";
                 } else {
                     foreach ($contacts as $email => $name) {
                         $contents .= "{$email}, ";
                     }
                 }
             }
         }
         $this->smarty->assign(array('contents' => $contents, 'import_ok' => $import_ok, 'errors' => $ers, 'success' => $oks, 'plugType' => $plugType, 'oi_services' => $oi_services));
         $this->smarty->display('user/invit.tpl');
     } else {
         tools::setFlash($this->l('Please log in to access this area'), 'error');
         tools::redirect('/user/login');
     }
 }
Example #4
0
$contents .= "<form action='' method='POST' name='openinviter'>" . '<br />' . ers($ers);
if (!$done) {
    if ($step == 'get_contacts') {
        $contents = $contents . "<table width='100%' align='center' style='border:none;'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td width=25%' align='right'>\r\n\t\t\t\t\t<label for='email_box'>" . JText::_('AUP_EMAIL') . "</label>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td width='75%'>\r\n\t\t\t\t\t<input class='thTextbox' type='text' name='email_box' value='{$_POST['email_box']}'>\r\n\t\t\t\t</td>\r\n\t\t\t</tr><td></td><td style='color:#999999; font-size:80%;'>" . JText::_('AUP_OI_DESCRIPTION_FIELD_EMAIL') . "</td></tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td width='25%' align='right'>\r\n\t\t\t\t\t<label for='password_box'>" . JText::_('AUP_PASSWORD') . "</label>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td width='75%'>\r\n\t\t\t\t\t<input class='thTextbox' type='password' name='password_box' value='{$_POST['password_box']}'>\r\n\t\t\t\t</td>\r\n\t\t\t</tr><td></td><td style='color:#999999;font-size:80%;'>" . JText::_('AUP_OI_DESCRIPTION_FIELD_PASSWORD') . "</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td width='25%' align='right'>\r\n\t\t\t\t\t<label for='provider_box'>" . JText::_('AUP_OI_ACCOUNT_WEBSITE') . "</label>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td width='75%'>\r\n\t\t\t\t\t<select class='thSelect' name='provider_box'><option value=''></option>";
        foreach ($oi_services as $type => $providers) {
            $contents .= "<option disabled>" . $inviter->pluginTypes[$type] . "</option>";
            foreach ($providers as $provider => $details) {
                $contents .= "<option value='{$provider}'" . ($_POST['provider_box'] == $provider ? ' selected' : '') . ">{$details['name']}</option>";
            }
        }
        $contents .= "</select>\r\n\t\t\t\t</td>\r\n\t\t\t</tr><td></td><td style='color:#999999;font-size:80%;'>" . JText::_('AUP_OI_DESCRIPTION_FIELD_ACCOUNT') . "</tr>\r\n\t\t\t<tr class='thTableImportantRow'>\r\n\t\t\t\t<td></td><td align='left'> <br />\r\n\t\t\t\t\t<input class='thButton' type='submit' name='import' value='" . JText::_('AUP_OI_IMPORT_CONTACTS') . "'>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t\t<input type='hidden' name='step' value='get_contacts'>";
    }
}
if (!$done) {
    if ($step == 'send_invites') {
        if (1 || $inviter->showContacts()) {
            $contents .= "<table width='100%' align='center'>\r\n\t\t\t<tr>\r\n\t\t\t\t<td style='background:#f6f6f6;' colspan='3'>\r\n\t\t\t\t\t" . JText::_('AUP_OI_FETCH_CONTACTS') . "\r\n\t\t\t\t</td>\r\n\t\t\t</tr>";
            if (count($contacts) == 0) {
                $contents .= "<tr><td  style='padding:20px;background:#FFCCFF;' colspan='3'>" . JText::_('AUP_OI_YOU_DONT_HAVE_ANY_CONTACTS') . "</td></tr>";
            } else {
                if ($provider == 'facebook' || $provider == 'linkedin') {
                    // facebook and linkedin does not allow you to import emails
                    $contents .= "<td colspan='3' style='padding:3px;'>\r\n\t\t\t\t\t<input type='submit' name='send_invites' value='" . JText::_('AUP_INVITE') . "'>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t<tr>\r\n\t\t\t\t<td style='background:#f6f6f6;'  width='15%'>\r\n\t\t\t\t\t<input type='checkbox' onChange='toggleAll(this)' name='toggle_all' title='" . JText::_('AUP_OI_SELECT_DESELECT_ALL') . "' checked>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td style='background:#f6f6f6;'  width='75%'>\r\n\t\t\t\t\t" . JText::_('AUP_NAME') . "\r\n\t\t\t\t</td>\r\n\t\t\t\t<td style='background:#f6f6f6;'  width='10%'>\r\n\t\t\t\t</td> </tr>";
                    $odd = true;
                    $counter = 0;
                    foreach ($contacts as $email => $name) {
                        $counter++;
                        $contents .= "<tr>\r\n\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<input name='check_{$counter}' value='{$counter}' type='checkbox' class='thCheckbox' checked>\r\n\t\t\t\t\t\t<input type='hidden' name='email_{$counter}' value='{$email}'>\r\n\t\t\t\t\t\t<input type='hidden' name='name_{$counter}' value='{$name}'>\r\n\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t<td>{$name}</td>\r\n\t\t\t\t\t\t<td></td></tr>";
                    }
                    $contents .= "<tr><td colspan='3' style='padding:3px;'>";
                    $contents .= "<input type='submit' name='send' value='" . JText::_('AUP_INVITE') . "'";