function eventGetContacts(EventControler $evtcl)
 {
     $plugType = 'email';
     $provider_box = $evtcl->provider_box;
     $email_box = $evtcl->email_box;
     $password_box = $evtcl->password_box;
     $msg = "";
     $contacts = "";
     $ok = false;
     if (empty($email_box)) {
         $msg = "Email missing !";
     }
     if (empty($password_box)) {
         $msg = "Password missing !";
     }
     if (empty($provider_box)) {
         $msg = "Provider missing !";
     }
     if ($msg == "") {
         $inviter = new OpenInviter();
         $inviter->startPlugin($provider_box);
         $internal = $inviter->getInternalError();
         if ($internal) {
             $msg = $internal;
         } elseif (!$inviter->login($email_box, $password_box)) {
             $internal = $inviter->getInternalError();
             $msg = $internal ? $internal : "Login failed. Please check the email and password you have provided and try again later !";
         } elseif (false === ($contacts = $inviter->getMyContacts())) {
             $msg = "Unable to get contacts !";
         } else {
             $msg = "Contacts imported successfully.";
             $ok = true;
             //$_POST['oi_session_id']=$inviter->plugin->getSessionID();
         }
     }
     if ($ok) {
         /*print_r($contacts);
         		exit();*/
         foreach ($contacts as $email => $name) {
             $do_contact = new Contact();
             $do_contact->firstname = $name;
             $do_contact->iduser = $_SESSION['do_User']->iduser;
             $do_contact->add();
             $lastInsertedContId = $do_contact->getPrimaryKeyValue();
             $do_contact->addEmail($email, 'Home');
             $do_contact->free();
             //contact view
             $do_cv = new ContactView();
             $do_cv->idcontact = $lastInsertedContId;
             $do_cv->firstname = $name;
             $do_cv->email_address = $email;
             $do_cv->add();
             $do_cv->free();
         }
     }
     $_SESSION['in_page_message'] = $msg;
 }
 /**
  * Getting list of e-mail addresses from email providers using openinviter
  *
  * @return  list of e-mail addresses with checkbox as string
  * @access public
  */
 function contactlist()
 {
     $errors = array();
     $contacts = array();
     App::import('Vendor', 'OpenInviter', array('file' => 'openinviter.php'));
     $inviter = new OpenInviter();
     $oi_services = $inviter->getPlugins();
     $inviter->startPlugin($this->data['openinviter']['provider_box']);
     $internal = $inviter->getInternalError();
     if ($internal) {
         $errors['inviter'] = $internal;
     } elseif (!$inviter->login($this->data['openinviter']['email_box'], $this->data['openinviter']['password_box'])) {
         $internal = $inviter->getInternalError();
         $errors['login'] = $internal ? $internal : "Login failed. Please check the email and password you have provided and try again later";
     } elseif (false === ($contacts = $inviter->getMyContacts())) {
         $errors['contacts'] = "Unable to get contacts.";
     }
     $this->set(compact('contacts'));
     $this->set('sender', $this->data['openinviter']['email_box']);
     $this->set(compact('errors'));
     return;
 }
Beispiel #3
0
     }
     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 : "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 {
             $import_ok = true;
             $step = 'send_invites';
             $_POST['oi_session_id'] = $inviter->plugin->getSessionID();
             $_POST['message_box'] = '';
         }
     }
 } elseif ($step == 'send_invites') {
     if (empty($_POST['provider_box'])) {
         $ers['provider'] = 'Provider missing !';
     } else {
         $inviter->startPlugin($_POST['provider_box']);
         $internal = $inviter->getInternalError();
         if ($internal) {
Beispiel #4
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');
     }
 }
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;
    }
}
 public function processmailAction()
 {
     $ers = array();
     $inviter = new OpenInviter();
     $oi_services = $inviter->getPlugins();
     $email_box = $this->getRequest()->getPost('email_box');
     $password_box = $this->getRequest()->getPost('password_box');
     $provider_box = $this->getRequest()->getPost('provider_box');
     $inviter->startPlugin($provider_box);
     $internal = $inviter->getInternalError();
     if ($internal) {
         $ers['inviter'] = $internal;
     } elseif (!$inviter->login($email_box, $password_box)) {
         $internal = $inviter->getInternalError();
         $ers['login'] = $internal ? $internal : $this->__("Login failed. Please check the email and password you have provided and try again later !");
     } elseif (false === ($contacts = $inviter->getMyContacts())) {
         $ers['contacts'] = $this->__("Unable to get contacts !");
     } else {
         $this->loadLayout();
         $this->_initLayoutMessages('customer/session');
         $this->renderLayout();
     }
     if (sizeof($ers)) {
         $err = implode("<br>", $ers);
         $this->_getSession()->addError($this->__("%s<br>", $err));
         $this->_redirect('rewardpoints/invitation/loginmail');
     }
 }
