Skip to content

Instantly share code, notes, and snippets.

@slackero
Created July 19, 2016 16:09
Show Gist options
  • Save slackero/2697518b1ae6b58d79e81f2dba15eb4a to your computer and use it in GitHub Desktop.
Save slackero/2697518b1ae6b58d79e81f2dba15eb4a to your computer and use it in GitHub Desktop.
Articles in phpwcms auto expired by December 31, 2010? Then use this script to fix the article kill date (and the historical bug).
<?php
/*************************************************************************************
Copyright notice
(c) 2002-2011 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
This script is part of PHPWCMS. The PHPWCMS web content management system 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.
The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
A copy is found in the textfile GPL.txt and important notices to the license
from the author is found in LICENSE.txt distributed with these scripts.
This script 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.
This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/
// Patch to fix the fixed article end date problem
/* CP based
[PHP]
@mysql_query("UPDATE ".DB_PREPEND."phpwcms_article SET article_tstamp=article_tstamp, article_end='2030-12-31 23:59:59' WHERE article_end='2010-12-31 23:59:59' AND article_deleted=0", $GLOBALS['db']);
[/PHP]
*/
$phpwcms = array();
define( 'ROOT', rtrim( str_replace("\\", '/', dirname(__FILE__) ), '/' ) . '/' );
// newer phpwcms
if(is_file(ROOT.'config/phpwcms/conf.inc.php')) {
require_once (ROOT.'config/phpwcms/conf.inc.php');
} elseif(is_file(ROOT.'include/inc_conf/conf.inc.php')) {
require_once (ROOT.'include/inc_conf/conf.inc.php');
} else {
die('SORRY: cannot run the script');
}
require_once (ROOT.'include/inc_lib/default.inc.php');
if(!isset($db)) {
require_once (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php');
}
$sql = "SELECT article_id FROM ".DB_PREPEND."phpwcms_article WHERE article_end='2010-12-31 23:59:59' AND article_deleted=0";
$result = mysql_query($sql, $db);
$total = mysql_num_rows($result);
echo '<html><head><title>Fix phpwcms fixed article end date</head><body>';
echo '<h1>Update '.$total.' articles with new fixed date</h1>';
$sql = "UPDATE ".DB_PREPEND."phpwcms_article SET ";
$sql .= "article_tstamp=article_tstamp, "; // keep article timestamp
$sql .= "article_end='2030-12-31 23:59:59' ";
$sql .= "WHERE article_end='2010-12-31 23:59:59' AND article_deleted=0";
echo '<p>The following command is used to correct your articles having false fixed article end dates.</p>';
echo '<code>'.$sql.';</code>';
if($total) {
@mysql_query($sql, $db);
echo '<p><b>Done!</b> Visit your <a href="'.$phpwcms["site"].$phpwcms["root"].'" target="_blank">website</a> and check if all is fine again</p>';
} else {
echo '<p><b>Fine!</b> It seems your <a href="'.$phpwcms["site"].$phpwcms["root"].'" target="_blank">website</a> is not touched by the problem (or got fixed).</p>';
}
echo '<p><a href="http://forum.phpwcms.org/viewtopic.php?f=3&amp;t=20949">Visit phpwcms forum for more information</a></p>';
echo '<hr /><p>Copyright &copy; 2011 Oliver Georgi, <a href="http://www.phpwcms.de">www.phpwcms.de</a></p></body></html>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment