Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../var/softacul.../cpg
File: update.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Coppermine Photo Gallery
[2] Fix | Delete
*
[3] Fix | Delete
* v1.0 originally written by Gregory Demar
[4] Fix | Delete
*
[5] Fix | Delete
* @copyright Copyright (c) 2003-2021 Coppermine Dev Team
[6] Fix | Delete
* @license GNU General Public License version 3 or later; see LICENSE
[7] Fix | Delete
*
[8] Fix | Delete
* update.php
[9] Fix | Delete
* @since 1.6.12
[10] Fix | Delete
*/
[11] Fix | Delete
[12] Fix | Delete
// define('SKIP_AUTHENTICATION', true);
[13] Fix | Delete
// If you don't remember the admin account data you're prompted for when running this file in your browser, umcomment the line above by removing the two slashes in front of it, upload that file to your webserver, run it in your browser. After successfully having run it, remember to restore the two slashes you removed and replace the "unsecure" version on your webserver with the "secure" version (the one that contains the double slashes).
[14] Fix | Delete
[15] Fix | Delete
define('IN_COPPERMINE', true);
[16] Fix | Delete
define('UPDATE_PHP', true);
[17] Fix | Delete
[18] Fix | Delete
if (!defined('SKIP_AUTHENTICATION')) { // try to include init.inc.php to get the "regular" coppermine user interface
[19] Fix | Delete
$error_reporting = error_reporting(E_ERROR); // silence all error reports but fatal ones
[20] Fix | Delete
ob_start(); // turn output buffering on - if including the regular coppermine files breaks, we can make sure that the output doesn't break the subsequent code
[21] Fix | Delete
include_once 'include/init.inc.php';
[22] Fix | Delete
$output = ob_get_clean();
[23] Fix | Delete
error_reporting($error_reporting); // set error reporting level back to how it used to be
[24] Fix | Delete
//echo $output; // For troubleshooting purposes, echo $output
[25] Fix | Delete
}
[26] Fix | Delete
session_start();
[27] Fix | Delete
[28] Fix | Delete
if (!function_exists('cpgGetMicroTime')) {
[29] Fix | Delete
function cpgGetMicroTime()
[30] Fix | Delete
{
[31] Fix | Delete
list($usec, $sec) = explode(" ", microtime());
[32] Fix | Delete
return ((float)$usec + (float)$sec);
[33] Fix | Delete
}
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).PATH_SEPARATOR.dirname(__FILE__).DIRECTORY_SEPARATOR.'include');
[37] Fix | Delete
[38] Fix | Delete
require_once 'include/inspekt.php';
[39] Fix | Delete
require_once 'include/sql_parse.php';
[40] Fix | Delete
require_once 'include/config.inc.php';
[41] Fix | Delete
require_once 'include/functions.inc.php';
[42] Fix | Delete
[43] Fix | Delete
// The default values
[44] Fix | Delete
$errors = '';
[45] Fix | Delete
$notes = '';
[46] Fix | Delete
[47] Fix | Delete
[48] Fix | Delete
$DFLT = array(
[49] Fix | Delete
'cfg_d' => 'include', // The config file dir
[50] Fix | Delete
'cfg_f' => 'include/config.inc.php', // The config file name
[51] Fix | Delete
'alb_d' => 'albums', // The album dir
[52] Fix | Delete
'upl_d' => 'userpics', // The uploaded pic dir
[53] Fix | Delete
);
[54] Fix | Delete
[55] Fix | Delete
$superCage = Inspekt::makeSuperCage();
[56] Fix | Delete
[57] Fix | Delete
// If including includes/init.inc.php has worked as expected, the constants should be populated, so let's check that first
[58] Fix | Delete
if (!defined('SKIP_AUTHENTICATION') && defined('COPPERMINE_VERSION') && GALLERY_ADMIN_MODE) {
[59] Fix | Delete
$_SESSION['auth'] = true;
[60] Fix | Delete
} else { // we need to populate the language array
[61] Fix | Delete
require 'lang/english.php';
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
if (!function_exists('cpg_display_help')) {
[65] Fix | Delete
$help = '&nbsp;'.cpg_display_help('f=upgrading.htm&amp;as=updater&amp;ae=updater_end&amp;top=1', '650', '500');
[66] Fix | Delete
} else {
[67] Fix | Delete
$help = '&nbsp;<a href="docs/en/upgrading.htm?hide_nav=1#updater" class="greybox"><img src="images/help.gif" border="0" width="13" height="11" alt="" /></a>';
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// --------------------- SELECT NEW DATABASE ACCESS METHOD --------------------- //
[71] Fix | Delete
// if a different dbase method is selected, we have to change the config and reload
[72] Fix | Delete
// the page to get to the correct dbase class
[73] Fix | Delete
if ($superCage->post->keyExists('action') && $superCage->post->getAlpha('action') == 'dbselect') {
[74] Fix | Delete
set_config_dbtype($superCage->post->getRaw('db_type'));
[75] Fix | Delete
if ($errors) {
[76] Fix | Delete
html_error($errors);
[77] Fix | Delete
} else {
[78] Fix | Delete
header('Location: update.php?dbswitch=1');
[79] Fix | Delete
}
[80] Fix | Delete
exit;
[81] Fix | Delete
}
[82] Fix | Delete
if ($superCage->get->keyExists('dbswitch') && $superCage->get->getInt('dbswitch')) {
[83] Fix | Delete
define('SKIP_AUTHENTICATION', true);
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
// ---------------------------- AUTHENTICATION --------------------------- //
[87] Fix | Delete
// SKIP_AUTHENTICATION is a constant that can be defined for users who can't retrieve any kind of password
[88] Fix | Delete
if (!defined('SKIP_AUTHENTICATION') && !$_SESSION['auth']) {
[89] Fix | Delete
html_header($lang_update_php['title']);
[90] Fix | Delete
if (!$superCage->post->keyExists('method')) {
[91] Fix | Delete
//first try to connect to the db to see if we can authenticate the admin
[92] Fix | Delete
test_sql_connection();
[93] Fix | Delete
if ($errors != '') {
[94] Fix | Delete
//we could not establish an sql connection, so update can't be done (and user can't be autenticated)
[95] Fix | Delete
html_error($errors);
[96] Fix | Delete
} else {
[97] Fix | Delete
//echo a box for admin autentication
[98] Fix | Delete
html_auth_box('admin');
[99] Fix | Delete
}
[100] Fix | Delete
} elseif ($superCage->post->getAlpha('method') == 'admin') {
[101] Fix | Delete
//try to autenticate the admin
[102] Fix | Delete
test_sql_connection();
[103] Fix | Delete
$user = $superCage->post->getEscaped('user');
[104] Fix | Delete
$pass = $superCage->post->getEscaped('pass');
[105] Fix | Delete
[106] Fix | Delete
// Check if column 'user_password_salt' exists in user table
[107] Fix | Delete
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}users LIMIT 1");
[108] Fix | Delete
$row = $result->fetchAssoc(true);
[109] Fix | Delete
$col_user_password_salt_exists = isset($row['user_password_salt']) ? true : false;
[110] Fix | Delete
[111] Fix | Delete
if ($col_user_password_salt_exists) {
[112] Fix | Delete
require 'include/passwordhash.inc.php';
[113] Fix | Delete
$sql = "SELECT user_password, user_password_salt, user_password_hash_algorithm, user_password_iterations FROM {$CONFIG['TABLE_PREFIX']}users WHERE user_group = 1 AND user_name = '$user'";
[114] Fix | Delete
$result = cpg_db_query($sql);
[115] Fix | Delete
$password_params = $result->fetchAssoc(true);
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
if (!$col_user_password_salt_exists || !$password_params['user_password_salt']) {
[119] Fix | Delete
$sql = "SELECT user_active FROM {$CONFIG['TABLE_PREFIX']}users WHERE user_group = 1 AND user_name = '$user' AND (user_password = '$pass' OR user_password = '".md5($pass)."')";
[120] Fix | Delete
$result = cpg_db_query($sql);
[121] Fix | Delete
if (!$result->numRows()) {
[122] Fix | Delete
//not authenticated, try mysql account details
[123] Fix | Delete
html_auth_box('MySQL');
[124] Fix | Delete
die();
[125] Fix | Delete
}
[126] Fix | Delete
} elseif (!cpg_password_validate($pass, $password_params)) {
[127] Fix | Delete
//not authenticated, try mysql account details
[128] Fix | Delete
html_auth_box('MySQL');
[129] Fix | Delete
die();
[130] Fix | Delete
}
[131] Fix | Delete
//authenticated, do the update
[132] Fix | Delete
$_SESSION['auth'] = true;
[133] Fix | Delete
start_update();
[134] Fix | Delete
} else {
[135] Fix | Delete
//try to autenticate via MySQL details (in configuration)
[136] Fix | Delete
if ($superCage->post->getEscaped('user') == $CONFIG['dbuser'] && $superCage->post->getEscaped('pass') == $CONFIG['dbpass']) {
[137] Fix | Delete
//authenticated, do the update
[138] Fix | Delete
$_SESSION['auth'] = true;
[139] Fix | Delete
start_update();
[140] Fix | Delete
} else {
[141] Fix | Delete
//no go, try again
[142] Fix | Delete
html_error($lang_update_php['could_not_authenticate'] . ' - <a href="update.php">' . $lang_update_php['try_again'] .'</a>');
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
html_footer();
[146] Fix | Delete
} else {
[147] Fix | Delete
html_header($lang_update_php['title']);
[148] Fix | Delete
$_SESSION['auth'] = true;
[149] Fix | Delete
start_update();
[150] Fix | Delete
html_footer();
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
// function definitions --- start
[154] Fix | Delete
// ------------------------- HTML OUTPUT FUNCTIONS ------------------------- //
[155] Fix | Delete
[156] Fix | Delete
function html_header($title, $charset = 'iso8859-1')
[157] Fix | Delete
{
[158] Fix | Delete
if (function_exists('pageheader') && defined('COPPERMINE_VERSION') && GALLERY_ADMIN_MODE) {
[159] Fix | Delete
pageheader($title);
[160] Fix | Delete
} else {
[161] Fix | Delete
echo <<< EOT
[162] Fix | Delete
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
[163] Fix | Delete
<html>
[164] Fix | Delete
<head>
[165] Fix | Delete
<title>{$title}</title>
[166] Fix | Delete
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
[167] Fix | Delete
<meta http-equiv="Pragma" content="no-cache" />
[168] Fix | Delete
<link rel="stylesheet" href="css/installer.css" type="text/css" />
[169] Fix | Delete
</head>
[170] Fix | Delete
<body>
[171] Fix | Delete
<img class="logo" src="images/coppermine-logo.png" border="0" alt="" />
[172] Fix | Delete
[173] Fix | Delete
EOT;
[174] Fix | Delete
}
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
function html_error($error_msg = '')
[178] Fix | Delete
{
[179] Fix | Delete
global $lang_update_php, $help;
[180] Fix | Delete
[181] Fix | Delete
echo <<< EOT
[182] Fix | Delete
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="maintable">
[183] Fix | Delete
<tr>
[184] Fix | Delete
<td class="tableh1" colspan="2"><h2>{$lang_update_php['welcome_updater']}{$help}</h2>
[185] Fix | Delete
</td>
[186] Fix | Delete
</tr>
[187] Fix | Delete
[188] Fix | Delete
EOT;
[189] Fix | Delete
if ($error_msg) {
[190] Fix | Delete
echo <<< EOT
[191] Fix | Delete
<tr>
[192] Fix | Delete
<td class="tableh2" colspan="2" align="center"><span class="error">&#149;&nbsp;&#149;&nbsp;&#149;&nbsp;ERROR&nbsp;&#149;&nbsp;&#149;&nbsp;&#149;</span>
[193] Fix | Delete
</td>
[194] Fix | Delete
</tr>
[195] Fix | Delete
<tr>
[196] Fix | Delete
<td class="tableh2" colspan="2">
[197] Fix | Delete
{$lang_update_php['errors_encountered']}:<br />
[198] Fix | Delete
</td>
[199] Fix | Delete
</tr>
[200] Fix | Delete
<tr>
[201] Fix | Delete
<td class="tableh2" colspan="2">
[202] Fix | Delete
{$error_msg}
[203] Fix | Delete
</td>
[204] Fix | Delete
</tr>
[205] Fix | Delete
[206] Fix | Delete
EOT;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
echo <<< EOT
[210] Fix | Delete
</tr>
[211] Fix | Delete
</table>
[212] Fix | Delete
[213] Fix | Delete
EOT;
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
[217] Fix | Delete
function html_install_success($notes)
[218] Fix | Delete
{
[219] Fix | Delete
global $DFLT, $lang_update_php;
[220] Fix | Delete
//Coppermine is now upgraded and ready to roll.
[221] Fix | Delete
echo '&nbsp;<br />';
[222] Fix | Delete
echo '<div class="maintable"><h2 class="tableh1">' . $lang_update_php['update_completed'] . '</h2>';
[223] Fix | Delete
echo '<p class="tableh2">';
[224] Fix | Delete
printf($lang_update_php['check_versions'], '<a href="versioncheck.php">', '</a>');
[225] Fix | Delete
echo '. ';
[226] Fix | Delete
printf($lang_update_php['start_page'], '<a href="index.php">', '</a>');
[227] Fix | Delete
echo '.</p></div>';
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
function html_footer()
[231] Fix | Delete
{
[232] Fix | Delete
if (function_exists('pagefooter') && defined('COPPERMINE_VERSION') && GALLERY_ADMIN_MODE) {
[233] Fix | Delete
pagefooter();
[234] Fix | Delete
} else {
[235] Fix | Delete
echo <<< EOT
[236] Fix | Delete
</body>
[237] Fix | Delete
</html>
[238] Fix | Delete
[239] Fix | Delete
EOT;
[240] Fix | Delete
}
[241] Fix | Delete
}
[242] Fix | Delete
[243] Fix | Delete
function html_auth_box($method)
[244] Fix | Delete
{
[245] Fix | Delete
global $lang_update_php, $lang_common, $help;
[246] Fix | Delete
[247] Fix | Delete
$superCage = Inspekt::makeSuperCage();
[248] Fix | Delete
[249] Fix | Delete
if ($superCage->get->keyExists('debug')) {
[250] Fix | Delete
$debug_mode = '?debug';
[251] Fix | Delete
} else {
[252] Fix | Delete
$debug_mode = '';
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
if (function_exists('cpg_fetch_icon')) {
[256] Fix | Delete
$update_icon = cpg_fetch_icon('update_database', 2);
[257] Fix | Delete
$ok_icon = cpg_fetch_icon('ok', 2);
[258] Fix | Delete
$login_icon = cpg_fetch_icon('login', 2);
[259] Fix | Delete
$username_icon = cpg_fetch_icon('my_profile', 2);
[260] Fix | Delete
$password_icon = cpg_fetch_icon('key_enter', 2);
[261] Fix | Delete
} else {
[262] Fix | Delete
$update_icon = '';
[263] Fix | Delete
$ok_icon = '';
[264] Fix | Delete
$login_icon = '';
[265] Fix | Delete
$username_icon = '';
[266] Fix | Delete
$password_icon = '';
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
echo <<< EOT
[270] Fix | Delete
<form name="cpgform" id="cpgform" method="post" action="update.php{$debug_mode}">
[271] Fix | Delete
<table border="0" cellspacing="0" cellpadding="0" class="maintable">
[272] Fix | Delete
<tr>
[273] Fix | Delete
<td class="tableh1" colspan="2">
[274] Fix | Delete
<h1>{$update_icon}{$lang_update_php['welcome_updater']}{$help}</h1>
[275] Fix | Delete
</td>
[276] Fix | Delete
</tr>
[277] Fix | Delete
<tr>
[278] Fix | Delete
<td class="tableh2" colspan="2">
[279] Fix | Delete
<h2>{$login_icon}{$lang_update_php['authentication_needed']}</h2>
[280] Fix | Delete
</td>
[281] Fix | Delete
</tr>
[282] Fix | Delete
<tr>
[283] Fix | Delete
<td class="tableh2" colspan="2">
[284] Fix | Delete
[285] Fix | Delete
EOT;
[286] Fix | Delete
if ($method == 'MySQL') {
[287] Fix | Delete
echo $lang_update_php['could_not_authenticate']. '. '.sprintf($lang_update_php['provide_admin_account_dbase'], $CONFIG['dbname']).'. <a href="update.php">' . $lang_update_php['try_again'] . '</a>.';
[288] Fix | Delete
} else {
[289] Fix | Delete
echo $lang_update_php['provide_admin_account_cpg'].'.';
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
echo <<< EOT
[293] Fix | Delete
</td>
[294] Fix | Delete
</tr>
[295] Fix | Delete
<tr>
[296] Fix | Delete
<td class="tableb">
[297] Fix | Delete
{$username_icon}{$lang_update_php['username']}:
[298] Fix | Delete
</td>
[299] Fix | Delete
<td class="tableb">
[300] Fix | Delete
<input type="text" name="user" size="30" class="textinput" />
[301] Fix | Delete
</td>
[302] Fix | Delete
</tr>
[303] Fix | Delete
<tr>
[304] Fix | Delete
<td class="tableb">
[305] Fix | Delete
{$password_icon}{$lang_update_php['password']}:
[306] Fix | Delete
</td>
[307] Fix | Delete
<td class="tableb">
[308] Fix | Delete
<input type="password" name="pass" size="30" class="textinput" />
[309] Fix | Delete
</td>
[310] Fix | Delete
</tr>
[311] Fix | Delete
<tr>
[312] Fix | Delete
<td class="tableb" colspan="2" align="center">
[313] Fix | Delete
<input type="hidden" name="method" value="{$method}" />
[314] Fix | Delete
<!--<input type="submit" name="submit" value="Login" class="button" />-->
[315] Fix | Delete
<button type="submit" class="button" name="submit" value="{$lang_common['ok']}">{$ok_icon}{$lang_common['ok']}</button>
[316] Fix | Delete
</td>
[317] Fix | Delete
</tr>
[318] Fix | Delete
</table>
[319] Fix | Delete
[320] Fix | Delete
</form>
[321] Fix | Delete
<script language="javascript" type="text/javascript">
[322] Fix | Delete
<!--
[323] Fix | Delete
document.cpgform.user.focus();
[324] Fix | Delete
-->
[325] Fix | Delete
</script>
[326] Fix | Delete
[327] Fix | Delete
EOT;
[328] Fix | Delete
}
[329] Fix | Delete
[330] Fix | Delete
function html_dbase_select ()
[331] Fix | Delete
{
[332] Fix | Delete
global $lang_update_php, $lang_common, $help;
[333] Fix | Delete
[334] Fix | Delete
$superCage = Inspekt::makeSuperCage();
[335] Fix | Delete
[336] Fix | Delete
require_once 'include/dbselect.inc.php';
[337] Fix | Delete
$dbselect = new DbaseSelect(array('mysqli'=>'MYSQLI'.$lang_update_php['recommended'],'pdo:mysql'=>'PDO:MYSQL','mysql'=>'MYSQL'.$lang_update_php['current_nr']));
[338] Fix | Delete
[339] Fix | Delete
if (function_exists('cpg_fetch_icon')) {
[340] Fix | Delete
$ok_icon = cpg_fetch_icon('ok', 2);
[341] Fix | Delete
} else { $update_icon = '';
[342] Fix | Delete
$ok_icon = '';
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
echo <<<EOT
[346] Fix | Delete
<form action="update.php" name="cpgform" id="cpgform" method="post" style="margin:0px;padding:0px">
[347] Fix | Delete
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="maintable">
[348] Fix | Delete
<tr>
[349] Fix | Delete
<td class="tableb" colspan="2">
[350] Fix | Delete
{$lang_update_php['newDbMethod']}<br />
[351] Fix | Delete
</td>
[352] Fix | Delete
</tr>
[353] Fix | Delete
<tr>
[354] Fix | Delete
<td colspan="2">&nbsp;</td>
[355] Fix | Delete
</tr>
[356] Fix | Delete
<tr>
[357] Fix | Delete
<td style="text-align:right;width:50%">Database Type</td>
[358] Fix | Delete
<td><select name="db_type">{$dbselect->options()}</select></td>
[359] Fix | Delete
</tr>
[360] Fix | Delete
<tr>
[361] Fix | Delete
<td colspan="2">&nbsp;</td>
[362] Fix | Delete
</tr>
[363] Fix | Delete
<tr>
[364] Fix | Delete
<td colspan="2" align="center" class="tableh2">
[365] Fix | Delete
<button type="submit" class="button" name="submit" value="{$lang_common['continue']}">{$lang_common['continue']}{$ok_icon}</button>
[366] Fix | Delete
</td>
[367] Fix | Delete
</tr>
[368] Fix | Delete
</table>
[369] Fix | Delete
<input type="hidden" name="action" value="dbselect" />
[370] Fix | Delete
</form>
[371] Fix | Delete
EOT;
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
[375] Fix | Delete
// --------------------------------- MAIN CODE ----------------------------- //
[376] Fix | Delete
function start_update()
[377] Fix | Delete
{
[378] Fix | Delete
global $errors, $notes, $lang_update_php, $LINEBREAK;
[379] Fix | Delete
global $update_icon, $ok_icon, $already_done_icon, $error_icon, $file_system_icon;
[380] Fix | Delete
[381] Fix | Delete
if (!check_db_type()) return;
[382] Fix | Delete
[383] Fix | Delete
// The updater
[384] Fix | Delete
//html_header($lang_update_php['title']);
[385] Fix | Delete
test_sql_connection();
[386] Fix | Delete
[387] Fix | Delete
if (function_exists('cpg_fetch_icon')) {
[388] Fix | Delete
$update_icon = cpg_fetch_icon('update_database', 2);
[389] Fix | Delete
$ok_icon = cpg_fetch_icon('ok', 2);
[390] Fix | Delete
$already_done_icon = cpg_fetch_icon('info', 2);
[391] Fix | Delete
$error_icon = cpg_fetch_icon('stop', 2);
[392] Fix | Delete
$file_system_icon = cpg_fetch_icon('hdd', 2);
[393] Fix | Delete
} else {
[394] Fix | Delete
$update_icon = '';
[395] Fix | Delete
$ok_icon = '';
[396] Fix | Delete
$already_done_icon = '';
[397] Fix | Delete
$error_icon = '';
[398] Fix | Delete
$file_system_icon = '';
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
if ($errors == '') {
[402] Fix | Delete
echo ' <table border="0" cellspacing="0" cellpadding="0" class="maintable" width="100%">' . $LINEBREAK;
[403] Fix | Delete
update_tables();
[404] Fix | Delete
update_files();
[405] Fix | Delete
echo ' </table>' . $LINEBREAK;
[406] Fix | Delete
} else {
[407] Fix | Delete
html_error($errors);
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
if ($errors == '') {
[411] Fix | Delete
html_install_success($notes);
[412] Fix | Delete
session_destroy();
[413] Fix | Delete
} else {
[414] Fix | Delete
html_error($errors);
[415] Fix | Delete
}
[416] Fix | Delete
//html_footer();
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
// Return an array containing config values specified in the array
[420] Fix | Delete
function cpg_get_config_value($config_name)
[421] Fix | Delete
{
[422] Fix | Delete
global $CONFIG;
[423] Fix | Delete
[424] Fix | Delete
$result = cpg_db_query("SELECT value FROM ".$CONFIG['TABLE_PREFIX']."config WHERE name='".$config_name."' LIMIT 1");
[425] Fix | Delete
$row = $result->fetchRow(true);
[426] Fix | Delete
[427] Fix | Delete
return is_array($row) ? $row[0] : null;
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
// ----------------------------- TEST FUNCTIONS ---------------------------- //
[431] Fix | Delete
function check_db_type ()
[432] Fix | Delete
{
[433] Fix | Delete
global $CONFIG;
[434] Fix | Delete
[435] Fix | Delete
if (!isset($CONFIG['dbtype']) || $CONFIG['dbtype'] == 'mysql') {
[436] Fix | Delete
html_dbase_select();
[437] Fix | Delete
return false;
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
return true;
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
function test_sql_connection()
[444] Fix | Delete
{
[445] Fix | Delete
global $errors, $CONFIG, $CPGDB, $lang_update_php;
[446] Fix | Delete
[447] Fix | Delete
if (!isset($CPGDB)) {
[448] Fix | Delete
list($db_ext, $db_sub) = explode(':', $CONFIG['dbtype'].':');
[449] Fix | Delete
$db_ext = $db_ext ?: 'mysql';
[450] Fix | Delete
require 'include/database/'.$db_ext.'/dbase.inc.php';
[451] Fix | Delete
$CPGDB = new CPG_Dbase($CONFIG);
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
if (!$CPGDB->isConnected()) {
[455] Fix | Delete
$errors .= '<hr />';
[456] Fix | Delete
$errors .= sprintf($lang_update_php['dbase_database_error'], $CONFIG['dbname']) . '. ';
[457] Fix | Delete
$errors .= sprintf($lang_update_php['check_config_file'] . '. ', 'include/config.inc.php');
[458] Fix | Delete
$errors .= '<br />';
[459] Fix | Delete
$errors .= sprintf($lang_update_php['dbase_said'], $CPGDB->db_type) . ': ' . $CPGDB->getError();
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
[463] Fix | Delete
[464] Fix | Delete
// ------------------------- SQL QUERIES TO CREATE TABLES ------------------ //
[465] Fix | Delete
function update_tables()
[466] Fix | Delete
{
[467] Fix | Delete
global $errors, $CONFIG, $CPGDB, $lang_update_php, $lang_common, $LINEBREAK, $help;
[468] Fix | Delete
global $update_icon, $ok_icon, $already_done_icon, $error_icon, $file_system_icon;
[469] Fix | Delete
[470] Fix | Delete
$loopCounter = 0;
[471] Fix | Delete
$cellStyle = '';
[472] Fix | Delete
$okerrs = array(1060,1061,1062);
[473] Fix | Delete
$superCage = Inspekt::makeSuperCage();
[474] Fix | Delete
[475] Fix | Delete
$db_update = 'sql/update.sql';
[476] Fix | Delete
$sql_query = fread(fopen($db_update, 'r'), filesize($db_update));
[477] Fix | Delete
// Update table prefix
[478] Fix | Delete
$sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query);
[479] Fix | Delete
//$sql_query = str_replace('{FIRST_USER_CAT}', FIRST_USER_CAT, $sql_query);
[480] Fix | Delete
[481] Fix | Delete
$sql_query = remove_remarks($sql_query);
[482] Fix | Delete
$sql_query = split_sql_file($sql_query, ';');
[483] Fix | Delete
$sql_query = array_map('trim', $sql_query);
[484] Fix | Delete
[485] Fix | Delete
echo <<< EOT
[486] Fix | Delete
<tr>
[487] Fix | Delete
<td class="tableh1" colspan="2">
[488] Fix | Delete
{$update_icon}{$lang_update_php['performing_database_updates']}{$help}
[489] Fix | Delete
</td>
[490] Fix | Delete
</tr>
[491] Fix | Delete
[492] Fix | Delete
EOT;
[493] Fix | Delete
[494] Fix | Delete
// Have to relax the sql modes for mysql 5.7 so it won't fail with zero dates, etc.
[495] Fix | Delete
cpg_db_query("SET SESSION sql_mode = ''");
[496] Fix | Delete
[497] Fix | Delete
foreach ($sql_query as $q) {
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function