Вы не зашли.
Главная » PHP » Браузерное расширение для форума
#21. TLENS Off (14)
Moderator
2011.06.27 17:05
Корочь все работает куку отдает.
Делай вместе с постом.
private_status = 0/1;
Да и хватит
#22. TLENS Off (14)
Moderator
2011.06.27 19:07
Бета версия что на данный момент.
Вложения
dir.zip 98kb [загрузок: 827]
Отредактировано TLENS (2011.06.28 16:04)
#23. TLENS Off (14)
Moderator
2011.07.12 18:06
Надо исправить dblclick не удобно так как сразу попа начинает сворачивается и иногда второй раз не успеваю сделать клик.
Какие идеи?
Использовать ролик?
#24. TLENS Off (14)
Moderator
2011.07.16 04:04
Паша ну как там ты делаешь апи привата?
#25. Gemorroj Off (107)
Administrator
2011.07.18 15:03
да, сейчас займусь... сорь за мудозвонство, совсем что-то плохой стал)
#26. Gemorroj Off (107)
Administrator
2011.07.18 15:03
Есть проблемка с приватными сообщениями. у нас сверяется последнее сообщение по его ID. Но у приватных сообщений и постов на форуме свои идентификаторы, которые в теории могут пересекаться.
Нужно для приватных сообщений делать отдельно запросы на сервер, либо в ответе на наши стандартные запросы посылать отдельно информацию по приватным и отдельно по постам на форуме.
Предлагаю остановиться на 2 варианте.
Добавлено спустя   2 минуты  1 секунду:
Вобщем, нужно изменить API. От расширение должно передаваться 2 идентификатора - ID приватного сообщения и ID поста на форуме.
Ответ будет содержать 2 массива с данными по последнему приватному сообщению и данными по последнему посту на форуме.
Добавлено спустя   2 минуты  50 секунд:
Пока подожду что ты скажешь.)
#27. TLENS Off (14)
Moderator
2011.07.19 06:06
Слушай я понял но не могу сосредоточится чтобы обмозговать как все будет реализовано в расширении, и как я хотел тогда.
Я вчера ножки обмывал сейчас не соберу себя до кучи.
Кстати пока не забыл надо нотификатион открывать вместе с search в адресе и уже внутри регулировать location.search и взать какой id светить. А то когда например видео смотришь через флеш, то окна блокируются, и как только закрыл видео появляется куча уведомлений с последним сообщением.
#28. Gemorroj Off (107)
Administrator
2011.07.20 10:10
TLENS, так какой вариант делаем?
#29. TLENS Off (14)
Moderator
2011.07.20 12:12
В общем да делай еще наверное два правильных апи скриптами подстроимся под них.
Отредактировано TLENS (2011.07.20 12:12)
#30. Gemorroj Off (107)
Administrator
2011.07.22 16:04
Код:
<?php
} else if (isset($_GET['informer'])) {
    include PUN_ROOT 'include/informer/Informer.inc.php';
    header('Content-Type: application/json; charset=UTF-8');
 
    try {
        $obj = new Informer($db$pun_user$lang_common$pun_config);
 
        if (isset($_GET['getMessage']) && isset($_GET['getPrivatMessage'])) {
            echo json_encode(array('status' => true'forum' => $obj->getMessage($_GET['getMessage']), 'privat' => $obj->getPrivateMessage($_GET['getPrivatMessage'])));
        } else if (isset($_GET['getPrivatMessage'])) {
            echo json_encode(array('status' => true'privat' => $obj->getPrivateMessage($_GET['getPrivatMessage'])));
        } else if (isset($_GET['getMessage'])) {
            echo json_encode(array('status' => true'forum' => $obj->getMessage($_GET['getMessage'])));
        } else if (isset($_GET['getPrivatMessages'])) {
            echo json_encode(array('status' => true'privat' => $obj->getPrivateMessages($_GET['getPrivatMessages'])));
        } else if (isset($_GET['getConfig'])) {
            echo json_encode(array('status' => true'config' => $obj->getConfig()));
        } else {
            echo json_encode(array('status' => true'forum' => $obj->getForums()));
        }
    } catch (Exception $e) {
        echo json_encode(array('status' => false'forum' => $e->getMessage()));
    }
}
Код:
<?php
 
class Informer
{
    private $_db;
    private $_pun_user;
    private $_lang;
    private $_pun_config;
 
 
    /**
     * Constructor
     * 
     * @param resource $db
     * @param array $pun_user
     * @param array $lang
     * @param array $pun_config
     */
    public function __construct ($db$pun_user$lang$pun_config)
    {
        $this->_db $db;
        $this->_pun_user $pun_user;
        $this->_lang $lang;
        $this->_pun_config $pun_config;
    }
 
 
    /**
     * getConfig
     * 
     * @return array
     * @throws Exception
     */
    public function getConfig ()
    {
        return array(
            'timezone' => $this->_pun_user['timezone'],
            'username' => $this->_pun_user['username'],
            'is_guest' => $this->_pun_user['is_guest']
        );
    }
 
 
    /**
     * getForums
     * 
     * @return array
     * @throws Exception
     */
    public function getForums ()
    {
        if (!$this->_pun_user['g_read_board']) {
            throw new Exception ($this->_lang['No view']);
        }
 
        $r $this->_db->query('
            SELECT f.id AS fid, f.last_post, f.last_post_id, f.last_poster, t.subject
 
            FROM ' $this->_db->prefix 'categories AS c
            INNER JOIN ' $this->_db->prefix 'forums AS f ON c.id=f.cat_id
            LEFT JOIN ' $this->_db->prefix 'topics AS t ON f.last_post_id=t.last_post_id
            LEFT JOIN ' $this->_db->prefix 'forum_perms AS fp ON (
                fp.forum_id=f.id
                AND fp.group_id=' $this->_pun_user['g_id'] . '
                AND (fp.read_forum IS NULL OR fp.read_forum=1)
            )
 
            WHERE fp.read_forum IS NULL OR fp.read_forum=1
 
            ORDER BY NULL
        'false);
        if (!$r) {
            throw new Exception ($this->_db->error());
        }
        if (!$this->_db->num_rows($r)) {
            throw new Exception ($this->_lang['Bad request']);
        }
 
        $data = array();
        while ($forum $this->_db->fetch_assoc($r)) {
            $data[$forum['fid']] = array(
                'last_post_id' => $forum['last_post_id'],
                'subject' => $forum['subject'],
                'last_post_time' => $forum['last_post'],
                'last_poster' => $forum['last_poster']
            );
        }
        return $data;
    }
 
 
    /**
     * getMessage
     * 
     * @param int $id
     * @return array
     * @throws Exception
     */
    public function getMessage ($id)
    {
        if (!$this->_pun_user['g_read_board']) {
            throw new Exception ($this->_lang['No view']);
        }
        if (!$id || $id || !is_numeric($id)) {
            throw new Exception ($this->_lang['Bad request']);
        }
 
        $r $this->_db->query('
            SELECT p.poster, p.message, p.hide_smilies, p.posted
            FROM ' $this->_db->prefix 'posts AS p
            INNER JOIN ' $this->_db->prefix 'topics AS t ON t.id = p.topic_id
            LEFT JOIN ' $this->_db->prefix 'forum_perms AS fp ON (
                fp.forum_id = t.forum_id
                AND fp.group_id = ' $this->_pun_user['g_id'] . '
                AND (fp.read_forum IS NULL OR fp.read_forum = 1)
            )
            WHERE p.id = ' $id
        false);
 
        if (!$r) {
            throw new Exception ($this->_db->error());
        }
        if (!$this->_db->num_rows($r)) {
            throw new Exception ($this->_lang['Bad request']);
        }
 
        $data $this->_db->fetch_assoc($r);
 
        return array (
            'message' => $this->_parseMessage($data['message'], $data['hide_smilies']),
            'poster' => $data['poster'],
            'posted' => $data['posted']
        );
    }
 
 
    /**
     * getPrivateMessage
     * 
     * @param int $id
     * @return array
     * @throws Exception
     */
    public function getPrivateMessage ($id)
    {
        if ($this->_pun_user['is_guest'] || !$this->_pun_user['g_pm'] || !$this->_pun_user['messages_enable'] || !$this->_pun_config['o_pms_enabled']) {
            throw new Exception ($this->_lang['No view']);
        }
        if (!$id || $id || !is_numeric($id)) {
            throw new Exception ($this->_lang['Bad request']);
        }
 
        $r $this->_db->query('
            SELECT m.subject, m.message, m.smileys, m.posted, m.sender
            FROM ' $this->_db->prefix 'messages AS m
            WHERE m.owner = ' $this->_pun_user['id'] . '
            AND m.id = ' $id
        false);
 
        if (!$r) {
            throw new Exception ($this->_db->error());
        }
        if (!$this->_db->num_rows($r)) {
            throw new Exception ($this->_lang['Bad request']);
        }
 
        $data $this->_db->fetch_assoc($r);
 
        return array (
            'subject' => $data['subject'],
            'message' => $this->_parseMessage($data['message'], $data['smileys']),
            'poster' => $data['sender'],
            'posted' => $data['posted']
        );
    }
 
 
 
    /**
     * getPrivateMessages
     * 
     * @param int $limit
     * @return array
     * @throws Exception
     */
    public function getPrivateMessages ($limit)
    {
        if ($this->_pun_user['is_guest'] || !$this->_pun_user['g_pm'] || !$this->_pun_user['messages_enable'] || !$this->_pun_config['o_pms_enabled']) {
            throw new Exception ($this->_lang['No view']);
        }
        if (!$limit || $limit || !is_numeric($limit)) {
            throw new Exception ($this->_lang['Bad request']);
        }
 
        $r $this->_db->query('
            SELECT m.id, m.subject, m.message, m.smileys, m.posted, m.sender
            FROM ' $this->_db->prefix 'messages AS m
            WHERE m.owner = ' $this->_pun_user['id'] . '
            ORDER BY m.id DESC
            LIMIT ' $limit
        false);
 
        if (!$r) {
            throw new Exception ($this->_db->error());
        }
        if (!$this->_db->num_rows($r)) {
            return array();
        }
 
 
        $out = array();
        while ($data $this->_db->fetch_assoc($r)) {
            $out[$data['id']] = array (
                'subject' => $data['subject'],
                'message' => $this->_parseMessage($data['message'], $data['smileys']),
                'poster' => $data['sender'],
                'posted' => $data['posted']
            );
        }
        return $out;
    }
 
 
    /**
     * _parseMessage
     * 
     * @param string $message
     * @param bool $hide_smilies
     * @return string
     */
    private function _parseMessage ($message$hide_smilies false)
    {
        require_once __DIR__ '/../parser.php';
        return parse_message($message$hide_smilies);
    }
}
?>
из кода понятно что требуется?)
Отредактировано Gemorroj (2011.09.01 13:01)
Страниц: 1 2 3 4 518 Все
Главная
WEB
PunBB Mod v0.6.2
0.020 s