if (!checkFormToken()) { cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__); } if ($CONFIG['enable_plugins']) { $installed = CPGPluginAPI::install($p); } else { cpgRedirectPage('pluginmgr.php', $lang_pluginmgr_php['pmgr'], $lang_pluginmgr_php['plugin_disabled_note']); } break; case 'delete': if (!checkFormToken()) { cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__); } $path = $p; if (is_bool(strpos('/', $path))) { cpg_folder_file_delete('./plugins/' . $path); if ($CONFIG['log_mode']) { log_write("Plugin '" . $path . "' deleted", CPG_GLOBAL_LOG); } } break; case 'moveu': if (!checkFormToken()) { cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__); } $name = $installed_plugin['name']; unset($installed_plugin); unset($priority); $plugin_id = $p; if ($CONFIG['enable_plugins'] == 1) { $thisplugin = @$CPG_PLUGINS[$plugin_id];
/** * Function used to delete a folder and everything within it except symlinks. * Does not perform any checks against the path parameter, so only perform * this function against trusted, validated paths and never against un-sanitized * user input! * Function should be performed by admin only, but is not limited to admin. There * are no particular permission-checks. * Contains hard-coded English language strings that are meant for debug output only. * @param $path full-path or relative path to folder * @return array(success(T)/failure(F), debug output) */ function cpg_folder_file_delete($path) { global $CONFIG; if ($CONFIG['debug_notice'] == 0) { $output = ''; } else { if ($CONFIG['debug_mode'] == 1) { $output = 1; } elseif ($CONFIG['debug_mode'] == 2 && defined(GALLERY_ADMIN_MODE)) { $output = 1; } else { $output = ''; } } // Perform some validity checks first rtrim($path, '/'); // if the path has a trailing slash we remove it here if (is_link($path)) { // We don't want to delete symlinks, so let's just return some text if ($output != '') { return array(false, $path . ' appears to be a symlink - we won\'t delete them for security reasons'); } else { return array(false, ''); } } if (!file_exists($path) && !is_dir($path)) { // if the path is not valid if ($output != '') { return array(false, 'Path ' . $path . ' does not exist'); } else { return array(false, ''); } } elseif (!is_readable($path)) { // ... if the path is not readable if ($output != '') { return array(false, 'Path ' . $path . ' is not readable'); } else { return array(false, ''); } } if (is_dir($path)) { if (version_compare(PHP_VERSION, '5.0.0') < 0) { $entries = array(); if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { $entries[] = $file; } closedir($handle); } } else { $entries = scandir($path); if ($entries === false) { $entries = array(); } } foreach ($entries as $entry) { if ($entry != '.' && $entry != '..') { cpg_folder_file_delete($path . '/' . $entry); } } // Delete the folder if ($output != '') { $result = rmdir($path); } else { $result = @rmdir($path); } if ($result == 1) { // We have issued the command to delete the folder and everything // appears to have gone fine, but we can not be sure if we succeeded, // so we'll test if the folder still is there. clearstatcache(); // We need to clear the cache before we check if the folder is still there. if (is_dir($path)) { $debug_output = 'Couldn\'t delete folder ' . $path . '. Review permissions!'; $success = false; } else { $debug_output = 'Folder deleted successfully'; $success = true; } } else { $debug_output = 'Couldn\'t delete folder ' . $path . '. Review permissions!'; $success = false; } if ($output != '') { return array($success, $debug_output); } else { return array($success, ''); } } else { // Delete the file if ($output != '') { $result = unlink($path); } else { $result = @unlink($path); } if ($result == 1) { // We have issued the command to delete the file and everything // appears to have gone fine, but we can not be sure if we succeeded, // so we'll test if the file still is there. clearstatcache(); // We need to clear the cache first. if (file_exists($path)) { $debug_output = 'Couldn\'t delete file ' . $path . '. Review permissions!'; $success = false; } else { $debug_output = 'File deleted successfully'; $success = true; } } else { $debug_output = 'Couldn\'t delete file ' . $path . '. Review permissions!'; $success = false; } if ($output != '') { return array($success, $debug_output); } else { return array($success, ''); } } }
function update_system_thumbs() { global $CONFIG, $lang_update_php, $lang_common, $ok_icon, $already_done_icon, $error_icon; $results = mysql_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}config;"); while ($row = mysql_fetch_array($results)) { $CONFIG[$row['name']] = $row['value']; } // while mysql_free_result($results); // Code to rename system thumbs in images folder $default_thumb_pfx = 'thumb_'; if ($default_thumb_pfx != $CONFIG['thumb_pfx']) { $THEME_DIR = 'themes/' . $CONFIG['theme'] . '/'; $folders = array('images/thumbs/', $THEME_DIR . 'images/'); $loopCounter = 0; foreach ($folders as $folder) { $thumbs = cpg_get_system_thumb_list($folder); foreach ($thumbs as $thumb) { $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate'; $rename_file_from = $folder . $thumb['filename']; $rename_file_to = $folder . str_replace($default_thumb_pfx, $CONFIG['thumb_pfx'], $thumb['filename']); $rename_output = sprintf($lang_update_php['rename_file'], '«<tt>' . $rename_file_from . '</tt>»', '«<tt>' . $rename_file_to . '</tt>»'); echo <<<EOT <tr> <td class="{$cellStyle}"> {$rename_output} </td> EOT; if (file_exists($rename_file_to)) { $result_output = $already_done_icon . $lang_update_php['already_done']; echo <<<EOT <td class="{$cellStyle}"> {$result_output} </td> </tr> EOT; $loopCounter++; if ($rename_file_from == $rename_file_to) { continue; } $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate'; $delete_file = $rename_file_from; $delete_output = sprintf($lang_update_php['delete_file'], '«<tt>' . $delete_file . '</tt>»'); echo <<<EOT <tr> <td class="{$cellStyle}"> {$delete_output} </td> EOT; if (!file_exists($delete_file)) { $result_output = $already_done_icon . $lang_update_php['already_done']; } else { list($delete_result, $debug_output) = cpg_folder_file_delete($delete_file); if ($delete_result == TRUE) { $result_output = $ok_icon . $lang_common['ok']; } else { $result_output = $error_icon . $lang_update_php['could_not_delete']; } } echo <<<EOT <td class="{$cellStyle}"> {$result_output} </td> </tr> EOT; $loopCounter++; continue; } else { $rename_result = @rename($rename_file_from, $rename_file_to); if ($rename_result == TRUE) { $result_output = $ok_icon . $lang_common['ok']; } else { $result_output = $error_icon . $lang_update_php['could_not_rename']; } } echo <<<EOT <td class="{$cellStyle}"> {$result_output} </td> </tr> EOT; $loopCounter++; } // foreach $thumbs } // foreach $folders } // if different thumb_pfx /* // Unnecessary for 1.5 since these thumbs are included with the system thumbs above // If old images for nopic.jpg and private.jpg exist, delete the new ones if (file_exists('images/nopic.jpg')) { cpg_folder_file_delete('images/thumb_nopic.jpg'); @rename('images/nopic.jpg', 'images/' . $CONFIG['thumb_pfx'] . 'nopic.jpg'); } if (file_exists('images/private.jpg')) { cpg_folder_file_delete('images/thumb_private.jpg'); @rename('images/private.jpg', 'images/' . $CONFIG['thumb_pfx'] . 'private.jpg'); } */ }
foreach ($success_array as $key) { cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET histogram_filesize='0', histogram_timestamp='0' WHERE pid='{$key}'"); } } elseif ($CONFIG['plugin_enlargeit_cachecontrol'] == '2') { // Garbage collection by maximum storage $result = cpg_db_query("SELECT SUM(histogram_filesize) AS sum_histogram FROM {$CONFIG['TABLE_PICTURES']} WHERE histogram_filesize>'0'"); $row = mysql_fetch_assoc($result); $cache_sum = $row['sum_histogram']; mysql_free_result($result); $result = cpg_db_query("SELECT pid, filepath, filename, histogram_filesize, histogram_timestamp FROM {$CONFIG['TABLE_PICTURES']} WHERE histogram_filesize<>'0' ORDER BY histogram_timestamp ASC"); $success_array = array(); if (mysql_num_rows($result)) { $success_array = array(); while ($data = mysql_fetch_assoc($result)) { if ($CONFIG['plugin_enlargeit_cachemaxsizemb'] * 1048576 < $cache_sum) { // 1048576 $delete = cpg_folder_file_delete($CONFIG['fullpath'] . $data['filepath'] . 'histogram_' . str_replace('.' . ltrim(substr($data['filename'], strrpos($data['filename'], '.')), '.'), '', $data['filename']) . '.png'); clearstatcache(); if (file_exists($CONFIG['fullpath'] . $data['filepath'] . 'histogram_' . str_replace('.' . ltrim(substr($data['filename'], strrpos($data['filename'], '.')), '.'), '', $data['filename']) . '.png') != TRUE) { $success_array[] = $data['pid']; $cache_sum = $cache_sum - $data['histogram_filesize']; } } } } mysql_free_result($result); foreach ($success_array as $key) { cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET histogram_filesize='0', histogram_timestamp='0' WHERE pid='{$key}'"); } } }
function enlargeit_uninstall() { global $CONFIG; $superCage = Inspekt::makeSuperCage(); if (!checkFormToken()) { global $lang_errors; cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__); } // Delete the histogram cache $result = cpg_db_query("SELECT filepath, filename FROM {$CONFIG['TABLE_PICTURES']} WHERE histogram_filesize<>'0'"); if (mysql_num_rows($result)) { while ($data = mysql_fetch_assoc($result)) { $delete = cpg_folder_file_delete($CONFIG['fullpath'] . $data['filepath'] . 'histogram_' . str_replace('.' . ltrim(substr($data['filename'], strrpos($data['filename'], '.')), '.'), '', $data['filename']) . '.png'); print $CONFIG['fullpath'] . $data['filepath'] . 'histogram_' . str_replace('.' . ltrim(substr($data['filename'], strrpos($data['filename'], '.')), '.'), '', $data['filename']) . '.png<br />'; } } mysql_free_result($result); // Delete the plugin config records cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_brdsize'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_brdround'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_brdcolor'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_shadow'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_shadowsize'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_shadowintens'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_shadowcolor'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_ani'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_maxstep'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_speed'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_titlebar'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_titletxtcol'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_ajaxcolor'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_center'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_dark'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_darkprct'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonpic'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttoninfo'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonfav'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttoncomment'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttondownload'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonbbcode'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonhist'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonvote'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonclose'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_buttonnav'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_adminmode'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_registeredmode'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_guestmode'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_sefmode'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_pictype'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_dragdrop'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_wheelnav'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_flvplayer'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_opaglide'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_brdbck'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_darkensteps'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_adminmenu'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_cachecontrol'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_cachemaxage'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_cachemaxsizemb'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_maximizemethod'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_img_types'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_enlargeit_mov_types'"); cpg_db_query("ALTER TABLE `{$CONFIG['TABLE_PICTURES']}` DROP `histogram_filesize`"); cpg_db_query("ALTER TABLE `{$CONFIG['TABLE_PICTURES']}` DROP `histogram_timestamp`"); return true; }
function fetchcontent_uninstall() { global $CONFIG; // Delete the plugin config records cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_image_denied'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_check_referer'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_domainlist'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_enable_logging'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_non_image'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_debug'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_max_cols'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_max_rows'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_hide_location'"); cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = 'plugin_fetchcontent_cachefolder'"); // Delete temporary files $loopCounter = 0; $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}plugin_fetchcontent"); while ($row = mysql_fetch_assoc($result)) { cpg_folder_file_delete($CONFIG['fullpath'] . $CONFIG['plugin_fetchcontent_cachefolder'] . $row['filepath']); $loopCounter++; } // Delete temporary folder @rmdir($CONFIG['fullpath'] . $CONFIG['plugin_fetchcontent_cachefolder']); // Drop the temporary files table $query = "DROP TABLE IF EXISTS {$CONFIG['TABLE_PREFIX']}plugin_fetchcontent"; cpg_db_query($query); return true; }
<h1>{$lang_plugin_thumb_rotate['empty_cache']}</h1> EOT; $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}plugin_thumb_rotate LIMIT {$records_processed_per_pageload}"); $loopCounter = 0; while ($row = mysql_fetch_assoc($result)) { $delete_array[$row['pid']] = $row['filepath']; } mysql_free_result($result); foreach ($delete_array as $key => $value) { if ($loopCounter / 2 == floor($loopCounter / 2)) { $cellstyle = 'tableb'; } else { $cellstyle = 'tableb tableb_alternate'; } if (is_file($CONFIG['fullpath'] . $value)) { $delete = cpg_folder_file_delete($CONFIG['fullpath'] . $value); } $result = cpg_db_query("DELETE FROM {$CONFIG['TABLE_PREFIX']}plugin_thumb_rotate WHERE `pid` = {$key}"); echo '<div class="' . $cellstyle . '">'; if (file_exists($CONFIG['fullpath'] . $value)) { echo $thumb_rotate_icon_array['cancel']; } else { echo $thumb_rotate_icon_array['ok']; } echo $CONFIG['fullpath'] . $value . '</div>'; $loopCounter++; } echo <<<EOT <a name="result"></a> <br /> {$message_output}
function thumb_rotate_empty_cache() { global $CONFIG; $loopCounter = 0; $result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}plugin_thumb_rotate"); while ($row = mysql_fetch_assoc($result)) { cpg_folder_file_delete($CONFIG['fullpath'] . $row['filepath']); $loopCounter++; } cpg_db_query("TRUNCATE TABLE `{$CONFIG['TABLE_PREFIX']}plugin_thumb_rotate`"); return $loopCounter; }