Ejemplo n.º 1
0
 public function info($type = 'admin')
 {
     parent::info();
     $cid = intval($this->input->get_post('cid'));
     $options = array();
     if ($cid > 0) {
         $options['where'] = array('cid' => $cid);
     }
     $item = $this->model->getOne($options, true);
     $this->parameters->fromArray(json_to_array($item['params']));
     $item['params'] = $this->parameters;
     $parents = array('顶级栏目');
     $where = array();
     if ($this->user_info->key != 'root') {
         $where = array('status >=' => 0);
     }
     $item['type'] = $item['type'] ? $item['type'] : $type;
     $options = array('type' => $item['type'], 'where' => $where, 'order' => " order_id desc,cid desc");
     $tree = new Tree();
     $tree->init($this->model->getAll2Array($options));
     foreach ($tree->getValueOptions() as $k => $tmp) {
         $parents[$k] = $tmp['title'];
     }
     $data = array('parents' => $parents, 'item' => $item);
     $this->_template('admin/setting/columinfo', $data);
 }
Ejemplo n.º 2
0
 public function sna_start()
 {
     $log_action = "sna_counting.cache";
     //抓取webpage_id
     $webpage_id = $this->get_current_webpage()->get_id();
     $query = $this->db->query("SELECT note " . "FROM log " . "WHERE log_timestamp > CURRENT_TIMESTAMP - INTERVAL '3 minutes' " . "AND webpage_id = " . $webpage_id . " " . "AND action_key = 'sna_counting.cache'");
     if ($query->num_rows() > 0) {
         $log_row = $query->row_array();
         $data = $log_row["note"];
         $data = json_to_array($data);
         return $data;
     } else {
         $usrlist = $this->create_user_list($webpage_id);
         $file = $this->create_file($usrlist, $webpage_id);
         $file_degree = $this->create_file_degree($usrlist, $webpage_id);
         $b_output = $this->count_betweenness($file);
         $d_output = $this->count_degree($file_degree);
         $ic_output = $this->count_incloseness($file);
         $id_output = $this->count_indegree($file);
         $od_output = $this->count_outdegree($file);
         $p_output = $this->count_pagerank($file);
         // $this->csv_to_r($files['file'], $files['file_degree'], $usrlist, $webpage_id);
         $data = $this->sna_tree($b_output, $d_output, $p_output, $od_output, $id_output, $ic_output, $usrlist, $webpage_id);
         return $data;
     }
 }
Ejemplo n.º 3
0
function hookForTree(&$array)
{
    $_ci =& get_instance();
    if (array_key_exists('params', $array)) {
        $_ci->parameters->fromArray(json_to_array($array['params']));
        $array['params'] = clone $_ci->parameters;
    }
}
Ejemplo n.º 4
0
 /**
  * (non-PHPdoc)
  * @see \Core\Service::_initRequestData()
  */
 protected function _initRequestData()
 {
     if (class_exists('\\HttpServer', false)) {
         $this->request_data = json_to_array(\HttpServer::$raw_data);
     } else {
         $this->request_data = json_to_array(file_get_contents('php://input'));
     }
 }
