Skip to content

Commit

Permalink
phpBB tapatalk plugin version 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Naguissa committed Aug 21, 2018
1 parent b2d0271 commit 5fa38ee
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 110 deletions.
2 changes: 1 addition & 1 deletion custom/customConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function mbqInitGetConfigValues($isTTServerCall = false)
{
MbqMain::$customConfig['base']['is_open'] = MbqBaseFdt::getFdt('MbqFdtConfig.base.is_open.range.yes');
}
MbqMain::$customConfig['base']['version'] = 'pb31_2.1.0';
MbqMain::$customConfig['base']['version'] = 'pb31_2.1.3';

MbqMain::$customConfig['base']['api_level'] = 4;
MbqMain::$customConfig['base']['json_support'] = MbqBaseFdt::getFdt('MbqFdtConfig.base.json_support.range.yes');
Expand Down
2 changes: 1 addition & 1 deletion mbqClass/lib/read/MbqRdEtForum.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function parseForumTree($parentForum, $forums)
public function initOMbqEtForum($var, $mbqOpt)
{
if ($mbqOpt['case'] == 'byForumId') {
$forumId = $var;
$forumId = intval($var);
if(MbqMain::$Cache->Exists('MbqEtForum',$forumId))
{
return MbqMain::$Cache->Get('MbqEtForum',$forumId);
Expand Down
7 changes: 3 additions & 4 deletions mbqClass/lib/read/MbqRdEtForumPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,11 @@ public function initOMbqEtForumPost($var, $mbqOpt) {
//$oMbqEtForumPost->allowSmilies->setOriValue($row['bind']['enable_smilies'] ? true : false);
//$oMbqEtForumPost->position->setOriValue($row['prev_posts'] + 1);
$oMbqEtForumPost->canThank->setOriValue(isset($row['bind']['can_thank']) && $row['bind']['can_thank']);
$oMbqEtForumPost->canUnthank->setOriValue(isset($row['bind']['can_unthank']) && $row['bind']['can_unthank']);
$oMbqEtForumPost->thankCount->setOriValue($row['bind']['post_author_id']);
$oMbqEtForumPost->canUnthank->setOriValue(isset($row['bind']['can_unthank']) && $row['bind']['can_unthank']);
//$oMbqEtForumPost->canLike->setOriValue($var['post_author_id']);
//$oMbqEtForumPost->isLiked->setOriValue($var['post_author_id']);

//$oMbqEtForumPost->thankCount->setOriValue($row['bind']['post_author_id']);
$oMbqEtForumPost->isThanked->setOriValue(isset($row['bind']['thanks_info']));
//$oMbqEtForumPost->likeCount->setOriValue($var['post_author_id']);

$oMbqEtForumPost->showReason->setOriValue($auth->acl_get('m_edit', $forum_id));
$oMbqEtForumPost->editReason->setOriValue(isset($row['bind']['post_edit_reason']) ? $row['bind']['post_edit_reason'] : '');
Expand Down
3 changes: 3 additions & 0 deletions mbqClass/lib/read/MbqRdEtForumTopic.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,11 @@ public function getObjsMbqEtForumTopic($var, $mbqOpt) {
$topic_ids = $var;
if(is_array($topic_ids))
{
$topic_ids = array_map('intval', $topic_ids);
$topic_ids = implode(',',$topic_ids);
}
else
$topic_ids = intval($topic_ids);
$sql = 'SELECT t.*, u.user_avatar, u.user_avatar_type,bm.topic_id as bookmarked
FROM ' . TOPICS_TABLE . ' t
LEFT JOIN ' . USERS_TABLE . ' u ON (t.topic_poster = u.user_id)
Expand Down
82 changes: 54 additions & 28 deletions mbqClass/lib/read/MbqRdEtUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,9 @@ public function getObjsMbqEtUser($var, $mbqOpt) {
if ($mbqOpt['case'] == 'byUserIds') {
$result = array();
$user_ids = implode(',',$var);
$sql = " SELECT u.*,
MAX(s.session_time) as session_time, MIN(s.session_viewonline) AS session_viewonline, session_start, session_page, session_forum_id
$sql = " SELECT u.*
FROM " . USERS_TABLE . " AS u
LEFT JOIN " . SESSIONS_TABLE . " AS s ON u.user_id = s.session_user_id
WHERE u.user_id in ($user_ids)
GROUP BY u.user_id
";
$sqlresult = $db->sql_query($sql);
$userRows = array();
Expand All @@ -195,6 +192,21 @@ public function getObjsMbqEtUser($var, $mbqOpt) {
$userRows[] = $row;
}
$db->sql_freeresult($sqlresult);
if ($config['load_onlinetrack'] && sizeof($user_ids))
{
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
FROM ' . SESSIONS_TABLE . '
WHERE ' . $db->sql_in_set('session_user_id', $user_ids) . '
GROUP BY session_user_id';
$result = $db->sql_query($sql);

$update_time = $config['load_online_time'] * 60;
while ($row = $db->sql_fetchrow($result))
{
MbqMain::$Cache->Set('MbqEtUserOnline', $row['session_user_id'], (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false);
}
$db->sql_freeresult($result);
}
return $this->getObjsMbqEtUser($userRows, array('case'=>'byUserRows'));
} elseif ($mbqOpt['case'] == 'byUserRows') {
$userRows = $var;
Expand All @@ -210,7 +222,7 @@ public function getObjsMbqEtUser($var, $mbqOpt) {
$sql = 'SELECT s.session_user_id, s.session_ip, s.session_viewonline
FROM ' . SESSIONS_TABLE . ' s
WHERE s.session_time >= ' . $onlinetime .
' AND s.session_user_id <> ' . ANONYMOUS . ' GROUP BY s.session_user_id ';
' AND s.session_user_id <> ' . ANONYMOUS . ' GROUP BY s.session_user_id, s.session_ip, s.session_viewonline ';
$result = $db->sql_query_limit($sql, $oMbqDataPage->numPerPage, $oMbqDataPage->startNum);
$oMbqDataPage->datas = array();
while($member = $db->sql_fetchrow($result))
Expand Down Expand Up @@ -325,12 +337,12 @@ protected function _getObjsMbqEtUserGetInactiveUsers($var, $mbqOpt)
if (!function_exists('view_inactive_users')) {
require_once($phpbb_root_path . '/includes/functions_admin.' . $phpEx);
}
$oMbqDataPage->datas = [];
$oMbqDataPage->datas = array();
$sql_where = '';
$sql_sort = 'user_inactive_time DESC';
$per_page = $oMbqDataPage->numPerPage;
$start = $oMbqDataPage->startNum;
$inactiveUsers = [];
$inactiveUsers = array();
$inactive_count = 0;
$start = view_inactive_users($inactiveUsers, $inactive_count, $per_page, $start, $sql_where, $sql_sort, true);

Expand Down Expand Up @@ -387,23 +399,23 @@ protected function _getObjsMbqEtUserGetMemberList($var, $mbqOpt)
}
// Count the users
$sql = 'SELECT COUNT(u.user_id) AS total_users
FROM ' . USERS_TABLE . " u
FROM ' . USERS_TABLE . " u
WHERE " . $db->sql_in_set('u.user_type', $user_types) . " $sqlWhere ";
$result = $db->sql_query($sql);
$total_users = (int) $db->sql_fetchfield('total_users');
$db->sql_freeresult($result);

$oMbqDataPage->datas = [];
$oMbqDataPage->datas = array();
if ($total_users) {
// Select
$sql = 'SELECT IFNULL(s.session_time,u.user_lastvisit) as last_active,!ISNULL(s.session_time) as is_online, u.*, s.session_page, s.session_forum_id
FROM ' . USERS_TABLE . ' u
LEFT JOIN (SELECT session_user_id, MAX(session_time) AS session_time,session_page,session_forum_id
FROM ' . SESSIONS_TABLE . '
WHERE session_time >= ' . $isOnlineValidTime . '
GROUP BY session_user_id
GROUP BY session_user_id, session_page, session_forum_id
) s on s.session_user_id = user_id
WHERE ' . $db->sql_in_set('u.user_type', $user_types) . ' ' . $sqlWhere . '
WHERE ' . $db->sql_in_set('u.user_type', $user_types) . ' ' . $sqlWhere . '
ORDER BY last_active DESC, u.user_lastvisit DESC';

$result = $db->sql_query_limit($sql, $oMbqDataPage->numPerPage, $oMbqDataPage->startNum);
Expand Down Expand Up @@ -608,7 +620,7 @@ public function initOMbqEtUser($var, $mbqOpt) {
$email = strtolower($var);
$sql = "SELECT u.user_id
FROM " . USERS_TABLE . " u
WHERE LOWER(u.user_email) = '$email'";
WHERE LOWER(u.user_email) = '" . $db->sql_escape($email) . "'";
$result = $db->sql_query($sql);
$member = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
Expand All @@ -619,19 +631,32 @@ public function initOMbqEtUser($var, $mbqOpt) {
return null;
}
else if ($mbqOpt['case'] == 'byUserId') {
$user_id = $var;
$user_id = intval($var);
if(MbqMain::$Cache->Exists('MbqEtUser',$user_id))
{
return MbqMain::$Cache->Get('MbqEtUser',$user_id);
}
$sql = " SELECT u.*, MAX(s.session_time) as session_time, MIN(s.session_viewonline) AS session_viewonline, session_start, session_page, session_forum_id
FROM " . USERS_TABLE . " AS u
LEFT JOIN " . SESSIONS_TABLE . " AS s ON u.user_id = s.session_user_id
WHERE u.user_id = '$user_id'
";

$sql = "SELECT * FROM " . USERS_TABLE . " AS u WHERE u.user_id = '$user_id'";
$result = $db->sql_query($sql);
$member = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if ($config['load_onlinetrack'])
{
$sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
FROM ' . SESSIONS_TABLE . '
WHERE ' . $db->sql_in_set('session_user_id', $user_id) . '
GROUP BY session_user_id';
$result = $db->sql_query($sql);

$update_time = $config['load_online_time'] * 60;
while ($row = $db->sql_fetchrow($result))
{
MbqMain::$Cache->Set('MbqEtUserOnline', $row['session_user_id'], (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false);
}
$db->sql_freeresult($result);
}
return $this->initOMbqEtUser($member, array('case'=>'user_row'));
}
}
Expand Down Expand Up @@ -1033,21 +1058,21 @@ private function getExtraCustomFields($var){
global $user, $auth;

$birthday = $this->processUserBirthday($var['user_birthday']);

$extra = array();
if ($birthday)
{
$extra[] = [
$extra[] = array(
'name' => 'Birthday',
'value' => $birthday,
];
);
}

if ($auth->acl_getf_global('m_') || $auth->acl_get('m_warn'))
{
$extra[] = [
$extra[] = array(
'name' => $user->lang['WARNINGS'],
'value' => $var['user_warnings'],
];
);
}

return $extra;
Expand All @@ -1064,16 +1089,17 @@ private function processUserBirthday($user_birthday)

if ($user_birthday)
{
$user_birthday = preg_replace('/\s/s', '', $user_birthday);
$user_birthday = explode('-', $user_birthday);

if (!empty(trim($user_birthday[0])) && !empty(trim($user_birthday[1])))
if (isset($user_birthday[0]) && isset($user_birthday[1]) && $user_birthday[0] && $user_birthday[1])
{
$dateObj = \DateTime::createFromFormat('!m', trim($user_birthday[1]));
$dateObj = \DateTime::createFromFormat('!m', $user_birthday[1]);
$birthdayMonth = $dateObj->format('M');
$birthdayDay = trim($user_birthday[0]);
if (!empty(trim($user_birthday[2])))
$birthdayDay = $user_birthday[0];
if (isset($user_birthday[2]) && $user_birthday[2])
{
$birthday = $birthdayDay . ' ' . $birthdayMonth . ' ' . trim($user_birthday[2]);
$birthday = $birthdayDay . ' ' . $birthdayMonth . ' ' . $user_birthday[2];
}
else
{
Expand Down
5 changes: 4 additions & 1 deletion mbqClass/lib/write/MbqWrEtUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ function tt_copy_avatar($uid,$avatar_url)
$avatar['width'] = $config['avatar_max_width'];
$avatar['height'] = $config['avatar_max_height'];
$error = array();
$upload_response = avatar_remote($avatar, $error);
if (function_exists('avatar_remote'))
{
$upload_response = avatar_remote($avatar, $error);
}

if(empty($error))
{
Expand Down
5 changes: 4 additions & 1 deletion mbqFrame/baseLib/baseRead/MbqBaseRdEtForumTopic.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ public function returnJsonApiDataForumTopic($oMbqEtForumTopic) {
public function returnApiArrDataForumTopic($objsMbqEtForumTopic) {
$data = array();
foreach ($objsMbqEtForumTopic as $oMbqEtForumTopic) {
$data[] = $this->returnApiDataForumTopic($oMbqEtForumTopic);
if ($oMbqEtForumTopic)
{
$data[] = $this->returnApiDataForumTopic($oMbqEtForumTopic);
}
}
return $data;
}
Expand Down
14 changes: 1 addition & 13 deletions mbqFrame/basePush/TapatalkBasePush.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,7 @@ public function do_push_request($data, $pushTest = false)

return true;
}

public static function getClientIp()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}


public static function getClienUserAgent()
{
$useragent = $_SERVER['HTTP_USER_AGENT'];
Expand Down
7 changes: 0 additions & 7 deletions mbqFrame/mbqBaseAction/MbqBaseActGetBoardStat.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ public function __construct() {
function getInput()
{
$in = new stdClass();
if(MbqMain::isJsonProtocol())
{

}
else
{
}
return $in;
}

Expand Down
16 changes: 8 additions & 8 deletions mbqFrame/mbqBaseAction/MbqBaseActGetThread.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* get_thread action
*/
Abstract Class MbqBaseActGetThread extends MbqBaseAct {

public function __construct() {
parent::__construct();
}

function getInput()
{
$in = new stdClass();
Expand All @@ -32,15 +32,15 @@ function getInput()
$in->oMbqDataPage = $oMbqDataPage;
return $in;
}

/**
* action implement
*/
protected function actionImplement($in) {
if (!MbqMain::$oMbqConfig->moduleIsEnable('forum')) {
MbqError::alert('', "Not support module forum!", '', MBQ_ERR_NOT_SUPPORT);
}

$oMbqRdEtForumTopic = MbqMain::$oClk->newObj('MbqRdEtForumTopic');
if ($oMbqEtForumTopic = $oMbqRdEtForumTopic->initOMbqEtForumTopic($in->topicId, array('case' => 'byTopicId'))) {
$oMbqAclEtForumTopic = MbqMain::$oClk->newObj('MbqAclEtForumTopic');
Expand Down Expand Up @@ -70,16 +70,16 @@ protected function actionImplement($in) {
$oMbqWrEtForumTopic->resetForumTopicSubscription($oMbqEtForumTopic);
} else {
if (MbqMain::hasLogin()) {
$reason = ['reason' => MBQ_ERR_NOT_PERMISSION];
$reason = array('reason' => MBQ_ERR_NOT_PERMISSION);
}else{
$reason = ['reason' => MBQ_ERR_LOGIN_REQUIRED];
$reason = array('reason' => MBQ_ERR_LOGIN_REQUIRED);
}
MbqError::alert('', $aclResult, $reason, MBQ_ERR_APP);
}
} else {
$reason = ['reason' => MBQ_ERR_DATA_NOT_FOUND];
$reason = array('reason' => MBQ_ERR_DATA_NOT_FOUND);
MbqError::alert('', "This topic does not exist or you do not have permission to access it!", $reason, MBQ_ERR_APP);
}
}

}
16 changes: 8 additions & 8 deletions mbqFrame/mbqBaseAction/MbqBaseActGetThreadByPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* get_thread_by_post action
*/
Abstract Class MbqBaseActGetThreadByPost extends MbqBaseAct {

public function __construct() {
parent::__construct();
}

function getInput()
{
$in = new stdClass();
Expand All @@ -28,15 +28,15 @@ function getInput()
}
return $in;
}

/**
* action implement
*/
protected function actionImplement($in) {
if (!MbqMain::$oMbqConfig->moduleIsEnable('forum')) {
MbqError::alert('', "Not support module forum!", '', MBQ_ERR_NOT_SUPPORT);
}

$oMbqRdEtForumPost = MbqMain::$oClk->newObj('MbqRdEtForumPost');
if ($oMbqEtForumPost = $oMbqRdEtForumPost->initOMbqEtForumPost($in->postId, array('case' => 'byPostId', 'perPage' => $in->postsPerRequest, 'requirePosition'=>true))) {
$topicId = $oMbqEtForumPost->topicId->oriValue;
Expand Down Expand Up @@ -74,16 +74,16 @@ protected function actionImplement($in) {
$oMbqWrEtForumTopic->resetForumTopicSubscription($oMbqEtForumTopic);
} else {
if (MbqMain::hasLogin()) {
$reason = ['reason' => MBQ_ERR_NOT_PERMISSION];
$reason = array('reason' => MBQ_ERR_NOT_PERMISSION);
}else{
$reason = ['reason' => MBQ_ERR_LOGIN_REQUIRED];
$reason = array('reason' => MBQ_ERR_LOGIN_REQUIRED);
}
MbqError::alert('', $aclResult, $reason, MBQ_ERR_APP);
}
} else {
$reason = ['reason' => MBQ_ERR_DATA_NOT_FOUND];
$reason = array('reason' => MBQ_ERR_DATA_NOT_FOUND);
MbqError::alert('', "This topic does not exist or you do not have permission to access it!", $reason, MBQ_ERR_APP);
}
}

}
Loading

0 comments on commit 5fa38ee

Please sign in to comment.