Jump to content

Archived

This topic is now archived and is closed to further replies.

ArcAiN6

building a patch system.

Recommended Posts

I recently started a project with a group, and after lengthy discussion, i've decided that the best way to patch / update thier mysql driven forums.

I was planning on using some sort of form to let the administrator select witch patch to apply, but i've run into a snag, whenever i select teh data on the form, and click submit, the screen is then blank..

here is what i have so far in it's entirity. I look forward to your suggestions and ideas :)

[DIR]= /home/http/vhosts/xxxxxxxxxx.com/subdomains/cf/htdocs

Form.php located in [DIR]/patches/:
[code]<?php
echo ("<html>");
echo ("<body>");
echo ("");
echo ("<form action='complete.php' method='post'>");
echo ("<select name='Patch'>");
echo ("<option value='patch.php'>Mass Inactive Users ban</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("</select>");
echo ("<input type='submit' name='submit' value='Patch'>");
echo ("</form>");
echo ("");
echo ("</body>");
echo ("</html>");
?>[/code]

Complete.php located in [DIR]/patches/:
[code]
<?php
include = 'includes/config.php';
include = 'includes/opendb.php';
mysql_select_db($dbname, $dbcnx);
include = 'includes/$patch';
if ( @mysql_query($sql) ) {
  echo("<p>Update affected " . mysql_affected_rows() . "
rows.</p>");
} else {
  echo("<p>Error performing update: " . mysql_error() .
"</p>");
}
?>
[/code]

config.php Located in [DIR]/includes/patches/:
[code]
<?php
// This is an example of config.php
$dbhost = 'localhost';
$dbuser = 'xxxxx';
$dbpass = 'xxxxxx';
$dbname = 'xxxxxxxxxxx';
// DO NOT EDIT BELOW THIS LINE

$patch = $_POST["Patch"];
$date = date('l dS \of F Y h:I:s A');
?>
[/code]


opendb.php Located in [DIR]/includes/patches/:
[code]
<?php
    // Connect to the database server
  $dbcnx = @mysql_connect("localhost", $dbuser, $dbpass);
  if (!$dbcnx) {
    echo( "<p>Unable to connect to the " .
          "database server at this time.</p>"
);
    exit();
}
?>

[/code]

patch.php located in [DIR]/patches/
[code]
<?php
$sql = "UPDATE ibf_members,ibf_member_extra
SET ibf_members.mgroup=5,
ibf_member_extra.signature='Banned on $date by nExfUn script'
WHERE ibf_members.id=ibf_member_extra.id
AND ibf_members.mgroup=151
AND ibf_members.posts<20
AND ibf_members.joined< UNIX_TIMESTAMP()-2592000;";
?>
[/code]


as you can see, i've attempted to make it so the admin can choose wich patch to apply by using a dropdown menu. But i've also parted everything out so it may be used again in other parts or or other standalone patches at a later date. The reason i'm attempting to do it this iway is to ease the burden on myself and the sql coder so we only need to write out as little as possible.

Any help with this would be much appreciated. Sorry for including all of the files, but i thought it would be more clear to everyone that way.

Share this post


Link to post
Share on other sites
Try making
echo ("<option value='patch.php'>Mass Inactive Users ban</option>");
echo ("<option value='patch'>Mass Inactive Users ban</option>");
and make
$patch = $_POST["Patch"];
$patch = $_POST["Patch"] . ".php";

and see if anything different happens, also on patch.php at the end add
mysql_query($sql);

Share this post


Link to post
Share on other sites
Corbin,

[code=php:0]
mysql_query($sql);
[/code]

Is already included after the statement itself, but it's just included in complete.php

Regards
Rich

Share this post


Link to post
Share on other sites
First use the firom in a function and add that function to a page called functions.php

Then include("functions.php");

Then call the function example function form(); any were you need it.

redesign your form had a hartattack here.

Share this post


Link to post
Share on other sites
ok... i rewrote everything.. but now i'm not getting any type of responce.. i.e. it supposed to tell me if everything went OK, or if something went wrong... just getting a blank page...


the form is not included as it's very large.. don't wanna over post.. if you guys need to see it let me know..

patch1.php
[code]
<?php
$dbhost = "localhost";
$user = "xxxxxx";
$pw = "xxxxxxx";
$dbname = "xxxxxxxxxx";
$join = $_POST["join"]
$memb = $_POST["memb"]
$count = $_POST["count"]
$date = date('l dS \of F Y h:I:s A');

$dbcnx = @mysql_connect($dbhost, $user, $pw);
  if (!$dbcnx) {
    echo( "<p>Unable to connect to the " .
          "database server at this time.</p>"
);
    exit();
}
mysql_select_db($dbname, $dbcnx);
$sql = "UPDATE ibf_members,ibf_member_extra
SET ibf_members.mgroup=5,
ibf_member_extra.signature='Banned on $date by nExfUn script'
WHERE ibf_members.id=ibf_member_extra.id
AND ibf_members.mgroup=$memb
AND ibf_members.posts<$count
AND ibf_members.joined< UNIX_TIMESTAMP()-$join;";
if ( @mysql_query($sql) ) {
  echo("<p>Update affected " . mysql_affected_rows() . "
rows.</p>");
} else {
  echo("<p>Error performing update: " . mysql_error() .
"</p>");
}

?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.