PDA

View Full Version : custom page stopped working after upgrade


vengefuldeath87
01-30-2007, 11:28 PM
Ive just upgraded from 3.6.3 to 3.6.4, and now my custom admin page has stopped working totally.

<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
@set_time_limit(0);

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style');
$specialtemplates = array('products');

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/adminfunctions_template.php');

print_cp_header();


$con = mysql_connect("localhost","u","p");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
// some code




// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminusers'))
{
print_cp_no_permission();
}
$name = $_POST['inputname'];
if($name) {
$result = mysql_query("SELECT * FROM lacn where username='".$name."'",$con);
if (mysql_num_rows($result) == 1) {
$result = mysql_query("delete from lacn where username='".$name."'",$con);
print_description_row('Removed '.$name);
} else {
print_description_row('User '.$name.' was not found.');
}
}


mysql_close($con);
print_cp_header($vbphrase['FAdmin']);
print_form_header('fadmin');
print_table_header('Delete User');

print_input_row('Enter Name to remove:', 'inputname');
print_submit_row("Submit!", 0);



print_cp_footer();


?>



I cant even get anything to output from the code, and the $_POST has stopped working.

Just to add, the db stuff connects to a different db, not the vbulletin one.

harmor19
01-31-2007, 01:04 AM
This is untested

<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
@set_time_limit(0);

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style');
$specialtemplates = array('products');

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/adminfunctions_template.php');

print_cp_header();


// ######################## CHECK ADMIN PERMISSIONS #######################
if (!can_administer('canadminusers'))
{
print_cp_no_permission();
}

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

if($_REQUEST['do'] == "delete")
{

$vbulletin->input->clean_gpc('p', 'inputname', TYPE_UINT);


if(!empty($vbulletin->GPC['inputname']))
{
$result = $db->query_first("SELECT * FROM lacn WHERE username='".$db->escape_string($vbulletin->GPC['inputname'])."'");

if (empty($result['username']))
{
$db->query_write("DELETE FROM lacn WHERE username='".$db->escape_string($vbulletin->GPC['inputname'])."'");
print_description_row('Removed '.$result['username']);
}
else
{
print_description_row("User ".$result['username']." was not found.");
}
}
}

if($_REQUEST['do'] == "main")
{
print_cp_header($vbphrase['FAdmin']);
print_form_header('fadmin', 'delete');
print_table_header('Delete User');

print_input_row('Enter Name to remove:', 'inputname');
print_submit_row("Submit!", 0);

}

print_cp_footer();


?>