/** * 获取用户详情 */ public function customerInfo() { $cus_id = Auth::id(); $customer = Auth::user()->name; $customer_info = CustomerInfo::where('cus_id', $cus_id)->first(); $data['company_name'] = $customer_info->company; $domain_pc = $customer_info->pc_domain; $data['domain_pc'] = str_replace('http://', '', $domain_pc); $domain_m = $customer_info->mobile_domain; $data['domain_m'] = str_replace('http://', '', $domain_m); if ($customer_info->favicon != '') { $data['favicon'] = asset('customers/' . $customer . '/images/l/common/' . $customer_info->favicon); } if ($customer_info->logo != '') { $data['logo_large'] = asset('customers/' . $customer . '/images/l/common/' . $customer_info->logo); } if ($customer_info->logo_small != '') { $data['logo_small'] = asset('customers/' . $customer . '/images/l/common/' . $customer_info->logo_small); } $data['pc_header_script'] = $customer_info->pc_header_script; $data['mobile_header_script'] = $customer_info->mobile_header_script; $data['title'] = $customer_info->title; $data['keywords'] = $customer_info->keywords; $data['description'] = $customer_info->description; $data['footer'] = $customer_info->footer; $data['mobile_footer'] = $customer_info->mobile_footer; $data['pc_footer_script'] = $customer_info->pc_footer_script; $data['mobile_footer_script'] = $customer_info->mobile_footer_script; $data['pc_num_per_page'] = $customer_info->pc_page_count; $data['pc_num_pagenav'] = $customer_info->pc_page_links; $data['m_num_per_page'] = $customer_info->mobile_page_count; $data['m_num_pagenav'] = $customer_info->mobile_page_links; $data['contactor'] = $customer_info->contact_name; $data['telephone'] = $customer_info->telephone; $data['mobile'] = $customer_info->mobile; $data['fax'] = $customer_info->fax; $data['mail'] = $customer_info->email; $data['qq'] = $customer_info->qq; $data['address'] = $customer_info->address; $websiteinfo = WebsiteInfo::where('cus_id', $cus_id)->select('pc_tpl_id', 'mobile_tpl_id')->first(); $pc_tpl_name = Template::where('id', $websiteinfo->pc_tpl_id)->pluck('name'); $pc_ini = parse_ini_file(public_path('/templates/' . $pc_tpl_name . '/config.ini'), true); $data['pc_logo_size'] = isset($pc_ini['Config']['LogoSize']) ? strtr($pc_ini['Config']['LogoSize'], '*', '/') : 0; $mobile_tpl_name = Template::where('id', $websiteinfo->mobile_tpl_id)->pluck('name'); $mobile_ini = parse_ini_file(public_path('/templates/' . $mobile_tpl_name . '/config.ini'), true); $data['m_logo_size'] = isset($mobile_ini['Config']['LogoSize']) ? strtr($mobile_ini['Config']['LogoSize'], '*', '/') : 0; $result['err'] = 0; $result['msg'] = ''; $result['data'] = $data; return Response::json($result); }
public function classifyList() { $customer = Auth::user()->name; $cus_id = Auth::id(); $classify = Classify::where('cus_id', $cus_id)->orderBy('sort')->orderBy('id')->get()->toArray(); $showtypetotal = WebsiteInfo::where('website_info.cus_id', $cus_id)->LeftJoin('template', 'mobile_tpl_id', '=', 'template.id')->select('template.list1showtypetotal', 'template.list2showtypetotal', 'template.list3showtypetotal', 'template.list4showtypetotal')->first(); if (count($classify)) { foreach ($classify as &$c_arr) { $liststr = 'list' . $c_arr['type'] . 'showtypetotal'; $c_arr['showtypetotal'] = $showtypetotal->{$liststr}; if ($c_arr['mobile_show']) { $c_arr['show'] = MobileHomepage::where('c_id', $c_arr['id'])->where('cus_id', $cus_id)->pluck('index_show'); } } } $result['err'] = 0; $result['msg'] = ''; $result['data'] = $this->toTree($classify); return Response::json($result); }
/** * 获取用户详情 */ public function customerInfo() { $cus_id = Auth::id(); $customer = Auth::user()->name; $weburl = Customer::where('id', $cus_id)->pluck('weburl'); $suf_url = str_replace('http://c', '', $weburl); $customer_info = CustomerInfo::where('cus_id', $cus_id)->first(); $data['company_name'] = $customer_info->company; $domain_pc = $customer_info->pc_domain; $data['domain_pc'] = str_replace('http://', '', $domain_pc); $domain_m = $customer_info->mobile_domain; $data['domain_m'] = str_replace('http://', '', $domain_m); $data['def_domain_pc'] = $customer . $suf_url; $data['def_domain_m'] = "m." . $customer . $suf_url; if ($customer_info->favicon != '') { $data['favicon'] = asset('customers/' . $customer . '/images/l/common/' . $customer_info->favicon); } if ($customer_info->logo != '') { $data['logo_large'] = asset('customers/' . $customer . '/images/l/common/' . $customer_info->logo); } if ($customer_info->logo_small != '') { $data['logo_small'] = asset('customers/' . $customer . '/images/l/common/' . $customer_info->logo_small); } $data['pc_header_script'] = $customer_info->pc_header_script; $data['mobile_header_script'] = $customer_info->mobile_header_script; $data['title'] = $customer_info->title; $data['keywords'] = $customer_info->keywords; $data['description'] = $customer_info->description; $data['footer'] = $customer_info->footer; $data['mobile_footer'] = $customer_info->mobile_footer; $data['pc_footer_script'] = $customer_info->pc_footer_script; $data['mobile_footer_script'] = $customer_info->mobile_footer_script; $data['pc_num_per_page'] = $customer_info->pc_page_count; $data['pc_imgtxt_per_page'] = $customer_info->pc_page_imgtxt_count; $data['pc_txt_per_page'] = $customer_info->pc_page_txt_count; $data['pc_img_per_page'] = $customer_info->pc_page_img_count; $data['pc_page_count_switch'] = $customer_info->pc_page_count_switch; $data['copyright'] = $customer_info->copyright; $data['pc_num_pagenav'] = $customer_info->pc_page_links; $data['m_num_per_page'] = $customer_info->mobile_page_count; $data['m_num_pagenav'] = $customer_info->mobile_page_links; $data['contactor'] = $customer_info->contact_name; $data['telephone'] = $customer_info->telephone; $data['mobile'] = $customer_info->mobile; $data['fax'] = $customer_info->fax; $data['mail'] = $customer_info->email; $data['qq'] = $customer_info->qq; $data['address'] = $customer_info->address; $data['enlarge'] = $customer_info->enlarge; $data['lang'] = $customer_info->lang; $data['background_music'] = $customer_info->background_music; $data['talent_support'] = $customer_info->talent_support; $data['lastpushtime'] = strtotime($customer_info->lastpushtime); $data['floatadv'] = json_decode($customer_info->floatadv); foreach ((array) $data['floatadv'] as $key => $val) { if (!isset($val->type) || $val->type == 'adv') { $data['floatadv'][$key]->url = asset('customers/' . $customer . '/images/l/common/' . $val->adv); } } $websiteinfo = WebsiteInfo::where('cus_id', $cus_id)->select('pc_tpl_id', 'mobile_tpl_id')->first(); $pc_tpl_name = Template::where('id', $websiteinfo->pc_tpl_id)->pluck('name'); if ($pc_tpl_name != null) { $pc_ini = parse_ini_file(public_path('/templates/' . $pc_tpl_name . '/config.ini'), true); } else { $pc_ini = false; } $data['pc_logo_size'] = isset($pc_ini['Config']['LogoSize']) ? strtr($pc_ini['Config']['LogoSize'], '*', '/') : 0; $mobile_tpl_name = Template::where('id', $websiteinfo->mobile_tpl_id)->pluck('name'); if ($mobile_tpl_name != null) { $mobile_ini = parse_ini_file(public_path('/templates/' . $mobile_tpl_name . '/config.ini'), true); } else { $mobile_ini = false; } $data['m_logo_size'] = isset($mobile_ini['Config']['LogoSize']) ? strtr($mobile_ini['Config']['LogoSize'], '*', '/') : 0; $result['err'] = 0; $result['msg'] = ''; $result['data'] = $data; return Response::json($result); }
public function mhomepageModify() { $cus_id = Auth::id(); $template_id = WebsiteInfo::where('cus_id', $cus_id)->pluck('mobile_tpl_id'); $data = Input::all(); $keys = array_keys($data); if ($keys[0] == 'slidepics') { if ($data['slidepics'] != '') { foreach ($data['slidepics'] as $key => $val) { $data['slidepics'][$key]['title'] = $data['slidepics'][$key]['PC_name']; $data['slidepics'][$key]['image'] = basename($data['slidepics'][$key]['phone_info_pic']); $data['slidepics'][$key]['link'] = $data['slidepics'][$key]['PC_link']; unset($data['slidepics'][$key]['PC_name']); unset($data['slidepics'][$key]['phone_info_pic']); unset($data['slidepics'][$key]['PC_link']); } } } $config_str = WebsiteConfig::where('cus_id', $cus_id)->where('type', 2)->where('template_id', $template_id)->pluck('value'); if ($config_str) { $config_arr = unserialize($config_str); $config_arr[$keys[0]]['value'] = $data[$keys[0]]; } else { $mobile = new PrintController('preview', 'mobile'); $config_arr = $mobile->mobilePageList('global', true); $config_arr[$keys[0]]['value'] = $data[$keys[0]]; } $new_config_str = serialize($config_arr); if ($config_str) { $result = DB::table('website_config')->where('cus_id', $cus_id)->where('type', 2)->where('template_id', $template_id)->update(array('value' => $new_config_str)); } else { $result = DB::table('website_config')->insert(array('cus_id' => $cus_id, 'type' => 2, 'template_id' => $template_id, 'key' => 'global', 'value' => $new_config_str)); } if ($result) { $return_msg = array('err' => 0, 'msg' => ''); } else { $return_msg = array('err' => 3001, 'msg' => '修改失败', 'data' => array()); } return Response::json($return_msg); }
/** * 定义用户id、用户名、 * @param string $showtpye * @param string $type */ function __construct($showtpye = 'preview', $type = 'pc') { $this->showtype = $showtpye; $this->type = $type; $this->cus_id = Auth::id(); $this->customer = Auth::user()->name; if ($this->showtype == 'preview') { $this->source_dir = '/customers/' . $this->customer . '/images/'; //asset('customers/' . $this->customer . '/images/') . '/'; if ($this->type == 'mobile') { $this->domain = '/mobile'; //url() . '/mobile'; $this->tpl_id = WebsiteInfo::where('cus_id', $this->cus_id)->pluck('mobile_tpl_id'); $this->themename = DB::table('template')->leftJoin('website_info', 'website_info.mobile_tpl_id', '=', 'template.id')->where('website_info.cus_id', '=', $this->cus_id)->pluck('template.name'); $this->source_dir = '/customers/' . $this->customer . '/mobile/images/'; //asset('customers/' . $this->customer . '/mobile/images/') . '/'; self::$cus_domain = ''; //CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_domain'); } else { $this->domain = ''; //url(); $this->tpl_id = WebsiteInfo::where('cus_id', $this->cus_id)->pluck('pc_tpl_id'); $this->themename = DB::table('template')->leftJoin('website_info', 'website_info.pc_tpl_id', '=', 'template.id')->where('website_info.cus_id', '=', $this->cus_id)->pluck('template.name'); self::$cus_domain = ''; //CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain'); } $this->site_url = '/templates/' . $this->themename . '/'; } else { if ($this->type == 'mobile') { $this->tpl_id = WebsiteInfo::where('cus_id', $this->cus_id)->pluck('mobile_tpl_id'); $this->themename = DB::table('template')->leftJoin('website_info', 'website_info.mobile_tpl_id', '=', 'template.id')->where('website_info.cus_id', '=', $this->cus_id)->pluck('template.name'); $mobile_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_domain'); $mobile_domain = str_replace('http://', '', $mobile_domain); if (strpos($mobile_domain, '/mobile')) { $this->domain = '/mobile'; } //$this->domain = '';//CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_domain'); } else { $this->tpl_id = WebsiteInfo::where('cus_id', $this->cus_id)->pluck('pc_tpl_id'); $this->themename = DB::table('template')->leftJoin('website_info', 'website_info.pc_tpl_id', '=', 'template.id')->where('website_info.cus_id', '=', $this->cus_id)->pluck('template.name'); $this->domain = ''; //CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain'); } self::$cus_domain = ''; // $this->domain; $this->site_url = $this->domain . '/'; $this->source_dir = '/images/'; //$this->domain . '/images/'; } }
/** * 判断一个用户是否需要推送并返回修改的次数 */ public function isNeedPush() { $count = Classify::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += Articles::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += WebsiteConfig::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += WebsiteInfo::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += MobileHomepage::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $count += CustomerInfo::where('cus_id', $this->cus_id)->where('pushed', '>', 0)->count(); $data_final = ['err' => 0, 'msg' => '', 'data' => ['cache_num' => $count]]; return Response::json($data_final); }
public function templateUploadZip() { set_time_limit(0); $files = Input::file(); $cus_id = Auth::id(); $temptype = Input::get("type"); $customization = Customer::where('id', $cus_id)->pluck('customization'); if ($customization <= 0 || $customization != 3 && $customization != $temptype) { return Response::json(['err' => 1001, 'msg' => '您未开启相应的高级定制,高级定制需要付费,如需要,请联系客服', 'data' => '您未开启高级定制,高级定制需要付费,如需要,请联系客服']); } $files = Input::file(); $file = $files['upload_zip']; if ($file->isValid()) { $type = $file->getClientOriginalExtension(); $truth_name = date('ymd') . mt_rand(100, 999) . '.' . $type; if ($type == "zip") { if (file_exists(public_path("temp_templates/{$truth_name}"))) { $result = ['err' => 1000, 'msg' => '模板覆盖成功']; } else { $up_result = $file->move(public_path("temp_templates/"), $truth_name); if ($up_result) { if ($temptype == 1) { $name = WebsiteInfo::leftJoin('template', 'pc_tpl_id', '=', 'template.id')->where('website_info.cus_id', $cus_id)->pluck('name'); } else { $name = WebsiteInfo::leftJoin('template', 'mobile_tpl_id', '=', 'template.id')->where('website_info.cus_id', $cus_id)->pluck('name'); } $tpl_name = $name; $result = $this->saveTemplate($truth_name, $tpl_name, $temptype); $pushed = WebsiteInfo::where("cus_id", $cus_id)->pluck("pushed"); if ($temptype == 1) { if ($pushed == 0 || $pushed == 2) { $pushed = 2; } else { $pushed = 1; } } else { if ($pushed == 0 || $pushed == 3) { $pushed = 3; } else { $pushed = 1; } } WebsiteInfo::where("cus_id", $cus_id)->update(array("pushed" => $pushed)); } else { $result = ['err' => 1001, 'msg' => '模板覆盖失败']; } } } else { $result = ['err' => 1002, 'msg' => '模板覆盖失败,请上传正确的文件类型']; } } else { $result = ['err' => 1002, 'msg' => '模板覆盖失败,请上传正确的文件类型']; } return Response::json($result); }
public function copy() { $cus_id = Auth::id(); $type = Input::get('tpye'); $type = 1; $id = WebsiteInfo::where('cus_id', $cus_id)->pluck('pc_tpl_id'); $had_name = WebsiteInfo::leftJoin('template', 'pc_tpl_id', '=', 'template.id')->where('template.cus_id', $cus_id)->pluck('name'); if ($had_name) { return Response::json(['err' => 0, 'msg' => '']); } else { $count = Template::where('type', $type)->where('cus_id', $cus_id)->count(); if ($count >= 3) { return Response::json(['err' => 1001, 'msg' => '定制模版超过3个']); } else { $tpl_info = Template::where('type', $type)->where('id', $id)->where('cus_id', 0)->first(); $name = $tpl_info->name; $new_name = $name . '_' . $cus_id; $template = new Template(); $template->name = $new_name; $template->tpl_num = 0; $template->tpl_name = $tpl_info->tpl_name; $template->type = $type; $template->cus_id = $cus_id; $template->former_id = $id; $template->save(); $insertedId = $template->id; $src = app_path('views/templates/' . $name); $dst = app_path('views/templates/' . $new_name); $src_public = public_path('templates/' . $name); $dst_public = public_path('templates/' . $new_name); $this->rcopy($src, $dst); $this->rcopy($src_public, $dst_public); //$img_src = public_path('admin/images/templates/'.$name.'.jpg'); //$img_dst = public_path('admin/images/templates/'.$new_name.'.jpg'); //$this->rcopy($img_src,$img_dst); $tpl = $type == 1 ? 'pc_tpl_id' : 'mobile_tpl_id'; $update[$tpl] = $insertedId; $update = WebsiteInfo::where('cus_id', $cus_id)->update($update); return Response::json(['err' => 0, 'msg' => '']); } } }
private function quickBarDefaultColor() { $id = Auth::id(); $search = "/QuickBar=(.*)/i"; $template = WebsiteInfo::where('cus_id', $id)->first(); //===获取PC端颜色=== $pc_name = Template::where('id', $template->pc_tpl_id)->pluck('name'); $config_str = file_get_contents(public_path('/templates/' . $pc_name) . '/config.ini'); $result = preg_match($search, $config_str, $config_arr); if (!$result) { $config_arr = array(); $config_arr[1] = '#AAA,#BBB,#FFF|totop'; } $color_str = preg_replace("/\\|(.*)/i", '', $config_arr[1]); $colors['pc'] = explode(',', ltrim($color_str, ',')); //===获取手机端颜色=== $mobile_name = Template::where('id', $template->mobile_tpl_id)->pluck('name'); $config_str = file_get_contents(public_path('/templates/' . $mobile_name) . '/config.ini'); $result = preg_match($search, $config_str, $config_arr); if ($result) { if (trim($config_arr[1]) != 'custom') { $color_str = preg_replace("/\\|(.*)/i", '', $config_arr[1]); $colors['mobile'] = explode(',', ltrim($color_str, ',')); } } return $colors; }
/** * 还原用户 * @param ftp_connect $conn ftp对象 * @param string $dir 路径 * @param string $username 用户名 * @return null */ function reductionCustomer() { if ($this->authData()) { $result = ''; $name = Input::get('username'); // $name = Input::get('name'); $Customer = Customer::where('name', $name)->where('is_del', 0)->get(); if (!isset($Customer[0])) { return Response::json(['err' => 1004, 'msg' => '用户不存在或未删除']); exit; } //修改静态服务器文件名 $conn = @ftp_connect($Customer[0]['ftp_address'], $Customer[0]['ftp_port']); if (!$conn) { return Response::json(['err' => 1004, 'msg' => 'FTP服务器连接失败']); exit; } if (!@ftp_login($conn, $Customer[0]['ftp_user'], $Customer[0]['ftp_pwd'])) { return Response::json(['err' => 1004, 'msg' => 'FTP服务器登陆失败']); exit; } @ftp_pasv($conn, 1); // 打开被动模拟 if (!@ftp_rename($conn, $name . "_beifen", $name)) { return Response::json(['err' => 1004, 'msg' => 'FTP服务器静态没有备份']); exit; } @ftp_close($conn); //解压备份的图片文件 $zip = new ZipArchive(); if (!is_dir(public_path("customers/" . $name))) { mkdir("customers/" . $name); } if ($zip->open(public_path("customers_backups/" . $name . '.zip')) === TRUE) { $zip->extractTo(public_path("customers/" . $name)); $zip->close(); } else { return Response::json(['err' => 1004, 'msg' => '解压失败']); exit; } if ($zip->open(public_path("packages/customernull.zip")) === TRUE) { $zip->extractTo(public_path("customers/" . $name)); } else { return Response::json(['err' => 1004, 'msg' => '解压失败2']); exit; } $zip->close(); //更新数据库 $update['is_del'] = 1; $cus_id = $Customer[0]['id']; $WebsiteInfo = WebsiteInfo::where('cus_id', $cus_id)->where('is_del', 0)->get(); if ($WebsiteInfo) { WebsiteInfo::where('cus_id', $cus_id)->update($update); } $CustomerInfo = CustomerInfo::where('cus_id', $cus_id)->where('is_del', 0)->get(); if ($CustomerInfo) { CustomerInfo::where('cus_id', $cus_id)->update($update); } Customer::where('id', $cus_id)->update($update); unlink(public_path("customers_backups/" . $name . ".zip")); $result = ['err' => 1000, 'msg' => '还原用户成功']; } else { $result = ['err' => 1002, 'msg' => '验证不通过']; } return Response::json($result); }