} 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!"; } $done = true; } } } else { $_POST['email_box'] = ''; $_POST['password_box'] = ''; $_POST['provider_box'] = ''; } $contents = "<script type='text/javascript'>\r\n\tfunction toggleAll(element) \r\n\t{\r\n\tvar form = document.forms.openinviter, z = 0;\r\n\tfor(z=0; z<form.length;z++)\r\n\t\t{\r\n\t\tif(form[z].type == 'checkbox')\r\n\t\t\tform[z].checked = element.checked;\r\n\t \t}\r\n\t}\r\n</script>"; $contents .= "<form action='' method='POST' name='openinviter'>" . ers($ers) . oks($oks); if (!$done) { if ($step == 'get_contacts') { $contents .= "<table align='center' class='thTable' cellspacing='2' cellpadding='0' style='border:none;'>\r\n\t\t\t<tr class='thTableRow'><td align='right'><label for='email_box'>Email</label></td><td><input class='thTextbox' type='text' name='email_box' value='{$_POST['email_box']}'></td></tr>\r\n\t\t\t<tr class='thTableRow'><td align='right'><label for='password_box'>Password</label></td><td><input class='thTextbox' type='password' name='password_box' value='{$_POST['password_box']}'></td></tr>\r\n\t\t\t<tr class='thTableRow'><td align='right'><label for='provider_box'>Email provider</label></td><td><select class='thSelect' name='provider_box'><option value=''></option>"; foreach ($oi_services as $type => $providers) { $contents .= "<optgroup label='{$inviter->pluginTypes[$type]}'>"; foreach ($providers as $provider => $details) { $contents .= "<option value='{$provider}'" . ($_POST['provider_box'] == $provider ? ' selected' : '') . ">{$details['name']}</option>"; } $contents .= "</optgroup>"; } $contents .= "</select></td></tr>\r\n\t\t\t<tr class='thTableImportantRow'><td colspan='2' align='center'><input class='thButton' type='submit' name='import' value='Import Contacts'></td></tr>\r\n\t\t</table><input type='hidden' name='step' value='get_contacts'>"; } else { $contents .= "<table class='thTable' cellspacing='0' cellpadding='0' style='border:none;'>\r\n\t\t\t\t<tr class='thTableRow'><td align='right' valign='top'><label for='message_box'>Message</label></td><td><textarea rows='5' cols='50' name='message_box' class='thTextArea' style='width:300px;'>{$_POST['message_box']}</textarea></td></tr>\r\n\t\t\t\t<tr class='thTableRow'><td align='center' colspan='2'><input type='submit' name='send' value='Send Invites' class='thButton' ></td></tr>\r\n\t\t\t</table>"; } }
if (empty($_POST['user_box'])) { $ers['user'] = "******"; } elseif ($_POST['user_box'] != $oi->settings['stats_user']) { $ers['user'] = "******"; } if (empty($_POST['password_box'])) { $ers['password'] = "******"; } elseif ($_POST['password_box'] != $oi->settings['stats_password']) { $ers['password'] = "******"; } if (count($ers) == 0) { $_SESSION['_oi_isLogged'] = $hash; header("Location: stats.php"); exit; } else { echo ers($ers); } } else { $_POST['user_box'] = ''; $_POST['password_box'] = ''; } echo showStyles(); echo "<body><table align='center'><tr><td align='center'><form method='POST' action='?'>\r\n\t\t<table>\r\n\t\t\t<tr class='tableHeader'><td colspan='2' align='center'>Login</td></tr>\r\n\t\t\t<tr class='tableOddRow'><td><label>User:</label></td><td><input type='text' name='user_box' value='{$_POST['user_box']}'></td></tr>\r\n\t\t\t<tr class='tableEvenRow'><td><label>Password:</label></td><td><input type='password' name='password_box' value=''></td></tr>\r\n\t\t\t<tr class='tableFooter'><td colspan='2'><input type='submit' value='Login'></td></tr>\r\n\t\t</table>\r\n\t</form></td><tr><table>\r\n\t"; exit; } echo showStyles(); if (isset($_GET['op'])) { if ($_GET['op'] == 'reset') { $oi->statsQuery("DELETE FROM oi_imports"); $oi->statsQuery("DELETE FROM oi_messages"); }
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'> </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; } }
/** * Invite throught social * * @static * @param string Sender name * @param boolean HTML/TXT format * @param string Email subject * @param string Email body * @param array Associative array of recipients (name, mail) * @param array Associative array of attachments (file) * @return boolean */ public static function invite() { X4Core::auto_load('inviter'); $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 = ''; } function ers($ers) { if (!empty($ers)) { $contents = '<div id="msg"><p>'; foreach ($ers as $key => $error) { $contents .= $error . '<br >'; } $contents .= '</p></div>'; return $contents; } } function oks($oks) { if (!empty($oks)) { $contents = '<div id="msg"><p>'; foreach ($oks as $key => $msg) { $contents .= $msg . '<br >'; } $contents .= '</p></div>'; return $contents; } } if (!empty($_POST['step'])) { $step = $_POST['step']; } else { $step = 'get_contacts'; } $ers = array(); $oks = array(); $import_ok = false; $done = false; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($step == 'get_contacts') { if (empty($_POST['email_box'])) { $ers['email'] = _X4OI_INVITER_MISSING; } if (empty($_POST['password_box'])) { $ers['password'] = _X4OI_PASSWORD_MISSING; } if (empty($_POST['provider_box'])) { $ers['provider'] = _X4OI_PROVIDER_EMPTY; } 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 : _X4OI_LOGIN_FAILED; } elseif (false === ($contacts = $inviter->getMyContacts())) { $ers['contacts'] = _X4OI_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'] = _X4OI_PROVIDER_MISSING; } else { $inviter->startPlugin($_POST['provider_box']); $internal = $inviter->getInternalError(); if ($internal) { $ers['internal'] = $internal; } else { if (empty($_POST['email_box'])) { $ers['inviter'] = _X4OI_INVITER_MISSING; } if (empty($_POST['oi_session_id'])) { $ers['session_id'] = _X4OI_NO_ACTIVE_SESSION; } if (empty($_POST['message_box'])) { $ers['message_body'] = _X4OI_MSG_MISSING; } else { $_POST['message_box'] = strip_tags($_POST['message_box']); $_POST['message_box'] = mb_convert_encoding($_POST['message_box'], 'ISO-8859-1', 'auto'); } $selected_contacts = array(); $contacts = array(); $message = array('subject' => _X4OI_SUBJECT, 'body' => _X4OI_BODY, 'attachment' => "\n\r" . _X4OI_ATTACHED_MSG . ": \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'] = _X4OI_NO_RECIPIENTS; } } } } if (count($ers) == 0) { $sendMessage = $inviter->sendMessage($_POST['oi_session_id'], $message, $selected_contacts); $inviter->logout(); if ($sendMessage === -1) { $message_footer = "\r\n\r\n" . _X4OI_FOOTER; $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'] = _X4OI_SENT_SUCCESSFULLY; } elseif ($sendMessage === false) { $internal = $inviter->getInternalError(); $ers['internal'] = $internal ? $internal : _X4OI_ERROR; } else { $oks['internal'] = _X4OI_SUCCESSFULLY; } $done = true; } } } else { $_POST['email_box'] = ''; $_POST['password_box'] = ''; $_POST['provider_box'] = ''; } $out = '<script type="text/javascript"> function toggleAll(element) { var form = document.forms.openinviter, z = 0; for(z=0; z<form.length;z++) { if(form[z].type == \'checkbox\') form[z].checked = element.checked; } } </script>'; $out .= ers($ers) . oks($oks) . '<form action="" method="POST" id="openinviter" name="openinviter"><fieldset>'; if (!$done) { if ($step == 'get_contacts') { $out .= '<label for="email_box">' . _X4OI_EMAIL . '</label> <input class="thTextbox" type="text" name="email_box" value="' . $_POST['email_box'] . '"> <label for="password_box">' . _X4OI_PASSWORD . '</label> <input class="thTextbox" type="password" name="password_box" value="' . $_POST['password_box'] . '"> <label for="provider_box">' . _X4OI_PROVIDER . '</label> <select class="thSelect" name="provider_box"><option value=""></option>'; foreach ($oi_services as $type => $providers) { $out .= '<optgroup label="' . $inviter->pluginTypes[$type] . '">'; foreach ($providers as $provider => $details) { $out .= '<option value="' . $provider . '" ' . ($_POST['provider_box'] == $provider ? ' selected="selected"' : '') . '>' . $details['name'] . '</option>'; } $out .= '</optgroup>'; } $out .= '</select> <div class="acenter"><button type="submit" name="import"></button></div> <input type="hidden" name="step" value="get_contacts">'; } else { $out .= '<label for="message_box">' . _X4OI_MSG . '</label> <textarea name="message_box">' . $_POST['message_box'] . '</textarea> <div class="acenter"><button type="submit" name="send"></button></div>'; } } //$contents.="<center><a href='http://openinviter.com/'><img src='http://openinviter.com/images/banners/banner_blue_1.gif?nr=56914' border='0' alt='Powered by OpenInviter.com' title='Powered by OpenInviter.com'></a></center>"; if (!$done) { if ($step == 'send_invites') { if ($inviter->showContacts()) { $out .= '<br /><h2>' . _X4OI_CONTACTS . '</h2>'; if (empty($contacts)) { $out .= '<h3>' . _X4OI_NO_CONTACTS . '</h3>'; } else { $out .= '<label for="toggle_all"><input class="check" type="checkbox" onChange="toggleAll(this)" name="toggle_all" title="Select/Deselect all" checked="checked" /> ' . _X4OI_SELECT_ALL . '</label>'; $counter = 0; foreach ($contacts as $email => $name) { $counter++; $mail = $plugType == 'email' && $email != $name ? $email : ''; $out .= '<label for="check_' . $counter . '"><input name="check_' . $counter . '" value="' . $counter . '" type="checkbox" class="check" checked="checked" /> ' . $name . ' ' . $mail . ' <input type="hidden" name="email_' . $counter . '" value="' . $email . '" /> <input type="hidden" name="name_' . $counter . '" value="' . $name . '" /></label>'; } $out .= '<div class="acenter"><button type="submit" name="send"></button></div>'; } } $out .= '<input type="hidden" name="step" value="send_invites" /> <input type="hidden" name="provider_box" value="' . $_POST['provider_box'] . '" /> <input type="hidden" name="email_box" value="' . $_POST['email_box'] . '" /> <input type="hidden" name="oi_session_id" value="' . $_POST['oi_session_id'] . '" />'; } } $out .= '</fieldset></form>'; return $out; }
} else { $import_ok = true; $step = 'send_invites'; $provider = $_POST['provider_box']; $_POST['oi_session_id'] = $inviter->plugin->getSessionID(); $_POST['message_box'] = ''; } } } } else { $_POST['email_box'] = ''; $_POST['password_box'] = ''; $_POST['provider_box'] = ''; } $contents = "<script type='text/javascript'>\r\n\tfunction toggleAll(element) \r\n\t{\r\n\tvar form = document.forms.openinviter, z = 0;\r\n\tfor(z=0; z<form.length;z++)\r\n\t\t{\r\n\t\tif(form[z].type == 'checkbox')\r\n\t\t\tform[z].checked = element.checked;\r\n\t \t}\r\n\t}\r\n</script>"; $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()) {
} elseif ($sendMessage === false) { $internal = $inviter->getInternalError(); $ers['internal'] = $internal ? $internal : $L['oi_errors_found']; } else { $oks['internal'] = $L['oi_invites_sent']; } $done = true; } } } else { $_POST['email_box'] = ''; $_POST['password_box'] = ''; $_POST['provider_box'] = ''; } $t1 = new XTemplate(cot_tplfile('openinviter.body', 'plug')); ers($ers, $t1); oks($oks, $t1); if (!$done) { if ($step == 'get_contacts') { $t1->assign(array('GET_EMAIL_BOX' => htmlspecialchars($_POST['email_box']), 'GET_PASSWORD_BOX' => htmlspecialchars($_POST['password_box']))); foreach ($oi_services as $type => $providers) { $t1->assign('GET_SERVICE_TYPE', htmlspecialchars($inviter->pluginTypes[$type])); foreach ($providers as $provider => $details) { $selected = $_POST['provider_box'] == $provider ? ' selected' : ''; $t1->assign(array('GET_SERVICE_PROVIDER_VAL' => htmlspecialchars($provider), 'GET_SERVICE_PROVIDER_SEL' => $selected, 'GET_SERVICE_PROVIDER_NAME' => $details['name'])); $t1->parse('MAIN.GET.GET_SERVICE.GET_SERVICE_PROVIDER'); } $t1->parse('MAIN.GET.GET_SERVICE'); } $t1->parse('MAIN.GET'); } else {