*
 *    "PCPIN Chat 6" is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
if (!is_object($session)) {
    die('Access denied');
}
_pcpin_loadClass('banner');
$banner = new PCPIN_Banner($session);
if (empty($banner_id)) {
    $banner_data = $banner->getRandomBanner($load_banner);
} elseif ($banner->_db_getList('id = ' . $banner_id, 1)) {
    $banner_data = $banner->_db_list[0];
}
if (empty($banner_data)) {
    // No banners loaded
    header('Location: dummy.html');
} else {
    switch ($banner_data['source_type']) {
        case 'u':
            header('Location: ' . PCPIN_FORMLINK . '?external_url=' . urlencode($banner_data['source']));
            die;
            break;
        case 'c':
            header('Content-Type: text/html; charset=UTF-8');
            header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
 *
 *    "PCPIN Chat 6" is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
if (!isset($display_position)) {
    $display_position = '';
}
$banner_data_xml = array();
_pcpin_loadClass('banner');
$banner = new PCPIN_Banner($session);
if (!empty($current_user->id)) {
    $xmlwriter->setHeaderMessage($l->g('error'));
    $xmlwriter->setHeaderStatus(1);
    if ($session->_s_room_id > 0) {
        if ($banner_data = $banner->getRandomBanner($display_position)) {
            $xmlwriter->setHeaderMessage('OK');
            $xmlwriter->setHeaderStatus(0);
            foreach ($banner_data as $key => $val) {
                if ($key == 'display_position' || $key == 'width' || $key == 'height' || $key == 'id') {
                    $banner_data_xml[$key] = $val;
                }
            }
        }
    }
}
$xmlwriter->setData(array('banner_data' => $banner_data_xml));