示例#1
0
<?php

// example2.php
require_once "../../../autoload.php";
$_site = array('siteDomain' => "localhost", 'siteName' => "Example2", 'copyright' => "2016 Barton L. Phillips", 'memberTable' => "members", 'noTrack' => true, 'dbinfo' => array('database' => 'test.sdb', 'engine' => 'sqlite3'), 'count' => false);
ErrorClass::setNoEmailErrs(true);
ErrorClass::setDevelopment(true);
$_site = arraytoobjectdeep($_site);
$S = new SiteClass($_site);
list($top, $footer) = $S->getPageTopBottom();
// Do some database operations
$S->query("select fname, lname from {$S->memberTable}");
$names = '';
while (list($fname, $lname) = $S->fetchrow('num')) {
    $names .= "{$fname} {$lname}<br>";
}
echo <<<EOF
{$top}
<h1>Example 2</h1>
<p>{$names}</p>
<hr>
{$footer}
EOF
;
示例#2
0
 public static function setNoOutput($b)
 {
     return self::$noOutput = $b;
 }
示例#3
0
 protected function setUp()
 {
     ErrorClass::setNoHtml(true);
     $this->s = arraytoobjectdeep($this->s);
     $this->S = new SiteClass($this->s);
 }
示例#4
0
 /**
  * Constructor
  *
  * @param array|object $s
  *  fields: siteDomain, subDomain, headFile,
  *  bannerFile, footerFile, count, daycountwhat, emailDomain, nodb:
  *  these fields are all protected. 
  *  If there are more elements in $s they become public properties. You can add myUri to populate
  *  $this->myIp if you don't want to count webmaster activity.
  *  count is default true and countMe is default false. The rest of the values are 'null' if not
  *  specifically set in $s.
  */
 public function __construct($s = null)
 {
     ErrorClass::init();
     // BLP 2014-12-31 -- Make sure this is done
     $this->isSiteClass = true;
     date_default_timezone_set("America/Los_Angeles");
     $arg = array();
     // temp array for $s during parsing
     if (!is_null($s)) {
         if (is_array($s)) {
             $arg = $s;
         } elseif (is_object($s)) {
             foreach ($s as $k => $v) {
                 $arg[$k] = $v;
             }
         } else {
             throw new Exception(__CLASS__ . ": Argument to constructor not an array or object");
         }
     }
     // Now make $this objects of the items that were in $s
     // That means you can put ANYTHING in $s and it will be public in $this!
     foreach ($arg as $k => $v) {
         $this->{$k} = $v;
     }
     // From here on we don't use $arg any more instead $this
     // If emailDomain is not set force it to siteDomain
     if (!$this->emailDomain) {
         $this->emailDomain = $this->siteDomain;
     }
     if ($this->nodb === true || is_null($this->dbinfo)) {
         // nodb === true so don't do any database stuff
         $this->nodb = true;
         $this->count = $this->countMe = false;
     }
     if (is_null($this->db) && $this->nodb !== true && !is_null($this->dbinfo)) {
         // instantiate the Database. Pass Everything on to Database
         $this->db = new Database($this);
     }
     // If myUri is set get the ip address into myIp
     // BLP 2016-11-27 -- Changed meaning. It can be an object
     if (isset($this->myUri)) {
         if (is_array($this->myUri)) {
             foreach ($this->myUri as $v) {
                 $this->myIp[] = gethostbyname($v);
             }
         } else {
             $this->myIp = gethostbyname($this->myUri);
             // get my home ip address
         }
     }
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->agent = $_SERVER['HTTP_USER_AGENT'];
     $this->self = $_SERVER['PHP_SELF'];
     if ($this->siteName == "Conejoskiclub") {
         $this->requestUri = $_SERVER['REQUEST_URI'];
     } else {
         $this->requestUri = $this->self;
     }
     // These all use database 'barton'
     // and are always done regardless of 'count' and 'countMe'!
     // These all check $this->nodb first and return at once if it is true.
     if ($this->noTrack != true) {
         $this->trackbots();
         // Should be the FIRST in the group. This sets $this->isBot
         $this->tracker();
         $this->logagent();
         // in 'masterdb' database. logip and logagent
         $this->setmyip();
     }
     // If 'count' is false we don't do these counters
     if ($this->count) {
         // Get the count for hitCount. This is done even if countMe is false. The hitCount is always
         // updated (unless the counter file does not exist).
         // That is why it is here rather than after the countMe test below!
         $this->counter();
         // in 'masterdb' database
         // If this is me and $countMe is false (default is false) then don't count.
         // not (true && true) ==   false, it is me and countMe=false
         // not (true && false) ==  true,  it is me and countMe=true
         // not (false && true) ==  true,  it isn't me and countMe=false
         // not (false && false) == true,  it isn't me and countMe=false
         if (!($this->isMe() && $this->countMe === false)) {
             // These are all checked for existance in the database in the functions and also the nodb
             // is checked and if true we return at once.
             $this->counter2();
             // in 'masterdb' database
             // arg can be ALL or a file or an array of files OR nothing!
             $this->daycount($this->daycountwhat);
             // in 'masterdb' database
         }
     }
 }
示例#5
0
 public function testGetCode()
 {
     $this->assertSame('Error', $this->object->getCode());
 }