Created
May 8, 2013 01:24
-
-
Save deivisonarthur/5537530 to your computer and use it in GitHub Desktop.
Script para limpar cache e log no Magento 1.7 - um outro parecido, porém mais cheio de fluflu foi esse https://github.com/deivisonarthur/magento-scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Deivison Arthur - Script para limpar cache e log no Magento 1.7*/ | |
$xml = simplexml_load_file('./app/etc/local.xml', NULL, LIBXML_NOCDATA); | |
$db['host'] = $xml->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; | |
/* http://seushop.com.br/clean.php?clean=log */ | |
if($_GET['clean'] == 'log') clean_log_tables(); | |
/* http://seushop.com.br/clean.php?clean=var */ | |
if($_GET['clean'] == 'var') clean_var_directory(); | |
/* http://seushop.com.br/clean.php?geral */ | |
if(isset($_GET['geral'])){ | |
clean_log_tables(); | |
clean_var_directory(); | |
}; | |
function clean_log_tables() { | |
global $db; | |
$tables = array( | |
'catalogindex_aggregation', | |
'catalogindex_aggregation_tag', | |
'catalogindex_aggregation_to_tag', | |
'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', | |
'report_event' | |
); | |
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 'OK - Banco '.$db['pref'].$k.' apagado!<br />'; | |
} | |
} | |
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/tmp/', | |
'includes/src/*' | |
); | |
foreach($dirs as $v => $k) { | |
exec('rm -rf '.$k); | |
echo 'OK - Diretorio '.$k.' Excluido!<br />'; | |
} | |
echo "Sistema limpo com sucesso!"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment