Jump to content

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.
Link to comment
https://forums.phpfreaks.com/topic/20261-building-a-patch-system/
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);
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]

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.