• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP isJson函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中isJson函数的典型用法代码示例。如果您正苦于以下问题:PHP isJson函数的具体用法?PHP isJson怎么用?PHP isJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: SaveMainMenu

function SaveMainMenu()
{
    if (isset($_POST["action"])) {
        switch ($_POST["action"]) {
            case "save":
                $json = rawurldecode($_POST["json"]);
                $json = $content = stripslashes(str_replace("\\n", "\n", $json));
                if (isJson($json)) {
                    if (file_put_contents("../core/menu-structure.json", $json) !== false) {
                        header('Content-Type: text/plain; charset=utf-8');
                        echo "success";
                    } else {
                        header('Content-Type: text/plain; charset=utf-8');
                        echo "failed";
                    }
                } else {
                    header('Content-Type: text/plain; charset=utf-8');
                    echo "failed";
                }
                break;
            case "reload":
                header('Content-Type: text/plain; charset=utf-8');
                $json_stream = file_get_contents("../core/menu-structure.json");
                echo $json_stream;
                break;
        }
    }
}
开发者ID:borisper1,项目名称:vesi-cms,代码行数:28,代码来源:main-menu.php


示例2: getHours

function getHours($hours, $format = true)
{
    global $d;
    $operation_hours = $hours;
    if (isJson($operation_hours)) {
        $hrs = json_decode($operation_hours, true);
    } else {
        $hrs = $operation_hours;
    }
    $h = '';
    if (count($hrs) > 0 && is_array($hrs)) {
        foreach ($d as $i => $v) {
            foreach ($hrs as $index => $val) {
                if ($v == $index) {
                    $index = ucwords($index);
                    if ($val['status'] == 'Opened') {
                        $t = explode(' ', $val['open']);
                        if ($t[1] == '1') {
                            $val['open'] = $t[0] . " AM ";
                        } else {
                            $val['open'] = $t[0] . " PM ";
                        }
                        $t = explode(' ', $val['close']);
                        if ($t[1] == '1') {
                            $val['close'] = $t[0] . " AM ";
                        } else {
                            $val['close'] = $t[0] . " PM ";
                        }
                        $hrs[$index] = $val['open'] . '-' . $val['close'];
                    } else {
                        $hrs[$index] = 'Closed';
                    }
                }
            }
        }
        $time = array_unique(array_values($hrs));
        $hours = array();
        foreach ($time as $i => $j) {
            foreach ($hrs as $k => $l) {
                if ($j == $l) {
                    $hours[$j][] = $k;
                }
            }
            $hours[$j] = implode(', ', $hours[$j]);
        }
        if ($format) {
            foreach ($hours as $m => $n) {
                $h .= $n . ' ' . $m;
            }
            $h = ucwords($h);
        } else {
            $h = $hours;
        }
        return $h;
    } else {
        $h = $h = ucwords($operation_hours);
        return $h;
    }
}
开发者ID:sahartak,项目名称:storage,代码行数:59,代码来源:functions.php


示例3: JsonToArray

 public function JsonToArray($json)
 {
     if (isJson($json)) {
         $array = json_decode($json, true);
         return $array;
     } else {
         throw exception("Invalid Json Array");
     }
 }
开发者ID:jhony112,项目名称:Challenge,代码行数:9,代码来源:Converter.php


示例4: rendejson

function rendejson($array)
{
    foreach ($array as $key => $value) {
        if (isJson($value)) {
            $array->{$key} = json_decode($value);
        }
    }
    return $array;
}
开发者ID:uxcriativo,项目名称:CLEANigniter,代码行数:9,代码来源:mygeral_helper.php


示例5: SaveConfigStandard

function SaveConfigStandard($config_json)
{
    $config_json = rawurldecode($config_json);
    $config_json = stripslashes(str_replace("\\n", "\n", $config_json));
    if (isJson($config_json)) {
        if (file_put_contents("../config.json", $config_json) === false) {
            echo "failed";
        }
    } else {
        echo "failed";
    }
}
开发者ID:borisper1,项目名称:vesi-cms,代码行数:12,代码来源:configuration.php


示例6: getSplitHBooking

 public function getSplitHBooking($post)
 {
     if (!isset($post['HBooking']) and isset($post['DocID'])) {
         $bookingid = $post['DocID'];
     } else {
         if (isset($post['HBooking'])) {
             $bookingid = $post['HBooking'];
         } else {
             $bookingid = '';
         }
     }
     $a_post = array_map('base64_decode', explode('#|#', $bookingid));
     $_return = array();
     foreach ($a_post as $item) {
         $_return[] = $post + isJson($item, true);
     }
     return $_return;
 }
开发者ID:gkawin,项目名称:siteminder,代码行数:18,代码来源:cancel_model.php


示例7: preparePage

 function preparePage($id = false)
 {
     global $post, $ioa_meta_data, $super_options;
     if (is_home()) {
         return;
     }
     $ioa_options = array();
     $ioa_meta_data['subtitle'] = '';
     if (isset($post)) {
         $ioa_meta_data['rad_data'] = get_post_meta($post->ID, "rad_data", true);
         if (get_post_meta($post->ID, 'rad_version', true) == "" && !is_array($ioa_meta_data['rad_data'])) {
             if (isJson($ioa_meta_data['rad_data'])) {
                 $ioa_meta_data['rad_data'] = json_decode(stripslashes($ioa_meta_data['rad_data']), true);
             } else {
                 $ioa_meta_data['rad_data'] = base64_decode($ioa_meta_data['rad_data']);
                 $ioa_meta_data['rad_data'] = json_decode(stripslashes($ioa_meta_data['rad_data']), true);
             }
         }
         $ioa_meta_data['title'] = get_the_title();
         if (get_post_meta(get_the_ID(), '_post_subtitle', true) != "" && get_post_meta(get_the_ID(), '_post_subtitle', true) != "none") {
             $ioa_meta_data['subtitle'] = get_post_meta(get_the_ID(), '_post_subtitle', true);
         }
         $ioa_options = get_post_meta(get_the_ID(), 'ioa_options', true);
     }
     if (!$id) {
         $ioa_options = get_post_meta(get_the_ID(), 'ioa_options', true);
         $ioa_meta_data['title'] = get_the_title();
     } else {
         $ioa_meta_data['title'] = get_the_title($id);
         $ioa_options = get_post_meta($id, 'ioa_options', true);
     }
     if ($ioa_options == "") {
         $ioa_options = array();
     }
     $page_layout = $page_sidebar = '';
     if (isset($ioa_options['page_layout'])) {
         $page_layout = $ioa_options['page_layout'];
     }
     if (isset($ioa_options['page_sidebar'])) {
         $page_sidebar = $ioa_options['page_sidebar'];
     }
     $ioa_meta_data['template_mode'] = 'wp-editor';
     if ($page_layout == "") {
         if (isset($super_options[SN . '_page_layout']) && trim($super_options[SN . '_page_layout']) != '') {
             $page_layout = $super_options[SN . '_page_layout'];
         } else {
             $page_layout = 'full';
         }
         if (isset($post) && $post->post_type == "post") {
             if (isset($super_options[SN . '_post_layout']) && $super_options[SN . '_post_layout'] != '') {
                 $page_layout = $super_options[SN . '_post_layout'];
             } else {
                 $page_layout = 'left-sidebar';
             }
         }
     }
     $ioa_meta_data['layout'] = $page_layout;
     $ioa_meta_data['sidebar'] = $page_sidebar;
     $flag = true;
     if (IOA_WOO_EXISTS && is_shop()) {
         $flag = false;
     }
     if (IOA_WOO_EXISTS && is_product_category()) {
         $flag = false;
         $ioa_meta_data['sidebar'] = $super_options[SN . '_woo_category_sidebar'];
         $ioa_meta_data['layout'] = $super_options[SN . '_woo_category_layout'];
         $ioa_meta_data['title'] = single_term_title('', false);
     }
     if (IOA_WOO_EXISTS && is_product_tag()) {
         $flag = false;
         $ioa_meta_data['sidebar'] = $super_options[SN . '_woo_tag_sidebar'];
         $ioa_meta_data['layout'] = $super_options[SN . '_woo_tag_layout'];
         $ioa_meta_data['title'] = single_term_title('', false);
     }
     if (is_tax()) {
         $ioa_meta_data['title'] = single_term_title('', false);
     }
     if ($flag) {
         if (is_author() || is_search() || is_tag() || is_category() || is_archive()) {
             $ioa_meta_data['layout'] = 'right-sidebar';
         }
         if ((is_author() || is_search() || is_tag() || is_category() || is_archive() || is_home()) && !(IOA_WOO_EXISTS && is_shop())) {
             if ((is_author() || is_search() || is_tag() || is_category() || is_archive()) && $flag) {
                 $ioa_meta_data['layout'] = 'right-sidebar';
             }
             if (is_archive()) {
                 $ioa_meta_data['title'] = "";
                 if (is_day()) {
                     $ioa_meta_data['title'] = __('Daily Archives:', 'ioa');
                 } elseif (is_month()) {
                     $ioa_meta_data['title'] = __('Monthly Archives: ', 'ioa');
                 } elseif (is_year()) {
                     $ioa_meta_data['title'] = __('Yearly Archives: ', 'ioa');
                 } elseif (is_tax()) {
                     $ioa_meta_data['title'] = single_term_title('', false);
                 } else {
                     $ioa_meta_data['title'] = __('Archives', 'ioa');
                 }
                 $show_title = "yes";
             }
//.........这里部分代码省略.........
开发者ID:severnrescue,项目名称:web,代码行数:101,代码来源:helper.php


示例8: array_merge

        if (strpos($Directory, '/_') === false) {
            $Return = array_merge($Return, globRecursive($Directory . '/' . basename($Pattern), $Flags));
        }
    }
    // FOREACHDIRECTORY
    return $Return;
}
$translation_files = globRecursive(__DIR__ . '/../lang/*/*.json');
$result['invalid_files'] = 0;
$result['valid_files'] = 0;
$result['errors'] = array();
foreach ($translation_files as $filename) {
    $shortname = translationFilename($filename);
    $error = false;
    // Validate JSON
    if (!isJson($filename)) {
        $result['invalid_files']++;
        $result['errors'][] = $shortname . " => Invalid JSON";
        continue;
    }
    // Validate all HTML tags have an open tag and close tag in same string
    $values = array_values(json_decode(file_get_contents($filename), TRUE));
    foreach ($values as $i => $value) {
        $line_number = $i + 1;
        // Translation number in transifex. Add 1 for JSON line number
        preg_match_all("/\\<([a-z0-9]+)\\s?[^\\<]*?(?<!\\/)\\s*\\>/i", $value, $open_tags);
        preg_match_all("/\\<\\/([a-z0-9]+)\\s?[^\\<]*?(?<!\\/)\\s*\\>/i", $value, $close_tags);
        foreach ($open_tags[1] as $oi => $open_tag) {
            foreach ($close_tags[1] as $ci => $close_tag) {
                if (strtolower($open_tag) === strtolower($close_tag)) {
                    unset($close_tags[1][$ci]);
开发者ID:pavlicekl,项目名称:mvp,代码行数:31,代码来源:translations-checker.php


示例9: addAction

 /**
  * 添加数据集合的索引
  *
  * @author young
  * @name 添加数据集合的索引
  * @version 2013.12.22 young
  */
 public function addAction()
 {
     $keys = $this->params()->fromPost('keys', '');
     if (!isJson($keys)) {
         return $this->msg(false, 'keys必须符合json格式,例如:{"index_name":1,"2d":"2d"}');
     }
     $keys = Json::decode($keys, Json::TYPE_ARRAY);
     if (!is_array($keys) || empty($keys)) {
         return $this->msg(false, '请检查$keys是否为空');
     }
     $keys = $this->filterKey($keys);
     // 检测字段是否都存在
     if (!$this->checkKeys(array_keys($keys))) {
         return $this->msg(false, '键值中包含未定义的字段');
     }
     if (!$this->_targetCollection->ensureIndex($keys, array('background' => true))) {
         return $this->msg(false, '创建索引失败');
     }
     $datas = array();
     $datas['keys'] = Json::encode($keys);
     $datas['collection_id'] = $this->_collection_id;
     $this->_model->insert($datas);
     return $this->msg(true, '创建索引成功');
 }
开发者ID:im286er,项目名称:ent,代码行数:31,代码来源:IndexController.php


示例10: ordersAction

 function ordersAction()
 {
     try {
         $user = !empty($this->_params[0]) ? $this->_params[0] : false;
         $id = !empty($this->_params[1]) ? $this->_params[1] : false;
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             if (!$user) {
                 throw new Exception("Inica el nombre e usuario", 1);
             }
             extract($_POST);
             $productos = isJson($productos) ? json_decode(stripslashes($productos), true) : $productos;
             $estado = isJson($estado) ? json_decode(stripslashes($estado), true) : $estado;
             $hash_compra = md5(uniqid(time()));
             $isValidOrder = isset($productos) && !empty($productos) && !empty($estado) && isset($estado);
             foreach ($productos as $producto) {
                 $check = $this->product->productoTallaColor($producto['idproducto'], $producto['talla'], $producto['color']);
                 if (empty($check)) {
                     throw new Exception("No existe la relacion del producto\n              {$producto['idproducto']}\n               con a talla {$producto['talla']} y color {$producto['color']}", 1);
                 }
             }
             if ($isValidOrder) {
                 $idorder = $this->clients->save(array("hash_compra" => $hash_compra, "estado" => $estado, "username" => $user), "compras");
                 foreach ($productos as $producto) {
                     $isValidColor = $this->color->toArray($producto['color']);
                     $isValidSize = $this->size->toArray($producto['talla']);
                     if (empty($isValidColor)) {
                         try {
                             $this->color->save(array("idcolor" => $producto['color']));
                         } catch (Exception $e) {
                             throw new Exception("El color no es válido", 1);
                         }
                     }
                     if (empty($isValidSize)) {
                         try {
                             $this->size->toArray(array("idtalla" => $producto['talla']));
                         } catch (Exception $e) {
                             throw new Exception("La talla no es válida", 1);
                         }
                     }
                     try {
                         $this->clients->save(array("idcompra" => $idorder, "idproducto" => $producto['idproducto'], "cantidad" => $producto['q'], "username" => $user, "idtalla" => $producto['talla'], "idcolor" => $producto['color']), "compras_productos_tallas_colores");
                     } catch (Exception $e) {
                         echo $e->getMessage();
                         return;
                     }
                 }
                 $res = array('code' => 200, 'Msg' => "OK", 'order' => $idorder);
                 echo json_encode($res);
                 return;
             }
             throw new Exception("Parametros POSTS incorrectos", 1);
         }
         $pedidos = $this->clients->getOrders($user, $id);
         echo json_encode($pedidos);
     } catch (Exception $e) {
         $error = array('error' => 400, 'errorMsg' => $e->getMessage());
         echo json_encode($error);
     }
     return;
 }
开发者ID:GNURub,项目名称:daw2,代码行数:60,代码来源:Api.controller.php


示例11: foreach

    }
}
// add joined classes to $dataobject
foreach ($joinObjs as $className => $classData) {
    $relObj = $dataobject->getFKDefinition($className);
    if ($joinSettings[$className]['type'] == 'file' && $classData['error'] == 4) {
        $hasData = false;
    } else {
        $hasData = array_filter($classData);
    }
    if ($relObj && $hasData) {
        $relClass = $relObj['class'];
        $relCardinality = $relObj['cardinality'];
        $addObj = $modx->newObject($relClass);
        foreach ($classData as $field => $value) {
            if (!empty($value) && isJson($value)) {
                $addObj->fromJson($value);
            } elseif (is_array($value)) {
                $value = getArrayFormat($value);
                $addObj->set($field, $value);
            } else {
                $addObj->set($field, $value);
            }
        }
        switch ($relCardinality) {
            case 'one':
                $dataobject->addOne($addObj);
                break;
            case 'many':
                $dataobject->addMany($addObj);
                break;
开发者ID:nicar,项目名称:FormIt2db,代码行数:31,代码来源:formit2db.snippet.php


示例12: bulkImport


//.........这里部分代码省略.........
  * @apiError ProductNotFound The id of the Product was not found.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 404 Not Found
  *     {
  *       "error": "ProductNotFound"
  *     }
  *     
  * @apiError RouteNotFound That route was not found on the server.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 404 
  *     {
  *       "error": "RouteNotFound"
  *     }    
  */
 public function bulkImport()
 {
     $results = array();
     $request = $this->di->get('request');
     $data = $request->getPost();
     $processCompany = $processBrand = $processChannel = $processArea = 1;
     if (!empty($data)) {
         $product = new Products();
         $productId = $product->id;
         $metaData = new Memory();
         $columns = $metaData->getColumnMap($product);
         $channelId = isset($data['channelId']) ? $data['channelId'] : '';
         $upload = isset($data['data']) ? $data['data'] : '';
         $channel = Channels::findFirstById($channelId);
         if (!$channel) {
             throw new HTTPException("Not found", 404, array('dev' => 'The requested channel does not exist.', 'internalCode' => 'P1000', 'more' => ''));
         }
         if (isJson($upload) && !empty($channelId)) {
             $productData = $brandData = $areaData = $companyData = array();
             $companyParams = $brandParams = $channelParams = $productParams = array();
             $channelAlias = $channel->alias;
             $errors = '';
             $upload = json_decode($upload, true);
             if (!empty($upload)) {
                 for ($i = 0; $i < count($upload); $i++) {
                     $productInformation = $upload[$i];
                     $company = Companies::findFirstByName($productInformation['companyName']);
                     if ($company) {
                         $companyId = $company->id;
                         $processCompany = 0;
                     } else {
                         $company = new Companies();
                         $schemaFile = $this->schemaDir . $this->getDI()->getConfig()->application->jsonSchema->companies;
                         $output = readJsonFromFile($schemaFile, $this);
                         if (!empty($output)) {
                             $properties = $output['properties'];
                             foreach ($properties as $key => $value) {
                                 switch ($key) {
                                     case 'options':
                                         continue 2;
                                         break;
                                     case 'name':
                                         $companyParams[$key] = $productInformation['companyName'];
                                         break;
                                     default:
                                         $companyParams[$key] = !empty($productInformation[$key]) ? $productInformation[$key] : '';
                                         break;
                                 }
                             }
                         }
开发者ID:sarahsampan,项目名称:compare-api,代码行数:67,代码来源:ProductsController.php


示例13: r145

 /**
  * Store plugins info and config as json data instead of serialized data
  *
  * @return array SQL statements to be executed
  */
 protected function r145()
 {
     $sqlUdp = array();
     $stmt = execute_query('SELECT plugin_id, plugin_info, plugin_config FROM plugin');
     if ($stmt->rowCount()) {
         $db = iMSCP_Database::getRawInstance();
         while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) {
             if (!isJson($row['plugin_info'])) {
                 $pluginInfo = $db->quote(json_encode(unserialize($row['plugin_info'])));
             } else {
                 $pluginInfo = $db->quote($row['plugin_info']);
             }
             if (!isJson($row['plugin_config'])) {
                 $pluginConfig = $db->quote(json_encode(unserialize($row['plugin_config'])));
             } else {
                 $pluginConfig = $db->quote($row['plugin_config']);
             }
             $sqlUdp[] = "\n\t\t\t\t\tUPDATE\n\t\t\t\t\t\tplugin\n\t\t\t\t\tSET\n\t\t\t\t\t\tplugin_info = {$pluginInfo}, plugin_config = {$pluginConfig}\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tplugin_id = {$row['plugin_id']}\n\t\t\t\t";
         }
     }
     return $sqlUdp;
 }
开发者ID:svenjantzen,项目名称:imscp,代码行数:27,代码来源:Database.php


示例14: validateParams

 public function validateParams($type = '', $params = array(), $content = '')
 {
     $_test = '';
     $_content = isJson($content) ? json_decode($content, true) : $content;
     switch ($type) {
         case 'API_LOGIN':
         case 'API_COUNT_CREDITS':
         case 'FILE':
         case 'GET_PROCESS_STATUS':
         case 'CREATE_BY_URL':
             if (count($params) == 0) {
                 throw new Exception("Error: no response headers - wrong implementation");
             }
             $_test = $this->parseHeaders($params);
             $_responseCode = $_test[$this->constants['RESPONSE_CODE']];
             $_foundError = false;
             if (isset($_test[$this->constants['COPYLEAKS_ERROR_HEADER']])) {
                 $_errCode = $_test[$this->constants['COPYLEAKS_ERROR_HEADER']];
                 $_error = new ErrorHandler($_errCode, $_content);
                 $_foundError = true;
                 throw new Exception("Error code: " . $_errCode . ", " . $_content['Message']);
             }
             if ($_responseCode !== 200) {
                 $_foundError = true;
                 // print_r($_content);die();
                 if (isset($_content['Message'])) {
                     throw new Exception("Response code: " . $_responseCode . ", " . $_content['Message']);
                 } else {
                     throw new Exception("Response code: " . $_responseCode . ", " . $_content);
                 }
             }
             return array('has_error' => $_foundError, 'response' => $_content, 'response_code' => $_responseCode);
             // break;
         // break;
         default:
             throw new Exception('INCORRECT VALIDATION TYPE');
     }
 }
开发者ID:copyleaks,项目名称:php-plagiarism-checker,代码行数:38,代码来源:API.php


示例15: formatData

/**
 * 数据库定义类型值的格式化转换函数
 *
 * @param mixed $value            
 * @param string $type            
 * @param string $key            
 * @throws \Zend\Json\Exception\RuntimeException
 * @return string
 */
function formatData($value, $type = 'textfield', $key = null)
{
    switch ($type) {
        case '_idfield':
            break;
        case 'numberfield':
            $value = preg_match("/^[0-9]+\\.[0-9]+\$/", $value) ? floatval($value) : intval($value);
            break;
        case 'datefield':
            if (!$value instanceof \MongoDate) {
                $value = preg_match("/^[0-9]+\$/", $value) ? new \MongoDate(intval($value)) : new \MongoDate(strtotime($value));
            }
            break;
        case '2dfield':
            $value = is_array($value) ? array(floatval($value['lng']), floatval($value['lat'])) : array(0, 0);
            break;
        case 'md5field':
            $value = trim($value);
            $value = preg_match('/^[0-9a-f]{32}$/i', $value) ? $value : md5($value);
            break;
        case 'sha1field':
            $value = trim($value);
            $value = preg_match('/^[0-9a-f]{40}$/i', $value) ? $value : sha1($value);
            break;
        case 'boolfield':
            $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
            break;
        case 'arrayfield':
            if (!is_array($value) && is_string($value)) {
                $value = trim($value);
                if (!empty($value)) {
                    if (!isJson($value)) {
                        throw new \Zend\Json\Exception\RuntimeException($key);
                    }
                    try {
                        $value = Json::decode($value, Json::TYPE_ARRAY);
                    } catch (\Zend\Json\Exception\RuntimeException $e) {
                        throw new \Zend\Json\Exception\RuntimeException($key);
                    }
                }
            }
            break;
        case 'documentfield':
            if (!is_array($value) && is_string($value)) {
                $value = trim($value);
                if (!empty($value)) {
                    if (!isJson($value)) {
                        throw new \Zend\Json\Exception\RuntimeException($key);
                    }
                    try {
                        $value = Json::decode($value, Json::TYPE_ARRAY);
                    } catch (\Zend\Json\Exception\RuntimeException $e) {
                        throw new \Zend\Json\Exception\RuntimeException($key);
                    }
                }
            }
            break;
        default:
            $value = trim($value);
            break;
    }
    return $value;
}
开发者ID:im286er,项目名称:ent,代码行数:72,代码来源:function.php


示例16: dealData

 /**
  * 处理入库的数据
  *
  * @param array $datas            
  * @return array
  */
 private function dealData($datas)
 {
     $validPostData = array_intersect_key($datas, $this->_schema['post']);
     array_walk($validPostData, function (&$value, $key) {
         $filter = isset($this->_schema['post'][$key]['filter']) ? $this->_schema['post'][$key]['filter'] : '';
         $type = $this->_schema['post'][$key]['type'];
         $rshCollection = isset($this->_schema['post'][$key]['rshCollection']) ? $this->_schema['post'][$key]['rshCollection'] : '';
         if (!empty($filter)) {
             $value = filter_var($value, $filter);
         }
         if ($type == 'arrayfield' && isset($this->_rshCollection[$rshCollection])) {
             $rowType = $this->_rshCollection[$rshCollection]['rshCollectionValueFieldType'];
             if (!is_array($value) && is_string($value)) {
                 if (!isJson($value)) {
                     throw new \Zend\Json\Exception\RuntimeException($key);
                 }
                 try {
                     $value = Json::decode($value, Json::TYPE_ARRAY);
                 } catch (\Zend\Json\Exception\RuntimeException $e) {
                     throw new \Zend\Json\Exception\RuntimeException($key);
                 }
             }
             array_walk($value, function (&$row, $index) use($rowType, $key) {
                 $row = formatData($row, $rowType, $key);
             });
         }
         $value = formatData($value, $type, $key);
     });
     $validFileData = array_intersect_key($datas, $this->_schema['file']);
     $validData = array_merge($validPostData, $validFileData);
     return $validData;
 }
开发者ID:im286er,项目名称:ent,代码行数:38,代码来源:DataController.php


示例17: json_decode

     $as_path_new_str = $_POST['AS_path_new'];
     $as_path_new = json_decode($as_path_new_str);
     $as_path_new_str = str_replace(' ', '', $as_path_new_str);
     if (is_array($as_path_new)) {
         $response['acknowledge_AS_path_new'] = true;
     } else {
         $as_path_new = array();
     }
 }
 // get country_code
 if (isset($_POST['country_code']) && is_string($_POST['country_code'])) {
     $country_code = $_POST['country_code'];
     $response['acknowledge_country_code'] = true;
 }
 // get raw_data
 if (isset($_POST['raw_data']) && is_string($_POST['raw_data']) && isJson($_POST['raw_data'])) {
     $raw_data_str = $_POST['raw_data'];
     $raw_data_str = str_replace(' ', '', $raw_data_str);
     $raw_data = json_decode($raw_data_str);
     if (is_object($raw_data)) {
         $response['acknowledge_raw_data'] = true;
     } else {
         $raw_data = array();
     }
 }
 // acknolwedge receipt of alert
 echo json_encode($response);
 // call exec of some Java
 $command = build_command($data_source, $timestamp, $prefix_old, $as_old, $prefix_new, $as_new, $as_path_new_str, $country_code, $raw_data_str);
 echo $command;
 exec($command, $output);
开发者ID:CAIDA,项目名称:bgp-hackathon,代码行数:31,代码来源:index.php


示例18: saveAction

 /**
  * 批量保存字段修改
  *
  * @author young
  * @name 批量保存字段修改
  * @version 2013.12.02 young
  * @return JsonModel
  */
 public function saveAction()
 {
     $updateInfos = $this->params()->fromPost('updateInfos', null);
     try {
         $updateInfos = Json::decode($updateInfos, Json::TYPE_ARRAY);
     } catch (\Exception $e) {
         return $this->msg(false, '无效的json字符串');
     }
     if (!is_array($updateInfos)) {
         return $this->msg(false, '更新数据无效');
     }
     $rename = array();
     foreach ($updateInfos as $row) {
         $_id = $row['_id'];
         unset($row['_id']);
         if ($row['field'] == null) {
             return $this->msg(false, '请填写字段名称');
         }
         if (!$this->checkFieldName($row['field'])) {
             return $this->msg(false, '字段名必须为以英文字母开始的“字母、数字、下划线”的组合,“点”标注子属性时,子属性必须以字母开始');
         }
         if ($row['label'] == null) {
             return $this->msg(false, '请填写字段描述');
         }
         if ($row['type'] == null) {
             return $this->msg(false, '请选择字段类型');
         }
         if ($row['rshSearchCondition'] !== '') {
             if (isJson($row['rshSearchCondition'])) {
                 try {
                     $row['rshSearchCondition'] = Json::decode($row['rshSearchCondition'], Json::TYPE_ARRAY);
                 } catch (\Exception $e) {
                     $this->msg(false, '关联集合约束查询条件的json格式错误');
                 }
             } else {
                 return $this->msg(false, '关联集合约束查询条件的json格式错误');
             }
         }
         if ($row['isQuick'] === true) {
             if ($row['type'] !== 'arrayfield') {
                 return $this->msg(false, '快速录入字段,输入类型必须是“数组”');
             }
             if ($row['quickTargetCollection'] === '') {
                 return $this->msg(false, '请选快速录入的目标集合');
             }
         }
         if ($row['isFatherField']) {
             if (empty($row['rshCollection'])) {
                 return $this->msg(false, '复选项,必须设定“关联结合”,且关联结合为自身');
             }
         }
         $row['filter'] = (int) $row['filter'];
         $oldStructureInfo = $this->_structure->findOne(array('_id' => myMongoId($_id)));
         if ($this->checkExist('field', $row['field'], array('collection_id' => $this->_collection_id)) && $oldStructureInfo['field'] != $row['field']) {
             return $this->msg(false, '字段名称已经存在');
         }
         if ($this->checkExist('label', $row['label'], array('collection_id' => $this->_collection_id)) && $oldStructureInfo['label'] != $row['label']) {
             return $this->msg(false, '字段描述已经存在');
         }
         if ($row['isBoxSelect']) {
             if ($row['type'] !== 'arrayfield') {
                 return $this->msg(false, '启用多选项时,请设定输入类型为“数组”');
             }
             if (empty($row['rshCollection'])) {
                 return $this->msg(false, '启用多选项时,必须设定“关联结合”');
             }
         }
         if ($oldStructureInfo['field'] != $row['field']) {
             if ($this->_mapping->getMapping($this->_collection_id) !== null) {
                 return $this->msg(false, '当前集合开启了映射,无法修改字段名');
             }
             $rename[$oldStructureInfo['field']] = $row['field'];
             $row['__OLD_FIELD__'] = $oldStructureInfo['field'];
         }
         $rst = $this->_structure->update(array('_id' => myMongoId($_id), 'collection_id' => $this->_collection_id), array('$set' => $row));
         $this->_plugin_structure->sync($row);
     }
     // 如果修改了字段名称,那么对于数据集合中的对应字段进行重命名操作
     if (!empty($rename)) {
         $dataCollection = $this->collection(iCollectionName($this->_collection_id));
         if ($dataCollection instanceof \MongoCollection) {
             $dataCollection->update(array(), array('$rename' => $rename));
         }
     }
     return $this->msg(true, '更新字段属性成功');
 }
开发者ID:im286er,项目名称:ent,代码行数:94,代码来源:StructureController.php


示例19: header

 header('Content-Type: application/json; charset=utf-8');
 $eventobj = !empty($_POST['event']) ? $_POST['event'] : '';
 if (empty($eventobj)) {
     $errinfo = array('status' => 1, 'msg' => 'no data.', 'alert' => '貼心提醒:APP請更新至最新版或再重新嘗試一次');
     print_r(json_encode($errinfo));
     exit;
 } else {
     #紀錄POST
     dbconn::postlog($eventobj);
     #解密
     $key = 'FD91861EE35E838D';
     $mode = MCRYPT_MODE_ECB;
     $mcrypt = new Mcrypt();
     $mcrypt->setkey($key);
     $mcrypt->setMode($mode);
     if (!isJson($eventobj)) {
         $errinfo = array('status' => 2, 'msg' => 'data err.', 'alert' => '貼心提醒:APP請更新至最新版或再重新嘗試一次');
         print_r(json_encode($errinfo));
         exit;
     }
     $eventarray = json_decode($eventobj);
     if (!empty($eventarray->user_id)) {
         $infoarray['user_id'] = $mcrypt->testdecrypt($key, $eventarray->user_id);
     }
     if (!empty($eventarray->device_id)) {
         $infoarray['device_id'] = $mcrypt->testdecrypt($key, $eventarray->device_id);
     }
     if (empty($infoarray['user_id']) or empty($infoarray['device_id'])) {
         $errinfo = array('status' => 3, 'msg' => 'parse err.', 'alert' => '資料有誤,請重新嘗試一次');
         print_r(json_encode($errinfo));
         exit;
开发者ID:bubutrip,项目名称:bubutrip,代码行数:31,代码来源:serviceapi.php


示例20: mysqli_query

<?php

require "init_j.php";
$result_query = "SELECT date, text, price, hard, hard_price, id_worker\n\tFROM `" . $S_CONFIG['prefix'] . "work`\n\tWHERE id=" . $_REQUEST['id'];
$results = mysqli_query($S_CONFIG['link'], $result_query) or exit(mysqli_error($S_CONFIG['link']));
$work = array();
while ($data = mysqli_fetch_array($results, MYSQLI_ASSOC)) {
    $work = $data;
    $work['text'] = str_replace("<br />", ", ", $data['text']);
    // print_r($work['hard']);
    if (isJson($work['hard'])) {
        $work['hardJson'] = json_decode($work['hard'], true);
    } else {
        $work['hardJson'] = array(array("edit_hard" => str_replace("<br />", "\r\n", $data['hard']), "edit_hardprice" => $data['hard_price']));
    }
    // var_dump($work['hardJson']);
    unset($work['hard']);
}
echo json_encode($work);
// header('HTTP/1.1 500 Internal Server Booboo');
// header('Content-Type: application/json; charset=UTF-8');
// die(json_encode(array('message' => 'ERROR', 'code' => 1)));
开发者ID:pCherkesov,项目名称:sc-online-base,代码行数:22,代码来源:edit_work.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP isListingDocument函数代码示例发布时间:2022-05-15
下一篇:
PHP isJoomla15函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap