Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
m_aws Class Reference

This class manage awstats statistic sets. More...

Public Member Functions

 m_aws ()
 Constructor. More...
 
 hook_menu ()
 
 alternc_password_policy ()
 Password kind used in this class (hook for admin class) More...
 
 alternc_module_description ()
 Name of the module function. More...
 
 get_list ()
 Returns an array with all the statistics of a member. More...
 
 get_stats_details ($id)
 Return an array with the details for 1 statistic set. More...
 
 host_list ()
 Return the list of domains / subdomains allowed for this member with the type (MX,URL,...) More...
 
 prefix_list ()
 Returns the list of prefixes that can be used on current account. More...
 
 select_prefix_list ($current)
 Echoes <option> tags of all the domains hosted on the account + the login of the account They can be used as a root for the login that may have access to web statistics hosted on an account $current will be the selected value. More...
 
 select_host_list ($current)
 Draw options for a select html code with the list of allowed and availables domains for this member. More...
 
 check_host_available ($current)
 Check if hosts is already used by awstats of available for this member. More...
 
 get_hostaliases ($id)
 Return the hostaliases list with an id. More...
 
 put_stats_details ($id, $users, $hostaliases, $public)
 Edit a statistic set (change allowed user list) More...
 
 delete_stats ($id)
 Delete a statistic set. More...
 
 add_stats ($hostname, $users="", $hostaliases, $public)
 Create a new statistic set. More...
 
 list_login ()
 
 list_allowed_login ($id)
 
 get_view_public ($id)
 
 login_exists ($login, $exists=1)
 
 del_login ($login)
 
 add_login ($login, $pass)
 
 change_pass ($login, $pass)
 
 allow_login ($login, $id, $noconf=0)
 
 delete_allowed_login ($id, $noconf=0)
 
 deny_login ($login, $id, $noconf=0)
 
 alternc_del_member ()
 
 alternc_del_domain ($dom)
 This function is called on each class when a domain name is uninstalled. More...
 
 hook_quota_get ()
 This function is called when we are asked to compute the used quota for a service. More...
 
 _check ($login)
 
 _delconf ($hostname)
 Delete the awstats configuration file for a statistic set. More...
 
 _createconf ($id, $nochk=0)
 Create a configuration file for a statistic set. More...
 
 _createhtpasswd ()
 
 alternc_export ()
 Exports all the aws related information for an account. More...
 
 crypt_apr1_md5 ($plainpasswd)
 from http://php.net/crypt#73619 More...
 

Public Attributes

 $CONFDIR ="/etc/awstats"
 Where are the awstats configuration files : private. More...
 
 $HTAFILE ="/etc/alternc/awstats.htpasswd"
 
 $CACHEDIR ="/var/cache/awstats"
 
 $TEMPLATEFILE ="/etc/alternc/templates/awstats/awstats.template.conf"
 Where is the template for conf files : private. More...
 

Detailed Description

This class manage awstats statistic sets.

Copyleft AlternC Team

Definition at line 33 of file m_aws.php.

Member Function Documentation

m_aws::_check (   $login)

Definition at line 654 of file m_aws.php.

References $c, $err, $mem, $r, and prefix_list().

Referenced by add_login(), allow_login(), change_pass(), and deny_login().

654  {
655  global $err,$mem;
656  $login=trim($login);
657  $login=strtolower($login);
658  if ($c=strpos($login,"_")) {
659  $prefix=substr($login,0,$c);
660  $postfix=substr($login,$c+1);
661  } else {
662  $prefix=$login;
663  $postfix="";
664  }
665  $r=$this->prefix_list();
666  if (!in_array($prefix,$r)) {
667  $err->raise("aws",_("prefix not allowed.")); // prefix not allowed.
668  return false;
669  }
670  if (!preg_match('/^[0-9a-z_-]*$/', $postfix)){
671  $err->raise("aws",_("Forbidden caracters in the postfix."));
672  return false;
673  }
674  return $login;
675  }
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
prefix_list()
Returns the list of prefixes that can be used on current account.
Definition: m_aws.php:200
$c
Definition: bootstrap.php:47
$mem
Definition: bootstrap.php:71
m_aws::_createconf (   $id,
  $nochk = 0 
)

Create a configuration file for a statistic set.

if nochk==1, does not check the owner of the stat set (for admin only) private

Definition at line 697 of file m_aws.php.

References $cuid, $db, $err, $f, $hostaliases, $hostname, $public, $uid, and $username.

Referenced by add_stats(), allow_login(), delete_allowed_login(), deny_login(), and put_stats_details().

