zmodel = Mage::getModel('livechat/livechat')->load(1); $zoptions = $this->zmodel->_data; $salt = array('salt' => $zoptions["salt"]); // this removes im bots if ($this->getRequest()->getParam('remove')=="yes") { $this->do_post_request(ZOPIM_IMREMOVE_URL, $salt); $html = '

'; } $iminfo = Zend_Json::decode($this->do_post_request(ZOPIM_IMINFO_URL, $salt)); $html = '

Instant Messaging Integration

'; if (isset($iminfo["bots"])) { $html .= " "; // .$this->getRequest()->getParam('abc') $html .= '

Step 1: Add Control Bot to the IM Client of Choice

IM CientChat Bot Name
'.$iminfo["bots"]["gtalk"].'
'.$iminfo["bots"]["msn"].'
'.$iminfo["bots"]["yahoo"].'
'.$iminfo["bots"]["aim"].'
For example, to use MSN Live Messenger to chat,
add '.$iminfo["bots"]["msn"].' to your MSN contact list.

Step 2: Send Setup Message to Control Bot

'; $html .= " "; $html .= '

Step 3: Accept the invitations to add the chat bots

Depending on the number of Chat Bots available in your Package, you may need to accept up to 8 invitations. You\'re done!

'; } else if (isset($iminfo["status"])) { $html .= '

Successfully linked Zopim with your '.$iminfo["protocol"].' account.


Remove IM Integration
You are connected using the account: '.$iminfo["username"].'.
Your status is now '.$iminfo["status"].'.


'; } else { $html .= '

' ; } return $html; } private function curPageURL() { $pageURL = 'http'; if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; } $pageURL = preg_replace("/\?.*$/", "", $pageURL); return $pageURL; } private function do_post_request($url, $_data) { if ($this->zmodel->getUseSSL() != "zopimUseSSL") { $url = str_replace("https", "http", $url); } $data = array(); while(list($n,$v) = each($_data)){ $data[] = urlencode($n)."=".urlencode($v); } $data = implode('&', $data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return $response; } }