/**
 *
 * Gets new notifications
 *
 */
function getNotifications()
{
    global $response;
    global $userid;
    global $db;
    global $markup;
    if (empty($_SESSION['notifytime']) or !empty($_SESSION['notifytime']) and time() - $_SESSION['notifytime'] > 30) {
        $result = $db->execute("\n\t\t\t\tSELECT * \n\t\t\t\tFROM arrowchat_notifications \n\t\t\t\tWHERE to_id='" . $db->escape_string($userid) . "' \n\t\t\t\t\tAND (alert_read != '1' OR user_read != '1') \n\t\t\t\tORDER BY alert_time DESC\n\t\t\t");
        while ($row = $db->fetch_array($result)) {
            $alert_id = $row['id'];
            $author_id = $row['author_id'];
            $author_name = $row['author_name'];
            $type = $row['type'];
            $message_time = $row['alert_time'];
            $misc1 = $row['misc1'];
            $misc2 = $row['misc2'];
            $misc3 = $row['misc3'];
            $test = true;
            if (isset($_SESSION['notifications'])) {
                foreach ($_SESSION['notifications'] as $vals) {
                    if (in_array($alert_id, $vals)) {
                        $test = false;
                    }
                }
            }
            if ($test or !isset($_SESSION['notifications'])) {
                $markup = get_markup($author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3);
                $db->execute("\n\t\t\t\t\t\tUPDATE arrowchat_notifications\n\t\t\t\t\t\tSET alert_read = '1'\n\t\t\t\t\t\tWHERE id = '" . $alert_id . "'\n\t\t\t\t\t");
                $notifications[] = array('alert_id' => $alert_id, 'markup' => $markup, 'type' => $type);
            }
            $_SESSION['notifications'][] = array($alert_id);
        }
        $_SESSION['notifytime'] = time();
        if (!empty($notifications)) {
            $response['notifications'] = $notifications;
        }
    }
}
|| #################################################################### ||
*/
// ########################## INCLUDE BACK-END ###########################
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'bootstrap.php';
require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . AC_FOLDER_INCLUDES . DIRECTORY_SEPARATOR . 'init.php';
// ########################### INITILIZATION #############################
$response = array();
$notifications = array();
// ###################### START NOTIFICATION RECEIVE ######################
if (logged_in($userid)) {
    $result = $db->execute("\n\t\t\tSELECT * \n\t\t\tFROM arrowchat_notifications \n\t\t\tWHERE to_id = '" . $db->escape_string($userid) . "' \n\t\t\tORDER BY alert_time DESC\n\t\t\tLIMIT 10\n\t\t");
    while ($row = $db->fetch_array($result)) {
        $alert_id = $row['id'];
        $author_id = $row['author_id'];
        $author_name = $db->escape_string(strip_tags($row['author_name']));
        $type = $row['type'];
        $message_time = $row['alert_time'];
        $misc1 = $row['misc1'];
        $misc2 = $row['misc2'];
        $misc3 = $row['misc3'];
        $markup = get_markup($author_id, $author_name, $type, $message_time, $misc1, $misc2, $misc3);
        $notifications[] = array('alert_id' => $alert_id, 'markup' => $markup, 'type' => $type);
    }
    if (!empty($notifications)) {
        $response['notifications'] = $notifications;
    }
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($response);
close_session();
exit;
Example #3
0
function do_markup($type, $in)
{
    $obj =& get_markup($type);
    return $obj->doMarkup($in);
}
Example #4
0
function side_help($markup_body, $markup_excerpt)
{
    if ($markup_body != $markup_excerpt) {
        $body = get_markup($markup_body);
        $excerpt = get_markup($markup_excerpt);
        return $body->sidehelp() . $excerpt->sidehelp(gTxt('excerpt'));
    } else {
        $body = get_markup($markup_body);
        return $body->sidehelp();
    }
}