View Single Post
  #276  
Old 11-18-2006, 07:14 PM
Jack Crazy Jack Crazy is offline
 
Join Date: Dec 2004
Posts: 27
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is their something wrong in my banneradmin.php file?
PHP Code:
<?php

/*======================================================================*\
|| #################################################################### ||
|| # Banner System Lite v.1.0                                          # ||
|| # Author: Thinh Nguyen (tnguy3n)                                      # ||
|| # Support site: http://www.vbviet.com                              # ||
|| # Copyright ? 2005 vBviet Network. All Rights Reserved.               # ||
|| # This file may not be redistributed in whole or significant part  # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('GET_EDIT_TEMPLATES'true);
define('THIS_SCRIPT''banneradmin');

require_once(
'./global.php');

// #################### Start main script ####################

if (empty($_REQUEST['do']))
{
    
$_REQUEST['do'] = 'settings';
}

if(
$_REQUEST['do'] == 'settings'){

    
header("Location: options.php?do=options&dogroup=bannersys");
}

// Banner Manager
if($_REQUEST['do'] == "manage")
{
    
print_cp_header("Banner System Manager");
    
print_table_start();
    
print_table_header("Banner Manager"4);
    
print_form_header('banneradmin','addbanner');
    
$banners $db->query_read("SELECT * FROM " TABLE_PREFIX "bannersys_banners ORDER BY bannerid ASC");
    
print_cells_row(array('Banner''Dimension''Status','Options'), 1111'tcat');
    while(
$banner $db->fetch_array($banners))
    {
        
$bannerid $banner['bannerid'];

        if(
$banner['status'] == '0')
        {
            
$status '<font color="red">Inactive</font>';
            
$linkopt "<a href=\"banneradmin.php?do=activate&bannerid=$bannerid\">Activate</a>";
        }
        elseif(
$banner['status'] == '1')
        {
            
$status '<font color="green">Active</font>';
            
$linkopt "<a href=\"banneradmin.php?do=deactivate&bannerid=$bannerid\">Deactivate</a>";
        }
        elseif(
$banner['status'] == '2'
        { 
            
$status '<font color="yellow">Unapproved</font>'
            
$linkopt "<a href=\"banneradmin.php?do=approve&bannerid=$bannerid\">Approve</a>";
        }

        
$cell = array();
        
$cell[] = "<div align='center'>$banner[bannername]<br />$banner[bannerdesc] <br /><a href=\"$banner[bannerurl]\" title=\"$banner[bannername]\" target=\"_blank\"><img src=\"$banner[imgurl]\" alt=\"$banner[bannername]\" borde=\"0\"></a></div>";
        
$cell[] = $banner['bwidth'] . ' x ' $banner['bheight'];
        
$cell[] = $status;
        
$cell[] = "<div align='center'><a href=\"banneradmin.php?do=modify&bannerid=$bannerid\">Modify</a> | <a href=\"banneradmin.php?do=delete&bannerid=$bannerid\" onClick=\"return confirm('Delete it?')\">Delete</a><br />$linkopt</div>";
        
print_cells_row($cell);
    }
    
print_submit_row('Add New Banner'04);
    
print_table_footer();
    
print_cp_footer();
    exit;
}
if(
$_REQUEST['do']=="addbanner"){
    
print_cp_header("Add New Banner");
    
print_table_start();
    
print_table_header("Add Banner");
    
print_form_header('banneradmin','insertbanner');
    
print_input_row("Banner Name:<dfn>Your banner name.</dfn>"'bannername');
    
print_input_row("Description:<dfn>Short description for the banner.</dfn>"'bannerdesc');
    
print_input_row("Banner Link:<dfn>Home link of the banner. Must start with http://www..</dfn>"'bannerurl');
    
print_input_row("Image Location:<dfn>Location of banner image. Must start with http://www.</dfn>"'imgurl');
    
print_input_row("Banner Width:<dfn></dfn>"'bwidth');
    
print_input_row("Banner Height:<dfn></dfn>"'bheight');
    
print_yes_no_row("Active?:<dfn>Is it active?</dfn>"'status');
    
print_submit_row('Add Banner'0);
    
print_table_footer();
    
print_cp_footer();
    exit;
}

if(
$_POST['do'] == 'insertbanner')
{
    
$vbulletin->input->clean_array_gpc('p', array('bannername' => TYPE_STR'bannerdesc' => TYPE_STR'bannerurl' => TYPE_STR'imgurl' => TYPE_STR'bwidth' => TYPE_INT'bheight' => TYPE_INT'status' => TYPE_INT));

    
$db->query_write("
        INSERT INTO " 
TABLE_PREFIX "bannersys_banners(bannername, bannerdesc, bannerurl, imgurl, bwidth, bheight, status) 
        VALUES('" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[bannername])) . "', 
            '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[bannerdesc])) . "', 
            '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[bannerurl])) . "', 
            '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[imgurl])) . "', 
            '" 
intval($vbulletin->GPC[bwidth]) . "', 
            '" 
intval($vbulletin->GPC[bheight]) . "',
            '" 
intval($vbulletin->GPC[status]) . "')
        "
);
    
define('CP_REDIRECT'"banneradmin.php?do=manage");
    
print_stop_message('banner_added_successfully');
    exit;
}

if(
$_REQUEST['do']=="modify")
{
    
$vbulletin->input->clean_array_gpc('r', array('bannerid' => TYPE_INT));

    
$banner$db->query_first("SELECT * FROM " TABLE_PREFIX "bannersys_banners WHERE bannerid = '" $vbulletin->GPC['bannerid'] . "'");
    
print_cp_header("Modify Banner");
    
print_table_start();
    
print_table_header("Modify Banner: $banner[bannername]");
    
print_form_header('banneradmin','update');
    
construct_hidden_code('bannerid'$banner['bannerid']);
    
print_input_row("Banner Name:<dfn>Your banner name.</dfn>"'bannername'$banner['bannername']);
    
print_input_row("Description:<dfn>Short description for the banner.</dfn>"'bannerdesc'$banner['bannerdesc']);
    
print_input_row("Banner Link:<dfn>Home link of the banner. Must start with http://www..</dfn>"'bannerurl'$banner['bannerurl']);
    
print_input_row("Image Location:<dfn>Location of banner image. Must start with http://www.</dfn>"'imgurl'$banner['imgurl']);
    
print_input_row("Banner Width:<dfn></dfn>"'bwidth'$banner['bwidth']);
    
print_input_row("Banner Height:<dfn></dfn>"'bheight'$banner['bheight']);
    
print_yes_no_row("Active?:<dfn>Is it active?</dfn>"'status'$banner['status']);
    
print_submit_row($vbphrase['update']);
    
print_table_footer();
    
print_cp_footer();
    exit;
}

if(
$_POST['do'] == 'update')
{
    
$vbulletin->input->clean_array_gpc('p', array(
                            
'bannerid'            => TYPE_INT,
                            
'bannername'        => TYPE_STR,
                            
'bannerdesc'        => TYPE_STR,
                            
'bannerurl'            => TYPE_STR,
                            
'imgurl'            => TYPE_STR,
                            
'bwidth'            => TYPE_INT,
                            
'bheight'            => TYPE_INT,
                            
'status'            => TYPE_INT
                        
));

    
$db->query_write("UPDATE " TABLE_PREFIX "bannersys_banners
        SET bannername = '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[bannername])) . "',
            bannerdesc = '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[bannerdesc])) . "',
            bannerurl = '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[bannerurl])) . "',
            imgurl = '" 
addslashes(htmlspecialchars_uni($vbulletin->GPC[imgurl])) . "',    
            bwidth = '" 
intval($vbulletin->GPC[bwidth]) . "',
            bheight = '" 
intval($vbulletin->GPC[bheight]) . "',    
            status = '" 
intval($vbulletin->GPC[status]) . "'    
        WHERE bannerid = '" 
intval($vbulletin->GPC[bannerid]) . "'
        "
);
    
define('CP_REDIRECT'"banneradmin.php?do=manage");
    
print_stop_message('updated_banner_successfully');
    exit;
}

if (
$_REQUEST['do'] == 'delete')
{
    
$vbulletin->input->clean_array_gpc('r', array('bannerid' => TYPE_INT));
    
$db->query_write("
        DELETE FROM " 
TABLE_PREFIX "bannersys_banners 
        WHERE bannerid = '" 
intval($vbulletin->GPC[bannerid]) . "'
    "
);
    
define('CP_REDIRECT'"banneradmin.php?do=manage");
    
print_stop_message('deleted_banner_successfully');
    exit;
}

if (
$_REQUEST['do'] == 'activate')
{
    
$vbulletin->input->clean_array_gpc('r', array('bannerid' => TYPE_INT));
    
$db->query_write("
        UPDATE " 
TABLE_PREFIX "bannersys_banners SET status = '1'
        WHERE bannerid = '" 
intval($vbulletin->GPC[bannerid]) . "'
    "
);
    
define('CP_REDIRECT'"banneradmin.php?do=manage");
    
print_stop_message('activated_banner_successfully');
    exit;
}

if (
$_REQUEST['do'] == 'deactivate')
{
    
$vbulletin->input->clean_array_gpc('r', array('bannerid' => TYPE_INT));
    
$db->query_write("
        UPDATE " 
TABLE_PREFIX "bannersys_banners SET status = '0'
        WHERE bannerid = '" 
intval($vbulletin->GPC[bannerid]) . "'
    "
);
    
define('CP_REDIRECT'"banneradmin.php?do=manage");
    
print_stop_message('deactivated_banner_successfully');
    exit;
}


// banner stats
if($_REQUEST['do'] == 'stats')
{
    
print_cp_header("Banner Stats Manager");
    
print_table_start();
    
print_table_header("Banner Stats"4);
    
print_cells_row(array('Banners''Total Hits''Status','Option'), 1111'tcat');

    
$getstats $db->query_read("SELECT banners.bannerid, banners.bannername, banners.bannerurl, banners.status, stats.*, COUNT(stats.bannerid) AS totalhits
        FROM " 
TABLE_PREFIX "bannersys_stats AS stats
        LEFT JOIN " 
TABLE_PREFIX "bannersys_banners AS banners ON (banners.bannerid = stats.bannerid)
        GROUP BY stats.bannerid
        ORDER BY totalhits DESC    
    "
);
    while(
$stats $db->fetch_array($getstats))
    {
        if(
$stats['status'] == '0')
        {
            
$status '<font color="red">Inactive</font>';
        }
        elseif(
$stats['status'] == '1')
        {
            
$status '<font color="green">Active</font>';
        }
        elseif(
$stats['status'] == '2'
        { 
            
$status '<font color="yellow">Unapproved</font>'
        }
        
        
// print results
        
$cell = array();
        
$cell[] = "<a href=\"$stats[bannerurl]\" target=\"_blank\">" $stats['bannername'] . '</a>';
        
$cell[] = $stats['totalhits'];
        
$cell[] = $status;
        
$cell[] = "<div align='center'><a href=\"banneradmin.php?do=viewstats&bannerid=$stats[bannerid]\">View Detail</a></div>";
        
print_cells_row($cell);
    }
    
print_table_footer();
    
print_cp_footer();
}


// view banner stats
if($_REQUEST['do'] == 'viewstats')
{
    
$bannerid $vbulletin->input->clean_gpc('r''bannerid'TYPE_INT);

    
print_cp_header("Banner Stats Manager");
    
print_table_start();
    
print_table_header("Detail Stats"3);
    
print_cells_row(array('User''Visit Date''User IP'), 111'tcat');

    
$getstats $db->query_read("SELECT stats.*, banner.bannerid, user.userid, user.username
        FROM " 
TABLE_PREFIX "bannersys_stats AS stats
        LEFT JOIN " 
TABLE_PREFIX "bannersys_banners AS banner ON (banner.bannerid = stats.bannerid)
        LEFT JOIN " 
TABLE_PREFIX "user AS user ON (user.userid = stats.visitorid)
        WHERE stats.bannerid = '
$bannerid'
        ORDER BY stats.visitdate DESC    
    "
);
    while(
$stats $db->fetch_array($getstats))
    {
        
$stats['visitdate'] = vbdate($vbulletin->options['dateformat'], $stats['visitdate']);

        if(
$stats['userid'])
        {
            
$user "<a href=\"../member.php?u=$stats[userid]\">" $stats['username'] . '</a>';
        }
        else
        {
            
$user 'Guest';
        }

        
// print results
        
$cell = array();
        
$cell[] = $user;
        
$cell[] = $stats['visitdate'];
        
$cell[] = $stats['visitorip'];
        
print_cells_row($cell);
    }
    
print_table_footer();
    
print_cp_footer();
}


?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01200 seconds
  • Memory Usage 2,003KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete