Skip to content

Commit 1bc96e5

Browse files
committed
fix fileDownload, fix open profile, fix hover selfInfo,
1 parent db701c7 commit 1bc96e5

16 files changed

Lines changed: 202 additions & 75 deletions

src/config.sample.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
'apiPageLogin' => './index.php?action=page.login',
1414
'apiPageLogout' => './index.php?action=page.logout',
1515
'apiPageJump' => "./index.php?action=page.jump",
16-
'loginPluginId' => '105',
16+
'loginPluginId' => '106',
1717
'apiPageWidget' => './index.php?action=page.widget',
1818
'apiPageSiteInit' => "./index.php?action=installDB",
1919
'session_verify_101' => 'http://open.akaxin.com:5208/index.php?action=api.session.verify&body_format=base64pb',
2020
'session_verify_102' => './index.php?action=api.session.verify&body_format=base64pb',
21+
'session_verify_106' => 'http://192.168.0.106:8081/duckchat/duckchat.php?action=api.session.verify&body_format=base64pb',
2122
"siteAddress" => '',
2223
'passport_cookie_name' => "duckchat_passport_cookie",
2324
'mail' =>

src/controller/BaseController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ protected function getAndSetClientLang()
384384
$this->language = Zaly\Proto\Core\UserClientLangType::UserClientLangEN;
385385
$this->zalyError = $this->ctx->ZalyErrorEn;
386386
}
387-
388387
}
389388

390389
private function returnErrorSession($errorInfo = false)

src/controller/Http/File/Http_File_DownloadFileController.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function index()
2323
$isGroupMessage = isset($_GET['isGroupMessage']) ? $_GET['isGroupMessage'] : "";
2424
$messageId = isset($_GET['messageId']) ? $_GET['messageId'] : "";
2525
$returnBase64 = $_GET['returnBase64'];
26+
2627
try{
2728
if(!in_array($mimeType, $this->notMsgMimeType) && !$messageId) {
2829
throw new Exception("it's msg attachment");
@@ -35,10 +36,8 @@ public function index()
3536
throw new Exception("no group premission, can't load img");
3637
}
3738
} else {
38-
3939
////TODO u2 can load img
4040
$info = $this->ctx->SiteU2MessageTable->queryMessageByMsgId([$messageId]);
41-
4241
if(!$info) {
4342
throw new Exception("no premission, can't load img");
4443
}
@@ -49,7 +48,6 @@ public function index()
4948
throw new Exception("no read permission, can't load img");
5049
}
5150
}
52-
$this->ctx->Wpf_Logger->error($tag, "download file info ==" . json_encode($info) );
5351

5452
$contentJson = $info['content'];
5553
$contentArr = json_decode($contentJson, true);
@@ -58,25 +56,26 @@ public function index()
5856
throw new Exception("get img content is not ok");
5957
}
6058
}
61-
6259
$fileContent = $this->ctx->File_Manager->readFile($fileId);
6360

6461
if(strlen($fileContent)<1) {
6562
throw new Exception("load file void");
6663
}
64+
6765
header('Cache-Control: max-age=86400, public');
6866
header("Content-type:$mimeType");
6967
if($mimeType == $this->documentMimeType) {
7068
header("Content-Disposition:attachment");
7169
}
70+
7271
if($returnBase64) {
7372
echo base64_decode($fileContent);
7473
} else {
7574
echo $fileContent;
7675
}
7776
}catch (Exception $ex) {
7877
header("Content-type:$mimeType");
79-
$this->ctx->Wpf_Logger->error($tag, $ex );
78+
$this->ctx->Wpf_Logger->error($tag, $ex);
8079
echo "failed";
8180
}
8281
}

src/controller/HttpBaseController.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ abstract class HttpBaseController extends \Wpf_Controller
3434
private $jumpRoomId = "";
3535
private $jumpRelation = "";
3636
public $siteCookieName = "zaly_site_user";
37+
public $language = "";
3738

3839
protected $ctx;
3940

