/** * Delete a feed's file * * @param string filename (without the path) of the feed * @return void * */ function deleteFeedFile($filename) { if (!empty($filename)) { $feedfile = SYND_getFeedPath($filename); if (file_exists($feedfile)) { @unlink($feedfile); } } }
/** * Tells a plugin to uninstall itself. * * @param string $type Plugin to uninstall * @return boolean Returns true on success otherwise false * @link http://wiki.geeklog.net/index.php/Plugin_Auto-Uninstall * */ function PLG_uninstall($type) { global $_PLUGINS, $_TABLES; if (empty($type)) { return false; } if (function_exists('plugin_autouninstall_' . $type)) { COM_errorLog("Auto-uninstalling plugin {$type}:", 1); $function = 'plugin_autouninstall_' . $type; $remvars = $function(); if (empty($remvars) || $remvars == false) { return false; } // removing tables if (isset($remvars['tables'])) { $num_tables = count($remvars['tables']); } else { $num_tables = 0; } for ($i = 0; $i < $num_tables; $i++) { if (isset($_TABLES[$remvars['tables'][$i]])) { COM_errorLog("Dropping table {$_TABLES[$remvars['tables'][$i]]}", 1); DB_query("DROP TABLE {$_TABLES[$remvars['tables'][$i]]}", 1); COM_errorLog('...success', 1); } } // removing variables if (isset($remvars['vars'])) { $num_vars = count($remvars['vars']); } else { $num_vars = 0; } for ($i = 0; $i < $num_vars; $i++) { COM_errorLog("Removing variable {$remvars['vars'][$i]}", 1); DB_delete($_TABLES['vars'], 'name', $remvars['vars'][$i]); COM_errorLog('...success', 1); } // removing groups if (isset($remvars['groups'])) { $num_groups = count($remvars['groups']); } else { $num_groups = 0; } for ($i = 0; $i < $num_groups; $i++) { $grp_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = '{$remvars['groups'][$i]}'"); if (!empty($grp_id)) { COM_errorLog("Attempting to remove the {$remvars['groups'][$i]} group", 1); DB_delete($_TABLES['groups'], 'grp_id', $grp_id); COM_errorLog('...success', 1); COM_errorLog("Attempting to remove the {$remvars['groups'][$i]} group from all groups.", 1); DB_delete($_TABLES['group_assignments'], 'ug_main_grp_id', $grp_id); COM_errorLog('...success', 1); } } // removing features if (isset($remvars['features'])) { $num_features = count($remvars['features']); } else { $num_features = 0; } for ($i = 0; $i < $num_features; $i++) { SEC_removeFeatureFromDB($remvars['features'][$i]); } // uninstall feeds $sql = "SELECT filename FROM {$_TABLES['syndication']} WHERE type = '{$type}';"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { COM_errorLog('removing feed files', 1); COM_errorLog($nrows . ' files stored in table.', 1); for ($i = 0; $i < $nrows; $i++) { $fcount = $i + 1; $A = DB_fetchArray($result); $fullpath = SYND_getFeedPath($A[0]); if (file_exists($fullpath)) { unlink($fullpath); COM_errorLog("removed file {$fcount} of {$nrows}: {$fullpath}", 1); } else { COM_errorLog("cannot remove file {$fcount} of {$nrows}, it does not exist! ({$fullpath})", 1); } } COM_errorLog('...success', 1); // Remove Links Feeds from syndiaction table COM_errorLog('removing links feeds from table', 1); DB_delete($_TABLES['syndication'], 'type', $type); COM_errorLog('...success', 1); } // remove comments for this plugin COM_errorLog("Attempting to remove comments for {$type}", 1); DB_delete($_TABLES['comments'], 'type', $type); COM_errorLog('...success', 1); // uninstall php-blocks if (isset($remvars['php_blocks'])) { $num_blocks = count($remvars['php_blocks']); } else { $num_blocks = 0; } for ($i = 0; $i < $num_blocks; $i++) { DB_delete($_TABLES['blocks'], array('type', 'phpblockfn'), array('phpblock', $remvars['php_blocks'][$i])); } // remove config table data for this plugin COM_errorLog("Attempting to remove config table records for group_name: {$type}", 1); DB_delete($_TABLES['conf_values'], 'group_name', $type); COM_errorLog('...success', 1); // remove topic assignment table data for this plugin COM_errorLog("Attempting to remove topic assignments table records for {$type}", 1); DB_delete($_TABLES['topic_assignments'], 'type', $type); COM_errorLog('...success', 1); // uninstall the plugin COM_errorLog("Attempting to unregister the {$type} plugin from Geeklog", 1); DB_delete($_TABLES['plugins'], 'pi_name', $type); COM_errorLog('...success', 1); COM_errorLog("Finished uninstalling the {$type} plugin.", 1); return true; } else { $retval = PLG_callFunctionForOnePlugin('plugin_uninstall_' . $type); if ($retval === true) { $plg = array_search($type, $_PLUGINS); if ($plg !== false) { unset($_PLUGINS[$plg]); } return true; } } return false; }
/** * Tells a plugin to uninstall itself. * * @param string $type Plugin to uninstall * @return boolean Returns true on success otherwise false * */ function PLG_uninstall($type) { global $_CONF, $_PLUGINS, $_TABLES; if (empty($type)) { return false; } if (function_exists('plugin_autouninstall_' . $type)) { COM_errorLog("Auto-uninstalling plugin {$type}:", 1); $function = 'plugin_autouninstall_' . $type; $remvars = $function(); if (empty($remvars) || $remvars == false) { return false; } // removing tables for ($i = 0; $i < count($remvars['tables']); $i++) { COM_errorLog("Dropping table {$_TABLES[$remvars['tables'][$i]]}", 1); DB_query("DROP TABLE {$_TABLES[$remvars['tables'][$i]]}", 1); COM_errorLog('...success', 1); } // removing variables for ($i = 0; $i < count($remvars['vars']); $i++) { COM_errorLog("Removing variable {$remvars['vars'][$i]}", 1); DB_delete($_TABLES['vars'], 'name', $remvars['vars'][$i]); COM_errorLog('...success', 1); } // removing groups for ($i = 0; $i < count($remvars['groups']); $i++) { $grp_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = '{$remvars['groups'][$i]}'"); if (!empty($grp_id)) { COM_errorLog("Attempting to remove the {$remvars['groups'][$i]} group", 1); DB_delete($_TABLES['groups'], 'grp_id', $grp_id); COM_errorLog('...success', 1); COM_errorLog("Attempting to remove the {$remvars['groups'][$i]} group from all groups.", 1); DB_delete($_TABLES['group_assignments'], 'ug_main_grp_id', $grp_id); COM_errorLog('...success', 1); } } // removing features for ($i = 0; $i < count($remvars['features']); $i++) { $access_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '{$remvars['features'][$i]}'"); if (!empty($access_id)) { COM_errorLog("Attempting to remove {$remvars['features'][$i]} rights from all groups", 1); DB_delete($_TABLES['access'], 'acc_ft_id', $access_id); COM_errorLog('...success', 1); COM_errorLog("Attempting to remove the {$remvars['features'][$i]} feature", 1); DB_delete($_TABLES['features'], 'ft_name', $remvars['features'][$i]); COM_errorLog('...success', 1); } } // uninstall feeds $sql = "SELECT filename FROM {$_TABLES['syndication']} WHERE type = '{$type}';"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { COM_errorLog('removing feed files', 1); COM_errorLog($nrows . ' files stored in table.', 1); for ($i = 0; $i < $nrows; $i++) { $fcount = $i + 1; $A = DB_fetchArray($result); $fullpath = SYND_getFeedPath($A[0]); if (file_exists($fullpath)) { unlink($fullpath); COM_errorLog("removed file {$fcount} of {$nrows}: {$fullpath}", 1); } else { COM_errorLog("cannot remove file {$fcount} of {$nrows}, it does not exist! ({$fullpath})", 1); } } COM_errorLog('...success', 1); // Remove Links Feeds from syndiaction table COM_errorLog('removing links feeds from table', 1); DB_delete($_TABLES['syndication'], 'type', $type); COM_errorLog('...success', 1); } // remove comments for this plugin COM_errorLog("Attempting to remove comments for {$type}", 1); DB_delete($_TABLES['comments'], 'type', $type); COM_errorLog('...success', 1); // uninstall php-blocks for ($i = 0; $i < count($remvars['php_blocks']); $i++) { DB_delete($_TABLES['blocks'], array('type', 'phpblockfn'), array('phpblock', $remvars['php_blocks'][$i])); } // remove autotag permissions DB_query("DELETE {$_TABLES['autotag_perm']}.*, {$_TABLES['autotag_usage']}.* FROM {$_TABLES['autotag_perm']} JOIN {$_TABLES['autotag_usage']} ON {$_TABLES['autotag_perm']}.autotag_id={$_TABLES['autotag_usage']}.autotag_id WHERE {$_TABLES['autotag_perm']}.autotag_namespace='" . $type . "'"); DB_delete($_TABLES['autotag_usage'], 'usage_namespace', $type); // remove config table data for this plugin COM_errorLog("Attempting to remove config table records for group_name: {$type}", 1); require_once $_CONF['path_system'] . 'classes/config.class.php'; $c = config::get_instance(); if ($c->group_exists($type)) { $c->delGroup($type); } COM_errorLog('...success', 1); // remove any rating data for the plugin COM_errorLog("Attempting to remove rating table records for type: {$type}", 1); DB_query("DELETE FROM {$_TABLES['rating']} WHERE type='" . $type . "'"); DB_query("DELETE FROM {$_TABLES['rating_votes']} WHERE type='" . $type . "'"); COM_errorLog('...success', 1); // uninstall the plugin COM_errorLog("Attempting to unregister the {$type} plugin from glFusion", 1); DB_delete($_TABLES['plugins'], 'pi_name', $type); COM_errorLog('...success', 1); COM_errorLog("Finished uninstalling the {$type} plugin.", 1); return true; } else { $retval = PLG_callFunctionForOnePlugin('plugin_uninstall_' . $type); if ($retval === true) { $plg = array_search($type, $_PLUGINS); if ($plg !== false) { unset($_PLUGINS[$plg]); } return true; } } return false; }
/** * Get the URL of the feed directory or a specific feed file * * @param string $feedfile (option) feed file name * @return string URL of feed directory or file * */ function MG_getFeedUrl($feedfile = '') { global $_CONF; $feedpath = SYND_getFeedPath(); $url = substr_replace($feedpath, $_CONF['site_url'], 0, strlen($_CONF['path_html']) - 1); $url .= $feedfile; return $url; }
/** * Delete a feed. * * @param int $fid feed id * @return string HTML redirect * */ function FEED_delete($fid) { global $_CONF, $_TABLES; if ($fid > 0) { $feedfile = DB_getItem($_TABLES['syndication'], 'filename', "fid = {$fid}"); if (!empty($feedfile)) { @unlink(SYND_getFeedPath($feedfile)); } DB_delete($_TABLES['syndication'], 'fid', $fid); CACHE_remove_instance('story'); COM_setMessage(59); return COM_refresh($_CONF['site_admin_url'] . '/syndication.php'); } return COM_refresh($_CONF['site_admin_url'] . '/syndication.php'); }
/** * Fix the character set of a default feed file which is hard-coded as 'iso-8859-1'. * * @param int $fid feed id */ function SYND_fixCharset($fid) { global $_CONF, $_TABLES, $_SYND_DEBUG; $sql = "SELECT COUNT(filename) AS cnt " . "FROM {$_TABLES['syndication']} " . "WHERE (fid = {$fid}) AND (filename = 'geeklog.rss') " . "AND (charset = 'iso-8859-1')"; $result = DB_query($sql); if ($result !== false) { list($cnt) = DB_fetchArray($result); if ($cnt == 1) { $fileName = SYND_getFeedPath('geeklog.rss'); clearstatcache(); if (@filesize($fileName) === 0) { $charset = DB_escapeString(COM_getCharset()); $sql = "UPDATE {$_TABLES['syndication']} " . "SET charset = '{$charset}' " . "WHERE (fid = {$fid})"; DB_query($sql); } } } }