/usr/share/nginx/html/bootstrap/service.php
return new FileCache($frontCache, ['cacheDir' => ROOT_DIR . 'storage/cache/', 'prefix' => 'cache_']);
}, true);
$di->set('cache', function () use ($di) {
$redis = new Redis();
$redis->connect($di["config"]->path("cache.host"), $di["config"]->path("cache.port"));
$redis->select($di["config"]->path("cache.db"));
return $redis;
}, true);
$di->set('db', function () use ($di) {
$connection = new Mysql([
'host' => $di["config"]->path("database.mysql.host"),
'port' => $di["config"]->path("database.mysql.port"),
'username' => $di["config"]->path("database.mysql.user"),
'password' => $di["config"]->path("database.mysql.pass"),
'dbname' => $di["config"]->path("database.mysql.db"),
'charset' => $di["config"]->path("database.mysql.charset"),
]);
$connection->setEventsManager($di['eventsManager']);
return $connection;
}, true);
$di->set('redis', function () use ($di) {
$redis = new Redis();
$redis->connect($di["config"]->path("database.redis.host"), $di["config"]->path("database.redis.port"));
$redis->select($di["config"]->path("database.redis.db"));
return $redis;
}, true);
$di->set('mongodb', function () use ($di) {
return new MongoDBClient(
"mongodb://" . $di["config"]->path('database.mongodb.host') . ':' . $di["config"]->path('database.mongodb.port'),
array_filter([
'username' => $di["config"]->path('database.mongodb.user'),
'password' => $di["config"]->path('database.mongodb.pass'),
Arguments
"SQLSTATE[HY000] [1203] User web1063 already has more than 'max_user_connections' active connections"
/usr/share/nginx/html/bootstrap/service.php
return new FileCache($frontCache, ['cacheDir' => ROOT_DIR . 'storage/cache/', 'prefix' => 'cache_']);
}, true);
$di->set('cache', function () use ($di) {
$redis = new Redis();
$redis->connect($di["config"]->path("cache.host"), $di["config"]->path("cache.port"));
$redis->select($di["config"]->path("cache.db"));
return $redis;
}, true);
$di->set('db', function () use ($di) {
$connection = new Mysql([
'host' => $di["config"]->path("database.mysql.host"),
'port' => $di["config"]->path("database.mysql.port"),
'username' => $di["config"]->path("database.mysql.user"),
'password' => $di["config"]->path("database.mysql.pass"),
'dbname' => $di["config"]->path("database.mysql.db"),
'charset' => $di["config"]->path("database.mysql.charset"),
]);
$connection->setEventsManager($di['eventsManager']);
return $connection;
}, true);
$di->set('redis', function () use ($di) {
$redis = new Redis();
$redis->connect($di["config"]->path("database.redis.host"), $di["config"]->path("database.redis.port"));
$redis->select($di["config"]->path("database.redis.db"));
return $redis;
}, true);
$di->set('mongodb', function () use ($di) {
return new MongoDBClient(
"mongodb://" . $di["config"]->path('database.mongodb.host') . ':' . $di["config"]->path('database.mongodb.port'),
array_filter([
'username' => $di["config"]->path('database.mongodb.user'),
'password' => $di["config"]->path('database.mongodb.pass'),
Arguments
array:6 [
"host" => "10.130.91.250"
"port" => "3306"
"username" => "web1063"
"password" => "V_YWR<~Puw%-Y^DM-+JY,Sn98CTAVq"
"dbname" => "football"
"charset" => "utf8mb4"
]
[internal]
Arguments
null
Phalcon\Di\FactoryDefault {#5}
[internal]
Arguments
App\Http\Models\FbConfig {#134}
null
[internal]
Arguments
App\Http\Models\FbConfig {#134}
[internal]
Arguments
App\Http\Models\FbConfig {#134}
Phalcon\Di\FactoryDefault {#5}
[internal]
Arguments
App\Http\Models\FbConfig {#134}
"app\http\models\fbconfig-fb_config"
"fb_config"
""
[internal]
Arguments
App\Http\Models\FbConfig {#134}
13
array:2 [
"value" => true
"description" => true
]
[internal]
Arguments
App\Http\Models\FbConfig {#134}
array:2 [
"value" => true
"description" => true
]
/usr/share/nginx/html/app/Http/Models/FbConfig.php
namespace App\Http\Models;
/**
* Config Entity
* @author phuctd <[email protected]>
* @version 1.0
* @since 20/11/2019
* ___ __ __
* / _ \ / / ___ _ / / ____ ___ ___
* / ___/ / _ \/ _ `/ / / / __// _ \ / _ \
* /_/ /_//_/\_,_/ /_/ \__/ \___//_//_/
*
* High performance, PHP framework
*/
class FbConfig extends AbstractEntity {
public function initialize() {
$this->keepSnapshots(true);
$this->allowEmptyStringValues(['value', 'description']);
// Bỏ comment dòng sau để chống update config_name
$this->skipAttributesOnUpdate(['name']);
}
public function beforeUpdate() {
$this->updated = date('Y-m-d H:i:s');
}
/**
*
* @var integer
* @Primary
* @Identity
* @Column(type="integer", length=11, nullable=false)
*/
public $id;
/**
*
* @var string
Arguments
array:2 [
0 => "value"
1 => "description"
]
[internal]
Arguments
App\Http\Models\FbConfig {#134}
[internal]
Arguments
null
Phalcon\Di\FactoryDefault {#5}
Phalcon\Mvc\Model\Manager {#116}
[internal]
Arguments
"App\Http\Models\FbConfig"
true
/usr/share/nginx/html/app/Http/Controllers/Controller.php
public function getAds() {
$ads = FbAds::find([
'columns' => 'html_id,embed_code,default_code,start_date,end_date',
'conditions' => 'active=' . FbAds::YES,
'cache' => [
'key' => 'ads'
]
]);
$adsJSON = [];
foreach ($ads as $ad) {
$adsJSON[] = $ad;
}
$this->view->ads = json_encode($adsJSON, JSON_UNESCAPED_SLASHES);
}
/**
* Load glocal configs from database | cache
*/
public function getGlobalConfigs() {
$configs = FbConfig::find();
foreach ($configs as $config) {
$this->configs[$config->name] = $config->value;
}
}
public function setPageMeta() {
$currentUrl = $this->router->getRewriteUri();
$pageMeta = FbPageMeta::findFirstByUrl($currentUrl);
if (!$pageMeta) {
$this->view->setVars([
'title' => $this->getConfig('default_title'),
'keywords' => $this->getConfig('default_keywords'),
'description' => $this->getConfig('default_description'),
'ogImage' => $this->getConfig('default_og_image'),
]);
} else {
$this->view->setVars([
'title' => $pageMeta->meta_title,
/usr/share/nginx/html/app/Http/Controllers/Controller.php
use App\Http\Models\FbRank;
use App\Http\Models\FbArticle;
use App\Http\Models\FbCountry;
use App\Http\Models\FbTeam;
use App\Http\Models\FbAds;
use App\Http\Models\FbNhaCai;
use App\Http\Models\FbPageMeta;
use App\Http\Models\FbAffliateLink;
/**
* Base Controller
* @package App\Http\Controllers
*/
class Controller extends BaseController {
private $configs = [];
public function initialize() {
$this->getAds();
$this->getGlobalConfigs();
$this->getFavoriteClubs();
$this->setPageMeta();
# Default vars
$this->view->setVars([
'siteName' => $this->getConfig('site_name'),
'footerHtml' => $this->getConfig('footer_html'),
'currentUrl' => rtrim($this->url->getBaseUri(), '/') . $this->router->getRewriteUri(),
'rootUrl' => $this->url->getBaseUri(),
'facebookPage' => $this->getConfig('facebook_page'),
'twitterPage' => $this->getConfig('twitter_page'),
'pinterestPage' => $this->getConfig('pinterest_page'),
'instagramPage' => $this->getConfig('instagram_page'),
'linkedPage' => $this->getConfig('linkedin_page'),
'aboutMePage' => $this->getConfig('aboutme_page'),
'contactEmail' => $this->getConfig('contact_email'),
'contactTele' => $this->getConfig('contact_telegram'),
'headerCode' => $this->getConfig('header_code'),
'footerMobileHtml' => $this->getConfig('footer_mobile_html'),
'dmcaCode' => $this->getConfig('dmca_code'),
/usr/share/nginx/html/app/Http/Controllers/MatchController.php
* / _ \ / / ___ _ / / ____ ___ ___
* / ___/ / _ \/ _ `/ / / / __// _ \ / _ \
* /_/ /_//_/\_,_/ /_/ \__/ \___//_//_/
*
* High performance, PHP framework
*/
namespace App\Http\Controllers;
use App\Http\Models\FbMatchs;
use App\Http\Models\FbMatchReport;
use App\Http\Models\FbLeagua;
use App\Http\Models\FbMatchDetail;
use App\Http\Models\FbLeaguaSeason;
use App\Http\Models\FbHandicap;
class MatchController extends Controller {
public function initialize() {
parent::initialize();
}
/**
* Chi tiết trận đấu
* @param string $homeSlug
* @param string $guessSlug
* @param integer $id
*/
public function detailAction($homeSlug, $guessSlug, $id) {
if (!is_numeric($id)) {
return $this->response->redirect($this->url->getBaseUri(), false, 301);
}
$this->getLeftSideBar();
$this->getRightSideBar();
$match = FbMatchs::findFirst($id);
if (!$match) {
return $this->show404();
/usr/share/nginx/html/bootstrap/kernel.php
/*
| Setting Listeners
|------------------------------------------------------------------
|
| config/app.php listeners
|
*/
foreach ($this->di['config']->path('app.listeners') as $name => $listener) {
$this->di['eventsManager']->attach($name, new $listener);
}
}
public function kernel() {
$application = new Application($this->di);
$application->setEventsManager($this->di['eventsManager']);
if ($this->di['config']->path('app.disableView')) {
$application->useImplicitView(false);
}
$application->handle()->send();
}
}
$app = new Framework;
return $app;
/usr/share/nginx/html/bootstrap/kernel.php
* @link https://github.com/xxtime/phalcon
*/
use Phalcon\Loader;
use Phalcon\Logger;
use Phalcon\Mvc\Application;
/**
* Class Framework
* @property \Phalcon\Di|\Phalcon\DiInterface $di
*/
class Framework {
public $di;
public function boot() {
$this->loader();
$this->setting();
$this->kernel();
}
public function loader() {
$loader = new Loader();
$loader->registerNamespaces(array(
'App' => APP_DIR,
))->register();
require_once ROOT_DIR . 'vendor/autoload.php';
require_once ROOT_DIR . 'bootstrap/helpers.php';
$this->di = require_once ROOT_DIR . 'bootstrap/service.php';
loadEnv();
}
public function setting() {
ini_set("date.timezone", 'Asia/Ho_Chi_Minh');
date_default_timezone_set('Asia/Ho_Chi_Minh');
/usr/share/nginx/html/public/index.php
* ___ __ __
* / _ \ / / ___ _ / / ____ ___ ___
* / ___/ / _ \/ _ `/ / / / __// _ \ / _ \
* /_/ /_//_/\_,_/ /_/ \__/ \___//_//_/
*
* @link https://www.xxtime.com
* @link https://github.com/xxtime/phalcon
*/
define('SYSTEM_START', microtime(true));
define('ROOT_DIR', dirname(__DIR__) . '/');
define('APP_DIR', ROOT_DIR . 'app/');
define('CONFIG_DIR', ROOT_DIR . 'config/');
$app = require_once ROOT_DIR . "bootstrap/kernel.php";
$app->boot();