Example #1
0
function debug_file($filename, $data, $is_array = true)
{
    if (!MK_DEBUG) {
        return false;
    }
    if ($is_array) {
        file_in('../cache/log/', $filename . '.txt', var_export($data, 1) . "\n", true, true);
    } else {
        file_in('../cache/log/', $filename . '.txt', $data . "\n", true, true);
    }
}
Example #2
0
File: mk.php Project: h3len/Project
 public function show()
 {
     $this->site_id = intval($this->input['plan']['site_id']);
     $this->page_id = intval($this->input['plan']['page_id']);
     $this->page_data_id = intval($this->input['plan']['page_data_id']);
     $this->content_type = intval($this->input['plan']['content_type']);
     $this->template_sign = $this->input['plan']['template_sign'];
     $this->client_type = intval($this->input['plan']['client_type']);
     $this->page_id_c = intval($this->input['plan']['page_id_c']);
     $this->page_data_id_c = intval($this->input['plan']['page_data_id_c']);
     $content_rid = intval($this->input['plan']['rid']);
     //只生成缓存文件
     $only_mk_cache = $this->input['only_mk_cache'];
     $this->plan = $this->input['plan'];
     //查询是否是专题的生成
     $page_type = common::get_page_manage($this->site_id, $this->page_id, 'id');
     $page_type_detail = $page_type[$this->page_id];
     if ($page_type_detail['sign'] == 'special') {
         //查询专题的生成目录
         include_once ROOT_PATH . 'lib/class/special.class.php';
         $special_obj = new special();
         $special_detail = $special_obj->get_mkspecial('', $this->page_data_id);
         $this->page_data_id_s = $special_detail['id'];
         $this->content_type_s = $this->page_data_id . 's';
     }
     //取缓存文件
     $file = MKPUBLISH_DIR . $this->get_cachedir() . '/' . $this->get_cachefilename();
     if ($only_mk_cache || !file_exists($file)) {
         //去生成缓存文件
         //$this->build_mk_cache();
     } else {
         $filedata = unserialize(file_get_contents($file));
         //$this->head_set        = $filedata['head_set'];
         //$this->cell_set        = $filedata['cell_set'];
         //$this->cell_mktype_set = $filedata['cell_mktype_set'];
         //$this->template_set    = $filedata['template_set'];
         $this->page_info = $filedata['page_info'];
         //$this->js              = $filedata['js'];
         //$this->css             = $filedata['css'];
         //$this->cell_ds         = $filedata['cell_ds'];
         //$this->ds              = $filedata['ds'];
         //$this->mar_css         = $filedata['mar_css'];
     }
     //取缓存文件
     $file_result = MKPUBLISH_DIR . $this->get_cachedir() . '/' . $this->get_cachefilename('result');
     if ($only_mk_cache || !file_exists($file_result)) {
         $this->build_mk_cache();
         /*             * 单元模板合并,生成文件 */
         //加载分页信息
         $this->head_set .= "\n" . '$need_page_info[\'file_mktype\'] = \'' . $this->page_info['file_mktype'] . '\';';
         $this->head_set .= "\n" . '$need_page_info[\'page_url\'] = \'' . '' . '\';';
         //$this->head_set .= "\n" . '$need_page_info[\'page_url\'] = \'' . rtrim($this->page_info['weburl'], '/') . '\';';
         $this->head_set .= "\n" . '$need_page_info[\'page_filename\'] = \'' . rtrim($this->page_info['filename'], '/') . '\';';
         $this->head_set .= "\n" . '$need_page_info[\'suffix\'] = \'' . $this->page_info['suffix'] . '\';';
         $this->head_set .= "\n" . '$GLOBALS[\'need_page_info\'] = $need_page_info;';
         //单元处理
         $this->cell_code();
         if (is_array($this->cell_set)) {
             foreach ($this->cell_set as $k => $v) {
                 $tem_replace_cell[$k] = $v['cell'];
                 //模板里需要替换的单元
                 $tem_find_cell[$k] = '/<span[\\s]+(?:id|class)="livcms_cell".+?>liv_' . $this->cell_mktype_set[$k]['cell_name'] . '<\\/span>/';
             }
         }
         //替换模板里的单元
         if ($tem_find_cell) {
             $this->template_set = preg_replace($tem_find_cell, $tem_replace_cell, $this->template_set);
         }
         //生成缓存文件
         $file_result_html = '<?php ' . $this->head_set . '?>' . $this->template_set;
         $file_result_html = $this->mateurl_replace($file_result_html);
         file_in(MKPUBLISH_DIR . $this->get_cachedir(), $this->get_cachefilename('result'), $file_result_html, true, true);
     }
     if ($only_mk_cache) {
         echo 'ok';
         exit;
     }
     $request['rid'] = $content_rid;
     if ($this->plan['page_num'] == -1) {
         //表示生成内容正文全文阅读
         $request['pp'] = -1;
     } else {
         $request['pp'] = $this->plan['page_num'] <= 1 ? 0 : intval($this->plan['offset']);
     }
     $request['__page_max_page'] = intval($this->plan['max_page']);
     $request['__content_detail'] = $this->plan['content_detail'];
     //运行缓存文件
     //可以先取内容正文,如关键字,描述,标题等
     //get_content
     $r = $this->pub_sys->mk_include($file_result, $request);
     //结果处理
     $_get_analysis_result = isset($r['_get_analysis_result']) ? $r['_get_analysis_result'] : array();
     $this->page_info['filename'] .= $this->plan['page_num'] <= 1 ? '' : '_' . $this->plan['page_num'];
     $_get_analysis_result['file_name'] = $this->plan['content_detail']['file_name'];
     //if ($_get_analysis_result['file_name'] && $_get_analysis_result['file_name'] != '.php')
     if ($this->page_info['file_mktype'] != 2) {
         if ($this->plan['page_num'] > 1 || $this->plan['page_num'] == -1) {
             $get_pages_url = get_pages_url($_get_analysis_result['file_name'], $this->plan['page_num'] == -1 ? 'all' : $this->plan['page_num']);
             $_get_analysis_result['file_name'] = $get_pages_url['filedir'];
             $ret['org_filename'] = $get_pages_url['org_filename'];
         }
     }
     $ret['html'] = $r['html'];
     $ret['new_plan'] = $_get_analysis_result['new_plan'];
     $ret['page_info'] = $this->page_info;
     $ret['status'] = 'ok';
     $ret['filename'] = $_get_analysis_result['file_name'];
     $ret['get_analysis_result'] = $_get_analysis_result;
     $ret['need_show_all_pages'] = $this->settings['need_show_all_pages'];
     $ret['page_content_type'] = $this->page_info['page_content_type'] ? 1 : 0;
     if ($this->mar_css) {
         $this->mar_css['css'] = $this->css;
         $ret['mar_css'] = $this->mar_css;
     }
     if ($this->site_id && !$this->page_id) {
         $ret['site'] = $this->site;
         $ret['client'] = $this->client;
     }
     if ($this->js_cell) {
         foreach ($this->js_cell as $k => $v) {
             $this->js_cell[$k]['head'] = str_replace('<start_replace___info></start_replace___info>', '$__info=' . var_export($r['__info'], true) . ';', $v['head']);
         }
         $ret['js_cell'] = $this->js_cell;
     }
     $this->addItem($ret);
     $this->output();
 }
