Esempio n. 1
0
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;
        }
    }
}
Esempio n. 2
0
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;
    }
}
Esempio n. 3
0
 public function JsonToArray($json)
 {
     if (isJson($json)) {
         $array = json_decode($json, true);
         return $array;
     } else {
         throw exception("Invalid Json Array");
     }
 }
Esempio n. 4
0
function rendejson($array)
{
    foreach ($array as $key => $value) {
        if (isJson($value)) {
            $array->{$key} = json_decode($value);
        }
    }
    return $array;
}
Esempio n. 5
0
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";
    }
}
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 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";
             }
             if (is_category()) {
                 $ioa_meta_data['title'] = __('Category : ', 'ioa') . single_cat_title('', false);
             }
             if (is_tag()) {
                 $ioa_meta_data['title'] = __('Tag : ', 'ioa') . single_tag_title('', false);
             }
             if (is_search()) {
                 $ioa_meta_data['title'] = __('Search Results for: ', 'ioa') . '<span>' . get_search_query() . '</span>';
             }
             if (is_author()) {
                 if (have_posts()) {
                     the_post();
                     $ioa_meta_data['title'] = __('Author Posts :', 'ioa') . get_the_author();
                 }
                 rewind_posts();
             }
         }
     }
     if (function_exists('is_bbpress') && is_bbpress()) {
         $ioa_meta_data['title'] = 'Forums';
         $ioa_meta_data['layout'] = "right-sidebar";
         $ioa_meta_data['sidebar'] = $super_options[SN . '_bbpress_sidebar'];
     }
     if (function_exists('is_bbpress') && is_bbpress()) {
         $ioa_meta_data['layout'] = "right-sidebar";
         $ioa_meta_data['sidebar'] = $super_options[SN . '_bbpress_sidebar'];
     }
     $ioa_meta_data['width'] = 1060;
     $ioa_meta_data['height'] = $ioa_meta_data['adaptive_height'] = '';
     if (isset($ioa_options['featured_media_height'])) {
         $ioa_meta_data['height'] = $ioa_options['featured_media_height'];
     }
     if (isset($ioa_options['adaptive_height'])) {
         $ioa_meta_data['adaptive_height'] = $ioa_options['adaptive_height'];
     }
     if ($ioa_meta_data['height'] == "") {
         $ioa_meta_data['height'] = 450;
     }
     $ioa_meta_data['featured_media_type'] = $ioa_meta_data['layered_media_type'] = $ioa_meta_data['klayered_media_type'] = '';
     if (isset($ioa_options['featured_media_type'])) {
         $ioa_meta_data['featured_media_type'] = $ioa_options['featured_media_type'];
     }
     if (isset($ioa_options['layered_media_type'])) {
         $ioa_meta_data['layered_media_type'] = $ioa_options['layered_media_type'];
     }
     if (isset($ioa_options['klayered_media_type'])) {
         $ioa_meta_data['klayered_media_type'] = $ioa_options['klayered_media_type'];
     }
     if ($ioa_meta_data['layered_media_type'] != "none" && $ioa_meta_data['layered_media_type'] != "" && function_exists('rev_slider_shortcode')) {
         $ioa_meta_data['featured_media_type'] = 'image-full';
     }
     if ($ioa_meta_data['klayered_media_type'] != "none" && $ioa_meta_data['klayered_media_type'] != "" && function_exists('lsSliders')) {
         $ioa_meta_data['featured_media_type'] = 'image-full';
     }
     $ioa_meta_data['background_image'] = $ioa_meta_data['featured_video'] = '';
     if (isset($ioa_options['background_image'])) {
         $ioa_meta_data['background_image'] = $ioa_options['background_image'];
     }
     if (isset($ioa_options['featured_video'])) {
         $ioa_meta_data['featured_video'] = $ioa_options['featured_video'];
     }
     if ($ioa_meta_data['layout'] == "left-sidebar" || $ioa_meta_data['layout'] == "right-sidebar" || $ioa_meta_data['layout'] == "sticky-right-sidebar" || $ioa_meta_data['layout'] == "sticky-left-sidebar") {
         $ioa_meta_data['width'] = 740;
     }
     $ioa_meta_data['single_portfolio_template'] = $ioa_meta_data['ioa_custom_template'] = $ioa_meta_data['thumb_resize'] = $ioa_meta_data['post_extras'] = $ioa_meta_data['blogmeta_enable'] = $ioa_meta_data['posts_item_limit'] = $ioa_meta_data['enable_thumbnail'] = '';
     if (isset($ioa_options['single_portfolio_template'])) {
         $ioa_meta_data['single_portfolio_template'] = $ioa_options['single_portfolio_template'];
     }
     if (isset($ioa_options['ioa_custom_template'])) {
         $ioa_meta_data['ioa_custom_template'] = $ioa_options['ioa_custom_template'];
     }
     if (isset($ioa_options['thumb_resize'])) {
         $ioa_meta_data['thumb_resize'] = $ioa_options['thumb_resize'];
     }
     if (isset($ioa_options['blog_metadata'])) {
         $ioa_meta_data['post_extras'] = $ioa_options['blog_metadata'];
     }
     if (isset($ioa_options['blogmeta_enable'])) {
         $ioa_meta_data['blogmeta_enable'] = $ioa_options['blogmeta_enable'];
     }
     if (isset($ioa_options['posts_item_limit'])) {
         $ioa_meta_data['posts_item_limit'] = $ioa_options['posts_item_limit'];
     }
     if (isset($ioa_options['enable_thumbnail'])) {
         $ioa_meta_data['enable_thumbnail'] = $ioa_options['enable_thumbnail'];
     }
     $ioa_meta_data['blog_excerpt'] = $ioa_meta_data['more_label'] = $ioa_meta_data['posts_excerpt_limit'] = '';
     if (isset($ioa_options['blog_excerpt'])) {
         $ioa_meta_data['blog_excerpt'] = $ioa_options['blog_excerpt'];
     }
     if (isset($ioa_options['more_label'])) {
         $ioa_meta_data['more_label'] = $ioa_options['more_label'];
     }
     if (isset($ioa_options['posts_excerpt_limit'])) {
         $ioa_meta_data['posts_excerpt_limit'] = $ioa_options['posts_excerpt_limit'];
     }
     if ($ioa_meta_data['posts_excerpt_limit'] == "") {
         $ioa_meta_data['posts_excerpt_limit'] = 150;
     }
     $ioa_meta_data['query_filter'] = array();
     $ioa_meta_data['portfolio_item_limit'] = $ioa_meta_data['portfolio_enable_thumbnail'] = '';
     if (isset($ioa_options['portfolio_item_limit'])) {
         $ioa_meta_data['portfolio_item_limit'] = $ioa_options['portfolio_item_limit'];
     }
     if (isset($ioa_options['portfolio_enable_thumbnail'])) {
         $ioa_meta_data['portfolio_enable_thumbnail'] = $ioa_options['portfolio_enable_thumbnail'];
     }
     if (isset($ioa_options['portfolio_enable_text'])) {
         $ioa_meta_data['portfolio_enable_text'] = $ioa_options['portfolio_enable_text'];
     }
     $ioa_meta_data['portfolio_excerpt'] = $ioa_meta_data['portfolio_more_label'] = '';
     if (isset($ioa_options['portfolio_excerpt'])) {
         $ioa_meta_data['portfolio_excerpt'] = $ioa_options['portfolio_excerpt'];
     }
     if (isset($ioa_options['portfolio_more_label'])) {
         $ioa_meta_data['portfolio_more_label'] = $ioa_options['portfolio_more_label'];
     }
     if ($ioa_meta_data['portfolio_more_label'] == "") {
         $ioa_meta_data['portfolio_more_label'] = "More";
     }
     if ($ioa_meta_data['more_label'] == "") {
         $ioa_meta_data['more_label'] = "More";
     }
     if (isset($ioa_options['portfolio_excerpt_limit'])) {
         $ioa_meta_data['portfolio_excerpt_limit'] = $ioa_options['portfolio_excerpt_limit'];
     }
     if (!isset($ioa_meta_data['portfolio_excerpt_limit']) || $ioa_meta_data['portfolio_excerpt_limit'] == "") {
         $ioa_meta_data['portfolio_excerpt_limit'] = 150;
     }
     if (isset($ioa_options['portfolio_image_resize'])) {
         $ioa_meta_data['thumb_resize'] = $ioa_options['portfolio_image_resize'];
     }
     $ioa_meta_data['portfolio_query_filter'] = array();
     $query_s = $portfolio_query_s = '';
     if (isset($ioa_options['query_filter'])) {
         $query_s = $ioa_options['query_filter'];
     }
     if (isset($ioa_options['portfolio_query_filter'])) {
         $portfolio_query_s = $ioa_options['portfolio_query_filter'];
     }
     if ($query_s != "") {
         $gen = array();
         $query_s = explode("&", $query_s);
         foreach ($query_s as $para) {
             $p = explode("=", $para);
             if ($para != "") {
                 $gen[$p[0]] = $p[1];
             }
         }
         $ioa_meta_data['query_filter'] = $gen;
     }
     if ($portfolio_query_s != "") {
         $gen = array();
         $custom_tax = array();
         $portfolio_query_s = explode("&", $portfolio_query_s);
         foreach ($portfolio_query_s as $para) {
             $p = explode("=", $para);
             if ($p[0] == "tax_query") {
                 $vals = explode("|", $p[1]);
                 $custom_tax[] = array('taxonomy' => $vals[0], 'field' => 'id', 'terms' => explode(",", $vals[1]));
             } else {
                 if ($para != "") {
                     $gen[$p[0]] = $p[1];
                 }
             }
         }
         $gen["tax_query"] = $custom_tax;
         $ioa_meta_data['portfolio_query_filter'] = $gen;
     }
 }