Ejemplo n.º 5
0
function json_to_array($web)
{
    $arr = array();
    foreach ($web as $k => $w) {
        if (is_object($w)) {
            $arr[$k] = json_to_array($w);
        } else {
            $arr[$k] = $w;
        }
    }
    return $arr;
}
Ejemplo n.º 6
0
 /**
  * Action範例
  * 
  * @param Array $data 由KALS_controller傳入的資料,組成是關連式的陣列
  * 
  * [Controller的JSON格式]
  * _data = {
  *  "field": "value"
  * };
  * 
  * //取用範例
  * _data["field];   //回傳value
  * 
  * [Model的Array格式]
  * $data = array(
  *  "field" => "value"
  * );
  * 
  * $data["field"];  //回傳value
  * 
  * @return Array 要回傳給KALS_controller的資料
  * 一樣是以關聯式陣列組成
  * 
  */
 public function open()
 {
     $webpage_id = $this->get_current_webpage()->get_id();
     $query = $this->db->query("SELECT note " . "FROM log " . "WHERE log_timestamp > CURRENT_TIMESTAMP - INTERVAL '3 minutes' " . "AND webpage_id = " . $webpage_id . " " . "AND action_key = 'sna_counting_good.cache'");
     if ($query->num_rows() > 0) {
         $log_row = $query->row_array();
         $data_good = $log_row["note"];
         $data_good = json_to_array($data_good);
         $usr_id = $this->get_current_user()->get_id();
         $query = $this->db->query('SELECT name FROM public.user WHERE user_id = ' . $usr_id);
         $row_name = $query->row_array();
         $who_to_react = array($row_name['name']);
         $query = $this->db->query('SELECT DISTINCT topic.user_id "user_topic" ' . 'FROM annotation topic ' . 'JOIN webpage2annotation USING (annotation_id) ' . 'JOIN annotation reply ' . 'ON topic.annotation_id = reply.topic_id ' . 'AND reply.topic_id IS NOT NULL ' . 'AND topic.deleted IS FALSE ' . 'AND reply.deleted IS FALSE ' . 'WHERE webpage_id = ' . $webpage_id . 'AND reply.user_id = ' . $usr_id);
         foreach ($query->result_array() as $row) {
             $query = $this->db->query('SELECT name FROM public.user WHERE user_id = ' . $row['user_topic']);
             $row_name = $query->row_array();
             array_push($who_to_react, $row_name['name']);
         }
         $tags = array_diff($data_good, $who_to_react);
         $tags2 = array_values($tags);
         if ($tags != NULL) {
             if (count($tags2) <= 3) {
                 $data["random_user"] = $tags2;
             } else {
                 $random_keys = array_rand($tags2, 3);
                 $tags3 = array();
                 $tags3[0] = $tags2[$random_keys[0]];
                 $tags3[1] = $tags2[$random_keys[1]];
                 $tags3[2] = $tags2[$random_keys[2]];
                 $data["random_user"] = $tags3;
             }
         } else {
             $data["random_user"] = $data_good;
         }
         return $data;
     } else {
         $rand_user_array = array("功能尚未開啟<br>");
         $data["random_user"] = $rand_user_array;
         return $data;
     }
 }
Ejemplo n.º 7
0
<?php

$key_pre = "e_{$table}";
$genders[0] = "男";
$genders[1] = "女";
$c_data = crf_ds_load('dyxx', $_SESSION['crf']['p_uid']);
$c_data = json_to_array($c_data);
//  print_r($c_data);
//print_r($hospital_name_arr);
?>
<table border="3">
  <tr>
    <td>&quot;中国慢性输血患者铁过载现状调研&quot;数据收集表</td>
    <td rowspan="2"><div align="center">筛选</div></td>
  </tr>
  <tr>
    <td>医院名称: 
      <?php 
global $user;
print $hospital_name_arr[$user->profile_hospital_no];
?>
    </td>
  </tr>
