예제 #1
0
<?php

namespace Nether;

use Nether;
use PDO;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
Nether\Option::Define(['nether-database-connections' => [], 'nether-database-query-log' => false]);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class Database
{
    /*//
    this class provides all the functionality and primary interface for interacting
    with database things.
    
    for simple code you can new Nether\Database($Alias) any time you need access.
    
    for more complex code where you may want to perform dependency injection you
    will want to use Nether\Database::Get($Alias) instead.
    //*/
    static $DBO = [];
    /*//
    	@type array
    	a singleton array for holding all the Database objects for each unique
    	connection that has been opened. example new Database('Default') will
    	cause DBC['Default'] to contain a reference to that Database instance. you
    	can use this to use a more dependency injection friendly style of coding
    	if you do not want to new Database in each method you need db access. your
    	unit tests can then store a mock in DBC['Default']. see the static Get
예제 #2
0
<?php

namespace Nether\Database;

use Exception;
use Nether;
Nether\Option::Define(['nether-database-verse-compiler' => 'Nether\\Database\\Verse\\MySQL']);
class Verse
{
    const ModeSelect = 1;
    const ModeInsert = 2;
    const ModeUpdate = 3;
    const ModeDelete = 4;
    const InsertNormal = 0;
    const InsertIgnore = 1;
    const InsertUpdate = 2;
    const JoinLeft = 1;
    const JoinRight = 2;
    const JoinInner = 4;
    const JoinOuter = 8;
    const JoinNatural = 16;
    const WhereAnd = 1;
    const WhereOr = 2;
    const WhereNot = 4;
    const SortAsc = 1;
    const SortDesc = 2;
    protected $Compiler = null;
    /*//
    	@type string
    	the name of the class that should compile the query into an SQL string.
    	//*/
예제 #3
0
파일: Client.php 프로젝트: dmanetwork/slack
/*//
@package dmanetwork/slack
@licence BSD-2-Clause (https://github.com/dmanetwork/slack/blob/master/LICENSE)
@url https://github.com/dmanetwork/slack
@version 20140516.1

This provides some basic functionality to easily automate sending messages to
Slack (slack.com) channels via the Slack API.
//*/
namespace DMA\Slack;

use DMA;
use Nether;
////////////////
////////////////
Nether\Option::Define(['slack-token' => null, 'slack-default-channel' => '#general', 'slack-default-name' => 'Optimus Prime', 'slack-default-icon' => null, 'slack-channels' => []]);
////////////////
////////////////
class Client
{
    protected $DefaultChannel;
    /*//
    	@type string
    	the default channel to send messages to.
    	//*/
    protected $DefaultName;
    /*//
    	@type string
    	the name used to chat messages.
    	//*/
    protected $DefaultIcon;
예제 #4
0
<?php

namespace Walker;

use Nether;
use Walker;
use Exception;
use StdClass;
////////////////
////////////////
Nether\Option::Define(['ConfigDir' => sprintf('%1$s%2$sconf', dirname(__FILE__, 3), DIRECTORY_SEPARATOR), 'SaveDir' => sprintf('%1$s%2$ssave%2$s%%CONFIGNAME%%', dirname(__FILE__, 3), DIRECTORY_SEPARATOR), 'Delay' => 3, 'UserAgent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.88 Safari/537.36 Vivaldi/1.0.385.5']);
////////////////
////////////////
class Config extends Nether\Object
{
    /*//
    this class defines the unique configurations that can be created to process
    the various jobs you may want to perform. this file also happens to define
    the default settings for the entire app (currently).
    //*/
    protected $File = '';
    /*//
    	@generated
    	the filename that this config file is written or will be written to in the
    	future when saved to disk as json. this property is automatically populated
    	by the GetFile() method when needed based on current configuration.
    	//*/
    public function GetFile() : string
    {
        /*//
        	@get File
예제 #5
0
<?php

namespace Nether;

use Nether;
use Exception;
///////////////////////////////////////////////////////////////////////////////
// library options ////////////////////////////////////////////////////////////
Option::Define(['surface-auto-capture' => true, 'surface-auto-stash' => 'surface', 'surface-auto-render' => true, 'surface-theme' => 'default', 'surface-theme-stack' => ['common'], 'surface-theme-style' => 'default', 'surface-title-brand' => true, 'surface-theme-root' => sprintf('%s/themes', rtrim(Option::Get('nether-web-root'), '/')), 'surface-theme-path' => sprintf('%s/themes', rtrim(Option::Get('nether-web-path'), '/'))]);
///////////////////////////////////////////////////////////////////////////////
// library ki event handlers //////////////////////////////////////////////////
Ki::Queue('avenue-redirect', function () {
    // if a redirect was requested shut down the automatic surface instance and
    // throw away whatever it already collected.
    if (!class_exists('Nether\\Stash')) {
        return;
    }
    $surface = Stash::Get(Option::Get('surface-auto-stash'));
    if ($surface && $surface instanceof Surface) {
        $surface->SetAutoRender(false)->Stop(false);
    }
    return;
}, true);
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
class Surface
{
    /*//
    this is the engine engine designed to make it easy to application output into
    page templates with ease. there is no template language, the templates are
    plain html with embedded php calls to the various surface methods. just in case
예제 #6
0
파일: Router.php 프로젝트: netherphp/avenue
<?php

namespace Nether\Avenue;

use Nether;
use Exception;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// define a list of shortcuts which can be used in the route conditions to make
// regular expressions easier to deal with. with care, you can also add your
// own shortcuts if there is anything you find yourself doing often.
Nether\Option::Define(['nether-avenue-condition-shortcuts' => ['(@)' => '(.+?)', '{@}' => '(?:.+?)', '(?)' => '(.*?)', '{?}' => '(?:.*?)', '(#)' => '(\\d+)', '{#}' => '(?:\\d+)', '($)' => '([^\\/]+)', '{$}' => '(?:[^\\/]+)', '(domain)' => '.*?([^\\.]+(?:\\.[^\\.]+)?)', '{domain}' => '.*?(?:[^\\.]+(?:\\.[^\\.]+)?)']]);
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
class Router
{
    public function __construct($opt = null)
    {
        /*//
        	argv(array Options)
        	//*/
        $opt = new Nether\Object($opt, ['Domain' => $this->GetRequestDomain(), 'Path' => $this->GetRequestPath(), 'Query' => $this->GetRequestQuery()]);
        $this->Domain = $opt->Domain;
        $this->Path = $opt->Path == '/' ? '/index' : $opt->Path;
        $this->Query = $opt->Query;
        if (array_key_exists('REMOTE_ADDR', $_SERVER)) {
            // we can identify a non-malicious webhit with their ip address.
            $userpart = $_SERVER['REMOTE_ADDR'];
        } else {
            // i'm not sure what i want to do about non-web or broken web.
            $userpart = '';
예제 #7
0
파일: Cache.php 프로젝트: netherphp/cache
<?php

namespace Nether;

use Nether;
use Exception;
Option::Define(['cache-autostash' => true, 'cache-stash-name' => 'cache', 'cache-verbose-get' => true, 'cache-key-prefix' => 'nether-cache', 'cache-drivers-load' => ['App' => 'Nether\\Cache\\Appcache', 'Mem' => 'Nether\\Cache\\Memcache', 'Disk' => 'Nether\\Cache\\Diskcache'], 'cache-drivers-use' => ['App', 'Mem']]);
class Cache
{
    protected $Drivers = [];
    /*//
    	@type array
    	list of currently active driver objects.
    	//*/
    protected $HitCount = 0;
    /*//
    	@type int
    	number of cache requests that ended in hits.
    	//*/
    protected $MissCount = 0;
    /*//
    	@type int
    	number of cache requests that ended in misses.
    	//*/
    ////////////////
    ////////////////
    protected $Logging = false;
    /*//
    	@type bool
    	if we should log the cache commands or not.
    	//*/
예제 #8
0
<?php

namespace Nether\Cache;

use Nether;
Nether\Option::Define(['cache-diskcache-path' => null]);
class Diskcache extends DriverInterface
{
    protected $Path;
    /*//
    	@type string
    	the directory path to the file cache.
    	//*/
    public function __construct()
    {
        $this->SetPath(Nether\Option::Get('cache-diskcache-path'));
        return;
    }
    public function SetPath($path)
    {
        /*//
        	define the path to store files in. automatically trims off any trailing
        	slashes that are left on.
        	//*/
        $this->Path = rtrim($path, '\\/');
        return;
    }
    ////////////////
    ////////////////
    public function GetFileName($key)
    {
예제 #9
0
<?php

namespace Nether\Cache;

use Nether;
Nether\Option::Define(['cache-memcache-pool' => []]);
class Memcache extends DriverInterface
{
    protected $Driver;
    /*//
    	@type object
    	this is an instance of the Memcache driver from the PHP Memcache Extension
    	for us to interact with the network pool.
    	see: http://us1.php.net/manual/en/class.memcache.php
    	//*/
    ////////////////
    ////////////////
    public function __construct()
    {
        $this->Driver = new \Memcached();
        $pool = Nether\Option::Get('cache-memcache-pool');
        /*//todo/
        		log instead of throw exception.
        		//*/
        if (!is_array($pool)) {
            throw new \Exception('cache-memcache-pool is not an array');
        }
        foreach ($pool as $server) {
            $this->AddServer($server);
        }
        return;