Skip to content

Commit

Permalink
simple developer tools
Browse files Browse the repository at this point in the history
  • Loading branch information
timo-bes committed Aug 28, 2010
1 parent c679bfb commit 8a584e3
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
dev/log
13 changes: 1 addition & 12 deletions Archive.php
Expand Up @@ -7,7 +7,7 @@
* Author: Timo Besenreuther
* EZdesign.de
* Created: 2010-07-23
* Modified: 2010-07-25
* Modified: 2010-08-28
*/

class Piwik_SiteSearch_Archive {
Expand Down Expand Up @@ -50,17 +50,6 @@ public static function getInstance() {
return self::$instance;
}

/** Simple file logger */
public static function log($message) {
if (is_array($message)) {
$message = print_r($message, true);
}
$log = './tmp/log';
$fh = fopen($log, 'a') or die('Can\'t open log file');
fwrite($fh, $message."\n\n");
fclose($fh);
}

/** Get data table from archive
* @return Piwik_DataTable */
public static function getDataTable($name, $idsite, $period, $date) {
Expand Down
11 changes: 11 additions & 0 deletions SiteSearch.php
Expand Up @@ -56,6 +56,17 @@ public function uninstall() {
Zend_Registry::get('db')->query($query);
}

/** Simple file logger */
public static function log($message) {
if (is_array($message)) {
$message = print_r($message, true);
}
$log = './plugins/SiteSearch/dev/log';
$fh = fopen($log, 'a') or die('Can\'t open log file');
fwrite($fh, $message."\n\n");
fclose($fh);
}

/** Register Hooks */
public function getListHooksRegistered() {
$hooks = array(
Expand Down
32 changes: 32 additions & 0 deletions dev/clear_archive.sh
@@ -0,0 +1,32 @@
#!/usr/bin/php
<?php

$config = parse_ini_file('../../../config/config.ini.php');

$db = mysql_connect($config['host'], $config['username'], $config['password'])
or die("Could not connect to database");

mysql_select_db($config['dbname'], $db);

$result = mysql_query('SHOW TABLES LIKE "'.$config['tables_prefix'].'archive_%"', $db);
if (!$result) {
echo mysql_error($db);
echo "\n";
}

$tables = array();
while ($row = mysql_fetch_row($result)) {
$tables[] = $row[0];
}

foreach ($tables as $table) {
echo 'Dropping '.$table;
echo "\n";
$result = mysql_query('DROP TABLE '.$table, $db);
if (!$result) {
echo mysql_error($db);
echo "\n";
}
}

?>
1 change: 1 addition & 0 deletions dev/info.php
@@ -0,0 +1 @@
<?php phpinfo() ?>
3 changes: 3 additions & 0 deletions dev/monitor_log.sh
@@ -0,0 +1,3 @@
#!/bin/bash

tail -f ./log

0 comments on commit 8a584e3

Please sign in to comment.