</table>
送样单位样本号(<?php 
print drupal_render($form[$key_pre . "_1_1"]);
?>
)
<table class="<?php 
print $class;
?>
Ejemplo n.º 8
0
function getAccountDetails($salt)
{
    $salty = array("salt" => get_option('zopimSalt'));
    return json_to_array(zopim_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
}
Ejemplo n.º 9
0
/**
 * 更新账目
 */
function update_bill()
{
    $userId = (int) $_SESSION['userId'];
    $op = $_REQUEST['op'];
    $billTypeFlag = (int) $_REQUEST['billTypeFlag'];
    $billId = is_empty($_REQUEST['billId']) ? null : (int) $_REQUEST['billId'];
    $billTime = $_REQUEST['billTime'];
    $billTypeId = is_empty($_REQUEST['billTypeId']) ? null : (int) $_REQUEST['billTypeId'];
    $accountId = (int) $_REQUEST['accountId'];
    $account2Id = is_empty($_REQUEST['account2Id']) ? null : $_REQUEST['account2Id'];
    $billSum = is_empty($_REQUEST['billSum']) ? null : (double) $_REQUEST['billSum'];
    $billDesc = is_empty($_REQUEST['billDesc']) ? null : $_REQUEST['billDesc'];
    $repayArray = is_empty($_REQUEST['repayArray']) ? null : $_REQUEST['repayArray'];
    $code = '0';
    if ($op == 'add') {
        $billId = -1;
    }
    $billService = new BillService();
    if ($op == 'add') {
        // 新增
        switch ($billTypeFlag) {
            case 0:
            case 1:
                $billService->insertNormalBill($userId, $billTypeFlag, $billTime, $billTypeId, $accountId, $billSum, $billDesc);
                break;
            case 2:
            case 3:
                $billService->insertTransferBill($userId, $billTypeFlag, $billTime, $billTypeId, $accountId, $account2Id, $billSum, $billDesc);
                break;
            case 5:
            case 6:
                $billService->insertDebtBill($userId, $billTypeFlag, $billTime, $billTypeId, $accountId, $account2Id, $billSum, $billDesc);
                break;
            case 4:
            case 7:
                $repayArray = json_to_array(urldecode($repayArray));
                //校验还款、收款合法性
                foreach ($repayArray as $repay) {
                    if ($billService->checkRepay((int) $repay['billId'], (double) $repay['repaySum']) == false) {
                        $code = 'mustRefreshRepayList';
                        break;
                    }
                }
                if ($code == '0') {
                    //插入还款、收款记录
                    foreach ($repayArray as $repay) {
                        $billService->insertRepayBill($userId, $billTypeFlag, $billTime, $accountId, $billDesc, (int) $repay['billId'], (double) $repay['repaySum']);
                    }
                }
                break;
        }
    } else {
        if ($op == 'edit') {
            // 修改
            switch ($billTypeFlag) {
                case 0:
                case 1:
                    $billService->updateNormalBill($userId, $billTypeFlag, $billId, $billTime, $billTypeId, $accountId, $billSum, $billDesc);
                    break;
                case 2:
                case 3:
                    $billService->updateTransferOutBill($userId, $billTypeFlag, $billId, $billTime, $billTypeId, $accountId, $account2Id, $billSum, $billDesc);
                    break;
                case 5:
                case 6:
                    //校验要修改的记录是否已经有了关联记录
                    if ($billService->countBillRepayRelated($billId) > 0) {
                        $code = 'existBillRelated';
                    } else {
                        $billService->updateDebtBill($userId, $billTypeFlag, $billId, $billTime, $billTypeId, $accountId, $account2Id, $billSum, $billDesc);
                    }
                    break;
                case 4:
                case 7:
                    $billService->updateRepayBill($userId, $billTypeFlag, $billId, $billTime, $accountId, $billSum, $billDesc);
                    break;
            }
        }
    }
    $output = array('retCode' => $code);
    echo get_json($output);
}
Ejemplo n.º 10
0
 function list_annotation($json, $callback = NULL)
 {
     $enable_profiler = FALSE;
     if ($enable_profiler === TRUE) {
         $this->output->enable_profiler(TRUE);
     }
     if (is_string($json)) {
         $data = json_to_object($json);
     } else {
         $data = $json;
     }
     $user = get_context_user();
     $url = $this->url;
     $search = new Search_annotation_collection();
     $search_id = null;
     if (isset($data->limit)) {
         $search_id = new Search_annotation_id_collection();
     }
     // 1 [ topic id ]
     if (isset($data->topic_id) && isset($data->target_topic) && $data->target_topic === TRUE) {
         $annotation = new Annotation($data->topic_id);
         $output_data = array('annotation_collection' => array($annotation->export_data()), 'totally_loaded' => true);
         return $this->_display_jsonp($output_data, $callback);
     } else {
         if (isset($data->topic_id) && isset($data->target_topic) && $data->target_topic === FALSE) {
             $search->set_target_topic_id($data->topic_id);
             if (isset($search_id)) {
                 $search_id->set_target_topic_id($data->topic_id);
             }
         }
     }
     // 2 [ scope ]
     //test_msg('2 [ scope ]', is_null($data->scope));
     //如果沒有設定範圍,則直接回傳空值
     //if (is_null($data->scope))
     //{
     //    //return $this->_create_null_list($callback);
     //}
     if (isset($data->scope)) {
         $scope_coll_data = $data->scope;
         //test_msg('2 [ scope ] 2', is_null($data->scope));
         $scope_coll = $this->annotation_scope_collection->import_webpage_search_data($url, $scope_coll_data);
         //test_msg($scope_coll->export_json());
         $search->set_overlap_scope($scope_coll);
         if (isset($search_id)) {
             $search_id->set_overlap_scope($scope_coll);
         }
         //test_msg('2 [ scope ] 3', is_null($data->scope));
     }
     // 3 [ target like ]
     // 4 [ target my ]
     //test_msg('3 [ target like ] 4 [ target my ]');
     if ((isset($data->target_like) or isset($data->target_my)) && is_null($user)) {
         return $this->_create_null_list($callback);
     }
     if (isset($data->target_like)) {
         $search->set_target_like($data->target_like, $user);
         if (isset($search_id)) {
             $search_id->set_target_like($data->target_like, $user);
         }
     }
     if (isset($data->target_my)) {
         if ($data->target_my === TRUE) {
             $search->set_target_user($user);
             if (isset($search_id)) {
                 $search_id->set_target_user($user);
             }
         } else {
             $search->set_exclude_user($user);
             if (isset($search_id)) {
                 $search_id->set_exclude_user($user);
             }
         }
     }
     // 5 [ target_topic ]
     if (isset($data->target_topic)) {
         $search->set_target_topic($data->target_topic);
         if (isset($search_id)) {
             $search_id->set_target_topic($data->target_topic);
         }
     }
     // 6 [ order by ]
     // 6 [ is_desc]
     //test_msg('6 [ order by ]', isset($data->order_by));
     //test_msg('6 [ order by ] direction', $data->direction);
     $order_id = 1;
     $default_direction = TRUE;
     if (isset($data->order_by)) {
         if ($data->order_by == 'update') {
             $order_id = 6;
             $default_direction = TRUE;
         } else {
             if ($data->order_by == 'create') {
                 $order_id = 7;
                 $default_direction = TRUE;
             } else {
                 // 依照分數排序
                 $order_id = 1;
                 $default_direction = TRUE;
             }
         }
     }
     if (isset($data->direction) && $data->direction == 'asc') {
         $default_direction = FALSE;
     }
     /*
     if (isset($data->order_by) === FALSE OR $data->order_by != 'update')
     {
         $order_id = 6;
         $default_is_desc = TRUE;
     }
     */
     //test_msg('6 [ order by ] add_oder', array($order_id, $default_is_desc));
     $search->add_order($order_id, $default_direction);
     //        if (isset($search_id)) {
     //            $search_id->add_order ($order_id, $default_direction);
     //        }
     // 7 [ offset ]
     //test_msg('7 [ offset ]', isset($data->offset));
     if (isset($data->offset)) {
         $search->set_offset($data->offset);
         //            if (isset($search_id)) {
         //                $search_id->set_offset($data->offset);
         //            }
     }
     // 8 [ limit ]
     //test_msg('8 [ limit ]', array(isset($data->limit),$data->limit));
     if (isset($data->limit)) {
         $search->set_limit($data->limit);
         //$search_id在此不作設限
     }
     $search->set_target_webpage(get_context_webpage());
     //輸出
     $totally_loaded = TRUE;
     if (isset($search_id)) {
         $totally_loaded = FALSE;
     }
     //不作limit的情況下讀完,表示完全讀取
     if (isset($search_id) && ($search->length() == $search_id->length() || $search->length() == 0)) {
         $totally_loaded = TRUE;
     }
     $annotation_collection = array();
     //test_msg('Search Length', $search->length());
     foreach ($search as $search_annotation) {
         $annotation_data = $search_annotation->export_webpage_data($url);
         if (isset($data->target_topic) && $data->target_topic === TRUE) {
             $search_data = json_to_object('{}');
             $search_data->target_topic = FALSE;
             $search_data->topic_id = $search_annotation->get_id();
             if (isset($data->respond_limit)) {
                 $search_data->limit = $data->respond_limit;
             }
             //$search_data->is_like = NULL;
             $search_data->order_by = 'create';
             if (isset($data->respond_direction)) {
                 $search_data->direction = $data->respond_direction;
             } else {
                 //$search_data->direction = "asc";
             }
             $search_data->show_total_count = TRUE;
             $search_result = $this->list_annotation($search_data);
             //test_msg($search_result);
             if (count($search_result['annotation_collection']) > 0) {
                 $annotation_data['respond_list'] = $search_result;
             }
         }
         array_push($annotation_collection, $annotation_data);
     }
     $output_data = array('annotation_collection' => $annotation_collection, 'totally_loaded' => $totally_loaded);
     if (isset($data->show_total_count) && $data->show_total_count === TRUE) {
         if (count($annotation_collection) === 0) {
             $output_data['total_count'] = 0;
         } else {
             if (isset($search_id)) {
                 $output_data['total_count'] = $search_id->length();
             } else {
                 $output_data['total_count'] = count($annotation_collection);
             }
         }
     }
     //log區
     $array_data = NULL;
     if (is_string($json)) {
         $array_data = json_to_array($json);
     } else {
         $array_data = (array) $json;
     }
     $user_id = NULL;
     if (isset($user)) {
         $user_id = $user->get_id();
     }
     $action = 12;
     if (isset($data->topic_id) && isset($data->target_topic) && $data->target_topic === FALSE && isset($data->limit) == FALSE) {
         $action = 16;
     }
     $do_log = TRUE;
     if (isset($data->limit) && $data->limit == 5) {
         $do_log = FALSE;
     }
     if (isset($data->target_my)) {
         if ($data->target_my == FALSE) {
             $do_log = FALSE;
         }
     } else {
         if ($user_id == NULL) {
             $action = 17;
             if (isset($data->topic_id) && isset($data->target_topic) && $data->target_topic === FALSE && isset($data->limit) == FALSE) {
                 $action = 18;
             }
         }
     }
     if ($do_log) {
         kals_log($this->db, $action, array('memo' => $array_data, 'user_id' => $user_id));
     }
     context_complete();
     if ($enable_profiler != TRUE) {
         return $this->_display_jsonp($output_data, $callback);
     }
 }
Ejemplo n.º 11
0
function setEditor($salt)
{
    $salty = array("salt" => get_option('zopimSalt'));
    return json_to_array(zopim_post_request(ZOPIM_SETEDITOR_URL, $salty));
}
Ejemplo n.º 12
0
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 
            }
        }
    }
}
Ejemplo n.º 13
0
 public function get_annotation($json, $callback)
 {
     $data = json_to_array($json);
     $annotation_id = $data["annotation_id"];
     //test_msg($annotation_id);
     $annotation = new Annotation($annotation_id);
     $data = array('annotation' => $annotation->export_data());
     $this->_display_jsonp($data, $callback);
 }