@@ -58,20 +59,18 @@ public function __construct(BaseCtx $context)
5859
public function doIndex()
5960
{
6061
$tag = __CLASS__ . "-" . __FUNCTION__;
61-
6262
try {
6363
parent::doIndex();
6464
$preSessionId = isset($_GET['preSessionId']) ? $_GET['preSessionId'] : "";
6565
$action = isset($_GET['action']) ? $_GET['action'] : "";
66-
66+
$this->getAndSetClientLang();
6767
if ($preSessionId) {
6868
$this->handlePreSessionId();
6969
}
70-
7170
if (!in_array($action, $this->whiteAction)) {
7271
$flag = $this->ctx->Site_Config->getConfigValue(SiteConfig::SITE_OPEN_WEB_EDITION);
7372
if ($flag != 1) {
74-
echo "该站点没有开起web版本";
73+
echo ZalyText::getText("text.open.web", $this->language);
7574
die();
7675
}
7776
$this->getUserIdByCookie();
@@ -85,6 +84,16 @@ public function doIndex()
8584
}
8685
}
8786

87+
protected function getAndSetClientLang()
88+
{
89+
$headLang = isset($_GET['lang']) ? $_GET['lang'] : "";
90+
if (isset($headLang) && $headLang == Zaly\Proto\Core\UserClientLangType::UserClientLangZH) {
91+
$this->language = Zaly\Proto\Core\UserClientLangType::UserClientLangZH;
92+
} else {
93+
$this->language = Zaly\Proto\Core\UserClientLangType::UserClientLangEN;
94+
}
95+
}
96+
8897
public function handlePreSessionId()
8998
{
9099
try {

src/controller/InstallDBController.php

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,24 @@ public function doIndex()
4747
$sampleFileName = dirname(__FILE__) . "/../" . $this->sampleConfigName;
4848

4949
if (file_exists($configFileName)) {
50+
$newConfig = require($configFileName);
51+
$dbType = $newConfig['dbType'];
52+
$sqliteName = $newConfig['sqlite']['sqliteDBName'];
53+
if($dbType == "sqlite" && $sqliteName) {
54+
$sqliteName = $this->_dbPath . "/" . $sqliteName;
55+
$fileExists = file_exists($sqliteName);
56+
if($newConfig['dbType'] == "sqlite" && !$fileExists) {
57+
echo "sqlite DB 文件不存在, 请删除config.php文件,初始化站点";
58+
return;
59+
}
60+
}
5061
$apiPageIndex = ZalyConfig::getConfig("apiPageIndex");
5162
header("Location:" . $apiPageIndex);
5263
exit();
5364
}
5465

5566
$config = require($sampleFileName);
67+
5668
$sqliteName = "";
5769

5870
$this->lang = $_GET['lang'];
@@ -417,30 +429,30 @@ private function initPluginMiniProgram()
417429
'permissionType' => Zaly\Proto\Core\PluginPermissionType::PluginPermissionAll,
418430
'authKey' => "",
419431
],
420-
// [
421-
// 'pluginId' => 104,
422-
// 'name' => "gif小程序",
423-
// 'logo' => "",
424-
// 'sort' => 2, //order = 2
425-
// 'landingPageUrl' => "index.php?action=miniProgram.gif.index",
426-
// 'landingPageWithProxy' => 1, //1 表示走site代理
427-
// 'usageType' => Zaly\Proto\Core\PluginUsageType::PluginUsageU2Message,
428-
// 'loadingType' => Zaly\Proto\Core\PluginLoadingType::PluginLoadingChatbox,
429-
// 'permissionType' => Zaly\Proto\Core\PluginPermissionType::PluginPermissionAll,
430-
// 'authKey' => "",
431-
// ],
432-
// [
433-
// 'pluginId' => 104,
434-
// 'name' => "gif小程序",
435-
// 'logo' => "",
436-
// 'sort' => 2, //order = 2
437-
// 'landingPageUrl' => "index.php?action=miniProgram.gif.index",
438-
// 'landingPageWithProxy' => 1, //1 表示走site代理
439-
// 'usageType' => Zaly\Proto\Core\PluginUsageType::PluginUsageGroupMessage,
440-
// 'loadingType' => Zaly\Proto\Core\PluginLoadingType::PluginLoadingChatbox,
441-
// 'permissionType' => Zaly\Proto\Core\PluginPermissionType::PluginPermissionAll,
442-
// 'authKey' => "",
443-
// ],
432+
[
433+
'pluginId' => 104,
434+
'name' => "gif小程序",
435+
'logo' => "",
436+
'sort' => 2, //order = 2
437+
'landingPageUrl' => "index.php?action=miniProgram.gif.index",
438+
'landingPageWithProxy' => 1, //1 表示走site代理
439+
'usageType' => Zaly\Proto\Core\PluginUsageType::PluginUsageU2Message,
440+
'loadingType' => Zaly\Proto\Core\PluginLoadingType::PluginLoadingChatbox,
441+
'permissionType' => Zaly\Proto\Core\PluginPermissionType::PluginPermissionAll,
442+
'authKey' => "",
443+
],
444+
[
445+
'pluginId' => 104,
446+
'name' => "gif小程序",
447+
'logo' => "",
448+
'sort' => 2, //order = 2
449+
'landingPageUrl' => "index.php?action=miniProgram.gif.index",
450+
'landingPageWithProxy' => 1, //1 表示走site代理
451+
'usageType' => Zaly\Proto\Core\PluginUsageType::PluginUsageGroupMessage,
452+
'loadingType' => Zaly\Proto\Core\PluginLoadingType::PluginLoadingChatbox,
453+
'permissionType' => Zaly\Proto\Core\PluginPermissionType::PluginPermissionAll,
454+
'authKey' => "",
455+
],
444456
[
445457
'pluginId' => 105,
446458
'name' => "账户密码管理小程序",

src/controller/MiniProgram/gif/MiniProgram_Gif_IndexController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MiniProgram_Gif_IndexController extends MiniProgramController
1515
private $u2Type = "u";
1616
private $userRelationAction = "duckChat.user.relation";
1717
private $limit=30;
18-
private $title = "GIF小程序";
18+
private $title = "GIF";
1919
private $roomType="";
2020
private $toId;
2121
private $seeType = "see_gif";
@@ -101,7 +101,7 @@ public function doRequest()
101101
}
102102
unset($gif['userId']);
103103
//gifId, gifUrl, width, height, userId
104-
$gif['gifUrl'] = "./index.php?action=http.file.downloadGif&gifId=".$gif['gifId'];
104+
$gif['gifUrl'] = "./index.php?action=miniProgram.gif.info&gifId=".$gif['gifId'];
105105
echo $this->display("miniProgram_gif_info", $gif);
106106
return;
107107
} else {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: zhangjun
5+
* Date: 08/10/2018
6+
* Time: 10:59 AM
7+
*/
8+
9+
class MiniProgram_Gif_InfoController extends \HttpBaseController
10+
{
11+
private $fileType = 'gif';
12+
13+
private $gifMiniProgramId = 104;
14+
private $title = "GIF";
15+
16+
public function getMiniProgramId()
17+
{
18+
return $this->gifMiniProgramId;
19+
}
20+
21+
public function requestException($ex)
22+
{
23+
$this->showPermissionPage();
24+
}
25+
26+
public function preRequest()
27+
{
28+
}
29+
30+
public function doRequest()
31+
{
32+
header('Access-Control-Allow-Origin: *');
33+
$method = $_SERVER['REQUEST_METHOD'];
34+
$tag = __CLASS__."-".__FUNCTION__;
35+
$gifId = $_GET['gifId'];
36+
$returnBase64 = isset($_GET['returnBase64']) ? $_GET['returnBase64'] : "";
37+
try{
38+
$result = $this->ctx->SiteUserGifTable->getGifByGifId($gifId);
39+
if(!$result) {
40+
echo "failed";
41+
return;
42+
}
43+
$gifUrl = $result['gifUrl'];
44+
$mimeType = $this->ctx->File_Manager->contentType($gifUrl);
45+
$fileContent = $this->ctx->File_Manager->readFile($gifUrl, $this->fileType );
46+
47+
if(strlen($fileContent)<1) {
48+
throw new Exception("load file void");
49+
}
50+
51+
header('Cache-Control: max-age=86400, public');
52+
header("Content-type:$mimeType");
53+
54+
if($returnBase64) {
55+
$fileContent = base64_encode($fileContent);
56+
} else {
57+
$fileContent = $fileContent;
58+
}
59+
echo $fileContent;
60+
}catch (Exception $e) {
61+
header("Content-type:$mimeType");
62+
$this->ctx->Wpf_Logger->error($tag, "error_msg ==" .$e->getMessage() );
63+
echo "failed";
64+
}
65+
}
66+
}

src/lib/Util/ZalyText.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ZalyText
1919
"text.group.notMember" => ["you aren't group member", "你不是群组成员"],
2020
"text.group.create" => ["group created,invite your friends to join chat", "群组已创建成功,邀请你的好友加入群聊吧"],
2121
"upload.file.size" => ["file exceeds maximum limit", "文件超过最大限制"],
22+
"text.open.web" => ["web is not allowed", "该站点没有开起web版本"],
2223
];
2324

2425
public static $keyGroupInvite = "{key.group.invite}";

src/lib/mock.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,11 @@ function mime_content_type($path)
5757
$mimeTypeHexs = [
5858
"89504e470d0a1a0a" => "image/png",
5959
"ffd8ffe0010" => "image/jpg",
60+
"ffd8ffe0" => "image/jpeg",
6061
"474946383961" => 'image/gif',
6162
"667479704d534e56" => 'video/mp4',
6263
'6674797069736f6d' => 'audio/mp4',
6364
'667479704d344120' => 'audio/x-m4a',
64-
'25504446' => 'application/pdf',
65-
'526172211a0700' => 'application/x-rar-compressed',
66-
'57696e5a6970' => 'application/zip',
67-
'cf11e0a1b11ae100' => 'application/msword',
68-
'eca5c100' => 'application/msword',
69-
'3c3f786d6c2076657273696f6e3d' => 'application/xml',
70-
'4d534346' => 'application/vnd.ms-powerpoint',
71-
'a0461df0' => 'application/vnd.ms-powerpoint',
72-
'fdffffffnnnn0000' => 'application/vnd.ms-powerpoint'
7365
];
7466

7567
$fileContent = file_get_contents($path);

src/public/css/zaly_msg.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ html, body{
810810

811811
#selfInfo {
812812
width:38.37rem;
813-
height:23.45rem;
813+
height:18.45rem;
814814
background:rgba(255,255,255,1);
815815
box-shadow:0rem 0.19rem 1.41rem 0.09rem rgba(153,153,153,1);
816816
border-radius:0.56rem;

0 commit comments

Comments
 (0)