function tapatalk_push_pm() { global $user_info, $db_prefix, $boardurl, $modSettings, $context, $ID_MEMBER; $sent_logs = !empty($context['send_log']) && !empty($context['send_log']['sent']) ? $context['send_log']['sent'] : array(); $sent_recipients = array(); foreach ($sent_logs as $sent_log) { if (preg_match('/ \'(.*?)\'/', $sent_log, $match)) { $sent_recipients[] = $match[1]; } } $sent_recipients = verify_smf_userids_from_names($sent_recipients); if (isset($sent_recipients) && !empty($sent_recipients) && isset($_REQUEST['subject'])) { $timestr = time(); $id_pm_req = db_query("\n SELECT p.id_pm\n FROM {$db_prefix}personal_messages p\n WHERE p.id_member_from = '{$ID_MEMBER}' ORDER BY id_pm DESC LIMIT 1", __FILE__, __LINE__); if ($id_pm_req && ($id_pm = mysql_fetch_assoc($id_pm_req))) { $sent_recipients_str = implode(',', $sent_recipients); $request = db_query("\n SELECT tu.uid\n FROM {$db_prefix}tapatalk_users tu\n WHERE tu.uid IN ({$sent_recipients_str})", __FILE__, __LINE__); $userids = ''; while ($row = mysql_fetch_assoc($request)) { if ($row['uid'] == $ID_MEMBER) { continue; } $userids = empty($userids) ? $row['uid'] : $userids . ',' . $row['uid']; $pushed_user_ids[] = $row['uid']; } $ttp_data = array('userid' => $userids, 'type' => 'pm', 'id' => $id_pm['id_pm'], 'title' => tt_push_clean($_REQUEST['subject']), 'author' => tt_push_clean($user_info['name']), 'authorid' => $ID_MEMBER, 'dateline' => time()); //store_as_alert($ttp_data); $ttp_post_data = array('url' => $boardurl, 'data' => base64_encode(serialize(array($ttp_data)))); //if(isset($modSettings['tp_push_key']) && !empty($modSettings['tp_push_key'])) //$ttp_post_data['key'] = $modSettings['tp_push_key']; tt_do_post_request($ttp_post_data); } } }
function tapatalk_push_quote_tag($post_id, $ttp_data, $newtopic = false, &$pushed_user_ids = array()) { global $user_info, $context, $smcFunc, $boardurl, $modSettings, $topic; if (($newtopic ? $topic : $context['current_topic']) && isset($_POST['message']) && $post_id && (function_exists('curl_init') || ini_get('allow_url_fopen'))) { $message = $_POST['message']; //@ push if (preg_match_all('/(?<=^@|\\s@)(#(.{1,50})#|\\S{1,50}(?=[,\\.;!\\?]|\\s|$))/U', $message, $tags)) { foreach ($tags[2] as $index => $tag) { if ($tag) { $tags[1][$index] = $tag; } } $tagged_usernames = array_unique($tags[1]); $tag_ids = verify_smf_userids_from_names($tagged_usernames); if (!empty($tag_ids)) { $ttp_data['type'] = 'tag'; $request = $smcFunc['db_query']('', ' SELECT tu.userid FROM {db_prefix}tapatalk_users tu WHERE tu.userid IN ({array_int:tag_ids})', array('tag_ids' => $tag_ids)); $userids = ''; while ($row = $smcFunc['db_fetch_assoc']($request)) { if ($row['userid'] == $user_info['id']) { continue; } if (in_array($row['userid'], $pushed_user_ids)) { continue; } if (!tapatalk_user_can_receive_push_topic($row['userid'], $ttp_data['subfid'], $ttp_data['id'])) { continue; } $pushed_user_ids[] = $row['userid']; $userids = empty($userids) ? $row['userid'] : $userids . ',' . $row['userid']; $ttp_data['userid'] = $row['userid']; store_as_alert($ttp_data); } $ttp_data['userid'] = $userids; if (!empty($userids)) { $return_status = tt_do_post_request($ttp_data); } } } //quote push $quotedUsers = array(); if (preg_match_all('/\\[quote author=(.*?) link=.*?\\]/si', $message, $quote_matches)) { $quotedUsers = $quote_matches[1]; $quote_ids = verify_smf_userids_from_names($quotedUsers); if (!empty($quote_ids)) { if (is_array($quote_ids)) { foreach ($quote_ids as $key => $quote_id) { $quote_ids[$key] = intval($quote_id); } } else { $quote_ids = intval($quote_ids); } $ttp_data['type'] = 'quote'; $request = $smcFunc['db_query']('', ' SELECT tu.userid FROM {db_prefix}tapatalk_users tu WHERE tu.userid IN ({' . (is_array($quote_ids) ? 'array_int' : 'int') . ':quoteids})', array('quoteids' => $quote_ids)); $userids = ''; while ($row = $smcFunc['db_fetch_assoc']($request)) { if ($row['userid'] == $user_info['id']) { continue; } if (in_array($row['userid'], $pushed_user_ids)) { continue; } if (!tapatalk_user_can_receive_push_topic($row['userid'], $ttp_data['subfid'], $ttp_data['id'])) { continue; } $userids = empty($userids) ? $row['userid'] : $userids . ',' . $row['userid']; $pushed_user_ids[] = $row['userid']; $ttp_data['userid'] = $row['userid']; store_as_alert($ttp_data); } $ttp_data['userid'] = $userids; if (!empty($userids)) { $return_status = tt_do_post_request($ttp_data); } } } } }