function get_order_form($store_id) { $data = array(); $template = 'order.form.html'; $visitor =& env('visitor'); /* 获取我的收货地址 */ $data['my_address'] = $this->_get_my_address($visitor->get('user_id')); $data['addresses'] = ecm_json_encode($data['my_address']); $data['regions'] = $this->_get_regions(); /* 默认地址 */ $addr_default = array(); foreach ($data['my_address'] as $key => $val) { if ($val['is_default']) { $addr_default = $data['my_address'][$key]; break; } } $data['addr_default'] = $addr_default; /* 配送方式 */ $data['shipping_methods'] = $this->_get_shipping_methods($store_id); if (empty($data['shipping_methods'])) { $this->_error('no_shipping_methods'); return false; } $data['shippings'] = ecm_json_encode($data['shipping_methods']); foreach ($data['shipping_methods'] as $shipping) { $data['shipping_options'][$shipping['shipping_id']] = $shipping['shipping_name']; } return array('data' => $data, 'template' => $template); }
/** * 后台首页 * * @author Garbin * @return void */ function index() { $back_nav = $menu = $this->_get_menu(); unset($back_nav['dashboard']); $this->_hook('on_load_adminmenu', array('menu' => &$menu)); $this->assign('menu', $menu); $this->assign('back_nav', $back_nav); $this->assign('menu_json', ecm_json_encode($menu)); $this->display('index.html'); }
function check_captcha() { $captcha = empty($_GET['captcha']) ? '' : strtolower(trim($_GET['captcha'])); if (!$captcha) { echo ecm_json_encode(false); return; } if (base64_decode($_SESSION['captcha']) != $captcha) { echo ecm_json_encode(false); } else { echo ecm_json_encode(true); } return; }
function check_growth() { $growth_needed = empty($_GET['growth_needed']) ? '' : trim($_GET['growth_needed']); $grade = empty($_GET['grade']) ? 0 : intval($_GET['grade']); if (!$growth_needed) { echo ecm_json_encode(false); return; } if ($this->_grade_mod->compare($grade, $growth_needed)) { echo ecm_json_encode(true); } else { echo ecm_json_encode(false); } return; }
function check_grade() { $grade_name = empty($_GET['grade_name']) ? '' : trim($_GET['grade_name']); $grade_id = empty($_GET['id']) ? 0 : intval($_GET['id']); if (!$grade_name) { echo ecm_json_encode(false); return; } if ($this->_grade_mod->unique($grade_name, $grade_id)) { echo ecm_json_encode(true); } else { echo ecm_json_encode(false); } return; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('recommended'))) { $data[$column] = $value; $this->_groupbuy_mod->edit("group_id = " . $id . " AND state = " . GROUP_ON, $data); if (!$this->_groupbuy_mod->has_error()) { echo ecm_json_encode(true); } } else { return; } return; }
/** * 取得商品信息 */ function _get_goods_info($id = 0) { $default_goods_image = Conf::get('default_goods_image'); // 商城默认商品图片 if ($id > 0) { $goods_info = $this->_goods_mod->get_info($id); if ($goods_info === false) { return false; } $goods_info['default_goods_image'] = $default_goods_image; if (empty($goods_info['default_image'])) { $goods_info['default_image'] = $default_goods_image; } } else { $goods_info = array('cate_id' => 0, 'if_show' => 1, 'recommended' => 1, 'price' => 1, 'stock' => 1, 'spec_qty' => 0, 'spec_name_1' => Lang::get('color'), 'spec_name_2' => Lang::get('size'), 'default_goods_image' => $default_goods_image, 'price2' => 1); } $goods_info['spec_json'] = ecm_json_encode(array('spec_qty' => $goods_info['spec_qty'], 'spec_name_1' => isset($goods_info['spec_name_1']) ? $goods_info['spec_name_1'] : '', 'spec_name_2' => isset($goods_info['spec_name_2']) ? $goods_info['spec_name_2'] : '', 'specs' => $goods_info['_specs'])); return $goods_info; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('ad_name', 'position', 'link'))) { $data[$column] = $value; $this->_ad_mod->edit($id, $data); if (!$this->_ad_mod->has_error()) { echo ecm_json_encode(true); } } else { return; } return; }
function check_name() { $store_name = empty($_GET['store_name']) ? '' : trim($_GET['store_name']); $store_mod =& m('store'); if (!$store_mod->unique($store_name)) { echo ecm_json_encode(false); return; } echo ecm_json_encode(true); }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('brand_name', 'recommended', 'sort_order'))) { $data[$column] = $value; if ($column == 'brand_name') { $brand = $this->_brand_mod->get_info($id); if (!$this->_brand_mod->unique($value, $id)) { echo ecm_json_encode(false); return; } } if ($this->_brand_mod->edit($id, $data)) { echo ecm_json_encode(true); } } else { return; } return; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('title', 'sort_order'))) { $data[$column] = $value; $this->_navi_mod->edit($id, $data); if (!$this->_navi_mod->has_error()) { $this->_clear_cache(); echo ecm_json_encode(true); } } else { return; } return; }
function check_category() { $cate_name = empty($_GET['cate_name']) ? '' : trim($_GET['cate_name']); $parent_id = empty($_GET['parent_id']) ? 0 : intval($_GET['parent_id']); $cate_id = isset($_GET['id']) ? intval($_GET['id']) : 0; if (!$cate_name) { echo ecm_json_encode(true); return; } if ($this->_gcategory_mod->unique($cate_name, $parent_id, $cate_id)) { echo ecm_json_encode(true); } else { echo ecm_json_encode(false); } return; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('cate_name', 'if_show', 'sort_order'))) { $data[$column] = $value; if ($column == 'cate_name') { $gcategory = $this->_gcategory_mod->get_info($id); if (!$this->_gcategory_mod->unique($value, $gcategory['parent_id'], $id)) { echo ecm_json_encode(false); return; } } if ($this->_gcategory_mod->edit($id, $data)) { echo ecm_json_encode(true); } } else { return; } return; }
function check_name() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $store_name = empty($_GET['store_name']) ? '' : trim($_GET['store_name']); if (!$this->_store_mod->unique($store_name, $id)) { echo ecm_json_encode(false); return; } echo ecm_json_encode(true); }
/** * 获取编辑器面板 * * @author Garbin * @return void */ function get_editor_panel() { /* 获取挂件列表 */ $widgets = list_widget(); header('Content-Type:text/html;charset=' . CHARSET); $this->assign('widgets', ecm_json_encode($widgets)); $this->assign('site_url', SITE_URL); $this->display('template.panel.html'); }
function check_user() { $user_name = empty($_GET['user_name']) ? null : trim($_GET['user_name']); if (!$user_name) { echo ecm_json_encode(false); return; } /* 连接到用户系统 */ $ms =& ms(); echo ecm_json_encode($ms->user->check_username($user_name)); }
function check_user() { $waiter_name = empty($_GET['waiter_name']) ? null : trim($_GET['waiter_name']); if (!$waiter_name) { echo ecm_json_encode(false); return; } $user_info = $this->_member_mod->get(array('conditions' => 'user_id=' . $this->_store_id, 'fields' => 'user_name')); $waiter_name1 = $user_info['user_name'] . ":" . $waiter_name; $waiter_info = $this->_waiter_mod->get("waiter_name = '{$waiter_name1}'"); $member_info = $this->_member_mod->get("user_name = '{$waiter_name1}'"); if ($waiter_info || $member_info) { echo ecm_json_encode(false); return; } else { echo ecm_json_encode(true); } }
function judge_cate_gnum() { $cate_id = $_GET['cate_id'] ? $_GET['cate_id'] : 0; if (!$cate_id) { echo ecm_json_encode(false); } $gcategory_mod =& m('gcategory'); $count = $gcategory_mod->get_cat_goods_total($cate_id); if ($count > 0) { $this->json_result(true); } else { echo 0; return; } }
function ecm_json_encode($value) { if (CHARSET == 'utf-8' && function_exists('json_encode')) { return json_encode($value); } $props = ''; if (is_object($value)) { foreach (get_object_vars($value) as $name => $propValue) { if (isset($propValue)) { $props .= $props ? ',' . ecm_json_encode($name) : ecm_json_encode($name); $props .= ':' . ecm_json_encode($propValue); } } return '{' . $props . '}'; } elseif (is_array($value)) { $keys = array_keys($value); if (!empty($value) && !empty($value) && ($keys[0] != '0' || $keys != range(0, count($value) - 1))) { foreach ($value as $key => $val) { $key = (string) $key; $props .= $props ? ',' . ecm_json_encode($key) : ecm_json_encode($key); $props .= ':' . ecm_json_encode($val); } return '{' . $props . '}'; } else { $length = count($value); for ($i = 0; $i < $length; $i++) { $props .= $props != '' ? ',' . ecm_json_encode($value[$i]) : ecm_json_encode($value[$i]); } return '[' . $props . ']'; } } elseif (is_string($value)) { //$value = stripslashes($value); $replace = array('\\' => '\\\\', "\n" => '\\n', "\t" => '\\t', '/' => '\\/', "\r" => '\\r', "\\b" => '\\b', "\f" => '\\f', '"' => '\\"', chr(0x8) => '\\b', chr(0xc) => '\\f'); $value = strtr($value, $replace); if (CHARSET == 'big5' && $value[strlen($value) - 1] == '\\') { $value = substr($value, 0, strlen($value) - 1); } return '"' . $value . '"'; } elseif (is_numeric($value)) { return $value; } elseif (is_bool($value)) { return $value ? 'true' : 'false'; } elseif (empty($value)) { return '""'; } else { return $value; } }
/** * Make a successfully message * * @param mixed $retval * @param string $msg * * @return void */ function json_result($retval = '', $msg = '', $jqremote = false) { if (!empty($msg)) { $msg = Lang::get($msg); } $this->json_header(); $json = ecm_json_encode(array('done' => true, 'msg' => $msg, 'retval' => $retval)); if ($jqremote === false) { $jqremote = isset($_GET['jsoncallback']) ? trim($_GET['jsoncallback']) : false; } if ($jqremote) { $json = $jqremote . '(' . $json . ')'; } echo $json; }
function ajax_prop_value() { if (!isset($_GET['pid']) || empty($_GET['pid'])) { echo ecm_json_encode(false); return; } $prop_value = $this->_prop_value_mod->find(array('conditions' => 'pid=' . $_GET['pid'])); foreach ($prop_value as $key => $val) { $prop_value[$key]['switchs'] = 0; } header("Content-Type:text/html;charset=" . CHARSET); echo ecm_json_encode(array_values($prop_value)); return; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('goods_name', 'brand', 'if_reindex', 'closed', 'is_rec', 'rec_order'))) { $data[$column] = $value; $this->_goods_mod->edit($id, $data); if (!$this->_goods_mod->has_error()) { echo ecm_json_encode(true); } } else { return; } return; }
function ajax_cate() { if (!isset($_GET['id']) || empty($_GET['id'])) { echo ecm_json_encode(false); return; } $cate = $this->_region_mod->get_list($_GET['id']); foreach ($cate as $key => $val) { $child = $this->_region_mod->get_list($val['region_id']); if (!$child || empty($child)) { $cate[$key]['switchs'] = 0; } else { $cate[$key]['switchs'] = 1; } } header("Content-Type:text/html;charset=" . CHARSET); echo ecm_json_encode(array_values($cate)); //$this->json_result($cate); return; }
function check_user_name() { $user_name = trim($_GET['user_name']); $member = $this->_member_mod->get(array('conditions' => "state=1 AND user_name='" . $user_name . "'", 'join' => 'has_store', 'fields' => 'store_id')); if ($member) { echo ecm_json_encode(true); return; } echo ecm_json_encode(false); }
function check_brand() { $brand_name = $_GET['brand_name']; if (!$brand_name) { echo ecm_json_encode(true); return; } if ($this->_brand_mod->unique($brand_name)) { echo ecm_json_encode(true); } else { echo ecm_json_encode(false); } return; }
/** * 检查用户是否存在 * * @author Garbin * @return void */ function check_user() { $user_name = empty($_POST['username']) ? null : trim($_POST['username']); if (!$user_name) { echo ecm_json_encode(false); return; } if (is_email($user_name)) { echo ecm_json_encode($this->ms->user->check_email($user_name)); } else { echo ecm_json_encode($this->ms->user->check_phone_mob($user_name)); } }
function index() { $send_result = $this->_sendmail(true); echo 'var send_result=' . ecm_json_encode($send_result) . ';'; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = $this->_m_share->getAll(); if (in_array($column, array('title', 'sort_order'))) { $data[$id][$column] = $value; if ($this->_m_share->setAll($data)) { $this->_clear_cache(); echo ecm_json_encode(true); } } else { return; } return; }
function ajax_col() { $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = isset($_GET['value']) ? trim($_GET['value']) : ''; $data = array(); if (in_array($column, array('if_show', 'sort_order'))) { $data[$column] = $value; if ($this->_article_mod->edit($id, $data)) { echo ecm_json_encode(true); } } else { return; } return; }
function ajax_col() { $id = $_GET['id']; $column = empty($_GET['column']) ? '' : trim($_GET['column']); $value = intval($_GET['value']); $data = array(); $arr = explode('-', $id); $recom_id = intval($arr[0]); $goods_id = intval($arr[1]); if (in_array($column, array('sort_order'))) { $data[$column] = $value; $this->_recommend_mod->createRelation('recommend_goods', $recom_id, array($goods_id => array('sort_order' => $value))); if (!$this->_recommend_mod->has_error()) { echo ecm_json_encode(true); } } else { return; } return; }