/** * 用户修改设置 */ public function customerSetting() { $cus_id = Auth::id(); $logo = CustomerInfo::where('cus_id', $cus_id)->pluck('logo'); $logo_small = CustomerInfo::where('cus_id', $cus_id)->pluck('logo_small'); $org_floatadv = CustomerInfo::where('cus_id', $cus_id)->pluck('floatadv'); $org_floatadv = json_decode($org_floatadv); $org_imgs = array(); foreach ((array) $org_floatadv as $v) { if (!isset($v->type) || $v->type == 'adv') { $org_imgs[] = $v->adv; } } $data['background_music'] = Input::get('background_music'); $data['talent_support'] = Input::get('talent_support'); $data['company'] = strtolower(Input::get('company_name')); $pc_domain = Input::get('domain_pc'); $data['pc_domain'] = strstr($pc_domain, 'http') ? $pc_domain : 'http://' . $pc_domain; $mobile_domain = Input::get('domain_m'); $data['mobile_domain'] = strstr($mobile_domain, 'http') ? $mobile_domain : 'http://' . $mobile_domain; $data['favicon'] = basename(Input::get('favicon')); $data['logo'] = basename(Input::get('logo_large')); $data['logo_small'] = basename(Input::get('logo_small')); $data['pc_header_script'] = Input::get('pc_header_script'); $data['mobile_header_script'] = Input::get('mobile_header_script'); $data['title'] = Input::get('title'); $data['keywords'] = Input::get('keywords'); $data['description'] = Input::get('description'); $data['footer'] = Input::get('footer'); $data['mobile_footer'] = Input::get('mobile_footer'); $data['pc_footer_script'] = Input::get('pc_footer_script'); $data['mobile_footer_script'] = Input::get('mobile_footer_script'); $data['pc_page_count'] = Input::get('pc_num_per_page') ? Input::get('pc_num_per_page') : 12; $data['pc_page_links'] = Input::get('pc_num_pagenav') ? Input::get('pc_num_pagenav') : 8; $data['mobile_page_count'] = Input::get('m_num_per_page') ? Input::get('m_num_per_page') : 12; $data['mobile_page_links'] = Input::get('m_num_pagenav') ? Input::get('m_num_pagenav') : 3; $data['contact_name'] = Input::get('contactor'); $data['telephone'] = Input::get('telephone'); $data['mobile'] = Input::get('mobile'); $data['fax'] = Input::get('fax'); $data['email'] = Input::get('mail'); $data['qq'] = Input::get('qq'); $data['address'] = Input::get('address'); $data['pc_page_imgtxt_count'] = Input::get('pc_imgtxt_per_page') > 0 ? Input::get('pc_imgtxt_per_page') : 3; $data['pc_page_txt_count'] = Input::get('pc_txt_per_page') > 0 ? Input::get('pc_txt_per_page') : 3; $data['pc_page_img_count'] = Input::get('pc_img_per_page') > 0 ? Input::get('pc_img_per_page') : 3; $data['pc_page_count_switch'] = Input::get('pc_page_count_switch'); $data['enlarge'] = Input::get('enlargev'); $data['lang'] = Input::get('lang'); $data['copyright'] = Input::get('copyright'); $data['pushed'] = 1; $float_adv = Input::get('float_adv') ? Input::get('float_adv') : array(); $float_type = Input::get('float_type') ? Input::get('float_type') : array(); $posx = Input::get('posx') ? Input::get('posx') : array(); $posy = Input::get('posy') ? Input::get('posy') : array(); $posw = Input::get('posw') ? Input::get('posw') : array(); $href = Input::get('href') ? Input::get('href') : array(); $position = Input::get('position') ? Input::get('position') : array(); $floatadv = array(); $num = 0; foreach ((array) $float_adv as $key => $val) { $floatadv[$num]['adv'] = $val; $floatadv[$num]['type'] = $float_type[$key]; $floatadv[$num]['posx'] = $posx[$key]; $floatadv[$num]['posy'] = $posy[$key]; $floatadv[$num]['posw'] = $posw[$key]; $floatadv[$num]['href'] = !empty($href[$key]) ? $href[$key] : ''; $floatadv[$num]['position'] = $position[$key]; $num++; } $data['floatadv'] = json_encode($floatadv); $update = CustomerInfo::where('cus_id', $cus_id)->update($data); if ($update) { if ($logo != $data['logo']) { $imgdel = new ImgDel(); $imgdel->mysave($logo, 'common'); } if ($logo_small != $data['logo_small']) { $imgdel = new ImgDel(); $imgdel->mysave($logo_small, 'common'); } foreach ((array) $org_imgs as $v) { if (!in_array($v, $float_adv)) { $imgdel = new ImgDel(); $imgdel->mysave($v, 'common'); } } $result = ['err' => 0, 'msg' => '', 'data' => '']; } else { $result = ['err' => 1002, 'msg' => '无法保存数据', 'data' => '']; } return Response::json($result); }
/** * 用户修改设置 */ public function customerSetting() { $cus_id = Auth::id(); $data['company'] = Input::get('company_name'); $pc_domain = Input::get('domain_pc'); $data['pc_domain'] = strstr($pc_domain, 'http') ? $pc_domain : 'http://' . $pc_domain; $mobile_domain = Input::get('domain_m'); $data['mobile_domain'] = strstr($mobile_domain, 'http') ? $mobile_domain : 'http://' . $mobile_domain; $data['favicon'] = basename(Input::get('favicon')); $data['logo'] = basename(Input::get('logo_large')); $data['logo_small'] = basename(Input::get('logo_small')); $data['pc_header_script'] = Input::get('pc_header_script'); $data['mobile_header_script'] = Input::get('mobile_header_script'); $data['title'] = Input::get('title'); $data['keywords'] = Input::get('keywords'); $data['description'] = Input::get('description'); $data['footer'] = Input::get('footer'); $data['mobile_footer'] = Input::get('mobile_footer'); $data['pc_footer_script'] = Input::get('pc_footer_script'); $data['mobile_footer_script'] = Input::get('mobile_footer_script'); $data['pc_page_count'] = Input::get('pc_num_per_page') ? Input::get('pc_num_per_page') : 12; $data['pc_page_links'] = Input::get('pc_num_pagenav') ? Input::get('pc_num_pagenav') : 8; $data['mobile_page_count'] = Input::get('m_num_per_page') ? Input::get('m_num_per_page') : 12; $data['mobile_page_links'] = Input::get('m_num_pagenav') ? Input::get('m_num_pagenav') : 3; $data['contact_name'] = Input::get('contactor'); $data['telephone'] = Input::get('telephone'); $data['mobile'] = Input::get('mobile'); $data['fax'] = Input::get('fax'); $data['email'] = Input::get('mail'); $data['qq'] = Input::get('qq'); $data['address'] = Input::get('address'); $update = CustomerInfo::where('cus_id', $cus_id)->update($data); if ($update) { Articles::where('cus_id', $cus_id)->where('pushed', 0)->update(array('pushed' => 1)); Classify::where('cus_id', $cus_id)->where('pushed', 0)->update(array('pushed' => 1)); $result = ['err' => 0, 'msg' => '', 'data' => '']; } else { $result = ['err' => 1002, 'msg' => '无法保存数据', 'data' => '']; } return Response::json($result); }
/** * 改变空间容量(添加/删除) * @param type $size 图片大小 * @param type $way 释放free/占用use * @return boolean */ public function change_capa($size = 0, $way = 'use') { $cus_id = Auth::id(); $cusinfo = CustomerInfo::where('cus_id', $cus_id)->first(); $capacity_use = $cusinfo->capacity_use; $capacity = $cusinfo->capacity; if ($way == 'use') { if ($capacity >= $capacity_use + $size) { $data = array("capacity_use" => $capacity_use + $size); } else { return false; //容量不足 } } else { if ($way == 'free') { if ($capacity_use - $size < 0) { $data = array("capacity_use" => 0); } else { $data = array("capacity_use" => $capacity_use - $size); } } } $flag = CustomerInfo::where('cus_id', $cus_id)->update($data); if ($flag) { //是否更新成功 return true; //修改成功 } else { return false; //修改失败 } }
/** * 推送 * * */ public function pushPrecent() { if (ob_get_level() == 0) { ob_start(); } $indexhtml = $this->homgepagehtml('pc'); $customer_data_get = CustomerPushfile::where('cus_id', $this->cus_id)->pluck('files'); if ($customer_data_get) { $new_data = 0; $customer_data = unserialize($customer_data_get); } else { $new_data = 1; $customer_data = []; } $mindexhtml = $this->homgepagehtml('mobile'); $pc_classify_ids = Classify::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id'); $mobile_classify_ids = Classify::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id'); $pc_article_ids = Articles::where('cus_id', $this->cus_id)->where('pc_show', 1)->lists('id'); $mobile_article_ids = Articles::where('cus_id', $this->cus_id)->where('mobile_show', 1)->lists('id'); $count = $this->htmlPagecount($pc_classify_ids, $mobile_classify_ids, $pc_article_ids, $mobile_article_ids); $this->html_precent = 70 / $count; $categoryhtml = $this->categoryhtml($pc_classify_ids, 'pc'); $mcategoryhtml = $this->categoryhtml($mobile_classify_ids, 'mobile'); $articlehtml = $this->articlehtml($pc_article_ids, 'pc'); $marticlehtml = $this->articlehtml($mobile_article_ids, 'mobile'); $this->percent = 20 / $count; $path = public_path('customers/' . $this->customer . '/' . $this->customer . '.zip'); $template = new PrintController('online', 'mobile'); $quickbar_json = $template->quickBarJson(); $zip = new ZipArchive(); if ($zip->open($path, ZipArchive::CREATE) === TRUE) { $zip->addFile($indexhtml, 'index.html'); $nowpercent = $this->percent + $this->lastpercent; if (floor($nowpercent) != $this->lastpercent) { echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />'; ob_flush(); flush(); } $this->lastpercent += 70 + $this->percent; $zip->addFile($mindexhtml, 'mobile/index.html'); $nowpercent = $this->percent + $this->lastpercent; if (floor($nowpercent) != floor($this->lastpercent)) { echo floor($nowpercent) . '%<script type="text/javascript">parent.refresh(' . floor($nowpercent) . ');</script><br />'; ob_flush(); flush(); } $this->lastpercent += $this->percent; $zip->close(); } //$customer_data = $this->compareZip($categoryhtml,$customer_data,'p','category',$path); //$customer_data = $this->compareZip($mcategoryhtml,$customer_data,'m','mobile/category',$path); //$customer_data = $this->compareZip($articlehtml,$customer_data,'pf','detail',$path); //$customer_data = $this->compareZip($marticlehtml,$customer_data,'mf','mobile/detail',$path); $this->compareZip($categoryhtml, $customer_data, 'p', 'category', $path); $this->compareZip($mcategoryhtml, $customer_data, 'm', 'mobile/category', $path); $this->compareZip($articlehtml, $customer_data, 'pf', 'detail', $path); $this->compareZip($marticlehtml, $customer_data, 'mf', 'mobile/detail', $path); if (90 > floor($this->lastpercent)) { echo '90%<script type="text/javascript">parent.refresh(90);</script><br />'; ob_flush(); flush(); } if ($zip->open($path, ZipArchive::CREATE) === TRUE) { $pc_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'website_info.pc_tpl_id', '=', 'template.id')->pluck('name'); $mobile_dir = Template::where('website_info.cus_id', $this->cus_id)->Leftjoin('website_info', 'template.id', '=', 'website_info.mobile_tpl_id')->pluck('name'); $aim_dir = public_path("templates/{$pc_dir}/"); $maim_dir = public_path("templates/{$mobile_dir}/"); //$images_dir=public_path("customers/".$this->customer."/images/"); $this->addDir($aim_dir, $zip); //$this->addDir($images_dir,$zip,'images/'); $this->addDir($maim_dir, $zip, 'mobile/'); $zip->close(); $data = serialize($customer_data); if ($new_data) { $customerpushfile = new CustomerPushfile(); $customerpushfile->cus_id = $this->cus_id; $customerpushfile->files = $data; $customerpushfile->save(); } else { CustomerPushfile::where('cus_id', $this->cus_id)->update(['files' => $data]); } $customerinfo = Customer::find($this->cus_id); $ftp_array = explode(':', $customerinfo->ftp_address); $ftp_array[1] = isset($ftp_array[1]) ? $ftp_array[1] : '21'; $conn = ftp_connect($ftp_array[0], $ftp_array[1]); if ($conn) { ftp_login($conn, $customerinfo->ftp_user, $customerinfo->ftp_pwd); ftp_pasv($conn, 1); ftp_put($conn, "site.zip", $path, FTP_BINARY); ftp_put($conn, "unzip.php", public_path("packages/unzip.php"), FTP_ASCII); ftp_put($conn, "quickbar.json", public_path('customers/' . $this->customer . '/quickbar.json'), FTP_ASCII); ftp_put($conn, "mobile/quickbar.json", public_path('customers/' . $this->customer . '/quickbar.json'), FTP_ASCII); ftp_close($conn); } echo '100%<script type="text/javascript">parent.refresh(100);</script><br />'; Classify::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]); Articles::where('cus_id', $this->cus_id)->where('pushed', 1)->update(['pushed' => 0]); $search_data = new TemplatesController(); $search_data->sendData(); $pc_domain = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_domain'); @file_get_contents("{$pc_domain}/unzip.php"); } else { echo '打包失败'; } ob_end_flush(); }
/** * 计算生成html文件的数量 * * @param array $pc_classify_ids pc栏目id * @param array $mobile_classify_ids 手机栏目id * @param array $pc_article_ids pc文章id * @param array $mobile_article_ids 手机文章id * @return int */ private function htmlPagecount($pc_classify_ids = [], $mobile_classify_ids = [], $pc_article_ids = [], $mobile_article_ids = []) { $template = new PrintController(); $page_count = 2; $pc_per_page = CustomerInfo::where('cus_id', $this->cus_id)->pluck('pc_page_count'); foreach ($pc_classify_ids as $id) { $c_ids = explode(',', $template->getChirldenCid($id)); $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('pc_show', '1')->count(); if ($total) { $page_count += ceil($total / $pc_per_page); } else { $page_count++; } } $mobileper_page = CustomerInfo::where('cus_id', $this->cus_id)->pluck('mobile_page_count'); foreach ($pc_classify_ids as $id) { $c_ids = explode(',', $template->getChirldenCid($id)); $total = Articles::whereIn('c_id', $c_ids)->where('cus_id', $this->cus_id)->where('mobile_show', '1')->count(); if ($total) { $page_count += ceil($total / $mobileper_page); } else { $page_count++; } } $page_count += count($pc_article_ids); $page_count += count($mobile_article_ids); return $page_count; }
/** * 判断一个用户是否需要推送并返回修改的次数 */ 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); }
/** * pushtest搜索页面数据 * * @param type $publicdata * @return type */ public function searchPush($publicdata) { error_reporting(E_ALL ^ E_NOTICE); $result = $publicdata['result']; $result['navs'] = $publicdata['navs']; $customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first(); $result['title'] = $customer_info->title; $result['keywords'] = $customer_info->keywords; $result['description'] = $customer_info->description; $c_id = Classify::where('type', 4)->where($this->type . '_show', 1)->where('cus_id', $this->cus_id)->pluck('id'); if ($c_id) { $current_arr = $this->currentCidArray($c_id); $result['navs'] = $this->addCurrent($result['navs'], $current_arr); } if (is_array($result['navs'])) { foreach ($result['navs'] as $nav) { if ($nav['current'] == 1) { $pagenavs = $nav['childmenu']; break; } else { $pagenavs = []; } } } $result['pagenavs'] = $pagenavs; $result['posnavs'] = array(0 => array('en_name' => 'Search', 'name' => '搜索', 'link' => 'javascript:;', 'icon' => '')); //搜索数据替换 if (!is_file(app_path('views/templates/' . $this->themename . '/searchresult_do.html'))) { //搜索数据标记与替换 if (is_file(app_path('views/templates/' . $this->themename . '/searchresult.html'))) { $file_content = file_get_contents(app_path('views/templates/' . $this->themename . '/searchresult.html')); } else { $file_content = file_get_contents(public_path("packages/searchresult.html")); } //匹配搜索循环 preg_match('/(\\{foreach[^\\}]*from[\\s]*=[\\s]*\\$search\\.data[^\\}]*\\})([\\s\\S]*?)\\{\\/foreach\\}/', $file_content, $search_foreach); $search_content = str_replace($search_foreach[2], '<!--search_content_start-->' . $search_foreach[2] . '<!--search_content_end-->', $file_content); //匹配foreach中的item值 preg_match('/item[\\s]*=[\\s]*([\\S]*)/', $search_foreach[1], $search_view); $search_view = $search_view[1]; //匹配所有查询中循环的值 preg_match_all('/{[\\s]*\\$' . $search_view . '[.|\\[]([a-z]*)[\\]]*}/', $search_foreach[2], $date_replace); $search_view = array('title' => '$title', 'image' => '$image', 'link' => '$link', 'description' => '$description', 'pubdate' => '$pubdate', 'pubtimestamp' => '$pubtimestamp', 'pubymd' => '$pubymd'); foreach ((array) $date_replace[0] as $k => $v) { $search_content = str_replace($v, 'search_' . $search_view[$date_replace[1][$k]], $search_content); } //分页匹配 $page_content = $search_content; $page_link_array = array('100-8_search' => '100-9_search'); preg_match('/(\\{foreach[^\\}]*from[\\s]*=[\\s]*\\$page_links\\.nears_link[^\\}]*\\})[\\s\\S]*?(\\{if[^\\}]*==[\\s]*\\$page_links\\.current_page[^\\}]*\\})([\\s\\S]*?)\\{else\\}([\\s\\S]*?)\\{\\/if\\}[\\s\\S]*?\\{\\/foreach\\}/', $page_content, $page_foreach); if ($page_foreach) { $page_content = str_replace($page_foreach[3], '<!--page_corrent_link_start-->' . $page_foreach[3] . '<!--page_corrent_link_end-->', $page_content); $page_content = str_replace($page_foreach[4], '<!--page_uncorrent_link_start-->' . $page_foreach[4] . '<!--page_uncorrent_link_end-->', $page_content); $page_link_array = array('100-8_search' => '100-9_search', '100-1_search' => 'javascript::'); } else { preg_match('/(\\{foreach[^\\}]*from[\\s]*=[\\s]*\\$page_links\\.nears_link[^\\}]*\\})([\\s\\S]*?)\\{\\/foreach\\}/', $page_content, $page_foreach); if ($page_foreach) { $page_content = str_replace($page_foreach[2], '<!--page_uncorrent_link_start-->' . $page_foreach[2] . '<!--page_uncorrent_link_end-->', $page_content); } } //分页结束 file_put_contents(app_path('views/templates/' . $this->themename . '/searchresult_do.html'), $page_content); $publicdata['repleace']['searchresult_do.html'] = $page_content; } $result['search'] = array('total' => '-1000_search', 'keyword' => 'search_$keyword', 'data' => array(0 => array('link' => '', 'title' => '', 'pubdate' => '', 'description' => ''))); $result['page_links'] = array('current_page' => '100-1_search', 'per_page' => '100-2_search', 'page_count' => '100-3_search', 'first_link' => '100-4_search', 'prev_link' => '100-5_search', 'next_link' => '100-6_search', 'last_link' => '100-7_search', 'nears_link' => $page_link_array); //替换结束 if ($this->type != 'mobile') { if (is_file(app_path('views/templates/' . $this->themename . '/searchresult.html'))) { $json_keys = $this->getJsonKey('searchresult.html'); if (count($json_keys)) { foreach ($json_keys as $key) { $result[$key] = $this->detailList($this->pagedata($key)); } } } } if ($this->type == 'pc') { $page_count = $customer_info->pc_page_count; $page_link_count = $customer_info->pc_page_links; } else { $page_count = $customer_info->mobile_page_count; $page_link_count = $customer_info->mobile_page_links; } //文章数据json保存 $article_data = Articles::where('cus_id', $this->cus_id)->where($this->type . '_show', '1')->orderBy('is_top', 'desc')->orderBy('created_at', 'desc')->select('id', 'title', 'img', 'introduction', 'created_at', 'use_url', 'url')->get()->toArray(); $article = array(); foreach ((array) $article_data as $article_img) { $article[$article_img['id']]['id'] = $article_img['id']; $article[$article_img['id']]['title'] = $article_img['title']; $article[$article_img['id']]['img'] = $article_img['img'] ? $this->source_dir . 'l/articles/' . $article_img['img'] : ''; $article[$article_img['id']]['introduction'] = $article_img['introduction']; $article[$article_img['id']]['created_at'] = strtotime($article_img['created_at']); $article[$article_img['id']]['link'] = $this->domain . '/detail/' . $article_img['id'] . '.html'; if ($article_img['use_url']) { $article[$article_img['id']]['link'] = $article_img['url']; } } $article['count'] = $page_count; $article['page_link'] = $page_link_count; $article_json = json_encode($article); if ($this->type == 'pc') { file_put_contents(public_path('customers/' . $this->customer . '/article_data.json'), $article_json); } else { file_put_contents(public_path('customers/' . $this->customer . '/mobile/article_data.json'), $article_json); } $content = $publicdata['repleace']['searchresult_do.html']; $content = preg_replace($publicdata['pattern'], $publicdata['repleace'], $content); $smarty = new Smarty(); $smarty->setCompileDir(app_path('storage/views/compile')); $smarty->setTemplateDir(app_path('views/templates/' . $this->themename)); $smarty->registerPlugin('function', 'mapExt', array('PrintController', 'createMap')); $smarty->registerPlugin('function', 'shareExt', array('PrintController', 'createShare')); $smarty->assign($result); ob_start(); $smarty->display('string:' . $content); $output = ob_get_contents(); ob_end_clean(); if (!count($result['footer_navs'])) { $output = preg_replace('/<a href="' . str_replace("/", "\\/", $result['site_url']) . '"( target="_blank")?( )?>首页<\\/a>( )?\\|([\\s]+)?(<br \\/>)?(<br>)?/is', "", $output); } return $output; }
public function searchPreview() { $result = $this->pagePublic(); $customer_info = CustomerInfo::where('cus_id', $this->cus_id)->first(); $result['title'] = $customer_info->title; $result['keywords'] = $customer_info->keywords; $result['description'] = $customer_info->description; $result['pagenavs'] = false; $result['posnavs'] = false; if ($this->type != 'mobile') { if (file_exists(app_path('views/templates/' . $this->themename . '/searchresult.html'))) { $json_keys = $this->getJsonKey('searchresult.html'); if (count($json_keys)) { foreach ($json_keys as $key) { $result[$key] = $this->detailList($this->pagedata($key)); } } } else { return false; } } return json_encode($result); }
public function classifyDelete() { $failed = ''; $cus_id = Auth::id(); $id = explode(',', ltrim(Input::get('id'), ',')); count($id) > 1 ? $id : ($id = $id[0]); if (is_array($id)) { foreach ($id as $v) { $classify = Classify::find($v); $c_del_img = $classify->img; $ids = Articles::where('c_id', $v)->lists('id'); $a_del_imgs = Articles::where('c_id', $v)->lists('img'); if (count($ids)) { $m_del_imgs = MoreImg::whereIn('a_id', (array) $ids)->lists('img'); } else { $m_del_imgs = array(); } $del_imgs = array_merge((array) $a_del_imgs, (array) $m_del_imgs); $d_c_result = Classify::where('id', $v)->where('cus_id', $cus_id)->delete(); Articles::where('c_id', $v)->where('cus_id', $cus_id)->delete(); $this->delMobileHomepage($v); //删除手机首页配置 if ($d_c_result) { foreach ((array) $del_imgs as $val) { $imgdel = new ImgDel(); $imgdel->mysave($val); } $imgdel = new ImgDel(); $imgdel->mysave($c_del_img, 'category'); $success[] = $v; } else { $failed .= $v . ','; } } } else { $classify = Classify::find($id); $c_del_img = $classify->img; $ids = Articles::where('c_id', $id)->lists('id'); $a_del_imgs = Articles::where('c_id', $id)->lists('img'); if (count($ids)) { $m_del_imgs = MoreImg::whereIn('a_id', (array) $ids)->lists('img'); } else { $m_del_imgs = array(); } $del_imgs = array_merge((array) $a_del_imgs, (array) $m_del_imgs); $d_c_result = Classify::where('id', $id)->where('cus_id', $cus_id)->delete(); Articles::where('c_id', $id)->where('cus_id', $cus_id)->delete(); $this->delMobileHomepage($id); $this->delChildClassify($id); if ($d_c_result) { foreach ((array) $del_imgs as $val) { $imgdel = new ImgDel(); $imgdel->mysave($val); } $imgdel = new ImgDel(); $imgdel->mysave($c_del_img, 'category'); $success[] = $id; } else { return Response::json(['err' => 1001, 'msg' => '栏目' . $id . '存在子目录或文章,删除失败']); } } if (!$failed) { CustomerInfo::where('cus_id', $cus_id)->update(['pushed' => 1]); $result = ['err' => 0, 'msg' => '', 'data' => $success]; } else { $result = ['err' => 1001, 'msg' => '删除栏目失败']; } return Response::json($result); }
public function pushFile() { $cus_id = Auth::id(); $customerinfo = CustomerInfo::where('cus_id', $cus_id)->first(); $pushed_at = strtotime($customerinfo->pushed_at); $updated_at = strtotime($customerinfo->updated_at); if ($pushed_at == NULL || $pushed_at < $updated_at) { //整站重新生成html //只需推送$customer.'.zip',不生成$customer.'_update.zip' } else { $pc_classify_updated = FALSE; $mobile_classify_updated = FALSE; $pc_classify_updated_at = Classify::where('cus_id', $cus_id)->where('pc_show', 1)->lists('updated_at'); $mobile_classify_updated_at = Classify::where('cus_id', $cus_id)->where('mobile_show', 1)->lists('updated_at'); foreach ($pc_classify_updated_at as $v) { if ($pushed_at < strtotime($v)) { $pc_classify_updated = TRUE; break; } } foreach ($mobile_classify_updated_at as $v) { if ($pushed_at < strtotime($v)) { $mobile_classify_updated = TRUE; break; } } /* /*找出PC生成html的部分 */ if ($pc_classify_updated || 'PC模版更换') { //PC所有页面重新生成html } else { $pc_article_updated_at = Articles::where('cus_id', $cus_id)->where('pc_show', 1)->lists('updated_at'); $cids = explode(',', $this->getChirldenCid($v['value']['id'])); //取得所有栏目id //PC文章修改--->其栏目、父级及长辈级栏目、文章页重新生成html //PC模版颜色更换 } /* /*找出手机生成html的部分 */ if ($pc_classify_updated) { //手机所有页面重新生成html } else { //手机文章修改--->其栏目、父级及长辈级栏目、文章页重新生成html //手机模版颜色更换 } //更新$customer.'.zip',创建$customer.'_update.zip',推送$customer.'_update.zip',删除$customer.'_update.zip' } }
private function qrcode($barcode) { // $qrencode=new QRencode(); $customer = Auth::user()->name; $id = Auth::id(); $customer_info = Customer::where('id', $id)->first(); $domain = $customer_info->{$barcode}; if ($domain == "") { $customer_info = CustomerInfo::where('cus_id', $id)->first(); $domain = $customer_info->{$barcode}; return ''; } // $url= str_replace('http://', '', $domain); // $errorCorrectionLevel = "L"; // $path='customers/'.$customer.'/images/l/common/'; // $outfile=public_path($path); // $enc = $qrencode->factory($errorCorrectionLevel,6); // $enc->encodePNG($url, $outfile.$barcode.".png", $saveandprint=false); // return asset($path.$barcode.".png"); return 'http://api.qrserver.com/v1/create-qr-code/?size=200x200&data=' . $domain; }
/** * 还原用户 * @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); }