1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
<?php
/* OpenDb - Open Media Lending Database
Copyright (C) 2001,2002 by Jason Pell
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// This must be first - includes config.php
require_once("./include/begin.inc.php");
include_once("./include/language.php");
include_once("./include/theme.php");
include_once("./functions/database.php");
include_once("./functions/auth.php");
include_once("./functions/logging.php");
include_once("./functions/http.php");
include_once("./functions/patchutils.php");
include_once("./functions/SniffBrowser.php");
function get_patch_title($from, $type, $title = NULL)
{
global $CONFIG_VARS;
if($type == "install")
return "Install";
else if($type == "optional")
return "Optional Update";
else//($type == "patch")
{
if(strlen($title)>0)
return "Upgrade";
else
return "Upgrade ($from to ".$CONFIG_VARS['site.version'].")";
}
}
function print_header($from, $type)
{
global $CONFIG_VARS;
echo("<html>");
echo("\n<head>");
echo("\n<title>".$CONFIG_VARS['site.title']." ".$CONFIG_VARS['site.version']." ".get_patch_title($from, $type)."</title>");
if(file_exists('./theme/default/style.css'))
echo("\n<link rel=stylesheet type=\"text/css\" href=\"./theme/default/style.css\">");
echo("\n<style type=\"text/css\">");
echo ("\n.upgrade_success { background-color:#99FF99 }".
"\n.upgrade_failure { background-color:#FF6666; font-weight: bold; font-family: courier,sans-serif }".
"\n.upgrade_warning { background-color:orange; font-weight: bold; font-family: courier,sans-serif }".
"\n.querytitle { color: #6D78AB; font-family:Verdana, Arial; font-weight:bold }".
"\n.code { color: black; font-family:Courier; font-weight:normal }");
echo("\n</style>");
echo("\n</head>");
}
/**
* The $disabled option is so confusing, I am creating a new
* function called build_patch_button, just so I can reverse
* the intention of the $disabled parameter, to an enabled
* one.
*/
function print_button($name, $value, $disabled=FALSE)
{
print_patch_button($name, $value, !$disabled);
}
/**
@param $disabled - if TRUE, button will be disabled.
*/
function print_patch_button($name, $value, $isEnabled=TRUE)
{
// Is get_browser array.
global $browser;
if($browser && $browser['type'] == "Netscape" && substr($browser['version'],0,1) == "4")
{
if($isEnabled)
echo("<input type=\"submit\" name=\"$name\" value=\"$value\">");
else
echo("<input type=\"button\" name=\"$name\" value=\"$value (DISABLED)\">");
}
else// For now this is all we are supporting.
{
echo("<input type=\"submit\" name=\"$name\" value=\"$value\"".($isEnabled?"":" DISABLED").">");
}
}
if($CONFIG_VARS['site.enable']!==FALSE || $CONFIG_VARS['patch.enable']===TRUE)
{
session_start();
// Override the patch.enable value, if a admin user is logged in.
if($CONFIG_VARS['patch.enable']!==TRUE &&
$CONFIG_VARS['patch.allow_admin_override']===TRUE &&
is_user_admin($HTTP_SESSION_VARS['user_id'], $HTTP_SESSION_VARS['user_type']))
{
$CONFIG_VARS['patch.enable'] = TRUE;
}
if($CONFIG_VARS['patch.enable']===TRUE)
{
if(strlen($HTTP_VARS['from'])>0)
{
// no operation specified - set up frames.
if(strlen($HTTP_VARS['op'])==0)
{
print_header($HTTP_VARS['from'], $HTTP_VARS['type']);
// Notice no $op defined!
$url = get_url_string($HTTP_VARS);
?>
<frameset scrolling="yes" rows="50%,*" border="1" frameborder="1">
<frame name="menu" src="<?php echo("$PHP_SELF?$url&op=menu"); ?>">
<frame name="main" src="<?php echo("$PHP_SELF?$url&op=main"); ?>">
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.
Please upgrade your browser to one that does!</p>
</body>
</noframes>
</frameset>
<?php
}
else//op specified.
{
print_header($HTTP_VARS['from'], $HTTP_VARS['type']);
if($HTTP_VARS['op'] == "menu")
{
echo("<div align=right><h1>".$CONFIG_VARS['site.title']." ".$CONFIG_VARS['site.version']."</h1>");
echo ("<font class=\"footer\">Finish applying the patch? [<a href=\"$PHP_SELF\" target=\"_parent\">Apply another patch</a>]");
if($CONFIG_VARS['site.enable']!==FALSE)
{
echo(" or [<a href=\"index.php\" target=\"_parent\">Login to OpenDb</a>]");
}
echo("</font></div>");
echo ("<h2>OpenDb Patch facility ".get_patch_title($HTTP_VARS['from'], $HTTP_VARS['type'], $HTTP_VARS['title'])."</h2>");
echo("<h3>".$HTTP_VARS['title']."</h3>");
}
else if($HTTP_VARS['op'] == "result")
{
echo ("<h3>Results...</h3>");
}
// Ignore any errors.
$browser = @SniffBrowser();
// Set a time limit of a good value, because some of the patches do a lot of work.
@set_time_limit(600);
if(file_exists("./patch/".$HTTP_VARS['from']."/index.php"))
{
include("./patch/".$HTTP_VARS['from']."/index.php");
}
else//Default
{
if($HTTP_VARS['op'] == "menu")
{
echo("<div align=\"center\">");
$files = get_patch_file_list($HTTP_VARS['from'],"sql");
if(is_not_empty_array($files))
{
echo("<form action=\"$PHP_SELF\" method=\"get\" target=\"main\">");
while (list(,$file) = each($files))
{
print_button("sqlfile", "$file", FALSE);
echo(" ");
}
echo("<br>");
echo("Preview SQL only<input type=\"checkbox\" name=\"preview\" value=\"true\">");
echo("<input type=\"hidden\" name=\"op\" value=\"result\">");
echo("<input type=\"hidden\" name=\"from\" value=\"".$HTTP_VARS['from']."\">");
echo("</form>");
}
else
{
echo("<div class=\"error\">- No Files Found -</div>");
}
echo("</div>");
}
else
{
if($HTTP_VARS['preview'] == 'true')
echo_patch_sql_file($HTTP_VARS['from'], $HTTP_VARS['sqlfile']);
else if(isset($HTTP_VARS['sqlfile']))
exec_patch_sql_file($HTTP_VARS['from'], $HTTP_VARS['sqlfile']);
}
}
if ($HTTP_VARS['op'] == 'result' && $HTTP_VARS['standalone']!='Y')//refresh menu for result.
echo( "<script language=\"javascript\"><!-- //hide\nparent.frames[0].location.reload();\n// -->\n</script>");
echo("</body>");
}
}
else
{
print_header($HTTP_VARS['from'], $HTTP_VARS['type']);
echo("<div align=right><h1>".$CONFIG_VARS['site.title']." ".$CONFIG_VARS['site.version']."</h1>");
if($CONFIG_VARS['site.enable']!==FALSE)
{
echo ("<font class=\"footer\">[<a href=\"index.php\" target=\"_parent\">Login to OpenDb</a>]</font>");
}
echo("</div>");
?>
<h2>OpenDb Patch facility</h2>
<h3>New Install:</h3>
<ul>
<li><a href="<?php echo $PHP_SELF; ?>?from=install&type=install">New <?php echo $CONFIG_VARS['site.version']; ?> Installation</a></li>
</ul>
<h3>Upgrade:</h3>
<!-------------------------------------Custom Section -------------------------------->
<ul>
<li><a href="<?php echo $PHP_SELF; ?>?from=0.80&type=patch">Upgrade from OpenDb 0.80 to <?php echo $CONFIG_VARS['site.version']; ?></a></li>
<li><a href="<?php echo $PHP_SELF; ?>?from=0.62&type=patch">Upgrade from OpenDb 0.62 to 0.80</a></li>
<li><a href="<?php echo $PHP_SELF; ?>?from=0.61&type=patch&title=Upgrade+from+0.61+to+0.62">Upgrade from OpenDb 0.61 to 0.62</a></li>
<li><a href="<?php echo $PHP_SELF; ?>?from=0.60&type=patch&title=Upgrade+from+0.60+to+0.62">Upgrade from OpenDb 0.60 to 0.62</a></li>
<li><a href="<?php echo $PHP_SELF; ?>?from=0.54&type=patch&title=Upgrade+from+0.54+to+0.62">Upgrade from OpenDb 0.54 to 0.62</a></li>
<li><a href="<?php echo $PHP_SELF; ?>?from=0.50&type=patch&title=Upgrade+from+OpenDb+0.50,+0.51,+0.52+or+0.53+to+0.54">Upgrade from OpenDb 0.50, 0.51, 0.52 or 0.53 to 0.54</a></li>
</ul>
<p><div class="help">
<h4>Upgrade Notes: </h4>
<ul>
<li>Upgrades from DVDDbp are no longer supported. If you are upgrading from DVDDBp, you will have to download and install OpenDb 0.62 first, and 'Upgrade from DVDDBp 1.45 to 0.62'. Then you will need to install
OpenDb <?php echo $CONFIG_VARS['site.version']; ?>, and then you will need to run the 'Upgrade from OpenDb 0.62 to <?php echo $CONFIG_VARS['site.version']; ?>' patch.</li>
<li>Upgrades from versions of OpenDb prior to 0.50 are no longer supported. You will have to upgrade to OpenDb 0.62 and then upgrade to this version.</li>
<li>If you are upgrading from OpenDb 0.61, you will need to run the 'Upgrade from OpenDb 0.60 to 0.62' patch, followed by the 'Upgrade from OpenDb 0.62 to
0.80' and 'Upgrade from OpenDb 0.80 to <?php echo $CONFIG_VARS['site.version']; ?>' patches.</li>
<li>If you are upgrading from OpenDb 0.60, you will need to run the 'Upgrade from OpenDb 0.60 to 0.62' patch, followed by the 'Upgrade from OpenDb 0.62 to
0.80' and 'Upgrade from OpenDb 0.80 to <?php echo $CONFIG_VARS['site.version']; ?>' patches.</li>
<li>If you are upgrading from OpenDb 0.54, you will need to run the 'Upgrade from OpenDb 0.54 to 0.62' patch, followed by the 'Upgrade from OpenDb 0.62 to
0.80' and 'Upgrade from OpenDb 0.80 to <?php echo $CONFIG_VARS['site.version']; ?>' patches.</li>
<li>If you are upgrading from OpenDb versions between 0.50 and 0.53, you will need to run the <i>' 0.50, 0.51, 0.52 or 0.53 to 0.54'</i> patch prior to
running the <i>'0.54 to <?php echo $CONFIG_VARS['site.version']; ?>'</i> patch.</li>
</ul>
</div></p>
<div class="help">
<h4>Upgrade / Install Notes:</h4>
<ul>
<li>Please make sure that the MySQL user has sufficient permissions to perform the necessary update
operations. The permissions should include {Select, Insert, Update, Delete, Create, Drop, Index, Alter, Lock Tables}
for the current database.</li>
</ul>
</div>
<!-------------------------------------Custom Section -------------------------------->
<h3>Optional:</h3>
<ul>
<li>
<a href="<?php echo $PHP_SELF; ?>?from=prefix&type=optional&title=Prefix+Tables">Prefix tables</a>
<br>Add/Remove OpenDb table prefixes. The $CONFIG_VARS['db_server.table_prefix'] variable must be set to
the correct value (Especially important for removing the prefix!)
</li>
<li>
<a href="<?php echo $PHP_SELF; ?>?from=session&type=optional&title=Database+Session+Handler">Database Session Handler</a>
<br>Add/Remove Session table. You should have the $CONFIG_VARS['session_handler.?????'] options configured correctly,
to ensure the table is inserted into the correct database, with the right name. As a minimum you should define
a $CONFIG_VARS['session_handler.session_table'], otherwise <b><i>php_session</i></b> will be used for the table name.
</li>
<li><a href="<?php echo $PHP_SELF; ?>?from=extras&type=optional&title=Extra+Stuff">Extra stuff</a>
<br>Extras such as Alternate title configuration, Extra Subtitles, etc.
</li>
<li><a href="<?php echo $PHP_SELF; ?>?from=lang&type=optional&title=International+Language+Support">International Language</a>
<br>Configure OpenDb for a particular language. You will still have to modify the
include/config.php $CONFIG_VARS['site.language'] variable.
</li>
<li><a href="<?php echo $PHP_SELF; ?>?from=country&type=optional&title=Customise+for+Country">Customise for Country</a>
<br>Age Recommendations, DVD Region, etc.
</li>
</ul>
<!------------------------------------------------------------------------------------------->
</body>
<?php
}
}//if($CONFIG_VARS['patch.enable']===TRUE)
else
{
echo _theme_header("Patch facility is not available.");
echo _theme_error("Patch facility is not available.");
echo _theme_footer();
}
}//if($CONFIG_VARS['site.enable']!==FALSE)
else
{
echo _theme_header($LANG_VARS['site_is_disabled'], FALSE);
echo _theme_error($LANG_VARS['site_is_disabled']);
echo _theme_footer();
}
// Cleanup after begin.inc.php
require_once("./include/end.inc.php");
?>
</html>
|