Current time: 04-19-2024, 04:02 PM Hello There, Guest! (LoginRegister)


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

Posts: 5
Joined: Jul 2007
Reputation: 0
Post: #1
Readout domainslist for webalizer
Hello,

I recently upgraded from vhcs2 to ispcp, with vhcs2 my customers have awstats and webalizer, i still want to offer them both so i manage to run them.
With vhcs there was a script for reading out the domainslist, this script isn't working with ispcp, so is there a way to do the same ?

I had also been looking on the german forum but there isn't any script for ispcp either.

Thx in advance
04-29-2009 11:55 PM
Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #2
RE: Readout domainslist for webalizer
You only need the Domains ?
Best would be to write a small scipt with a SQL Query.

Greez BeNe
04-30-2009 12:51 AM
Visit this user's website Find all posts by this user Quote this message in a reply
topmusic Offline
Newbie
*

Posts: 5
Joined: Jul 2007
Reputation: 0
Post: #3
RE: Readout domainslist for webalizer
(04-30-2009 12:51 AM)BeNe Wrote:  You only need the Domains ?
Best would be to write a small scipt with a SQL Query.

Greez BeNe

Well i have a script with SQL Query from vhcs, but that isn't working with the common-ispcp.pl file.
04-30-2009 01:08 AM
Find all posts by this user Quote this message in a reply
BeNe Offline
Moderator
*****
Moderators

Posts: 5,899
Joined: Jan 2007
Reputation: 68
Post: #4
RE: Readout domainslist for webalizer
I never had a system with VHCS running on it Rolleyes
Can you post it here or upload anywhere so that we can have a look ?

Greez BeNe
04-30-2009 01:11 AM
Visit this user's website Find all posts by this user Quote this message in a reply
rbtux Offline
Moderator
*****
Moderators

Posts: 1,847
Joined: Feb 2007
Reputation: 33
Post: #5
RE: Readout domainslist for webalizer
when all customers have all services in ispcp you could read the file /etc/postfix/ispcp/domains... as simple approach...
04-30-2009 01:16 AM
Visit this user's website Find all posts by this user Quote this message in a reply
topmusic Offline
Newbie
*

Posts: 5
Joined: Jul 2007
Reputation: 0
Post: #6
RE: Readout domainslist for webalizer
(04-30-2009 01:16 AM)rbtux Wrote:  when all customers have all services in ispcp you could read the file /etc/postfix/ispcp/domains... as simple approach...

That domains file differs from the 1 that is created by the script.

here are the files that are be used to readout the domainlist in the vhcs2 system.

webalizer.cron
Code:
#!/bin/bash
/var/www/vhcs2/engine/vhcs2-get-domain.pl
for domain in $(cat /etc/webalizer/domains)
do
webalizer /var/www/virtual/$domain/logs/$domain-access.log -o /var/www/virtual/$domain/htdocs/webstats/
done

and the vhcs2-get-domain.pl
Code:
#!/usr/bin/perl -w
require '/var/www/ispcp/engine/ispcp_common_code.pl';
use strict;
use warnings;
&return_all_domains;
sub return_all_domains {
  #initializing vars
  my $sql;
  my ($rs, $rdata) = (undef, undef);
  $sql = "select domain_name from domain";

  ($rs, $rdata) = doSQL($sql);

  my $dmn_count = @$rdata;

  # open the file to write all domains in
  open(FILE, '>/etc/webalizer/domains') or die("impossible Access /etc/webalizer/domains");

  if ($dmn_count > 0) {
    foreach (@$rdata) {
      my $row = $_;
      print FILE @$row[0]."\n";
      #it is necessary to add an anti slash before last "N" of the preceding line.

    }
  }
  close FILE;
}

hope you have enough or else i put the files online.
i already changed the lines containing vhcs to ispcp, that is the same for the file 'ispcp_common_code.pl'
the original you can get at http://www.top-music.org/ispcp/files/vhc...n_code.zip

kind regards.
(This post was last modified: 05-02-2009 10:10 PM by topmusic.)
05-02-2009 10:00 PM
Find all posts by this user Quote this message in a reply
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
help40 Offline
Junior Member
*

Posts: 16
Joined: Mar 2010
Reputation: 0
Post: #8
RE: Readout domainslist for webalizer
a little offtopic about webalizer

what about protecting "westats" directory automaticly ? so it is not word accessable
03-07-2010 10:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


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