Example #3
0
 public function show($plan = array())
 {
     if ($rid = intval($this->input['rid'])) {
         if ($this->input['rid']) {
             //file_put_contents('../cache/1.txt', var_export($this->input, 1));
         }
         /*             * 从发布库来生成内容 */
         $plan['rid'] = $rid;
         $plan['title'] = $this->input['title'];
         $plan['site_id'] = intval($this->input['site_id']);
         $plan['page_id'] = intval($this->input['page_id']);
         $plan['page_data_id'] = intval($this->input['page_data_id']);
         $plan['content_type'] = intval($this->input['content_type']);
         $plan['client_type'] = intval($this->input['client_type']);
         $plan['content_type_sign'] = $this->input['content_type_sign'];
         $plan['template_sign'] = $this->input['template_sign'];
         $plan['page_id_c'] = intval($this->input['page_id_c']);
         $plan['page_data_id_c'] = intval($this->input['page_data_id_c']);
         $plan['publish_time'] = TIMENOW;
         $plan['content_detail'] = $this->input['content_detail'];
     } else {
         if (!$plan) {
             $plan = $this->obj->get_plan_first();
             if (!$plan) {
                 echo "没有需要生成的队列";
                 return;
             }
             $this->obj->delete('mking', ' id=' . $plan['id']);
         }
         unset($plan['id']);
         //如果是正文,并且rid没有值,取列表插库
         if (!in_array($plan['content_type'], $this->settings['content_type_true']) && !$plan['rid'] && $plan['m_type'] == 6) {
             include_once ROOT_PATH . 'lib/class/publishcontent.class.php';
             $this->pub_content = new publishcontent();
             $all_content_type = $this->pub_content->get_all_content_type();
             if (!$all_content_type || !$all_content_type[$plan['content_type']]) {
                 echo "没有到发布库获取到内容类型";
                 return;
             }
             $content_param['bundle_id'] = $all_content_type[$plan['content_type']]['bundle_id'];
             //$content_param['module_id']   = $all_content_type[$plan['content_type']]['module_id'];
             $content_param['site_id'] = $plan['site_id'];
             $content_param['column_id'] = $plan['page_data_id'];
             $content_param['client_type'] = $plan['client_type'];
             $content_param['offset'] = $plan['offset'];
             $content_param['count'] = $plan['count'];
             $content_param = $content_param + $plan['content_param'] + array('from_mkpublish' => 1);
             $content_datas = $this->pub_content->get_content($content_param);
             if (!$content_datas || !is_array($content_datas)) {
                 echo "没有内容可发布";
                 return;
             }
             if (!$plan['page_id']) {
                 $page_data = $this->pub_sys->get_page_by_sign('column', $plan['site_id']);
                 if (!$page_data['id']) {
                     $plan['failure'] = '请求模板页面类型数据失败:' . var_export($page_data, true);
                     $this->insert_mklog($plan);
                     $this->errorOutput(var_export($page_data, true));
                 }
                 $plan['page_id'] = $page_data['id'];
             }
             //内容插入到正在发布库
             foreach ($content_datas as $k => $v) {
                 $new_plan[$k] = array();
                 $new_plan[$k] = $plan;
                 $new_plan[$k]['page_data_id'] = $v['column_id'];
                 $new_plan[$k]['rid'] = $v['id'];
                 $new_plan[$k]['publish_time'] = TIMENOW;
                 $new_plan[$k]['title'] = $v['title'];
                 $new_plan[$k]['template_sign'] = $v['template_sign'];
                 $new_plan[$k]['content_param'] = serialize($plan['content_param']);
                 $new_plan[$k]['offset'] = 0;
                 $new_plan[$k]['page_num'] = 1;
                 $new_plan[$k]['content_type_sign'] = $all_content_type[$plan['content_type']]['bundle_id'];
                 $new_plan[$k]['content_detail'] = serialize(array('content_url' => $v['content_url'], 'id' => $v['id'], 'rid' => $v['rid'], 'cid' => $v['cid'], 'content_fromid' => $v['content_fromid'], 'file_name' => $v['file_name'], 'template_sign' => $v['template_sign'], 'content_type_sign' => $v['content_type_sign'], 'column_id' => $v['column_id'], 'site_id' => $v['site_id']));
             }
             if ($new_plan && is_array($new_plan)) {
                 $this->obj->insert_plan_batch('mking', $new_plan);
             }
             //看有没有余下的内容
             $next_plan = $plan;
             $plan_content_count = count($content_datas);
             $next_plan['offset'] += $plan_content_count;
             if ($plan['mk_count']) {
                 //有设置生成条数,暂时有bug
                 if ($plan_content_count < $plan['count'] || $next_plan['offset'] >= $plan['mk_count']) {
                     return;
                 }
                 $n_plannum = $plan['mk_count'] - $offset;
                 if ($n_plannum <= 0) {
                     return;
                 }
                 $next_plan['count'] = $n_plannum >= $plan['count'] ? $plan['count'] : $n_plannum;
             } else {
                 if ($plan_content_count < $plan['count']) {
                     return;
                 }
                 $next_plan['count'] = $plan['count'];
             }
             $next_plan['publish_time'] = TIMENOW;
             $next_plan['content_param'] = serialize($plan['content_param']);
             $this->obj->insert('mking', $next_plan);
             return;
         }
         //运行剩下的内容页
     }
     if ($plan['site_id'] && $plan['page_id'] && !$plan['page_data_id'] && !$plan['rid']) {
         return;
     }
     $rets = $this->pub_sys->mk($plan);
     $log_arr = $plan;
     file_put_contents('../cache/2.txt', var_export($rets, 1));
     if ($rets['status'] == 'error') {
         $log_arr['failure'] = $rets['message'];
         $this->insert_mklog($log_arr);
         $this->errorOutput(var_export($rets, true));
     }
     if (!is_array($rets[0])) {
         $log_arr['failure'] = '访问模板生成文件接口出错,可能:访问模板域名,生成超时';
         $this->insert_mklog($log_arr);
         $this->errorOutput(var_export($rets, true));
     }
     $ret = $rets[0];
     if ($ret['status'] != 'ok') {
         $log_arr['failure'] = '模板生成接口返回状态status不ok';
         $this->insert_mklog($log_arr);
         $this->errorOutput(var_export($rets, true));
     }
     //将站点,客户端信息写入道前端m2o/conf/var.php
     $var_data_tag = false;
     $varstr = '<?php ';
     if (!empty($ret['site']) && is_array($ret['site'])) {
         $var_data_tag = true;
         $varstr .= '$gGlobalConfig[\'v_site\'] = ' . var_export($ret['site'], true) . ';' . "\n";
     }
     if (!empty($ret['client'])) {
         $var_data_tag = true;
         $varstr .= '$gGlobalConfig[\'v_client\'] = ' . var_export($ret['client'], true) . ';' . "\n";
     }
     $varstr .= ' ?>';
     if ($var_data_tag) {
         $sitedir = $ret['site']['site_dir'];
         if ($sitedir) {
             @file_put_contents(rtrim($sitedir, '/') . '/m2o/conf/var.php', $varstr);
         }
     }
     //将列表,内容页面的css文件写入道css文件中生成引入
     if ($ret['mar_css']['mar_css_dir']) {
         $ret['mar_css']['css'] = str_replace(array('<style type="text/css">', '</style>'), '', $ret['mar_css']['css']);
         file_in($ret['mar_css']['mar_css_dir'], $ret['mar_css']['mar_css_filename'], $ret['mar_css']['css'], true, true);
     }
     //js单元
     if ($ret['js_cell'] && is_array($ret['js_cell'])) {
         foreach ($ret['js_cell'] as $k => $v) {
             $js_html = '';
             $js_html .= '<?php ' . $v['head'] . "\n" . $v['ds'] . "\n" . ' ?>' . $v['cell'];
             file_in($v['include_dir'], $v['include_filename'], $js_html, true, true);
             if ($v['dir'] && $v['filename']) {
                 $callback_html = '<?php  
                     if(!file_exists(\'' . $v['include_dir'] . $v['include_filename'] . '\'))
                     {
                         $callback_html = \'\';
                     }
                     else
                     {
                         ob_clean();
                         ob_start();
                         include \'' . $v['include_dir'] . $v['include_filename'] . '\';
                         $callback_html = ob_get_contents();
                         ob_clean();
                     }
                     ?>';
                 $callback_html .= 'document.write(\'<?php echo str_replace(array("\\n","\'"), array("","\\\'"), $callback_html) ?>\')';
                 file_in($v['dir'], $v['filename'], $callback_html, true, true);
             }
         }
     }
     //生成的余下队列
     if ($ret['new_plan'] && is_array($ret['new_plan'])) {
         $after_plan = array('title' => $plan['title'], 'rid' => $plan['rid'], 'site_id' => $plan['site_id'], 'page_id' => $plan['page_id'], 'page_data_id' => $plan['page_data_id'], 'content_type' => $plan['content_type'], 'client_type' => $plan['client_type'], 'content_type_sign' => $plan['content_type_sign'], 'template_sign' => $plan['template_sign'], 'offset' => intval($ret['new_plan']['offset']), 'page_num' => intval($ret['new_plan']['page_num']), 'max_page' => intval($plan['max_page']), 'publish_time' => intval($plan['publish_time']), 'content_detail' => serialize($plan['content_detail']));
         $this->obj->insert('mking', $after_plan);
         if ($after_plan['page_num'] == 2 && $ret['need_show_all_pages'] && $ret['page_content_type']) {
             $all_pages_plan = array('title' => $plan['title'], 'rid' => $plan['rid'], 'site_id' => $plan['site_id'], 'page_id' => $plan['page_id'], 'page_data_id' => $plan['page_data_id'], 'content_type' => $plan['content_type'], 'client_type' => $plan['client_type'], 'content_type_sign' => $plan['content_type_sign'], 'template_sign' => $plan['template_sign'], 'offset' => intval($ret['new_plan']['offset']), 'page_num' => -1, 'max_page' => intval($plan['max_page']), 'publish_time' => intval($plan['publish_time']), 'content_detail' => serialize($plan['content_detail']));
             $this->obj->insert('mking', $all_pages_plan);
         }
     }
     /**
      * $ret:new_plan,html,page_info,status
      * $page_info:file_mktype,weburl,dir,suffix
      * */
     //生成文件
     $dir = rtrim($ret['page_info']['dir'], '/');
     $ret['page_info']['filename'] = $ret['page_info']['filename'] ? $ret['page_info']['filename'] : 'index';
     if (!$ret['filename'] && !empty($plan['content_detail']['filename'])) {
         $ret['filename'] = $plan['content_detail']['filename'];
     }
     if ($ret['filename'] && $ret['page_info']['file_mktype'] != 2) {
         //内容页静态生成
         if ($ret['page_info']['custom_content_dir']) {
             $dir = str_replace($ret['page_info']['relate_dir'], '', $dir);
             $dir = rtrim($dir, '/') . '/' . trim($ret['page_info']['custom_content_dir'], '/');
         }
         if ($ret['page_info']['file_mktype'] != 1 && $ret['filename'] == '.php') {
             $filename = $plan['content_type_sign'] . '.php';
         } else {
             $fnarr = explode('/', $ret['filename']);
             $fnarr_count = count($fnarr);
             for ($i = 0; $i < $fnarr_count; $i++) {
                 if ($i == $fnarr_count - 1) {
                     $filename = $fnarr[$i];
                 } else {
                     $dir .= '/' . $fnarr[$i];
                 }
             }
             if (!$filename) {
                 $log_arr['failure'] = '内容页filename:' . $ret['filename'] . ' 不正确';
                 $this->insert_mklog($log_arr);
                 $this->errorOutput("NO_FILENAME");
             }
         }
     } else {
         if ($ret['page_info']['page_type'] == 'special') {
             if ($ret['page_info']['custom_content_dir']) {
                 $dir = str_replace($ret['page_info']['relate_dir'], '', $dir);
                 $dir = rtrim($dir, '/') . '/' . trim($ret['page_info']['custom_content_dir'], '/') . '/' . $ret['page_info']['special_dir'];
             }
             $filename = $ret['page_info']['filename'] . $ret['page_info']['suffix'];
         } else {
             if ($plan['content_type_sign'] && $ret['page_info']['file_mktype'] == 2) {
                 //有内容类型标识是内容正文生成,页面生成方式为动态
                 $filename = $plan['content_type_sign'] . '.php';
             } else {
                 if (!$plan['rid']) {
                     //表示首页或者列表页生成
                     $filename = $ret['page_info']['filename'] . $ret['page_info']['suffix'];
                 }
             }
         }
     }
     if (!$filename || $filename == '<') {
         if ($ret['get_analysis_result']['is_contentdetail']) {
             if (!$plan['rid']) {
                 $log_arr['failure'] = '首页或者列表页可能包含了正文样式';
             } else {
                 $log_arr['failure'] = '未获取到正文页内容详情的filename';
             }
         } else {
             if ($plan['rid']) {
                 $log_arr['failure'] = '内容页未选择正文样式或者数据源配置出错';
             } else {
                 $log_arr['failure'] = '站点或者栏目未设置生成文件名名称:index;再或者未获取到发布库站点栏目信息';
             }
         }
         $this->insert_mklog($log_arr);
         $this->errorOutput("NO_FILENAME");
     }
     $ret['html'] = ltrim($ret['html']);
     $fr = file_in($dir, $filename, $ret['html'], true, true);
     if (!$fr) {
         $log_arr['failure'] = '目录或者文件不可写,请查看目录权限:' . $dir . '/' . $filename;
         $this->insert_mklog($log_arr);
         $this->errorOutput("NO_PATH_AUTH");
     }
     //进入完成库
     $complete_plan = $plan;
     $complete_plan['content_param'] = serialize($complete_plan['content_param']);
     if ($ret['page_info']['file_mktype'] != 1) {
         $complete_plan['rid'] = 0;
     }
     $complete_plan['publish_time'] = TIMENOW;
     if (!$complete_plan['publish_user']) {
         $complete_plan['publish_user'] = $this->user['user_name'];
     }
     if (!$complete_plan['file_path']) {
         $complete_plan['file_path'] = $dir;
     }
     if (!$complete_plan['file_name']) {
         $complete_plan['file_name'] = $filename;
     }
     if ($ret['org_filename']) {
         $complete_plan['file_name'] = $ret['org_filename'];
     }
     unset($complete_plan['page_id_c']);
     unset($complete_plan['page_data_id_c']);
     unset($complete_plan['content_detail']);
     $this->obj->complete_plan($complete_plan);
     //删除同名文件下动静态
     preg_match('/(.*?)\\.(\\w+)$/i', $filename, $fmat);
     if ($fmat[0]) {
         switch ($fmat[2]) {
             case 'php':
                 @unlink($dir . '/' . $fmat[1] . '.html');
                 @unlink($dir . '/' . $fmat[1] . '.htm');
                 for ($j = 1; $j <= 50; $j++) {
                     @unlink($dir . '/' . $fmat[1] . '_' . $j . '.html');
                     @unlink($dir . '/' . $fmat[1] . '_' . $j . '.htm');
                 }
                 break;
             case 'html':
                 @unlink($dir . '/' . $fmat[1] . '.php');
                 @unlink($dir . '/' . $fmat[1] . '.htm');
                 break;
             case 'htm':
                 @unlink($dir . '/' . $fmat[1] . '.php');
                 @unlink($dir . '/' . $fmat[1] . '.html');
                 break;
         }
     }
     echo rtrim($dir, '/') . '/' . $filename;
 }
Example #4
0
    public function mk_ini($bundle_id, $module_id, $m_s)
    {
        if (!$m_s) {
            return false;
        }
        $content = '<?php 
				return ';
        $content .= var_export($m_s, 1);
        $content .= ' ?>';
        file_in(CUR_CONF_PATH . 'data', $bundle_id . '_' . $module_id . '.ini.php', $content, true, true);
    }
Example #5
0
 public function create_get_file($field, $tablename, $child_table, $array_field, $array_child_field)
 {
     $dir = $this->settings['get_content_api_path'];
     $filename = $tablename . $this->settings['get_content_api_suffix'];
     $filename_class = $tablename . '.class' . $this->settings['get_content_api_suffix'];
     $strings = file_get_contents(CUR_CONF_PATH . 'admin/get_content_api.php');
     $string_class = file_get_contents(CUR_CONF_PATH . 'admin/get_content_api.class.php');
     $find_arr = array('{$tablename}', '{$child_tablename}', '{$child_table}', '{$field}', '{$array_field}', '{$array_child_field}');
     $replace_arr = array($tablename, empty($child_table) ? '' : $tablename . '_' . $child_table, $child_table, $field, $array_field, $array_child_field);
     $strings = str_replace($find_arr, $replace_arr, $strings);
     $string_class = str_replace($find_arr, $replace_arr, $string_class);
     //生成文件
     if (!file_in($dir, $filename, $strings, true)) {
         $result['msg'] = '未生成取内容接口文件';
         $result['error'] = '2';
         $this->addItem($result);
         $this->output();
     }
     if (!file_in($dir, $filename_class, $string_class, true)) {
         $result['msg'] = '未生成取内容接口文件';
         $result['error'] = '2';
         $this->addItem($result);
         $this->output();
     }
 }
Example #6
0
 public function index_cell($cell_ret, $mode_data, $datasourceid, $mode_variables)
 {
     $i = 0;
     //取数据源详细信息
     $datasource_data = $this->datasource_param($datasourceid);
     //		print_r($cell_ret['default_cell']);exit;
     foreach ($cell_ret['default_cell'] as $k => $v) {
         /**
          * 单元生成方式是静态的还是动态的  0是静态  1是动态
          * 动态的判断缓存里是否有包含文件  有则删除
          * 静态的则把数据源跟缓存运行的结果插入页面
          * */
         if (!$v['cell_mode']) {
             $tem_cell[$i][$k]['name'] = $v['cell_name'];
             $tem_cell[$i][$k]['program'] = '';
             continue;
         }
         $ds_param = array();
         $tem_cell[$i][$k]['name'] = $v['cell_name'];
         //数据源参数跟单元设的参数合并
         $data_input_variable = array();
         if ($v['data_source']) {
             if (!empty($v['param_asso']['input_param'])) {
                 $data_input_variable = $v['param_asso']['input_param'];
                 $data_input_variable = is_array($data_input_variable) ? $data_input_variable : array();
             }
         }
         $datasource_data[$v['data_source']] = is_array($datasource_data[$v['data_source']]) ? $datasource_data[$v['data_source']] : array();
         $ds_param = $data_input_variable + $datasource_data[$v['data_source']];
         if ($v['cell_type'] == 1) {
             //获取单元缓存
             $cell_cache = common::get_cell_cache($v['id']);
             if ($v['data_source']) {
                 $tem_cell[$i][$k]['program'] = '$m2o[\'data\'] = $ds_' . $v['data_source'] . '->show(array(\'offset\'=>$_GET[\'cur_page\'])+' . var_export($ds_param, true) . ');';
             }
             //先处理单元缓存,再插入到单元中去
             $cell_cache = preg_replace('/include_once.+?;/', '', $cell_cache);
             $tem_cell[$i][$k]['program'] = '<?php ' . $tem_cell[$i][$k]['program'] . ' ?>' . $cell_cache;
             $tem_cell[$i][$k]['program'] = $tem_cell[$i][$k]['program'];
         } else {
             //静态单元
             $cache_file = MODE_CACHE_DIR . $v['id'] . '.php';
             if ($v['data_source']) {
                 $ds_param['offset'] = $this->plan['offset'];
                 $m2o['data'] = common::get_content_by_datasource($v['data_source'], $ds_param);
             }
             if (!$m2o['data']) {
                 $m2o['data'] = $mode_data[$v['cell_mode']]['default_param'];
             }
             //判断是否是列表,是否需要分页,生成静态分页列表
             if (!empty($mode_variables[$v['cell_mode']]['need_page'])) {
                 $this->is_need_page = true;
                 if (!empty($m2o['data']['list']) && is_array($m2o['data']['list'])) {
                     $page_plan = $this->plan;
                     $page_plan['offset'] = count($m2o['data']['list']) + $this->plan['offset'];
                     $page_plan['content_param'] = serialize($page_plan['content_param']);
                     $page_plan['page_num'] = $page_plan['page_num'] == '0' ? 2 : ++$page_plan['page_num'];
                     $this->obj->insert('mkpublish_plan', $page_plan);
                 }
                 $need_page_info['total_rows'] = $m2o['data']['totalcount'];
                 $need_page_info['cur_page'] = intval($this->plan['offset']);
             }
             if (MK_DEBUG) {
                 file_in('../cache/log/', '首页列表页每个单元ID.txt', $cache_file, false, true);
             }
             $tem_cell[$i][$k]['program'] = $this->include_file($cache_file, $m2o['data'], $need_page_info);
             if (MK_DEBUG) {
                 file_in('../cache/log/', '首页列表页每个单元生成结果.txt', $tem_cell[$i][$k]['program'], false, true);
             }
         }
     }
     return array('tem_cell' => $tem_cell);
 }
Example #7
0
    public function mk_ini($bundle_id, $module_id, $charset, $content, $index = '127.0.0.1', $index_port = '8383', $search = '127.0.0.1', $search_port = '8384')
    {
        $head = '';
        $head .= 'project.name = ' . $bundle_id . '_' . $module_id . '
';
        $head .= 'project.default_charset = ' . $charset . '
';
        $head .= 'server.index = ' . $index . ':' . $index_port . '
';
        $head .= 'server.search = ' . $search . ':' . $search_port . '

';
        file_in(CUR_CONF_PATH . 'data', $bundle_id . '_' . $module_id . '.ini', $head . $content, true, true);
    }
Example #8
0
 public function dz_accesstoken($platdata)
 {
     if (!$this->input['cookie_data'] || !$this->input['filename']) {
         return 'NO_COOKIE';
     }
     $md5_filename = md5($this->input['filename']);
     $dir = substr($md5_filename, 0, 2) . '/' . substr($md5_filename, 2, 2) . '/';
     file_in($this->settings['cookie_dir'] . $dir, $this->input['filename'], $this->input['cookie_data']);
     $access_token['expires_in'] = 2592000;
     $access_token['cookie_dir'] = realpath($this->settings['cookie_dir'] . $dir . $this->input['filename']);
     $access_token['uid'] = $this->input['data']['user_id'];
     //更新到数据库中
     if ($this->obj->updatetoken($platdata['token'], array('access_token' => json_encode($access_token), 'addTime' => TIMENOW))) {
         $insert_data['plat_type'] = $platdata['type'];
         $insert_data['uid'] = $this->input['data']['user_id'];
         $insert_data['platId'] = $platdata['platId'];
         $insert_data['name'] = $this->input['data']['user_name'];
         $insert_data['avatar'] = '';
         $insert_data['token'] = $platdata['token'];
         $insert_data['user_id'] = $this->user['user_id'];
         $insert_data['user_name'] = $this->user['user_name'];
         $insert_data['create_time'] = $insert_data['update_time'] = TIMENOW;
         $insert_data['mode_type'] = $this->input['data']['forum'] ? serialize($this->input['data']['forum']) : '';
         $auth_user = $this->input['other'] ? $this->obj->get_plat_user($insert_data) : $this->obj->get_auth_user($insert_data);
         if (!$auth_user) {
             $insert_id = $this->input['other'] ? $this->obj->insert_plat_user($insert_data) : $this->obj->insert_auth_user($insert_data);
         } else {
             $this->input['other'] ? $this->obj->update_plat_user($insert_data, $auth_user['id']) : $this->obj->update_auth_user($insert_data, $auth_user['id']);
         }
         return $data;
     } else {
         return 'GET_FAILD';
     }
     //插入到第三方用户表中
     if (!$data) {
         return false;
     }
     /**
             $insert_data['plat_type']   = $platdata['type'];
             $insert_data['platId']      = $platdata['platId'];
             $insert_data['uid']         = $data['access_token']['uid'];
             $insert_data['name']        = $data['userdata']['name'];
             $insert_data['avatar']      = $data['userdata']['avatar_large'];
             $insert_data['token']       = $data['access_plat_token'];
             $insert_data['user_id']     = $this->user['user_id'];
             $insert_data['user_name']   = $this->user['user_name'];
             $insert_data['create_time'] = $insert_data['update_time'] = TIMENOW;
             $auth_user                  = $this->input['other'] ? $this->obj->get_plat_user($insert_data) : $this->obj->get_auth_user($insert_data);
             if (!$auth_user)
             {
                 $insert_id = $this->input['other'] ? $this->obj->insert_plat_user($insert_data) : $this->obj->insert_auth_user($insert_data);
             }
             else
             {
                 $this->input['other'] ? $this->obj->update_plat_user($insert_data, $auth_user['id']) : $this->obj->update_auth_user($insert_data, $auth_user['id']);
             }
     
             $result['access_plat_token'] = $data['access_plat_token'];
             $result['oauth_suc']         = 1;
             $result['name']              = empty($data['userdata']['name']) ? '' : $data['userdata']['name'];
             $result['pic']               = empty($data['userdata']['avatar_large']) ? '' : $data['userdata']['avatar_large'];
             $result['auth_user_id']      = empty($auth_user['id']) ? $insert_id : $auth_user['id'];
     */
 }