Skip to content

Commit ab5e035

Browse files
committed
merge develop
2 parents 5cae01e + 6ae2b23 commit ab5e035

File tree

14 files changed

+407
-398
lines changed

14 files changed

+407
-398
lines changed

src/config.sample.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
return array(
10-
'siteVersionName' => '1.0.9',
11-
'siteVersionCode' => '10009',
10+
'siteVersionName' => '1.0.12',
11+
'siteVersionCode' => '10012',
1212
'apiPageIndex' => './index.php?action=page.index',
1313
'apiPageLogin' => './index.php?action=page.login',
1414
'apiPageLogout' => './index.php?action=page.logout',

src/controller/Api/Group/Api_Group_QuitController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf
3333
$this->setRpcError($errorCode, $errorInfo);
3434
throw new Exception($errorInfo);
3535
}
36+
3637
$this->quitGroup($groupId);
3738

39+
$this->updateGroupAvatar($groupId);
40+
3841
$this->setRpcError($this->defaultErrorCode, "");
3942
$this->rpcReturn($transportData->getAction(), new \Zaly\Proto\Site\ApiGroupQuitResponse());
4043
} catch (Exception $ex) {

src/controller/Api/Group/Api_Group_UpdateController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ private function handleValues($values, $groupId)
113113
$this->ctx->Wpf_Logger->info($tag, " group profile updateValues =". json_encode($updateValues));
114114
$this->ctx->Wpf_Logger->info($tag, " group profile writeUpdateAdminType =". $writeUpdateAdminType);
115115

116-
117-
//只有群主管理员可以修改
118-
$this->isGroupAdmin($groupId);
119-
120116
$groupInfo = $this->getGroupProfile($groupId);
121117

122118
if($writeUpdateAdminType !== false) {
@@ -152,6 +148,9 @@ private function handleValues($values, $groupId)
152148
return;
153149
}
154150

151+
//只有群主管理员可以修改
152+
$this->isGroupAdmin($groupId);
153+
155154
$where = [
156155
"groupId" => $groupId
157156
];

src/controller/HttpBaseController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public function __construct(BaseCtx $context)
5151

5252
}
5353

54+
abstract public function index();
5455

