Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined #3

Open
seansan opened this issue Mar 4, 2013 · 0 comments
Open

Combined #3

seansan opened this issue Mar 4, 2013 · 0 comments

Comments

@seansan
Copy link

seansan commented Mar 4, 2013

This is what we made of it, but I must say it finishes so quick that I am not sure i it actually works.

Let me know if this helps

global->resources->default_setup->connection->host; $db['name'] = $xml->global->resources->default_setup->connection->dbname; $db['user'] = $xml->global->resources->default_setup->connection->username; $db['pass'] = $xml->global->resources->default_setup->connection->password; $db['pref'] = $xml->global->resources->db->table_prefix; if($_GET['clean'] == 'log') clean_log_tables(); if($_GET['clean'] == 'var') clean_var_directory(); echo "----------------------- CLEANUP START -------------------------
"; $start = (float) array_sum(explode(' ',microtime())); echo "
**************\* SETTING PERMISSIONS ***************
"; clean_log_tables(); clean_var_directory(); $end = (float) array_sum(explode(' ',microtime())); echo "
------------------- CLEANUP COMPLETED in:". sprintf("%.4f", ($end-$start))." seconds ------------------
"; function clean_log_tables() { global $db; ``` $tables = array( 'dataflow_batch_export', 'dataflow_batch_import', 'log_customer', 'log_quote', 'log_summary', 'log_summary_type', 'log_url', 'log_url_info', 'log_visitor', 'log_visitor_info', 'log_visitor_online', 'index_event', 'report_event', 'report_compared_product_index', 'report_viewed_product_index', 'catalog_compare_item', 'catalogindex_aggregation', 'catalogindex_aggregation_tag', 'catalogindex_aggregation_to_tag' ); mysql_connect($db['host'], $db['user'], $db['pass']) or die(mysql_error()); mysql_select_db($db['name']) or die(mysql_error()); foreach($tables as $v => $k) { @mysql_query('TRUNCATE `'.$db['pref'].$k.'`'); echo "Cleaned table: $k
"; flush(); } ``` } ## Function to clean out the contents of specified directory function cleandir($dir) { ``` if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && is_file($dir.'/'.$file)) { if (unlink($dir.'/'.$file)) { } else { echo $dir . '/' . $file . ' (file) NOT deleted!
'; } } else if ($file != '.' && $file != '..' && is_dir($dir.'/'.$file)) { cleandir($dir.'/'.$file); if (rmdir($dir.'/'.$file)) { } else { echo $dir . '/' . $file . ' (directory) NOT deleted!
'; } } } closedir($handle); } ``` } function clean_var_directory() { $dirs = array( 'downloader/.cache/_', 'downloader/pearlib/cache/_', 'downloader/pearlib/download/*', 'var/cache/', 'var/locks/', 'var/log/', 'var/report/', 'var/session/', 'var/import/', 'var/export/', 'var/tmp/' ); ``` foreach($dirs as $v => $k) { # exec('rm -rf '.$k); cleandir($k); echo "Cleaned directory: $k
"; flush(); } ``` } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant