SetTemplate("../../admin/templates/pageheader.install");
doTemplate();
}
function PageFooter()
{
$GLOBALS["AL_CLASS_TEMPLATE"]->SetTemplate("../../admin/templates/pagefooter.install");
doTemplate();
}
function doTemplate(){
ob_start();
echo $GLOBALS["AL_CLASS_TEMPLATE"]->ParseTemplate();
$tmp = ob_get_contents();
ob_end_clean();
$tmp =str_replace('images/','admin/images/',$tmp);
$tmp =str_replace('styles/','admin/styles/',$tmp);
echo $tmp;
}
PageHeader();
// dont' start straight away, let the user know what will happen and give them a "start" button
$filename = "NX.1.5.update.php";
if(!isset($_POST['step'])){
// default it
?>
Add the column 'CatPass' to the categories table in order to allow
for password protected categories
Alter your Contact Us page to fix a bug with it either not being in
the database or not working
If you know your contact page is already working fine, have received a
fix or have altered it to function, uncheck the box below. If you are not sure, and haven't altered your contact page, leave it checked.
Adding Index to database which should speed up the front page on sites with large number of articles
";
}else{
header("Location: ".$filename);
}
?>
}elseif (isset($_POST['step']) && $_POST['step'] == '3'){
$error = false;
if($_POST['version'] == "nx1"){
if($_POST['fixDB'] == 'true'){
// check for the Catpass column
$result = mysql_query(sprintf("SHOW COLUMNS FROM %scategories",$GLOBALS["AL_CFG"]["tablePrefix"]));
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$pass = false;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
if($row['Field'] == 'catPass'){
$pass = true;
break;
}
}
}
// already there, spit out an error
if($pass == true){
echo "
Error: The column catPass already exists, have you already run the update script?
";
$error = true;
}else{
// not there, add it
mysql_query(sprintf("ALTER TABLE `%scategories` ADD `catPass` VARCHAR( 255 ) NOT NULL",$GLOBALS["AL_CFG"]["tablePrefix"]));
echo "
Added Category Password column. ".mysql_error()."
";
}
}
// check if they said to fix the contact page
if($_POST['fixcontact'] == 'true'){
// locate the contact page via title
$query = mysql_query(sprintf("select * from %spages where Title='Contact Us' and Type='2'",$GLOBALS["AL_CFG"]["tablePrefix"]));
if(mysql_num_rows($query) > 0){
// does exist, modify it
if(mysql_query(sprintf("update `%spages` set Content='
' where Title='Contact Us' and Type='2'",$GLOBALS["AL_CFG"]["tablePrefix"]))){
echo "
Updated contact form success
";
}else{
$error = true;
echo "
Error: Update contact form error ".mysql_error()."
Error: Insert contact form error ".mysql_error()."
";
}
}
}
}elseif($_POST['version'] == "nx3"){
$sql = sprintf("create index idx_order on %sarticles(StartDate, ArticleID)",$GLOBALS["AL_CFG"]["tablePrefix"]);
mysql_query($sql);
if(mysql_error() != ""){
if(mysql_error() == "Duplicate key name 'idx_order'"){
$error = true;
echo "
An Error has Occurred: You have already run this upgrade script. The database is reporting the Index exists!";
echo " ";
echo " ";
}else{
$error = true;
echo "
An Error has Occurred: ";
echo mysql_error();
echo " ";
echo " ";
}
}else{
$error = false;
}
}else{
header("Location: ".$filename);
}
if($error == true){
// if failure, tell them to email interspire
echo "
Errors were encountered while updating your copy of ArticleLive. Please contact Interspire Support for assistance.
";
}else{
// if success, tell them to delete the update file
echo "
The update was successful! For security, please delete this upgrade script from your website. (Filename: ".$filename.")