public function index() { /* 初始化默认查询条件 */ $newsletter_query_struct = array('where' => array('user_id' => 0), 'like' => array(), 'orderby' => array(), 'limit' => array('per_page' => 20, 'offset' => 0)); /* 权限检查 得到所有可管理站点ID列表 */ $site_id_list = role::check('newsletter'); /* Newsletter列表模板 */ $this->template->content = new View("user/newsletter"); /* 搜索功能 */ $search_arr = array('email', 'ip'); $search_value = $this->input->get('search_value'); $search_type = $this->input->get('search_type'); $where_view = array(); if ($search_arr) { foreach ($search_arr as $value) { if ($search_type == $value && strlen($search_value) > 0) { $newsletter_query_struct['where'][$value] = $search_value; if ($value == 'ip') { $newsletter_query_struct['where'][$value] = tool::myip2long($search_value); } } } $where_view['search_type'] = $search_type; $where_view['search_value'] = $search_value; } //当前切入的站点查询条件 $site_in = site::current_query_site_ids(); $where_view['site_id'] = ''; $newsletter_query_struct['where']['site_id'] = $site_in; /* 列表排序 */ $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('site_id' => 'ASC'), 3 => array('site_id' => 'DESC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('date_add' => 'ASC'), 7 => array('date_add' => 'DESC'), 8 => array('ip' => 'ASC'), 9 => array('ip' => 'DESC'), 10 => array('active' => 'ASC'), 11 => array('active' => 'DESC')); $orderby = controller_tool::orderby($orderby_arr); $newsletter_query_struct['orderby'] = $orderby; /* 每页显示条数 */ $per_page = controller_tool::per_page(); $newsletter_query_struct['limit']['per_page'] = $per_page; /* 调用分页 */ $this->pagination = new Pagination(array('total_items' => Mynewsletter::instance()->query_count($newsletter_query_struct), 'items_per_page' => $per_page)); $newsletter_query_struct['limit']['offset'] = $this->pagination->sql_offset; $newsletters = Mynewsletter::instance()->query_assoc($newsletter_query_struct); foreach ($newsletters as $key => $value) { $site = Mysite::instance($value['site_id'])->get(); $newsletters[$key]['site'] = $site; } /* 调用列表 */ $this->template->content->newsletter_list = $newsletters; /* 搜索信息保存 */ $this->template->content->where = $where_view; }
/** * 删除模板 * @param int $id */ public function delete($id = 0) { $id = $id ? $id : $this->data['id']; $theme = ORM::factory('theme', $id); if ($theme->loaded) { $site = Mysite::instance()->get(); if (isset($site['theme_id']) && $site['theme_id'] == $id) { return false; } $this->clear_theme($theme->id); $theme->delete(); return true; } else { return false; } }
/** * 得到当前站点的统计信息 */ public function statking() { // 初始化返回数据 $return_data = array(); //请求结构体 $request_data = array(); try { $site_detail = Mysite::instance()->detail(); $statking_id = $site_detail['statking_id']; $statking_main = statking::get_main_detail($statking_id); //0.7s $statking_str = statistics::get_statkings($statking_id); //0.8s $this->template = new View('template_blank'); $this->template->content = new View("site/statistics_statking"); $this->template->content->statking_str = $statking_str; $this->template->content->statking_main = $statking_main; $html = $this->template->render(); $data = array(); $data['statking_str'] = $statking_str; $data['statking_main'] = $statking_main; $return_data['count_ip'] = $statking_main['site']['all_count_ip']; $return_data['html'] = $html; exit(json_encode($return_data)); } 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 = new View('layout/empty_html'); $this->template->content = $return_struct['msg']; } 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; } } }
/** * save a record * @return void */ function save() { $error = false; $errorMsg = ""; $model = $this->getModel($this->get('suffix')); $config = Mysite::getInstance(); $properties = $config->getProperties(); foreach (@$properties as $key => $value) { unset($row); $row = $model->getTable('config'); $newvalue = JRequest::getVar($key); $value_exists = array_key_exists($key, $_POST); if ($value_exists && !empty($key)) { // proceed if newvalue present in request. prevents overwriting for non-existent values. $row->load(array('config_name' => $key)); $row->config_name = $key; $row->value = $newvalue; if (!$row->save()) { $error = true; $errorMsg .= JText::_("Could not store") . " {$key} :: " . $row->getError() . " - "; } } } if (!$error) { $this->messagetype = 'message'; $this->message = JText::_('Saved'); $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onAfterSave' . $this->get('suffix'), array($row)); } else { $this->messagetype = 'notice'; $this->message = JText::_('Save Failed') . " - " . $errorMsg; } $redirect = "index.php?option=com_mysite"; $task = JRequest::getVar('task'); switch ($task) { default: $redirect .= "&view=" . $this->get('suffix'); break; } $redirect = JRoute::_($redirect, false); $this->setRedirect($redirect, $this->message, $this->messagetype); }
/** * get carrier_range data * * @param Array $where * @param Array $orderby * @param Int $limit * @param Int $offset * @param Int $in * @return Array */ private function _data($where = NULL, $in = NULL, $orderby = NULL, $limit = 0, $offset = 100) { $list = array(); $orm = ORM::factory('carrier_range'); if (!empty($where)) { $orm->where($where); } if (!empty($in)) { $orm->in('site_id', $in); } if (!empty($orderby)) { $orm->orderby($orderby); } $orm_list = $orm->find_all($limit, $offset); $list = array(); foreach ($orm_list as $key => $rs) { $list[$key] = $rs->as_array(); $list[$key]['site'] = Mysite::instance($rs->site_id)->get(); } return $list; }
/** * * @return void **/ function _default($tpl = null) { Mysite::load('DSCTools', 'library.tools'); // check config $row = Mysite::getInstance(); $this->assign('row', $row); // add toolbar buttons JToolBarHelper::save('save'); JToolBarHelper::cancel('close', JText::_('Close')); // plugins $filtered = array(); $items = DSCTools::getPlugins(); for ($i = 0; $i < count($items); $i++) { $item =& $items[$i]; // Check if they have an event if ($hasEvent = DSCTools::hasEvent($item, 'onListConfigMysite')) { // add item to filtered array $filtered[] = $item; } } $items = $filtered; $this->assign('items_sliders', $items); // Add pane jimport('joomla.html.pane'); $sliders = JPane::getInstance('sliders'); $this->assign('sliders', $sliders); // form $validate = JUtility::getToken(); $form = array(); $view = strtolower(JRequest::getVar('view')); $form['action'] = "index.php?option=com_mysite&controller={$view}&view={$view}"; $form['validate'] = "<input type='hidden' name='{$validate}' value='1' />"; $this->assign('form', $form); // set the required image // TODO Fix this to use defines $required = new stdClass(); $required->text = JText::_('Required'); $required->image = "<img src='" . JURI::root() . "/media/com_mysite/images/required_16.png' alt='{$required->text}'>"; $this->assign('required', $required); }
/** * 获取前台分类链接 * * @param int id 分类id * @return string 分类链接 */ public static function permalink($id, $absolute = true) { $category_service = CategoryService::get_instance(); $category = $category_service->get($id); $route = Myroute::instance()->get(); $route_type = $route['type']; $category_route = $route['category']; $category_suffix = $route['category_suffix']; $domain = Mysite::instance()->get('domain'); if ($route_type == 0) { // 0: none get category and product with id $category_permalink = $category_route . '/' . $category['id']; } if ($route_type == 1) { // 1: get product with {product}/permalink $category_permalink = $category_route . '/' . urlencode($category['uri_name']); } if ($route_type == 2 || $route_type == 4) { // 2: get category and product with {category_permalink} and {category+permalink}/{product_permalink} $category_permalink = urlencode($category['uri_name']); } if ($route_type == 3) { // 3: get category and prdouct with {category_permalink1}/.../{category_permalinkn} and {category_permalink1}/.../{category_permalinkn}/{product_permalink} $parents = $category_service->get_parents_by_category_id($id); $category_permalink = ''; foreach ($parents as $category) { if ($category == end($parents)) { $category_permalink .= urlencode($category['uri_name']); } else { $category_permalink .= urlencode($category['uri_name']) . '/'; } } } if ($absolute) { return 'http://' . $domain . '/' . $category_permalink . $category_suffix; } else { return $category_permalink . $category_suffix; } }
/** * 获得商品前台链接 * * @param int 商品id * @param String 商品链接 */ public static function permalink($product) { static $routes = array(); static $categorys = array(); if (!is_array($product)) { $product = ProductService::get_instance()->get($product); } $routes = Myroute::instance()->get(); $domain = Mysite::instance()->get('domain'); $route_type = $routes['type']; $product_suffix = $routes['product_suffix']; $product_route = $routes['product']; if ($route_type == 2 or $route_type == 3) { if (!isset($categorys[$product['category_id']])) { $categorys[$product['category_id']] = CategoryService::get_instance()->get($product['category_id']); } } $permalink = ''; $product['uri_name'] = isset($product['uri_name']) ? $product['uri_name'] : $product['id']; switch ($route_type) { case 0: //$permalink = $product_route.'/'.$product['id'].$product_suffix; $permalink = $product_route . $product['id']; break; case 1: $permalink = $product_route . '/' . urlencode($product['uri_name']) . $product_suffix; break; case 2: $permalink = urlencode($categorys[$product['category_id']]['uri_name']) . '/' . urlencode($product['uri_name']) . $product_suffix; break; case 3: $permalink = urlencode($categorys[$product['category_id']]['uri_name']) . '/' . urlencode($product['uri_name']) . $product_suffix; break; case 4: $permalink = $product_route . '/' . urlencode($product['uri_name']) . $product_suffix; break; } return Kohana::config('config.front_protocol') . $domain . '/' . $permalink; }
protected function get_site_name($site_id) { if (!isset($this->site_names[$site_id])) { $site_name = Mysite::instance($site_id)->get('name'); if ($site_name === NULL) { throw new MyRuntimeException(sprintf('未找到 ID 为 "%s" 的站点', $site_id)); } $this->site_names[$site_id] = $site_name; } return $this->site_names[$site_id]; }
/** * 批量更新分类的name_url */ public function update_category_name_url() { $site = Mysite::instance($this->site_id)->get(); if ($_POST) { $domain = $this->input->post('domain'); if (empty($domain) || $domain != $site['domain']) { remind::set(Kohana::lang('o_global.input_error'), 'site/update/update_category_name_url'); } $query_struct = array('where' => array('site_id' => $this->site_id), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); $category_count = Mycategory::instance()->count($query_struct); $category_names = array(); //1000个商品以下直接读取所有的商品 if ($category_count < 1000) { $query_struct['limit']['per_page'] = $category_count; $categorys = Mycategory::instance()->lists($query_struct); $category_name = array(); foreach ($categorys as $key => $value) { $category_name = $value['name']; //判断是否为中文的商品 if (preg_match('/[\\x7f-\\xff]/', $category_name)) { continue; } $category_name_url = strtolower(product::generate_name_url($category_name)); //过滤重复的NAME URL $name_url_exist = Mycategory::instance()->check_name_url($category_name_url, $this->site_id, $value['id']); $perfix = 1; while ($name_url_exist) { $category_name_url = $category_name_url . '-' . $perfix; $name_url_exist = Mycategory::instance()->check_name_url($category_name_url, $this->site_id, $value['id']); $perfix++; } $data = array(); $data['name_url'] = $category_name_url; if (!Mycategory::instance($value['id'])->edit($data)) { $category_names[] = $value['name']; } } } else { remind::set(Kohana::lang('o_site.product_request_check'), 'site/update/update_category_name_url'); } if (count($category_names) > 0) { $category_name_str = ''; foreach ($category_names as $key => $value) { $category_name_str = $value . '|'; } remind::set(Kohana::lang('o_site.name_update_error') . $category_name_str, 'site/update/update_category_name_url'); } else { remind::set(Kohana::lang('o_site.name_update_success'), 'site/update/update_category_name_url', 'success'); } } $this->template->content = new View("site/update_category_name_url"); $this->template->content->site = $site; }
/** * 配置站点的支付成功代码 */ public function pay_code() { // 初始化返回数据 $return_data = array(); //请求结构体 $request_data = array(); try { /* 管理员才能进行代码更新操作 */ if ($this->manager_is_admin == 1) { $site = Mysite::instance($this->site_id)->get(); $site_detail = Mysite::instance($this->site_id)->detail(); //无站点ID非法操作 if (!$site['id']) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 401); } //更新pay_code信息 if ($_POST) { $pay_code = $this->input->post('pay_code'); if (empty($pay_code)) { throw new MyRuntimeException(Kohana::lang('o_site.site_config_payment_success_cannot_submit'), 402); } //更新站点robots信息 $data = array(); $data['pay_code'] = $pay_code; if (Mysite_detail::instance()->update_by_site_id($this->site_id, $data)) { remind::set(Kohana::lang('o_global.update_success'), 'site/config/pay_code', 'success'); } else { remind::set(Kohana::lang('o_global.update_error'), 'site/config/pay_code'); } } $pay_code = isset($site_detail['pay_code']) ? $site_detail['pay_code'] : ''; $this->template->content = new View("site/pay_code"); $this->template->content->pay_code = $pay_code; } else { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } } 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 = new View('layout/empty_html'); $this->template->content = $return_struct['msg']; } 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; } } }
<?php define('hopedir', dirname(__FILE__) . DIRECTORY_SEPARATOR); define('plugdir', dirname(__FILE__) . '/plug'); define('M_SC', 'mysite'); date_default_timezone_set("Asia/Hong_Kong"); //时间区域 header("Content-Type:text/html;charset=utf-8"); //输出格式 if (!file_exists(hopedir . 'config/hopeconfig.php')) { echo '未安装程序<a href="/install/index.php">进入安装页面</a>'; exit; } include hopedir . '/lib/function.php'; $config = hopedir . "/config/hopeconfig.php"; $Mysite = hopedir . "/lib/core/Mysite.php"; require $Mysite; Mysite::createWebApp($config)->run();
/** * get user_log data * * @param Array $query_struct * @param Array $orderby * @param Int $limit * @param Int $offset * @return Array */ private function _data($query_struct = array(), $orderby = NULL, $limit = 1000, $offset = 0) { $list = array(); $where = array(); $like = array(); $in = array(); $user_log = ORM::factory('user_log'); //WHERE if (count($query_struct) > 0) { if (isset($query_struct['where'])) { foreach ($query_struct['where'] as $key => $value) { $where[$key] = $value; } } } //LIKE if (count($query_struct) > 0) { if (isset($query_struct['like'])) { foreach ($query_struct['like'] as $key => $value) { $like[$key] = $value; } } } //IN if (count($query_struct) > 0) { if (isset($query_struct['in'])) { foreach ($query_struct['in'] as $key => $value) { $in[$key] = $value; } } } //WHERE if (count($where) > 0) { $user_log->where($where); } //LIKE if (count($like) > 0) { $user_log->like($like); } //IN if (count($in) > 0) { foreach ($in as $key => $value) { $user_log->in($key, $value); } } if (!empty($orderby)) { $user_log->orderby($orderby); } $orm_list = $user_log->find_all($limit, $offset); //var_dump($orm_list);exit; foreach ($orm_list as $item) { $merge_arr['site_name'] = Mysite::instance()->get('name'); $merge_arr['manager_name'] = Mymanager::instance($item->manager_id)->get('name'); $list[] = array_merge($item->as_array(), $merge_arr); } return $list; }
/** * 添加存储文件 * */ public function add_attach($file_meta) { $site_id = $file_meta['site_id']; $site = Mysite::instance($site_id)->get(); $site_domain = $site['domain']; //'www.2.opococ.com'; $timestamp_current = time(); $src_ip_address = Input::instance()->ip_address(); // 需要提效数据 $attach_meta = array('siteId' => $site_id, 'siteDomain' => $site_domain); $attachment_data_original = array('filePostfix' => $file_meta['type'], 'fileMimeType' => $file_meta['mime'], 'fileSize' => $file_meta['size'], 'fileName' => $file_meta['name'], 'srcIp' => $src_ip_address, 'attachMeta' => json_encode($attach_meta), 'createTimestamp' => $timestamp_current, 'modifyTimestamp' => $timestamp_current); require_once Kohana::find_file('vendor', 'phprpc/phprpc_client', TRUE); $attachmentService = new PHPRPC_Client(Kohana::config('phprpc.remote.Attachment.host')); $phprpcApiKey = Kohana::config('phprpc.remote.Attachment.apiKey'); // 调用后端添加附件信息,并调用存储服务存储文件 $args_org = array($attachment_data_original); $sign_org = md5(json_encode($args_org) . $phprpcApiKey); $attachment_original_id = $attachmentService->phprpc_addAttachmentFileData($attachment_data_original, @file_get_contents($file_meta['tmpfile']), $sign_org); return $attachment_original_id; }
/** * 用于提交emailafriend时给自己发送邮件 * @param $email 自己的邮件地址 * @param $title_param 标题变量 * @param $content_param 内容变量 */ public static function email_to_me($email, $title_param, $content_param) { $site_id = Mysite::instance()->id(); //判断是否生成打折号并取得打折号的折扣信息 $config = Mycoupon::instance()->is_generate_discount_num('email_to_me'); if (!empty($config)) { $discount_info = Mycoupon::instance()->get_discount_number($config); } //设置打折信息 $param_data = array(); if (!empty($discount_info)) { $param_data = array('{discount_num}' => $discount_info['discount_num'], '{expiration_date}' => $discount_info['expiration_date'], '{discount_value}' => $discount_info['discount_value']); } //判断取得的模板类型 $mail_type = 'email_to_me'; if (empty($param_data)) { $mail_type = 'email_to_meNoDiscountNumber'; } $content_param = array_merge($content_param, $param_data); //发送邮件 $from_mail = ''; $to_mail = $email; self::send_mail(1, $mail_type, $to_mail, $from_mail, $title_param, $content_param); }
public static function createWebApp($config = NULL) { self::$app = self::createApp('IApplication', $config); return self::$app; }
<?php /** * @version 1.5 * @package Fingertips * @author Dioscouri Design * @link http://www.dioscouri.com * @copyright Copyright (C) 2007 Dioscouri Design. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php */ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); Mysite::load('MysiteTable', 'tables.base'); class MysiteTableMenus extends MysiteTable { function MysiteTableMenus(&$db) { $tbl_key = 'menu_id'; $tbl_suffix = 'menus'; $this->set('_suffix', $tbl_suffix); $name = "mysite"; parent::__construct("#__{$name}_{$tbl_suffix}", $tbl_key, $db); } function reorder($where = '') { $reorder = parent::reorder($where); // now, load the parent item for this menutype, and reorder it $table = JTable::getInstance('Items', 'MysiteTable'); $table->load(array('menutype' => $this->menutype, 'parent' => 0)); if (!empty($table->item_id)) { // reorder
<?php echo JText::_("Copyright"); ?> : <?php echo Mysite::getInstance()->getCopyrightYear(); ?> © <a href="<?php echo $url; ?> " target="_blank">Dioscouri Design</a> <br/> <?php echo JText::_("Version"); ?> : <?php echo Mysite::getInstance()->getVersion(); ?> </td> <td style="text-align: right; width: 33%;"> <a href="<?php echo $url; ?> " target="_blank"><img src="<?php echo $img_path . "/" . $img_file; ?> "></img></a> </td> </tr> </tbody> </table>
/** * SEO信息编辑操作 */ public function do_edit() { //收集请求 $request_data = $this->input->post(); //* 权限验证 */ $site_id = site::id(); $site_id_list = role::check('seo_manage', 0, 0); if (empty($site_id_list)) { remind::set('access denied', request::referrer(), 'error'); } //检测输入的域名是否与操作的域名一致 $site_name = Mysite::instance($site_id)->get('domain'); if ($request_data['site_domain'] != $site_name) { remind::set('输入的域名与操作的站点有误', request::referrer(), 'error'); } // 验证 - 数据有效性 $seo_manages = Myseo_manage::instance($request_data['id'])->get(); if (!$seo_manages['id']) { remind::set('无效SEO信息,请重试', request::referrer(), 'error'); } // 权限验证 if ($site_id != $seo_manages['site_id'] || !in_array($seo_manages['site_id'], $site_id_list)) { remind::set('access denied', request::referrer(), 'error'); } //执行添加 if ($_POST) { $set_data = array('parent_id' => $request_data['parent_id'], 'site_id' => $seo_manages['site_id'], 'site_domain' => $request_data['site_domain'], 'meta_title' => $request_data['meta_title'], 'meta_keywords' => $request_data['meta_keywords'], 'meta_description' => $request_data['meta_description'], 'update_timestamp' => time()); if (!empty($request_data['is_contain_child'])) { $set_data['is_contain_child'] = $request_data['is_contain_child']; } else { $set_data['is_contain_child'] = 0; } if (Myseo_manage::instance($seo_manages['id'])->update($set_data)) { Myseo_manage::instance()->update_seo_manage_by_site_id($site_id); remind::set('编辑 SEO信息成功', 'product/seo_manage', 'success'); } else { remind::set('编辑 SEO信息 失败', request::referrer(), 'error'); } } }
public function build() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //$profiler = new Profiler; //* 初始化返回数据 */ $return_data = array(); //* 收集请求数据 ==根据业务逻辑定制== */ $request_data = $this->input->post(); //* 实现功能后屏蔽此异常抛出 */ //throw new MyRuntimeException('Not Implemented',501); //权限验证 if ($this->site_id == 0) { throw new MyRuntimeException(Kohana::lang('o_global.select_site'), 400); } role::check('default', $this->site_id, 0); // 调用底层服务 $sitemap_service = SitemapService::get_instance(); //业务逻辑 $xmlContent = ''; $xmlContent .= '<?xml version="1.0" encoding="UTF-8"?>'; $xmlContent .= '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; //添加首页 if (!empty($request_data['index']) && is_numeric($request_data['index'])) { $priority = number_format($request_data['index'], 1); } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } $site_domain = Mysite::instance($this->site_id)->get('domain'); $xmlContent .= sitemap::Render('http://' . $site_domain, 0, 'always', $priority); //添加分类页面 $categories = $sitemap_service->get_category_page_by_site_id($this->site_id); if (!empty($request_data['category']) && is_numeric($request_data['category'])) { $priority = number_format($request_data['category'], 1); } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } if (!empty($categories)) { foreach ($categories as $category) { if (empty($request_data['exclude_category']) || !empty($request_data['exclude_category']) && !in_array($category['id'], $request_data['exclude_category'])) { $xmlContent .= sitemap::Render(category::permalink($category['id']), 0, 'weekly', $priority); } } } //添加商品页面 if (!empty($request_data['product']) && is_numeric($request_data['product'])) { $priority = number_format($request_data['product'], 1); } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } if (isset($request_data['on_sale'])) { $on_sale = intval($request_data['on_sale']); } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } $products = $sitemap_service->get_product_page_by_site_id($this->site_id, $on_sale); if (!empty($request_data['exclude_product'])) { if (preg_match('/^([a-zA-Z0-9_]+,)*[a-zA-Z0-9_]+$/i', $request_data['exclude_product'])) { $request_data['exclude_product'] = explode(',', $request_data['exclude_product']); } else { throw new MyRuntimeException(Kohana::lang('o_site.product_id_format_check'), 404); } } if (!empty($products)) { foreach ($products as $product) { if (empty($request_data['exclude_product'])) { $xmlContent .= sitemap::Render(product::permalink($product['id']), $product['update_timestamp'], 'weekly', $priority); } elseif (!empty($request_data['exclude_product']) && !in_array($product['sku'], $request_data['exclude_product'])) { $xmlContent .= sitemap::Render(product::permalink($product['id']), $product['update_timestamp'], 'weekly', $priority); } } } //添加促销页 if (!empty($request_data['promotion']) && is_numeric($request_data['promotion'])) { $priority = number_format($request_data['promotion'], 1); } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } $promotions = $sitemap_service->get_promotion_page_by_site_id($this->site_id); if (!empty($promotions)) { $route = Myroute::instance()->get(); $action = $route['promotion']; foreach ($promotions as $promotion) { $xmlContent .= sitemap::Render('http://' . $site_domain . '/' . $action . '/' . $promotion['id'], time(), 'weekly', $priority); } } //添加文案页 if (!empty($request_data['doc']) && is_numeric($request_data['doc'])) { $priority = number_format($request_data['doc'], 1); } else { throw new MyRuntimeException(Kohana::lang('o_global.bad_request'), 404); } $docs = $sitemap_service->get_doc_page_by_site_id($this->site_id); if (!empty($docs)) { foreach ($docs as $doc) { $lastmod = strtotime($doc['updated']); $xmlContent .= sitemap::Render('http://' . $site_domain . '/' . $doc['permalink'], $lastmod, 'weekly', $priority); } } $xmlContent .= '</urlset>'; $data['sitemap'] = $xmlContent; if (!Mysite_detail::instance()->update_by_site_id($this->site_id, $data)) { throw new MyRuntimeException(Kohana::lang('o_site.sitemap_error_handle'), 500); } //* 补充&修改返回结构体 */ $return_struct['status'] = 1; $return_struct['code'] = 200; $return_struct['msg'] = '操作成功'; $return_struct['content'] = $return_data; $return_struct['action'] = array('type' => 'location', 'url' => url::base() . 'site/sitemap'); //* 请求类型 */ 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->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; } } }
public function category_features() { // 初始化默认查询条件 $request_struct_current = array('where' => array('site_id' => NULL), 'like' => array(), 'orderby' => array('id' => 'DESC'), 'limit' => array('per_page' => 20, 'offset' => 0)); // 收集请求数据 $request_data = $this->input->get(); $category_id = $request_data['id']; // 验证 - 数据有效性 $category = Mycategory::instance($category_id)->get(); if (!$category['id']) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } /* b2c类型的站点列表 */ $site_id_list = role::check('product_virtual_category', 0, 0); // 权限验证 if (empty($site_id_list)) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } if (!in_array($category['site_id'], $site_id_list)) { remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error'); } // 排序处理 controller_tool::request_orderby($request_struct_current, $request_data); // 每页条目数 controller_tool::request_per_page($request_struct_current, $request_data); // 站点查询 $request_struct_current['where']['site_id'] = $category['site_id']; //当前查询 $request_struct_current['where']['category_id'] = $category['id']; $count = Mycategory_feature::instance()->count($request_struct_current); // 模板输出 分页 $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $request_struct_current['limit']['per_page'])); $request_struct_current['limit']['offset'] = $this->pagination->sql_offset; $category_feature_list = Mycategory_feature::instance()->lists($request_struct_current); foreach ($category_feature_list as $key => $rs) { $category_feature_list[$key]['site'] = Mysite::instance($rs['site_id'])->get(); if ($rs['type'] == 1) { $category_feature_list[$key]['type'] = '规格'; $category_feature_list[$key]['group_id'] = Myattribute_group::instance($rs['group_id'])->get('name'); $category_feature_list[$key]['value_id'] = Myattribute::instance($rs['value_id'])->get('name'); } if ($rs['type'] == 2) { $category_feature_list[$key]['type'] = '附加属性'; $category_feature_list[$key]['group_id'] = Myfeature_group::instance($rs['group_id'])->get('name'); $category_feature_list[$key]['value_id'] = Myfeature::instance($rs['value_id'])->get('name'); } } // 模板输出 $this->template->content = new View("product/virtualcategory_features"); // 变量绑定 $this->template->content->category_feature_list = $category_feature_list; $this->template->content->count = $count; // 当前应用专用数据 $this->template->content->data = $category; }
public function edit() { $return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array()); try { //* 初始化返回数据 */ $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('inquiry_subject', $site_id, 0); //数据验证 $inquieysubject_service = InquirysubjectService::get_instance(); if (!isset($request_data['id']) || !is_numeric($request_data['id'])) { throw new MyRuntimeException(Kohana::lang('o_global.input_error'), 404); } $inquieysubject = $inquieysubject_service->get($request_data['id']); if ($inquieysubject['site_id'] != $site_id) { throw new MyRuntimeException(Kohana::lang('o_global.access_denied'), 403); } //返回数据 $return_data['data'] = $inquieysubject; //当前站点 $site_name = Mysite::instance($inquieysubject['site_id'])->get('name'); //* 补充&修改返回结构体 */ $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; //:: 当前应用专用数据 $this->template->content->site_name = $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; } } }
<?php /** * @version 1.5 * @package MySite * @author Dioscouri Design * @link http://www.dioscouri.com * @copyright Copyright (C) 2007 Dioscouri Design. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php */ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); Mysite::load('MysiteViewBase', 'views.base'); class MysiteViewMenus extends MysiteViewBase { function _defaultToolbar() { JToolBarHelper::custom('generateItems', "refresh", "refresh", JText::_('Sync Sitemap Items'), true); JToolBarHelper::deleteList(JText::_('VALIDDELETEITEMS')); } /** * * @return void **/ function _form($tpl = null) { parent::_form($tpl); jimport('joomla.html.pane'); $model = $this->getModel(); // get the data $row = $model->getTable();
/** * * @param unknown_type $selected * @param unknown_type $name * @param unknown_type $attribs * @param unknown_type $idtag * @param unknown_type $allowAny * @param unknown_type $allowNone * @param unknown_type $title * @param unknown_type $title_none * @param unknown_type $enabled */ public static function item($selected, $name = 'filter_parentid', $attribs = array('class' => 'inputbox', 'size' => '1'), $idtag = null, $allowAny = false, $allowNone = false, $title = 'Select Parent', $title_none = 'No Parent', $enabled = null) { JModel::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_mysite' . DS . 'models'); $model = JModel::getInstance('Items', 'MysiteModel'); $model->setState('order', 'tbl.ordering'); $model->setState('direction', 'ASC'); // establish the hierarchy of the menu $children = array(); // get all rows from DB $rows = $model->getAll(); // get children and create new list foreach ($rows as $v) { $parent = $v->parent; $v->parent_id = $v->parent; $items = @$children[$parent] ? $children[$parent] : array(); array_push($items, $v); $children[$parent] = $items; } // set the max level $level = strlen($model->getState('filter_levellimit')) ? $model->getState('filter_levellimit') - 1 : 9999; // indent the list Mysite::load('MysiteMenu', 'library.menu'); $items = MysiteMenu::treerecurse(0, '', array(), $children, $level, 0, 0, '- ', '--'); if ($allowAny) { $list[] = self::option('', "- " . JText::_($title) . " -", 'item_id', 'title'); } if ($allowNone) { $list[] = self::option('0', "- " . JText::_($title_none) . " -", 'item_id', 'title'); } foreach (@$items as $item) { $list[] = self::option($item->item_id, $item->treename, 'item_id', 'title'); } return self::genericlist($list, $name, $attribs, 'item_id', 'title', $selected, $idtag); }
/** * get site type */ public static function type() { $site = Mysite::instance(self::id())->get(); return $site['type']; }
/** * 分配管理员站点 */ public function site($id) { //zhu add $this->_check_manager($id); if ($_POST) { $manager = Mymanager::instance($id)->get(); $target_select = $this->input->post('target_select'); if ($manager['site_num'] < count($target_select)) { remind::set(Kohana::lang('o_manage.self_account') . $manager['site_num'] . Kohana::lang('o_manage.num_site'), 'manage/manager/site/' . $id); } if (!$target_select) { remind::set(Kohana::lang('o_manage.select_site'), 'manage/manager/site/' . $id); } if (Mymanager::instance()->set_sites($id, $_POST)) { remind::set(Kohana::lang('o_global.add_success'), 'manage/manager', 'success'); } else { remind::set(Kohana::lang('o_global.add_error'), 'manage/manager/site/' . $id); } } /* 得到当前所有的站点类型 */ $site_types = Mysite_type::instance()->site_types(); /* 验证是超级管理员就列出所有站点 */ if (role::is_root($this->manager_name)) { $sites = Mysite::instance()->get_sites(); } else { /* 超级管理员外自己不能调整自己的站点 */ if ($this->manager_id == $id) { remind::set(Kohana::lang('o_manage.self_can_not_set_self_site'), 'manage/manager'); } $sites = Mymanager::instance($this->manager_id)->sites(); } $target_sites = Mymanager::instance($id)->sites(); $optional_sites = tool::my_array_diff($sites, $target_sites); $this->template->content = new View("manage/assign_site"); $this->template->content->sites = $optional_sites; $this->template->content->site_types = $site_types; $this->template->content->target_sites = $target_sites; $this->template->content->access_url = url::base() . 'manage/site/ajax_search_site'; $this->template->content->title = '管理员站点分组管理'; }
<?php /** * @version 1.5 * @package Mysite * @author Dioscouri Design * @link http://www.dioscouri.com * @copyright Copyright (C) 2007 Dioscouri Design. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php */ /** ensure this file is being included by a parent file */ defined('_JEXEC') or die('Restricted access'); Mysite::load('MysiteModelBase', 'models.base'); class MysiteModelConfig extends MysiteModelBase { }
</head> <body> <div class="topnav"> <div class="sitenav"> <div class="welcome">您好, <span class="username"><?php if (!empty($manager['name'])) { echo $manager['name']; } ?> </span> 欢迎进入后台管理系统</div> <div class="sitelink"> <a href="/manage/manager/change_password" target="mcMainFrame">修改密码</a> | <a href="/login/logout" target="_parent">安全退出</a> <!-- a target="mcMainFrame" title="点击刷新视图窗口" href="javascript:location.reload()" class="reload">刷新内容</a> <a href="http://<?php echo Mysite::instance()->get('domain'); ?> " target="_blank">网站前台</a--> </div> </div> <div class="leftnav"> <ul> <li class="navleft"></li> <?php foreach ($nodes as $row) { ?> <eq><li><A id="<?php echo $row['target']; ?> " href="javascript:parent.mcMenuFrame.show_menu('<?php echo $row['target'];
private function get_statking_id_site_name() { $site_detail = Mysite::instance($this->site_id)->detail(); $statking_id = $site_detail['statking_id']; $site_name = Mysite::instance($this->site_id)->get('domain'); //$statking_id = 100097; return array('statking_id' => $statking_id, 'site_name' => $site_name); }
// set the options array $options = array('site' => 'site', 'type' => 'components', 'ext' => 'com_mysite'); // Require the base controller Mysite::load('MysiteController', 'controller', $options); // Require specific controller if requested $controller = JRequest::getWord('controller', JRequest::getVar('view')); if (!Mysite::load('MysiteController' . $controller, "controllers.{$controller}", $options)) { $controller = ''; } // redirect to default? if (empty($controller)) { // redirect to default $redirect = "index.php?option=com_mysite&view=dashboard"; $redirect = JRoute::_($redirect, false); JFactory::getApplication()->redirect($redirect); } // load the plugins JPluginHelper::importPlugin('mysite'); // Create the controller $classname = 'MysiteController' . $controller; $controller = Mysite::getClass($classname); // ensure a valid task exists $task = JRequest::getVar('task'); if (empty($task)) { $task = 'display'; } JRequest::setVar('task', $task); // Perform the requested task $controller->execute($task); // Redirect if set by the controller $controller->redirect();