コード例 #1
0
ファイル: TextNode.php プロジェクト: JackHarley/Hydrogen
 public function render($phpFile)
 {
     if (!Config::getVal('view', 'allow_php') && strpos($this->text, PHPFile::PHP_OPENTAG)) {
         throw new TemplateSyntaxException('Template "' . $this->origin . '" contains raw PHP code, which has been disallowed in the autoconfig file.');
     }
     $phpFile->addPageContent($this->text);
 }
コード例 #2
0
ファイル: ScreenshotBean.php プロジェクト: Zartas/appDB
 protected function get_shot_url()
 {
     $url = $this->stored['shot_url'];
     $url = str_replace('%/', '%', $url);
     $url = str_replace('%BASE_URL%', Config::getVal('urls', 'base_url') . '/', $url);
     return str_replace('%SCREEN_URL%', Config::getVal('urls', 'screenshot_url') . '/', $url);
 }
コード例 #3
0
ファイル: ShortAppBean.php プロジェクト: Zartas/appDB
 protected function get_smallicon_url()
 {
     $url = $this->stored['smallicon_url'];
     $url = str_replace('%/', '%', $url);
     $url = str_replace('%BASE_URL%', Config::getVal('urls', 'base_url') . '/', $url);
     return str_replace('%ICON_URL%', Config::getVal('urls', 'icon_url') . '/', $url);
 }
コード例 #4
0
 /**
  * Adds an external tag to the Hydrogen template engine.  Once added,
  * the tag can be used in any Hydrogen template file for the duration
  * of that request.
  *
  * @param string $tagName The name of the tag to add.  The name is
  * 		what will be typed in the template files themselves.
  * @param string $className The class name (with namespace) of this
  * 		tag.  The tag must extend the class
  * 		{@link \hydrogen\view\engines\hydrogen\Tag}.
  * @param string $path The path to the PHP to require_once before using
  * 		the given class, either absolute or relative to the base_url
  * 		defined in the hydrogen.autoconfig.php file.  This argument is
  * 		OPTIONAL: if omitted, Hydrogen will assume the class will be
  * 		automatically loaded when accessed.
  */
 public static function addTag($tagName, $className, $path = false)
 {
     $tagName = strtolower($tagName);
     static::$tagClass[$tagName] = static::formatNamespace($className, false);
     if ($path) {
         static::$tagPath[$tagName] = Config::getAbsolutePath($path);
     }
 }
コード例 #5
0
 public function __construct()
 {
     $res = new Memcache();
     $host = Config::getVal('cache', 'memcache_host') ?: 'localhost';
     $port = Config::getVal('cache', 'memcache_port') ?: 11211;
     $res->addServer($host, $port);
     $this->memcache = $res;
 }
コード例 #6
0
 public static function getEngine()
 {
     if (is_null(static::$engine)) {
         $engineName = Config::getVal('semaphore', 'engine', false) ?: 'No';
         $engineClass = "\\hydrogen\\semaphore\\engines\\{$engineName}Engine";
         static::$engine = new $engineClass();
     }
     return static::$engine;
 }
コード例 #7
0
 public function profile()
 {
     $um = UserModel::getInstance();
     $nick = $um->getLoggedInNick();
     if (!$nick) {
         header("Location: " . Config::getVal("general", "app_url") . "/index.php/user/login");
     } else {
         View::load('user/profile', array("nick" => $nick));
     }
 }
コード例 #8
0
 public function getLogsByTime($startTimeObj, $endTimeObj)
 {
     $query = new Query("SELECT");
     $query->where("channel_name = ?", Config::getVal("general", "channel"));
     $startTimeObj->makeTimestamp();
     $endTimeObj->makeTimestamp();
     $query->where("time > ?", $startTimeObj->timestamp);
     $query->where("time < ?", $endTimeObj->timestamp, "AND");
     $messagesArray = ChannelActionBean::select($query);
     return $messagesArray;
 }
コード例 #9
0
ファイル: LoaderFactory.php プロジェクト: TomFrost/Hydrogen
 /**
  * Gets an instance (newly created or old) of a Loader.
  *
  * @param string $loaderType The type of loader (loader name, with a
  * 		capital first letter) of which to get an instance.  This argument
  * 		is optional; if false, the loader type specified in the
  * 		[view]=>loader config value will be used.  This value is normally
  * 		specified within hydrogen.autoload.php.
  * @return \hydrogen\view\Loader a Loader of the appropriate type.
  */
 public static function getLoader($loaderType = false)
 {
     if (!$loaderType) {
         $loaderType = Config::getVal("view", "loader") ?: "File";
     }
     if (!isset(static::$loaders[$loaderType])) {
         $class = __NAMESPACE__ . '\\loaders\\' . $loaderType . 'Loader';
         static::$loaders[$loaderType] = new $class();
     }
     return static::$loaders[$loaderType];
 }
コード例 #10
0
 public function __construct()
 {
     $pool = Config::getVal("cache", "pool_name");
     $mc = new Memcached($pool);
     if ($pool === false || count($mc->getServerList()) === 0) {
         $host = Config::getVal('cache', 'memcache_host') ?: 'localhost';
         $port = Config::getVal('cache', 'memcache_port') ?: 11211;
         $mc->addServer($host, $port);
     }
     $this->memcached = $mc;
 }
コード例 #11
0
ファイル: ExcerptFilter.php プロジェクト: TomFrost/Hydrogen
    public static function applyTo($string, $args, &$escape, $phpfile)
    {
        if (count($args) > 3) {
            throw new TemplateSyntaxException('The "excerpt" filter supports only three arguments.');
        }
        $phpfile->addFunction('excerptFilter', array('$str', '$num', '$needle', '$append'), <<<'PHP'
			if ($str = trim($str)) {
				$cutpos = 0;
				if ($needle === false)
					$cutpos = $num;
				else {
					$steps = 0;
					$findpos = 0;
					while ($steps < $num && $findpos !== false) {
						$findpos = strpos($str, $needle, $findpos + 1);
						$steps++;
					}
					if ($findpos)
						$cutpos = $findpos;
				}
				if ($cutpos && strlen($str) > $cutpos)
					return substr($str, 0, $cutpos) . $append;
			}
			return $str;
PHP
);
        $num = isset($args[0]) ? $args[0]->getValue($phpfile) : 20;
        $mode = isset($args[1]) ? trim($args[1]->getValue($phpfile), "'") : 'w';
        $append = isset($args[2]) ? $args[2]->getValue($phpfile) : false;
        if ($append === false) {
            $append = Config::getVal('view', 'excerpt_append') ?: self::DEFAULT_APPEND_STRING;
            $append = "'" . str_replace("'", '\\\'', $append) . "'";
        }
        $needle = false;
        switch ($mode) {
            case 'l':
                $needle = '"\\n"';
                break;
            case 'c':
                $needle = 'false';
                break;
            case 'w':
            default:
                $needle = '" "';
        }
        // Manually handle the escaping here just in case excerptFilter needs
        // to append something that can't be escaped.
        if ($escape) {
            $string = "htmlentities({$string})";
            $escape = false;
        }
        return "excerptFilter({$string}, {$num}, {$needle}, {$append})";
    }
コード例 #12
0
ファイル: ScreenshotModel.php プロジェクト: Zartas/appDB
 protected function saveScreenshotLocally($jpg_url, $filename, &$is_horiz = false)
 {
     if (!($img = @imagecreatefromjpeg($jpg_url))) {
         return false;
     }
     if (!@imagejpeg($img, Config::getVal('paths', 'screenshot_path') . "/{$filename}", 95)) {
         return false;
     }
     $is_horiz = imagesx($img) > imagesy($img);
     @imagedestroy($img);
     return true;
 }
コード例 #13
0
ファイル: TextFileEngine.php プロジェクト: TomFrost/Hydrogen
 public function __construct()
 {
     $logdir = Config::getVal('log', 'logdir');
     $prefix = Config::getVal('log', 'fileprefix', false) ?: 'log';
     $filename = $prefix . date('ymd') . '.log';
     // Get our path relative to the config file
     $logdir = Config::getAbsolutePath($logdir);
     // Add the trailing slash if necessary
     if ($logdir[strlen($logdir) - 1] != DIRECTORY_SEPARATOR) {
         $logdir .= DIRECTORY_SEPARATOR;
     }
     $this->logfile = $logdir . $filename;
 }
コード例 #14
0
ファイル: VariableNode.php プロジェクト: TomFrost/Hydrogen
 public function render($phpFile)
 {
     $phpFile->addPageContent(PHPFile::PHP_OPENTAG);
     $printVar = Config::getVal('view', 'print_missing_var') ?: false;
     if ($printVar) {
         $phpFile->addPageContent('try {');
     }
     $phpFile->addPageContent('echo ' . $this->getVariablePHP($phpFile) . ';');
     if ($printVar) {
         $phpFile->addPageContent('} catch (\\hydrogen\\view\\exceptions\\NoSuchVariableException $e) { echo "{?", $e->variable, "?}"; }');
     }
     $phpFile->addPageContent(PHPFile::PHP_CLOSETAG);
 }
コード例 #15
0
ファイル: ViewSandbox.php プロジェクト: TomFrost/Hydrogen
 /**
  * Creates a new ViewSandbox and calculates the necessary URLs.
  *
  * @param ContextStack|boolean context The context in which to load the
  * 		view.  If false or omitted, an empty context will be used.
  */
 public function __construct($context = false)
 {
     $this->context = $context ?: new ContextStack();
     $this->cleanAppURL = Config::getRequiredVal("general", "app_url");
     if ($this->cleanAppURL[strlen($this->cleanAppURL) - 1] == '/') {
         $this->cleanAppURL = substr($this->cleanAppURL, 0, -1);
     }
     $this->cleanViewURL = Config::getVal("view", "root_url");
     if ($this->cleanViewURL === null) {
         $this->cleanViewURL = $this->appURL(Config::getRequiredVal("view", "url_path"));
     }
     if ($this->cleanViewURL[strlen($this->cleanViewURL) - 1] == '/') {
         $this->cleanViewURL = substr($this->cleanViewURL, 0, -1);
     }
 }
コード例 #16
0
 /**
  * Gets an instance of the specified cache engine.  If an instance has already been
  * created for the specified engine, it will be returned.  Otherwise, a new instance
  * will be made.
  *
  * @param string engine The name of the engine to instantiate or get.
  * @return CacheEngine An instance of the specified engine.
  */
 public static function getEngine($engine = false)
 {
     if (!isset(self::$engine)) {
         static::$engine = array();
     }
     if (!$engine) {
         $engine = Config::getVal('cache', 'engine');
     }
     if (!$engine) {
         $engine = 'No';
     }
     if (!isset(static::$engine[$engine])) {
         $engineClass = '\\hydrogen\\cache\\engines\\' . $engine . 'Engine';
         static::$engine[$engine] = new $engineClass();
     }
     return static::$engine[$engine];
 }
コード例 #17
0
ファイル: DatabaseLoader.php プロジェクト: TomFrost/Hydrogen
 /**
  * Loads the contents of the specified template.
  *
  * @param string $templateName The name of the template to be loaded.
  * @return string The unaltered, unparsed contents of the specified
  * 		template.
  * @throws hydrogen\view\exceptions\NoSuchViewException if the specified
  * 		template is not found or cannot be loaded.
  */
 public function load($viewName)
 {
     $table = Config::getRequiredVal("view", "table_name");
     $nameCol = Config::getRequiredVal("view", "name_field");
     $contentCol = Config::getRequiredVal("view", "content_field");
     $query = new Query("SELECT");
     $query->field($contentCol);
     $query->from($table);
     $query->where($nameCol . " = ?", $viewName);
     $query->limit(1);
     $stmt = $query->prepare();
     $stmt->execute();
     $result = $stmt->fetchObject();
     if (!$result->{$contentCol}) {
         throw new NoSuchViewException("View " . $viewName . " does not exist in database.");
     }
     return $result->{$contentCol};
 }
コード例 #18
0
ファイル: RedisEngine.php プロジェクト: TomFrost/Hydrogen
 /**
  * Construct a new RedisEngine.
  */
 public function __construct()
 {
     $pooling = Config::getVal("cache", "use_pooling");
     $server = Config::getRequiredVal("cache", "server");
     $port = Config::getVal("cache", "port") ?: 6379;
     $timeout = Config::getVal("cache", "timeout") ?: null;
     $password = Config::getVal("cache", "password");
     $this->engine = new Redis();
     if ($pooling) {
         $this->engine->pconnect($server, $port, $timeout);
     } else {
         $this->engine->connect($server, $port, $timeout);
     }
     if ($password) {
         $this->engine->auth($password);
     }
     $this->engine->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
 }
コード例 #19
0
ファイル: UrlNode.php プロジェクト: JackHarley/Hydrogen
 public function render($phpFile)
 {
     $appURL = $this->relative ? Config::getRequiredVal('general', 'app_url') : '';
     while ($appURL && $appURL[strlen($appURL) - 1] === '/') {
         $appURL = substr($appURL, 0, -1);
     }
     $first = true;
     foreach ($this->folders as $folder) {
         if ($first && !$this->relative) {
             $appURL .= $folder;
             $first = false;
         } else {
             if (is_object($folder)) {
                 $appURL .= '/' . PHPFile::PHP_OPENTAG . 'echo urlencode(' . $folder->getVariablePHP($phpFile) . ');' . PHPFile::PHP_CLOSETAG;
             } else {
                 $appURL .= '/' . urlencode($folder);
             }
         }
     }
     if ($this->kvPairs) {
         if (strtolower(substr($appURL, -4)) !== '.php') {
             $appURL .= '/';
         }
         $appURL .= '?';
         foreach ($this->kvPairs as $key => $val) {
             $appURL .= $key . '=';
             if (is_object($val)) {
                 $appURL .= PHPFile::PHP_OPENTAG . 'echo urlencode(' . $val->getVariablePHP($phpFile) . ');' . PHPFile::PHP_CLOSETAG;
             } else {
                 $appURL .= urlencode($val);
             }
             $appURL .= '&';
         }
         $appURL = substr($appURL, 0, -1);
     }
     $phpFile->addPageContent($appURL);
 }
コード例 #20
0
 /**
  * Creates a new instance of DatabaseEngine if the specified connection is new, or returns
  * the stored engine for a connection that an engine's already been instantiated for.  The
  * DatabaseEngine is connected as soon as it is created.
  * 
  * If no dbConfigName is specified, the database configuration from the
  * {@link \hydrogen\config\Config} object is used.  If there are multiple database configurations
  * in the Config object, the first one defined will be used here.
  *
  * If multiple database configurations have been specified in the Config object, the sub-key of
  * the appropriate configuration can be passed in for dbConfigName.  For example:
  * <pre>
  * [database]
  * host[primary] = localhost
  * port[primary] = 3306
  * socket[primary] = 
  * database[primary] = myDB
  * username[primary] = myDBUser
  * password[primary] = myDBPass
  * table_prefix[primary] = myApp_
  *
  * host[backup] = backup.mydomain.com
  * port[backup] = 3306
  * socket[backup] = 
  * database[backup] = backupDB
  * username[backup] = myDBUser
  * password[backup] = myDBPass
  * table_prefix[backup] = myApp_
  * </pre>
  * Using this configuration, this function could be called with either "primary" or "backup"
  * as the dbConfigName argument to get the appropriate DatabaseEngine.  If no dbConfigName
  * is specified, the "primary" sub-key will be used since it appears first in the file.
  *
  * @param string|boolean dbConfigName OPTIONAL: The sub-key of the engine configuration to
  * 		pull from the {@link \hydrogen\config\Config} object.  If false or unspecified, the
  * 		first (or only) database configuration is pulled from Config.
  * @throws hydrogen\database\exceptions\DatabaseConnectionException if a connection could not
  * 		be made.
  * @return DatabaseEngine The requested DatabaseEngine with a connection to the specified
  * 		database server.
  */
 public static function getEngine($dbConfigName = false)
 {
     if ($dbConfigName === false) {
         $engines = Config::getRequiredVal('database', 'engine');
         if (is_array($engines)) {
             $engines = array_keys($engines);
             $dbConfigName = $engines[0];
         }
     }
     return static::getCustomEngine(Config::getRequiredVal('database', 'engine', $dbConfigName), Config::getVal('database', 'host', $dbConfigName), Config::getVal('database', 'port', $dbConfigName), Config::getVal('database', 'socket', $dbConfigName), Config::getVal('database', 'database', $dbConfigName), Config::getVal('database', 'username', $dbConfigName), Config::getVal('database', 'password', $dbConfigName), Config::getVal('database', 'table_prefix', $dbConfigName));
 }
コード例 #21
0
ファイル: changes.php プロジェクト: Zartas/appDB
	<h1 id="pagetitle">Upcoming Changes</h1>
	<h2 class="pheading">Top priority</h2>
	<ul>
		<li>Internationalization!  If you can help translate the text on <?php 
echo Config::getVal('general', 'site_name');
?>
, check <a href="http://hackulo.us">Hackulous</a> for updates on when we can use your skill!</li>
		<li>Implement a link reporting system, where users can inform <?php 
echo Config::getVal('general', 'site_name');
?>
 of links that are incorrect or no longer exist.</li>
		<li>Implement a link counter, which can judge the popularity of a submitted application by how many times its links were clicked on in total.  Once this is underway, results can be listed by popularity and the link-removal system can be automated.</li>
		<li>Give the links area for each application a complete overhaul.  Show which domain each link is to so you aren't forced to hover over each and look at the status bar.</li>
		<li>Implement the Link Certification System, allowing volunteers to mark links that they've certified to be working and correct.</li>
	</ul>
	<h2 class="pheading">Also in the works</h2>
	<ul>
		<li>The ability to edit your own links and manual submissions, change your password, retrieve your forgotten password, and all that other user account stuff.</li>
		<li>A reviews system.  Reviews in Apple's App Store are rarely relevant and can't be trusted, and so we're planning to have our own reviews process.  Posting reviews will require an account on <?php 
echo Config::getVal('general', 'site_name');
?>
.</li>
		<li>Back-button functionality.  Unfortunately this is still impossible to implement in all web browsers at once, but the browser's back button should function as though each page of apps or each viewed application were a separate page you could go back and forward to, rather than an AJAX call.  Note that this will not affect current AJAX functionality.</li>
		<li>A better design.  This site's design was thrown together very quickly to allow for speedy development of this web application.  It is very functional, but not very suave.  Note that this is not a high priority, as <?php 
echo Config::getVal('general', 'site_name');
?>
 believes the functionality and features provided by the other listed goals is more important.</li>
		<li>A "Watchlist" feature, where a single click will add an app to your watch list.  From there, you will be informed when it's updated.</li>
		<li>Add a manual submission form so that applications not currently available in the iTunes store can be added.</li>
		<li>Other unlisted surprises :)</li>
