Current time: 09-22-2024, 03:37 PM Hello There, Guest! (LoginRegister)


Post Reply 
Readout domainslist for webalizer
Author Message
topmusic Offline
Newbie
*

Posts: 5
Joined: Jul 2007
Reputation: 0
Post: #7
RE: Readout domainslist for webalizer
Well i did some research about that perl scripting myself and i have wrote a new script that will be running from the webalizer.cron file.

Create a file in /var/www/ispcp/engine/
ispcp-get-domain.pl
Code:
#!/usr/bin/perl -w
#   -------------------------------------------------------------------------------
#  |                  webalizer: a web based log                                   |
#  |                  Copyright (c) 2009 by TopMusic                               |
#  |                                                                               |
#  | This program is free software; you can redistribute it and/or                 |
#  | modify it under the terms of the GNU General Public License                   |
#  | as published by the Free Software Foundation; either version 2                |
#  | of the License, or (at your option) any later version.                        |
#  |                                                                               |
#   -------------------------------------------------------------------------------

use DBI;
use warnings;

$user = "mysql username";
$password = "mysql password";
$database = "database name";
$host_name = "localhost";

# Open connection and establish object
$dbh = DBI->connect("DBI:mysql:$database:$host_name", $user, $password);

# Store SQL to be run in the $SQL var
$SQL = "SELECT domain_name from domain";

# Prepare and execute your SQL
$cursor = $dbh->prepare($SQL);
$cursor->execute;

#handle any SQL errors
if ($DBI::errstr) {
print "$DBI::errstr $SQL";
exit;
}
# open the file to write all domains in
my $filename = '/etc/webalizer/domains';
open FILE, "> $filename"  or die "Can't open $filename : $!";
while (@row=$cursor->fetchrow) {
    foreach ($row[0]) {
    print FILE $_ . "\n";
    }
}
close(FILE);

#Close the cursor
$cursor->finish;

#disconnect;
$dbh->disconnect;

So this little script creates a new domains file in the /etc/webalizer directory, wherein all the domains are put that are running on your ispcp server.
(This post was last modified: 05-11-2009 05:38 AM by topmusic.)
05-11-2009 05:36 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Readout domainslist for webalizer - topmusic - 05-11-2009 05:36 AM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)