PDA

View Full Version : Help with editing Tables


sketch42
12 Jul 2005, 05:06
well basically i need help with this hack and the author has yet to provide answers for near a week both here and on his support forums on his site

basically what i need to do is modify this so when its ran it doesnt look for the prefix's in the database. his installation script never inserted prefixs

any help would be greatly appreciated.
TIA


<?php

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

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'nutt_maintenance');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array();

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./nutt_global.php');
require_once('./includes/adminfunctions.php');

// get permissions to view eaccelerator config
// change 1 to your userid
if (!can_administer())
{
print_no_permission();
}

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

if ($_REQUEST['do'] == 'passkeys')
{
$users = $DB_site->query("
SELECT userid, passkey, username, salt
FROM " . TABLE_PREFIX . "user
");

while ($user = $DB_site->fetch_array($users))
{
if (empty($user['passkey']))
{
if ($_REQUEST['extra'] == 'show')
{
echo $user['username'] . '<br />';
}
else
{
$passkey = md5($user['username'].time().$user['salt']);
$update = $DB_site->query("
UPDATE " . TABLE_PREFIX . "user
SET passkey = '$passkey'
WHERE userid = $user[userid]
");
}
}
}

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

if ($_REQUEST['do'] == 'deletethreads')
{
$threads = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "thread
WHERE forumid = $vboptions[nutt_forumid]
");
while ($thread = $DB_site->fetch_array($threads))
{
$DB_site->query("
DELETE
FROM " . TABLE_PREFIX . "thread
WHERE threadid = $thread[threadid]
");

$DB_site->query("
DELETE
FROM " . TABLE_PREFIX . "post
WHERE threadid = $thread[threadid]
");
}

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

if ($_REQUEST['do'] == 'makethreads')
{
$torrents = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "nutt_torrents
WHERE threadid = ''
");
while ($torrent = $DB_site->fetch_array($torrents))
{
$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "thread(title, lastpost, forumid, open, replycount, postusername, postuserid, lastposter, dateline, visible, sticky)
VALUES (\"$torrent[name]\", \"$torrent[added]\", $vboptions[nutt_forumid], 1, 0, \"$torrent[owner]\", $torrent[ownerid], \"$torrent[owner]\", \"$torrent[added]\", 1, 0)
");
$threadid = $DB_site->insert_id();

// Now add Post to thread
$message = mysql_real_escape_string("".$torrent['name']." (.$vboptions['nutt_url']."/details.php?t=".$torrent['id'].)\n\r".$torrent['descr']);

$DB_site->query("
INSERT INTO " . TABLE_PREFIX . "post(threadid, parentid, title, username, userid, dateline, pagetext, allowsmilie, showsignature, ipaddress, iconid, visible, attach)
VALUES ($threadid, 0, \"$torrent[name]\", \"$torrent[owner]\", $torrent[ownerid], \"$torrent[added]\", \"$message\", 1, 1, '$_SERVER[REMOTE_ADDR]', 0, 1, 0)
");
$postid = $DB_site->insert_id();

$DB_site->query("
UPDATE " . TABLE_PREFIX . "thread
SET firstpostid = $postid
WHERE threadid = $threadid
");

$DB_site->query("
UPDATE " . TABLE_PREFIX . "forum
SET threadcount = threadcount + 1,
replycount = replycount + 1
WHERE forumid = $vboptions[nutt_forumid]
");

$DB_site->query("
UPDATE " . TABLE_PREFIX . "nutt_torrents
SET threadid = $threadid
WHERE id = $torrent[id]
");

$DB_site->query("
UPDATE " . TABLE_PREFIX . "forum
SET lastpost = ".time().",
lastposter = \"$bbuserinfo[username]\",
lastthread = \"$torrent\",
lastthreadid = $threadid,
threadcount = threadcount + 1,
replycount = replycount + 1
WHERE forumid = $forumid
");
}

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

if ($_REQUEST['do'] == 'comments')
{
$torrents = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "nutt_torrents
WHERE comments = 0
");
while ($torrent = $DB_site->fetch_array($torrents))
{
unset($posts, $comments, $update);

$posts = $DB_site->query_first("
SELECT COUNT(*) as count
FROM " . TABLE_PREFIX . "post
WHERE threadid = $torrent[threadid]
");
$comments = $posts['count'] -1;

$update = $DB_site->query("
UPDATE " . TABLE_PREFIX . "nutt_torrents
SET comments = $comments
WHERE id = $torrent[id]
");
}

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

if ($_REQUEST['do'] == 'resettemp')
{
$update = $DB_site->query("
UPDATE " . TABLE_PREFIX . "user
SET tempuploaded = '', tempdownloaded = '', tempreset = " . time() . "
WHERE tempuploaded > 0 OR tempdownloaded > 0
");

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

if ($_REQUEST['do'] == 'resetpeers')
{
$update = $DB_site->query("
DELETE FROM " . TABLE_PREFIX . "nutt_peers
");

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

if ($_REQUEST['do'] == 'resettorrentpeers')
{
$update = $DB_site->query("
UPDATE " . TABLE_PREFIX . "nutt_torrents
SET seeders = 0, leechers = 0
");

print("<a href=\"nutt_maintenance.php?do=options\">Done! Go back.</a><br />");
}

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

}

if ($_REQUEST['do'] == 'options')
{
print('<center>');
print('NuTT Maintenace 0.1<br /><br />');
print("<a href=\"nutt_maintenance.php?do=resetpeers\">Reset peers</a><br />");
print("<a href=\"nutt_maintenance.php?do=resettorrentpeers\">Reset seeds/leechers</a><br />");
print("<a href=\"nutt_maintenance.php?do=resettemp\">Reset temp stats</a><br />");
print("<a href=\"nutt_maintenance.php?do=makethreads\">Make torrent threads</a><br />");
print("<a href=\"nutt_maintenance.php?do=deletethreads\">Delete torrent threads</a><br />");
print("<a href=\"nutt_maintenance.php?do=comments\">Update comment counts</a><br />");
print("<a href=\"nutt_maintenance.php?do=rehash\">Rehash all torrents</a><br />");
print("<a href=\"nutt_maintenance.php?do=passkeys\">Generate passkeys</a>");
print('</center>');
}
?>

Marco van Herwaarden
12 Jul 2005, 05:57
If it was an error of the installation script, i would just rename the tables,, and don't mess with the source.

sketch42
12 Jul 2005, 05:59
If it was an error of the installation script, i would just rename the tables,, and don't mess with the source.
how would i do that?

Marco van Herwaarden
12 Jul 2005, 06:04
Easiest would be to use phpMyAdmin if you have that on your server.

sketch42
12 Jul 2005, 06:07
Easiest would be to use phpMyAdmin if you have that on your server.
lol... i know that but i im not familiar with how to do that in phpmyadmin :confused: :(

Marco van Herwaarden
12 Jul 2005, 07:53
RENAME TABLE tablename TO prefix_tablename;

sketch42
12 Jul 2005, 08:00
RENAME TABLE tablename TO prefix_tablename;
thank you so much... everythings workin now wooohoo :)