public static function instance()
 {
     if (!isset(self::$instance)) {
         $class = __CLASS__;
         self::$instance = new $class();
     }
     return self::$instance;
 }
Example #2
0
 private function __construct()
 {
     $type = '@DB_TYPE@';
     $host = '@DB_HOST@';
     $name = '@DB_NAME@';
     $user = '******';
     $pass = '******';
     try {
         $this->dbh = new PDO("{$type}:host={$host};dbname={$name}", $user, $pass);
         $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (Exception $e) {
         $ldoc = LittleDropsOfCode::instance();
         $ldoc->setErrorPage('db');
     }
 }
Example #3
0
<?php

$page = LittleDropsOfCode::instance()->getPage();
$tracker = "http://github.com/lcabrini/littledropsofcode/issues";
?>

<h2>404</h2>

<p>You are looking for the page <span class="missing"><?php 
echo $page;
?>
</span>, 
which does not exist.</p> 

<p>If you got here by clicking a link on the site, there is probably a bug 
hiding somewhere in the code. Please report it to our issue tracking system at 
<a href="<?php 
echo $tracker;
?>
"><?php 
echo $tracker;
?>
</a>.</p>
Example #4
0
<?php

function __autoload($class)
{
    require_once LIBLDOC_PATH . "/classes/{$class}.php";
}
Database::instance();
$ldoc = LittleDropsOfCode::instance();
$ldoc->action();
Example #5
0
<?php

$user = User::instance();
$v = $user->validate($_POST);
if ($v['valid']) {
    $u = User::instance()->add($_POST);
    ActivityLog::instance()->registration($u);
    LittleDropsOfCode::instance()->setPage('post-register');
} else {
    LittleDropsOfCode::instance()->setPage('register');
}
Example #6
0
<?php

$auth = new Authenticator();
$res = $auth->authenticate($_POST);
if ($res['auth']) {
    Session::instance()->login($_POST['username']);
    LittleDropsOfCode::instance()->setPage('home');
} else {
    LittleDropsOfCode::instance()->setPage('login');
}