<file_sep><?php

error_reporting(E_ALL);

header('HTTP/1.1 404 Not Found');<file_sep><?php

/**
 * YAF引导类， 
 *
 *
 *
 *
 *
 * 
 */
class Bootstrap extends Yaf_Bootstrap_Abstract
{

    // public function _initPlugin(Yaf_Dispatcher $dispatcher) {
    //     $user = new UserPlugin();
    //     $dispatcher->registerPlugin($user);
    // }

	public function _initConfig()
	{
		
	}
}<file_sep><?php

class LoginController extends core_Commonents
{
	public function init()
	{
		parent::init(FALSE);
	}

	public function indexAction()
	{
		$this->getView()->display('login/index.tpl');
	}
}<file_sep><?php

function bootstrap_add_route($dispatcher)
{
	$router = $dispatcher->getRouter();
	
	$articles_detail_ = new Yaf_Route_Regex(
		'%details/([a-zA-Z0-9\/]+)%',
		array(
		    'controller' => 'Articles',
		    'action' => 'detail'
		),
		array(
		    1 => 'id'
		)
	);
	$router->addRoute('articles_detail_', $articles_detail_);

 
    $category_router = new Yaf_Route_Regex(
    	'%category/([a-zA-Z0-9\/]+)%',
    	array(
    		'controller' => 'Classify',
    		'action'     => 'groups'
    	),
    	array(
    		1 => 'category',
    	)
    );

    $router->addRoute('category_router', $category_router);
}<file_sep><?php

class core_Base extends Yaf_Controller_Abstract
{

	private $smarty;

	public function init()
	{
		$this->_initSmarty();
	}

	private function _initSmarty()
	{
		$smarty = new Helper_Smarty();
        $this->smarty = $smarty;
	}

	//重写YAF getView方法， 使其使用smarty引擎
	public function getView()
	{
		return $this->smarty;
	}

	public function set_assign($name, $value)
	{
		$this->smarty->assign($name, $value);
	}

	public function set_display($path)
	{
		//$this->smarty->default_modifiers = array('$' => 'escape:"html"');
		$this->smarty->display($path);
	}


}<file_sep>[product]
application.directory = APP_PATH;
application.view.ext  = tpl;
application.bootstrap = BASE_PATH "/conf/bootstrap.php";
application.modules   = "Index, V1"

;application.ext		String	php	PHP脚本的扩展名
;application.bootstrap	String	Bootstrapplication.php	Bootstrap路径(绝对路径)
;application.library	String	application.directory + "/library"	本地(自身)类库的绝对目录地址
;application.baseUri	String	NULL	在路由中, 需要忽略的路径前缀, 一般不需要设置, Yaf会自动判断.
;application.dispatcher.defaultModule	String	index	默认的模块
;application.dispatcher.throwException	Bool	True	在出错的时候, 是否抛出异常
;application.dispatcher.catchException	Bool	False	是否使用默认的异常捕获Controller, 如果开启, 在有未捕获的异常的时候, 控制权会交给ErrorController的errorAction方法, 可以通过$request->getException()获得此异常对象
;application.dispatcher.defaultController	String	index	默认的控制器
;application.dispatcher.defaultAction	String	index	默认的动作
;application.view.ext	String	phtml	视图模板扩展名
;application.modules	String	Index	声明存在的模块名, 请注意, 如果你要定义这个值, 一定要定义Index Module
;application.system.*	String	*		通过这个属性, 可以修改yaf的runtime configure, 比如application.system.lowcase_path, 但是请注意只有PHP_INI_ALL的配置项才可以在这里被修改, 此选项从2.2.0开始引入<file_sep><?php

class Config
{
	private static $_data = NULL;

	/**
	 *
	 * 
	 * @param [type] $key   [description]
	 * @param [type] $value [description]
	 */
	public static function set($key, $value = NULL)
	{
		if (is_array($key)) {
			foreach ($key as $key_item => $value_item) {
				if (empty($key_item)) continue;
				self::$_data[$key_item] = $value_item;
			}

		} else {
			self::$_data[$key] = $value;
		}
	}

	public static function get($key)
	{
		if(empty($key) || !isset(self::$_data[$key])) return FALSE;
		return self::$_data[$key];
	}
}













$all = [

	'BaseURL' => 'http://www.yaftest1.com',

];









Config::set($all);
Config::set($dbconfig);
$all = NULL;
$dbconfig = NULL;
<file_sep><?php

class MysqldbModel extends DBModel
{

	public function __construct($tableName)
	{
		parent::__construct($tableName, 'Mysql');
	}

	/** 
	 * 
	 * example 1.
     * where(array(
     *   'key1' => 'value1',
     *   'key2' => NULL,
     *   'key3' => array('!=' => 'value3'),
     *   'key4' => array('value4_1', 'value4_2')
     * ));
     *
     * output : WHERE `key1`='value1' AND `key2` is NULL AND `key3` != 'value3' AND (`key4` = 'value4_1' OR `key4` = 'value4_2')
     *
     * example 2.
     * where(array(
     *    array('key1' => array('like' => '%value1%')),
     *    array(
     *          'key2' => 3,
     *          'key3' => 4,
     *    )
     * ), array(
     *   'order_by' => 'id DESC',
     *   'offset' => 10,
     *   'limit' => 20,
     * ));
     * 
     * output: WHERE (`key1` like '%value1%') OR (`key2`='3' AND `key3`='4') ORDER BY id DESC LIMIT 10, 20
     *
     * select(
     * 	['id' => 1],
     *  [
     *  	'fields' => 'name,age,okok,xxxxxxxx'//可以    count_num AS `total`  取别名
     *      'order_by' => 'id DESC',
	 *      'offset' => 10,
	 *      'limit' => 20,
     *  ]
     * )
     *
     * output  select name,age,okok,xxxxxxxx,haha form 表名 where id = 1 order by id desc limit 10,20
     *
     * 
     */
	public function select($where, $attrs = [])
	{
		$pdo = $this->initPDO(TRUE);//read

		$sql           = $this->_sql_makeer->where($where, $attrs);
		$table         = $this->_table_name;
		$select_fields = isset($attrs['fields']) ? $attrs['fields'] : '*';
		$sql           = "select {$select_fields} from {$table}" . $sql;

		return $this->selectBySql($sql);
	}


	/**
	 * 插入数据
     * 
     * 单行数据
     * insert(array(
     *   'key1' => 'val1',
     *   'key2' => '&/CURRENT_TIMESTAMP',
     * ));
     *
     * output : (`key1`,`key2`) VALUES ('val1',CURRENT_TIMESTAMP)
     *
     * 多行数据
     * insert(array(
     *    'key1', 'key2',
     * ), array(
     *      array('val11', 'val12'),
     *      array('val21', 'val22')
     * ));
     * output: (`key1`,`key2`) VALUES ('val11','val12'),('val21','val22')
     *
     * 
	 * @param  array   $data           [description]
	 * @param  [type]  $rowsData       不为空是可批量插入
	 * @param  boolean $return_last_id 是否返回lastID, 
	 * @return boolean|int
     *
     * @todo  返回lastid总是0， 。。。。。。
     * 
	 */
	public function insert($data = [], $rowsData = NULL, $return_last_id = TRUE)
	{
		$pdo   = $this->initPDO(FALSE);//wrrite
		
		$sql   = $this->_sql_makeer->insert($data, $rowsData);
		$table = $this->_table_name;
		$sql   = "insert into {$table}" . $sql;
		//insert into sss (`key1`,`key2`) VALUES ('xxx1','xxx1'),('xxx2','xxx2')

		//这里可以加入日志配置
		$sth = $pdo->prepare($sql);
        $ret = $sth->execute();
        $this->_errors['errorCode'] = $sth->errorCode();
        $this->_errors['errorInfo'] = $sth->errorInfo();
        if ($ret === FALSE) {
        	//数据库出错,    这里可以加入日志配置
        	return FALSE;
        }
        if ($return_last_id) {
        	return $this->getLastId();
        }
        return TRUE;
	}

	/**
     * @example
     * update(array(
     *   'key1' => 'value1',
     *   'key2' => '&/CURRENT_TIMESTAMP',
     * ));
     * output: " (`key1`,`key2`) VALUES ('value1',CURRENT_TIMESTAMP)"
     * 
     * @param array $data
     * @return string
     */
	public function update($where, $data = [])
	{
		if (empty($data)) return FALSE;

		$pdo   = $this->initPDO(FALSE);//wrrite

		$sql_update = $this->_sql_makeer->update($data);
		$sql_where  = $this->_sql_makeer->where($where);
		$table      = $this->_table_name;

		$sql = "UPDATE {$table} " . $sql_update . $sql_where;

		$res = $this->selectBySql($sql);
		return $res === FALSE ? FALSE : TRUE;
	}
}<file_sep><?php

public class core_Auth extends core_AbcBase
{
	private $base = null;

	public function __construct(core_Base $base)
	{
		$this->base = $base;
	}

	public function init()
	{
		$this->base->init();
		echo "<h1>core_Auth init</h1>";
	}
}<file_sep><?php

error_reporting(E_ALL);

//定义项目跟路径
define('BASE_PATH',  realpath( dirname(__FILE__).'/../'));

//定义应用路径
define('APP_PATH', realpath( BASE_PATH . '/application/'));

//应用入口路径
defined('PUBLIC_PATH') or define('PUBLIC_PATH', realpath(BASE_PATH . '/public/'));


//引入全局引导配置，
require PUBLIC_PATH . '/bootstrap.php';

//yaf 加载应用配置文件
//$yaf = new Yaf_Application(BASE_PATH . '/conf/application.ini');
$yaf = new Yaf_Application(
	[
	    'application' => [
                'directory' => APP_PATH,
                'modules' => "Index,Demo",
                'view'    =>   [
                    'ext'  => 'tpl',
                ],
                // 'dispatcher' => [
                //     'defaultController' => 'index',
                //     'defaultAction' => 'index',
                //     'catchException' => false,
                //     'defaultModule' => 'V1',
                //     'throwException' => true,
                // ],
                // 'bootstrap' => BASE_PATH . "/conf/bootstrap.php",
		]
	]
);

$dispatcher = $yaf->getDispatcher();
$dispatcher->autoRender(FALSE);//关闭默认视图输出FALSE, 开启为默认TRUE

bootstrap_add_route($dispatcher);


//运行yaf
$yaf->run();
	//->bootstrap()//可选的调用, 起用时， 要指定bootstrap文件所在地址
<file_sep>$(function() {
    var testEditormdView;
    var id = article_id;
    $.get("/articles/getContent", {id:id}, function(markdown) {
        if (markdown.code == 0) {
            testEditormdView = editormd.markdownToHTML("test-editormd-view2", {
                markdown        : markdown.result ,//+ "\r\n" + $("#append-test").text(),
                //htmlDecode      : true,       // 开启 HTML 标签解析，为了安全性，默认不开启
                htmlDecode      : "style,script,iframe",  // you can filter tags decode
                //toc             : false,
                tocm            : true,    // Using [TOCM]
                //tocContainer    : "#custom-toc-container", // 自定义 ToC 容器层
                //gfm             : false,
                //tocDropdown     : true,
                // markdownSourceCode : true, // 是否保留 Markdown 源码，即是否删除保存源码的 Textarea 标签
                emoji           : true,
                taskList        : true,
                tex             : true,  // 默认不解析
                flowChart       : true,  // 默认不解析
                sequenceDiagram : true,  // 默认不解析
            });
        } else {
            layer.alert('获取文章内容失败，请尝试重新加载！');
        }
    }, 'JSON');
    
});<file_sep><?php

class TopsModel extends MysqldbModel
{
	public function __construct()
	{
		parent::__construct('tops');
	}
}<file_sep><?php

class Helper_Test
{
	private $name = 'helper_test';

	public function getName()
	{
		return $this->name;
	}

	public function guid() {
	    $charid = strtoupper(md5(uniqid(mt_rand(), true)));
	    $uuid =
	    substr($charid, 0, 8).
	    substr($charid, 8, 4).
	    substr($charid,12, 4).
	    substr($charid,16, 4).
	    substr($charid,20,12);
	    return $uuid;
	}
}<file_sep><?php

interface service_DB extends service_BaseDB
{

	public function select($where, $attrs = []);


	public function insert($data = [], $rowsData = NULL, $return_last_id = TRUE);


	public function update($where, $data = []);


	public function delete($where);
}<file_sep><?php
/**
 *
 * 核心模型类
 *
 *
 *
 * 
 */
abstract class DBModel implements service_DB
{

	protected $_default_sql_makeer = 'Mysql';

	protected $_table_name = '';

	protected $_table_prefix = '';

	protected $_errors = [];

	protected $_pdo = NULL;

	protected $_sql_makeer = NULL;

	protected $_dbconfig = NULL;

	protected $_isread = TRUE; //默认是读， 从从库读取数据， 主库插入数据

	const DB_SLAVE = 'read'; //常量，从数据库配置数组键名
	const DB_MASTER = 'write';

	public function __construct($tableName, $sqlMakeer = '')
	{
		if (empty($tableName)) {
			throw new exception_Exception('The tabme name non\'t allow null!!!');
		}
		
		if (!empty($sqlMakeer))
			$this->_default_sql_makeer = $sqlMakeer;

		$sql = 'sql_' . $this->_default_sql_makeer;
		try {
			$this->_sql_makeer = $sql::getInstance();
		} catch (exception_Exception $e) {
			throw new exception_Exception('sqlMakeer is nont extise, on ' . $e->getLine(), 1);
		}

		$configs = Config::get('DBConfig');
		if (empty($configs)) throw new exception_Exception('db propertince is error, ' . $e->getLine(), 1);
		if($isread) {
			$index = rand(1, count($configs[self::DB_SLAVE]));
			$this->_dbconfig = $configs[self::DB_SLAVE][$index-1];
		} else {
			$this->_dbconfig = $configs[self::DB_MASTER];
		}
		$this->_table_prefix = $this->_dbconfig['prefix'];
		$this->_table_name = $this->_dbconfig['prefix'].$tableName;
	}


	/**
	 * 
	 * 初始化pdo链接， 在crud操作前请先初始化pdo操作， 因为该操作会读取数据库配置、
	 * 
	 * @param  boolean $isread 主从配置关键， true代表从从机上获取数据，false代表从master获取，
	 *                         一般insert，delete用主机， 其余用从机
	 * @return PDO 		PDO object
	 */
	protected function initPDO($isread = TRUE)
	{
		static $instance = NULL;
		$kk = $isread ? 'read' : 'write';
		if (isset($instance[$kk]) && is_object($instance[$kk])) {
			return $instance[$kk];
		}

		$dns = $this->_dbconfig['dns'];
		$driver_options = NULL;
		try {
			$pdo = new PDO($dns, $this->_dbconfig['user'], $this->_dbconfig['password'], $driver_options);
			$this->_pdo = $pdo;
			$instance[$kk] = $pdo;
		} catch (exception_Exception $e) {
			throw new exception_Exception('sqlMakeer is nont extise, on ' . $e->getLine(), 1);
		}
		return $this->_pdo;
	}

	/**
	 * 外部调用数据库操作失败接口
	 * 
	 * @return array 
	 */
	public function getErrors()
	{
		return $this->_errors;
	}


	public function getTableName()
	{
		return $this->_table_name;
	}

	public function getTabblePrefix()
	{
		return $this->_table_prefix;
	}


	private function join($tag = 'INNER')
	{
		$table_master = $this->_table_name;

		$sql = 'select * from table_master inner join ';

	}

	/**
	 * $obj->join('left, inner, reight')
	 *     ->table('tablename', 'bieming')
	 *     ->where('id = id')
	 *     ->order()
	 *     ->limit()
	 *
	 *
	 *
	 * 
	 */



	/**
	 * 查询一个
	 * 
	 * @param  array $where 查询条件  参考Mysqldb select方法，
	 * @param  array  $attrs 字段、分页等
	 * @return
	 */
	public function selectOne($where, $attrs = [])
	{
		$attrs['limit'] = 1;
        $attrs['offset'] = 0;
        
        $res = $this->select($where, $attrs);
        if ($res === FALSE) {
            return FALSE;
        }

        if (empty($res)) {
            return NULL;
        }

        return array_pop($res);
	}


	/**
	 * 计数
	 * 
	 * @param  array $where  查询条件  参考Mysqldb select方法，
	 * @return
	 */
	public function selectCount($where)
	{
		$attrs['fields'] = 'count(*) AS `total`';
		$res = $this->selectOne($where, $attrs);

		if ( !empty($res)){
			return intval(['total']);
		}
		return 0;
	}


	/**
	 * 
	 *  获取最好一条ID， 可能不同数据库获取不同， （mysql）是可以这样获取的
	 *  若其他数据库获取方式不同， 子类可覆盖该方法
	 *
	 * 
	 * @return [type] [description]
	 */
	protected function getLastId()
	{
		$pdo = $this->initPDO(FALSE);
		return $pdo->lastInsertId();
	}


	/**
	 * 
	 * 根据sql查询数据
	 * 
	 * @param  string $sql sql语句
	 * @return boolean|array  返回结果， FALSE表示数据库操作失败，
	 */
	protected function selectBySql($sql)
	{

		$sth = $this->_pdo->prepare($sql);
        $ret = $sth->execute();
        $this->_errors['errorCode'] = $sth->errorCode();
        $this->_errors['errorInfo'] = $sth->errorInfo();
        if ($ret === FALSE) {
        	//数据库出错,    这里可以加入日志配置
        	return FALSE;
        }
        return $sth->fetchAll(PDO::FETCH_ASSOC);
	}

	/**
	 * 
	 * 根据条件删除
	 * 
	 * @param  array $where 
	 * @return int 返回删除受影响的行数
	 */
	public function delete($where)
	{
		$pdo   = $this->initPDO();
		$table = $this->_table_name;

		$sql   = $this->_sql_makeer->where($where);
		$sql   = "DELETE FROM {$table}" . $sql;

		return $this->selectBySql($sql);
	}


	/**
	 * 直接执行sql
	 * @param  [type]  $sql    [description]
	 * @param  boolean $isread [description]
	 * @return [type]          [description]
	 */
	public function execute($sql, $isread = TRUE)
	{
		$pdo = $this->initPDO($isread, $isread);
		return $this->selectBySql($sql);
	}


	//由于不同数据库sqlmaker返回可能不一样， 所有具体的crud也不一样，
	//所yi数据库的crud应该根据具体数据库来配置
	public abstract function select($where, $attrs = []);

	public abstract function insert($data = [], $rowsData = NULL, $return_last_id = TRUE);

	public abstract function update($where, $data = []);

	

}<file_sep><?php

session_start();

var_dump($_SESSION);

$_SESSION['xxxx'] = 222;
<file_sep>
<?php

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\FirePHPHandler;

class IndexController extends core_Commonents
{

	private $logger = NULL;

	public function init()
	{
		parent::init(FALSE);

		// Create the logger
		$logger = new Logger('my_logger');
		// Now add some handlers
		$logger->pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG));
		$logger->pushHandler(new FirePHPHandler());

		$this->logger = $logger;
	}
	
	public function indexAction()
	{
		echo "Hello world";
		//$this->getView()->assign('content', '你好， 世界！22');

		// You can now use your logger
		$this->logger->addInfo('My logger is now ready');

		//$this->getView()->display('index/index.tpl');
	}

	public function actionPostAction()
    {
        $url = 'www.yaftest1.com/Demo/index/Require_post';
        $data = array(
            'name' => 'ethan',
            'gender' => 'male',
        );

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        //curl_setopt($ch, CURLOPT_POST,1);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
        
        //特别注意， 请求头设置为这样， $_POST是接收不到数据的，详情看下文链接
        //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    
        $result = curl_exec($ch); 
        curl_close($ch);      
        print_r($result);
    }

    public function Require_postAction()
    {
        $post = $_POST;
        print_r($post);
    }


    


}<file_sep><?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 16:01:06
         compiled from "static\common\inc\js_lib.tpl" */ ?>
<?php /*%%SmartyHeaderCode:2308956f22e67abb040-05286353%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '41137f215a8b7cf8312adadfcf93f1482853d4a5' => 
    array (
      0 => 'static\\common\\inc\\js_lib.tpl',
      1 => 1458720017,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '2308956f22e67abb040-05286353',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_56f22e67abeec6_98928943',
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56f22e67abeec6_98928943')) {function content_56f22e67abeec6_98928943($_smarty_tpl) {?><script src="//lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="/static/plugins/layer/layer.js"></script>
<script src="/static/plugins/layer/extend/layer.ext.js"></script><?php }} ?>
<file_sep><?php

class RegisterController extends core_Commonents
{

	public function init()
	{
		parent::init(FALSE);
	}

	public function indexAction()
	{
		$this->getView()->display('register/index.tpl');
	}
}<file_sep><?php

class service_Wocao
{

	public function __construct()
	{
		echo "----";
	}


	public function fanshe($moduleName, $controllerName, $acctionName)
	{
		$class = new \ReflectionClass($controllerName);
	}



	public function __destruct()
	{
		echo "end------------";
	}
	
}<file_sep><?php

class TestController extends core_Commonents
{
	
	public function init($check = true)
	{
		parent::init(FALSE);
	}

	public function indexAction()
	{
		
		$sip = 'ssttp://sss.ss.ss';
		$sip = stripos($sip, 'http://');
		var_dump($sip);

		$name = gettext('你好世界！');

		$this->getView()->assign('name', $name);
		$this->getView()->display('test/index.tpl');
	}


	public function xxx1Action()
	{
		$this->getView()->display('test/t.tpl');
	}


	public function xxx2Action()
	{
		$imageStrs = $_POST['IMGSTR'];

		$image = explode('__', $imageStrs, -1);

		foreach($image as $key => $v) {
			unset($image[$key]);

			$image[$key]['image_src'] = $v;
			$v=substr($v,-4);//去除前面
			$image[$key]['image_name'] = mt_rand(1, 1111) .$v;
		}
		print_r($image);
	}


	public function ajaxFileAction()
	{
		var_dump($_GET);
		var_dump($_POST);
		var_dump($_FILES);

		echo json_encode(['error' => 'success']);
	}

	public function ajaxFileShowAction()
	{
		$this->getView()->display('test/ajax.tpl');
	}

	public function wocaocaoAction()
    {
    	$this->getView()->display('test/wwwww.tpl');
    }

    public function wocaocao2Action()
    {
    	var_dump($_POST);
    }

}<file_sep><?php

class Helper_Http
{

	/**
	 * 获得请求URL，不含协议
	 * @return string
	 */
	public static function getFormUrl()
	{
		return $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
	}
	
	/**
	 * 获得请求URL，含协议
	 * @return string
	 */
	public static function getFullUrl()
	{
		return 'http://' . static::getFormUrl();
	}
}<file_sep><?php

class core_Commonents extends core_Base
{
	
	protected $user = NULL;

	protected $_id = 1;//当前用户ID

	protected $islogin = FALSE;

	protected $_is_ajax = FALSE;
	
	protected $_is_post = FALSE;

	/**
	 * INIT 
	 * @param  boolean $check 是否需要登录
	 * @return [type]         [description]
	 */
	public function init($check = TRUE)
	{
		parent::init();

		if ($check)
		$this->_checkLogging();

		if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
			$this->_is_ajax = TRUE;
		}

		if ( !empty($_POST)) {
			$this->_is_post = TRUE;
		}
	}

	public function wocao()
	{
		echo "core_Commonents wocao";
	}

	protected function _checkLogging()
	{
		if (empty($this->user)) $this->redirect();
	}

	/**
	 * 重定向
	 * 
	 * @param  string  $url  重定向URL
	 * @param  integer $code 状态码
	 * @return exit script
	 */
	public function redirect($url = '' , $code = 302)
	{
		if ( empty($url)) $url = Config::get('BaseURL') . '/login';
		$call = Helper_Http::getFullUrl();
		$url .= '?form='.urlencode($call);
		header('Location:'.$url, TRUE, $code);
		exit;
	}


	/**
	 * ajax return success
	 * 
	 * @param  string  $message [description]
	 * @param  array   $data    [description]
	 * @param  integer $code    [description]
	 * @return json
	 */
	protected function _ajax_return_success($message = 'SUCCESS', $data = [], $code = 0)
	{
		$json_data = [
			'msg' => $message,
			'code' => $code,
			'result' => $data,
		];
		$this->_print_json($json_data);
	}

	/**
	 * ajax return failed
	 * 
	 * @param  string  $message [description]
	 * @param  integer $code    [description]
	 * @return json
	 */
	protected function _ajax_return_failed($message = 'service exception, plase try again!!', $data = [], $code = 500)
	{
		$json_data = [
			'msg' => $message,
			'code' => $code,
			'result' => $data,
		];
		$this->_print_json($json_data);
	}

	/**
	 * print json to page
	 * 
	 * @param  array  $data [description]
	 * @return 
	 */
	protected function _print_json($data = [])
	{
		$json = json_encode($data);
		echo $json;
		exit;
	}

	public function show_404()
	{
		$this->getView()->display('common/404.tpl');
		exit;
	}

}<file_sep>
<?php

class IndexController extends core_Commonents
{

	use trait_Session;

	public function init($c = TRUE)
	{
		parent::init(FALSE);
		
	}
	
	// public function wocao()
	// {
	// 	echo "IndexController wocao";
	// }

	/**
	 * 
	 * 
	 * @return [type] [description]
	 */
	public function indexAction()
	{
		$this->wocao();
		echo "Hello world";

		// $x = new service_Wocao();

		// list($m, $c, $a) = $this->getRequestURI();
		// $x->fanshe($m, $c, $a);
		// $x = null;
		// $this->getView()->assign('content', '你好， 世界！22');

		// //$this->set_assign('content', '你好， 世界！');

		// //$this->disableView(); //关闭视图输出

		// $this->getView()->display('index/index.tpl');
	}

	public function aaaAction()
	{
		$aa = new UserPlugin();
		var_dump($aa);
	}

	public function testAction()
	{
		// $db = new MysqldbModel('onetable');
		// $ok = $db->delete(['id' => 2]);

		// var_dump($ok);
		// var_dump($db->getErrors());
		$this->getView()->display('test/test_upload.tpl');
	}


	public function uploadAction()
	{
		echo "<h1>--------------------get--------------------</h1>";
		var_dump($_GET);
		echo "<h1>--------------------post--------------------</h1>";
		var_dump($_POST);
		echo "<h1>--------------------file--------------------</h1>";
		var_dump($_FILES);
	}


	//http://www.yaftest1.com/index/pic
	public function picAction()
	{
		var_dump($_GET);
		foreach ($pics as $key => $value) {
			$data[] = [
				'image_src'  =>$value,
				'image_name' => mt_rand(1, 1111) . '.jpg'
			];
		}
	}


	public function httptestAction()
	{


		// var_dump($_POST);

		// echo "----------\r\n";

		// var_dump($http_raw_post_data);

		$raw_post_data = file_get_contents('php://input', 'r'); 
		var_dump($raw_post_data);

	}

	/**
     * 获得当前请求的 m + c + a
     * @return [type] [description]
     */
    protected function getRequestURI()
    {
        $module_name     = $this->getRequest()->getModuleName();
        $controller_name = $this->getRequest()->getControllerName();
        $action_name     = $this->getRequest()->getActionName();

        return [$module_name, $controller_name, $action_name];
    }



}<file_sep>## YAF

> yaf自身有自己的加载机制， 只要满足特定的文件夹格式， 无需再自己配置`autoload`，


<file_sep><?php

interface service_BaseDB
{
	
}<file_sep><?php

/**
 *
 *
	1	routerStartup	
		在路由之前触发	这个是7个事件中, 最早的一个. 
		但是一些全局自定的工作, 还是应该放在Bootstrap中去完成

	2	routerShutdown	路由结束之后触发	
		此时路由一定正确完成, 否则这个事件不会触发

	3	dispatchLoopStartup	分发循环开始之前被触发	 

	4	preDispatch	分发之前触发	如果在一个请求处理过程中, 
		发生了forward, 则这个事件会被触发多次

	5	postDispatch	分发结束之后触发	此时动作已经执行结束, 
		视图也已经渲染完成. 和preDispatch类似, 此事件也可能触发多次

	6	dispatchLoopShutdown	分发循环结束之后触发
		此时表示所有的业务逻辑都已经运行完成, 但是响应还没有发送
 *
 * 
 */
class UserPlugin extends Yaf_Plugin_Abstract
{
	
	/*public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {
    	echo "routerStartup";
    }

	public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {
		echo "routerShutdown";
	}*/



}<file_sep><?php

class ClassifyController extends core_Commonents
{

	public function init()
	{
		parent::init(FALSE);
	}

	public function groupsAction()
	{
		$group = $this->getRequest()->getParam('category');

		


		$class = new ArticleModel();
		$table1 = $class->getTableName();
		$table2 = $class->getTabblePrefix() . 'classify';

		$sql = "select * from {$table1} as table1 inner join {$table2} as table2 where table1.`c_id` = table2.`c_id`";
		
		$ssss = $class->execute($sql);
		var_dump($sss);

	}
	
}<file_sep><?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:27
         compiled from "F:\Zend\git\yaf\application\views\index\index.tpl" */ ?>