Ejemplo n.º 14
0
/**
 * Gets information about the givin user, searching results in the ldap server.
 * @global string $ldap_servers_cred_json_file path to the json file containing list of ldap servers for credentials
 * @param string $login the user we search info about
 * @return assoc_array|false
 */
function ldap_getinfo($login)
{
    global $ldap_servers_cred_json_file;
    $ldap_servers_cred = json_to_array($ldap_servers_cred_json_file);
    if (count($ldap_servers_cred) == 0) {
        return false;
    }
    //try go get user's full name
    $index = 0;
    $result = false;
    do {
        $link_identifier = private_ldap_connect($ldap_servers_cred, $index);
        // bind to ldap failed
        if ($link_identifier === false) {
            return false;
        }
        checkauth_last_error("");
        //bind succeeded, so try to get more info about the user
        $treepath = $ldap_servers_cred[$index]["base_dn"];
        $filter = str_replace("!LOGIN", $login, $ldap_servers_cred[$index]["filter"]);
        $search_res = ldap_search($link_identifier, $treepath, $filter);
        if (!$search_res) {
            //bind failed
            $errno = ldap_errno($link_identifier);
            $errstring = ldap_error($link_identifier);
            checkauth_last_error("{$errno}:{$errstring}:search into ldap failed");
        } else {
            //retrieve the result of the search
            $info = ldap_get_entries($link_identifier, $search_res);
            if ($info['count'] != 1) {
                checkauth_last_error("wrong search result count:" . $info['count']);
            }
            $userinfo = array();
            $userinfo['login'] = $login;
            //return login as normal login
            if (isset($info[0]['cn'][0])) {
                $userinfo['full_name'] = $info[0]['cn'][0];
                $result = true;
            }
            if (isset($info[0]['mail'][0])) {
                $userinfo['email'] = $info[0]['mail'][0];
            }
        }
        $index++;
    } while (!$result);
    return $userinfo;
}
Ejemplo n.º 15
0
	public function update_cart () {
		$param = $_REQUEST['paramStr'];
	    if(!empty($param)){
	        $param = trim($param);
	        $param = stripcslashes($param);
	        $param = json_decode($param);
	        $arr = json_to_array($param);
	        $msg = zy_flow_update_cart($arr);
	        jsonExit("{\"status\":\"$msg\"}");
	    }else{
	        $msg = rpcLang('flow.php', 'wrong_param');
	        jsonExit("{\"status\":\"$msg\"}");
	    }
	}
