From 30aa4ccaafb10707c8da72e734d1f59f2c528ce8 Mon Sep 17 00:00:00 2001 From: alecpl Date: Tue, 18 May 2010 10:32:39 +0000 Subject: - Renamed all php-cli scripts to use .sh extension --- CHANGELOG | 1 + INSTALL | 2 +- bin/cleandb.php | 80 ------------------------------------------ bin/cleandb.sh | 80 ++++++++++++++++++++++++++++++++++++++++++ bin/decrypt.php | 70 ------------------------------------- bin/decrypt.sh | 70 +++++++++++++++++++++++++++++++++++++ bin/dumpschema.php | 101 ----------------------------------------------------- bin/dumpschema.sh | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 253 insertions(+), 252 deletions(-) delete mode 100755 bin/cleandb.php create mode 100755 bin/cleandb.sh delete mode 100644 bin/decrypt.php create mode 100755 bin/decrypt.sh delete mode 100644 bin/dumpschema.php create mode 100755 bin/dumpschema.sh diff --git a/CHANGELOG b/CHANGELOG index b29c6f06b..32d907bca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG RoundCube Webmail =========================== +- Renamed all php-cli scripts to use .sh extension - Some files from /bin + spellchecking actions moved to the new 'utils' task - Added thread tree icons - Extend contact groups support (#1486682) diff --git a/INSTALL b/INSTALL index be5a0e93b..19a9aa516 100644 --- a/INSTALL +++ b/INSTALL @@ -126,7 +126,7 @@ using that version you'll have to change ownership of the DB later. Database cleaning ----------------- Do keep your database slick and clean we recommend to periodically execute -bin/cleandb.php which finally removes all records that are marked as deleted. +bin/cleandb.sh which finally removes all records that are marked as deleted. Best solution is to install a cronjob running this script daily. diff --git a/bin/cleandb.php b/bin/cleandb.php deleted file mode 100755 index 79d0b6510..000000000 --- a/bin/cleandb.php +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env php - | - +-----------------------------------------------------------------------+ - - $Id$ - -*/ - -if (php_sapi_name() != 'cli') { - die('Not on the "shell" (php-cli).'); -} - -define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); -require INSTALL_PATH.'program/include/iniset.php'; - -// mapping for table name => primary key -$primary_keys = array( - 'contacts' => "contact_id", - 'contactgroups' => "contactgroup_id", -); - -// connect to DB -$RCMAIL = rcmail::get_instance(); -$db = $RCMAIL->get_dbh(); - -if (!$db->is_connected() || $db->is_error) - die("No DB connection"); - -if (!empty($_SERVER['argv'][1])) - $days = intval($_SERVER['argv'][1]); -else - $days = 7; - -// remove all deleted records older than two days -$threshold = date('Y-m-d 00:00:00', time() - $days * 86400); - -foreach (array('contacts','contactgroups','identities') as $table) { - - $sqltable = get_table_name($table); - - // also delete linked records - // could be skipped for databases which respect foreign key constraints - if ($db->db_provider == 'sqlite' - && ($table == 'contacts' || $table == 'contactgroups') - ) { - $pk = $primary_keys[$table]; - $memberstable = get_table_name('contactgroupmembers'); - - $db->query( - "DELETE FROM $memberstable". - " WHERE $pk IN (". - "SELECT $pk FROM $sqltable". - " WHERE del=1 AND changed < ?". - ")", - $threshold); - - echo $db->affected_rows() . " records deleted from '$memberstable'\n"; - } - - // delete outdated records - $db->query("DELETE FROM $sqltable WHERE del=1 AND changed < ?", $threshold); - - echo $db->affected_rows() . " records deleted from '$table'\n"; -} - -?> diff --git a/bin/cleandb.sh b/bin/cleandb.sh new file mode 100755 index 000000000..51746446a --- /dev/null +++ b/bin/cleandb.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env php + | + +-----------------------------------------------------------------------+ + + $Id$ + +*/ + +if (php_sapi_name() != 'cli') { + die('Not on the "shell" (php-cli).'); +} + +define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); +require INSTALL_PATH.'program/include/iniset.php'; + +// mapping for table name => primary key +$primary_keys = array( + 'contacts' => "contact_id", + 'contactgroups' => "contactgroup_id", +); + +// connect to DB +$RCMAIL = rcmail::get_instance(); +$db = $RCMAIL->get_dbh(); + +if (!$db->is_connected() || $db->is_error) + die("No DB connection"); + +if (!empty($_SERVER['argv'][1])) + $days = intval($_SERVER['argv'][1]); +else + $days = 7; + +// remove all deleted records older than two days +$threshold = date('Y-m-d 00:00:00', time() - $days * 86400); + +foreach (array('contacts','contactgroups','identities') as $table) { + + $sqltable = get_table_name($table); + + // also delete linked records + // could be skipped for databases which respect foreign key constraints + if ($db->db_provider == 'sqlite' + && ($table == 'contacts' || $table == 'contactgroups') + ) { + $pk = $primary_keys[$table]; + $memberstable = get_table_name('contactgroupmembers'); + + $db->query( + "DELETE FROM $memberstable". + " WHERE $pk IN (". + "SELECT $pk FROM $sqltable". + " WHERE del=1 AND changed < ?". + ")", + $threshold); + + echo $db->affected_rows() . " records deleted from '$memberstable'\n"; + } + + // delete outdated records + $db->query("DELETE FROM $sqltable WHERE del=1 AND changed < ?", $threshold); + + echo $db->affected_rows() . " records deleted from '$table'\n"; +} + +?> diff --git a/bin/decrypt.php b/bin/decrypt.php deleted file mode 100644 index 7ef5a470a..000000000 --- a/bin/decrypt.php +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env php - | - +-----------------------------------------------------------------------+ - - $Id$ -*/ - -/*- - * If http_received_header_encrypt is configured, the IP address and the - * host name of the added Received: header is encrypted with 3DES, to - * protect information that some could consider sensitve, yet their - * availability is a must in some circumstances. - * - * Such an encrypted Received: header might look like: - * - * Received: from DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ== - * [my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4] - * with HTTP/1.1 (POST); Thu, 14 May 2009 19:17:28 +0200 - * - * In this example, the two encrypted components are the sender host name - * (DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==) and the IP - * address (my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4). - * - * Using this tool, they can be decrypted into plain text: - * - * $ bin/decrypt_received.php 'my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4' \ - * > 'DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==' - * 84.3.187.208 - * 5403BBD0.catv.pool.telekom.hu - * $ - * - * Thus it is known that this particular message was sent by 84.3.187.208, - * having, at the time of sending, the name of 5403BBD0.catv.pool.telekom.hu. - * - * If (most likely binary) junk is shown, then - * - either the encryption password has, between the time the mail was sent - * and `now', changed, or - * - you are dealing with counterfeit header data. - */ - -if (php_sapi_name() != 'cli') { - die("Not on the 'shell' (php-cli).\n"); -} - -define('INSTALL_PATH', realpath(dirname(__FILE__).'/..') . '/'); -require INSTALL_PATH . 'program/include/iniset.php'; - -if ($argc < 2) { - die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n"); -} - -$RCMAIL = rcmail::get_instance(); - -for ($i = 1; $i < $argc; $i++) { - printf("%s\n", $RCMAIL->decrypt($argv[$i])); -}; diff --git a/bin/decrypt.sh b/bin/decrypt.sh new file mode 100755 index 000000000..51a89e903 --- /dev/null +++ b/bin/decrypt.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env php + | + +-----------------------------------------------------------------------+ + + $Id$ +*/ + +/*- + * If http_received_header_encrypt is configured, the IP address and the + * host name of the added Received: header is encrypted with 3DES, to + * protect information that some could consider sensitve, yet their + * availability is a must in some circumstances. + * + * Such an encrypted Received: header might look like: + * + * Received: from DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ== + * [my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4] + * with HTTP/1.1 (POST); Thu, 14 May 2009 19:17:28 +0200 + * + * In this example, the two encrypted components are the sender host name + * (DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==) and the IP + * address (my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4). + * + * Using this tool, they can be decrypted into plain text: + * + * $ bin/decrypt.sh 'my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4' \ + * > 'DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==' + * 84.3.187.208 + * 5403BBD0.catv.pool.telekom.hu + * $ + * + * Thus it is known that this particular message was sent by 84.3.187.208, + * having, at the time of sending, the name of 5403BBD0.catv.pool.telekom.hu. + * + * If (most likely binary) junk is shown, then + * - either the encryption password has, between the time the mail was sent + * and `now', changed, or + * - you are dealing with counterfeit header data. + */ + +if (php_sapi_name() != 'cli') { + die("Not on the 'shell' (php-cli).\n"); +} + +define('INSTALL_PATH', realpath(dirname(__FILE__).'/..') . '/'); +require INSTALL_PATH . 'program/include/iniset.php'; + +if ($argc < 2) { + die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n"); +} + +$RCMAIL = rcmail::get_instance(); + +for ($i = 1; $i < $argc; $i++) { + printf("%s\n", $RCMAIL->decrypt($argv[$i])); +}; diff --git a/bin/dumpschema.php b/bin/dumpschema.php deleted file mode 100644 index b9a76e419..000000000 --- a/bin/dumpschema.php +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/env php - | - +-----------------------------------------------------------------------+ - - $Id$ - -*/ - -if (php_sapi_name() != 'cli') { - die('Not on the "shell" (php-cli).'); -} - -define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); -require INSTALL_PATH.'program/include/iniset.php'; - -/** callback function for schema dump **/ -function print_schema($dump) -{ - foreach ((array)$dump as $part) - echo $dump . "\n"; -} - -$config = new rcube_config(); - -// don't allow public access if not in devel_mode -if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) { - header("HTTP/1.0 401 Access denied"); - die("Access denied!"); -} - -$options = array( - 'use_transactions' => false, - 'log_line_break' => "\n", - 'idxname_format' => '%s', - 'debug' => false, - 'quote_identifier' => true, - 'force_defaults' => false, - 'portability' => false, -); - -$dsnw = $config->get('db_dsnw'); -$dsn_array = MDB2::parseDSN($dsnw); - -// set options for postgres databases -if ($dsn_array['phptype'] == 'pgsql') { - $options['disable_smart_seqname'] = true; - $options['seqname_format'] = '%s'; -} - -$schema =& MDB2_Schema::factory($dsnw, $options); -$schema->db->supported['transactions'] = false; - - -// send as text/xml when opened in browser -if ($_SERVER['REMOTE_ADDR']) - header('Content-Type: text/xml'); - - -if (PEAR::isError($schema)) { - $error = $schema->getMessage() . ' ' . $schema->getUserInfo(); -} -else { - $dump_config = array( - // 'output_mode' => 'file', - 'output' => 'print_schema', - ); - - $definition = $schema->getDefinitionFromDatabase(); - $definition['charset'] = 'utf8'; - - if (PEAR::isError($definition)) { - $error = $definition->getMessage() . ' ' . $definition->getUserInfo(); - } - else { - $operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_STRUCTURE); - if (PEAR::isError($operation)) { - $error = $operation->getMessage() . ' ' . $operation->getUserInfo(); - } - } -} - -$schema->disconnect(); - -if ($error && !$_SERVER['REMOTE_ADDR']) - fputs(STDERR, $error); - -?> diff --git a/bin/dumpschema.sh b/bin/dumpschema.sh new file mode 100755 index 000000000..5afcb7cf5 --- /dev/null +++ b/bin/dumpschema.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env php + | + +-----------------------------------------------------------------------+ + + $Id$ + +*/ + +if (php_sapi_name() != 'cli') { + die('Not on the "shell" (php-cli).'); +} + +define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); +require INSTALL_PATH.'program/include/iniset.php'; + +/** callback function for schema dump **/ +function print_schema($dump) +{ + foreach ((array)$dump as $part) + echo $dump . "\n"; +} + +$config = new rcube_config(); + +// don't allow public access if not in devel_mode +if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) { + header("HTTP/1.0 401 Access denied"); + die("Access denied!"); +} + +$options = array( + 'use_transactions' => false, + 'log_line_break' => "\n", + 'idxname_format' => '%s', + 'debug' => false, + 'quote_identifier' => true, + 'force_defaults' => false, + 'portability' => false, +); + +$dsnw = $config->get('db_dsnw'); +$dsn_array = MDB2::parseDSN($dsnw); + +// set options for postgres databases +if ($dsn_array['phptype'] == 'pgsql') { + $options['disable_smart_seqname'] = true; + $options['seqname_format'] = '%s'; +} + +$schema =& MDB2_Schema::factory($dsnw, $options); +$schema->db->supported['transactions'] = false; + + +// send as text/xml when opened in browser +if ($_SERVER['REMOTE_ADDR']) + header('Content-Type: text/xml'); + + +if (PEAR::isError($schema)) { + $error = $schema->getMessage() . ' ' . $schema->getUserInfo(); +} +else { + $dump_config = array( + // 'output_mode' => 'file', + 'output' => 'print_schema', + ); + + $definition = $schema->getDefinitionFromDatabase(); + $definition['charset'] = 'utf8'; + + if (PEAR::isError($definition)) { + $error = $definition->getMessage() . ' ' . $definition->getUserInfo(); + } + else { + $operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_STRUCTURE); + if (PEAR::isError($operation)) { + $error = $operation->getMessage() . ' ' . $operation->getUserInfo(); + } + } +} + +$schema->disconnect(); + +if ($error && !$_SERVER['REMOTE_ADDR']) + fputs(STDERR, $error); + +?> -- cgit v1.2.3