Mass Deface
Email Grabber
"SET NAMES 'utf8'"));
$zdbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
exit();
}
$domains=trim($argv[1]);
echo fs_filehandler::NewLine() . "BEGIN Webalizer Stats" . fs_filehandler::NewLine();
if ( ui_module::CheckModuleEnabled( 'Webalizer Stats' ) ) {
GenerateWebalizerStats($domains);
}
else {
echo "Webalizer Stats Module DISABLED." . fs_filehandler::NewLine();
}
echo "END Webalizer Stats" . fs_filehandler::NewLine();
function GenerateWebalizerStats($domains)
{
global $zdbh;
$sql = $zdbh->prepare( "SELECT * FROM x_vhosts LEFT JOIN x_accounts ON x_vhosts.vh_acc_fk=x_accounts.ac_id_pk WHERE vh_name_vc=:domains AND vh_deleted_ts IS NULL;" );
$sql->bindParam(':domains',$domains );
$sql->execute();
echo "Generating webalizer stats html..." . fs_filehandler::NewLine();
while ( $rowvhost = $sql->fetch() ) {
$basedir = ctrl_options::GetSystemOption( 'sentora_root' ) . "modules/webalizer_stats/stats/" . $rowvhost[ 'ac_user_vc' ] . "/" . $rowvhost[ 'vh_name_vc' ];
if ( !file_exists( $basedir ) ) {
@mkdir( $basedir, 0755, TRUE );
}
/** set webalizer command dependant on OS */
if ( sys_versions::ShowOSPlatformVersion() == "Windows" ) {
$command = ctrl_options::GetSystemOption( 'sentora_root' ) .
'modules/webalizer_stats/bin/webalizer.exe';
}
else {
chmod( ctrl_options::GetSystemOption( 'sentora_root' ) . "modules/webalizer_stats/bin/webalizer", 4777 );
$command = "webalizer";
}
/** all other args and flags are the same so keep them outsite to avoid duplication */
$flag = '-o';
$secondFlags = '-d -F clf -n';
$domain = $rowvhost[ 'vh_name_vc' ];
$dom_arr = array_filter(explode(".",$rowvhost['vh_name_vc']));
if($dom_arr[0] == "*"){
$file_name = str_replace("*.","wildcard_",$rowvhost['vh_name_vc']);
}else{
$file_name = $rowvhost['vh_name_vc'];
}
$logFile = realpath( ctrl_options::GetSystemOption( 'log_dir' ) .
'domains/' .
$rowvhost[ 'ac_user_vc' ] .
'/' .
$file_name .
'-access.log' );
$statsPath = ctrl_options::GetSystemOption( 'sentora_root' ) .
"modules/webalizer_stats/stats/" .
$rowvhost[ 'ac_user_vc' ] .
'/' .
$rowvhost[ 'vh_name_vc' ];
/** build arg array, this is in the required order! do not just change the order of this array */
$args = array(
$logFile,
$flag,
$statsPath,
$secondFlags,
$domain,
);
echo "Generating stats for: " . $rowvhost[ 'ac_user_vc' ] . "/" . $rowvhost[ 'vh_name_vc' ] . fs_filehandler::NewLine();
//$returnValue = ctrl_system::systemCommand( $command, $args );
$returnValue = trim(shell_exec("$command $logFile -o $statsPath -d -F clf -n $domain"));
echo $returnValue. fs_filehandler::NewLine();
echo "\n -------------------------------------------------". fs_filehandler::NewLine();
//echo (0 === $returnValue ? 'Succeeded' : 'Failed') . fs_filehandler::NewLine();
}
}
?>