[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/include/ -> SiteConfigDb.class.php (source)

   1  <?php
   2  /* 
   3   * phpMyVisites : website statistics and audience measurements
   4   * Copyright (C) 2002 - 2006
   5   * http://www.phpmyvisites.net/ 
   6   * phpMyVisites is free software (license GNU/GPL)
   7   * Authors : phpMyVisites team
   8  */
   9  
  10  // $Id: SiteConfigDb.class.php 227 2007-07-01 18:05:15Z cmil $
  11  
  12  /**
  13   * deals with sites in the database
  14   */
  15  class SiteConfigDb
  16  {
  17  	function SiteConfigDb()
  18      {
  19      }
  20      
  21      
  22  	function checkInfo()
  23      {
  24          //var_dump($this->info['logo']);
  25          
  26          // check logo ok
  27          $f = INCLUDE_PATH."/images/logos/".$this->info['logo'];
  28          if( !file_exists( $f ))
  29          {
  30              trigger_error('Logo selected ('.INCLUDE_PATH."/images/logos/".$this->info['logo'].') does not exist!', E_USER_WARNING);
  31              $this->info['logo'] = 'pixel.gif';
  32          }
  33          
  34          $authParamsChoice = array( 'all', 'none', 'except', 'only' );
  35          
  36          // check params_choice is one of the 4 allowed 
  37          // (and so don't need to test in phpmyvisites.php)
  38          if( !in_array( $this->info['params_choice'], $authParamsChoice ))
  39          {
  40              $this->info['params_choice'] = 'all';
  41          }
  42      }
  43      
  44  	function addSite( $a_info, $url )
  45      {
  46          //var_dump($a_info);
  47          $this->info = $a_info;
  48          
  49          $this->checkInfo();
  50          
  51          $idNewSite = insertLine( T_SITE, array_keys($this->info), array_values($this->info) );
  52          
  53          insertLine(T_SITE_URL, array('idsite', 'url'), array( $idNewSite, $url) );
  54          
  55          return $idNewSite;
  56      }
  57      
  58  	function modSite( $a_info, $url )
  59      {
  60          //var_dump($a_info);
  61          $this->info = $a_info;
  62          
  63          $this->checkInfo();
  64          
  65          updateLine( T_SITE, $a_info, 'idsite');
  66          updateLine( T_SITE_URL, array( 'idsite' => $a_info['idsite'], 'url' => $url), 'idsite');
  67      }
  68      
  69  	function delSite( $idSite )
  70      {
  71          $r = query("DELETE 
  72                      FROM ".T_SITE."
  73                      WHERE idsite = $idSite
  74                      ");
  75      }
  76      
  77  	function modIpExclude( $a_ipValues, $idSite)
  78      {
  79          // delete old values
  80          $r = query("DELETE 
  81                      FROM ".T_IP_IGNORE."
  82                      WHERE idsite = ".$idSite
  83                      );
  84          
  85          foreach($a_ipValues as $value)
  86          {
  87              insertLine( T_IP_IGNORE, array('ip_min', 'ip_max', 'idsite'), $value ); 
  88          }
  89      }
  90  
  91  	function setNewsletterName( $name, $idNl)
  92      {
  93          $r = query("UPDATE ".T_NEWSLETTER."
  94                      SET name = '$name'
  95                      WHERE idnewsletter = $idNl
  96                      ");
  97      }
  98      
  99  	function addNewsletter( $name, $idSite)
 100      {
 101          $r = query("INSERT 
 102                      INTO ".T_NEWSLETTER."    (idsite, name) 
 103                      VALUES ($idSite, '$name')
 104                      ");
 105      }
 106      
 107  	function delNewsletter($idNewsletter )
 108      {
 109          $r = query("DELETE 
 110                      FROM ".T_NEWSLETTER."
 111                      WHERE idnewsletter = $idNewsletter
 112                      ");
 113      }
 114      
 115  	function createNewsletter($idNewsletter, $name, $idSite)
 116      {
 117          $r = query("INSERT 
 118                      INTO ".T_NEWSLETTER."    (idnewsletter, idsite, name) 
 119                      VALUES ($idNewsletter, $idSite, '$name')
 120                      ");
 121      }
 122      
 123  	function addPartner( $name, $a_urls, $idSite )
 124      {
 125          $r = query("INSERT INTO ".T_SITE_PARTNER." (idsite, name)
 126                      VALUES ($idSite, '$name')
 127                      ");
 128          $this->setPartnerUrls( $a_urls, mysql_insert_id() );
 129      }
 130  	function setPartnerUrls( $a_urls, $partnerId )
 131      {
 132          $r = query("DELETE FROM ".T_SITE_PARTNER_URL."
 133                      WHERE idsite_partner = $partnerId
 134                      ");
 135  
 136          foreach($a_urls as $value)
 137          {
 138              insertLine( T_SITE_PARTNER_URL, array('idsite_partner', 'url'), array( $partnerId, $value) ); 
 139          }
 140      }
 141  	function setPartner( $name, $a_urls, $idPartner)
 142      {
 143          $r = query("UPDATE ".T_SITE_PARTNER."
 144                      SET name = '$name'
 145                      WHERE idsite_partner = $idPartner
 146                      ");
 147          $this->setPartnerUrls( $a_urls, $idPartner );
 148      }
 149  	function delPartner( $idPartner)
 150      {        
 151          $r = query("DELETE 
 152                      FROM ".T_SITE_PARTNER.", ".T_SITE_PARTNER_URL."
 153                      USING ".T_SITE_PARTNER."
 154                          LEFT JOIN ".T_SITE_PARTNER_URL."
 155                          USING ( idsite_partner )
 156                      WHERE ".T_SITE_PARTNER.".idsite_partner = $idPartner
 157                      ");
 158      }
 159  	function setUrls( $a_urls, $idSite )
 160      {
 161          $r = query("DELETE FROM ".T_SITE_URL."
 162                      WHERE idsite = $idSite");
 163          foreach($a_urls as $value)
 164          {
 165              if(strlen(trim($value[1])) != 0)
 166              {
 167                  insertLine( T_SITE_URL, array('idsite', 'url'), $value ); 
 168              }
 169          }
 170      }
 171  }
 172  ?>


Généré le : Mon Nov 26 14:10:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics