function zopim_account_config() { global $usernameToCodeURL, $languagesURL, $current_user; ?> <div class="wrap"> <?php if (isset($_GET["action"]) && $_GET["action"] == "deactivate") { update_option('zopimSalt', ""); update_option('zopimCode', "zopim"); } $message = ""; $authenticated = ""; if (isset($_POST["action"]) && $_POST["action"] == "login") { if ($_POST["zopimUsername"] != "" && $_POST["zopimPassword"] != "") { $logindata = array("email" => $_POST["zopimUsername"], "password" => $_POST["zopimPassword"]); $loginresult = json_to_array(zopim_post_request(ZOPIM_LOGIN_URL, $logindata)); if (isset($loginresult->error)) { $error["login"] = "******"; $gotologin = 1; update_option('zopimSalt', "wronglogin"); } else { if (isset($loginresult->salt)) { update_option('zopimUsername', $_POST["zopimUsername"]); update_option('zopimSalt', $loginresult->salt); $account = getAccountDetails(get_option('zopimSalt')); $editor = setEditor(get_option('zopimSalt')); if (isset($account)) { update_option('zopimCode', $account->account_key); if (get_option('zopimGreetings') == "") { $jsongreetings = to_json($account->settings->greetings); update_option('zopimGreetings', $jsongreetings); } } } else { update_option('zopimSalt', ""); $error["login"] = "******"; } } } else { update_option('zopimSalt', "wronglogin"); $gotologin = 1; $error["login"] = "******"; } } else { if (isset($_POST["action"]) && $_POST["action"] == "signup") { $createdata = array("email" => $_POST["zopimnewemail"], "first_name" => $_POST["zopimfirstname"], "last_name" => $_POST["zopimlastname"], "display_name" => $_POST["zopimfirstname"] . " " . $_POST["zopimlastname"], "eref" => $_POST["zopimeref"], "source" => "wordpress", "recaptcha_challenge_field" => $_POST["recaptcha_challenge_field"], "recaptcha_response_field" => $_POST["recaptcha_response_field"]); $signupresult = json_to_array(zopim_post_request(ZOPIM_SIGNUP_URL, $createdata)); if (isset($signupresult->error)) { $message = "<div style='color:#c33;'>Error during activation: <b>" . $signupresult->error . "</b>. Please try again.</div>"; } else { if (isset($signupresult->account_key)) { $message = "<b>Thank you for signing up. Please check your mail for your password to complete the process. </b>"; $gotologin = 1; } else { $message = "<b>Could not activate account. The wordpress installation was unable to contact Zopim servers. Please check with your server administrator to ensure that <a href='http://www.php.net/manual/en/book.curl.php'>PHP Curl</a> is installed and permissions are set correctly.</b>"; } } } } if (get_option('zopimCode') != "" && get_option('zopimCode') != "zopim") { $accountDetails = getAccountDetails(get_option('zopimSalt')); if (!isset($accountDetails) || isset($accountDetails->error)) { $gotologin = 1; $error["auth"] = ' <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span>Account no longer linked!</span></h3> <div style="padding:10px;line-height:17px;"> We could not verify your Zopim account. Please check your password and try again. </div> </div> </div>'; } else { $authenticated = "ok"; } } if ($authenticated == "ok") { if ($accountDetails->package_id == "trial") { $accountDetails->package_id = "Free Lite Package + 14 Days Full-features"; } else { $accountDetails->package_id .= " Package"; } ?> <div id="icon-options-general" class="icon32"><br/></div><h2>Set up your Zopim Account</h2> <br/> <div style="background:#FFFEEB;padding:25px;border:1px solid #eee;"> <span style="float:right;"><a href="admin.php?page=zopim_account_config&action=deactivate">Deactivate</a></span> Currently Activated Account → <b><?php echo get_option('zopimUsername'); ?> </b> <div style="display:inline-block;margin-left:5px;background:#444;color:#fff;font-size:10px;text-transform:uppercase;padding:3px 8px;-moz-border-radius:5px;-webkit-border-radius:5px;"><?php echo ucwords($accountDetails->package_id); ?> </div> <!--<br><p><br>You can <a href="admin.php?page=zopim_customize_widget">customize</a> the chat widget, or <a href="admin.php?page=zopim_dashboard">launch the dashboard</a> for advanced features.--> <br><br>To start using Zopim chat, launch our dashboard for access to all features, including widget customization! <br><br><a href="<?php echo ZOPIM_DASHBOARD_LINK . "&username="******" style="text-decoration:none;" target="_blank" data-popup="true"><div class="zopim_btn_orange">Launch Dashboard</div></a> (This will open up a new browser tab) <form method="post" action="admin.php?page=zopim_account_config"> <?php if (isset($_POST['widget-options'])) { $opts = $_POST['widget-options']; update_option('zopimWidgetOptions', $opts); echo '<i>Widget options updated.<br/></i>'; } ?> <p> Optional code for customization with Zopim API: <br/> <textarea name="widget-options" style="width:680px; height: 200px;"><?php echo esc_textarea(zopim_get_widget_options()); ?> </textarea> <br/> <input class="button-primary" type="submit" value="Update widget options" /> </p> </form> </div> <?php } else { ?> <div id="icon-options-general" class="icon32"><br/></div><h2>Set up your Zopim Account</h2> <?php if (isset($error["auth"])) { echo $error["auth"]; } else { if ($message == "") { ?> Congratulations on successfully installing the Zopim WordPress plugin!<br> <br> <?php } else { echo $message; } } ?> <div id="existingform"> <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span>Link up with your Zopim account</span></h3> <div style="padding:10px;"> <?php if (isset($error["login"])) { echo '<span class="error">' . $error["login"] . '</span>'; } ?> <form method="post" action="admin.php?page=zopim_account_config"> <input type="hidden" name="action" value="login"> <table class="form-table"> <tr valign="top"> <th scope="row">Zopim Username (E-mail)</th> <td><input type="text" name="zopimUsername" value="<?php echo get_option('zopimUsername'); ?> " /></td> </tr> <tr valign="top"> <th scope="row">Zopim Password</th> <td><input type="password" name="zopimPassword" value="" /></td> </tr> <!--<tr valign="center"> <th scope="row">Use SSL</th> <td><input type="checkbox" name="zopimUseSSL" value="zopimUseSSL" <?php if (get_option('zopimUseSSL') == "zopimUseSSL") { echo "checked='checked'"; } ?> /> uncheck this if you are unable to login</td> </tr>--> </table> <br/> The Zopim chat widget will display on your blog after your account is linked up. <br/> <p class="submit"> <input id="linkup" type="submit" onclick="animateButton()" class="button-primary" value="<?php _e('Link Up'); ?> " /> Don't have a Zopim account? <a href="<?php echo ZOPIM_SIGNUP_REDIRECT_URL; ?> " target="_blank" data-popup="true">Sign up now</a>. </p> </form> </div> </div> </div> </div> </div> <?php } }
function setEditor($salt) { $salty = array("salt" => get_option('zopimSalt')); return json_to_array(zopim_post_request(ZOPIM_SETEDITOR_URL, $salty)); }
function getAccountDetails($salt) { $salty = array("salt" => get_option('zopimSalt')); return json_to_array(zopim_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty)); }
function zopim_instant_messaging() { ?> <div class="wrap"> <div id="icon-users" class="icon32"></div> <h2>Relay your messages</h2> Use your favourite Instant Messaging (IM) client to chat with your website visitors!<p> <?php $salt = array('salt' => get_option('zopimSalt')); if (isset($_GET["remove"]) && $_GET["remove"] == 1) { echo "Removed IM Set Up. <br><br>"; json_to_array(zopim_post_request(ZOPIM_IMREMOVE_URL, $salt)); } $iminfo = json_to_array(zopim_post_request(ZOPIM_IMINFO_URL, $salt)); if (isset($iminfo->bots)) { // Can set up IM ?> <style> td {} .clients td.first {border:none;background:#888;color:#fff;} .steps {width:100%} .steps td {background:#f9f9f9;padding:15px;} .clients td {padding:8px;border-top:1px solid #dfdfdf;background:#fff;} .clients {border:1px solid #dfdfdf;background:#fff} .explain { background:#FAFAFA; color:#667788; font-size:8pt; line-height:13px; margin:4px 0 0 0; padding:8px 3px; display: inline-block; } </style> <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span>Setting up your Chat Bots</span></h3> <div style="padding:10px 0px;line-height:17px;"> <table class="steps" cellspacing="0" cellpadding="0"> <tr valign="top"> <td style="border-right:5px solid #fff;width:394px;"> 1. Add the Control Bot to the IM Client of your choice.<br/><br/> <table class="clients" cellpadding="0" cellspacing="0"> <tr><td align="center" width="160" class="first"><b>IM Client</b></td><td class="first" width="200"><b>Chat Bot's Name</b></td></tr> <tr><td valign="center" align="center">Gtalk</td><td><?php echo $iminfo->bots->gtalk; ?> </td></tr> <tr><td valign="center" align="center">Yahoo</td><td><?php echo $iminfo->bots->yahoo; ?> </td></tr> <tr><td valign="center" align="center">AIM</td><td><?php echo $iminfo->bots->aim; ?> </td></tr> <tr><td valign="center" align="center">Microsoft</td><td><?php echo $iminfo->bots->msn; ?> </td></tr> </table> <div class="explain">For example, to use <b>Gtalk</b> to chat,<br/>add <b><?php echo $iminfo->bots->gtalk; ?> </b> to your Gtalk contact list.</div> </td> <td> 2. Send the Control Bot this message:<br/><br/><input style="font-size:31px;color:#555;margin:0 0 5px;width:380px;" type="text" value="#setup <?php echo $iminfo->auth_key; ?> " id="box-content" readonly></input><br/> <br/><br/> 3. Accept the invitations to add the Chat Bots.<br> <div class="explain">Depending on the number of Chat Bots available in your Package,<br/>you may need to accept up to 8 invitations</div> <br/><br/>That's all!<br/><br/> The Chat Bot will now relay all messages sent from<br/>your website to your IM Client. <br/><br/> Chat away! </td> </tr> </table> </div> </div> </div> <?php } else { if (isset($iminfo->status)) { // integration already set up ?> <h3><img src="<?php echo ZOPIM_IM_LOGOS . $iminfo->protocol; ?> .png"> Your <?php echo strtoupper($iminfo->protocol); ?> account is now linked with Zopim.</h3> You are connected using the account: <?php echo $iminfo->username; ?> . <br> Your status is now <b><?php echo $iminfo->status; ?> </b>.<br><br> <!-- <H3>Disable IM Integration</h3> You can <a href="admin.php?page=zopim_instant_messaging&remove=1">disable IM integration by clicking here</a>. --> <?php } else { // could not contact zopim to get the IM status if (get_option('zopimCode') != "zopim") { ?> <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span>Account not linked</span></h3> <div style="padding:10px;line-height:17px;"> Please <a href="admin.php?page=zopim_account_config">link your account / check your password</a> before setting up Chat Bots. </div> </div> </div> <?php } else { ?> <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span>Account not activated</span></h3> <div style="padding:10px;line-height:17px;"> Please <a href="admin.php?page=zopim_account_config">activate your account</a> before setting up Chat Bots. </div> </div> </div> <?php } } } }