Exemple #1
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     /**
      * 判断用户登录情况
      */
     if (isset($_REQUEST['session_id'])) {
         $session = Session::instance($_REQUEST['session_id']);
         $manager = role::get_manager($_REQUEST['session_id']);
     } else {
         $session = Session::instance();
         $manager = role::get_manager();
     }
     /* 当前请求的URL */
     $current_url = urlencode(url::current(TRUE));
     //当前用户管理的站点的ID
     $this->site_id = site::id();
 }
Exemple #2
0
 /**
  * 构造方法
  */
 public function __construct()
 {
     parent::__construct();
     if ($this->is_ajax_request()) {
         $this->template = new View('layout/default_json');
     }
     $this->site_id = site::id();
 }
Exemple #3
0
 public function __construct()
 {
     parent::__construct();
     $this->site_id = site::id();
     if ($this->site_id <= 0) {
         die(Kohana::lang('o_global.access_denied'));
     }
 }
Exemple #4
0
 /**
  * 构造方法
  */
 public function __construct()
 {
     $package_name = substr(dirname(__FILE__), strlen(APPPATH . 'controllers/'));
     empty($package_name) && ($package_name = 'default');
     $this->package_name = $package_name;
     $this->class_name = strtolower(substr(__CLASS__, 0, strpos(__CLASS__, '_')));
     $this->phprpc_server = Kohana::config('phprpc.remote.statking.host');
     $this->site_ids = role::get_site_ids();
     $this->site_id = site::id();
     parent::__construct();
     if ($this->is_ajax_request() == TRUE) {
         $this->template = new View('layout/default_json');
     }
 }
Exemple #5
0
?>
js/jquery.validate.js"></script>
<script type="text/javascript" src="<?php 
echo url::base();
?>
js/jq/plugins/tinymce/tiny_mce.js"></script>
<script type="text/javascript" src="<?php 
echo url::base();
?>
js/init_tiny_mce.js"></script>
<script type="text/javascript">
var global_site_id = <?php 
if (isset($messages['site_id'])) {
    echo $messages['site_id'];
} else {
    echo site::id();
}
?>
;
    $(document).ready(function(){
        $("#edit_form").validate({
            errorPlacement:function(error, element){
                if(element.attr("name") == "content"){
                    //alert(error);
                    error.appendTo( element.parent());
                }else{
                    error.insertAfter(element)
                }
            }
        });
		tinyMCE.execCommand('mceAddControl', true, 'content');
Exemple #6
0
 /**
  * 设定菜单的排序
  */
 public function set_order()
 {
     //初始化返回数组
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     $request_data = $this->input->get();
     $id = isset($request_data['id']) ? $request_data['id'] : '';
     $order = isset($request_data['order']) ? $request_data['order'] : '';
     /* 验证是否可以操作 */
     if (!role::verify('product_filter', site::id(), 0)) {
         $return_struct['msg'] = Kohana::lang('o_global.permission_enough');
         exit(json_encode($return_struct));
     }
     if (empty($id) || empty($order) && $order != 0) {
         $return_struct['msg'] = Kohana::lang('o_global.bad_request');
         exit(json_encode($return_struct));
     }
     if (!is_numeric($order) || $order < 0) {
         $return_struct['msg'] = Kohana::lang('o_global.position_rule');
         exit(json_encode($return_struct));
     }
     $aliasfilter_service = Alias_filterService::get_instance();
     $aliasfilter_service->set($id, array('order' => $order));
     $return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order));
     exit(json_encode($return_struct));
 }
 /**
  * 设定菜单的排序
  */
 public function set_order()
 {
     //初始化返回数组
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     $request_data = $this->input->get();
     $id = isset($request_data['id']) ? $request_data['id'] : '';
     $order = isset($request_data['order']) ? $request_data['order'] : '';
     /* 验证是否可以操作 */
     if (!role::verify('inquiry_subject', site::id(), 0)) {
         $return_struct['msg'] = Kohana::lang('o_global.permission_enough');
         exit(json_encode($return_struct));
     }
     $validation = Validation::factory($request_data)->pre_filter('trim')->add_rules('id', 'required', 'digit')->add_rules('order', 'required', 'digit');
     if (!$validation->validate()) {
         $return_struct['msg'] = Kohana::lang('o_global.position_rule');
         exit(json_encode($return_struct));
     }
     if (empty($id) || empty($order) && $order != 0) {
         $return_struct['msg'] = Kohana::lang('o_global.bad_request');
         exit(json_encode($return_struct));
     }
     if (!is_numeric($order) || $order < 0) {
         $return_struct['msg'] = Kohana::lang('o_global.position_rule');
         exit(json_encode($return_struct));
     }
     $inquieysubject_service = InquirysubjectService::get_instance();
     $inquieysubject_service->set($id, array('position' => $order));
     $return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order));
     exit(json_encode($return_struct));
 }
Exemple #8
0
 public function __construct()
 {
     parent::__construct();
     $this->site_id = site::id();
 }
Exemple #9
0
 public function delete()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array('assoc' => NULL, 'count' => 0);
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         $site_ids = role::get_site_ids();
         if (empty($site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         $in_site_id = site::id();
         if (isset($request_data['site_id']) and $request_data['site_id'] === '0') {
             unset($request_data['site_id']);
         }
         if (isset($request_data['site_id']) and !in_array($request_data['site_id'], $site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         if ($in_site_id > 0) {
             $query_site_id = $in_site_id;
         } else {
             throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         $template_id = intval($request_data['template_id']);
         $template = Product_templateService::get_instance()->index(array('where' => array('id' => $template_id)));
         if (!empty($template)) {
             if ($template[0]['site_id'] == $query_site_id) {
                 ORM::factory('product_template')->where('id', $template_id)->delete_all();
             } else {
                 throw new MyRuntimeException('没有权限删除该商品模板!', 403);
             }
         } else {
             throw new MyRuntimeException('该模板不存在,或者已被删除!', 403);
         }
         //* 补充&修改返回结构体 */
         //* 补充&修改返回结构体 ==根据业务逻辑定制== */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '商品模板已经成功删除!';
         $return_struct['content'] = $return_data;
         $return_struct['action'] = array('type' => 'location', 'url' => !empty($request_data['listurl']) ? url::base() . $request_data['listurl'] : url::base() . $this->package_name . '/' . $this->class_name . '/' . 'index');
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             //* 模板输出 */
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             //* 变量绑定 */
             $this->template->title = Kohana::config('site.name');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
             //:: 当前应用专用数据
             $this->template->content->title = Kohana::config('site.name');
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Exemple #10
0
 /**
  * 对网站联盟订单的查询处理
  *
  */
 public function select()
 {
     $site_id_list = role::check('affiliate');
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //* 初始化返回数据 */
         $return_data = array('assoc' => NULL, 'count' => 0);
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         $site_ids = role::get_site_ids();
         if (empty($site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         $in_site_id = site::id();
         if (isset($request_data['site_id']) and $request_data['site_id'] === '0') {
             unset($request_data['site_id']);
         }
         if (isset($request_data['site_id']) and !in_array($request_data['site_id'], $site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         if ($in_site_id > 0) {
             $query_site_id = $in_site_id;
         } else {
             $query_site_id = $site_ids;
             //throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         $site_name = Mysite::instance($this->site_id)->get('domain');
         //页数
         $page = isset($request_data['page']) && intval($request_data['page']) >= 1 ? intval($request_data['page']) : 1;
         //联盟id
         $affiliate_id = isset($request_data['affiliate_id']) && intval($request_data['affiliate_id']) >= 1 ? intval($request_data['affiliate_id']) : 0;
         //起始时间
         $time_f = isset($request_data['time_f']) ? $request_data['time_f'] : date('Y-m-d', time() - 86400 * 365 * 5);
         $time_f = $time_f == '' ? date('Y-m-d', time() - 86400 * 365 * 5) : $time_f;
         //结束时间
         $time_t = isset($request_data['time_t']) ? $request_data['time_t'] : date('Y-m-d');
         $time_t = $time_t == '' ? date('Y-m-d') : $time_t;
         //获取联盟的订单
         $where = array('site_id' => $query_site_id, 'order_time >' => date('Y-m-d H:i:s', strtotime($time_f . ' 00:00:00')), 'order_time <' => date('Y-m-d H:i:s', strtotime($time_t . ' 23:59:59')));
         if ($affiliate_id > 0) {
             $where['affiliate_id'] = $affiliate_id;
         }
         $query_struct = array('where' => $where, 'limit' => array('page' => $page, 'per_page' => 20));
         $orders = Affiliate_orderService::get_instance()->index($query_struct);
         $orders_count = Affiliate_orderService::get_instance()->count($query_struct);
         $this->pagination = new Pagination(array('total_items' => $orders_count, 'items_per_page' => 20));
         $affiliates = AffiliateService::get_instance()->index(array('where' => array('mark' => 1)));
         for ($i = 0; $i < count($affiliates); $i++) {
             if ($affiliates[$i]['id'] == $affiliate_id) {
                 $affiliates[$i]['selected'] = 1;
             } else {
                 $affiliates[$i]['selected'] = 0;
             }
         }
         $content = new View($this->package_name . '/' . $this->class_name . '/' . __FUNCTION__);
         $this->template->content = $content;
         $this->template->content->site_name = $site_name;
         $this->template->content->orders = $orders;
         $this->template->content->pagination = $this->pagination;
         $this->template->content->time_f = $time_f;
         $this->template->content->time_t = $time_t;
         $this->template->content->affiliates = $affiliates;
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Exemple #11
0
 public function __construct()
 {
     parent::__construct();
     $this->site_id = site::id();
     role::check('site_scan', $this->site_id);
 }
Exemple #12
0
 public function check_exist_uri_name()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         //* 实现功能后屏蔽此异常抛出 */
         //throw new MyRuntimeException('Not Implemented',501);
         //必须为ajax请求
         if (!$this->is_ajax_request()) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         //* 权限验证 */
         $site_id = site::id();
         if ($site_id == 0) {
             throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         if (!isset($request_data['uri_name']) || empty($request_data['uri_name'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404);
         }
         $category_service = CategoryService::get_instance();
         if (isset($request_data['category_id']) && is_numeric($request_data['category_id'])) {
             $category = $category_service->get($request_data['category_id']);
             //判断站点
             if ($site_id != $category['site_id']) {
                 throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 404);
             }
             if (strtolower($category['uri_name']) == strtolower($request_data['uri_name'])) {
                 exit(Kohana::lang('o_global.true'));
             }
         }
         // 调用底层服务
         if ($category_service->check_exist_uri_name($site_id, $request_data['uri_name'])) {
             exit(Kohana::lang('o_global.false'));
         } else {
             exit(Kohana::lang('o_global.true'));
         }
     } catch (MyRuntimeException $ex) {
         $this->_ex($ex, $return_struct, $request_data);
     }
 }
Exemple #13
0
 /**
  * SEO信息删除
  */
 public function delete($id)
 {
     //收集请求
     $seo_manages = Myseo_manage::instance($id)->get();
     $site_id = site::id();
     if ($site_id == 0) {
         remind::set('请首先进入所要操作的站点', request::referrer(), 'error');
     }
     if (!$seo_manages['id']) {
         remind::set('无效SEO信息,请重试', request::referrer(), 'error');
     }
     $site_id_list = role::check('seo_manage', 0, 0);
     // 权限验证
     if (!in_array($seo_manages['site_id'], $site_id_list)) {
         remind::set('access denied', request::referrer(), 'error');
     }
     if (Myseo_manage::instance()->delete($id)) {
         Myseo_manage::instance()->update_seo_manage_by_site_id($site_id);
         remind::set('删除 信息成功', request::referrer(), 'success');
     } else {
         remind::set('删除 信息失败', request::referrer(), 'error');
     }
 }
 /**
  * 请求站点处理
  *
  * 2010-04-21
  */
 public static function request_site(&$request_struct_current, &$request_data, $site_id_list)
 {
     if (isset($request_data['site_id']) && intval($request_data['site_id']) > 0) {
         $request_struct_current['where']['site_id'] = intval($request_data['site_id']);
         $request_data['site_id'] = $request_struct_current['where']['site_id'];
     } else {
         $site_id = site::id();
         if ($site_id > 0) {
             $request_struct_current['where']['site_id'] = $site_id;
             $request_data['site_id'] = $site_id;
         } else {
             $request_struct_current['where']['site_id'] = $site_id_list;
             $request_data['site_id'] = -1;
         }
     }
 }
Exemple #15
0
 public function __construct()
 {
     parent::__construct();
     // DISABLE MAGIC QUOTES
     if (function_exists('set_magic_quotes_runtime')) {
         @set_magic_quotes_runtime(false);
     }
     // Charset
     $this->charset = Kohana::config('kc.charset');
     // INPUT INIT
     $this->get = $this->input->get();
     $this->post = $this->input->post();
     $this->cookie = $this->input->cookie();
     // LINKING UPLOADED FILE
     if (count($_FILES)) {
         $this->file =& $_FILES[key($_FILES)];
     }
     // SETTING UP SESSION
     $session_life_time = Kohana::config('kc._sessionLifetime');
     $session_dir = Kohana::config('kc._sessionDir');
     $session_domain = Kohana::config('kc._sessionDomain');
     if ($session_life_time) {
         ini_set('session.gc_maxlifetime', $session_life_time * 60);
     }
     if ($session_dir) {
         ini_set('session.save_path', $session_dir);
     }
     if ($session_domain) {
         ini_set('session.cookie_domain', $session_domain);
     }
     // RELOAD DEFAULT CONFIGURATION
     $this->config = Kohana::config('kc');
     // LOAD SESSION CONFIGURATION IF EXISTS
     if (isset($this->config['_sessionVar']) && is_array($this->config['_sessionVar'])) {
         foreach ($this->config['_sessionVar'] as $key => $val) {
             if (substr($key, 0, 1) != "_" && isset($this->config[$key])) {
                 $this->config[$key] = $val;
             }
         }
         if (!isset($this->config['_sessionVar']['self'])) {
             $this->config['_sessionVar']['self'] = array();
         }
         $this->session =& $this->config['_sessionVar']['self'];
     } else {
         $this->session =& $_SESSION;
     }
     // GET TYPE DIRECTORY
     $this->types =& $this->config['types'];
     $firstType = array_keys($this->types);
     $firstType = $firstType[0];
     $this->type = isset($this->get['type']) && isset($this->types[$this->get['type']]) ? $this->get['type'] : $firstType;
     // LOAD DIRECTORY TYPE SPECIFIC CONFIGURATION IF EXISTS
     if (is_array($this->types[$this->type])) {
         foreach ($this->types[$this->type] as $key => $val) {
             if (in_array($key, $this->typeSettings)) {
                 $this->config[$key] = $val;
             }
         }
         $this->types[$this->type] = isset($this->types[$this->type]['type']) ? $this->types[$this->type]['type'] : "";
     }
     // COOKIES INIT
     if (isset($this->config['cookieDomain']) and !strlen($this->config['cookieDomain'])) {
         $this->config['cookieDomain'] = $_SERVER['HTTP_HOST'];
     }
     if (isset($this->config['cookiePath']) and !strlen($this->config['cookiePath'])) {
         $this->config['cookiePath'] = "/";
     }
     // HOST APPLICATIONS INIT
     if (isset($this->get['CKEditorFuncNum'])) {
         $this->opener['CKEditor']['funcNum'] = $this->get['CKEditorFuncNum'];
     }
     if (isset($this->get['opener']) && strtolower($this->get['opener']) == "tinymce" && isset($this->config['_tinyMCEPath']) && strlen($this->config['_tinyMCEPath'])) {
         $this->opener['TinyMCE'] = true;
     }
     // 通过参数传递过来的site_id 优先级高
     $site_id = isset($this->get['site_id']) ? $this->get['site_id'] : 0;
     // 通过全局方法获得的site_id
     $site_id2 = site::id();
     $this->site_id = $site_id > 0 ? $site_id : $site_id2;
     if ($this->site_id == 0) {
         $this->back_msg(Kohana::lang('o_global.select_site'));
     }
 }
Exemple #16
0
 public function index()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         $request_data = $this->input->get();
         $site_ids = role::get_site_ids();
         if (empty($site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403);
         }
         $site_id = site::id();
         if ($site_id <= 0 && !in_array($site_id, $site_ids)) {
             throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         //获取站点的统计ID
         $site_detail = Mysite::instance($site_id)->detail();
         $statking_id = $site_detail['statking_id'];
         $site_name = Mysite::instance($site_id)->get('domain');
         //$statking_id = 100097;
         require_once Kohana::find_file('vendor', 'phprpc/phprpc_client', TRUE);
         $client = new PHPRPC_Client($this->phprpc_server);
         $date_today = date('Y-m-d');
         //今日数据
         $phprpc_statking_key = Kohana::config('phprpc.remote.statking.api_key');
         $args = array($statking_id, strtotime($date_today . $this->time_offset));
         $sign = md5(json_encode($args) . $phprpc_statking_key);
         $today = $client->get_data_pv_ip_by_time($statking_id, strtotime($date_today . $this->time_offset), $sign);
         //昨日数据
         $phprpc_statking_key = Kohana::config('phprpc.remote.statking.api_key');
         $args = array($statking_id, strtotime(date('Y-m-d', time() - 86400) . $this->time_offset));
         $sign = md5(json_encode($args) . $phprpc_statking_key);
         $yesterday = $client->get_data_pv_ip_by_time($statking_id, strtotime(date('Y-m-d', time() - 86400) . $this->time_offset), $sign);
         //24小时流量
         $now_hour = intval(date('H'));
         $hours = array();
         $ps1 = $ps2 = $ct = $chart_data = '';
         $pv_max = $ip_min = 0;
         for ($i = $now_hour + 1; $i <= 23; $i++) {
             $hours[]['h'] = $i;
             $hours[]['v'] = $yesterday['hours'][$i];
             $ct == '' ? $ct .= $i : ($ct .= ',' . $i);
             $ps1 == '' ? $ps1 .= $yesterday['hours'][$i]['pv'] : ($ps1 .= ',' . $yesterday['hours'][$i]['pv']);
             $ps2 == '' ? $ps2 .= $yesterday['hours'][$i]['ip_count'] : ($ps2 .= ',' . $yesterday['hours'][$i]['ip_count']);
             $chart_data .= "{$i};{$yesterday['hours'][$i]['pv']};{$yesterday['hours'][$i]['ip_count']}\n";
             if ($yesterday['hours'][$i]['pv'] > $pv_max) {
                 $pv_max = $yesterday['hours'][$i]['pv'];
             }
             $ip_min == 0 ? $ip_min = $yesterday['hours'][$i]['ip_count'] : '';
             if ($yesterday['hours'][$i]['ip_count'] < $ip_min) {
                 $ip_min = $yesterday['hours'][$i]['ip_count'];
             }
         }
         for ($i = 0; $i <= $now_hour; $i++) {
             $hours[]['h'] = $i;
             $hours[]['v'] = $today['hours'][$i];
             $ct == '' ? $ct .= $i : ($ct .= ',' . $i);
             $ps1 == '' ? $ps1 .= $today['hours'][$i]['pv'] : ($ps1 .= ',' . $today['hours'][$i]['pv']);
             $ps2 == '' ? $ps2 .= $today['hours'][$i]['ip_count'] : ($ps2 .= ',' . $today['hours'][$i]['ip_count']);
             $chart_data .= "{$i};{$today['hours'][$i]['pv']};{$today['hours'][$i]['ip_count']}\n";
             if ($today['hours'][$i]['pv'] > $pv_max) {
                 $pv_max = $today['hours'][$i]['pv'];
             }
             $ip_min == 0 ? $ip_min = $today['hours'][$i]['ip_count'] : '';
             if ($today['hours'][$i]['ip_count'] < $ip_min) {
                 $ip_min = $today['hours'][$i]['ip_count'];
             }
         }
         if ($pv_max == $ip_min) {
             $pv_max = $ip_min + 10;
         }
         $src1 = "/sitestat/chart?type=lc&w=800&h=300&ma={$pv_max}&mi={$ip_min}&r=10&t=pv-ip&ct={$ct}&sp=30&g=2&ps1={$ps1}&ps2={$ps2}&clr1=255,0,0&clr2=0,255,0";
         $src2 = "/sitestat/chart?type=bg&w=800&h=300&ma={$pv_max}&mi={$ip_min}&r=10&t=pv-ip&ct={$ct}&sp=30&g=2&ps1={$ps1}&ps2={$ps2}&clr1=255,0,0&clr2=0,255,0";
         $flash1 = "<embed width=\"800\" height=\"400\" flashvars=\"path=/amline/&settings_file=/amline/chart_settings/pv_ip.xml&chart_data={$chart_data}\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#FFFFFF\" name=\"img_src1\" id=\"img_src1\" style=\"\" src=\"/amline/amline.swf\" type=\"application/x-shockwave-flash\">";
         $flash2 = "<embed width=\"800\" height=\"400\" flashvars=\"path=/amline/&settings_file=/amline/chart_settings/pv_ip.xml&chart_data={$chart_data}&preloader_color=#999999\" quality=\"high\" bgcolor=\"#FFFFFF\" name=\"img_src2\" id=\"img_src2\" style=\"display:none\" src=\"/amline/amcolumn.swf\" type=\"application/x-shockwave-flash\">";
         //站点概况
         $phprpc_statking_key = Kohana::config('phprpc.remote.statking.api_key');
         $args = array($statking_id);
         $sign = md5(json_encode($args) . $phprpc_statking_key);
         $overview = $client->get_data_pv_ip_by_one_site($statking_id, $sign);
         //来路域名
         $phprpc_statking_key = Kohana::config('phprpc.remote.statking.api_key');
         $args = array($statking_id, strtotime($date_today . $this->time_offset), strtotime($date_today . $this->time_offset));
         $sign = md5(json_encode($args) . $phprpc_statking_key);
         $domains_all = $client->get_data_domain_by_time_range($statking_id, strtotime($date_today . $this->time_offset), strtotime($date_today . $this->time_offset), 0, 1, 10, $sign);
         $domains = $domains_all['data'];
         //受访页面
         $phprpc_statking_key = Kohana::config('phprpc.remote.statking.api_key');
         $args = array($statking_id, strtotime($date_today . $this->time_offset), strtotime($date_today . $this->time_offset));
         $sign = md5(json_encode($args) . $phprpc_statking_key);
         $pages_all = $client->get_data_page_by_time_range($statking_id, strtotime($date_today . $this->time_offset), strtotime($date_today . $this->time_offset), 0, 1, 10, $sign);
         $pages = $pages_all['data'];
         //地区分布
         $phprpc_statking_key = Kohana::config('phprpc.remote.statking.api_key');
         $args = array($statking_id, strtotime($date_today . $this->time_offset), strtotime($date_today . $this->time_offset));
         $sign = md5(json_encode($args) . $phprpc_statking_key);
         $areas_all = $client->get_data_country_by_time_range($statking_id, strtotime($date_today . $this->time_offset), strtotime($date_today . $this->time_offset), 0, 1, 10, $sign);
         $areas = $areas_all['data'];
         $ps = $pts = '';
         $chart_data = "[title];[value]\n";
         for ($i = 1; $i < count($areas); $i++) {
             $ps .= $ps == '' ? $areas[$i]['pv'] : ',' . $areas[$i]['pv'];
             $pts .= $pts == '' ? $areas[$i]['name'] : ',' . $areas[$i]['name'];
             $chart_data .= "{$areas[$i]['name']};{$areas[$i]['pv']}\n";
         }
         $chart_data = urlencode($chart_data);
         $src3 = "/sitestat/chart?type=pc&w=400&h=200&ps={$ps}&pts={$pts}";
         $flash3 = "<embed width=\"800\" height=\"400\" flashvars=\"path=/amline/&settings_file=/amline/chart_settings/pie.xml&chart_data={$chart_data}\" quality=\"high\" bgcolor=\"#FFFFFF\" name=\"amline\" id=\"amline\" style=\"\" src=\"/amline/ampie.swf\" type=\"application/x-shockwave-flash\">";
         $content = new View($this->package_name . '/' . $this->class_name . '/' . 'index');
         $this->template->content = $content;
         $this->template->content->site_name = $site_name;
         $this->template->content->sitestat_left = new View($this->package_name . '/sitestat_left');
         $this->template->content->sitestat_left->overview = 1;
         $this->template->content->today_pv_ip = $today['day'];
         $this->template->content->yesterday_pv_ip = $yesterday['day'];
         $this->template->content->average = $overview['average'];
         $this->template->content->highest = $overview['highest'];
         $this->template->content->total = $overview['total'];
         $this->template->content->src1 = $src1;
         $this->template->content->src2 = $src2;
         $this->template->content->src3 = $src3;
         $this->template->content->flash1 = $flash1;
         $this->template->content->flash2 = $flash2;
         $this->template->content->flash3 = $flash3;
         $this->template->content->domains = $domains;
         $this->template->content->pages = $pages;
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }
Exemple #17
0
<?php

defined('SYSPATH') or die('No direct access allowed.');
?>
<!-- header_content -->
<div class="new_sub_menu">
    <div class="new_sub_menu_con">
        <div class="newgrid_tab fixfloat">
            <ul>
                <li class="on">添加物流方式</li>
            </ul>
            <span class="fright">
                <?php 
if (site::id() > 0) {
    ?>
                当前站点:<a href="http://<?php 
    echo site::domain();
    ?>
" target="_blank" title="点击访问"><?php 
    echo site::domain();
    ?>
</a> [ <a href="<?php 
    echo url::base();
    ?>
manage/site/out">返回</a> ]
                <?php 
}
?>
            </span>
        </div>
    </div>
Exemple #18
0
 public function transport_relation()
 {
     $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
     try {
         //$profiler = new Profiler;
         //* 初始化返回数据 */
         $return_data = array();
         //* 收集请求数据 ==根据业务逻辑定制== */
         $request_data = $this->input->get();
         //* 权限验证 */
         $site_id = site::id();
         if ($site_id == 0) {
             throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400);
         }
         role::check('product_classify', $site_id, 0);
         //数据验证
         if (!isset($request_data['classify_id']) || !preg_match('/^\\d+$/', $request_data['classify_id'])) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         // 调用底层服务
         $classify = ClassifyService::get_instance()->get($request_data['classify_id']);
         if ($classify['site_id'] != $site_id) {
             throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404);
         }
         $arguments = empty($classify['argument_relation_struct']) ? array() : json_decode($classify['argument_relation_struct'], TRUE);
         $features = ClassifyService::get_instance()->get_features_by_classify_id($request_data['classify_id']);
         $return_struct['arguments'] = $arguments;
         $return_struct['features'] = $features;
         //* 补充&修改返回结构体 */
         $return_struct['status'] = 1;
         $return_struct['code'] = 200;
         $return_struct['msg'] = '';
         $return_struct['content'] = $return_data;
         //* 请求类型 */
         if ($this->is_ajax_request()) {
             // ajax 请求
             // json 输出
             $this->template->content = $return_struct;
         } else {
             // html 输出
             //* 模板输出 */
             $content = new View($this->package . '/' . $this->class_name . '/' . __FUNCTION__);
             //* 变量绑定 */
             $this->template->title = Kohana::config('site.name');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
             //:: 当前应用专用数据
         }
         // end of request type determine
     } catch (MyRuntimeException $ex) {
         $return_struct['status'] = 0;
         $return_struct['code'] = $ex->getCode();
         $return_struct['msg'] = $ex->getMessage();
         //TODO 异常处理
         //throw $ex;
         if ($this->is_ajax_request()) {
             $this->template->content = $return_struct;
         } else {
             $this->template->return_struct = $return_struct;
             $content = new View('info');
             $this->template->content = $content;
             //* 请求结构数据绑定 */
             $this->template->content->request_data = $request_data;
             //* 返回结构体绑定 */
             $this->template->content->return_struct = $return_struct;
         }
     }
 }