示例#1
0
文件: Config.php 项目: reedboat/wflib
 public function append($config = array())
 {
     if (!is_array($config)) {
         $config = array();
     }
     self::$_config = array_merge_recursive2(self::$_config, $config);
 }
示例#2
0
文件: Api.php 项目: reedboat/wflib
 /**
  * authenticate api鉴权方法
  */
 public function authenticate()
 {
     $data = $_SERVER['REQUEST_METHOD'] == 'GET' ? $_GET : $_POST;
     $type = $_SERVER['REQUEST_METHOD'] == 'GET' ? 'read' : 'write';
     $param = new WF_Parameter();
     $token = $param->query('token', '');
     $ts = $param->query('ts', 0);
     $ua = $param->query('ua', '');
     if (!WF_Config::get("auth.{$type}", false)) {
         return true;
     }
     if (!$token || !$ts || !$ua) {
         throw new LogicException('授权参数缺失', 403);
     }
     if (abs(time() - $ts) > 300) {
         throw new LogicException('鉴权超时', 403);
     }
     $tokenizer = new Token();
     if (!$tokenizer->check($token, $ua, $ts, $data)) {
         throw new LogicException('未授权的访问', 403);
     }
 }
示例#3
0
<?php

// change the following paths if necessary
require_once 'inc/tags/lib/Loader.class.php';
WF_Loader::registerAutoload();
require_once "inc/tags/TagArticles.inc.php";
require_once "inc/tags/Tag.inc.php";
require_once "inc/tags/ArticleTags.inc.php";
require_once "inc/tags/ArticleMini.inc.php";
require_once "inc/tags/TagsKey.inc.php";
require_once "inc/tags/TagSite.inc.php";
require __DIR__ . '/fixtures/util.func.php';
$conf = (require __DIR__ . '/config/test.conf.php');
define("ROOT_DIR", __DIR__);
WF_Registry::set('logger', new WF_Logger());
$instance = WF_Db::instance($conf['db']);
WF_Registry::set('db', $instance);
unset($instance);
WF_DbTestCase::setBasePath(ROOT_DIR . "/fixtures");
WF_Event::bind('addArticleTag', array(TagArticles::model(), 'onAddArticleTag'));
WF_Event::bind('removeArticleTag', array(TagArticles::model(), 'onRemoveArticleTag'));
$redis = new Redis();
$redis_config = $conf['redis'];
$redis->connect($redis_config['host'], $redis_config['port']);
$redis->flushAll();
WF_Registry::set('cache', $redis);
WF_Registry::set('redis', $redis);
WF_Config::set('tagitem_use_cache', true);
TagSite::refresh(__DIR__ . '/data/sites.dat');
$id = TagSite::getSiteId('news');
示例#4
0
文件: Util.php 项目: reedboat/wflib
 public function serialize($data, $seperator = null)
 {
     if (is_string($data)) {
         return $data;
     }
     $arr = array();
     foreach ($data as $key => $value) {
         if (is_integer($key)) {
             array_push($arr, $value);
         } else {
             array_push($arr, strtoupper($key));
             if (strval($value) === '') {
                 $value = '-';
             }
             array_push($arr, $value);
         }
     }
     if ($seperator == null) {
         $seperator = WF_Config::get('log_seperator', "\t");
     }
     return implode($seperator, $arr);
 }