Beispiel #7
0
 function get_contacts($email, $pass, $provider)
 {
     global $database, $session, $form;
     traceCalls(__METHOD__, __LINE__);
     $path = getEditablePath('error.php');
     include_once "editables/" . $path;
     if (!$provider) {
         $form->setError("emailError", $lang['error']['empty_provider']);
         return 0;
     }
     if (!$email || strlen($email = trim($email)) < 1) {
         $form->setError("emailError", $lang['error']['empty_email']);
         return 0;
     }
     if (!eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\\.[a-z]{2,4}\$", trim($email))) {
         $form->setError("emailError", $lang['error']['invalid_email']);
         return 0;
     }
     if (!$pass || strlen($pass) < 1) {
         $form->setError("emailError", $lang['error']['empty_password']);
         return 0;
     }
     if ($form->num_errors == 0) {
         include 'inviter/openinviter.php';
         $inviter = new OpenInviter();
         $oi_services = $inviter->getPlugins();
         $inviter->startPlugin($provider);
         $internal = $inviter->getInternalError();
         if ($internal) {
             $form->setError("emailError", $lang['error']['error_occure']);
             return 0;
         } elseif (!$inviter->login($email, $pass)) {
             $form->setError("emailError", $lang['error']['invalid_userpass']);
             return 0;
         } elseif (false === ($contacts = $inviter->getMyContacts())) {
             echo "Unable to get contacts ! Please try again";
             return 0;
         }
         $_SESSION['contacts'] = $contacts;
         return 1;
     }
 }
 public function fetch_invites_contacts($email, $password, $provider)
 {
     //echo $email.', '.$password.', '.$provider;die;
     $this->layout = '';
     set_time_limit(0);
     include_once '../Vendor/open_inviter/openinviter.php';
     $err_msg = '';
     $fetchedEmails = '';
     $inviter = new OpenInviter();
     $startPlugin = $inviter->startPlugin($provider);
     if ($startPlugin) {
         // if plugin started
         $login = $inviter->login($email, $password);
         if ($login) {
             //login the user
             $contacts = $inviter->getMyContacts();
             if ($contacts) {
                 foreach ($contacts as $key => $val) {
                     $fetchedEmails[$key] = $key;
                 }
             } else {
                 $err_msg = 'Unable to Fetch Contacts!';
             }
         } else {
             $err_msg = 'Invalid Login Email or Password';
         }
     } else {
         $err_msg = 'Plugin Error!';
     }
     return $fetchedEmails;
 }
$provider = $argv[3];
$inviter->startPlugin($provider);
$internal_error = $inviter->getInternalError();
if ($internal_error) {
   echo "error: " . $internal_error;
}
else {
   if (!$inviter->login($argv[1],$argv[2])) {
      $internal_error = $inviter->getInternalError();
      if ($internal_error) {
         echo "error: " . $internal_error;
      }
      else {
         echo "error: login error\n";
      }
   }
   else {
     $contacts=$inviter->getMyContacts();
     foreach ($contacts as $contact => $name) {
        if ($contact == $contacts[$contact]) {
          echo $contact . ",\n";
        }
        else {
          echo $contact . "," . $contacts[$contact] . "\n";
        }
     }
   }
}
?>
Beispiel #10
0
 $oi_services = $inviter->getPlugins();
 $plug_type = 'email';
 if (isset($oi_services['social'][$_POST['oi_service']])) {
     $plug_type = 'social';
 }
 $inviter->startPlugin($_POST['oi_service']);
 $internal_errors = $inviter->getInternalError();
 if ($internal_errors) {
     echo '-1';
     exit;
 }
 if (!$inviter->login($_POST['username'], $_POST['password'])) {
     echo '-2';
     exit;
 }
 if (($raw_contacts = $inviter->getMyContacts()) === false) {
     echo '-3';
     exit;
 }
 $contacts = array();
 $i = 0;
 foreach ($raw_contacts as $key => $value) {
     $contacts[$i]['email'] = $key;
     $contacts[$i]['name'] = $value;
     $contacts[$i]['index'] = $i;
     $i++;
 }
 $_SESSION['yel']['member'][$_POST['id']]['contacts'] = $contacts;
 $response = array('openinviter' => array('sessionid' => $inviter->plugin->getSessionID(), 'plugin_type' => $plug_type, 'contacts' => $contacts));
 header('Content-type: text/xml');
 echo $xml_dom->get_xml_from_array($response);