Commit e12e0e22 by doszhang

dos

parent cd336f47
...@@ -35,7 +35,7 @@ return array( ...@@ -35,7 +35,7 @@ return array(
'driverConfig' => array( 'driverConfig' => array(
'accessKey' => 'ggMPohY9_87Q69nDYUMwvR7XqlLYAREH-btbJG3U', 'accessKey' => 'ggMPohY9_87Q69nDYUMwvR7XqlLYAREH-btbJG3U',
'secrectKey' => 'OPzIqCWVMDs7tAYjPi9Hn7JkxBj2CtHARCCEnrdd', 'secrectKey' => 'OPzIqCWVMDs7tAYjPi9Hn7JkxBj2CtHARCCEnrdd',
'domain' => '7xou29.media1.z0.glb.clouddn.com', 'domain' => 'geely-cdn.izhida.cn',
'bucket' => 'zhida-stream', 'bucket' => 'zhida-stream',
// 'domain' => '7xjtzd.com2.z0.glb.qiniucdn.com', // 'domain' => '7xjtzd.com2.z0.glb.qiniucdn.com',
// 'bucket' => 'zhida-yingxiaoyi', // 'bucket' => 'zhida-yingxiaoyi',
......
...@@ -26,7 +26,13 @@ class IndexController extends Controller ...@@ -26,7 +26,13 @@ class IndexController extends Controller
public function index() public function index()
{ {
$this->display(); $user = $this->get_user_info_from_cookie();
// 如果没有获取到用户信息,引导用户授权
if (!$user) {
$this->request_auth($this->get_url());
return;
}
$this->display();
} }
public function detectSensitiveWords($text){ public function detectSensitiveWords($text){
...@@ -78,61 +84,78 @@ class IndexController extends Controller ...@@ -78,61 +84,78 @@ class IndexController extends Controller
} }
} }
// private function detectSensitiveWords($name){ public function upload()
// $text = $name; {
// $resp = file_get_contents('http://nex3-avatar.dev.izhida.cn/index/detectSensitiveWords?text='.$text); $user = $this->get_user_info_from_cookie();
// // $text = $name; if (!$user) {
// // $text = '胡锦涛'; $this->ajaxReturn(array(
// // $cred = new Credential("AKID9B4pPq5YBgz9Yo7qDRkspgOQK3c89PrD", "MXWK3DKNFzYgpvWwCKH4kKoma0O1Yu8A"); 'status' => 404,
// // $httpProfile = new HttpProfile(); 'msg' => '用户不存在'
// // $httpProfile->setEndpoint("nlp.tencentcloudapi.com"); ));
return;
}
if (!$_POST['image']) {
$this->ajaxReturn(array(
'status' => -1,
'msg' => '请填写完整信息'
));
return;
}
$url = $this->saveCommonImageToQiniu($_POST['image'], uniqid('missfresh_poster__'));
if($_POST['source'] == 'poster')
{
M('User')->where(['id' => $user['id']])->save([
'poster_url' => $url,
]);
$this->ajaxReturn(array(
'status' => 1,
'img_url' => $url,
'msg' => '信息提交成功!'
));
return;
}
else
{
M('User')->where(['id' => $user['id']])->save([
'headposter_url' => $url,
]);
$this->ajaxReturn(array(
'status' => 1,
'img_url' => $url,
'msg' => '信息提交成功!'
));
return;
}
// // $clientProfile = new ClientProfile(); }
// // $clientProfile->setHttpProfile($httpProfile); private function saveCommonImageToQiniu($imgData, $fileNameWithoutExt)
// // $client = new NlpClient($cred, "ap-guangzhou", $clientProfile); {
// // $req = new SensitiveWordsRecognitionRequest(); $head = substr($imgData, 0, 20);
$type = 'png';
// // $params = '{"Text":"+'. $text .'+"}'; if (stripos($head, 'data:image/jpg;') !== false || stripos($head, 'data:image/jpeg;') !== false) {
// // $req->fromJsonString($params); $type = 'jpg';
// // $resp = $client->SensitiveWordsRecognition($req); $imgData = substr($imgData, strlen('data:image/jpeg;base64,'));
// // $resp = $resp->toJsonString(); } else {
// // return $resp; $imgData = substr($imgData, strlen('data:image/png;base64,'));
}
// return json_decode($resp,1); $imgData = str_replace(' ', '+', $imgData);
// } $data = base64_decode($imgData);
if (strlen($data) == 0) {
// public function checkWord() { return false;
// $name = $_POST['name']; }
// if(empty($name)) $fileName = $fileNameWithoutExt . '.' . $type;
// { $upfile = array(
// $this->ajaxReturn(array( 'name' => 'file',
// 'status' => 0, 'fileName' => $fileName,
// 'msg' => '非法', 'fileBody' => $data,
// 'step' => 3 );
// )); $config = C('UPLOAD_SITEIMG_QINIU')['driverConfig'];
// return; $qiniu = new QiniuStorage($config);
// } $opt = array();
// $detectResult = $this->detectSensitiveWords($name); $result = $qiniu->upload($opt, $upfile);
$url = $qiniu->downlink($fileName);
// if($detectResult['SensitiveWords'] != null) return $url;
// { }
// $this->ajaxReturn(array(
// 'status' => -1,
// 'msg' => '您提交的姓名包含敏感词',
// 'step' => 3
// ));
// return;
// }
// else
// {
// $this->ajaxReturn(array(
// 'status' => 1,
// 'msg' => '通过',
// 'step' => 3
// ));
// return;
// }
// }
// 计算中文字符串长度 // 计算中文字符串长度
function utf8_strlen($string = null) { function utf8_strlen($string = null) {
......
...@@ -260,7 +260,10 @@ function creatPoster() { ...@@ -260,7 +260,10 @@ function creatPoster() {
txtDraw(posterctx, $('[name=customize]').val(), 50, 'normal', '#fff', 90,231); txtDraw(posterctx, $('[name=customize]').val(), 50, 'normal', '#fff', 90,231);
$('#poster').attr('src',getManBase64(posterCanvas)); var src = getManBase64(posterCanvas);
$('#poster').attr('src',src);
uplodImg('poster',src);
$('.upload-page').fadeOut(300); $('.upload-page').fadeOut(300);
$('.poster-page').fadeIn(300); $('.poster-page').fadeIn(300);
...@@ -294,7 +297,10 @@ function creatPoster() { ...@@ -294,7 +297,10 @@ function creatPoster() {
frameimg.onload = function() { frameimg.onload = function() {
posterctx.drawImage(frameimg,51*2,184*2,387*2,387*2); posterctx.drawImage(frameimg,51*2,184*2,387*2,387*2);
$('#poster').attr('src',getManBase64(posterCanvas)); var src = getManBase64(posterCanvas);
$('#poster').attr('src',src);
uplodImg('poster',src);
$('.upload-page').fadeOut(300); $('.upload-page').fadeOut(300);
$('.poster-page').fadeIn(300); $('.poster-page').fadeIn(300);
...@@ -352,7 +358,10 @@ function createHeadimg() { ...@@ -352,7 +358,10 @@ function createHeadimg() {
txtDraw(headimgctx, $('[name=customize]').val(), 41, 'normal', '#fff'); txtDraw(headimgctx, $('[name=customize]').val(), 41, 'normal', '#fff');
headimgctx.restore(); headimgctx.restore();
$('#headimg').attr('src',getManBase64(headimgCanvas)); var src = getManBase64(headimgCanvas);
$('#headimg').attr('src',src);
uplodImg('headimg',src);
$('.upload-page').fadeOut(300); $('.upload-page').fadeOut(300);
$('.headimg-page').delay(0).fadeIn(300); $('.headimg-page').delay(0).fadeIn(300);
...@@ -380,7 +389,10 @@ function createHeadimg() { ...@@ -380,7 +389,10 @@ function createHeadimg() {
frameimg.onload = function() { frameimg.onload = function() {
headimgctx.drawImage(frameimg,0,0,headimgCanvas.width,headimgCanvas.height); headimgctx.drawImage(frameimg,0,0,headimgCanvas.width,headimgCanvas.height);
$('#headimg').attr('src',getManBase64(headimgCanvas)); var src = getManBase64(headimgCanvas);
$('#headimg').attr('src',src);
uplodImg('headimg',src);
$('.upload-page').fadeOut(300); $('.upload-page').fadeOut(300);
$('.headimg-page').delay(0).fadeIn(300); $('.headimg-page').delay(0).fadeIn(300);
...@@ -390,6 +402,14 @@ function createHeadimg() { ...@@ -390,6 +402,14 @@ function createHeadimg() {
} }
function uploadImg(source,src) {
$.ajax({
type: "POST",
url: "Index/upload",
data: {image: src,source: source}
});
}
function homeBtnGoHandleClick() function homeBtnGoHandleClick()
{ {
$('.subtitle,.copywriting1,.btn-go').fadeOut(300); $('.subtitle,.copywriting1,.btn-go').fadeOut(300);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment