当前位置: 首页>>代码示例>>PHP>>正文


PHP CJs::decodeJson方法代码示例

本文整理汇总了PHP中CJs::decodeJson方法的典型用法代码示例。如果您正苦于以下问题:PHP CJs::decodeJson方法的具体用法?PHP CJs::decodeJson怎么用?PHP CJs::decodeJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CJs的用法示例。


在下文中一共展示了CJs::decodeJson方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doAction

 protected function doAction()
 {
     foreach (CJs::decodeJson($this->getInput('grid')) as $col => $column) {
         foreach ($column as $row => $widgetName) {
             $widgetName = str_replace('_widget', '', $widgetName);
             CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT);
             CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT);
         }
     }
     $data = ['main_block' => ''];
     $response = new CControllerResponseData($data);
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:13,代码来源:CControllerDashboardSort.php

示例2: dirname

** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
require_once dirname(__FILE__) . '/include/func.inc.php';
require_once dirname(__FILE__) . '/include/classes/class.chttp_request.php';
$allowed_content = array('application/json-rpc' => 'json-rpc', 'application/json' => 'json-rpc', 'application/jsonrequest' => 'json-rpc');
$http_request = new CHTTP_request();
$content_type = $http_request->header('Content-Type');
$content_type = explode(';', $content_type);
$content_type = $content_type[0];
if (!isset($allowed_content[$content_type])) {
    header('HTTP/1.0 412 Precondition Failed');
    exit;
}
require_once dirname(__FILE__) . '/include/classes/core/Z.php';
header('Content-Type: application/json');
$data = $http_request->body();
try {
    Z::getInstance()->run(ZBase::EXEC_MODE_API);
    $jsonRpc = new CJSONrpc($data);
    echo $jsonRpc->execute();
} catch (Exception $e) {
    // decode input json request to get request's id
    $jsonData = CJs::decodeJson($data);
    $response = array('jsonrpc' => '2.0', 'error' => array('code' => 1, 'message' => $e->getMessage()), 'id' => isset($jsonData['id']) ? $jsonData['id'] : null);
    echo CJs::encodeJson($response);
}
开发者ID:hujingguang,项目名称:work,代码行数:31,代码来源:api_jsonrpc.php

示例3: zbx_empty

    $dashconf['severity'] = zbx_empty($severity) ? null : explode(';', $severity);
    $dashconf['severity'] = zbx_toHash($dashconf['severity']);
    $config = select_config();
    $dashconf['extAck'] = $config['event_ack_enable'] ? CProfile::get('web.dashconf.events.extAck', 0) : 0;
}
/*
 * Actions
 */