<?php /*%%SmartyHeaderCode:2729556f22e679539f0-79062059%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'c8caa57bbcf579e95d47ece8ce4bba65ece45467' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\index\\index.tpl',
      1 => 1457686243,
      2 => 'file',
    ),
    'b7aba38bca2edd88e759555da3d41a3d050d194e' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\base.tpl',
      1 => 1458622089,
      2 => 'file',
    ),
    '00bb99ef4a9bc68c1e51c7d435e33d9abfa8f392' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\header.tpl',
      1 => 1458623402,
      2 => 'file',
    ),
    '25d0cfc6ae6a2d07f03e53021daf49c4789747eb' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\footer.tpl',
      1 => 1457685727,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '2729556f22e679539f0-79062059',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_56f22e67a883b3_84155262',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56f22e67a883b3_84155262')) {function content_56f22e67a883b3_84155262($_smarty_tpl) {?>
<!DOCTYPE html>
<html>
<head>

	<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
	<meta name="renderer" content="webkit" />

	<meta charset="utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

	<title>社区---Godruoyi</title>

	<meta name="description" content="This is description , you can input everthing.">

	<meta name="keywords" content="KEY WORDS">

	<!-- setting icon -->
<!-- 	<link rel="shortcut icon" href="resource/common/favicon.ico" type="image/x-icon"/>-->     
    
	<?php echo $_smarty_tpl->getSubTemplate ("static/common/inc/css_common.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


	
	<?php echo $_smarty_tpl->getSubTemplate ("static/common/inc/js_lib.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


	
	
    

</head>
<body>
	
        <?php /*  Call merged included template "../common/header.tpl" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("../common/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '2729556f22e679539f0-79062059');
content_56f22e67a16f22_06825672($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack); 
/*  End of included template "../common/header.tpl" */?>
    

	
<div class="aw-container-wrap">
	<div class="container category">
		<div class="row">
			<div class="col-sm-12">
				<ul class="list">
					<li class="active"><a href="#">全部</a></li>
					<li><a href="#">PHP</a></li>
					<li><a href="#">Laravel</a></li>
					<li><a href="#">ThinnkPHP</a></li>
					<li><a href="#">YAF</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="col-sm-12 col-md-9 aw-main-content">
					<!-- 新消息通知 -->
					<div class="aw-mod aw-notification-box hide" id="index_notification">
						<div class="mod-head common-head">
							<h2>
								<span class="pull-right">
									<a href="" class="text-color-999"><i class="icon icon-setting"></i> 通知设置</a>
								</span>
								<i class="icon icon-bell"></i>新通知<em class="badge badge-important" name="notification_unread_num"></em>
							</h2>
						</div>
						<div class="mod-body">
							<ul id="notification_list"></ul>
						</div>
						<div class="mod-footer clearfix">
							<a href="javascript:;" onclick="AWS.Message.read_notification(false, 0, false);" class="pull-left btn btn-mini btn-gray">我知道了</a>
							<a href="#notifications/" class="pull-right btn btn-mini btn-success">查看所有</a>
						</div>
					</div>
					<!-- end 新消息通知 -->
					<!-- tab切换 -->
					<ul class="nav nav-tabs aw-nav-tabs active hidden-xs">
						<li><a href="#sort_type-unresponsive">等待回复</a></li>
						<li><a href="#sort_type-hot__day-7" id="sort_control_hot">热门</a></li>
						<li><a href="#is_recommend-1">推荐</a></li>
						<li class="active"><a href="#">最新</a></li>

						<h2 class="hidden-xs"><i class="icon icon-list"></i> 发现</h2>
					</ul>
					<!-- end tab切换 -->

					
					<div class="aw-mod aw-explore-list">
						<div class="mod-body">
							<div class="aw-common-list">
								<div class="aw-item active" data-topic-id="251,6,">
									<a class="aw-user-name hidden-xs" data-id="792" href="#people/Jellybean" rel="nofollow">
										<img src="#static/common/avatar-max-img.png" alt="" />
									</a>	
									<div class="aw-question-content">
										<h4>
											<a href="#question/363">size的大小，对es search性能的影响</a>
										</h4>
										<a href="#question/363#!answer_form" class="pull-right text-color-999">回复</a>
										<p>
											<a class="aw-question-tags" href="#explore/category-2">Elasticsearch</a>
						• 					<a href="#people/Jellybean" class="aw-user-name">Jellybean</a>
											<span class="text-color-999">发起了问题 • 1 人关注 • 0 个回复 • 14 次浏览 • 3 小时前				</span>
											<span class="text-color-999 related-topic hide"> • 来自相关话题</span>
										</p>
									</div>
								</div>
							</div>
						</div>
						<div class="mod-footer">
							<div class="page-control">
								<ul class="pagination pull-right">
									<li class="active"><a href="javascript:;">1</a></li>
									<li><a href="#sort_type-new__day-0__is_recommend-0__page-2">2</a></li>
									<li><a href="#sort_type-new__day-0__is_recommend-0__page-3">3</a></li>
									<li><a href="#sort_type-new__day-0__is_recommend-0__page-4">4</a></li>
									<li><a href="#sort_type-new__day-0__is_recommend-0__page-2">&gt;</a></li>
									<li><a href="#sort_type-new__day-0__is_recommend-0__page-42">&gt;&gt;</a></li>
								</ul>
							</div>						
						</div>
					</div>
				</div>

				<!-- 侧边栏 -->
				<div class="col-sm-12 col-md-3 aw-side-bar hidden-xs hidden-sm">
					<div class="aw-mod aw-text-align-justify">
						<div class="mod-head">
							<a href="#topic/channel-hot" class="pull-right">更多 &gt;</a>
							<h3>热门话题</h3>
						</div>
						<div class="mod-body">
							<dl>
								<dt class="pull-left aw-border-radius-5">
									<a href="#topic/elasticsearch">
										<img alt="" src="#uploads/topic/20151101/61458e7771b84fd8f6551a51051dc112_50_50.png" />
									</a>
								</dt>
								<dd class="pull-left">
									<p class="clearfix">
										<span class="topic-tag">
											<a href="#topic/elasticsearch" class="text" data-id="38">elasticsearch</a>
										</span>
									</p>
									<p><b>41</b> 个问题, <b>37</b> 人关注</p>
								</dd>
							</dl>
							<dl>
								<dt class="pull-left aw-border-radius-5">
									<a href="#topic/elastic"><img alt="" src="#static/common/topic-mid-img.png" /></a>
								</dt>
								<dd class="pull-left">
									<p class="clearfix">
										<span class="topic-tag">
											<a href="#topic/elastic" class="text" data-id="165">elastic</a>
										</span>
									</p>
									<p><b>3</b> 个问题, <b>7</b> 人关注</p>
								</dd>
							</dl>
						</div>
					</div>
					<div class="aw-mod aw-text-align-justify">
						<div class="mod-head">
							<a href="#people/" class="pull-right">更多 &gt;</a>
							<h3>热门用户</h3>
						</div>
						<div class="mod-body">
							<dl>
								<dt class="pull-left aw-border-radius-5">
									<a href="#people/rayshen"><img alt="" src="#static/common/avatar-mid-img.png" /></a>
								</dt>
								<dd class="pull-left">
									<a href="#people/rayshen" data-id="503" class="aw-user-name">rayshen						</a>
									<p class="signature"></p>
									<p><b>2</b> 个问题, <b>0</b> 次赞同</p>
								</dd>
							</dl>
			
							<dl>
								<dt class="pull-left aw-border-radius-5">
									<a href="#people/dreams"><img alt="" src="#static/common/avatar-mid-img.png" /></a>
								</dt>
								<dd class="pull-left">
									<a href="#people/dreams" data-id="806" class="aw-user-name">dreams						</a>
									<p class="signature"></p>
									<p><b>3</b> 个问题, <b>0</b> 次赞同</p>
								</dd>
							</dl>
						</div>
					</div>				
				</div>
				<!-- end 侧边栏 -->
			</div>
		</div>
	</div>
</div>

	
	
         <?php /*  Call merged included template "../common/footer.tpl" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("../common/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '2729556f22e679539f0-79062059');
content_56f22e67a789b7_29803353($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack); 
/*  End of included template "../common/footer.tpl" */?>
    

	

	<!-- 百度统计 -->
    <script type="text/javascript">
        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F777acfdc44fd57af7be29408af76bcba' type='text/javascript'%3E%3C/script%3E"));
    </script>

	<a class="aw-back-top hidden-xs" href="javascript:;" onclick="$.scrollTo(1, 600, {queue:true});"><i class="icon icon-up"></i></a>
	<!-- DO NOT REMOVE -->
	<div id="aw-ajax-box" class="aw-ajax-box"></div>
	<div style="display:none;" id="__crond">
		<script type="text/javascript">
			/*$(document).ready(function () {
				$('#__crond').html(unescape('%3Cimg%20src%3D%22' + G_BASE_URL + '/crond/run/1456901234%22%20width%3D%221%22%20height%3D%221%22%20/%3E'));
			});*/
		</script>
	</div>
</body>
</html><?php }} ?>
<?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:27
         compiled from "F:\Zend\git\yaf\application\views\common\header.tpl" */ ?>
<?php if ($_valid && !is_callable('content_56f22e67a16f22_06825672')) {function content_56f22e67a16f22_06825672($_smarty_tpl) {?>
<div class="aw-top-menu-wrap">
	<div class="container">
		<!-- logo -->
		<div class="aw-logo hidden-xs">
			<a href="http://www.godruoyi.com"></a>
		</div>
		<!-- end logo -->
		<!-- 搜索框 -->
		<div class="aw-search-box  hidden-xs hidden-sm">
			<form class="navbar-search" action="#" id="global_search_form" method="post">
				<input class="form-control search-query" type="text" placeholder="搜索问题、话题或人" autocomplete="off" name="q" id="aw-search-query" />
				<span title="搜索" id="global_search_btns" onClick="$('#global_search_form').submit();"><i class="icon icon-search"></i></span>
				<div class="aw-dropdown">
					<div class="mod-body">
						<p class="title">输入关键字进行搜索</p>
						<ul class="aw-dropdown-list hide"></ul>
						<p class="search"><span>搜索:</span><a onClick="$('#global_search_form').submit();"></a></p>
					</div>
					<div class="mod-footer">
						<a href="#publish" onClick="$('#header_publish').click();" class="pull-right btn btn-mini btn-success publish">发起问题</a>
					</div>
				</div>
			</form>
		</div>
		<!-- end 搜索框 -->
		<!-- 导航 -->
		<div class="aw-top-nav navbar">
			<div class="navbar-header">
			  <button  class="navbar-toggle pull-left">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			  </button>
			</div>
			<nav role="navigation" class="collapse navbar-collapse bs-navbar-collapse">
			  <ul class="nav navbar-nav">
				<li><a href="#" class="active"><i class="icon icon-list"></i> 文章</a></li>

				<!-- <li><a href="#question/" class="">问题</a></li>

				<li><a href="#article/" class="">文章</a></li> -->

				<li><a href="#" ><i class="icon icon-topic"></i> 讨论</a></li>
				<li><a href="#"><i class="icon icon-bulb"></i> Help</a></li>
				<?php if (!empty($_smarty_tpl->tpl_vars['islogin']->value)) {?>
					<li><a href="#"><i class="icon icon-bulb"></i> 消息</a></li>
				<?php }?>					
				<li>
					<a style="font-weight:bold;" title="more...">· · ·</a>
					<div class="dropdown-list pull-right">
						<ul id="extensions-nav-list"></ul>
					</div>
				</li>
			  </ul>
			</nav>
		</div>
		<!-- end 导航 -->

		<?php if (empty($_smarty_tpl->tpl_vars['islogin']->value)) {?>
		<!-- 用户栏 -->
		<div class="aw-user-nav">
			<!-- 登陆&注册栏 -->
			<a class="login btn btn-normal btn-primary" href="/login">登录</a>
			<a class="register btn btn-normal btn-success" href="/register">注册</a>								<!-- end 登陆&注册栏 -->
		</div>
		<!-- end 用户栏 -->
		<!-- 发起 -->
		<?php } else { ?>
		<!-- end 发起 -->
		<!-- 用户栏 -->
		<div class="aw-user-nav">
			<!-- 登陆&注册栏 -->
			<a href="" class="aw-user-nav-dropdown">
				<img alt="godruoyi" src="" />
			</a>
			<div class="aw-dropdown dropdown-list pull-right">
				<ul class="aw-dropdown-list">
					<li><a href=""><i class="icon icon-inbox"></i> 个人中心<span class="badge badge-important hide" id="inbox_unread">0</span></a></li>
					<li class="hidden-xs"><a href=""><i class="icon icon-setting"></i> 设置</a></li>
					<li><a href=""><i class="icon icon-logout"></i> 退出</a></li>
				</ul>
			</div>
			<!-- end 登陆&注册栏 -->
		</div>
		<!-- end 用户栏 -->

		<!-- 发起 -->
		<div class="aw-publish-btn">
			<a id="header_publish" class="btn-primary" href="" onclick=""><i class="icon icon-ask"></i>发起</a>
			<div class="dropdown-list pull-right">
				<ul>
					
					<li>
						<a href="/articles/create">文章</a>
					</li>
				</ul>
			</div>
		</div>
			<!-- end 发起 -->
		<?php }?>
	</div>
</div><?php }} ?>
<?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:27
         compiled from "F:\Zend\git\yaf\application\views\common\footer.tpl" */ ?>
<?php if ($_valid && !is_callable('content_56f22e67a789b7_29803353')) {function content_56f22e67a789b7_29803353($_smarty_tpl) {?><div class="aw-footer-wrap">
	<div class="aw-footer">
		Copyright © 2016 · <a target="_blank" href="#">Godruoyi</a></span>
		<span class="hidden-xs"> · <a href="#" target="blank">Godruoyi</a></span>
	</div>
</div><?php }} ?>
<file_sep><?php

class A
{

	public $name = 'name';

	private static $instance = null;

	private function __construct()
	{}

	public static function getInstance()
	{
		if (is_null(self::$instance)) {
			self::$instance = new self();
		}
		return self::$instance;
	}
}

$a = A::getInstance();
echo $a->name;<file_sep><?php


trait trait_Session
{
	public function wocao()
	{
		echo "trait_Session wocao";
	}

	private function __construct()
	{

	}
}<file_sep><?php

class Helper_Smarty extends Smarty
{

	public function __construct()
	{
		parent::__construct();

		$this->setTemplateDir(APP_PATH . '/views/');
        $this->setConfigDir(BASE_PATH . '/log/smarty/config/');
        $this->setCompileDir(BASE_PATH . '/log/smarty/compile/');
        $this->setCacheDir(BASE_PATH . '/log/smarty/cache/');

        //开启smarty调试，  un-comment the following line to show the debug console
        //$this->debugging = true;

		$this->left_delimiter = '{%';
        $this->right_delimiter = '%}';

	}
	
}<file_sep><?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:27
         compiled from "static\common\inc\css_common.tpl" */ ?>
<?php /*%%SmartyHeaderCode:1404056f22e67aa77c5-76919150%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'd34a940ff1b1d41b8a91b53c1b4810b12d987eec' => 
    array (
      0 => 'static\\common\\inc\\css_common.tpl',
      1 => 1458620714,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '1404056f22e67aa77c5-76919150',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_56f22e67aab647_82063725',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56f22e67aab647_82063725')) {function content_56f22e67aab647_82063725($_smarty_tpl) {?><link rel="stylesheet" type="text/css" href="/static/common/css/bs.css" />
<link rel="stylesheet" type="text/css" href="/static/common/css/icon.css" />
<link href="/static/common/css/common.css" rel="stylesheet" type="text/css" />
<link href="/static/common/css/link.css" rel="stylesheet" type="text/css" />
<link href="/static/common/css/style.css" rel="stylesheet" type="text/css" />
<?php }} ?>
<file_sep><?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 16:57:28
         compiled from "F:\Zend\git\yaf\application\views\articles\index.tpl" */ ?>
<?php /*%%SmartyHeaderCode:2116056f22ee3acb017-56056684%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '0a4cd3c1ae63125eb18d5465826ee84667e07238' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\articles\\index.tpl',
      1 => 1458723444,
      2 => 'file',
    ),
    'b7aba38bca2edd88e759555da3d41a3d050d194e' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\base.tpl',
      1 => 1458622089,
      2 => 'file',
    ),
    '00bb99ef4a9bc68c1e51c7d435e33d9abfa8f392' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\header.tpl',
      1 => 1458623402,
      2 => 'file',
    ),
    '25d0cfc6ae6a2d07f03e53021daf49c4789747eb' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\footer.tpl',
      1 => 1457685727,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '2116056f22ee3acb017-56056684',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_56f22ee3cc6d83_86300865',
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56f22ee3cc6d83_86300865')) {function content_56f22ee3cc6d83_86300865($_smarty_tpl) {?>
<!DOCTYPE html>
<html>
<head>

	<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
	<meta name="renderer" content="webkit" />

	<meta charset="utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

	<title>写文章---Godruoyi</title>

	<meta name="description" content="This is description , you can input everthing.">

	<meta name="keywords" content="KEY WORDS">

	<!-- setting icon -->
<!-- 	<link rel="shortcut icon" href="resource/common/favicon.ico" type="image/x-icon"/>-->     
    
	<?php echo $_smarty_tpl->getSubTemplate ("static/common/inc/css_common.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


	
	<?php echo $_smarty_tpl->getSubTemplate ("static/common/inc/js_lib.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


	
	
	<link rel="stylesheet" type="text/css" href="/static/plugins/editor/css/editormd.css">


</head>
<body>
	
        <?php /*  Call merged included template "../common/header.tpl" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("../common/header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '2116056f22ee3acb017-56056684');
content_56f25a78bed699_95607996($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack); 
/*  End of included template "../common/header.tpl" */?>
    

	
<div class="aw-container-wrap">
	<div class="container aw-publish aw-publish-article">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="aw-main-content">
					<!-- tab 切换 -->
					<ul class="nav nav-tabs aw-nav-tabs active">
						<h2 class="hidden-xs"><i class="icon icon-ask"></i> 文章发布</h2>
					</ul>
					<!-- end tab 切换 -->
					<form id="question_form">
						<div class="aw-mod aw-mod-publish">
							<div class="mod-body">
								<h3>文章标题:</h3>
								<!-- 文章标题 -->
								<div class="aw-publish-title">
									<input type="text" name="title_articles" id="title_articles" value="" class="form-control" minlength="20" required/>
									<input type="hidden" name="classify_id_hidden" value="" id="classify_id_hidden" required/>
										<div class="aw-dropdown aw-question-dropdown">
											<i class="aw-icon i-dropdown-triangle active"></i>
											<p class="title">没有找到相关结果</p>
											<ul class="aw-question-dropdown-list"></ul>
										</div>
										<div class="dropdown">
											<div class="dropdown-toggle" data-toggle="dropdown">
												<div id="aw-topic-tags-select">
													<span>选择分类</span>
													<a href="javascript:;">
														<i class="icon icon-down"></i>
													</a>
												</div>
												<div aria-labelledby="dropdownMenu" role="menu" class="aw-dropdown" id="menu-arr">
													<ul class="aw-dropdown-list">
														<?php if (!empty($_smarty_tpl->tpl_vars['classify']->value)) {?>
															<?php  $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['item']->_loop = false;
 $_from = $_smarty_tpl->tpl_vars['classify']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value) {
$_smarty_tpl->tpl_vars['item']->_loop = true;
?>
																<li><a data-value="<?php echo $_smarty_tpl->tpl_vars['item']->value['id'];?>
"><?php echo $_smarty_tpl->tpl_vars['item']->value['name'];?>
</a></li>
															<?php } ?>
														<?php } else { ?>
															<li><a data-value="0">暂无分组</a></li>
														<?php }?>
													</ul>
												</div>
											</div>
										</div>
								</div>
								<!-- end 文章标题 -->

								<h3>文章内容:</h3>
								<div class="aw-mod aw-editor-box">
									<div class="mod-head">
										<div id="test-editormd">
											<textarea name="content_articles" id="content_articles" required></textarea>
								        </div>
									</div>
									
								</div>
							</div>
							<div class="mod-footer clearfix">
								<a href="" target="_blank">[积分规则]</a>
								<span class="aw-anonymity"></span>
								<a class="btn btn-large btn-success btn-publish-submit" id="publish_submit">确认发布</a>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	var testEditor;
    $(function() {
        testEditor = editormd("test-editormd", {
            width   : "90%",
            height  : 640,
            syncScrolling : "single",
            path    : "/static/plugins/editor/lib/",
            saveHTMLToTextarea: true,
        });
 	});
</script>

	
	
         <?php /*  Call merged included template "../common/footer.tpl" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("../common/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '2116056f22ee3acb017-56056684');
content_56f25a78c76237_31284340($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack); 
/*  End of included template "../common/footer.tpl" */?>
    

	
	<script type="text/javascript" src="/static/plugins/editor/editormd.min.js"></script>
	<script type="text/javascript" src="/static/articles/js/index.js"></script>
	<script type="text/javascript" src="/static/articles/js/form.js"></script>
	<!-- <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script> -->
	<!-- <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script> -->


	<!-- 百度统计 -->
    <script type="text/javascript">
        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F777acfdc44fd57af7be29408af76bcba' type='text/javascript'%3E%3C/script%3E"));
    </script>

	<a class="aw-back-top hidden-xs" href="javascript:;" onclick="$.scrollTo(1, 600, {queue:true});"><i class="icon icon-up"></i></a>
	<!-- DO NOT REMOVE -->
	<div id="aw-ajax-box" class="aw-ajax-box"></div>
	<div style="display:none;" id="__crond">
		<script type="text/javascript">
			/*$(document).ready(function () {
				$('#__crond').html(unescape('%3Cimg%20src%3D%22' + G_BASE_URL + '/crond/run/1456901234%22%20width%3D%221%22%20height%3D%221%22%20/%3E'));
			});*/
		</script>
	</div>
</body>
</html><?php }} ?>
<?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 16:57:28
         compiled from "F:\Zend\git\yaf\application\views\common\header.tpl" */ ?>
<?php if ($_valid && !is_callable('content_56f25a78bed699_95607996')) {function content_56f25a78bed699_95607996($_smarty_tpl) {?>
<div class="aw-top-menu-wrap">
	<div class="container">
		<!-- logo -->
		<div class="aw-logo hidden-xs">
			<a href="http://www.godruoyi.com"></a>
		</div>
		<!-- end logo -->
		<!-- 搜索框 -->
		<div class="aw-search-box  hidden-xs hidden-sm">
			<form class="navbar-search" action="#" id="global_search_form" method="post">
				<input class="form-control search-query" type="text" placeholder="搜索问题、话题或人" autocomplete="off" name="q" id="aw-search-query" />
				<span title="搜索" id="global_search_btns" onClick="$('#global_search_form').submit();"><i class="icon icon-search"></i></span>
				<div class="aw-dropdown">
					<div class="mod-body">
						<p class="title">输入关键字进行搜索</p>
						<ul class="aw-dropdown-list hide"></ul>
						<p class="search"><span>搜索:</span><a onClick="$('#global_search_form').submit();"></a></p>
					</div>
					<div class="mod-footer">
						<a href="#publish" onClick="$('#header_publish').click();" class="pull-right btn btn-mini btn-success publish">发起问题</a>
					</div>
				</div>
			</form>
		</div>
		<!-- end 搜索框 -->
		<!-- 导航 -->
		<div class="aw-top-nav navbar">
			<div class="navbar-header">
			  <button  class="navbar-toggle pull-left">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			  </button>
			</div>
			<nav role="navigation" class="collapse navbar-collapse bs-navbar-collapse">
			  <ul class="nav navbar-nav">
				<li><a href="#" class="active"><i class="icon icon-list"></i> 文章</a></li>

				<!-- <li><a href="#question/" class="">问题</a></li>

				<li><a href="#article/" class="">文章</a></li> -->

				<li><a href="#" ><i class="icon icon-topic"></i> 讨论</a></li>
				<li><a href="#"><i class="icon icon-bulb"></i> Help</a></li>
				<?php if (!empty($_smarty_tpl->tpl_vars['islogin']->value)) {?>
					<li><a href="#"><i class="icon icon-bulb"></i> 消息</a></li>
				<?php }?>					
				<li>
					<a style="font-weight:bold;" title="more...">· · ·</a>
					<div class="dropdown-list pull-right">
						<ul id="extensions-nav-list"></ul>
					</div>
				</li>
			  </ul>
			</nav>
		</div>
		<!-- end 导航 -->

		<?php if (empty($_smarty_tpl->tpl_vars['islogin']->value)) {?>
		<!-- 用户栏 -->
		<div class="aw-user-nav">
			<!-- 登陆&注册栏 -->
			<a class="login btn btn-normal btn-primary" href="/login">登录</a>
			<a class="register btn btn-normal btn-success" href="/register">注册</a>								<!-- end 登陆&注册栏 -->
		</div>
		<!-- end 用户栏 -->
		<!-- 发起 -->
		<?php } else { ?>
		<!-- end 发起 -->
		<!-- 用户栏 -->
		<div class="aw-user-nav">
			<!-- 登陆&注册栏 -->
			<a href="" class="aw-user-nav-dropdown">
				<img alt="godruoyi" src="" />
			</a>
			<div class="aw-dropdown dropdown-list pull-right">
				<ul class="aw-dropdown-list">
					<li><a href=""><i class="icon icon-inbox"></i> 个人中心<span class="badge badge-important hide" id="inbox_unread">0</span></a></li>
					<li class="hidden-xs"><a href=""><i class="icon icon-setting"></i> 设置</a></li>
					<li><a href=""><i class="icon icon-logout"></i> 退出</a></li>
				</ul>
			</div>
			<!-- end 登陆&注册栏 -->
		</div>
		<!-- end 用户栏 -->

		<!-- 发起 -->
		<div class="aw-publish-btn">
			<a id="header_publish" class="btn-primary" href="" onclick=""><i class="icon icon-ask"></i>发起</a>
			<div class="dropdown-list pull-right">
				<ul>
					
					<li>
						<a href="/articles/create">文章</a>
					</li>
				</ul>
			</div>
		</div>
			<!-- end 发起 -->
		<?php }?>
	</div>
</div><?php }} ?>
<?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 16:57:28
         compiled from "F:\Zend\git\yaf\application\views\common\footer.tpl" */ ?>
<?php if ($_valid && !is_callable('content_56f25a78c76237_31284340')) {function content_56f25a78c76237_31284340($_smarty_tpl) {?><div class="aw-footer-wrap">
	<div class="aw-footer">
		Copyright © 2016 · <a target="_blank" href="#">Godruoyi</a></span>
		<span class="hidden-xs"> · <a href="#" target="blank">Godruoyi</a></span>
	</div>
</div><?php }} ?>
<file_sep><?php

class Helper_Validate
{
	private $config = NULL;

	private $_validate = NULL;

	private $_errors = NULL;

	private $allow_methhod = ['GET', 'POST'];

	public function __construct(array $config)
	{
		if ( !empty($config)) $this->config = $config;
		$this->_validate = new Helper_FormValidate();
	}


	public function validate($key = '', $method = 'GET')
	{
		if (empty($key) || !isset($this->config[$key])) return FALSE;
		if ( !in_array(strtoupper($method), $this->allow_methhod)) return FALSE;
		$data = $this->config[$key];
		foreach ($data as $key2 => $value) {

			// $field  = $key2;//name
			// $assign = '';//名字
			// if ( stripos($key2, '|') != FALSE) {
			// 	$field_assign = explode('|', $key2);
			// 	$assign = $field_assign[1];
			// 	$field = $field_assign[0];
			// }

			$validates = $value;//require
			if (stripos($value, '|') != FALSE) {
				$validates = explode('|', $value);//array [require, minlength[10],]
			}
			if (is_string($validates)) {
				$request_method = $validates;
				$param = NULL;
				if (stripos($validates, '[') != FALSE && stripos($validates, ']') != FALSE) { // minlength[20|
					$method_params = explode('[', $validates);
					$request_method = $method_params[0];
					$param = $method_params[1];
				} else {
					throw new exception_Exception('方法验证错误，缺少中括号'.$validates);
				}
				if (empty($param)) {
					$isok = $this->_validate->$request_method($key2);
				} else {
					$isok = $this->_validate->$request_method($key2, $param);
				}
				if ($isok) continue;
				$this->_errors[] = $this->_validate->getError();
			}

			

		}




	}

}<file_sep><?php /* Smarty version Smarty-3.1.19, created on 2016-03-24 11:15:19
         compiled from "F:\Zend\git\yaf\application\views\common\404.tpl" */ ?>
<?php /*%%SmartyHeaderCode:1193756f35b9bb80a52-27027791%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'b8f333fe2be235e6e69d621ef2bb2cc841c3ce17' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\404.tpl',
      1 => 1458789318,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '1193756f35b9bb80a52-27027791',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_56f35b9bb9bfe9_38696813',
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56f35b9bb9bfe9_38696813')) {function content_56f35b9bb9bfe9_38696813($_smarty_tpl) {?><!DOCTYPE html>
<html lang="en" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
		<meta name="robots" content="noindex, nofollow" />
		
		<title>404 Not Found</title>

		<link rel="icon" type="image/png" href="favicon.png" />
		
		<style type="text/css" media="screen">
			html, body{ margin: 0; padding: 0; border: 0; font-size: 100%; vertical-align: baseline; }
			body{ font: 100%/160% Georgia, Constantia, "<NAME>", LucidaBright, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Times, Serif; text-align: center; color: #2A2925; background: #E1E0DC; padding-top: 10%; }
			img{ float: right; width: 25%; min-width: 150px; max-width: 300px; height: auto; margin-top: -5%; }
			p{ margin: 0; padding: 0 2% 2% 2%; line-height: 1em; font-size: 1.8em; }
			.error{ font-size: 4em; }
			.funny{ font-style: italic; }
      		a, a:link, a:visited{ color: #fff; background: #2A2925; text-decoration: none; padding: .2em .4em; line-height: 2em; -webkit-border-radius: .5em; -moz-border-radius: .5em; border-radius: .5em; }
        	a:hover{ background: #281d30; }
		</style>
	</head>
	<body>
		<p class="error">404 Not Found</p><p class="funny">No Coffee, No Workee!</p>
		<p><a href="/" title="Back on track trooper!">&larr;godruoyi.com/</a></p>
	</body>
</html><?php }} ?>
<file_sep><?php

/**
 *
 *
 * 
 */
class ArticlesController extends core_Commonents
{

	public function init()
	{
		parent::init(FALSE);
	}

	public function createAction()
	{
		if ($this->_is_ajax) return $this->_do_create(); 

		//$this->_checkLogging();
		$classify = new ClassifyModel();
		$res = $classify->select(NULL, ['fields' => 'c_name as `name`, c_id as `id`']);

		$this->getView()->assign('classify', $res);
		$this->getView()->display('articles/index.tpl');
	}


	public function detailAction()
	{
		$id = $this->getRequest()->getParam('id');
		$id = intval($id);
		if ($id <= 0) {
			$this->show_404();
		}
		$article = new ArticleModel();

		$result = $article->selectOne(['a_id' => $id], ['fields' => 'a_id, a_title, a_brower,u_id,c_id,a_createtime']);
		if ( empty($result)) $this->show_404();

		$user_id = $result['u_id'];
		$group_id = $result['c_id'];
		$brower_num = $result['a_brower'];

		$fenlei = new ClassifyModel();
		$names = $fenlei->selectOne(['c_id' => $group_id], ['fields' => 'c_name as `name`']);

		//$user = new UsersModel();
		//$users = $user->selectOne(['u_id' => $user_id], ['fields' => 'u_name as `username`, u_img as `image_url`']);

		//评论
		$tops = new TopsModel();
		$countn = $tops->selectCount(['a_id' => $id]);

		$top = NULL;
		if ($countn > 0) {
			$top = $tops->select(['a_id' => $id], ['order_by' => 't_id DESC','offset' => 0, 'limit' => 20]);
		}


		$data = [
			'user' => [
				'user_id' => 1,
				'user_name' => 'xulianbo',//$users['username'],
				'user_img' => '',//$users['image_url'],
				'user_nickname' => '大牛牛',//$users['image_url'],
			],
			'group' => [
				'group_id' => $group_id,
				'group_name' => $names['name'],
			],
			'article' =>[
				'article_id' => $result['a_id'],
				'article_title' => $result['a_title'],
				'article_brower' => $result['a_brower'],
				'article_createtime' => date('Y-m-d', strtotime($result['a_createtime'])),
			],
			'tops' => [
				'count' => $countn,
				'data'  => $top,
			],
		];	

		//更新浏览量， ， 这里应该用插件的。。。。。
		//TODO...............

		$this->getView()->assign('articles_data', $data);
		$this->getView()->display('articles/detail.tpl');
	}



	public function getContentAction()
	{
		$id = intval( $_GET['id']);
		if (!$this->_is_ajax || $id <= 0) {
			$this->_ajax_return_failed('获取文章失败，请尝试重新加载！');
		}
		$article = new ArticleModel();

		$result = $article->selectOne(['a_id' => $id], ['fields' => 'a_content as `content`']);
		if ( empty($result)) $this->_ajax_return_failed('获取文章失败，请尝试重新加载！');
		$this->_ajax_return_success('success', $result['content']);
	}







	private function _do_create()
	{
		$title = $_POST['title'];
		$id = $_POST['id'];
		$content = $_POST['content'];

		if(empty($title)) {
			$this->_ajax_return_failed('标题不能为空!!');
		}
		if(empty($id) || (int)$id <= 0) {
			$this->_ajax_return_failed('请选择分类!!');
		}
		if(empty($content)) {
			$this->_ajax_return_failed('内容不能为空!!');
		}

		$articles = new ArticleModel();
		$data = [
			'a_title' => $title,
			'a_content' => $content,
			'a_brower' => 0,
			'c_id' => $id,
			'u_id' => $this->_id,
			'a_createtime' => date('Y-m-d H:i:s'),
		];
		$ok = $articles->insert($data, NULL, FALSE);
		if (!$ok){
			$errors = $articles->getErrors();
			$this->_ajax_return_failed('插入失败!!', $errors);
		}
		$this->_ajax_return_success();
	}

}<file_sep><?php

$dbconfig = [
	'DBConfig' => [
		'write' => [
			'dns'  => 'mysql:host=localhost;dbname=test_my;port=3306',
	        'user' => 'root',
	        'password' => '<PASSWORD>',       
	        'charset' => 'utf8',
	        'prefix' => 'g_',
		],

		'read'  => [
			//从机可能有很多歌
			[
				'dns'  => 'mysql:host=localhost;dbname=test_my;port=3306',
		        'user' => 'root',
		        'password' => '<PASSWORD>',       
		        'charset' => 'utf8',
		        'prefix' => 'g_',
			],
			[
				'dns'  => 'mysql:host=localhost;dbname=test_my;port=3306',
		        'user' => 'root',
		        'password' => '<PASSWORD>',       
		        'charset' => 'utf8',
		        'prefix' => 'g_',
			]
		],
	],
];<file_sep><?php

class ArticleModel extends MysqldbModel
{
	public function __construct()
	{
		parent::__construct('articles');
	}
}<file_sep><?php

class ClassifyModel extends MysqldbModel
{
	public function __construct()
	{
		parent::__construct('classify');
	}
}<file_sep><?php

class Acticleslugin extends Yaf_Plugin_Abstract
{
	public function dispatchLoopShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {
		
		

	}
}
<file_sep><?php

/**
 * 应用全局引导配置
 *
 * 在这里可以定义通用的配置文件， 自定义的加载器等
 * 
 */

date_default_timezone_set("Asia/Chongqing");
error_reporting(E_ALL);

//定义用户类库路径
defined('LIB_PPATH') or define('LIB_PPATH', APP_PATH . '/library/');

//定义环境， 默认是在开发环境
defined('APP_EVE') or define('APP_EVE', 'develop');


//########################################################  暂时先这样处理
//引入数据库配置
$file = BASE_PATH . '/conf/' . APP_EVE . '/DB.php';
if (file_exists($file)) require $file;

//引入全局配置
require BASE_PATH . '/conf/common.config.php';
//########################################################

require PUBLIC_PATH . '/route.php';


//set composer autoload
require BASE_PATH . '/vendor/autoload.php';


//smarty引入放在全局引导文件里， 放在YAF引导类下有点xiaobug
require LIB_PPATH . '/thirdlib/smarty/Smarty.class.php';
require LIB_PPATH . '/thirdlib/smarty/smarty-gettext.php';<file_sep><?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:36
         compiled from "F:\Zend\git\yaf\application\views\register\index.tpl" */ ?>
<?php /*%%SmartyHeaderCode:130256f22e701896c4-43225257%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'c8534be8fc39005a2fdb84f93c89f0160bb868a0' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\register\\index.tpl',
      1 => 1458632347,
      2 => 'file',
    ),
    'b7aba38bca2edd88e759555da3d41a3d050d194e' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\base.tpl',
      1 => 1458622089,
      2 => 'file',
    ),
    '00bb99ef4a9bc68c1e51c7d435e33d9abfa8f392' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\header.tpl',
      1 => 1458623402,
      2 => 'file',
    ),
    '25d0cfc6ae6a2d07f03e53021daf49c4789747eb' => 
    array (
      0 => 'F:\\Zend\\git\\yaf\\application\\views\\common\\footer.tpl',
      1 => 1457685727,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '130256f22e701896c4-43225257',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
  'version' => 'Smarty-3.1.19',
  'unifunc' => 'content_56f22e7032b6b7_21840410',
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_56f22e7032b6b7_21840410')) {function content_56f22e7032b6b7_21840410($_smarty_tpl) {?>
<!DOCTYPE html>
<html>
<head>

	<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
	<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" />
	<meta name="renderer" content="webkit" />

	<meta charset="utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

	<title>注册---Godruoyi</title>

	<meta name="description" content="This is description , you can input everthing.">

	<meta name="keywords" content="KEY WORDS">

	<!-- setting icon -->
<!-- 	<link rel="shortcut icon" href="resource/common/favicon.ico" type="image/x-icon"/>-->     
    
	<?php echo $_smarty_tpl->getSubTemplate ("static/common/inc/css_common.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


	
	<?php echo $_smarty_tpl->getSubTemplate ("static/common/inc/js_lib.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>


	
	
<link rel="stylesheet" type="text/css" href="/static/register/css/register.css">


</head>
<body>
	


	
<div class="aw-register-box">
    <div class="mod-head">
        <a href="http://www.godruoyi.com/"><img src="/  /images/login_logo.png" alt="" /></a>
        <h1>注册新用户</h1>
    </div>
    <div class="mod-body">
        <form class="aw-register-form" action="" method="post" id="register_form">
                        
            <ul>
                <li class="alert alert-danger hide error_message text-left">
                    <i class="icon icon-delete"></i> <em></em>
                </li>

                <li>
                    <input class="aw-register-name form-control" type="text" name="user_name" placeholder="用户名" tips="请输入一个 2-14 位的用户名" errortips="用户名长度不符合" value="" />
                </li>
                <li>
                    <input class="aw-register-email form-control" type="text" placeholder="邮箱" name="email" tips="请输入你常用的电子邮箱作为你的账号" value="" errortips="邮箱格式不正确" />
                </li>
                <li>
                    <input class="aw-register-pwd form-control" type="<PASSWORD>" name="password" placeholder="密码" tips="请输入 6-16 个字符,区分大小写" errortips="密码不符合规则" />
                </li>
                
                <li class="aw-register-verify">
                    <img class="pull-right" id="captcha" onclick="" src="">
                    <input type="text" class="form-control" name="seccode_verify" placeholder="验证码" />
                </li>

                <li class="last">
                    <label><input type="checkbox" checked="checked" value="agree" name="agreement_chk" /> 我同意</label> <a href="javascript:;" class="aw-agreement-btn">用户协议</a>
                    <a href="/login" class="pull-right">已有账号?</a>
                    <div class="aw-register-agreement hide">
                        <div class="aw-register-agreement-txt" id="register_agreement"></div>
                    </div>

                </li>
                <li class="clearfix">
                    <button class="btn btn-large btn-blue btn-block" onclick="">注册</button>
                </li>
            </ul>
        </form>
    </div>
</div>

	
	
         <?php /*  Call merged included template "../common/footer.tpl" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("../common/footer.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '130256f22e701896c4-43225257');
content_56f22e70317e20_46335524($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack); 
/*  End of included template "../common/footer.tpl" */?>
    

	

	<!-- 百度统计 -->
    <script type="text/javascript">
        var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
        document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F777acfdc44fd57af7be29408af76bcba' type='text/javascript'%3E%3C/script%3E"));
    </script>

	<a class="aw-back-top hidden-xs" href="javascript:;" onclick="$.scrollTo(1, 600, {queue:true});"><i class="icon icon-up"></i></a>
	<!-- DO NOT REMOVE -->
	<div id="aw-ajax-box" class="aw-ajax-box"></div>
	<div style="display:none;" id="__crond">
		<script type="text/javascript">
			/*$(document).ready(function () {
				$('#__crond').html(unescape('%3Cimg%20src%3D%22' + G_BASE_URL + '/crond/run/1456901234%22%20width%3D%221%22%20height%3D%221%22%20/%3E'));
			});*/
		</script>
	</div>
</body>
</html><?php }} ?>
<?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:36
         compiled from "F:\Zend\git\yaf\application\views\common\header.tpl" */ ?>
<?php if ($_valid && !is_callable('content_56f22e702aa818_92717795')) {function content_56f22e702aa818_92717795($_smarty_tpl) {?>
<div class="aw-top-menu-wrap">
	<div class="container">
		<!-- logo -->
		<div class="aw-logo hidden-xs">
			<a href="http://www.godruoyi.com"></a>
		</div>
		<!-- end logo -->
		<!-- 搜索框 -->
		<div class="aw-search-box  hidden-xs hidden-sm">
			<form class="navbar-search" action="#" id="global_search_form" method="post">
				<input class="form-control search-query" type="text" placeholder="搜索问题、话题或人" autocomplete="off" name="q" id="aw-search-query" />
				<span title="搜索" id="global_search_btns" onClick="$('#global_search_form').submit();"><i class="icon icon-search"></i></span>
				<div class="aw-dropdown">
					<div class="mod-body">
						<p class="title">输入关键字进行搜索</p>
						<ul class="aw-dropdown-list hide"></ul>
						<p class="search"><span>搜索:</span><a onClick="$('#global_search_form').submit();"></a></p>
					</div>
					<div class="mod-footer">
						<a href="#publish" onClick="$('#header_publish').click();" class="pull-right btn btn-mini btn-success publish">发起问题</a>
					</div>
				</div>
			</form>
		</div>
		<!-- end 搜索框 -->
		<!-- 导航 -->
		<div class="aw-top-nav navbar">
			<div class="navbar-header">
			  <button  class="navbar-toggle pull-left">
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			  </button>
			</div>
			<nav role="navigation" class="collapse navbar-collapse bs-navbar-collapse">
			  <ul class="nav navbar-nav">
				<li><a href="#" class="active"><i class="icon icon-list"></i> 文章</a></li>

				<!-- <li><a href="#question/" class="">问题</a></li>

				<li><a href="#article/" class="">文章</a></li> -->

				<li><a href="#" ><i class="icon icon-topic"></i> 讨论</a></li>
				<li><a href="#"><i class="icon icon-bulb"></i> Help</a></li>
				<?php if (!empty($_smarty_tpl->tpl_vars['islogin']->value)) {?>
					<li><a href="#"><i class="icon icon-bulb"></i> 消息</a></li>
				<?php }?>					
				<li>
					<a style="font-weight:bold;" title="more...">· · ·</a>
					<div class="dropdown-list pull-right">
						<ul id="extensions-nav-list"></ul>
					</div>
				</li>
			  </ul>
			</nav>
		</div>
		<!-- end 导航 -->

		<?php if (empty($_smarty_tpl->tpl_vars['islogin']->value)) {?>
		<!-- 用户栏 -->
		<div class="aw-user-nav">
			<!-- 登陆&注册栏 -->
			<a class="login btn btn-normal btn-primary" href="/login">登录</a>
			<a class="register btn btn-normal btn-success" href="/register">注册</a>								<!-- end 登陆&注册栏 -->
		</div>
		<!-- end 用户栏 -->
		<!-- 发起 -->
		<?php } else { ?>
		<!-- end 发起 -->
		<!-- 用户栏 -->
		<div class="aw-user-nav">
			<!-- 登陆&注册栏 -->
			<a href="" class="aw-user-nav-dropdown">
				<img alt="godruoyi" src="" />
			</a>
			<div class="aw-dropdown dropdown-list pull-right">
				<ul class="aw-dropdown-list">
					<li><a href=""><i class="icon icon-inbox"></i> 个人中心<span class="badge badge-important hide" id="inbox_unread">0</span></a></li>
					<li class="hidden-xs"><a href=""><i class="icon icon-setting"></i> 设置</a></li>
					<li><a href=""><i class="icon icon-logout"></i> 退出</a></li>
				</ul>
			</div>
			<!-- end 登陆&注册栏 -->
		</div>
		<!-- end 用户栏 -->

		<!-- 发起 -->
		<div class="aw-publish-btn">
			<a id="header_publish" class="btn-primary" href="" onclick=""><i class="icon icon-ask"></i>发起</a>
			<div class="dropdown-list pull-right">
				<ul>
					
					<li>
						<a href="/articles/create">文章</a>
					</li>
				</ul>
			</div>
		</div>
			<!-- end 发起 -->
		<?php }?>
	</div>
</div><?php }} ?>
<?php /* Smarty version Smarty-3.1.19, created on 2016-03-23 13:49:36
         compiled from "F:\Zend\git\yaf\application\views\common\footer.tpl" */ ?>
<?php if ($_valid && !is_callable('content_56f22e70317e20_46335524')) {function content_56f22e70317e20_46335524($_smarty_tpl) {?><div class="aw-footer-wrap">
	<div class="aw-footer">
		Copyright © 2016 · <a target="_blank" href="#">Godruoyi</a></span>
		<span class="hidden-xs"> · <a href="#" target="blank">Godruoyi</a></span>
	</div>
</div><?php }} ?>
<file_sep><?php

abstract public class core_AbcBase extends core_Base
{
	abstract public function init();
}<file_sep><?php

class Helper_FormValidate
{
	
	private static $instance = NULL;

	public function __construct()
	{
		if (self::$instance == NULL)
		{
			self::$instance = new self();
		}
		return self::$instance;
	}


	public function required($name, $data)
    {
        if (strlen($data)<=0) {
            return "'{$name}' 不能为空";
        } else {
            return TRUE;
        }
    }

    //最小值
    public function min($name, $data, $min)
    {
        $min = (int) $min;
        if (!is_null($data) && $data >= $min) {
            return TRUE;
        } else {
            return "'{$name}' 最小值为{$min}";
        }
    }

    public function max($name, $data, $max)
    {
        $max = (int) $max;
        if (!is_null($data) && $data <= $max) {
            return TRUE;
        } else {
            return "'{$name}' 最大值为{$max}";
        }
    }

    public function integer($name, $data)
    {
        if (empty($data)) {
            return TRUE;
        }

        $data = (int) $data;
        if (!empty($data)) {
            return TRUE;
        } else {
            return "'{$name}' 必须为整数";
        }
    }

    public function numeric($name, $data)
    {
        if (empty($data)) {
            return TRUE;
        }

        if (is_numeric($data)) {
            return TRUE;
        } else {
            return "'{$name}' 必须为数字";
        }
    }

    //用户名的检查,只能是字母数字和下划线
    public function username($name, $data)
    {
        if (empty($data)) {
            return TRUE;
        }

        $pattern = '/^[_\w\d]+$/i';
        if (!preg_match($pattern, $data))
        {
            return "'{$name}' 只能是字母数字和下划线";
        }

        return TRUE;
    }

    public function valid_url($name, $str)
    {
        if (empty($str)) {
            return TRUE;
        }

        $pattern = "/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i";
        if (!preg_match($pattern, $str))
        {
            return "'{$name}' 不是有效的URL地址";
        }

        return TRUE;
    }

    /**
     * 密码校验，不能是全数字或全字母
     */
    public function valid_password($name, $str)
    {
        if (empty($str)) {
            return TRUE;
        }

       $pattern = '/^(?!\d+$)(?![a-zA-Z]+$)(?![ ]+$).+?/';
        if (!preg_match($pattern, $str))
        {
            return "'{$name}' 不符合密码规则";
        }

        return TRUE;
    }
    
    /**
     * 匹配格式：
     * 11位手机号码
     * 3-4位区号，7-8位直播号码，1－4位分机号
     * 如：12345678901、1234-12345678-1234
     * 2015-03-23新增美国电话格式:xxx-xxx-xxxx、+xx-xxx-xxx-xxxx或没有连接字符串
     */
    public function valid_phone($name, $str)
    {
        if (empty($str)) {
            return TRUE;
        }

        $pattern = "(^\+?((\d{1}|\d{2})-?\d{3}-?\d{3}-?\d{4})$|(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)";
       
        if (!preg_match($pattern, $str))
        {
            return "'{$name}' 不是有效的电话号码";
        }

        return TRUE;
    }

    public function valid_datetime($name, $str)
    {
        if (empty($str)) {
            return TRUE;
        }

        if (Helper_Date::isDateTime($str) && !Helper_Date::isEmpty($str)) {
            return TRUE;
        } else {
            return "'{$name}' 不是有效的日期";
        }

    }
    
    public function valid_date($name, $str)
    {
    	if (empty($str)) {
    		return TRUE;
    	}
    
    	if (Helper_Date::isDate($str) && !Helper_Date::isEmpty($str)) {
    		return TRUE;
    	} else {
    		return "'{$name}' 不是有效的日期";
    	}
    
    	}

    public function valid_email($name, $str)
    {
        if (empty($str)) {
            return TRUE;
        }

        $pattern = '/^(\w)+([\.\w\-]+)*@(\w)+((\.\w+){1,5})$/i';
        if(!preg_match($pattern, $str)) {
            return "'{$name}' 不是有效的电子邮箱";
        }

        return TRUE;
    }

    //字符串最小长度
    public function min_length($name, $str, $len)
    {
        if (empty($str)) {
            return TRUE;
        }
        
        if (!empty($str) && strlen($str) >= $len)
        {
            return TRUE;
        } else {
            return "'{$name}'至少输入{$len}个字符";
        }
    }

    //字符串最大长度
    public function max_length($name, $str, $len)
    {
        if (empty($str) || strlen($str) <= $len)
        {
            return TRUE;
        } else {
            return "'{$name}'最多输入{$len}个字符";
        }
    }

    //字符串最小长度
    public function utf8min_length($name, $str, $len)
    {
        if (!empty($str) && mb_strlen($str, 'UTF-8') >= $len)
        {
            return TRUE;
        } else {
            return "'{$name}'至少输入{$len}个字符";
        }
    }

    //字符串最大长度
    public function utf8max_length($name, $str, $len)
    {
        if (empty($str) || mb_strlen($str, 'UTF-8') <= $len)
        {
            return TRUE;
        } else {
            return "'{$name}'最多输入{$len}个字符";
        }
    }

    //检查是否是一个合理的价格
    public function price($name, $data)
    {
        if (empty($data)) {
            return TRUE;
        }
        
        if (!is_numeric($data)) {
            return "'{$name}'不是有效的数字";
        }

        $nums = explode('.', $data);
        if (count($nums) < 2) {
            //证明是整数
            return TRUE;
        }
        if (strlen($nums[1]) > 2) {
            return "'{$name}' 只能精确到小数点2位";
        }

        return TRUE;
    }

}