[geeklog-cvs] geeklog-1.3/public_html/admin story.php,1.98,1.99
geeklog-cvs-admin at lists.geeklog.net
geeklog-cvs-admin at lists.geeklog.net
Fri Jul 25 06:08:57 EDT 2003
Update of /usr/cvs/geeklog/geeklog-1.3/public_html/admin
In directory geeklog_prod:/tmp/cvs-serv24463
Modified Files:
story.php
Log Message:
Moved story deletion to a function. Also make sure we update the RSS feed and the Older Stories block when deleting stories.
Index: story.php
===================================================================
RCS file: /usr/cvs/geeklog/geeklog-1.3/public_html/admin/story.php,v
retrieving revision 1.98
retrieving revision 1.99
diff -C2 -d -r1.98 -r1.99
*** story.php 6 Jul 2003 13:55:58 -0000 1.98
--- story.php 25 Jul 2003 10:08:55 -0000 1.99
***************
*** 924,927 ****
--- 924,971 ----
}
+ /**
+ * Delete a story from the database.
+ *
+ * @param string $sid id of story to delete
+ * @return string HTML for a redirect to admin/story.php
+ *
+ */
+ function deletestory ($sid)
+ {
+ global $_TABLES, $_CONF;
+
+ $result = DB_query ("SELECT ai_filename FROM {$_TABLES['article_images']} WHERE ai_sid = '$sid'");
+ $nrows = DB_numRows ($result);
+ for ($i = 1; $i <= $nrows; $i++) {
+ $A = DB_fetchArray ($result);
+ $filename = $_CONF['path_html'] . 'images/articles/' . $A['ai_filename'];
+ if (!@unlink ($filename)) {
+ // log the problem but don't abort the script
+ echo COM_errorLog ('Unable to remove the following image from the article: ' . $filename);
+ }
+
+ // remove unscaled image, if it exists
+ $lFilename_large = substr_replace ($A['ai_filename'], '_original.',
+ strrpos ($A['ai_filename'], '.'), 1);
+ $lFilename_large_complete = $_CONF['path_html'] . 'images/articles/'
+ . $lFilename_large;
+ if (file_exists ($lFilename_large_complete)) {
+ if (!@unlink ($lFilename_large_complete)) {
+ // again, log the problem but don't abort the script
+ echo COM_errorLog ('Unable to remove the following image from the article: ' . $lFilename_large_complete);
+ }
+ }
+ }
+ DB_delete ($_TABLES['article_images'], 'ai_sid', $sid);
+ DB_delete ($_TABLES['comments'], 'sid', $sid);
+ DB_delete ($_TABLES['stories'], 'sid', $sid);
+
+ // update RSS feed and Older Stories block
+ COM_exportRDF ();
+ COM_olderStuff ();
+
+ return COM_refresh ($_CONF['site_admin_url'] . '/story.php?msg=10');
+ }
+
// MAIN
***************
*** 930,960 ****
if (!isset ($sid) || empty ($sid) || ($sid == 0)) {
COM_errorLog ('Attempted to delete story sid=' . $sid);
! $display .= COM_refresh ($_CONF['site_admin_url'] . '/story.php');
} else if ($type == 'submission') {
! DB_delete($_TABLES['storysubmission'],'sid',$sid,$_CONF['site_admin_url'] . "/moderation.php");
} else {
! $result = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} WHERE ai_sid = '$sid'");
! $nrows = DB_numRows($result);
! for ($i = 1; $i <= $nrows; $i++) {
! $A = DB_fetchArray($result);
! $filename = $_CONF['path_html'] . 'images/articles/' . $A['ai_filename'];
! if (!@unlink($filename)) {
! echo COM_errorLog('Unable to remove the following image from the article: ' . $filename);
! }
!
! // remove unscaled image, if it exists
! $lFilename_large = substr_replace ($A['ai_filename'], '_original.',
! strrpos ($A['ai_filename'], '.'), 1);
! $lFilename_large_complete = $_CONF['path_html'] . 'images/articles/'
! . $lFilename_large;
! if (file_exists ($lFilename_large_complete)) {
! if (!@unlink ($lFilename_large_complete)) {
! echo COM_errorLog ('Unable to remove the following image from the article: ' . $lFilename_large_complete);
! }
! }
! }
! DB_delete($_TABLES['article_images'],'ai_sid',$sid);
! DB_delete($_TABLES['comments'],'sid',$sid);
! DB_delete($_TABLES['stories'],'sid',$sid,$_CONF['site_admin_url'] . "/story.php?msg=10");
}
} else if (($mode == $LANG24[9]) && !empty ($LANG24[9])) { // preview
--- 974,983 ----
if (!isset ($sid) || empty ($sid) || ($sid == 0)) {
COM_errorLog ('Attempted to delete story sid=' . $sid);
! echo COM_refresh ($_CONF['site_admin_url'] . '/story.php');
} else if ($type == 'submission') {
! DB_delete ($_TABLES['storysubmission'], 'sid', $sid,
! $_CONF['site_admin_url'] . '/moderation.php');
} else {
! echo deletestory ($sid);
}
} else if (($mode == $LANG24[9]) && !empty ($LANG24[9])) { // preview
More information about the geeklog-cvs
mailing list