Esempio n. 8
0
        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]);
Esempio n. 9
0
 /**
  * 添加数据集合的索引
  *
  * @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, '创建索引成功');
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
    }
}
// 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;
     }
     $server['REQUEST_METHOD'] = $zf2Request->getMethod();
     // Seed headers with HTTP auth information
     $headers = $headers->toArray();
     if (isset($server['PHP_AUTH_USER'])) {
         $headers['PHP_AUTH_USER'] = $server['PHP_AUTH_USER'];
     }
     if (isset($server['PHP_AUTH_PW'])) {
         $headers['PHP_AUTH_PW'] = $server['PHP_AUTH_PW'];
     }
     // Ensure the bodyParams are passed as an array
     $bodyParams = $this->bodyParams() ?: [];
     return new OAuth2Request($zf2Request->getQuery()->toArray(), $bodyParams, [], [], [], $server, $zf2Request->getContent(), $headers);
 }
 /**
  * @api {post} /products/import/ POST /products/import/
  * @apiExample Example usage:
  * curl -i -X POST "http://apibeta.compargo.com/v1/products/import/?language=en&countryCode=ph
  *      -H "X-COMPARE-REST-API-KEY: 1234567890"
  *      -d "channelId=a1d14206-1ea9-11e4-b32d-eff91066cccf&
  *          data=[{"areaName": "NCR Luzon, Visayas and Mindanao",
  *            	   "brandName": "Bank of Commerce",
  *            	   "companyName": "Bank of Commerce",
  *            	   "productName": "Visa Classic",
  *            	   "productImage": "bank-of-commerce-visa-classic.jpg",
  *            	   "linkInformation": "http://www.bankcom.com.ph/percc.php#vc",
  *            	   "linkApplication": "http://www.bankcom.com.ph/img/ccaf.pdf",
  *            	   "featured": 0,
  *            	   "hasApplyButton": 0,
  *            	   "overlayOrClickthrough": 0,
  *            	   "phoneNumber": 0,
  *            	   "status": 1,
  *            	   "providerCard": 1,
  *            	   "premiumCard": 0,
  *            	   "octopusCard": 0,
  *            	   "islamicCard": 0,
  *            	   "businessCard": 0,
  *            	   "studentCard": 0,
  *            	   "travelCard": 0,
  *            	   "shoppingCard": 0,
  *            	   "specialtyCard": 0,
  *            	   "onlineShoppingCard": 0,
  *            	   "coBranded": 0,
  *            	   "greatFor1": "Get a separate credit limit for your local and foreign transactions",
  *            	   "greatFor2": "Get up to 30% of your credit limit as cash advance",
  *            	   "greatFor3": "Purchase new appliances, gadgets or other high-ticket items by installment",
  *            	   "bewareThat1": 0,
  *            	   "bewareThat2": 0,
  *            	   "bewareThat3": 0,
  *            	   "promoPicture": 0,
  *            	   "promoTitle": 0,
  *            	   "promoApplyPicture": 0,
  *            	   "promoApplyContent": 0,
  *            	   "ribbonBest": 0,
  *            	   "rewardConversion": "P50 spent = 1 point",
  *            	   "rewardConversionCondition": "Only principal cardholders can redeem reward points",
  *            	   "rewardMultiplier": "No points multiplier",
  *            	   "rewardMultiplierCondition": 0,
  *            	   "rewardSpendingShopping": "SM P500 Gift Card (3,711 points)",
  *            	   "rewardSpendingEntertainment": "SM Cinema Tickets for Two (3,149 points)",
  *            	   "rewardSpendingDining": 0,
  *            	   "rewardSpendingOther": 0,
  *            	   "earningPointsOctopus": 0,
  *            	   "earningPointsAutomaticTransaction": 0,
  *            	   "earningPointsOnlineBillPayments": 0,
  *            	   "earningPointsOnlineShopping": 0,
  *            	   "earningPointsInstallment": 0,
  *            	   "cashbackDining": 0,
  *            	   "cashbackDiningCondition": 0,
  *            	   "cashbackShopping": 0,
  *            	   "cashbackShoppingCondition": 0,
  *            	   "cashbackGroceries": 0,
  *            	   "cashbackGroceriesCondition": 0,
  *            	   "cashbackEntertainment": 0,
  *            	   "cashbackEntertainmentCondition": 0,
  *            	   "cashbackPetrol": 0,
  *            	   "cashbackPetrolCondition": 0,
  *            	   "cashbackLocalRetail": 0,
  *            	   "cashbackLocalRetailCondition": 0,
  *            	   "cashbackOverseasSpending": 0,
  *            	   "cashbackOverseasCondition": 0,
  *            	   "cashbackGeneral": 0,
  *            	   "cashbackGeneralCondition": 0,
  *            	   "cashbackOther": 0,
  *            	   "cashbackOtherCondition": 0,
  *            	   "cashbackMetaCondition": 0,
  *            	   "cbeLocalRetails": 0,
  *            	   "cbeLocalRetailsCondition": 0,
  *            	   "cbeLocalDining": 0,
  *            	   "cbeLocalDiningCondition": 0,
  *            	   "cbeOverseasTransaction": 0,
  *            	   "cbeOverseasTransactionCondition": 0,
  *            	   "cbeOnlineShopping": 0,
  *            	   "cbeOnlineShoppingCondition": 0,
  *            	   "cbeOnlineBillPayment": 0,
  *            	   "cbeOnlineBillPaymentCondition": 0,
  *            	   "cbeOctopusAavs": 0,
  *            	   "cbeOctopusAavsCondition": 0,
  *            	   "cbeAutomaticTransaction": 0,
  *            	   "cbeAutomaticTransactionCondition": 0,
  *            	   "cbeInstalment": 0,
  *            	   "cbeInstalmentConditi": 0,
  *            	   "cbeSpecialCondition": 0,
  *            	   "cbsAllNewTransactions": 0,
  *            	   "cbsCashCoupons": 0,
  *            	   "cbsAutopusAavs": 0,
  *            	   "cbsPetrol": 0,
  *            	   "cbsDining": 0,
  *            	   "cbsShopping": 0,
  *            	   "cbsEntertainment": 0,
  *            	   "cbsTravel": 0,
  *            	   "cbsSpecialCondition": 0,
  *            	   "discountsDining": 0,
  *            	   "discountsDiningCondition": 0,
  *            	   "discountsShopping": 0,
  *            	   "discountsShoppingCondition": 0,
  *            	   "discountsGroceries": 0,
  *            	   "discountsGroceriesCondition": 0,
  *            	   "discountsEntertainment": 0,
  *            	   "discountsEntertainmentCondition": 0,
  *            	   "discountsPetrol": 0,
  *            	   "discountsPetrolCondition": 0,
  *            	   "discountsOther": 0,
  *            	   "discountsOtherCondition": 0,
  *            	   "discountsMetaCondition": 0,
  *            	   "milesConversionLocal": 0,
  *            	   "milesConversionConditionLocal": 0,
  *            	   "milesConversionOverseas": 0,
  *            	   "milesConversionConditionOverseas": 0,
  *            	   "milesPogram": 0,
  *            	   "insurance": 0,
  *            	   "airportLounge": 0,
  *            	   "travelOther": 0,
  *            	   "fraudProtection": 0,
  *            	   "installmentPlan": 0,
  *            	   "personalAssistant": 0,
  *            	   "parking": 0,
  *            	   "creditLimit": 0,
  *            	   "purchaseInterest": 3.5,
  *            	   "purchaseApr": 0,
  *            	   "cashAdvanceInterest": 0,
  *            	   "cashAdvanceApr": 0,
  *            	   "interestFreePeriod": 21,
  *            	   "delinquencyRetailPurchaseApr": 0,
  *            	   "delinquencyCashAdvanceApr": 0,
  *            	   "annualFee": 1500,
  *            	   "annualFeePromo": 0,
  *            	   "annualFeeWaiver": "Request for a reversal by calling Customer Care and spend P5,000 within the specified period",
  *            	   "foreignTransactionFee": "2% of the converted amount",
  *            	   "annualFeeSupplementary": "P750",
  *            	   "annualFeeSupplementaryCondition": 0,
  *            	   "cashAdvanceFee": "5% of the amount withdrawn ",
  *            	   "cashAdvanceFee2": 0,
  *            	   "cardReplacementFee": "P300",
  *            	   "annualFeeAfterFirst": 1500,
  *            	   "partlyWaivedCondition": 0,
  *            	   "minimumRepayment": "5% of the amount due",
  *            	   "minimumRepayment2": "P500, whichever is higher",
  *            	   "latePayment": "2% of the overdue amount",
  *            	   "latePayment2": 0,
  *            	   "creditOverLimit": 0,
  *            	   "balanceTransferLowest": 0.88,
  *            	   "balanceTransferMonth": 18,
  *            	   "balanceTransferLongest": 0,
  *            	   "balanceTransferHighlight": 0,
  *            	   "balanceTransferAware": 0,
  *            	   "monthlyIncomeLocals": 10000,
  *            	   "monthlyIncomeForeigners": 0,
  *            	   "minimumEmploymentSalaried": 0,
  *            	   "minimumEmploymentSelfEmployed": 0,
  *            	   "minimumAge": 21,
  *            	   "minimumAgeSupplementary": 18,
  *            	   "existingCardHolder": 1,
  *            	   "nationality": 1,
  *            	   "residence": 0,
  *            	   "other1": 0,
  *            	   "other2": 0,
  *            	   "minimumAnnualIncome": 10000,
  *            	   "maxAge": 65,
  *            	   "language": "en"
  *               }]"
  * 
  *      
  * @apiDescription Bulk import of Products
  * @apiName        Import
  * @apiGroup       Products
  *
  * @apiHeader  {String} X-COMPARE-REST-API-KEY   Products unique access-key.
  *
  * @apiParam   {String} language                 Mandatory Language.
  * @apiParam   {String} countryCode              Mandatory Country Code.
  * @apiParam   {String} id                       Mandatory Product Unique ID.
  * @apiParam   {String} channelId                Mandatory ChannelId of the Product.
  * @apiParam   {String} date                     Mandatory Data of the Product.
  *
  * @apiSuccess {String} id                       The ID of Product.
  *
  * @apiSuccessExample Success-Response:
  *     HTTP/1.1 200 OK
  *     {
  *       "id": "96b3d052-3716-11e4-b18a-fe7344fb1ea4"
  *     } 
  *     
  * @apiError InvalidAccessToken The access token is invalid.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 401 Unauthorized
  *     {
  *       "error": "InvalidAccessToken"
  *     }
  *
  * @apiError MissingAuthenticationCredentials The authentication credentials are missing.
  *
  * @apiErrorExample Error-Response:
  *     HTTP/1.1 401 Unauthorized
  *     {
  *       "error": "MissingAuthenticationCredentials"
  *     }
  * @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;
                                 }
                             }
                         }
                         $valid = $company->validateProperty($companyParams, $schemaFile);
                         if (!empty($valid)) {
                             $errors .= implode(", ", $valid);
                             throw new HTTPException("Request unable to be followed due to semantic errors.", 422, array('dev' => ucfirst($errors), 'internalCode' => 'P1000', 'more' => ''));
                         }
                         $companyParams['id'] = $company->id;
                         $companyParams['createdBy'] = isset($productInformation['createdBy']) ? $productInformation['createdBy'] : '';
                         $companyParams['modifiedBy'] = isset($productInformation['modifiedBy']) ? $productInformation['modifiedBy'] : '';
                         $processCompany = 1;
                     }
                     $brandName = !empty($productInformation['brandName']) ? $productInformation['brandName'] : $productInformation['companyName'];
                     if (isset($brandName)) {
                         $brand = Brands::findFirstByName($brandName);
                         if ($brand) {
                             $brandId = $brand->id;
                             $processBrand = 0;
                         } else {
                             $brand = new Brands();
                             $schemaFile = $this->schemaDir . $this->getDI()->getConfig()->application->jsonSchema->brands;
                             $output = readJsonFromFile($schemaFile, $this);
                             if (!empty($output)) {
                                 $properties = $output['properties'];
                                 foreach ($properties as $key => $value) {
                                     switch ($key) {
                                         case 'options':
                                             continue 2;
                                             break;
                                         case 'name':
                                             $brandParams['name'] = $brandName;
                                             break;
                                         default:
                                             $brandParams[$key] = !empty($productInformation[$key]) ? $productInformation[$key] : '';
                                             break;
                                     }
                                 }
                             }
                             $valid = $brand->validateProperty($brandParams, $schemaFile);
                             if (!empty($valid)) {
                                 $errors .= implode(", ", $valid);
                                 throw new HTTPException("Request unable to be followed due to semantic errors.", 422, array('dev' => ucfirst($errors), 'internalCode' => 'P1000', 'more' => ''));
                             }
                             $brandParams['id'] = $brand->id;
                             $brandParams['createdBy'] = isset($productInformation['createdBy']) ? $productInformation['createdBy'] : '';
                             $brandParams['modifiedBy'] = isset($productInformation['modifiedBy']) ? $productInformation['modifiedBy'] : '';
                             $processBrand = 1;
                         }
                     }
                     $areaName = $productInformation['areaName'];
                     if (isset($areaName)) {
                         $area = Areas::findFirstByName($areaName);
                         if ($area) {
                             $areaId = $area->id;
                         } else {
                             $area = new Areas();
                             $schemaFile = $this->schemaDir . $this->getDI()->getConfig()->application->jsonSchema->areas;
                             $output = readJsonFromFile($schemaFile, $this);
                             if (!empty($output)) {
                                 $properties = $output['properties'];
                                 foreach ($properties as $key => $value) {
                                     switch ($key) {
                                         case 'options':
                                             continue 2;
                                             break;
                                         case 'name':
                                             $areaParams['name'] = $areaName;
                                             break;
                                         default:
                                             $areaParams[$key] = !empty($productInformation[$key]) ? $productInformation[$key] : '';
                                             break;
                                     }
                                 }
                             }
                             $valid = $area->validateProperty($areaParams, $schemaFile);
                             if (!empty($valid)) {
                                 $errors .= implode(", ", $valid);
                                 throw new HTTPException("Request unable to be followed due to semantic errors.", 422, array('dev' => ucfirst($errors), 'internalCode' => 'P1000', 'more' => ''));
                             }
                             $areaParams['id'] = $area->id;
                             $areaParams['name'] = $areaName;
                             $areaParams['language'] = $productInformation['language'];
                             $areaParams['status'] = $productInformation['status'];
                             if (isset($areaParams['status'])) {
                                 $areaParams['active'] = $productInformation['status'] != Areas::ACTIVE ? 0 : 1;
                             }
                             $areaParams['createdBy'] = isset($productInformation['createdBy']) ? $productInformation['createdBy'] : '';
                             $areaParams['modifiedBy'] = isset($productInformation['modifiedBy']) ? $productInformation['modifiedBy'] : '';
                             $processArea = 1;
                         }
                     }
                     $productName = !empty($productInformation['productName']) ? $productInformation['productName'] : '';
                     if (isset($productName)) {
                         $product = Products::findFirstByName($productName);
                         if ($product) {
                             $productId = $product->id;
                             $processChannel = 0;
                         } else {
                             $params['productName'] = $productInformation['productName'];
                             $params['featured'] = isset($productInformation['featured']) ? $productInformation['featured'] : 0;
                             $params['productImage'] = isset($productInformation['productImage']) ? $productInformation['productImage'] : '';
                             $product = new Products();
                             $schemaFile = $this->schemaDir . $this->getDI()->getConfig()->application->jsonSchema->{$channelAlias};
                             $output = readJsonFromFile($schemaFile, $this);
                             if (!empty($output)) {
                                 $properties = $output['properties'];
                                 foreach ($properties as $key => $value) {
                                     switch ($key) {
                                         case 'options':
                                             continue 2;
                                             break;
                                         case 'name':
                                             $productData['name'] = $productInformation['productName'];
                                             break;
                                         case 'id':
                                             $productData['id'] = $product->id;
                                             break;
                                         default:
                                             $productData[$key] = !empty($productInformation[$key]) ? $productInformation[$key] : '';
                                             break;
                                     }
                                 }
                             }
                             $valid = $product->validateProperty($productData, $schemaFile);
                             if (!empty($valid)) {
                                 $errors .= implode(", ", $valid);
                                 throw new HTTPException("Request unable to be followed due to semantic errors.", 422, array('dev' => $errors, 'internalCode' => 'P1000', 'more' => ''));
                             }
                             $productData['id'] = $product->id;
                             $productData['channelId'] = $channelId;
                             $productData['name'] = $productInformation['productName'];
                             $productData['alias'] = '';
                             $productData['language'] = $productInformation['language'];
                             $productData['featured'] = $productInformation['featured'];
                             $productData['icon'] = $productInformation['productImage'];
                             $productData['status'] = $productInformation['status'];
                             if (isset($productData['status'])) {
                                 $productData['active'] = $productInformation['status'] != Products::ACTIVE ? 0 : 1;
                             }
                             $productData['createdBy'] = isset($productInformation['createdBy']) ? $productInformation['createdBy'] : '';
                             $productData['modifiedBy'] = isset($productInformation['modifiedBy']) ? $productInformation['modifiedBy'] : '';
                             $processChannel = 1;
                         }
                         // only save the records when all data is valid
                         if ($processCompany) {
                             $companyParams['id'] = $company->id;
                             if ($company->create($companyParams)) {
                                 $companyId = $company->id;
                             } else {
                                 throw new HTTPException("Request unable to be followed due to semantic errors", 422, array('dev' => $company->getMessages(), 'internalCode' => 'P1000', 'more' => ''));
                             }
                         }
                         if ($processBrand) {
                             $brandParams['companyId'] = $company->id;
                             if ($brand->create($brandParams)) {
                                 $brandId = $brand->id;
                             } else {
                                 throw new HTTPException("Request unable to be followed due to semantic errors", 422, array('dev' => $brand->getMessages(), 'internalCode' => 'P1000', 'more' => ''));
                             }
                         }
                         if ($processArea) {
                             if ($area->create($areaParams)) {
                                 $areaId = $area->id;
                             } else {
                                 throw new HTTPException("Request unable to be followed due to semantic errors", 422, array('dev' => $area->getMessages(), 'internalCode' => 'P1000', 'more' => ''));
                             }
                         }
                         if ($processChannel) {
                             $productData['id'] = $product->id;
                             $productData['brandId'] = $brandId;
                             if ($product->create($productData)) {
                                 $productId = $product->id;
                             } else {
                                 throw new HTTPException("Request unable to be followed due to semantic errors", 422, array('dev' => $product->getMessages(), 'internalCode' => 'P1000', 'more' => ''));
                             }
                         }
                         unset($productInformation['productName']);
                         unset($productInformation['areaName']);
                         unset($productInformation['brandName']);
                         unset($productInformation['companyName']);
                         unset($productInformation['language']);
                         unset($productInformation['featured']);
                         unset($productInformation['productImage']);
                         $this->_addProductsOptions($productId, $areaId, $channelAlias, $productInformation);
                     }
                 }
                 return $results;
             } else {
                 throw new HTTPException('Could not return results in specified format', 403, array('dev' => 'Could not understand type specified by type parameter in query string.', 'internalCode' => 'NF1000', 'more' => 'Type may not be implemented.'));
             }
         } else {
             throw new HTTPException('Could not return results in specified format', 403, array('dev' => 'Could not understand type specified by type parameter in query string.', 'internalCode' => 'NF1000', 'more' => 'Type may not be implemented.'));
         }
     } else {
         throw new HTTPException("The request cannot be fulfilled due to bad syntax.", 400, array('dev' => 'A required field is missing.', 'internalCode' => 'P1000', 'more' => ''));
     }
 }
Esempio n. 14
0
 /**
  * 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;
 }
Esempio n. 15
0
 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');
     }
 }
Esempio n. 16
0
/**
 * 数据库定义类型值的格式化转换函数
 *
 * @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;
}
Esempio n. 17
0
 /**
  * 处理入库的数据
  *
  * @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;
 }
Esempio n. 18
0
     $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);
Esempio n. 19
0
 /**
  * 批量保存字段修改
  *
  * @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, '更新字段属性成功');
 }
Esempio n. 20
0
 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;
Esempio n. 21
0
<?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)));
Esempio n. 22
0
	<script src="JSONViewer/jquery.jsonview.js"></script>
	<script src="shortcut.js"></script>
	<script src="custom.js"></script>
	<script src="JqueryUI/js/jquery-ui-1.9.2.custom.js"></script>
	<style>
body{
	min-width: 700px;
	font: 82.5% "Trebuchet MS", sans-serif;
}
</style>
<div id="responseTabs" class="responseTabs">
	<ul>
		<li><a href="#hisTabs-2">Raw</a></li>
		<?php 
$isJson = false;
if (isJson($his[0]['response'])) {
    $isJson = true;
}
if ($isJson) {
    echo '<li><a href="#hisTabs-4">JSON Viewer</a></li>';
}
?>
		<?php 
if (!$isJson) {
    echo '<li><a href="#hisTabs-3">HTML</a></li>';
}
?>
		<li><a href="#hisTabs-1">Params</a></li>
	</ul>
	
	<div id="hisTabs-2">
Esempio n. 23
0
 /**
  * 编辑统计信息
  *
  * @author young
  * @name 编辑统计信息
  * @version 2014.01.25 young
  */
 public function editAction()
 {
     $_id = trim($this->params()->fromPost('_id', ''));
     $project_id = trim($this->params()->fromPost('__PROJECT_ID__', ''));
     $collection_id = trim($this->params()->fromPost('__COLLECTION_ID__', ''));
     $name = trim($this->params()->fromPost('name', ''));
     $yAxisTitle = trim($this->params()->fromPost('yAxisTitle', ''));
     // Y轴名称
     $yAxisType = trim($this->params()->fromPost('yAxisType', ''));
     // Y轴统计方法
     $yAxisField = trim($this->params()->fromPost('yAxisField', ''));
     // Y轴统计字段
     $xAxisTitle = trim($this->params()->fromPost('xAxisTitle', ''));
     $xAxisType = trim($this->params()->fromPost('xAxisType', ''));
     $xAxisField = trim($this->params()->fromPost('xAxisField', ''));
     $seriesType = trim($this->params()->fromPost('seriesType', ''));
     $seriesField = trim($this->params()->fromPost('seriesField', ''));
     // 用于pie
     $maxShowNumber = intval($this->params()->fromPost('maxShowNumber', 100));
     // 显示最大数量,防止饼状图太多
     $isDashboard = filter_var($this->params()->fromPost('isDashboard', null), FILTER_VALIDATE_BOOLEAN);
     // 是否显示在控制面板
     $dashboardQuery = trim($this->params()->fromPost('dashboardQuery', ''));
     // 控制面板附加查询条件
     $statisticPeriod = intval($this->params()->fromPost('statisticPeriod', 24 * 3600));
     // 控制面板显示周期
     $colspan = intval($this->params()->fromPost('colspan', 1));
     // 行显示是否合并
     $priority = intval($this->params()->fromPost('priority', 0));
     // 优先级
     $interval = intval($this->params()->fromPost('interval', 3600));
     // 统计执行间隔
     if ($name == null) {
         return $this->msg(false, '请填写统计名称');
     }
     if ($interval < 300) {
         return $this->msg(false, '统计时间的间隔不得少于300秒');
     }
     if (!in_array($seriesType, $this->_seriesType, true)) {
         return $this->msg(false, '请设定统计图表类型');
     }
     if ($seriesType !== 'pie') {
         if (empty($yAxisTitle)) {
             return $this->msg(false, '请设定Y轴统计名称');
         }
         if (empty($yAxisType)) {
             return $this->msg(false, '请设定Y轴统计类型');
         }
         if (empty($yAxisField)) {
             return $this->msg(false, '请设定Y轴统计字段');
         }
         if (empty($xAxisTitle)) {
             return $this->msg(false, '请设定X轴统计名称');
         }
         if (empty($xAxisType)) {
             return $this->msg(false, '请设定X轴统计类型');
         }
         if (empty($xAxisField)) {
             return $this->msg(false, '请设定X轴统计字段');
         }
     } else {
         if (empty($seriesField)) {
             return $this->msg(false, '请设定饼形图统计属性');
         }
     }
     if ($dashboardQuery !== '') {
         if (isJson($dashboardQuery)) {
             try {
                 $dashboardQuery = Json::decode($dashboardQuery, Json::TYPE_ARRAY);
             } catch (\Exception $e) {
                 return $this->msg(false, '统计条件的json格式错误');
             }
         } else {
             return $this->msg(false, '统计条件的json格式错误');
         }
     }
     $datas = array();
     $datas['project_id'] = $project_id;
     $datas['collection_id'] = $collection_id;
     $datas['name'] = $name;
     $datas['yAxisTitle'] = $yAxisTitle;
     // title string
     $datas['yAxisType'] = $yAxisType;
     // [Numeric]
     $datas['yAxisField'] = $yAxisField;
     // array()
     $datas['xAxisTitle'] = $xAxisTitle;
     // title string
     $datas['xAxisType'] = $xAxisType;
     // [Category|Time]
     $datas['xAxisField'] = $xAxisField;
     // array()
     $datas['seriesType'] = $seriesType;
     // [line|column|pie]
     $datas['seriesField'] = $seriesField;
     // pie
     $datas['seriesXField'] = $xAxisField;
     // 用于x轴显示
     $datas['seriesYField'] = $yAxisField;
     // 用于y轴显示
     $datas['maxShowNumber'] = $maxShowNumber;
     $datas['isDashboard'] = $isDashboard;
     $datas['dashboardQuery'] = $dashboardQuery;
     $datas['statisticPeriod'] = $statisticPeriod;
     $datas['colspan'] = $colspan;
     $datas['priority'] = $priority;
     $datas['interval'] = $interval;
     $datas['lastExecuteTime'] = new \MongoDate(0);
     $datas['resultExpireTime'] = new \MongoDate(0 + $interval);
     $datas['isRunning'] = false;
     $this->_statistic->update(array('_id' => myMongoId($_id)), array('$set' => $datas));
     return $this->msg(true, '编辑统计成功');
 }
Esempio n. 24
0
function AJAXSaveContent($id, $type, $content, $content_type, $dispname, $settings)
{
    global $connection;
    $content = rawurldecode($content);
    if ($content_type == "json") {
        //check if content is valid JSON
        $content = stripslashes(str_replace("\\n", "\n", $content));
        if (!isJson($content)) {
            die("failed - invaild JSON code");
        }
    } elseif ($content_type == "html") {
        //filter HTML content with htmLawed
        include "../core/libs/htmLawed.php";
        $content = htmLawed($content, array('safe' => 1));
        //temporary htmLawed settings, move to configuration.php
        //Strip non-relative links to the website, experimental, TODO: must be tested
        $base_url = str_replace("/backend/modules/content.php", "", $_SERVER["PHP_SELF"]);
        $content = str_replace("href=\"{$base_url}\"", "href=\"index.php\"", $content);
        $content = str_replace("href=\"{$base_url}/\"", "href=\"index.php\"", $content);
        $content = str_replace("href=\"{$base_url}/", "href=\"", $content);
        $content = str_replace("src=\"{$base_url}/", "src=\"", $content);
    }
    if ($settings !== "") {
        //check if settings are valid JSON
        $settings = stripslashes(str_replace("\\n", "\n", $settings));
        if (!isJson($settings)) {
            die("failed - invaild JSON settings");
        }
    }
    $settings = $connection->real_escape_string($settings);
    $content = $connection->real_escape_string($content);
    if ($id == "new") {
        $id = uniqid();
        $request = "INSERT INTO generic_content (id,`element-type`,content,displayname,settings) VALUES ('{$id}','{$type}','{$content}','{$dispname}','{$settings}')";
    } else {
        $request = "SELECT `element-type` FROM generic_content WHERE id='{$id}'";
        $result = $connection->query($request);
        $line = $result->fetch_assoc();
        if ($line["element-type"] == $type) {
            $request = "UPDATE generic_content SET content='{$content}',settings='{$settings}',displayname='{$dispname}' WHERE id='{$id}'";
        } else {
            die("failed - type mismatch");
        }
    }
    $connection->query($request);
    if ($connection->error) {
        die("failed");
    } else {
        echo "success";
    }
}
Esempio n. 25
0
<?php

include './admin.php';
?>



<?php 
function isJson($string)
{
    return is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))) ? true : false;
}
if (isset($_POST['jsonSubmit']) && !empty($_POST['jsonSubmit'])) {
    if (isset($_POST['jsonText']) && !empty($_POST['jsonText'])) {
        if (isJson($_POST['jsonText'])) {
            if (file_put_contents('config/questions.json', $_POST['jsonText'])) {
            } else {
                fwrite('config/questions.json', $_POST['jsonText']);
            }
        } else {
            echo "STRING NOT JSON";
        }
    }
}
?>
<section class="admin">

<div id="previewDiv" class="half"></div>
<button onclick="submitChanges()">MOVE CHANGES >></button>

Esempio n. 26
0
 public function init()
 {
     /* set timezone */
     if (!ini_get('date.timezone')) {
         date_default_timezone_set('GMT');
     }
     /* get permited table */
     $this->_permited_tables = (include APPLICATION_PATH . '/configs/tables.php');
     /* get params */
     $this->_params = $this->getRequest()->getParams();
     /* convert params json */
     foreach ($this->_params as $k => $v) {
         /* url decode */
         if (!is_array($v)) {
             $v = urldecode($v);
         }
         /* check if json */
         if (isJson($v)) {
             $this->_params[$k] = json_decode($v, true);
         }
     }
     $this->type = 1;
     $this->env = risI($this->_params, "env");
     $this->method = risI($this->_params, "method");
     $this->filter = risI($this->_params, "filter");
     $this->like = risI($this->_params, "like");
     $this->col = risI($this->_params, "col");
     $this->table = risI($this->_params, "table");
     $this->join = risI($this->_params, "join");
     $this->fields = risI($this->_params, "fields");
     $this->id = risI($this->_params, "id");
     $this->dbTable = null;
     /** permited actions without token or table */
     if (!in_array($this->_params['action'], $this->_permited_actions)) {
         if ($this->method == 'multiple_login') {
             $is_ok = true;
             $tables_arr = explode(',', $this->table);
             foreach ($tables_arr as $tbl) {
                 if (!in_array($tbl, $this->_permited_tables)) {
                     $is_ok = false;
                     break;
                 }
             }
             if (!$is_ok) {
                 $this->type = 2;
                 $this->response = array('data' => $this->_params, 'message' => 'Please provide accesible tables', 'type' => $this->type);
             }
         } else {
             /** public tables && public table according to enviroment */
             if (isset($this->_params['table']) && !in_array($this->_params['table'], $this->_permited_tables)) {
                 /** if no token specified */
                 if (!isset($this->_params['token']) || isNE($this->_params['token'])) {
                     $this->type = 2;
                     $this->response = array('data' => $this->_params, 'message' => 'Please provide token', 'type' => $this->type);
                     /** if not valid token */
                 } else {
                     $tokensTbl = $this->f('tokens');
                     $filter = array('token' => $this->_params['token'], 'date_logout' => null);
                     $tokens = $tokensTbl->selectBy($filter)->toArray();
                     if (empty($tokens)) {
                         $this->type = 2;
                         $this->response = array('data' => $this->_params, 'message' => 'Invalid token specified', 'type' => $this->type);
                     }
                 }
             }
         }
         /** if no table specified **/
         if ($this->type == 1 && (!isset($this->_params['table']) || isNE($this->table))) {
             /** permit certain actions */
             if (!in_array($this->_params['action'], array('reports'))) {
                 $this->type = 2;
                 $this->response = array('data' => $this->_params, 'message' => 'Please specify table', 'type' => $this->type);
             }
         }
     }
     $this->joins = (include APPLICATION_PATH . '/configs/joins.php');
     $contextSwitch = $this->_helper->getHelper('ContextSwitch');
     $contextSwitch->initContext('json');
 }
Esempio n. 27
0
<?php

function isJson($filename)
{
    $string = file_get_contents($filename);
    json_decode($string);
    return json_last_error() == JSON_ERROR_NONE;
}
require_once __DIR__ . '/function.glob_recursive.php';
$json_files = glob_recursive(__DIR__ . '/../*.json');
$result['invalid_files'] = array();
$result['valid_files'] = array();
foreach ($json_files as $filename) {
    // Validate
    if (isJson($filename)) {
        $result['valid_files'][] = $filename;
    } else {
        $result['invalid_files'][] = $filename;
    }
}
var_dump($result);
if (!empty($result['invalid_files'])) {
    // That's an error
    exit(1);
}
Esempio n. 28
0
 /**
  * Get update info from GitHub (using the GitHub API)
  *
  * @param bool $forceReload Whether data must be reloaded from Github
  * @return array|bool An array containing update info on success, false on failure
  */
 public function getUpdateInfo($forceReload = false)
 {
     if (null === $this->updateInfo) {
         $file = CACHE_PATH . '/imscp_info.json';
         if ($forceReload || !file_exists($file) || strtotime('+1 day', filemtime($file)) < time()) {
             clearstatcache();
             $context = stream_context_create(array('http' => array('method' => 'GET', 'protocol_version' => '1.1', 'header' => array('Host: api.github.com', 'Accept: application/vnd.github.v3+json', 'User-Agent: i-MSCP', 'Connection: close', 'timeout' => 3))));
             if (!stream_context_set_option($context, 'ssl', 'verify_peer', false)) {
                 $this->setError(tr('Unable to set sslverifypeer option'));
                 return false;
             }
             if (!stream_context_set_option($context, 'ssl', 'allow_self_signed', true)) {
                 $this->setError(tr('Unable to set sslallowselfsigned option'));
                 return false;
             }
             // Retrieving latest release info from GitHub
             $info = @file_get_contents('https://api.github.com/repos/i-MSCP/imscp/releases/latest', false, $context);
             if ($info === false) {
                 $this->setError(tr('Unable to get update info from Github'));
             } elseif (!isJson($info)) {
                 $this->setError(tr('Invalid payload received from GitHub'));
                 return false;
             }
             if (file_exists($file)) {
                 if (!@unlink($file)) {
                     $this->setError(tr('Unable to delete i-MSCP info file.'));
                     write_log(sprintf('Unable to deelte i-MSCP info file.'), E_USER_ERROR);
                     return false;
                 }
             }
             if (@file_put_contents($file, $info, LOCK_EX) === false) {
                 write_log(sprintf('Unable to create i-MSCP info file.'), E_USER_ERROR);
             } else {
                 write_log(sprintf('New i-MSCP info file has been created.'), E_USER_NOTICE);
             }
         } else {
             if (($info = file_get_contents($file)) === false) {
                 $this->setError(tr('Unable to load i-MSCP info file.'));
                 write_log(sprintf('Unable to load i-MSCP info file.'), E_USER_ERROR);
                 return false;
             }
         }
         $this->updateInfo = json_decode($info, true);
     }
     return $this->updateInfo;
 }
Esempio n. 29
0
 public function bettingDataNotNullButValidJson(ApiTester $I)
 {
     $I->sendGET($this->endpoint . SOURCE);
     $tips = $I->grabDataFromResponseByJsonPath('$.tips');
     foreach ($tips[0] as $tip) {
         $I->assertNotNull($tip['betting_data'], 'betting_data is NULL');
         $I->assertTrue(isJson($tip['betting_data']), "betting_data ain't no Json");
     }
 }
Esempio n. 30
0
 $id = $encrypt->decode($id);
 $query = "SELECT store_name,store_pic,operation_hours,concat(address,', ',city,', ',region) as address, city,status, region, postalcode, address as staddress,country\n                 FROM `data_mcdonalds2`\n                 WHERE id='{$id}' LIMIT 1 ";
 //echo $query;
 $result = mysqli_query($mysqli, $query);
 if (!$result) {
     die_with_error(mysqli_error($result));
 }
 $result_array = '';
 while ($row = mysqli_fetch_assoc($result)) {
     foreach ($row as $key => $value) {
         if ($key == 'id') {
             $row[$key] = $encrypt->encode($value);
         }
     }
     $operation_hours = $row['operation_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) {
                     if ($val['status'] == 'Opened') {
                         $t = explode(' ', $val['open']);
                         if ($t[1] == '1') {
                             $val['open'] = $t[0] . " AM";
                         } else {
                             $val['open'] = $t[0] . " PM";