Skip to content

Instantly share code, notes, and snippets.

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).
Copyright notice
(c) 2002-2011 Oliver Georgi ( // 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
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
@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']);
$phpwcms = array();
define( 'ROOT', rtrim( str_replace("\\", '/', dirname(__FILE__) ), '/' ) . '/' );
// newer phpwcms
if(is_file(ROOT.'config/phpwcms/')) {
require_once (ROOT.'config/phpwcms/');
} elseif(is_file(ROOT.'include/inc_conf/')) {
require_once (ROOT.'include/inc_conf/');
} else {
die('SORRY: cannot run the script');
require_once (ROOT.'include/inc_lib/');
if(!isset($db)) {
require_once (PHPWCMS_ROOT.'/include/inc_lib/');
$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=";t=20949">Visit phpwcms forum for more information</a></p>';
echo '<hr /><p>Copyright &copy; 2011 Oliver Georgi, <a href=""></a></p></body></html>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment