Example #1
0
<?php

include "kartouche/config.php";
include "includes/fns.php";
checklg($lg);
checkval($total);
checktext($db_table);
checkview($view);
if (isset($pointer)) {
    checkval($pointer);
}
include "includes/trans.php";
include "includes/header.php";
$address = $REMOTE_ADDR;
if (!isset($pointer)) {
    $pointer = 1;
}
$shown = $pointer;
$pointer = $pointer - 1;
dbconnect();
if ($view == "empty") {
    $sql = "select * from {$db_table} where msgstr='' limit {$pointer}," . RECS_SHOWN;
} else {
    $sql = "select * from {$db_table} limit {$pointer}," . RECS_SHOWN;
}
$result = mysql_query($sql) or die($kerr1);
$query = "select count(*) as count from {$db_table}";
$q_result = mysql_query($query);
$q_row = mysql_fetch_object($q_result);
$numrows = $q_row->count;
$next = $shown + RECS_SHOWN;
        } else {
            $count = intval(count($row)) / 2;
            $readstring = [];
            for ($i = 3; $i < $count; $i++) {
                //$name = array_keys($row)[$i * 2];
                $value = $row[$i];
                if ($value == null || $value == "") {
                } else {
                    $add = unserialize($value);
                    if (is_array($add)) {
                        if (isset($add['isread'])) {
                            $notificationarray[] = checktext($connection, $connectinfo, $add[0]);
                        } else {
                            //Must be collection of items
                            for ($t = 0; $t < count($add); $t++) {
                                $notificationarray[] = checktext($connection, $connectinfo, $add[$t]);
                            }
                        }
                    }
                }
            }
        }
        usort($notificationarray, "sortbydate");
        array_unshift($notificationarray, ["numberunseen" => $row["numberunseen"]]);
        echo json_encode($notificationarray);
    } else {
        echo "Error - authorization mismatch";
    }
} else {
    echo 'Error - invalid supplied post data (not enough info?)';
}