Exemplo n.º 1
0
function tt_send_push_data($user_id, $type, $id, $sub_id, $title, $author, $is_only_alert = false)
{
    global $config, $db, $user, $phpbb_root_path;
    if (!function_exists("tt_get_ignore_users")) {
        if (!defined("IN_MOBIQUO")) {
            define('IN_MOBIQUO', true);
        }
        if (!isset($config['tapatalkdir'])) {
            $config['tapatalkdir'] = 'mobiquo';
        }
        require_once $phpbb_root_path . $config['tapatalkdir'] . '/mobiquo_common.php';
    }
    $ignore_users = tt_get_ignore_users($user_id);
    if (in_array($user->data['user_id'], $ignore_users)) {
        return false;
    }
    $boardurl = generate_board_url();
    $ttp_data = array('userid' => $user_id, 'type' => $type, 'id' => $id, 'subid' => $sub_id, 'title' => tt_push_clean($title), 'author' => tt_push_clean($author), 'dateline' => time());
    if (push_data_table_exists()) {
        tt_insert_push_data($ttp_data);
    }
    if ($is_only_alert) {
        return;
    }
    $ttp_post_data = array('url' => $boardurl, 'data' => base64_encode(serialize(array($ttp_data))));
    if (!empty($config['tapatalk_push_key'])) {
        $ttp_post_data['key'] = $config['tapatalk_push_key'];
    }
    $return_status = tt_do_post_request($ttp_post_data);
    return $return_status;
}
Exemplo n.º 2
0
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);
        }
    }
}
Exemplo n.º 3
0
function tapatalk_push_subscirbe($thread_id, $pushed_user_ids = array())
{
    global $user_info, $smcFunc, $context, $boardurl, $topic;
    if (empty($thread_id)) {
        $thread_id = $topic;
    }
    $ttp_data = array('type' => 'newsub', 'id' => $topic, 'subfid' => $context['current_board'], 'author' => tt_push_clean($user_info['name']), 'authorid' => $user_info['id'], 'author_postcount' => $user_info['posts'], 'dateline' => time());
    if (!empty($ttp_data['subfid'])) {
        $request = $smcFunc['db_query']('', '
            SELECT b.name
            FROM {db_prefix}boards as b
            WHERE b.id_board = {int:subfid}', array('subfid' => intval($ttp_data['subfid'])));
        $row = $smcFunc['db_fetch_assoc']($request);
        if (!empty($row)) {
            $ttp_data['sub_forum_name'] = tt_push_clean($row['name']);
        }
    }
    // Get all the important topic info.
    $request = $smcFunc['db_query']('', '
        SELECT ms.subject
        FROM {db_prefix}topics AS t
            INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
        WHERE t.id_topic = {int:thread_id}
        LIMIT 1', array('thread_id' => $thread_id));
    $topicinfo = $smcFunc['db_fetch_assoc']($request);
    $ttp_data['title'] = isset($topicinfo['subject']) ? $topicinfo['subject'] : '';
    $request = $smcFunc['db_query']('', '
        SELECT ts.id_member_started as id_member
        FROM {db_prefix}topics ts
        LEFT JOIN {db_prefix}tapatalk_users tu ON (ts.id_member_started=tu.userid)
        WHERE ts.id_topic = {int:thread_id}', array('thread_id' => $thread_id));
    $userids = '';
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        if ($row['id_member'] == $user_info['id']) {
            continue;
        }
        if (in_array($row['id_member'], $pushed_user_ids)) {
            continue;
        }
        if (!tapatalk_user_can_receive_push_topic($row['id_member'], $ttp_data['subfid'], $ttp_data['id'])) {
            continue;
        }
        $userids = empty($userids) ? $row['id_member'] : $userids . ',' . $row['id_member'];
        $pushed_user_ids[] = $row['id_member'];
        $ttp_data['userid'] = $row['id_member'];
        store_as_alert($ttp_data);
    }
    $ttp_data['userid'] = $userids;
    if (!empty($userids)) {
        $return_status = tt_do_post_request($ttp_data);
    }
}
Exemplo n.º 4
0
function tapatalk_push_quote($data, $user_name_arr, $type = "quote")
{
    global $db, $user, $config, $table_prefix, $phpbb_root_path, $phpEx;
    $boardurl = generate_board_url();
    $return_status = false;
    if (!check_push()) {
        return false;
    }
    if (!empty($user_name_arr) && !empty($data) && (function_exists('curl_init') || ini_get('allow_url_fopen'))) {
        foreach ($user_name_arr as $username) {
            $user_id = get_user_id($username);
            if ($user_id == $user->data['user_id']) {
                continue;
            }
            if ($user_id == $data['poster_id']) {
                continue;
            }
            $sql = "SELECT userid FROM " . $table_prefix . "tapatalk_users WHERE userid = '" . $user_id . "' AND " . $type . " = 1";
            $result = $db->sql_query($sql);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!empty($row)) {
                $ttp_data = array('userid' => $row['userid'], 'type' => $type, 'id' => empty($data['topic_id']) ? $data['forum_id'] : $data['topic_id'], 'subid' => $data['post_id'], 'title' => tt_push_clean($data['topic_title']), 'author' => tt_push_clean($user->data['username']), 'dateline' => time());
                $ttp_post_data = array('url' => $boardurl, 'data' => base64_encode(serialize(array($ttp_data))));
                $return_status = tt_do_post_request($ttp_post_data);
            }
        }
    }
    return $return_status;
}
Exemplo n.º 5
0
<?php

error_reporting(E_ALL & ~E_NOTICE);
$phpbb_root_path = dirname(dirname(__FILE__)) . '/';
define('IN_PHPBB', 1);
$phpEx = 'php';
define('IN_MOBIQUO', 1);
require_once 'xmlrpcresp.' . $phpEx;
include $phpbb_root_path . 'common.php';
include 'push_hook.php';
$return_status = tt_do_post_request(array('test' => 1, 'key' => $config['tapatalk_push_key']), true);
if (empty($config['tapatalk_push_key'])) {
    $return_status = 'Please set Tapatalk API Key at forum option/setting';
}
$server_ip = tt_do_post_request(array('ip' => 1), true);
$board_url = generate_board_url();
$table_exist = push_table_exists();
if (isset($_GET['checkcode'])) {
    $string = file_get_contents($phpbb_root_path . 'includes/functions_posting.php');
    echo 'push code have been added in phpbb : ' . (strstr($string, 'tapatalk_push_reply($data);') ? 'yes' : 'no') . '<br/>';
    exit;
}
echo '<b>Tapatalk Push Notification Status Monitor</b><br/>';
echo '<br/>Push notification test: ' . ($return_status === '1' ? '<b>Success</b>' : 'Failed(' . $return_status . ')');
echo '<br/>Current server IP: ' . $server_ip;
echo '<br/>Current forum url: ' . $board_url;
echo '<br/>Tapatalk user table existence: ' . ($table_exist ? 'Yes' : 'No');
echo '<br/><br/><a href="http://tapatalk.com/api/api.php" target="_blank">Tapatalk API for Universal Forum Access</a> | <a href="http://tapatalk.com/mobile.php" target="_blank">Tapatalk Mobile Applications</a><br>
    For more details, please visit <a href="http://tapatalk.com" target="_blank">http://tapatalk.com</a>';
Exemplo n.º 6
0
function tapatalk_push_pm()
{
    global $mybb, $db, $pm, $pminfo;
    if (!($pminfo['messagesent'] && $db->table_exists('tapatalk_users'))) {
        return false;
    }
    $query = $db->query("\r\n        SELECT p.pmid, p.toid ,tu.pm\r\n        FROM " . TABLE_PREFIX . "privatemessages p\r\n        LEFT JOIN " . TABLE_PREFIX . "tapatalk_users tu ON (p.toid=tu.userid)\r\n        WHERE p.fromid = '{$mybb->user['uid']}' and p.dateline = " . TIME_NOW . " AND p.folder = 1\r\n    ");
    $ttp_push_data = array();
    while ($user = $db->fetch_array($query)) {
        if ($user['toid'] == $mybb->user['uid']) {
            continue;
        }
        if (tt_check_ignored($user['toid'])) {
            continue;
        }
        $ttp_data[] = array('userid' => $user['toid'], 'type' => 'pm', 'id' => $user['pmid'], 'title' => tt_push_clean($pm['subject']), 'author' => tt_push_clean($mybb->user['username']), 'dateline' => TIME_NOW);
        tt_insert_push_data($ttp_data[count($ttp_data) - 1]);
        if ($user['pm'] == 1) {
            $ttp_push_data[] = $ttp_data[count($ttp_data) - 1];
        }
    }
    if (!empty($ttp_push_data)) {
        $ttp_post_data = array('url' => $mybb->settings['bburl'], 'data' => base64_encode(serialize($ttp_push_data)));
        $return_status = tt_do_post_request($ttp_post_data);
    }
}
Exemplo n.º 7
0
<?php

define('IN_MYBB', 1);
require_once '../global.php';
error_reporting(E_ALL & ~E_NOTICE);
$return_status = tt_do_post_request(array('test' => 1, 'key' => $mybb->settings['tapatalk_push_key']), true);
if (empty($mybb->settings['tapatalk_push_key'])) {
    $return_status = 'Please set Tapatalk API Key at forum option/setting';
}
$return_ip = tt_do_post_request(array('ip' => 1), true);
$board_url = $mybb->settings['bburl'];
$option_status = 'On';
echo '<b>Tapatalk Push Notification Status Monitor</b><br/>';
echo '<br/>Push notification test: ' . ($return_status == '1' ? '<b>Success</b>' : '<font color="red">Failed(' . $return_status . ')</font>');
echo '<br/>Current server IP: ' . $return_ip;
echo '<br/>Current forum url: ' . $board_url;
echo '<br/><br/><a href="http://tapatalk.com/api/api.php" target="_blank">Tapatalk API for Universal Forum Access</a> | <a href="http://tapatalk.com/mobile.php" target="_blank">Tapatalk Mobile Applications</a><br>
    For more details, please visit <a href="http://tapatalk.com" target="_blank">http://tapatalk.com</a>';