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


PHP isJSON函数代码示例

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


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

示例1: unjsonizeMaybe

function unjsonizeMaybe($original)
{
    if (isJSON($original)) {
        return json_decode($original);
    }
    return $original;
}
开发者ID:puresolcom,项目名称:polyether,代码行数:7,代码来源:helpers.php

示例2: actionCommentCreate

 public function actionCommentCreate()
 {
     if (isset($_POST['commentJSON']) && isJSON($_POST['commentJSON'])) {
         $productCommentModel = new ProductComment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['commentJSON'], true);
         $productCommentModel->text = isset($commentCreatePost['text']) ? $commentCreatePost['text'] : '';
         $productCommentModel->create_time = date("Y-m-d H:i:s");
         $productCommentModel->product_id = isset($commentCreatePost['product_id']) ? $commentCreatePost['product_id'] : '';
         $productCommentModel->contact_method = isset($commentCreatePost['contact_method']) ? $commentCreatePost['contact_method'] : '';
         $productCommentModel->amazing_level = isset($commentCreatePost['amazing_level']) ? $commentCreatePost['amazing_level'] : 5;
         if (!$productCommentModel->validateProductId($productCommentModel->product_id)) {
             $errorMessage = Yii::t('productComment', 'The product is not exist, please try again!');
         }
         if (!$productCommentModel->validateContactMethod()) {
             $errorMessage = Yii::t('productComment', 'Contact method is too long, please shorten it!');
         }
         if (!$productCommentModel->validateSiteMark()) {
             $errorMessage = Yii::t('productComment', 'The mark is out of range, please try again!');
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $productModel = Product::model()->findByAttributes(array('product_id' => $productCommentModel->product_id));
             $productModel->product_mark_sum = $productModel->product_mark * $productModel->product_marked_times + $productCommentModel->amazing_level;
             ++$productModel->product_marked_times;
             $productModel->product_mark = $productModel->product_mark_sum / $productModel->product_marked_times;
             if ($productCommentModel->save() && $productModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $productCommentModel->create_time));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
开发者ID:roychen-7,项目名称:Shining-Town,代码行数:34,代码来源:ProductCommentController.php

示例3: actionCommentCreate

 public function actionCommentCreate()
 {
     if (isset($_POST['productCommentJSON']) && isJSON($_POST['productCommentJSON'])) {
         $productCommentModel = new ProductComment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['productCommentJSON']);
         $productCommentModel->text = $commentCreatePost['text'];
         $productCommentModel->create_time = date("Y-m-d H:i:s");
         $productCommentModel->product_id = $commentCreatePost['product_id'];
         $productCommentModel->contact_method = $commentCreatePost['contact_method'];
         $productCommentModel->amazing_level = $commentCreatePost['amazing_level'];
         if (!$productCommentModel->validateProductId()) {
             $errorMessage = '该产品不存在,请确认后重新提交';
         }
         if (!$productCommentModel->validateContactMethod()) {
             $errorMessage = '联系方式超出长度,请简略填写联系信息(小于50个字)';
         }
         if (!$productCommentModel->validateSiteMark()) {
             $errorMessage = '评分不在范围之内,请重新输入或与管理员联系';
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $productModel = Product::model()->findByPk($productCommentModel->product_id);
             $productModel->product_mark_sum = $productModel->product_mark * $productModel->product_mark_times + $productCommentModel->amazing_level;
             ++$productModel->product_mark_times;
             $productModel->product_mark = $productModel->product_mark_sum / $productModel->product_mark_times;
             if ($productCommentModel->save() && $productModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $productCommentModel->create_time));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
开发者ID:roychad,项目名称:ST_server,代码行数:34,代码来源:ProductCommentController.php

示例4: client_notification_list

function client_notification_list()
{
    global $HAMMU_BOL_Service;
    global $language;
    global $Userservice;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //Lang Call Start
    $hammu_lang_id = $app->request()->params("lang_id");
    if (!empty($hammu_lang_id)) {
        getCurrentLanguages($hammu_lang_id);
    }
    //Lang Call end
    $inviterId = $app->request()->params("inviterId");
    $rarray = $HAMMU_BOL_Service->findClientListByIds($inviterId);
    $datas = json_decode(json_encode($rarray, true), true);
    $data_content = "";
    $meet_location = "";
    $longitude = "";
    $latitude = "";
    $instruction = "";
    $final_date = "";
    if (!empty($datas)) {
        $return_array = array();
        $inviteeId_loop = null;
        $data_content = "";
        //        print_r($datas);
        //        exit;
        foreach ($datas as $key => $data) {
            $searchArr = checkFavorite($data['inviterId'], $data['inviteeId']);
            if (count($searchArr)) {
                $is_favorite = "1";
            } else {
                $is_favorite = "0";
            }
            $inviteeUsername = $Userservice->getUserName($data["inviteeId"]);
            $date = date("Y/m/d H:i", $data["timestamp"]);
            $time = date("H:i", $data["timestamp"]);
            $data_timestamp = $data["data"];
            $json_string = isJSON($data_timestamp);
            if (!empty($json_string)) {
                $meet_location_result = json_decode($data_timestamp);
                $meeting_data_arr = (array) $meet_location_result;
                if (in_array($meeting_data_arr['meet_location'], $meeting_data_arr)) {
                    $meet_location = $meeting_data_arr['meet_location'];
                }
                if (in_array($meeting_data_arr['latitude'], $meeting_data_arr)) {
                    $latitude = $meeting_data_arr['latitude'];
                }
                if (in_array($meeting_data_arr['longitude'], $meeting_data_arr)) {
                    $longitude = $meeting_data_arr['longitude'];
                }
                if (in_array($meeting_data_arr['instruction'], $meeting_data_arr)) {
                    $instruction = $meeting_data_arr['instruction'];
                }
                if (in_array($meeting_data_arr['date'], $meeting_data_arr)) {
                    $data_content = $final_date = date("Y-m-d H:i", $meeting_data_arr['date']);
                }
            } else {
                if ($data_timestamp) {
                    // $data_content = date("Y-m-d H:i", $data_timestamp);
                    $data_content = "";
                }
            }
            $message = $language->text('hammu', $data["action"] . "_noti", array('user' => $inviteeUsername, "date" => $date, "time" => $time, "data" => $data_content));
            $flag = "none";
            if ($data["action"] == "invitation_accept") {
                $flag = "agree";
            } else {
                if ($data["action"] == "buy_rose") {
                    $flag = "location";
                } else {
                    if ($data["action"] == "propose_date_accept" || $data["action"] == "client_re_arrange") {
                        $flag = "confirm";
                    } else {
                        if ($data["action"] == "meet_location") {
                            $flag = "meetting";
                        } else {
                            if ($data["action"] == "buy_rose_client") {
                                $flag = "location";
                            }
                        }
                    }
                }
            }
            //echo $data["inviteeId"];
            if ($inviteeId_loop != $data["inviteeId"]) {
                $inviteeId_loop = $data["inviteeId"];
                $user_infos = getUserInfo($inviteeId_loop);
            }
            $user_infos["meet_location"] = $meet_location;
            $user_infos["latitude"] = $latitude;
            $user_infos["longitude"] = $longitude;
            $user_infos["instruction"] = $instruction;
            $user_infos["propose_date"] = $final_date;
            $return_array[] = array("message" => $message, "id" => $data["id"], "data" => $data["data"], "flag" => $flag, "action" => $data["action"], "seen_unseen" => $data["flag"], "inviteeId" => $data["inviteeId"], "user_info" => $user_infos, "date" => date("Y/m/d H:i", $data["timestamp"]), "is_favorite" => $is_favorite);
        }
        // exit;
        $return_data = array("response_status" => "1", "data" => $return_array);
//.........这里部分代码省略.........
开发者ID:bhushansonar,项目名称:hammu,代码行数:101,代码来源:index_4_7_2015.php

示例5: isJSON

             if (!empty($value)) {
                 $stringVAL .= '<td>' . $value . '</td>';
             }
         }
         return $stringVAL .= '</tr></table>';
     } else {
         return $string;
     }
 }
 $description_product = $field['description_product'][0];
 $ingredients_product = $field['ingredients_product'][0];
 $ingredients_product_all = $field['ingredients_product_all'][0];
 $warning_product = $field['warning_product'][0];
 $type_product = $field['type_product'][0];
 $odor_product = $field['odor_product'][0];
 $extent_product = isJSON($field['extent_product'][0]);
 $type_packaging_product = $field['type_packaging_product'][0];
 $cardboard_product = $field['cardboard_product'][0];
 $pallets_product = $field['pallets_product'][0];
 ?>
         <div class="col-xs-12 col-sm-3 col-md-3">
             <?php 
 $content = get_post(get_the_ID());
 echo $content->post_content;
 ?>
             <div class="col-xs-12 product-extend-block">
                 <?php 
 echo $extent_product;
 ?>
             </div>
         </div>
开发者ID:drammer,项目名称:chemiko,代码行数:31,代码来源:single-products.php

示例6: client_notification_list

function client_notification_list()
{
    global $HAMMU_BOL_Service;
    global $language;
    global $Userservice;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $inviterId = $app->request()->params("inviterId");
    $rarray = $HAMMU_BOL_Service->findClientListByIds($inviterId);
    $datas = json_decode(json_encode($rarray, true), true);
    if (!empty($datas)) {
        $return_array = array();
        $inviteeId_loop = null;
        //$user_infos;
        $data_content = "";
        foreach ($datas as $key => $data) {
            $inviteeUsername = $Userservice->getUserName($data["inviteeId"]);
            $date = date("Y/m/d H:i", $data["timestamp"]);
            $time = date("H:i", $data["timestamp"]);
            $data_timestamp = $data["data"];
            $data_content = "";
            $json_string = isJSON($data_timestamp);
            if (!empty($json_string)) {
                $meet_location_result = json_decode($data_timestamp);
                //                print_r($meet_location_result->meet_location);
                //                exit;
            } else {
                if ($data_timestamp) {
                    $data_content = date("Y-m-d H:i", $data_timestamp);
                }
            }
            $message = $language->text('hammu', $data["action"] . "_noti", array('user' => $inviteeUsername, "date" => $date, "time" => $time, "data" => $data_content));
            $flag = "none";
            if ($data["action"] == "invitation_accept") {
                $flag = "agree";
            } else {
                if ($data["action"] == "buy_rose") {
                    $flag = "location";
                } else {
                    if ($data["action"] == "propose_date_accept" || $data["action"] == "client_re_arrange") {
                        $flag = "confirm";
                    }
                }
            }
            if ($inviteeId_loop != $data["inviteeId"]) {
                $inviteeId_loop = $data["inviteeId"];
                $user_infos = getUserInfo($inviteeId_loop);
            }
            $return_array[] = array("message" => $message, "id" => $data["id"], "data" => $data["data"], "flag" => $flag, "action" => $data["action"], "seen_unseen" => $data["flag"], "inviteeId" => $data["inviteeId"], "user_info" => $user_infos, "date" => date("Y/m/d H:i", $data["timestamp"]));
        }
        $return_data = array("response_status" => "1", "data" => $return_array);
        $app->response->setBody(json_encode($return_data));
    } else {
        $return_data = array("response_status" => "0", "response_message" => "You have No Notification");
        $app->response->setBody(json_encode($return_data));
    }
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:58,代码来源:index____.php

示例7: createorder


//.........这里部分代码省略.........
             if ($this->cart->hasShipping()) {
                 $this->tax->setZone($shipping_address['country_id'], $shipping_address['zone_id']);
             } else {
                 $this->tax->setZone($payment_address['country_id'], $payment_address['zone_id']);
             }
         }
         $product_data = array();
         $total_saleoff = 0;
         $sale2 = 0;
         foreach ($this->cart->getProducts() as $product) {
             $option_data = array();
             foreach ($product['option'] as $option) {
                 if ($option['type'] != 'file') {
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $option['option_value'], 'type' => $option['type']);
                 } else {
                     $encryption = new Encryption($this->config->get('config_encryption'));
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $encryption->decrypt($option['option_value']), 'type' => $option['type']);
                 }
                 if ($option['type'] != 'date') {
                     $option_include = $option['include'];
                 }
             }
             $version_int = $this->model_onecheckout_checkout->versiontoint();
             //version
             if ($version_int < 1513 && $version_int >= 1500) {
                 $version_tax = $this->tax->getRate($product['tax_class_id']);
             } elseif ($version_int >= 1513) {
                 $version_tax = $this->tax->getTax($product['price'], $product['tax_class_id']);
             }
             if (preg_match('/người lớn/', $product['option'][0]['name'])) {
                 $sale = 0;
                 $date = explode('/', end($option_data)['value']);
                 $date_ch = strtotime($date[1] . '/' . $date[0] . '/' . $date[2]);
                 if (isJSON($this->event->check((int) $product['product_id']))) {
                     $EVENT_START = EVENT_START;
                     $EVENT_START2 = EVENT_START;
                     $EVENT_END = EVENT_END;
                 } else {
                     $EVENT_START = '0000-00-00';
                     $EVENT_START2 = '0000-00-00';
                     $EVENT_END = '0000-00-00';
                 }
                 if ($date_ch >= strtotime($EVENT_START2) && $date_ch <= strtotime($EVENT_END)) {
                     /*---- code by minh event am lich -----*/
                     $json = json_decode($this->event->check((int) $product['product_id']), true);
                     if (isset($json)) {
                         if (EVENT_CODE == 'GT_') {
                             preg_match('/[0-9]/', $json['name'], $match);
                             if ($product['day_pay'] == 1) {
                                 if ($product['quantity'] < 3) {
                                     $sale = 75000;
                                 } elseif ($product['quantity'] >= 3 && $product['quantity'] < 5) {
                                     $sale = 105000;
                                 } elseif ($product['quantity'] > 5) {
                                     $sale = 145000;
                                 }
                             }
                             if ($product['day_pay'] == 2) {
                                 if ($product['quantity'] < 3) {
                                     $sale = 145000;
                                 } elseif ($product['quantity'] >= 3 && $product['quantity'] < 5) {
                                     $sale = 175000;
                                 } elseif ($product['quantity'] > 5) {
                                     $sale = 295000;
                                 }
                             }
开发者ID:bamboo0079,项目名称:shopcart,代码行数:67,代码来源:confirm.php

示例8: wsOnMessage

function wsOnMessage($clientID, $message, $messageLength, $binary)
{
    global $Server;
    $client = $Server->wsClients[$clientID];
    $ip = long2ip($client[6]);
    // check if message length is 0
    if ($messageLength == 0) {
        $Server->wsClose($clientID);
        return;
    }
    if ($data = isJSON($message)) {
        if ($data->type == 'auth') {
            $data->id;
            $user = getUserInfo($data->id);
            if (!$user) {
                $Server->wsRemoveClient($clientID);
                $Server->log("!{$clientID}[{$ip}] not in system.");
            } else {
                $Server->wsClients[$clientID][15] = $data->room;
                $Server->wsClients[$clientID][12] = $data->id;
                $Server->wsClients[$clientID][13] = $user['last_name'] . ' ' . $user['first_name'];
                $client = $Server->wsClients[$clientID];
                foreach (array_keys($Server->wsClients) as $id) {
                    if ($id != $clientID) {
                        contactUpdate($id, $clientID, 'online');
                        sendMess($id, array('System', "{$client[13]} подключен к чату", '000'), $data->room);
                    } else {
                        sendMess($id, array('System', "Здравствуйте, {$client[13]}", '000'));
                        $color = getHystory($id, $data->room);
                        getUsers($id, $data->room);
                        getRooms($id);
                    }
                }
                if ($color) {
                    $Server->wsClients[$clientID][14] = $color;
                } else {
                    if (++$Server->c_id >= 6) {
                        $Server->c_id = 0;
                    }
                    $Server->wsClients[$clientID][14] = $Server->colors[$Server->c_id];
                }
                $Server->log("{$clientID}[{$ip}] login as {$client[13]} ({$client[12]}).");
                // $Server->log($Server->wsClients[$clientID]);
            }
        } else {
            if ($data->type == 'createRoom') {
                createRoom($clientID, $data->id, $data->room);
            } else {
                if ($data->type == 'add2Room') {
                    add2Room($clientID, $data->id, $data->room);
                } else {
                    if ($data->type == 'delRoom') {
                        updateRoom($data->room, false, $data->id, true);
                        getRooms($clientID);
                        foreach (array_keys($Server->wsClients) as $id) {
                            if ($id != $clientID) {
                                getUsers($id, $Server->wsClients[$id][15]);
                            }
                        }
                    } else {
                        if ($data->type == 'renRoom') {
                            updateRoom($data->room, $data->name, $data->id);
                            getRooms($clientID);
                        }
                    }
                }
            }
        }
    } else {
        $Server->log("{$clientID}[{$ip}] say:{$message}");
        if (!isset($client[12]) || $client[12] == '') {
            sendMess($clientID, array('System', "НЕАВТОРИЗОВАННАЯ ПОПЫТКА ДОСТУПА!", 'f00'));
            $Server->log("{$clientID}[{$ip}] unauthorized access.");
            $Server->wsClose($clientID);
        } else {
            //The speaker is the only person in the room. Don't let them feel lonely.
            /*if ( sizeof($Server->wsClients) == 1 )
            			sendMess($clientID, array('System', "Чат пуст, дождитесь хотябы одного собеседника", '000'));
            		else{*/
            $color = $client[14];
            $message = str_replace('<', '&lt;', $message);
            $message = str_replace('>', '&gt;', $message);
            $message = str_replace('\'', '&#039;', $message);
            $send_mes = set_smiles($message);
            //Send the message to everyone but the person who said it
            foreach (array_keys($Server->wsClients) as $id) {
                $time = date('H:i:s');
                if ($id != $clientID) {
                    $mes = array($client[13] . '|' . $time, $send_mes, $color);
                } else {
                    $mes = array('You|' . $time, $send_mes, $color);
                    addHistory($client[12], $message, $color, $client[15]);
                }
                sendMess($id, $mes, $client[15]);
            }
            //}
        }
    }
}
开发者ID:omusico,项目名称:sugar_work,代码行数:99,代码来源:server.php

示例9: EventAL

 public function EventAL()
 {
     $tourgroup = 3;
     $price1 = $price2 = $price3 = '';
     $this->language->load('product/product');
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->load->model('catalog/category');
     $this->load->model('catalog/manufacturer');
     if (isset($this->request->get['manufacturer_id'])) {
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_brand'), 'href' => $this->url->link('product/manufacturer'), 'separator' => $this->language->get('text_separator'));
         $url = '';
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $manufacturer_info = $this->model_catalog_manufacturer->getManufacturer($this->request->get['manufacturer_id']);
         if ($manufacturer_info) {
             $this->data['breadcrumbs'][] = array('text' => $manufacturer_info['name'], 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $this->request->get['manufacturer_id'] . $url), 'separator' => $this->language->get('text_separator'));
         }
     }
     if (isset($this->request->get['search']) || isset($this->request->get['tag'])) {
         $url = '';
         if (isset($this->request->get['search'])) {
             $url .= '&search=' . $this->request->get['search'];
         }
         if (isset($this->request->get['tag'])) {
             $url .= '&tag=' . $this->request->get['tag'];
         }
         if (isset($this->request->get['description'])) {
             $url .= '&description=' . $this->request->get['description'];
         }
         if (isset($this->request->get['category_id'])) {
             $url .= '&category_id=' . $this->request->get['category_id'];
         }
         if (isset($this->request->get['sub_category'])) {
             $url .= '&sub_category=' . $this->request->get['sub_category'];
         }
         if (isset($this->request->get['sort'])) {
             $url .= '&sort=' . $this->request->get['sort'];
         }
         if (isset($this->request->get['order'])) {
             $url .= '&order=' . $this->request->get['order'];
         }
         if (isset($this->request->get['page'])) {
             $url .= '&page=' . $this->request->get['page'];
         }
         if (isset($this->request->get['limit'])) {
             $url .= '&limit=' . $this->request->get['limit'];
         }
         $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_search'), 'href' => $this->url->link('product/search', $url), 'separator' => $this->language->get('text_separator'));
     }
     if (isset($this->request->get['product_id'])) {
         $product_id = (int) $this->request->get['product_id'];
     } else {
         $product_id = 0;
     }
     $this->data['grouptour'] = 0;
     if (isset($product_id)) {
         /* bat dieu kien kiem tra thu vien event, neu la chuoi JSON, san pham thuoc dieu kien cua thu vien, neu khong se return 0*/
         if (isJSON($this->event->check($product_id))) {
             $this->data['promotion_date_start'] = EVENT_START;
             $this->data['promotion_date_start2'] = EVENT_START;
             $this->data['promotion_date_end'] = EVENT_END;
         } else {
             $this->data['promotion_date_start'] = '0000-00-00';
             $this->data['promotion_date_start2'] = '0000-00-00';
             $this->data['promotion_date_end'] = '0000-00-00';
         }
         /* Khoa end*/
         if ($this->event->check($product_id)) {
             $this->data['event'] = 'event';
             $json = json_decode($this->event->check($product_id));
             $match = explode('#', $json->name);
             // print_r($match);
             // exit();
             if (isset($match[3]) && $match[3] != 0 && !empty($match[3])) {
                 if ($match[3] <= 3) {
                     $this->data['linkbannergroup'] = HTTP_SERVER . '/image/data/banner-promotion/nguyendan/1-3n.jpg';
                     $this->data['grouptour'] = 1;
                 } elseif ($match[3] >= 4 && $match[3] <= 6) {
                     $this->data['linkbannergroup'] = HTTP_SERVER . '/image/data/banner-promotion/nguyendan/4-6n.jpg';
                     $this->data['grouptour'] = 2;
                 } else {
                     $this->data['linkbannergroup'] = HTTP_SERVER . '/image/data/banner-promotion/nguyendan/7n.jpg';
                     $this->data['grouptour'] = 3;
                 }
             } else {
                 $this->data['grouptour'] = 4;
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:bamboo0079,项目名称:shopcart,代码行数:101,代码来源:vq2-catalog_controller_product_product.php

示例10: actionCommentCreate

 public function actionCommentCreate()
 {
     if (isset($_POST['commentJSON']) && isJSON($_POST['commentJSON'])) {
         $commentModel = new Comment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['commentJSON'], true);
         $commentModel->text = isset($commentCreatePost['text']) ? $commentCreatePost['text'] : Yii::t('comment', 'no comment text');
         $commentModel->create_time = date("Y-m-d H:i:s");
         $commentModel->contact_method = isset($commentCreatePost['contact_method']) ? $commentCreatePost['contact_method'] : null;
         $commentModel->service_attitude = isset($commentCreatePost['service_attitude']) ? $commentCreatePost['service_attitude'] : 5;
         $commentModel->delivery_speed = isset($commentCreatePost['delivery_speed']) ? $commentCreatePost['delivery_speed'] : 5;
         if (!Comment::model()->validateContactMethod($commentCreatePost['contact_method'])) {
             $errorMessage = Yii::t('comment', 'Contact method is too long!');
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['service_attitude'])) {
             $errorMessage = Yii::t('comment', 'Service mark is out of range!');
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['delivery_speed'])) {
             $errorMessage = Yii::t('comment', 'Delivery mark is out of range!');
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $siteMarkModel = SiteMark::model()->findByAttributes(array('id' => '1'));
             $siteMarkModel->service_attitude_sum = $siteMarkModel->service_attitude * $siteMarkModel->service_attitude_times + $commentModel->service_attitude;
             $siteMarkModel->delivery_speed_sum = $siteMarkModel->delivery_speed * $siteMarkModel->delivery_speed_times + $commentModel->delivery_speed;
             ++$siteMarkModel->service_attitude_times;
             ++$siteMarkModel->delivery_speed_times;
             $siteMarkModel->service_attitude = $siteMarkModel->service_attitude_sum / $siteMarkModel->service_attitude_times;
             $siteMarkModel->delivery_speed = $siteMarkModel->delivery_speed_sum / $siteMarkModel->delivery_speed_times;
             if ($siteMarkModel->save() && $commentModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $commentModel->create_time));
             } else {
                 $errorMessage = Yii::t('comment', 'Server error!');
                 $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
开发者ID:roychen-7,项目名称:Shining-Town,代码行数:40,代码来源:CommentController.php

示例11: evolve_sanitize_typography

function evolve_sanitize_typography($input)
{
    if (isJSON($input)) {
        $output = get_object_vars(json_decode($input));
    } else {
        $output = wp_parse_args($input, array('size' => '', 'face' => '', 'style' => '', 'color' => ''));
    }
    $output['size'] = apply_filters('evolve_font_size', $output['size']);
    $output['face'] = apply_filters('evolve_font_face', $output['face']);
    $output['style'] = apply_filters('evolve_font_style', $output['style']);
    $output['color'] = apply_filters('evolve_color', $output['color']);
    //var_dump($output);
    return $output;
}
开发者ID:thejasonhsu,项目名称:Illumin,代码行数:14,代码来源:options-sanitize.php

示例12: out

if (!is_array($data["data"])) {
    echo out(array("success" => false, "message" => $data));
}
$obj = array();
$f_data = array();
function isJSON($string)
{
    return is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))) ? true : false;
}
foreach ($data["data"] as $row) {
    $row[0] = $row[0] - $_SESSION['time_offset'] * 60;
    $row[0] = date($date_format, $row[0]);
    // $date_format = "d.m.y H:i:s"; - data.php
    $row[4] = urldecode($row[4]);
    //добавлено, чтобы в 1с не декодировать
    if (isJSON($row[4])) {
        $row[4] = json_decode($row[4], true);
        $i = 0;
        foreach ($row[4] as $key => $value) {
            foreach ($value as $key => $val) {
                $t["item" . $i]["name"] = $key;
                $t["item" . $i]["value"] = $val;
                $i++;
            }
        }
        $row[4] = $t;
        $row[4] = translate($row[4], $_SESSION['lang'] ? $_SESSION['lang'] : 'ru');
    }
    $f_data[] = $row;
    $f_data = translate($f_data, $_SESSION['lang'] ? $_SESSION['lang'] : 'ru');
    //переводим на рус/англ
开发者ID:komunikator,项目名称:komunikator,代码行数:31,代码来源:get_call_logs_1C.php

示例13: piVarRaw

function piVarRaw($path)
{
    global $verbose;
    // Explode the dot-syntax into parts
    $varParts = explode(".", $path);
    // Reverse it so we can array_pop() to get
    //  and remove the variable part with one line.
    $varParts = array_reverse($varParts);
    if ($verbose) {
        var_dump($varParts);
    }
    // I'll come back to this...
    $firstPart = array_pop($varParts);
    $restored = restoreExternalized($firstPart);
    piLog($restored);
    $jsonString = isJSON($restored);
    if ($jsonString === false) {
        if ($restored === $firstPart) {
            return $path;
        }
        return $restored;
    }
    if ($verbose) {
        //var_dump($jsonString);
        //die();
    }
    // Decode the JSON string. The first one should be JSON...
    $varBase = $jsonString;
    //json_decode($jsonString, true);
    // Go through parts
    $currentVar = $varBase;
    while (count($varParts) > 0) {
        // Next variable name in dot-syntax
        $newVarName = array_pop($varParts);
        // Go ahead and get a restored version of the variable
        $externVarName = restoreExternalized($newVarName);
        if (isset($currentVar[$newVarName])) {
            // Current variable has the subobject
            $currentVar = $currentVar[$newVarName];
        } else {
            if (isset($currentVar[$externVarName])) {
                // Doesn't have the subobject.
                // Check if it has the restored name
                $currentVar = $currentVar[$externVarName];
            } else {
                if (isset($currentVar[intval($newVarName)])) {
                    // Current variable has the subobject
                    $currentVar = $currentVar[intval($newVarName)];
                } else {
                    if (isset($currentVar[intval($externVarName)])) {
                        // Doesn't have the subobject.
                        // Check if it has the restored name
                        $currentVar = $currentVar[intval($externVarName)];
                    } else {
                        // Welp that didn't exist... return what we got...
                        $jsonCheck = isJson($currentVar);
                        if ($jsonCheck !== false) {
                            $currentVar = json_encode($currentVar, JSON_PRETTY_PRINT);
                        }
                        array_push($varParts, $currentVar);
                        $varParts = array_reverse($varParts);
                        $currentVar = implode(".", $varParts);
                        break;
                    }
                }
            }
        }
        // Decode JSON sub-objects
        $jsonCheck = isJson($currentVar);
        if ($jsonCheck !== false) {
            $currentVar = $jsonCheck;
        }
    }
    // Array check
    if (is_array($currentVar)) {
        // Our last object was an array. Encode it
        $currentVar = trim(json_encode($currentVar, JSON_PRETTY_PRINT));
    }
    return $currentVar;
}
开发者ID:saurabhsrb,项目名称:pipress,代码行数:80,代码来源:piProcessing.php

示例14: actionCommentCreate

 public function actionCommentCreate()
 {
     if (isset($_POST['commentJSON']) && isJSON($_POST['commentJSON'])) {
         $commentModel = new Comment();
         $errorMessage = null;
         $commentCreatePost = json_decode($_POST['commentJSON'], true);
         $commentModel->text = $commentCreatePost['text'];
         $commentModel->create_time = date("Y-m-d H:i:s");
         $commentModel->contact_method = $commentCreatePost['contact_method'];
         $commentModel->service_attitude = $commentCreatePost['service_attitude'];
         $commentModel->delivery_speed = $commentCreatePost['delivery_speed'];
         if (!Comment::model()->validateContactMethod($commentCreatePost['contact_method'])) {
             $errorMessage = '联系方式太长';
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['service_attitude'])) {
             $errorMessage = '服务态度打分不在范围内';
         }
         if (!Comment::model()->validateSiteMark($commentCreatePost['delivery_speed'])) {
             $errorMessage = '发货速度打分不在范围内';
         }
         $this->layout = false;
         if ($errorMessage === null) {
             $siteMarkModel = SiteMark::model()->findByAttributes(array('id' => '1'));
             $siteMarkModel->service_attitude_sum = $siteMarkModel->service_attitude * $siteMarkModel->service_attitude_times + $commentModel->service_attitude;
             $siteMarkModel->delivery_speed_sum = $siteMarkModel->delivery_speed * $siteMarkModel->delivery_speed_times + $commentModel->delivery_speed;
             ++$siteMarkModel->service_attitude_times;
             ++$siteMarkModel->delivery_speed_times;
             $siteMarkModel->service_attitude = $siteMarkModel->service_attitude_sum / $siteMarkModel->service_attitude_times;
             $siteMarkModel->delivery_speed = $siteMarkModel->delivery_speed_sum / $siteMarkModel->service_attitude_times;
             if ($siteMarkModel->save() && $commentModel->save()) {
                 $this->render('_customerCreate', array('response' => 'success', 'message' => $commentModel->create_time));
             } else {
                 $errorMessage = '服务器错误!';
                 $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
             }
         } else {
             $this->render('_customerCreate', array('response' => 'failure', 'message' => $errorMessage));
         }
     }
 }
开发者ID:roychad,项目名称:ST_server,代码行数:40,代码来源:CommentController.php


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