</div>
コード例 #22
0
ファイル: applist.php プロジェクト: Zartas/appDB
// Includes
require_once __DIR__ . '/../lib/appdb/appdb.inc.php';
use hydrogen\config\Config;
use appdb\models\ApplicationModel;
// Start us up
header("Content-type: text/xml; charset=utf-8");
// Constants
$PERPAGE = 15;
// Get the vars
$sort = isset($_GET['sort']) ? $_GET['sort'] : 'newvers';
$cat = isset($_GET['cat']) ? $_GET['cat'] : 0;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
if (isset($_POST['filter'])) {
    $_GET['filter'] = $_POST['filter'];
}
$filter = isset($_GET['filter']) && !Config::getVal('general', 'disable_search') ? trim($_GET['filter']) : false;
if ($filter) {
    $sort = "relevance";
}
// Get the apps
$am = ApplicationModel::getInstance();
$apps = $am->getAppListCached($PERPAGE, $page, $sort, $cat, $filter);
$total = $am->getResultCountCached($cat, $filter);
$curshowing = $page * $PERPAGE;
$numNextPage = $total - $curshowing;
if ($numNextPage <= 0) {
    $numNextPage = false;
} else {
    if ($numNextPage > $PERPAGE) {
        $numNextPage = $PERPAGE;
    }
コード例 #23
0
/* 
 * This line loads the application's config file.
 *
 * The first argument is the path to the config file itself.  This may be absolute,
 * or relative to the base path given above.
 *
 * The second argument dictates how the config file is cached.  If true, the
 * processed config will be cached by its filename.  If it's a string, it will
 * be cached by that string.  If false, it won't be cached at all.  The
 * recommended value is "true" unless there's a chance you'll be loading
 * multiple config files with the same name.
 *
 * If the third argument is true, it will check to see if the config file has been 
 * modified every time the page is loaded, and, when a change is detected, update the 
 * cached version of the file.  In production, this value can be set to false to save 
 * CPU cycles and stat() calls.  To make config changes take effect in this case, 
 * simply delete the cached config file.
 */
Config::addConfig('config' . DIRECTORY_SEPARATOR . 'config.ini.php', true, true);
/*
 * The rest of this file can be used to override user-specified config settings or
 * set config new items that shouldn't be presented to the user.
 */
// The folder, relative to the base path, where views for the View library are stored.
Config::setVal("view", "folder", "themes" . DIRECTORY_SEPARATOR . "default");
// The URL path to add to the general->app_url config value to target view files
// within the web browser.  This is usually the same as the folder above.
Config::setVal("view", "url_path", "themes/default");
// Alternatively, you can set an entirely new URL as the view root.  This is only
// needed in special circumstances.  Do not set this unless you know you need it.
// Config::setVal("view", "root_url", "http://cloud.domain.com/theme/default");
コード例 #24
0
ファイル: applisting.php プロジェクト: Zartas/appDB
$page += 0;
$filter = isset($_GET['filter']) && $_GET['filter'] != '*' && !Config::getVal('general', 'disable_search') ? strtolower(trim($_GET['filter'])) : '';
if (!$filter && $sort == "relevance") {
    $sort = "newvers";
}
$am = ApplicationModel::getInstance();
$apps = $am->getAppListCached($perpage, $page, $sort, $cat, $filter);
if (!$apps) {
    $jsonError = array('valid' => '0', 'error' => 'No applications matched your request.');
    die(json_encode($jsonError));
}
$total = $am->getResultCountCached($cat, $filter);
if ($sort != 'appname' && $sort != 'relevance') {
    $rsslink = Config::getVal('urls', 'base_url') . '/';
    if (Config::getVal('rewrite', 'rss_options', false) != '') {
        $rsslink .= Config::getVal('rewrite', 'rss_options');
        $rsslink = str_replace(array('%RESULTS%', '%SORT%', '%CAT%', '%FILTER%', '%TYPE%'), array('15', $sort, $cat, $filter == '' ? '*' : $filter, 'html'), $rsslink);
    } else {
        $rsslink .= "rss.php?results=15&sort={$sort}&cat={$cat}&filter={$filter}&type=html";
    }
} else {
    $rsslink = 0;
}
$jsonPage = array('valid' => 1, 'perpage' => $perpage, 'sort' => $sort, 'page' => $page, 'category' => $cat, 'filter' => $filter, 'rss' => $rsslink, 'totalapps' => $total, 'categories' => array(), 'apps' => array());
$acm = AppCategoryModel::getInstance();
$cats = $acm->getAllCached();
foreach ($cats as $bean) {
    $jsonPage['categories']["{$bean->id}"] = $bean->category_name;
}
foreach ($apps as $app) {
    $catbean = $app->getMapped('category');
コード例 #25
0
 /**
  * Creates a new instance of DatabaseEngine if the specified connection is new, or returns
  * the stored engine for a connection that an engine's already been instantiated for.  The
  * DatabaseEngine is connected as soon as it is created.
  * 
  * If no dbConfigName is specified, the database configuration from the
  * {@link \hydrogen\config\Config} object is used.  If there are multiple database configurations
  * in the Config object, the first one defined will be used here.
  *
  * If multiple database configurations have been specified in the Config object, the sub-key of
  * the appropriate configuration can be passed in for dbConfigName.  For example:
  * <pre>
  * [database]
  * host[primary] = localhost
  * port[primary] = 3306
  * socket[primary] = 
  * database[primary] = myDB
  * username[primary] = myDBUser
  * password[primary] = myDBPass
  * table_prefix[primary] = myApp_
  *
  * host[backup] = backup.mydomain.com
  * port[backup] = 3306
  * socket[backup] = 
  * database[backup] = backupDB
  * username[backup] = myDBUser
  * password[backup] = myDBPass
  * table_prefix[backup] = myApp_
  * </pre>
  * Using this configuration, this function could be called with either "primary" or "backup"
  * as the dbConfigName argument to get the appropriate DatabaseEngine.  If no dbConfigName
  * is specified, the "primary" sub-key will be used since it appears first in the file.
  *
  * @param string|boolean dbConfigName OPTIONAL: The sub-key of the engine configuration to
  * 		pull from the {@link \hydrogen\config\Config} object.  If false or unspecified, the
  * 		first (or only) database configuration is pulled from Config.
  * @throws hydrogen\database\exceptions\DatabaseConnectionException if a connection could not
  * 		be made.
  * @return DatabaseEngine The requested DatabaseEngine with a connection to the specified
  * 		database server.
  */
 public static function getEngine($dbConfigName = false)
 {
     if ($dbConfigName === false) {
         $engines = Config::getRequiredVal('database', 'engine');
         if (is_array($engines)) {
             $engines = array_keys($engines);
             $dbConfigName = $engines[0];
         }
     }
     try {
         $db = static::getCustomEngine(Config::getRequiredVal('database', 'engine', $dbConfigName), Config::getVal('database', 'host', $dbConfigName), Config::getVal('database', 'port', $dbConfigName), Config::getVal('database', 'socket', $dbConfigName), Config::getVal('database', 'database', $dbConfigName), Config::getVal('database', 'username', $dbConfigName), Config::getVal('database', 'password', $dbConfigName), Config::getVal('database', 'table_prefix', $dbConfigName));
     } catch (DatabaseConnectionException $e) {
         // Re-throw exception to remove DB credentials from the stack trace
         throw new DatabaseConnectionException($e->getMessage());
     }
     return $db;
 }
コード例 #26
0
ファイル: domains.php プロジェクト: Zartas/appDB
<div id="page_domains" class="staticpage">
	<h1 id="pagetitle">Approved Domains</h1>
	<h2 class="pheading">Approved what?</h2>
	<p><?php 
echo Config::getVal('general', 'site_name');
?>
 has a level of quality to maintain, and we pride ourselves on how easy and useful this site is.  However, there are many file-sharing services out there whose quality and level of service are so abysmal that we can't even imagine forcing <?php 
echo Config::getVal('general', 'site_name');
?>
 users to download from there.  Unfortunately, some of our greedier users started posting links to these sites due to payment benefits they offered.  Their greed was making <?php 
echo Config::getVal('general', 'site_name');
?>
 worse for everyone!  So we've locked down the links you can submit to a set list of sites.</p>

	<h2 class="pheading">I know a good site that's not in this list!</h2>
	<p>Fantastic!  Contact the <?php 
echo Config::getVal('general', 'site_name');
?>
 author to have it added :)</p>

	<h2 class="pheading">Approved file-sharing sites</h2>
	<p>
		<ul>
			<?php 
foreach (Config::getVal('domains', 'allowed') as $aldm) {
    echo "<li><a href=\"http://{$aldm}\">{$aldm}</a></li>\n";
}
?>
		</ul>
	</p>
</div>
コード例 #27
0
ファイル: appsubmit.php プロジェクト: Zartas/appDB
if (!class_exists('hydrogen\\config\\Config', false)) {
    die("Quit trying to hack my damn code.");
}
function returnBadRequest()
{
    die(json_encode(array('success' => 0, 'errormsg' => 'Bad request.')));
}
// Must be logged in
if (!UserSession::getUserBean()) {
    die(json_encode(array('success' => 0, 'errormsg' => 'You must be logged in to submit links.')));
}
// Can't be done via proxy
require_once __DIR__ . '/../lib/proxydetector/proxy_detector.php';
$pd = new proxy_detector();
if ($pd->detect()) {
    die(json_encode(array('success' => 0, 'errormsg' => 'Sorry, ' . Config::getVal('general', 'site_name') . ' does not accept submissions from proxy servers.')));
}
// Assert that we have the essential value
if (!isset($_POST['id']) || !preg_match("/\\d+/", $_POST['id'])) {
    returnBadRequest();
}
$itunes_id = $_POST['id'];
// Get cracker
$cracker = false;
if (isset($_POST['crackersel'])) {
    if ($_POST['crackersel'] == 'me') {
        $bean = UserSession::getUserBean();
        $cracker = $bean->username;
    } else {
        if ($_POST['crackersel'] == 'other' && isset($_POST['crackerother']) && trim($_POST['crackerother']) != '') {
            $cracker = trim($_POST['crackerother']);
コード例 #28
0
ファイル: index.php プロジェクト: JackHarley/AwesomeIRCBotWeb
 * Index page for AwesomeIRCBotWeb
 * Includes all the library files and dispatches
 * the request to a controller
 *
 * Copyright (c) 2011, Jack Harley
 * All Rights Reserved
 */
session_start();
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set("display_errors", "On");
date_default_timezone_set('UTC');
require_once __DIR__ . "/lib/hydrogen/hydrogen.inc.php";
require_once __DIR__ . "/lib/awesomeircbotweb/awesomeircbotweb.inc.php";
use hydrogen\controller\Dispatcher;
use hydrogen\view\View;
use hydrogen\config\Config;
use hydrogen\errorhandler\ErrorHandler;
use awesomeircbotweb\models\UserModel;
use awesomeircbotweb\models\ChannelModel;
ErrorHandler::attachErrorPage();
View::setVar("channel", Config::getVal("general", "channel"));
View::setVar("ircAddress", Config::getVal("general", "irc_network_address"));
$um = UserModel::getInstance();
$nick = $um->getLoggedInNick();
if ($nick) {
    View::setVar("loggedInUser", $nick);
}
Dispatcher::addHomeMatchRule("\\awesomeircbotweb\\controllers\\HomeController", "index");
Dispatcher::addPathInfoAutoMapRule("\\awesomeircbotweb\\controllers", "Controller");
Dispatcher::addMatchAllRule("\\awesomeircbotweb\\controllers\\ErrorController", "notFound");
Dispatcher::dispatch();
コード例 #29
0
	'lib/myapp/filters/BorkFilter.php'); */
//HydrogenEngine::addFilterNamespace('\myapp\filters');
/***  FOR THE 'hydrogen' VIEW ENGINE ONLY:
 ***  Custom tag declarations
 ***
 ***  The following methods can be used to add custom tags to the Hydrogen
 ***  templating engine without them physically existing in the Hydrogen
 ***  library folder or namespace.  The first method declares classes
 ***  individually (with optional file path if it won't be autoloaded), while
 ***  the second adds a namespace from which tags can be autoloaded.  See
 ***  the documentation in hydrogen/view/engines/hydrogen/HydrogenEngine.php
 ***  for details and usage.
 ***/
/*HydrogenEngine::addTag('onweekdays', '\myapp\tags\OnweekdaysTag',
	'lib/myapp/tags/OnweekdaysTag.php'); */
//HydrogenEngine::addTagNamespace('\myapp\tags');
/***  [view] -> use_cache
 ***  This is a REQUIRED value
 ***
 ***  This value controls the cacheing of compiled views.  This *dramatically*
 ***  increases the performance of your view rendering, shaving a considerable
 ***  amount execution time, RAM, and CPU usage off of each request.  If on,
 ***  each view will be loaded from a raw PHP file (opcode-cached if you're
 ***  using something like XCache or APC) inside of the cache folder defined
 ***  above.  However, any time a change is made to a view template, the cached
 ***  files will have to be manually deleted to cause Hydrogen to recompile the
 ***  view.  It is recommended to leave this off during development to avoid
 ***  that hassle, but keep it on in production.
 ***/
Config::setVal("view", "use_cache", false);
コード例 #30
0
 protected function uniqueKey($type, $key)
 {
     return Config::getRequiredVal('recache', 'unique_name') . ':' . $type . ':' . $key;
 }