private function insert_preview_data($p, $id) { //基本信息 $basic = array('topic_title' => $p['title'], 'topic_update' => time(), 'topic_create' => time(), 'topic_is_deleted' => 1); //详细信息 unset($p['preview']); $in1 = $this->upload_prop_image($p); $in2 = $this->upload_tp2_right_img($in1); $in3 = $this->upload_tp3_right_img($in2); $in4 = $this->upload_nav_img($in3); $topic_id = Bll_Topic::add_topic($basic, $in4); $preview_host = APF::get_instance()->get_config('preview_host'); $url = $preview_host . $topic_id . '.html?act=preview'; $this->response->redirect($url); }
private function handle_form($p) { $preview = $p['preview']; //基本信息 $basic = array('topic_title' => $p['title'], 'topic_update' => time(), 'topic_create' => time(), 'topic_is_deleted' => $preview); //补充上传文件 $upload_files = array(); $upload_files_ids = array(); foreach ($_FILES as $k => $v) { if (is_array($v['tmp_name'])) { $upload_files[$k] = array_values($v['tmp_name']); } else { $upload_files[$k] = $v['tmp_name']; } } foreach ($upload_files as $input_name => $tmp_name) { if (is_array($tmp_name)) { foreach ($tmp_name as $k => $v) { if (file_exists($v)) { $upload_files_ids[$input_name][$k] = $this->upload($v); } else { $upload_files_ids[$input_name][$k] = ''; } } } else { if (file_exists($tmp_name)) { $upload_files_ids[$input_name] = $this->upload($tmp_name); } } } //详细信息 unset($p['preview']); $info = array_merge($p, $upload_files_ids); $topic_id = Bll_Topic::add_topic($basic, $info); if ($preview === '0') { //保存 $url = 'http://' . $_SERVER['HTTP_HOST'] . '/user/topic/'; } else { //预览 $preview_host = APF::get_instance()->get_config('preview_host'); $url = $preview_host . $topic_id . '.html?act=preview'; } $this->response->redirect($url); }