Ejemplo n.º 16
0
function getAccountDetails($salt)
{
    $salty = array("salt" => $salt);
    return json_to_array(do_post_request(ZOPIM_GETACCOUNTDETAILS_URL, $salty));
}
Ejemplo n.º 17
0
function get_languages()
{
    $langjson = '{"--":" - Auto Detect - ","ar":"Arabic","bn":"Bengali","bg":"Bulgarian","zh_CN":"Chinese (China)","zh_TW":"Chinese (Taiwan)","hr":"Croatian","cs":"Czech","da":"Danish","nl":"Dutch; Flemish","et":"Estonian","fo":"Faroese","fi":"Finnish","fr":"French","ka":"Georgian","de":"German","el":"Greek","he":"Hebrew","hu":"Hungarian","is":"Icelandic","id":"Indonesian","it":"Italian","ja":"Japanese","ko":"Korean","ku":"Kurdish","lv":"Latvian","lt":"Lithuanian","mk":"Macedonian","ms":"Malay","nb":"Norwegian Bokmal","fa":"Persian","pl":"Polish","pt":"Portuguese","pt_BR":"Portuguese (Brazil)","ro":"Romanian","ru":"Russian","sr":"Serbian","sk":"Slovak","sl":"Slovenian","es":"Spanish; Castilian","sv":"Swedish","th":"Thai","tr":"Turkish","uk":"Ukrainian","ur":"Urdu","vi":"Vietnamese"}';
    return json_to_array($langjson);
}
Ejemplo n.º 18
0
function json_to_array($web) {
    $arr = array();
    foreach ($web as $k => $w) {
        if (is_object($w))
            $arr[$k] = json_to_array($w); //判断类型是不是object
        else
            $arr[$k] = $w;
    }
    return $arr;
}
Ejemplo n.º 19
0
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 &rarr; <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>&nbsp;&nbsp;(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');
        ?>
" />
		&nbsp;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 
    }
}
Ejemplo n.º 20
0
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(do_post_request(ZOPIM_IMREMOVE_URL, $salt));
    }
    $iminfo = json_to_array(do_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 Cient</b></td><td class="first" width="200"><b>Chat Bot's Name</b></td></tr>
	 <tr><td valign="center" align="center"><img src="<?php 
        echo ZOPIM_IM_LOGOS;
        ?>
big/gtalk.png"></td><td><?php 
        echo $iminfo->bots->gtalk;
        ?>
</td></tr>
	 <tr><td valign="center" align="center"><img src="<?php 
        echo ZOPIM_IM_LOGOS;
        ?>
big/msn.png"></td><td><?php 
        echo $iminfo->bots->msn;
        ?>
</td></tr>
	 <tr><td valign="center" align="center"><img src="<?php 
        echo ZOPIM_IM_LOGOS;
        ?>
big/yahoo.png"></td><td><?php 
        echo $iminfo->bots->yahoo;
        ?>
</td></tr>
	 <tr><td valign="center" align="center"><img src="<?php 
        echo ZOPIM_IM_LOGOS;
        ?>
big/aim.png"></td><td><?php 
        echo $iminfo->bots->aim;
        ?>
</td></tr>
	 </table>
	 <div class="explain">For example, to use <b>MSN Live Messenger</b> to chat,<br/>add <b>zdctrlbot01@hotmail.com</b> to your MSN 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/>
<input id="copy" value="Copy to Clipboard" type="button"></input>

	<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>
	<script type="text/javascript" src="http://www.zopim.com/static/ZeroClipboard.js"></script>
	<script language="javascript">

//create client
	ZeroClipboard.setMoviePath('http://www.zopim.com/static/ZeroClipboard.swf');
	var clip = new ZeroClipboard.Client();

//event
function $(id) { return document.getElementById(id); }

clip.addEventListener('mousedown',function() {
	clip.setText(document.getElementById('box-content').value);
});
clip.addEventListener('complete',function(client,text) {
	window.status = 'copied: ' + text;
});
//glue it to the button
clip.glue('copy');
</script>

<?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 
            }
        }
    }
}