if (isset($_REQUEST['favobj'])) {
    $_REQUEST['pmasterid'] = get_request('pmasterid', 'mainpage');
    if ($_REQUEST['favobj'] == 'hat') {
        if ($_REQUEST['favaction'] == 'flop') {
            $widgetName = substr($_REQUEST['favref'], 4);
            CProfile::update('web.dashboard.widget.' . $widgetName . '.state', $_REQUEST['favstate'], PROFILE_TYPE_INT);
        } elseif (getRequest('favaction') == 'sort') {
            $favdata = CJs::decodeJson(getRequest('favdata'));
            foreach ($favdata as $col => $column) {
                foreach ($column as $row => $widgetName) {
                    $widgetName = substr($widgetName, 4, -7);
                    CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT);
                    CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT);
                }
            }
        } elseif ($_REQUEST['favaction'] == 'refresh') {
            switch ($_REQUEST['favref']) {
                case 'hat_syssum':
                    $syssum = make_system_status($dashconf);
                    $syssum->show();
                    break;
                case 'hat_hoststat':
                    $hoststat = make_hoststat_summary($dashconf);
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:dashboard.php

示例4: request

 /**
  * Executes a given JSON request and returns the result. Returns false if an error has occurred.
  *
  * @param array $params
  *
  * @return mixed    the output of the script if it has been executed successfully or false otherwise
  */
 protected function request(array $params)
 {
     // connect to the server
     if (!$this->connect()) {
         return false;
     }
     // set timeout
     stream_set_timeout($this->socket, $this->timeout);
     // send the command
     if (fwrite($this->socket, CJs::encodeJson($params)) === false) {
         $this->error = _s('Cannot send command, check connection with Zabbix server "%1$s".', $this->host);
         return false;
     }
     // read the response
     $readBytesLimit = $this->totalBytesLimit && $this->totalBytesLimit < $this->readBytesLimit ? $this->totalBytesLimit : $this->readBytesLimit;
     $response = '';
     $now = time();
     $i = 0;
     while (!feof($this->socket)) {
         $i++;
         if (time() - $now >= $this->timeout) {
             $this->error = _s('Connection timeout of %1$s seconds exceeded when connecting to Zabbix server "%2$s".', $this->timeout, $this->host);
             return false;
         } elseif ($this->totalBytesLimit && $i * $readBytesLimit >= $this->totalBytesLimit) {
             $this->error = _s('Size of the response received from Zabbix server "%1$s" exceeds the allowed size of %2$s bytes. This value can be increased in the ZBX_SOCKET_BYTES_LIMIT constant in include/defines.inc.php.', $this->host, $this->totalBytesLimit);
             return false;
         }
         if (($out = fread($this->socket, $readBytesLimit)) !== false) {
             $response .= $out;
         } else {
             $this->error = _s('Cannot read the response, check connection with the Zabbix server "%1$s".', $this->host);
             return false;
         }
     }
     fclose($this->socket);
     // check if the response is empty
     if (!strlen($response)) {
         $this->error = _s('Empty response received from Zabbix server "%1$s".', $this->host);
         return false;
     }
     $response = CJs::decodeJson($response);
     if (!$response || !$this->validateResponse($response)) {
         $this->error = _s('Incorrect response received from Zabbix server "%1$s".', $this->host);
         return false;
     }
     // request executed successfully
     if ($response['response'] == self::RESPONSE_SUCCESS) {
         return $response['data'];
     } else {
         $this->error = $response['info'];
         return false;
     }
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:60,代码来源:CZabbixServer.php

示例5: validateField

 private function validateField($field, $rules)
 {
     if (false === ($rules = $this->validationRuleParser->parse($rules))) {
         $this->addError(true, $this->validationRuleParser->getError());
         return false;
     }
     $fatal = array_key_exists('fatal', $rules);
     foreach ($rules as $rule => $params) {
         switch ($rule) {
             /*
              * 'fatal' => true
              */
             case 'fatal':
                 // nothing to do
                 break;
                 /*
                  * 'not_empty' => true
                  */
             /*
              * 'not_empty' => true
              */
             case 'not_empty':
                 if (array_key_exists($field, $this->input) && $this->input[$field] === '') {
                     $this->addError($fatal, _s('Incorrect value for field "%1$s": %2$s.', $field, _('cannot be empty')));
                     return false;
                 }
                 break;
             case 'json':
                 if (array_key_exists($field, $this->input)) {
                     if (!is_string($this->input[$field]) || !CJs::decodeJson($this->input[$field])) {
                         $this->addError($fatal, _s('Incorrect value "%1$s" for "%2$s" field.', $this->input[$field], $field));
                         return false;
                     }
                 }
                 break;
                 /*
                  * 'in' => array(<values)
                  */
             /*
              * 'in' => array(<values)
              */
             case 'in':
                 if (array_key_exists($field, $this->input)) {
                     if (!is_string($this->input[$field]) || !in_array($this->input[$field], $params)) {
                         $this->addError($fatal, _s('Incorrect value "%1$s" for "%2$s" field.', $this->input[$field], $field));
                         return false;
                     }
                 }
                 break;
             case 'int32':
                 if (array_key_exists($field, $this->input)) {
                     if (!is_string($this->input[$field]) || !$this->is_int32($this->input[$field])) {
                         $this->addError($fatal, _s('Incorrect value "%1$s" for "%2$s" field.', $this->input[$field], $field));
                         return false;
                     }
                 }
                 break;
             case 'id':
                 if (array_key_exists($field, $this->input)) {
                     if (!is_string($this->input[$field]) || !$this->is_id($this->input[$field])) {
                         $this->addError($fatal, _s('Incorrect value "%1$s" for "%2$s" field.', $this->input[$field], $field));
                         return false;
                     }
                 }
                 break;
                 /*
                  * 'array_id' => true
                  */
             /*
              * 'array_id' => true
              */
             case 'array_id':
                 if (array_key_exists($field, $this->input)) {
                     if (!is_array($this->input[$field]) || !$this->is_array_id($this->input[$field])) {
                         $this->addError($fatal, _s('Incorrect value "%1$s" for "%2$s" field.', $this->input[$field], $field));
                         return false;
                     }
                 }
                 break;
                 /*
                  * 'array_db' => array(
                  *     'table' => <table_name>,
                  *     'field' => <field_name>
                  * )
                  */
             /*
              * 'array_db' => array(
              *     'table' => <table_name>,
              *     'field' => <field_name>
              * )
              */
             case 'array':
                 if (array_key_exists($field, $this->input) && !is_array($this->input[$field])) {
                     $this->addError($fatal, _s('Incorrect value "%1$s" for "%2$s" field.', $this->input[$field], $field));
                     return false;
                 }
                 break;
                 /*
                  * 'array_db' => array(
                  *     'table' => <table_name>,
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CNewValidator.php

示例6: getRequest

    if (in_array($widgetName, $widgets)) {
        // refresh rate
        if (hasRequest('widgetRefreshRate')) {
            $widgetRefreshRate = getRequest('widgetRefreshRate');
            CProfile::update('web.dashboard.widget.' . $widgetName . '.rf_rate', $widgetRefreshRate, PROFILE_TYPE_INT);
            echo 'PMasters["dashboard"].dolls["' . $widgetName . '"].frequency(' . CJs::encodeJson($widgetRefreshRate) . ');' . "\n" . 'PMasters["dashboard"].dolls["' . $widgetName . '"].restartDoll();';
        }
        // widget state
        if (hasRequest('widgetState')) {
            CProfile::update('web.dashboard.widget.' . $widgetName . '.state', getRequest('widgetState'), PROFILE_TYPE_INT);
        }
    }
}
// sort
if (hasRequest('widgetSort')) {
    foreach (CJs::decodeJson(getRequest('widgetSort')) as $col => $column) {
        foreach ($column as $row => $widgetName) {
            $widgetName = str_replace('_widget', '', $widgetName);
            CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT);
            CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT);
        }
    }
}
// favourites
if (hasRequest('favobj') && hasRequest('favaction')) {
    $favouriteObject = getRequest('favobj');
    $favouriteAction = getRequest('favaction');
    $favouriteId = getRequest('favid');
    $result = true;
    DBstart();
    switch ($favouriteObject) {
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:dashboard.php


注:本文中的CJs::decodeJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。