5556
/**
5657
* 处理方法, 根据bodyFormatType, 获取transData

src/controller/InstallDBController.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,15 @@ public function doIndex()
201201
$testCurlUrl = $sampleFile['test_curl'];
202202
$testCurlUrl = ZalyHelper::getFullReqUrl($testCurlUrl);
203203
$curlResult = $this->curl->request($testCurlUrl, 'get');
204-
$doucmentRoot = isset($_SERVER['DOCUMENT_ROOT']) ? str_replace("//", "/", $_SERVER['DOCUMENT_ROOT']) : "";
205-
$scriptRoot = isset($_SERVER['SCRIPT_FILENAME']) ? str_replace("//", "/", $_SERVER['SCRIPT_FILENAME']) : "";
206-
$doucmentUri = isset($_SERVER['DOCUMENT_URI']) ? $_SERVER['DOCUMENT_URI'] : "";
207-
204+
//防止自己配置nginx的时候,多写一个/
205+
$requestUri = isset($_SERVER['REQUEST_URI']) ? str_replace(array("\\", "//"), array("/", "/"), $_SERVER['REQUEST_URI']) : "";
206+
$requestUris = explode("/", $requestUri);
208207
$isInstallRootPath = true;
209-
if(!$doucmentRoot || !$scriptRoot) {
210-
$isInstallRootPath = false;
211-
}
212-
if($doucmentRoot.$doucmentUri != $scriptRoot) {
208+
209+
if(count($requestUris) > 2) {
213210
$isInstallRootPath = false;
214211
}
212+
215213
if($isInstallRootPath === false) {
216214
echo $this->lang == 1 ? "目前只支持根目录运行" : "Currently only the root directory is supported.";
217215
return;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* check current version need to upgrade
4+
* User: anguoyue
5+
* Date: 13/10/2018
6+
* Time: 3:54 PM
7+
*/
8+
9+
abstract class Page_VersionController extends HttpBaseController
10+
{
11+
protected $versions = [
12+
10011 => "1.0.11",
13+
14+
10012 => "1.0.12"
15+
];
16+
17+
abstract function doRequest();
18+
19+
public function index()
20+
{
21+
$this->initUpgradeVersion();
22+
23+
$this->doRequest();
24+
}
25+
26+
protected function initUpgradeVersion()
27+
{
28+
$siteVersion = [
29+
"versionCode" => 10011,
30+
"versionName" => "",
31+
"upgradeErrCode" => "",
32+
"upgradeErrInfo" => "",
33+
];
34+
35+
$fileName = dirname(__FILE__) . "/../../version.php";
36+
$contents = var_export($siteVersion, true);
37+
file_put_contents($fileName, "<?php\n return {$contents};\n ");
38+
}
39+
40+
protected function getUpgradeVersion()
41+
{
42+
$fileName = dirname(__FILE__) . "/../../version.php";
43+
if (file_exists($fileName)) {
44+
$this->initUpgradeVersion();
45+
}
46+
$versionArrays = require($fileName);
47+
48+
return $versionArrays;
49+
}
50+
51+
/**
52+
* @param $versionCode
53+
* @param $versionName
54+
* @param $upgradeErrCode success/doing/error
55+
* @param $upgradeErrInfo
56+
*/
57+
protected function setUpgradeVersion($versionCode, $versionName, $upgradeErrCode, $upgradeErrInfo)
58+
{
59+
$siteVersion = [
60+
"versionCode" => $versionCode,
61+
"versionName" => $versionName,
62+
"upgradeErrCode" => $upgradeErrCode,
63+
"upgradeErrInfo" => $upgradeErrInfo,
64+
];
65+
66+
$fileName = dirname(__FILE__) . "/../../version.php";
67+
$contents = var_export($siteVersion, true);
68+
file_put_contents($fileName, "<?php\n return {$contents};\n ");
69+
}
70+
71+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* check current version need to upgrade
4+
* User: anguoyue
5+
* Date: 13/10/2018
6+
* Time: 3:54 PM
7+
*/
8+
9+
class Page_Version_CheckController extends Page_VersionController
10+
{
11+
12+
public function doRequest()
13+
{
14+
15+
$versionCode = $_POST["versionCode"];
16+
17+
$oldVersionCode = ZalyConfig::getConfig(ZalyConfig::$configSiteVersionCodeKey);
18+
19+
if (!is_numeric($oldVersionCode)) {
20+
$oldVersionCode = 10011;
21+
}
22+
23+
if (empty($versionCode)) {
24+
//给所有的版本
25+
$newVersionCode = ZalyConfig::getSampleConfig(ZalyConfig::$configSiteVersionCodeKey);
26+
$this->logger->error("==================", "oldVersion=" . $oldVersionCode . " to newVersion=" . $newVersionCode);
27+
28+
$versions = [];
29+
30+
foreach ($this->versions as $code => $name) {
31+
if ($oldVersionCode >= $code) {
32+
$versions[] = [$code => $name];
33+
}
34+
}
35+
36+
echo json_encode($versions);
37+
} else {
38+
//检测当前版本是否已经升级完
39+
$upgradeInfo = $this->getUpgradeVersion();
40+
41+
$this->logger->error("==================", var_export($upgradeInfo, true));
42+
43+
echo json_encode($upgradeInfo);
44+
}
45+
46+
return;
47+
}
48+
49+
50+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* check current version need to upgrade
4+
* User: anguoyue
5+
* Date: 13/10/2018
6+
* Time: 3:54 PM
7+
*/
8+
9+
class Page_Version_UpgradeController
10+
{
11+
12+
13+
private $versions = [
14+
10011 => "1.0.11",
15+
16+
10012 => "1.0.12"
17+
];
18+
19+
public function index()
20+
{
21+
22+
}
23+
24+
private function upgrade_10011_10012()
25+
{
26+
27+
}
28+
}

src/lib/Util/ZalyConfig.php

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,105 @@
88

99
class ZalyConfig
1010
{
11+
private static $verifySessionKey = "session_verify_";
12+
13+
public static $configSiteVersionNameKey = "siteVersionName";
14+
public static $configSiteVersionCodeKey = "siteVersionCode";
15+
1116
public static $config;
12-
private static $verifySessionKey="session_verify_";
17+
public static $sampleConfig;
1318

14-
public static function getConfigFile()
19+
//load config.php
20+
public static function loadConfigFile()
1521
{
16-
$fileName = dirname(__FILE__) ."/../../config.php";
17-
if(!file_exists($fileName)) {
18-
$fileName = dirname(__FILE__) ."/../../config.sample.php";
22+
$fileName = dirname(__FILE__) . "/../../config.php";
23+
if (!file_exists($fileName)) {
24+
$fileName = dirname(__FILE__) . "/../../config.sample.php";
1925
}
2026

2127
self::$config = require($fileName);
2228
}
2329

24-
public static function getConfig($key = "")
30+
// load sample.config.php
31+
public static function loadSampleConfigFile()
32+
{
33+
$sampleConfigFileName = dirname(__FILE__) . "/../../config.sample.php";
34+
35+
self::$sampleConfig = require($sampleConfigFileName);
36+
}
37+
38+
public static function getConfig($key = "")
2539
{
26-
self::getConfigFile();
27-
if(isset(self::$config[$key])) {
40+
self::loadConfigFile();
41+
if (isset(self::$config[$key])) {
2842
return self::$config[$key];
2943
}
3044
return false;
3145
}
46+
47+
public static function getSampleConfig($key = "")
48+
{
49+
50+
self::loadSampleConfigFile();
51+
52+
if (isset(self::$sampleConfig[$key])) {
53+
return self::$sampleConfig[$key];
54+
}
55+
56+
return false;
57+
}
58+
3259
public static function getAllConfig()
3360
{
34-
self::getConfigFile();
61+
self::loadConfigFile();
3562
return self::$config;
3663
}
3764

3865

3966
public static function getSessionVerifyUrl($pluginId)
4067
{
41-
self::getConfigFile();
42-
$key = self::$verifySessionKey.$pluginId;
68+
self::loadConfigFile();
69+
$key = self::$verifySessionKey . $pluginId;
4370
return self::$config[$key];
4471
}
4572

4673
public static function getApiIndexUrl()
4774
{
4875
$domain = self::getDomain();
4976
$pageIndexUrl = self::$config['apiPageIndex'];
50-
if(strpos($pageIndexUrl,"./") == 0) {
77+
if (strpos($pageIndexUrl, "./") == 0) {
5178
$pageIndexUrl = str_replace("./", "/", $pageIndexUrl);
5279
}
53-
return $domain.$pageIndexUrl;
80+
return $domain . $pageIndexUrl;
5481
}
5582

5683
public static function getApiPageJumpUrl()
5784
{
5885
$domain = self::getDomain();
5986
$pageJumpUrl = self::$config['apiPageJump'];
60-
if(strpos($pageJumpUrl,"./") == 0) {
87+
if (strpos($pageJumpUrl, "./") == 0) {
6188
$pageJumpUrl = str_replace("./", "/", $pageJumpUrl);
6289
}
63-
return $domain.$pageJumpUrl;
90+
return $domain . $pageJumpUrl;
6491
}
6592

6693
public static function getApiPageWidget()
6794
{
6895
$domain = self::getDomain();
6996
$pageWidgetUrl = self::$config['apiPageWidget'];
70-
if(strpos($pageWidgetUrl,"./") == 0) {
97+
if (strpos($pageWidgetUrl, "./") == 0) {
7198
$pageWidgetUrl = str_replace("./", "/", $pageWidgetUrl);
7299
}
73-
return $domain.$pageWidgetUrl;
100+
return $domain . $pageWidgetUrl;
74101
}
75102

76103
public static function getDomain()
77104
{
78-
self::getConfigFile();
105+
self::loadConfigFile();
79106

80-
$scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME']."://" : "http://";
81-
$domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "" ;
107+
$scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] . "://" : "http://";
108+
$domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "";
82109

83-
return $scheme.$domain;
110+
return $scheme . $domain;
84111
}
85112
}

src/public/js/im/zalyMsg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ function appendOrInsertRoomList(msg, isInsert, showNotification)
200200
}
201201

202202
var avatar = msg.roomType == GROUP_MSG ? msg.avatar : msg.userAvatar;
203+
203204
try{
204205
name = name.trim();
205-
}catch (error){
206+
}catch (error) {
206207

207208
}
208-
209209
if(name !=undefined && name.length>10) {
210210
name = name.substr(0, 8) + "...";
211211
}

0 commit comments

Comments
 (0)