697  {
698  global $db,$err,$cuid,$L_ALTERNC_LOGS;
699  $s=@implode("",file($this->TEMPLATEFILE));
700  if (!$s) {
701  $err->raise("aws",_("Problem to create the configuration"));
702  return false;
703  }
704  if ($nochk) {
705  $db->query("SELECT * FROM aws WHERE id='$id';");
706  } else {
707  $db->query("SELECT * FROM aws WHERE id='$id' AND uid='$cuid';");
708  }
709  if (!$db->num_rows()) {
710  $err->raise("aws",_("This statistic does not exist"));
711  return false;
712  }
713  $db->next_record();
714  $uid = $db->f('uid');
715  $hostname=$db->f("hostname");
716  $hostaliases=$db->f("hostaliases");
717  $public=$db->f("public");
718  $db->query("SELECT login FROM membres WHERE uid = '$uid'");
719  $db->next_record();
720  $username = $db->f('login');
721  $db->query("SELECT login FROM aws_access WHERE id='$id';");
722  $users="";
723  while ($db->next_record()) {
724  $users.=$db->f("login")." ";
725  }
726 
727  $replace_vars = array(
728  '%%UID%%' => $uid,
729  '%%USER%%' => $username,
730  '%%ALTERNC_LOGS%%' => $L_ALTERNC_LOGS,
731  '%%PUBLIC%%' => $public,
732  '%%HOSTNAME%%' => $hostname,
733  '%%HOSTALIASES%%' => $hostaliases,
734  '%%USERS%%' => $users,
735  );
736  foreach ($replace_vars as $k=>$v){
737  $s=str_replace($k,$v,$s);
738  }
739 
740  $f=fopen($this->CONFDIR."/awstats.".$hostname.".conf","wb");
741  fputs($f,$s,strlen($s));
742  fclose($f);
743 
744  return true;
745  }
$hostaliases
Definition: aws_edit.php:42
$uid
$hostname
Definition: aws_edit.php:40
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$public
Definition: aws_edit.php:43
global $username
Definition: change.php:59
m_aws::_createhtpasswd ( )

Definition at line 749 of file m_aws.php.

References $db, $err, and $f.

Referenced by add_login(), add_stats(), allow_login(), alternc_del_domain(), alternc_del_member(), change_pass(), del_login(), delete_allowed_login(), deny_login(), and put_stats_details().

749  {
750  global $db, $err;
751  $f=@fopen($this->HTAFILE,"wb");
752  if ($f) {
753  $db->query("SELECT login,pass FROM aws_users;");
754  while ($db->next_record()) {
755  fputs($f,$db->f("login").":".$db->f("pass")."\n");
756  }
757  fclose($f);
758  return true;
759  } else {
760  $err->raise("aws",sprintf(_("Problem to edit file %s"), $this->HTAFILE));
761  return false;
762  }
763  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_aws::_delconf (   $hostname)

Delete the awstats configuration file for a statistic set.

private

Definition at line 682 of file m_aws.php.

References $err, and $hostname.

Referenced by alternc_del_domain(), alternc_del_member(), and delete_stats().

682  {
683  global $err,$action;
684  if (!preg_match('/^[._a-z0-9-]*$/', $hostname)){
685  $err->raise("aws",_("Hostname is incorrect"));
686  return false;
687  }
688  $action->del($this->CONFDIR. DIRECTORY_SEPARATOR . "awstats.".$hostname.".conf");
689  }
$hostname
Definition: aws_edit.php:40
$err
Definition: bootstrap.php:72
m_aws::add_login (   $login,
  $pass 
)

Definition at line 469 of file m_aws.php.

References $cuid, $db, $err, _check(), _createhtpasswd(), crypt_apr1_md5(), and login_exists().

469  {
470  global $db,$err,$cuid;
471  $err->log("aws","add_login");
472 
473  if (!($login=$this->_check($login))) {
474  $err->raise("aws",_("Login incorrect"));
475  return false;
476  }
477  if ($this->login_exists($login,1)) {
478  $err->raise("aws",_("Login already exist"));
479  return false;
480  }
481  $pass=$this->crypt_apr1_md5($pass);
482  // FIXME retourner une erreur l'insert se passe pas bien
483  $db->query("INSERT INTO aws_users (uid,login,pass) VALUES ('$cuid','$login','$pass');");
484  return $this->_createhtpasswd();
485  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
crypt_apr1_md5($plainpasswd)
from http://php.net/crypt#73619
Definition: m_aws.php:802
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_check($login)
Definition: m_aws.php:654
login_exists($login, $exists=1)
Definition: m_aws.php:441
m_aws::add_stats (   $hostname,
  $users = "",
  $hostaliases,
  $public 
)

Create a new statistic set.

Parameters
string$hostnameThe domain name
$uersarray the array of users that will be allowed
$hostaliasesarray an array of host aliases
$publicboolean Shall this statistic set be public ?
Returns
boolean TRUE if the set has been created

Definition at line 348 of file m_aws.php.

References $cuid, $db, $err, $hostaliases, $hostname, $id, $key, $mem, $r, $val, _createconf(), _createhtpasswd(), allow_login(), and host_list().

348  {
349  global $db,$err,$quota,$mem,$cuid;
350  $err->log("aws","add_stats",$hostname);
351  $ha="";
352  $r=$this->host_list();
353  $hosts=array();
354  foreach ($r as $key=>$val) {
355  $hosts[]=$val["hostname"];
356  }
357  reset($hosts);
358  if (!in_array($hostname,$hosts) || $hostname=="") {
359  $err->raise("aws",_("This hostname does not exist (Domain name)"));
360  return false;
361  }
362 
363  // Parse the hostaliases array (it should contains valid domains)
364  if (is_array($hostaliases)) {
365  foreach($hostaliases as $ho) {
366  if (!in_array($ho,$hosts) || $hostname=="") {
367  $err->raise("aws",_("This hostname does not exist (Hostaliases)"));
368  return false;
369  }
370  $ha .= "$ho ";
371  }
372  }
373 
374  if ($quota->cancreate("aws")) {
375  $db->query("INSERT INTO aws (hostname,uid,hostaliases,public) VALUES ('$hostname','$cuid','$ha','$public')");
376  $id=$db->lastid();
377  if (is_array($users)) {
378  foreach($users as $v) {
379  $this->allow_login($v,$id, 1);
380  }
381  }
382  if (!$this->_createconf($id) ) return false;
383  if (!$this->_createhtpasswd() ) return false;
384  mkdir($this->CACHEDIR."/".$hostname,0777);
385  return true;
386  } else {
387  $err->raise("aws",_("Your stat quota is over..."));
388  return false;
389  }
390  }
$val
Definition: tempovars.php:15
$hostaliases
Definition: aws_edit.php:42
$hostname
Definition: aws_edit.php:40
host_list()
Return the list of domains / subdomains allowed for this member with the type (MX,URL,...)
Definition: m_aws.php:173
allow_login($login, $id, $noconf=0)
Definition: m_aws.php:508
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_createconf($id, $nochk=0)
Create a configuration file for a statistic set.
Definition: m_aws.php:697
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14
if(!isset($is_include)) if(!$key &&!$crt) $id
$mem
Definition: bootstrap.php:71
m_aws::allow_login (   $login,
  $id,
  $noconf = 0 
)

Definition at line 508 of file m_aws.php.

References $cuid, $db, $err, $id, _check(), _createconf(), _createhtpasswd(), and login_exists().

Referenced by add_stats(), and put_stats_details().

508  { // allow user $login to access stats $id.
509  global $db,$err,$cuid;
510  $err->log("aws","allow_login");
511 
512  if (!($login=$this->_check($login))) {
513  $err->raise("aws",_("Login incorrect"));
514  return false;
515  }
516  if (!$this->login_exists($login)) {
517  $err->raise("aws",_("Login does not exist"));
518  return false;
519  }
520  $db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
521  if (!$db->next_record()) {
522  $err->raise("aws",_("The requested statistic does not exist."));
523  return false;
524  }
525  $db->query("SELECT login FROM aws_access WHERE id='$id' AND login='$login'");
526  if ($db->next_record()) {
527  $err->raise("aws",_("This login is already allowed for this statistics."));
528  return false;
529  }
530  $db->query("INSERT INTO aws_access (uid,id,login) VALUES ('$cuid','$id','$login');");
531  if (!$noconf) {
532  $this->_createconf($id);
533  $this->_createhtpasswd();
534  }
535  return true;
536  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_createconf($id, $nochk=0)
Create a configuration file for a statistic set.
Definition: m_aws.php:697
_check($login)
Definition: m_aws.php:654
login_exists($login, $exists=1)
Definition: m_aws.php:441
if(!isset($is_include)) if(!$key &&!$crt) $id
m_aws::alternc_del_domain (   $dom)

This function is called on each class when a domain name is uninstalled.

Parameters
string$domthe domain to uninstall

Definition at line 618 of file m_aws.php.

References $cuid, $db, $dom, $err, $i, $t, _createhtpasswd(), and _delconf().

618  {
619  global $err,$cuid;
620  $err->log("aws","alternc_del_domain",$dom);
621  $db=new DB_System();
622  $db->query("SELECT id,hostname FROM aws WHERE uid='$cuid' AND (hostname='$dom' OR hostname like '%.$dom')");
623  $t=array();
624  while ($db->next_record()) {
625  $t[]=array($db->f("hostname"),$db->f("id"));
626  }
627  foreach ($t as $i) {
628  $db->query("DELETE FROM aws WHERE uid='$cuid' AND hostname='".$i[0]."';");
629  $db->query("DELETE FROM aws_access WHERE uid='$cuid' AND id='".$i[1]."';");
630  $this->_delconf($i[0]);
631  }
632  return $this->_createhtpasswd();
633  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$t
Definition: dom_editdns.php:58
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
$dom
Definition: whois_test.php:10
_delconf($hostname)
Delete the awstats configuration file for a statistic set.
Definition: m_aws.php:682
m_aws::alternc_del_member ( )

Definition at line 595 of file m_aws.php.

References $cuid, $db, $err, $i, $t, _createhtpasswd(), and _delconf().

595  {
596  global $db,$err,$cuid;
597  $err->log("aws","del_member");
598  $db->query("SELECT * FROM aws WHERE uid='$cuid';");
599  $t=array();
600  while ($db->next_record()) {
601  $t[]=$db->f("hostname");
602  }
603  $db->query("DELETE FROM aws WHERE uid='$cuid';");
604  foreach ($t as $i) {
605  $this->_delconf($i);
606  }
607  $db->query("DELETE FROM aws_access WHERE uid='$cuid'");
608  $db->query("DELETE FROM aws_users WHERE uid='$cuid';");
609  return $this->_createhtpasswd();
610  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$t
Definition: dom_editdns.php:58
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_delconf($hostname)
Delete the awstats configuration file for a statistic set.
Definition: m_aws.php:682
m_aws::alternc_export ( )

Exports all the aws related information for an account.

private EXPERIMENTAL 'sid' function ;)

Definition at line 772 of file m_aws.php.

References $cuid, $db, $err, $host, $id, and $r.

772  {
773  global $db,$err,$cuid;
774  $err->log("aws","export");
775  $str="<aws>\n";
776  $db->query("SELECT login,pass FROM aws_users WHERE uid='$cuid';");
777  while ($db->next_record()) {
778  $str.=" <user><login>".$db->Record["login"]."</login><pass hash=\"des\">".$db->Record["pass"]."</pass></user>\n";
779  }
780  $r=array();
781  $db->query("SELECT id, hostname FROM aws WHERE uid='$cuid' ORDER BY hostname;");
782  while ($db->next_record()) {
783  $r[$db->Record["id"]]=$db->Record["hostname"];
784  }
785  foreach($r as $id=>$host) {
786  $str.=" <domain>\n <name>".$host."</name>\n";
787  $db->query("SELECT login FROM aws_access WHERE id='$id';");
788  while ($db->next_record()) {
789  $str.=" <user>".$db->Record["login"]."</user>\n";
790  }
791  $str.=" </domain>\n";
792  }
793  $str.="</aws>\n";
794  return $str;
795  }
$host
Definition: config.php:86
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
if(!isset($is_include)) if(!$key &&!$crt) $id
m_aws::alternc_module_description ( )

Name of the module function.

Definition at line 81 of file m_aws.php.

81  {
82  return array("aws"=>_("The stats module allows any user to ask for statistics about his web site. Statistics are web pages generated daily based on the visits of the day before. Awstats is the soft used to produce those stats. The statistics are then protected by a login and a password."));
83  }
m_aws::alternc_password_policy ( )

Password kind used in this class (hook for admin class)

Definition at line 72 of file m_aws.php.

72  {
73  return array("aws"=>"Awstats Web Statistics");
74  }
m_aws::change_pass (   $login,
  $pass 
)

Definition at line 489 of file m_aws.php.

References $cuid, $db, $err, _check(), _createhtpasswd(), crypt_apr1_md5(), and login_exists().

489  {
490  global $db,$err,$cuid;
491  $err->log("aws","change_pass");
492 
493  if (!($login=$this->_check($login))) {
494  $err->raise("aws",_("Login incorrect")); // Login incorrect
495  return false;
496  }
497  if (!($this->login_exists($login))) {
498  $err->raise("aws",_("Login does not exists")); // Login does not exists
499  return false;
500  }
501  $pass=$this->crypt_apr1_md5($pass);
502  $db->query("UPDATE aws_users SET pass='$pass' WHERE login='$login';");
503  return $this->_createhtpasswd();
504  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
crypt_apr1_md5($plainpasswd)
from http://php.net/crypt#73619
Definition: m_aws.php:802
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_check($login)
Definition: m_aws.php:654
login_exists($login, $exists=1)
Definition: m_aws.php:441
m_aws::check_host_available (   $current)

Check if hosts is already used by awstats of available for this member.

Definition at line 254 of file m_aws.php.

References $err, $key, $r, $val, each(), and get_list().

Referenced by select_host_list().

254  {
255  global $err;
256  $err->log("aws","check_host_available",$current);
257  $r=$this->get_list();
258  if(is_array($r)){
259  reset($r);
260  while (list($key,$val)=each($r)) {
261  if ($current==$val["hostname"]) {
262  $err->raise("aws",_("Host already managed by awstats!"));
263  return false;
264  }
265  }
266  }
267  return true;
268  }
$val
Definition: tempovars.php:15
get_list()
Returns an array with all the statistics of a member.
Definition: m_aws.php:96
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
x each(["height","width"], function(e, n){x.cssHooks[n]={get:function(e, r, i){return r?0===e.offsetWidth &&Xt.test(x.css(e,"display"))?x.swap(e, Qt, function(){return sn(e, n, i)}):sn(e, n, i):t}, set:function(e, t, r){var i=r &&Rt(e);return on(e, t, r?an(e, n, r, x.support.boxSizing &&"border-box"===x.css(e,"boxSizing",!1, i), i):0)}}})
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14
m_aws::crypt_apr1_md5 (   $plainpasswd)

from http://php.net/crypt#73619

Definition at line 802 of file m_aws.php.

References $i.

Referenced by add_login(), and change_pass().

802  {
803  $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8);
804  $len = strlen($plainpasswd);
805  $text = $plainpasswd.'$apr1$'.$salt;
806  $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd));
807  for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); }
808  for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; }
809  $bin = pack("H32", md5($text));
810  for($i = 0; $i < 1000; $i++) {
811  $new = ($i & 1) ? $plainpasswd : $bin;
812  if ($i % 3) $new .= $salt;
813  if ($i % 7) $new .= $plainpasswd;
814  $new .= ($i & 1) ? $bin : $plainpasswd;
815  $bin = pack("H32", md5($new));
816  }
817  for ($i = 0; $i < 5; $i++) {
818  $k = $i + 6;
819  $j = $i + 12;
820  if ($j == 16) $j = 5;
821  $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp;
822  }
823  $tmp = chr(0).chr(0).$bin[11].$tmp;
824  $tmp = strtr(strrev(substr(base64_encode($tmp), 2)),
825  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
826  "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
827  return "$"."apr1"."$".$salt."$".$tmp;
828  }
m_aws::del_login (   $login)

Definition at line 454 of file m_aws.php.

References $cuid, $db, $err, _createhtpasswd(), and login_exists().

454  {
455  global $db,$err,$cuid;
456  $err->log("aws","del_login");
457  if (!$this->login_exists($login,1)) {
458  $err->raise("aws",_("Login does not exist"));
459  return false;
460  }
461  $db->query("DELETE FROM aws_users WHERE uid='$cuid' AND login='$login';");
462  $db->query("DELETE FROM aws_access WHERE uid='$cuid' AND login='$login';");
463  $this->_createhtpasswd();
464  return true;
465  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
login_exists($login, $exists=1)
Definition: m_aws.php:441
m_aws::delete_allowed_login (   $id,
  $noconf = 0 
)
Parameters
integer$id

Definition at line 544 of file m_aws.php.

References $cuid, $db, $err, $id, _createconf(), and _createhtpasswd().

Referenced by delete_stats(), and put_stats_details().

544  {
545  global $db,$err,$cuid;
546  $err->log("aws","delete_allowed_login");
547 
548  $db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
549  if (!$db->next_record()) {
550  $err->raise("aws",_("The requested statistic does not exist."));
551  return false;
552  }
553  $db->query("DELETE FROM aws_access WHERE id='$id';");
554  if (!$noconf) {
555  $this->_createconf($id);
556  $this->_createhtpasswd();
557  }
558  return true;
559  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_createconf($id, $nochk=0)
Create a configuration file for a statistic set.
Definition: m_aws.php:697
if(!isset($is_include)) if(!$key &&!$crt) $id
m_aws::delete_stats (   $id)

Delete a statistic set.

Parameters
integer$idThe statistic set ID
Returns
string the domain name of the deleted statistic set, or FALSE if an error occurred

Definition at line 320 of file m_aws.php.

References $cuid, $db, $err, $hostname, $id, _delconf(), and delete_allowed_login().

320  {
321  global $db,$err,$cuid,$action;
322  $err->log("aws","delete_stats",$id);
323  $db->query("SELECT hostname FROM aws WHERE id='$id' and uid='$cuid';");
324  if (!$db->num_rows()) {
325  $err->raise("aws",_("This statistic does not exist"));
326  return false;
327  }
328  $db->next_record();
329  $hostname=$db->f("hostname");
330  $this->delete_allowed_login($id,1);
331  $this->_delconf($hostname);
332  $db->query("DELETE FROM aws WHERE id='$id'");
333  $action->del($this->CACHEDIR. DIRECTORY_SEPARATOR . $hostname . DIRECTORY_SEPARATOR);
334  return $hostname;
335 
336  }
$hostname
Definition: aws_edit.php:40
delete_allowed_login($id, $noconf=0)
Definition: m_aws.php:544
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
if(!isset($is_include)) if(!$key &&!$crt) $id
_delconf($hostname)
Delete the awstats configuration file for a statistic set.
Definition: m_aws.php:682
m_aws::deny_login (   $login,
  $id,
  $noconf = 0 
)

Definition at line 563 of file m_aws.php.

References $cuid, $db, $err, $id, _check(), _createconf(), _createhtpasswd(), and login_exists().

563  { // deny user $login to access stats $id.
564  global $db,$err,$cuid;
565  $err->log("aws","deny_login");
566 
567  if (!($login=$this->_check($login))) {
568  $err->raise("aws",_("Login incorrect")); // Login incorrect
569  return false;
570  }
571  if (!$this->login_exists($login,0)) {
572  $err->raise("aws",_("Login does not exists")); // Login does not exists
573  return false;
574  }
575  $db->query("SELECT id FROM aws WHERE id='$id' AND uid='$cuid'");
576  if (!$db->next_record()) {
577  $err->raise("aws",_("The requested statistic does not exist."));
578  return false;
579  }
580  $db->query("SELECT login FROM aws_access WHERE id='$id' AND login='$login'");
581  if (!$db->next_record()) {
582  $err->raise("aws",_("This login is already denied for this statistics."));
583  return false;
584  }
585  $db->query("DELETE FROM aws_access WHERE id='$id' AND login='$login';");
586  if (!$noconf) {
587  $this->_createconf($id);
588  $this->_createhtpasswd();
589  }
590  return true;
591  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_createconf($id, $nochk=0)
Create a configuration file for a statistic set.
Definition: m_aws.php:697
_check($login)
Definition: m_aws.php:654
login_exists($login, $exists=1)
Definition: m_aws.php:441
if(!isset($is_include)) if(!$key &&!$crt) $id
m_aws::get_hostaliases (   $id)

Return the hostaliases list with an id.

Definition at line 275 of file m_aws.php.

References $cuid, $db, $err, $id, and $r.

275  {
276  global $db,$err,$cuid;
277  $r=array();
278  if ($id == NULL)
279  return $r;
280  $db->query("SELECT hostaliases FROM aws WHERE uid='$cuid' and id='$id' ORDER by hostaliases;");
281  while ($db->next_record()) {
282  $r[]=$db->f("hostaliases");
283  }
284 
285  return $r;
286  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
if(!isset($is_include)) if(!$key &&!$crt) $id
m_aws::get_list ( )

Returns an array with all the statistics of a member.

Returns
array Returns an indexed array of associative arrays like that : $r[0-n]["id"] = Id of the stat set $r[0-n]["hostname"]= domain $r[0-n]["users"]= list of allowed users separated with ' '

Definition at line 96 of file m_aws.php.

References $cuid, $db, $err, $r, and $t.

Referenced by check_host_available().

96  {
97  global $db,$err,$cuid;
98  $err->log("aws","get_list");
99  $r=array();
100  $db->query("SELECT id, hostname FROM aws WHERE uid='$cuid' ORDER BY hostname;");
101  if ($db->num_rows()) {
102  while ($db->next_record()) {
103  $r[]=array(
104  "id"=>$db->f("id"),
105  "hostname"=>$db->f("hostname")
106  );
107  }
108  $t=array();
109  foreach ($r as $v) {
110  $db->query("SELECT login FROM aws_access WHERE id='".$v["id"]."';");
111  $u="";
112  while ($db->next_record()) {
113  $u.=$db->f("login")." ";
114  }
115  $t[]=array(
116  "id"=>$v["id"],
117  "hostname"=>$v["hostname"],
118  "users"=>$u
119  );
120  }
121  return $t;
122  } else {
123  $err->raise("aws",_("No statistics currently defined"));
124  return false;
125  }
126  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
$t
Definition: dom_editdns.php:58
$cuid
Definition: bootstrap.php:43
m_aws::get_stats_details (   $id)

Return an array with the details for 1 statistic set.

Parameters
integer$idID of the set we want.
Returns
array Returns an associative array as follow : $r["id"] = Id $r["hostname"]= domain $r["users"] = List of allowed users, separated by ' '

Definition at line 139 of file m_aws.php.

References $cuid, $db, $err, $hostaliases, $hostname, $id, and $public.

Referenced by put_stats_details().

139  {
140  global $db,$err,$cuid;
141  $err->log("aws","get_stats_details",$id);
142  $db->query("SELECT id, hostname, hostaliases, public FROM aws WHERE uid='$cuid' AND id='$id';");
143  if ($db->num_rows()) {
144  $db->next_record();
145  $id=$db->f("id");
146  $hostname=$db->f("hostname");
147  $hostaliases=$db->f("hostaliases");
148  $public=$db->f("public");
149  $db->query("SELECT login FROM aws_access WHERE id='$id';");
150  $u="";
151  while ($db->next_record()) {
152  $u.=$db->f("login")." ";
153  }
154  return array(
155  "id"=>$id,
156  "hostname"=>$hostname,
157  "users"=>$u,
158  "hostaliases"=>$hostaliases,
159  "public"=>$public
160  );
161  } else {
162  $err->raise("aws",_("This statistic does not exist"));
163  return false;
164  }
165  }
$hostaliases
Definition: aws_edit.php:42
$hostname
Definition: aws_edit.php:40
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$public
Definition: aws_edit.php:43
if(!isset($is_include)) if(!$key &&!$crt) $id
m_aws::get_view_public (   $id)

Definition at line 426 of file m_aws.php.

References $cuid, $db, and $err.

426  {
427  global $db,$err,$cuid;
428  $db->query("SELECT public FROM aws WHERE id='$id' and uid='$cuid';");
429  if ($db->num_rows()) {
430  $db->next_record();
431  $pub=$db->f("public");
432  } else {
433  $pub=1;
434  }
435  return $pub;
436  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_aws::hook_menu ( )

Definition at line 57 of file m_aws.php.

57  {
58  $obj = array(
59  'title' => _("Web Statistics"),
60  'ico' => 'images/stat.png',
61  'link' => 'aws_list.php',
62  'pos' => 80,
63  ) ;
64 
65  return $obj;
66  }
m_aws::hook_quota_get ( )

This function is called when we are asked to compute the used quota for a service.

Definition at line 641 of file m_aws.php.

References $cuid, $db, $err, and $q.

641  {
642  global $db,$err,$cuid;
643  $err->log("aws","get_quota");
644  $db->query("SELECT COUNT(*) AS cnt FROM aws WHERE uid='$cuid'");
645  $q=Array("name"=>"aws", "description"=>_("Awstats"), "used"=>0);
646  if ($db->next_record()) {
647  $q['used']=$db->f("cnt");
648  }
649  return $q;
650  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_aws::host_list ( )

Return the list of domains / subdomains allowed for this member with the type (MX,URL,...)

Returns
array an array of allowed domains / subdomains.

Definition at line 173 of file m_aws.php.

References $cuid, $db, $err, and $r.

Referenced by add_stats(), and select_host_list().

173  {
174  global $db,$err,$cuid;
175  $r=array();
176  $db->query("SELECT sd.domaine, sd.sub, dt.name, dt.description FROM sub_domaines sd, domaines_type dt WHERE compte='$cuid' AND lower(sd.type) = lower(dt.name) AND dt.only_dns = false ORDER BY domaine,sub;");
177  while ($db->next_record()) {
178  if ($db->f("sub")) {
179  $r[]=array(
180  "hostname"=>$db->f("sub").".".$db->f("domaine"),
181  "type"=>$db->f("name"),
182  "desc"=>$db->f("description")
183  );
184  } else {
185  $r[]=array(
186  "hostname"=>$db->f("domaine"),
187  "type"=>$db->f("name"),
188  "desc"=>$db->f("description")
189  );
190  }
191  }
192  return $r;
193  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:77
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_aws::list_allowed_login (   $id)

Definition at line 411 of file m_aws.php.

References $cuid, $db, $err, and $res.

411  {
412  global $db,$err,$cuid;
413  $err->log("aws","list_allowed_login");
414  $db->query("SELECT u.login,a.id FROM aws_users u LEFT JOIN aws_access a ON a.id='$id' AND a.login=u.login WHERE u.uid='$cuid';");
415  $res=array();
416  if (!$db->next_record()) {
417  return false;
418  }
419  do {
420  $res[]=array("login"=>$db->f("login"),"selected"=>($db->f("id")));
421  } while ($db->next_record());
422  return $res;
423  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$res
Definition: index.php:127
$cuid
Definition: bootstrap.php:43
m_aws::list_login ( )

Definition at line 394 of file m_aws.php.

References $cuid, $db, $err, and $res.

394  {
395  global $db,$err,$cuid;
396  $err->log("aws","list_login");
397  $db->query("SELECT login FROM aws_users WHERE uid='$cuid';");
398  $res=array();
399  if (!$db->next_record()) {
400  $err->raise("aws",_("No user currently defined"));
401  return false;
402  }
403  do {
404  $res[]=$db->f("login");
405  } while ($db->next_record());
406  return $res;
407  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$res
Definition: index.php:127
$cuid
Definition: bootstrap.php:43
m_aws::login_exists (   $login,
  $exists = 1 
)

Definition at line 441 of file m_aws.php.

References $cuid, $db, and $err.

Referenced by add_login(), allow_login(), change_pass(), del_login(), and deny_login().

441  {
442  global $db,$err,$cuid;
443  $err->log("aws","list_login");
444  $db->query("SELECT login FROM aws_users WHERE uid='$cuid' AND login='$login';");
445  if (!$db->next_record()) {
446  return ($exists==0);
447  } else {
448  return ($exists==1);
449  }
450  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_aws::m_aws ( )

Constructor.

Definition at line 54 of file m_aws.php.

54  {
55  }
m_aws::prefix_list ( )

Returns the list of prefixes that can be used on current account.

Returns
array an arry with the list of domains + the login of the account

Definition at line 200 of file m_aws.php.

References $cuid, $db, $mem, and $r.

Referenced by _check(), and select_prefix_list().

200  {
201  global $db,$mem,$cuid;
202  $r=array();
203  $r[]=$mem->user["login"];
204  $db->query("SELECT domaine FROM domaines WHERE compte='$cuid' ORDER BY domaine;");
205  while ($db->next_record()) {
206  $r[]=$db->f("domaine");
207  }
208  return $r;
209  }
global $db
Definition: bootstrap.php:22
$r
Definition: aws_add.php:77
$cuid
Definition: bootstrap.php:43
$mem
Definition: bootstrap.php:71
m_aws::put_stats_details (   $id,
  $users,
  $hostaliases,
  $public 
)

Edit a statistic set (change allowed user list)

Parameters
integer$idthe stat number we change
array$usersthe list of allowed users

Definition at line 295 of file m_aws.php.

References $cuid, $db, $err, $id, _createconf(), _createhtpasswd(), allow_login(), delete_allowed_login(), and get_stats_details().

295  {
296  global $err,$db,$cuid;
297  if ($this->get_stats_details($id)) {
298  $this->delete_allowed_login($id, 1);
299  if (is_array($users)) {
300  foreach($users as $v) {
301  $this->allow_login($v,$id,1);
302  }
303  }
304  $db->query("UPDATE aws SET hostaliases='$hostaliases', public='$public' where id='$id';");
305  $this->_createconf($id);
306  $this->_createhtpasswd();
307  return true;
308  } else {
309  return false;
310  }
311  }
delete_allowed_login($id, $noconf=0)
Definition: m_aws.php:544
allow_login($login, $id, $noconf=0)
Definition: m_aws.php:508
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
_createhtpasswd()
Definition: m_aws.php:749
_createconf($id, $nochk=0)
Create a configuration file for a statistic set.
Definition: m_aws.php:697
if(!isset($is_include)) if(!$key &&!$crt) $id
get_stats_details($id)
Return an array with the details for 1 statistic set.
Definition: m_aws.php:139
m_aws::select_host_list (   $current)

Draw options for a select html code with the list of allowed and availables domains for this member.

Definition at line 236 of file m_aws.php.

References $c, $key, $r, $val, check_host_available(), each(), and host_list().

236  {
237  $r=$this->host_list();
238  reset($r);
239  while (list($key,$val)=each($r)) {
240  $ho=$val["hostname"];
241  $ty=$val["desc"];
242  if ($current==$ho) $c=" selected=\"selected\""; else $c="";
243  if ($this->check_host_available($ho)) echo "<option value=\"$ho\"$c>$ho ("._($ty).")</option>";
244  }
245  return true;
246  }
$val
Definition: tempovars.php:15
host_list()
Return the list of domains / subdomains allowed for this member with the type (MX,URL,...)
Definition: m_aws.php:173
$r
Definition: aws_add.php:77
x each(["height","width"], function(e, n){x.cssHooks[n]={get:function(e, r, i){return r?0===e.offsetWidth &&Xt.test(x.css(e,"display"))?x.swap(e, Qt, function(){return sn(e, n, i)}):sn(e, n, i):t}, set:function(e, t, r){var i=r &&Rt(e);return on(e, t, r?an(e, n, r, x.support.boxSizing &&"border-box"===x.css(e,"boxSizing",!1, i), i):0)}}})
check_host_available($current)
Check if hosts is already used by awstats of available for this member.
Definition: m_aws.php:254
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14
$c
Definition: bootstrap.php:47
m_aws::select_prefix_list (   $current)

Echoes <option> tags of all the domains hosted on the account + the login of the account They can be used as a root for the login that may have access to web statistics hosted on an account $current will be the selected value.

Parameters
string$currentThe default selected value
Returns
boolean TRUE.

Definition at line 220 of file m_aws.php.

References $c, $key, $r, $val, each(), and prefix_list().

220  {
221  $r=$this->prefix_list();
222  reset($r);
223  while (list($key,$val)=each($r)) {
224  if ($current==$val) $c=" selected=\"selected\""; else $c="";
225  echo "<option$c>$val</option>";
226  }
227  return true;
228  }
$val
Definition: tempovars.php:15
$r
Definition: aws_add.php:77
x each(["height","width"], function(e, n){x.cssHooks[n]={get:function(e, r, i){return r?0===e.offsetWidth &&Xt.test(x.css(e,"display"))?x.swap(e, Qt, function(){return sn(e, n, i)}):sn(e, n, i):t}, set:function(e, t, r){var i=r &&Rt(e);return on(e, t, r?an(e, n, r, x.support.boxSizing &&"border-box"===x.css(e,"boxSizing",!1, i), i):0)}}})
if(empty($_POST['key'])||empty($_POST['val'])) $key
Definition: tempovars.php:14
prefix_list()
Returns the list of prefixes that can be used on current account.
Definition: m_aws.php:200
$c
Definition: bootstrap.php:47

Member Data Documentation

m_aws::$CACHEDIR ="/var/cache/awstats"

Definition at line 41 of file m_aws.php.

m_aws::$CONFDIR ="/etc/awstats"

Where are the awstats configuration files : private.

Definition at line 39 of file m_aws.php.

m_aws::$HTAFILE ="/etc/alternc/awstats.htpasswd"

Definition at line 40 of file m_aws.php.

m_aws::$TEMPLATEFILE ="/etc/alternc/templates/awstats/awstats.template.conf"

Where is the template for conf files : private.

Definition at line 47 of file m_aws.php.


The documentation for this class was generated from the following file: