<repo_name>kdj1219/ess<file_sep>/app/controllers/UserController.php
<?php

class UserController extends BaseController {

    /**
     *  用户首页
     */
	public function index()
	{
		$users = UserProcessor::getUserList();

		return View::make('user.index', compact('users'));
	}

    /**
     *  登入
     */
	public function login()
	{
		if (Request::isMethod('get')) 
		{
			return View::make('user.login');
		}
		elseif (Request::isMethod('post')) 
		{
			$uname = Input::get('uname');
         	$pword = Input::get('pword');
          	$remember = intval(Input::get('remember'));

            try
            {
                // Login credentials
                $credentials = array(
                    'email'    => $uname,
                    'password' => <PASSWORD>,
                );

                // Authenticate the user
                $user = Sentry::authenticate($credentials, false);

                if($user){
                    if($remember) Sentry::loginAndRemember($user);
                    return Redirect::to('/');
                }
            }
            catch (Cartalyst\Sentry\Users\LoginRequiredException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'Login field is required.');
            }
            catch (Cartalyst\Sentry\Users\PasswordRequiredException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'Password field is required.');
            }
            catch (Cartalyst\Sentry\Users\WrongPasswordException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'Wrong password, try again.');
            }
            catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'User was not found.');
            }
            catch (Cartalyst\Sentry\Users\UserNotActivatedException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'User is not activated.');
            }

            // The following is only required if the throttling is enabled
            catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'User is suspended.');
            }
            catch (Cartalyst\Sentry\Throttling\UserBannedException $e)
            {
                return Redirect::to('/login')
                    ->with('message', 'User is banned.');
            }

		}
	}

    /**
     *  登出
     */
	public function logout()
	{
        Sentry::logout();
		return Redirect::to('/login');
	}

}
<file_sep>/app/models/SentenceProcessor.php
<?php

class SentenceProcessor {

    /**
     * 获取例句列表
     */
    public static function getSentenceList($keywords='')
    {
        $user = Sentry::getUser();
        if(empty($keywords)){
            $sentences = Sentence::where('uid','=',$user->id)->orderBy('created_at','desc')->paginate(1);
        }else{
            $sentences = Sentence::where('uid','=',$user->id)->where('description', 'like', '%'.urldecode($keywords).'%')->orderBy('created_at','desc')->paginate(1);
        }

        return $sentences;
    }

    /**
     * 通过例句id获取例句详细信息
     *
     * @param string $sentenceId  例句的id
     * @return false
     */
    public static function getDetailById($sentenceId=''){
        $user = Sentry::getUser();

        if(empty($user) || empty($sentenceId) || !is_numeric($sentenceId)){
            return false;
        }

        $sentenceInfo = Sentence::where('uid','=',$user->id)->where('id','=',$sentenceId)->first();

        if( empty($sentenceInfo) ) return false;

        return $sentenceInfo;
    }

    /**
     * 获取随机例句
     */
    public static function getRandomSentence()
    {
        $user = Sentry::getUser();
        $sentences = Sentence::where('uid','=',$user->id)->orderByRaw("RAND()")->first();

        return $sentences;
    }

    /**
     * 添加例句
     *
     * @param $newSentence             新的例句
     * @param $description         新的例句的描述说明
     */
    public static function addSentence($newSentence, $description){
        $sentence = new Sentence;
        $user = Sentry::getUser();

        $sentence->sentence = $newSentence;
        $sentence->description = $description;
        $sentence->uid = $user->id;

        $res = $sentence->save();

        return $res;
    }

    /**
     * 更新例句
     *
     * @param $sentenceId          例句的id
     * @param $sentence            例句
     * @param $description         例句的描述说明
     */
    public static function updateSentence($sentenceId, $sentence, $description){
        $user = Sentry::getUser();
        $sentenceObj = Sentence::where('uid','=',$user->id)->find($sentenceId);

        $sentenceObj->sentence = $sentence;
        $sentenceObj->description = $description;

        $res = $sentenceObj->save();

        return $res;
    }

    /**
     * 删除例句
     *
     * @param $sentenceId             例句ID
     *
     */
    public static function delSentence($sentenceId){
        $res = Sentence::destroy($sentenceId);
        return $res;
    }

}
<file_sep>/app/models/User.php
<?php

class User extends Eloquent {

	/**
	 * The database table used by the model.
	 *
	 * @var string
	 */
	protected $table = 'users';
	protected $primaryKey = 'id';

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	// protected $hidden = array('password', 'remember_token');

    public function roles()
    {
        return $this->belongsToMany('Role','users_groups','user_id','group_id');
    }

}
<file_sep>/app/controllers/WordController.php
<?php

class WordController extends BaseController {

    /**
     *  首页
     */
	public function index()
	{
        $keywords = Input::get('key');
        $words = WordProcessor::getWordList($keywords);

        return View::make('word.index', compact('words'));
	}

    /**
     *  添加词汇页面
     */
    public function add(){
        return View::make('word.add');
    }

    /**
     *  Ajax执行添加词汇
     */
    public function doAdd(){
        $word = Input::get('word');
        $description = Input::get('description');

        $res = array('stat'=>0,'msg'=>'');

        if(''==$word || ''==$description){
            $res['msg'] = 'Can not be empty.';
            echo json_encode($res);
            die;
        }

        $succ = WordProcessor::addWord($word, $description);

        if($succ){
            $res['stat'] = 1;
            $res['msg'] = 'Add Successfully.';
        }else{
            $res['msg'] = 'Add Unsuccessfully.';
        }

        echo json_encode($res);
        die;
    }

    /**
     *  Ajax执行删除词汇
     */
    public function doDelete(){
        $wordId = Input::get('word_id');

        $res = array('stat'=>0,'msg'=>'');

        if(''==$wordId || !is_numeric($wordId)){
            $res['msg'] = 'Word Id is wrong.';
            echo json_encode($res);
            die;
        }

        $succ = WordProcessor::delWord($wordId);

        if($succ){
            $res['stat'] = 1;
            $res['msg'] = 'Delete Successfully.';
        }else{
            $res['msg'] = 'Delete Unsuccessfully.';
        }

        echo json_encode($res);
        die;
    }

}
<file_sep>/app/libraries/paypal/lib/Api/RelatedResources.php
<?php

namespace PayPal\Api;

use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;

/**
 * Class RelatedResources
 *
 * @property \PayPal\Api\Sale          sale
 * @property \PayPal\Api\Authorization authorization
 * @property \PayPal\Api\Capture       capture
 * @property \PayPal\Api\Refund        refund
 */
class RelatedResources extends PPModel
{
    /**
     * Set Sale
     * A sale transaction
     *
     * @param \PayPal\Api\Sale $sale
     *
     * @return $this
     */
    public function setSale($sale)
    {
        $this->sale = $sale;
        return $this;
    }

    /**
     * Get Sale
     * A sale transaction
     *
     * @return \PayPal\Api\Sale
     */
    public function getSale()
    {
        return $this->sale;
    }

    /**
     * Set Authorization
     * An authorization transaction
     *
     * @param \PayPal\Api\Authorization $authorization
     *
     * @return $this
     */
    public function setAuthorization($authorization)
    {
        $this->authorization = $authorization;
        return $this;
    }

    /**
     * Get Authorization
     * An authorization transaction
     *
     * @return \PayPal\Api\Authorization
     */
    public function getAuthorization()
    {
        return $this->authorization;
    }

    /**
     * Set Capture
     * A capture transaction
     *
     * @param \PayPal\Api\Capture $capture
     *
     * @return $this
     */
    public function setCapture($capture)
    {
        $this->capture = $capture;
        return $this;
    }

    /**
     * Get Capture
     * A capture transaction
     *
     * @return \PayPal\Api\Capture
     */
    public function getCapture()
    {
        return $this->capture;
    }

    /**
     * Set Refund
     * A refund transaction
     *
     * @param \PayPal\Api\Refund $refund
     *
     * @return $this
     */
    public function setRefund($refund)
    {
        $this->refund = $refund;
        return $this;
    }

    /**
     * Get Refund
     * A refund transaction
     *
     * @return \PayPal\Api\Refund
     */
    public function getRefund()
    {
        return $this->refund;
    }

    /**
     * Set Order
     * 
     * @param \PayPal\Api\Order $order
     * 
     * @return $this
     */
    public function setOrder($order)
    {
        $this->order = $order;

        return $this;
    }

    /**
     * Get Order
     * 
     * @return \PayPal\Api\Order
     */
    public function getOrder()
    {
        return $this->order;
    }
}
<file_sep>/app/database/seeds/WordTableSeeder.php
<?php
/**
 * Created by PhpStorm.
 * User: <NAME>
 * Date: 2014/10/14
 * Time: 14:47
 */

class WordTableSeeder extends Seeder {
    public function run()
    {
        DB::table('words')->insert(
            array(
                'word' => 'cat',
                'description' => '猫',
                'created_at'=>date('Y-m-d H:i:s',time()),
                'updated_at'=>date('Y-m-d H:i:s',time()),
            )
        );
    }
} <file_sep>/config/mgt/config.php
<?php
/**
 * config.php
 *
 * Descript Here
 *
 * @filename config.php
 * @version  v1.0
 * @update   2013-3-28
 * @author   randy.hong
 * @contact  <EMAIL>
 * @package  chinascope
 */

//DB配置
define('OMS_DB_DRIVER',          'mysql');
define('OMS_DB_HOST',            '192.168.250.200');
define('OMS_DB_PORT',            '3306');
define('OMS_DB_NAME',            'ada_cam');
define('OMS_DB_USER',            'ada_user');
define('OMS_DB_PASS',            '<PASSWORD>');
define('OMS_DB_CHARSET',         'utf8');
define('OMS_DB_DEBUG',           TRUE);
define('BASE_DOMAIN',			'chinascope.net');

//redis缓存配置
define('REDIS_HOST',			 '192.168.250.200');							//redis host
define('REDIS_PORT',			 6379);		

//redis缓存配置
define('REDIS_HOST_SH',			 '192.168.250.200');							//redis host
define('REDIS_PORT_SH',			 6379);									//redis port

//MONGO ADA服务器配置
define('MONGO_ADA_HOST',		'192.168.250.200');
define('MONGO_ADA_PORT',		'27017');
define('MONGO_ADA_DB',			'ada');

//MONGO ADMIN服务器配置
define('MONGO_ADMIN_HOST',		'192.168.250.200');
define('MONGO_ADMIN_PORT',		'27017');
define('MONGO_ADMIN_DB',		'csf_admin');

//REST接口和JAVA借口地址配置
define('REST_SERVER',            'http://1172.16.31.10:18080');              //rest search service

//SMTP服务器配置
define('SMTP_HOST',				'mail.chinascopefinancial.com');			 // SMTP URL
define('SMTP_PORT',				25);                                         // SMTP PORT
define('SMTP_USER',				'<EMAIL>');			 // SMTP USER
define('SMTP_PASS',				'<PASSWORD>');                            // SMTP PASSWORD
define('MAIL_CHARSET',			'utf-8');                                    // CHARSET CONFIG

define('MAIL_SUPPORT',			"<EMAIL>");      // support team email address
define('MAIL_SALES',			"<EMAIL>");      // sales team email address
define('MAIL_TRIAL',			"<EMAIL>");      // sales team email address

//程序环境变量
!defined('ENVIRONMENT') && define('ENVIRONMENT',            'production');<file_sep>/app/database/seeds/UserTableSeeder.php
<?php
/**
 * Created by PhpStorm.
 * User: <NAME>
 * Date: 2014/10/14
 * Time: 14:47
 */

class UserTableSeeder extends Seeder {
    public function run()
    {

        try
        {
            // Create the group
            $group = Sentry::createGroup(array(
                'name'        => 'Administrator',
                'permissions' => array(
                    'admin' => 1,
                    'users' => 1,
                ),
            ));
        }
        catch (Cartalyst\Sentry\Groups\NameRequiredException $e)
        {
            echo 'Name field is required';
        }
        catch (Cartalyst\Sentry\Groups\GroupExistsException $e)
        {
            echo 'Group already exists';
        }

        try
        {
            // Create the user
            $user = Sentry::createUser(array(
                'email'     => '<EMAIL>',
                'password'  => '<PASSWORD>',
                'activated' => true,
                'first_name' => 'Daniel',
                'last_name' => 'Kong',
            ));

            // Find the group using the group id
            $adminGroup = Sentry::findGroupById(1);

            // Assign the group to the user
            $user->addGroup($adminGroup);
        }
        catch (Cartalyst\Sentry\Users\LoginRequiredException $e)
        {
            echo 'Login field is required.';
        }
        catch (Cartalyst\Sentry\Users\PasswordRequiredException $e)
        {
            echo 'Password field is required.';
        }
        catch (Cartalyst\Sentry\Users\UserExistsException $e)
        {
            echo 'User with this login already exists.';
        }
        catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
        {
            echo 'Group was not found.';
        }
    }
} <file_sep>/config/www/config.php
<?php
/**
 * config.php
 *
 * Descript Here
 *
 * @filename config.php
 * @version  v1.0
 * @update   2013-3-28
 * @author   randy.hong
 * @contact  <EMAIL>
 * @package  chinascope
 */

//DB配置
define('OMS_DB_DRIVER',          'mysql');
define('OMS_DB_HOST',            'sg-com-csf-web-db.cwiif0vzcyt6.ap-southeast-1.rds.amazonaws.com');
define('OMS_DB_PORT',            '3306');
define('OMS_DB_NAME',            'ada_cam');
define('OMS_DB_USER',            'website');
define('OMS_DB_PASS',            '<PASSWORD>');
define('OMS_DB_CHARSET',         'utf8');
define('OMS_DB_DEBUG',           TRUE);
define('BASE_DOMAIN',			'chinascopefinancial.com');

//redis缓存配置
define('REDIS_HOST',			 '10.142.123.144');							//redis host
define('REDIS_PORT',			 6379);	

//redis缓存配置
define('REDIS_HOST_SH',			 '172.16.17.32');							//redis host
define('REDIS_PORT_SH',			 6379);										//redis port

//MONGO ADA服务器配置
define('MONGO_ADA_HOST',		'10.142.123.144');
define('MONGO_ADA_PORT',		'27017');
define('MONGO_ADA_DB',			'ada');

//MONGO ADMIN服务器配置
define('MONGO_ADMIN_HOST',		'10.134.105.228');
define('MONGO_ADMIN_PORT',		'27017');
define('MONGO_ADMIN_DB',		'ada');

//REST接口和JAVA借口地址配置
define('REST_SERVER',           'http://10.134.213.90:18080');

//SMTP服务器配置
define('SMTP_HOST',				'mail.chinascopefinancial.com');			 // SMTP URL
define('SMTP_PORT',				25);                                         // SMTP PORT
define('SMTP_USER',				'<EMAIL>');			 // SMTP USER
define('SMTP_PASS',				'<PASSWORD>');                            // SMTP PASSWORD
define('MAIL_CHARSET',			'utf-8');                                    // CHARSET CONFIG

define('MAIL_SUPPORT',			"<EMAIL>");      // support team email address
define('MAIL_SALES',			"<EMAIL>");      // sales team email address
define('MAIL_TRIAL',			"<EMAIL>");      // trial team email address

//程序环境变量
!defined('ENVIRONMENT') && define('ENVIRONMENT',            'production');<file_sep>/app/routes.php
<?php
Route::model('user', 'User');
Route::model('order', 'Order');
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

Route::match(array('get', 'post'), '/login', 'UserController@login');
Route::match(array('get', 'post'), 'refund/alipay/notify', 'RefundController@alipayNotify');


/**
 * Sentry filter
 *
 * Checks if the user is logged in
 */
Route::filter('sentry', function()
{
    if ( ! Sentry::check()) {
        return Redirect::to('/login');
    }
});

/**
 * InGroup filter
 *
 * Check if the user belongs to a group
 */
Route::filter('inGroup', function($route, $request, $value)
{
    try
    {
        $user = Sentry::getUser();

        $group = Sentry::findGroupByName($value);

        if( ! $user->inGroup($group))
        {
            throw new NotFoundException;
//            return Response::make('Not Found', 404);
        }
    }
    catch (Cartalyst\Sentry\Users\UserNotFoundException $e)
    {
        throw new NotFoundException;
//        return Response::make('Not Found', 404);
    }

    catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e)
    {
        throw new NotFoundException;
//        return Response::make('Not Found', 404);
    }
});

//against csrf attack
Route::when('*', 'csrf', array('post', 'put', 'delete'));

Route::group(array('before' => 'sentry|inGroup:Administrator'), function()
{
    Route::get('/', function(){ return View::make('index'); });
    Route::get('/logout', 'UserController@logout');

    Route::get('user', 'UserController@index');
    Route::get('word', 'WordController@index');
    Route::get('word/add', 'WordController@add');
    Route::post('word/add', 'WordController@doAdd');
    Route::post('word/delete', 'WordController@doDelete');

    Route::get('sentence', 'SentenceController@index');
    Route::get('sentence/daily', 'SentenceController@daily');
    Route::get('sentence/add', 'SentenceController@add');
    Route::post('sentence/add', 'SentenceController@doAdd');
    Route::get('sentence/edit/{sentence_id}', 'SentenceController@edit');
    Route::post('sentence/edit', 'SentenceController@doEdit');
    Route::post('sentence/delete', 'SentenceController@doDelete');
});
<file_sep>/gulpfile.js
//Load gulp and plug-ins
var gulp = require('gulp');
var del = require('del');
var path = require('path');
var runSequence = require('run-sequence');
var merge = require('merge-stream');
var $ = require('gulp-load-plugins')();


//Common tasks for sources


//step 3 Pre-compile Sass files
// sources/styles/*.scss -> public/styles/*.css
// echo "/.sass-cache" >> .gitignore
gulp.task('styles', function () {

    var vendDeps = gulp.src('./sources/styles/vondors/**/*.css')
        .pipe($.concat('vendor.css'))
        .pipe($.minifyCss())
        .pipe($.rename('vendor.min.css'))
        .pipe(gulp.dest('public/assets/css'))
        .pipe($.size({title: 'styles'}));

    var mainDeps = gulp.src('./sources/styles/css/screen.css')
        .pipe($.minifyCss())
        .pipe($.rename('screen.min.css'))
        .pipe(gulp.dest('public/assets/css'))
        .pipe($.size({title: 'styles'}))

    return merge(vendDeps, mainDeps);
});

//step 4 Check syntax and copy files
// sources/scripts/*.js -> public/scripts/*.js
gulp.task('scripts', function () {

    var vendDeps = gulp.src(['./sources/scripts/vondors/**/*.js'])
        .pipe($.jshint('.jshintrc'))
        .pipe($.concat('vendor.js'))
        .pipe($.uglify())
        .pipe($.rename('vendor.min.js'))
        .pipe(gulp.dest('public/assets/js'))
        .pipe($.size({title: 'vendor-scripts'}));

    var appDeps = gulp.src('./sources/scripts/app.js')
        .pipe($.jshint('.jshintrc'))
        .pipe($.uglify())
        .pipe($.rename('app.min.js'))
        .pipe(gulp.dest('public/assets/js'))
        .pipe($.size({title: 'app-scripts'}));

    return merge(vendDeps, appDeps);
});

//step 6 Copy fonts
//sources/fonts/**/*.* -> public/assets/fonts/
gulp.task('fonts', function () {
    return gulp.src([
        'sources/fonts/*.{otf,eot,svg,ttf,woff}',
        'public/bower_components/**/fonts/**/*.{otf,eot,svg,ttf,woff}'
    ])
        .pipe($.flatten())
        .pipe(gulp.dest('public/assets/fonts'))
        .pipe($.size({title: 'fonts'}));
});

/////// DEVELOPMENT ///////

// Clean
gulp.task('clean:develop', function (cb) {
    del(['public/**/*.html', '!public/bower_components/**/*.html', '.sass-cache'], cb);
});

// Prepare for development
gulp.task('prepare', function (cb) {
    runSequence(
        'clean:develop',
        ['styles', 'scripts', 'fonts'],
        cb);
});


// Watch
gulp.task('watch', ['prepare'], function () {
    gulp.watch('sources/styles/vondors/**/*.css', ['styles']);
    gulp.watch('sources/scripts/**/*.js', ['scripts']);
});

/////// BUILD ///////

// HTML
gulp.task('build', ['styles', 'scripts', 'fonts'], function () {

});

// Clean Cache
gulp.task('clean:cache', function (cb) {
    return $.cache.clearAll(cb);
});

// Clean
gulp.task('clean', ['clean:develop', 'clean:cache'], function (cb) {
    del([
        'public/assets/css', 'public/assets/js',
        'public/assets/fonts',
    ], cb);
});

// Clean temporary sources
gulp.task('clean:temporary', function (cb) {
    del([
        '.sass-cache'
    ], cb);
});

// Build
gulp.task('default', function (cb) {
    runSequence('clean', 'build', 'clean:temporary', cb);
});
<file_sep>/app/controllers/SentenceController.php
<?php

class SentenceController extends BaseController {

    /**
     *  首页
     */
	public function index()
	{
        $keywords = Input::get('key');
        $sentences = SentenceProcessor::getSentenceList($keywords);

        return View::make('sentence.index', compact('sentences','keywords'));
	}

    /**
     *  每日一句
     */
    public function daily()
    {
        $sentences = SentenceProcessor::getRandomSentence();

        return View::make('sentence.daily', compact('sentences'));
    }

    /**
     *  添加例句页面
     */
    public function add(){
        return View::make('sentence.add');
    }

    /**
     *  Ajax执行添加例句
     */
    public function doAdd(){
        $sentence = Input::get('sentence');
        $description = Input::get('description');

        $res = array('stat'=>0,'msg'=>'');

        if(''==$sentence || ''==$description){
            $res['msg'] = 'Can not be empty.';
            echo json_encode($res);
            die;
        }

        $succ = SentenceProcessor::addSentence($sentence, $description);

        if($succ){
            $res['stat'] = 1;
            $res['msg'] = 'Add Successfully.';
        }else{
            $res['msg'] = 'Add Unsuccessfully.';
        }

        echo json_encode($res);
        die;
    }

    /**
     *   Ajax执行删除例句
     */
    public function doDelete(){
        $sentenceId = Input::get('sentence_id');

        $res = array('stat'=>0,'msg'=>'');

        if(''==$sentenceId || !is_numeric($sentenceId)){
            $res['msg'] = 'Word Id is wrong.';
            echo json_encode($res);
            die;
        }

        $succ = SentenceProcessor::delSentence($sentenceId);

        if($succ){
            $res['stat'] = 1;
            $res['msg'] = 'Delete Successfully.';
        }else{
            $res['msg'] = 'Delete Unsuccessfully.';
        }

        echo json_encode($res);
        die;
    }

    /**
     *  编辑例句页面
     */
    public function edit(){
        $sentenceId = Route::input('sentence_id');

        if(''==$sentenceId || !is_numeric($sentenceId)){
            return Redirect::to('/sentence');
        }

        $sentenceDetail = SentenceProcessor::getDetailById($sentenceId);

        return View::make('sentence.edit', compact('sentenceDetail'));
    }

    /**
     *  Ajax执行更新例句
     */
    public function doEdit(){
        $sentenceId = Input::get('sentence_id');
        $sentence = Input::get('sentence');
        $description = Input::get('description');

        $res = array('stat'=>0,'msg'=>'');

        if(''==$sentenceId || ''==$sentence || ''==$description){
            $res['msg'] = 'Can not be empty.';
            echo json_encode($res);
            die;
        }

        $succ = SentenceProcessor::updateSentence($sentenceId, $sentence, $description);

        if($succ){
            $res['stat'] = 1;
            $res['msg'] = 'Update Successfully.';
        }else{
            $res['msg'] = 'Update Unsuccessfully.';
        }

        echo json_encode($res);
        die;
    }

}
<file_sep>/app/models/UserProcessor.php
<?php

class UserProcessor {

    /**
     * 获取用户列表
     */
    public static function getUserList()
    {
        $users = User::where('activated','1')->get();

        foreach($users as $key=>$user){
            $user->roles = implode(',', array_column($user->roles->toArray(),'name'));
        }

        return $users;
    }

}
<file_sep>/sources/scripts/app.js
/**
 * Created by <NAME> on 2014/10/19.
 */

$(document).ready(function(){
    /**
     *  点击单词添加按钮
     */
    $('#add_btn').click(function(){
        var word = $('#inputWord').val();
        var description = $('#inputDescription').val();

        if(word=='' || description==''){
            new $.flavr('Can not be empty.');
            return false;
        }

        //防止csrf攻击
        ajaxCsrfSetup();

        $.ajax({
            type:'post',
            url:app_url + '/word/add',
            data:{word:word,description:description},
            beforeSend: function(){
                // Handle the beforeSend event
                $("#main-container").mask("Loading...");
            },

            complete: function(){
                // Handle the complete event
                $("#main-container").unmask();
            },
            success:function(data){
                if(typeof(JSON) !== 'object' || typeof(JSON.parse) !== 'function'){
                    new $.flavr('Something Wrong!');
                    return false;
                }

                var res = JSON.parse(data);
                new $.flavr(res.msg);
                $('#inputWord').val('');
                $('#inputDescription').val('');
            }
        });
    });

    /**
     *   点击单词删除按钮
     */
    $('.word_del_btn').click(function(){
        var word_id = $(this).attr('item_id');
        var item = $(this).parents('tr');

        if(word_id=='' || isNaN(word_id)){
            new $.flavr('Word Id is wrong.');
            return false;
        }

        new $.flavr({ content : 'Are you sure to delete it?',
            dialog : 'confirm',
            onConfirm : function(){
                //防止csrf攻击
                ajaxCsrfSetup();

                $.ajax({
                    type:'post',
                    url:app_url + '/word/delete',
                    data:{word_id:word_id},
                    beforeSend: function(){
                        // Handle the beforeSend event
                        $("#main-container").mask("Loading...");
                    },

                    complete: function(){
                        // Handle the complete event
                        $("#main-container").unmask();
                    },
                    success:function(data){
                        if(typeof(JSON) !== 'object' || typeof(JSON.parse) !== 'function'){
                            new $.flavr('Something Wrong!');
                            return false;
                        }

                        var res = JSON.parse(data);
                        new $.flavr(res.msg);
                        item.remove();
                    }
                });
            },
            onCancel : function(){}
        });
    });

    /**
     *  点击例句添加按钮
     */
    $('#sentence_add_btn').click(function(){
        var sentence = $('#sentenceWord').val();
        var description = $('#sentenceDescription').val();

        if(sentence=='' || description==''){
            new $.flavr('Can not be empty.');
            return false;
        }

        //防止csrf攻击
        ajaxCsrfSetup();

        $.ajax({
            type:'post',
            url:app_url + '/sentence/add',
            data:{sentence:sentence,description:description},
            beforeSend: function(){
                // Handle the beforeSend event
                $("#main-container").mask("Loading...");
            },

            complete: function(){
                // Handle the complete event
                $("#main-container").unmask();
            },
            success:function(data){
                if(typeof(JSON) !== 'object' || typeof(JSON.parse) !== 'function'){
                    new $.flavr('Something Wrong!');
                    return false;
                }

                var res = JSON.parse(data);
                new $.flavr(res.msg);
                $('#sentenceWord').val('');
                $('#sentenceDescription').val('');
            }
        });
    });

    /**
     *   点击例句编辑按钮
     */
    $('.sentence_edit_btn').click(function(){
        var sentence_id = $(this).attr('item_id');

        if(sentence_id=='' || isNaN(sentence_id)){
            new $.flavr('Sentence Id is wrong.');
            return false;
        }

        window.location.href = app_url + '/sentence/edit/' + sentence_id;

    });

    /**
     *  点击例句更新按钮
     */
    $('#sentence_update_btn').click(function(){
        var sentence_id = $('#sentenceId').val();
        var sentence = $('#sentenceWord').val();
        var description = $('#sentenceDescription').val();

        if(sentence_id=='' || sentence=='' || description==''){
            new $.flavr('Can not be empty.');
            return false;
        }

        //防止csrf攻击
        ajaxCsrfSetup();

        $.ajax({
            type:'post',
            url:app_url + '/sentence/edit',
            data:{sentence_id:sentence_id,sentence:sentence,description:description},
            beforeSend: function(){
                // Handle the beforeSend event
                $("#main-container").mask("Loading...");
            },

            complete: function(){
                // Handle the complete event
                $("#main-container").unmask();
            },
            success:function(data){
                if(typeof(JSON) !== 'object' || typeof(JSON.parse) !== 'function'){
                    new $.flavr('Something Wrong!');
                    return false;
                }

                var res = JSON.parse(data);
                new $.flavr(res.msg);
                window.location.href = app_url + '/sentence/edit/' + sentence_id;
            }
        });
    });

    /**
     *   点击例句删除按钮
     */
    $('.sentence_del_btn').click(function(){
        var sentence_id = $(this).attr('item_id');
        var item = $(this).parents('tr');

        if(sentence_id=='' || isNaN(sentence_id)){
            new $.flavr('Sentence Id is wrong.');
            return false;
        }

        new $.flavr({ content : 'Are you sure to delete it?',
            dialog : 'confirm',
            onConfirm : function(){
                //防止csrf攻击
                ajaxCsrfSetup();

                $.ajax({
                    type:'post',
                    url:app_url + '/sentence/delete',
                    data:{sentence_id:sentence_id},
                    beforeSend: function(){
                        // Handle the beforeSend event
                        $("#main-container").mask("Loading...");
                    },

                    complete: function(){
                        // Handle the complete event
                        $("#main-container").unmask();
                    },
                    success:function(data){
                        if(typeof(JSON) !== 'object' || typeof(JSON.parse) !== 'function'){
                            new $.flavr('Something Wrong!');
                            return false;
                        }

                        var res = JSON.parse(data);
                        new $.flavr(res.msg);
                        window.location.reload();
                    }
                });
            },
            onCancel : function(){}
        });
    });

    /**
     *  隐藏显示例句按钮
     */
    $("#sentence_show_btn").click(function(){
        var sentence_holder = $("#sentence_holder");
        if(sentence_holder.hasClass('hidden')){
            sentence_holder.removeClass('hidden');
            $(this).html('点击我隐藏');
        }else{
            sentence_holder.addClass('hidden');
            $(this).html('点击我显示');
        }
    });

    /**
     *  点击换一句按钮
     */
    $("#sentence_random_btn").click(function(){
        location.reload();
    });

    /**
     *  点击搜索按钮
     */
    $("#sentence_search_btn").click(function(){
        var key = $.trim( $('#sentence_key').val() );
        if(''!=key){
            window.location.href = app_url + '/sentence?key='+encodeURIComponent(key);
        }
        return false;
    });
    $("#word_search_btn").click(function(){
        var key = $.trim( $('#word_key').val() );
        if(''!=key){
            window.location.href = app_url + '/word?key='+encodeURIComponent(key);
        }
        return false;
    });


    //这个就是键盘触发的函数
    var SubmitOrHidden = function(evt){
        var btn;
        if(1==$("#sentence_search_btn").length){
            btn = $("#sentence_search_btn");
        }else if(1==$("#word_search_btn").length){
            btn = $("#word_search_btn");
        }

        evt = window.event || evt;
        if(evt.keyCode==13){//如果取到的键值是回车
            btn.click();
        }
    }

    window.document.onkeydown=SubmitOrHidden;//当有键按下时执行函数

    /**
     *   ajax against csrf setup
     */
    var ajaxCsrfSetup = function()   {
        $.ajaxSetup({
            headers: {
                'X-CSRF-Token': $('meta[name="_token"]').attr('content')
            }
        });
    }

});

<file_sep>/app/libraries/paypal/lib/Api/Order.php
<?php

namespace PayPal\Api;

use PayPal\Common\PPModel;
use PayPal\Rest\ApiContext;

/**
 * Class Order
 * 
 * @property string             id
 * @property string             createTime
 * @property string             updateTime
 * @property string             state
 * @property \PayPal\Api\Amount amount
 * @property string             parentPayment
 * @property \PayPal\Api\Links  links
 * @property string             reasonCode
 */
class Order extends PPModel
{
    /**
     * Set the identifier of the order transaction.
     * 
     * @param string $id
     * 
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Get the identifier of the order transaction.
     * 
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set the time the resource was created.
     * 
     * @param string $create_time
     * 
     * @return $this
     */
    public function setCreateTime($create_time)
    {
        $this->create_time = $create_time;

        return $this;
    }

    /**
     * Get the time the resource was created.
     * 
     * @return string
     */
    public function getCreateTime()
    {
        return $this->create_time;
    }

    /**
     * Set the time the resource was last updated.
     * 
     * @param string $update_time
     * 
     * @return $this
     */
    public function setUpdateTime($update_time)
    {
        $this->update_time = $update_time;

        return $this;
    }

    /**
     * Get the time the resource was last updated.
     * 
     * @return string
     */
    public function getUpdateTime()
    {
        return $this->update_time;
    }

    /**
     * Set the state of the order transaction.
     * 
     * Allowed values are: `PENDING`, `COMPLETED`, `REFUNDED` or `PARTIALLY_REFUNDED`.
     * 
     * @param string $state
     * 
     * @return $this
     */
    public function setState($state)
    {
        $this->state = $state;

        return $this;
    }

    /**
     * Get the state of the order transaction.
     * 
     * Allowed values are: `PENDING`, `COMPLETED`, `REFUNDED` or `PARTIALLY_REFUNDED`.
     * 
     * @return string
     */
    public function getState()
    {
        return $this->state;
    }

    /**
     * Set the amount being collected.
     * 
     * @param \PayPal\Api\Amount $amount
     * 
     * @return $this
     */
    public function setAmount($amount)
    {
        $this->amount = $amount;

        return $this;
    }

    /**
     * Get the amount being collected.
     * 
     * @return \PayPal\Api\Amount
     */
    public function getAmount()
    {
        return $this->amount;
    }

    /**
     * Set ID of the payment resource on which this transaction is based.
     * 
     * @param string $parent_payment
     * 
     * @return $this
     */
    public function setParentPayment($parent_payment)
    {
        $this->parent_payment = $parent_payment;

        return $this;
    }

    /**
     * Get ID of the payment resource on which this transaction is based.
     * 
     * @return string
     */
    public function getParentPayment()
    {
        return $this->parent_payment;
    }

    /**
     * Set Links
     * 
     * @param \PayPal\Api\Links $links
     * 
     * @return $this
     */
    public function setLinks($links)
    {
        $this->links = $links;

        return $this;
    }

    /**
     * Get Links
     * 
     * @return \PayPal\Api\Links
     */
    public function getLinks()
    {
        return $this->links;
    }

    /**
     * Reason code for the transaction state being Pending or Reversed. Assigned in response.
     * 
     * Allowed values: `CHARGEBACK`, `GUARANTEE`, `BUYER_COMPLAINT`, `REFUND`,
     * `UNCONFIRMED_SHIPPING_ADDRESS`,
     * `ECHECK`, `INTERNATIONAL_WITHDRAWAL`,
     * `RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION`, `PAYMENT_REVIEW`,
     * `REGULATORY_REVIEW`, `UNILATERAL`, or `VERIFICATION_REQUIRED`
     * (`ORDER` can also be set in the response).
     * 
     * @param string $reason_code
     * 
     * @return $this
     */
    public function setReasonCode($reason_code)
    {
        $this->reason_code = $reason_code;

        return $this;
    }

    /**
     * Reason code for the transaction state being Pending or Reversed. Assigned in response.
     * 
     * Allowed values: `CHARGEBACK`, `GUARANTEE`, `BUYER_COMPLAINT`, `REFUND`,
     * `UNCONFIRMED_SHIPPING_ADDRESS`,
     * `ECHECK`, `INTERNATIONAL_WITHDRAWAL`,
     * `RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION`, `PAYMENT_REVIEW`,
     * `REGULATORY_REVIEW`, `UNILATERAL`, or `VERIFICATION_REQUIRED`
     * (`ORDER` can also be set in the response).
     * 
     * @return string
     */
    public function getReasonCode()
    {
        return $this->reason_code;
    }
}
<file_sep>/app/models/WordProcessor.php
<?php

class WordProcessor {

    /**
     * 获取单词列表
     */
    public static function getWordList($keywords='')
    {
        $user = Sentry::getUser();
        if(empty($keywords)){
            $words = Word::where('uid','=',$user->id)->orderBy('created_at','desc')->paginate(10);
        }else{
            $words = Word::where('uid','=',$user->id)->where('description', 'like', '%'.urldecode($keywords).'%')->orderBy('created_at','desc')->paginate(10);
        }

        foreach($words as $key=>$word){
            if(is_mobile()){
                $word->url = 'http://m.youdao.com/dict?le=eng&q='.$word->word;
            }else{
                $word->url = 'http://dict.youdao.com/search?q='.$word->word.'&keyfrom=dict.index';
            }

            $word->jq_url = 'http://dictionary.cambridge.org/dictionary/american-english/'.$word->word;
        }

        return $words;
    }

    /**
     * 添加单词
     *
     * @param $newword             新的单词
     * @param $description      添加新的单词
     */
    public static function addWord($newword, $description){
        $word = new Word;
        $user = Sentry::getUser();

        $word->word = $newword;
        $word->description = $description;
        $word->uid = $user->id;

        $res = $word->save();

        return $res;
    }

    /**
     * 删除单词
     *
     * @param $wordId             单词ID
     *
     */
    public static function delWord($wordId){
        $res = Word::destroy($wordId);
        return $res;
    }

}
<file_sep>/app/libraries/alipay/alipay_config.class.php
<?php
/* *
 * 类名：AlipayConfig
 * 功能：支付宝获取配置类
 * 详细：获取alipay.config.php配置文件
 * 版本：3.3
 * 日期：2012-07-23
 * 说明：
 * 以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 * 该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

class AlipayConfig {

	private static $config;

	/**
	 * 获取支付宝配置
	 * return 配置文件数组
	 */
	public static function get() {

		if(self::$config===null){
			//引入配置文件
			require_once("alipay.config.php");
			self::$config = $alipay_config;
		}

		return self::$config;
	}

}
?>