#0 | MongoDB\Driver\Manager->executeQuery(butashop.keywords, Object(MongoDB\Driver\Query))
/home/ebooking/sites/models/MainDB.php (96) <?php
namespace Multiple\Models;
class MainDB
{
public static $connection = false;
public static $db = "butashop";
public static $collection = false;
public static function getSource()
{
return null;
}
public static function setCollection($collection)
{
self::$collection = $collection;
}
public static function init()
{
self::$collection = static::getSource();
if(!self::$connection)
self::$connection = new \MongoDB\Driver\Manager('mongodb://localhost:27017/'.self::$db);
}
public static function insert($data)
{
self::init();
$insRec = new \MongoDB\Driver\BulkWrite;
$id = $insRec->insert($data);
$result = self::$connection->executeBulkWrite(self::$db.'.'.self::$collection, $insRec);
if($result)
{
return $id;
}
else
{
return false;
}
}
/**
public static function save($data)
{
return self::insert($data);
} */
public function save()
{
$ins = [];
foreach($this as $key => $value)
{
if($key !== "_id")
$ins[$key] = $value;
}
if($this->_id)
{
self::update(["_id" => $this->_id], $ins);
//exit(json_encode($this));
return (string)$this->_id;
}
return self::insert($ins);
}
public static function count($array = [])
{
$filter = (@$array[0]) ? $array[0]: [];
$options = [];
self::init();
$Command = new \MongoDB\Driver\Command(["count" => self::$collection, "query" => $filter]);
$Result = self::$connection->executeCommand(self::$db, $Command);
return $Result->toArray()[0]->n;
}
public static function find($array = [])
{
$filter = (@$array[0]) ? $array[0]: [];
$options = [];
if(isset($array["limit"]))
$options["limit"] = @$array["limit"];
if(isset($array["sort"]))
$options["sort"] = @$array["sort"];
if(isset($array["skip"]))
$options["skip"] = $array["skip"];
self::init();
$query = new \MongoDB\Driver\Query($filter, $options);
$rows = self::$connection->executeQuery(self::$db.'.'.self::$collection, $query);
return $rows->toArray();
}
public static function findById($id)
{
if(strlen($id) < 5)
return false;
$filter["_id"] = self::objectId($id);
self::init();
$query = new \MongoDB\Driver\Query($filter, []);
$rows = self::$connection->executeQuery(self::$db.'.'.self::$collection, $query);
foreach($rows as $row)
{
$obj = new static();
foreach($row as $k => $v){
$obj->{$k} = $v;
}
return $obj;
}
return false;
}
public static function findFirst($array = [])
{
$filter = (@$array[0]) ? $array[0]: [];
$options = [];
$options["limit"] = 1;
if(isset($array["sort"]))
$options["sort"] = @$array["sort"];
if(isset($array["skip"]))
$options["skip"] = $array["skip"];
self::init();
$query = new \MongoDB\Driver\Query($filter, $options);
$rows = self::$connection->executeQuery(self::$db.'.'.self::$collection, $query);
foreach($rows as $row)
{
$obj = new static();
foreach($row as $k => $v){
$obj->{$k} = $v;
}
return $obj;
}
return false;
}
public static function sum($field, $filter=[])
{
self::init();
$pipleLine = [];
if(count($filter) > 0)
$pipleLine[] = ['$match' => $filter];
$pipleLine[] = [
'$group' => ['_id' => '$asdaksdkaskk', 'total' => ['$sum' => '$'.$field], 'count' => ['$sum' => 1]],
];
$Command = new \MongoDB\Driver\Command([
'aggregate' => self::$collection,
'pipeline' => $pipleLine,
//'cursor' => new stdClass,
]);
$Result = self::$connection->executeCommand(self::$db, $Command);
//echo var_dump($field);
//echo "<pre>";var_dump($Result->toArray()[0]->result[0]);exit;
return $Result->toArray()[0]->result[0]->total;
}
public static function update($filter, $data)
{
self::init();
$options = ['multi' => true, 'upsert' => false];
$insRec = new \MongoDB\Driver\BulkWrite;
$insRec->update(
$filter,
['$set' => $data],
$options
);
$result = self::$connection->executeBulkWrite(self::$db.'.'.self::$collection, $insRec);
if($result)
{
return true;
}
else
{
return false;
}
}
public static function increment($filter, $data)
{
self::init();
$options = ['multi' => true, 'upsert' => false];
$insRec = new \MongoDB\Driver\BulkWrite;
$insRec->update(
$filter,
['$inc' => $data],
$options
);
$result = self::$connection->executeBulkWrite(self::$db.'.'.self::$collection, $insRec);
if($result)
{
return true;
}
else
{
return false;
}
}
public static function updateAndIncrement($filter, $update, $increment)
{
self::init();
$options = ['multi' => true, 'upsert' => false];
$insRec = new \MongoDB\Driver\BulkWrite;
$insRec->update(
$filter,
[
'$set' => $update,
'$inc' => $increment
],
$options
);
$result = self::$connection->executeBulkWrite(self::$db.'.'.self::$collection, $insRec);
if($result)
{
return true;
}
else
{
return false;
}
}
public static function delete($filter)
{
self::init();
$bulk = new \MongoDB\Driver\BulkWrite;
$bulk->delete($filter, ['limit' => 0]);
$result = self::$connection->executeBulkWrite(self::$db.'.'.self::$collection, $bulk);
if($result)
{
return true;
}
else
{
return false;
}
}
public static function getDate($time=false, $currentTimezone=false)
{
if(!$time)
$time=time();
$time *= 1000;
$datetime = new \MongoDB\BSON\UTCDateTime($time);
return $datetime;
}
public function dateTime($date, $currentTimezone=false)
{
$addTime = ($currentTimezone) ? 0: TIME_DIFF;
$unixtime = 0;
if($date && method_exists($date, "toDateTime"))
$unixtime = strtotime(@$date->toDateTime()->format("Y-m-d H:i:s")) + $addTime;
return $unixtime;
}
public function dateFormat($date, $format = "Y-m-d H:i:s", $currentTimezone=false)
{
$addTime = ($currentTimezone) ? 0: TIME_DIFF;
if($date && method_exists($date, "toDateTime"))
$unixtime = strtotime(@$date->toDateTime()->format("Y-m-d H:i:s")) + $addTime;
if(@$unixtime)
return date($format, $unixtime);
return 0;
}
public function toSeconds($date, $currentTimezone=false)
{
$addTime = ($currentTimezone) ? 0: TIME_DIFF;
if($date && method_exists($date, "toDateTime"))
return round(@$date->toDateTime()->format("U.u"), 0) + $addTime;
return 0;
}
public static function objectId($id)
{
if(strlen($id) < 5)
return false;
return new \MongoDB\BSON\ObjectID($id);
}
public function getUnixtime()
{
return time() + 0;
}
} |
#1 | Multiple\Models\MainDB::find(Array([0] => Array([lang] => ua), [limit] => 50, [skip] => 125236, [sort] => Array([index_id] => 1)))
/home/ebooking/sites/erobooking.com/apps/library/Acl.php (191) <?php
use \Phalcon\Events\Event;
use \Phalcon\Mvc\Dispatcher;
use \Phalcon\Http\Response\Cookies;
use Multiple\Models\Users;
use Multiple\Models\MongoKeywords;
use Multiple\Models\MongoHitlogs;
use Multiple\Models\MongoCategories;
use Multiple\Models\Languages;
use Multiple\Models\MongoColors;
use Multiple\Models\MongoMaterial;
use Multiple\Models\MongoProductCountry;
use Multiple\Models\MongoProductOptions;
use Multiple\Models\MongoForWhat;
use Multiple\Models\MongoBrands;
use Multiple\Models\Currency;
use Multiple\Models\MongoCountry;
use Multiple\Models\Cache;
use Multiple\Models\MainDB;
use Lib\Lib;
class Acl extends \Phalcon\Di\Injectable
{
protected $_module;
protected $error;
public function __construct($module)
{
$this->_module = $module;
}
public function auth()
{
if(!@$_COOKIE["ref"]){
setcookie("ref", $this->request->getHTTPReferer(), time()+300*24*3600, "/");
}
$data = false;
if ($this->request->get("logout")){
Users::destroyCookie();
}else if($_COOKIE['u_id']){
$data = Users::getById($_COOKIE['u_id']);
if (!$data){
Users::destroyCookie();
}elseif(Lib::generatePassword($data->password) == $_COOKIE['u_pw'] && (int)@$data->active == 1){
Users::$id = $data->id;
Users::$data = $data;
Users::$data->visited_at = date("Y-m-d H:i:s");
Users::$data->save();
}else{
Users::destroyCookie();
}
}
$this->view->setVar("user_data", $data);
}
public function initLang()
{
}
public function botLog(){
if (strpos(strtolower($this->request->getServer("HTTP_USER_AGENT")), "bot") == false && !$this->request->isAjax()){
$H = new MongoHitlogs();
$H->url = urldecode($this->request->getServer("REQUEST_URI"));
$H->user_id = (float)@Users::$id;
$H->ip = $this->request->getServer("REMOTE_ADDR");
$H->useragent = $this->request->getServer("HTTP_USER_AGENT");
$H->referer = $this->request->getServer("HTTP_REFERER");
$H->bot = strpos(strtolower($this->request->getServer("HTTP_USER_AGENT")), "googlebot") > 0 ? "google": "other";
$H->domain = _SITEURL_;
$H->domain_id = DOMAIN_ID;
$H->date = MainDB::getDate();
//$H->save();
}
}
public function initCurrency()
{
switch(_LANG_){
default:$currency = 4;break;
case 'az':$currency = 5;break;
case 'ru':$currency = 2;break;
case 'en':$currency = 1;break;
case 'ua':$currency = 4;break;
}
if(@Currency::$currencies[$this->request->get("currency")]){
$currency = $this->request->get("currency");
setcookie("currency", $currency, time()+365*24*3600, "/");
}elseif(@Currency::$currencies[@$_COOKIE["currency"]]){
$currency = $_COOKIE["currency"];
}
define("_CURRENCY_", $currency);
}
public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
{
self::initCurrency();
self::auth();
self::botLog();
define("_ROOT_", "/"._LANG_);
define("_PAYMENT_CURRENCY_", 4);
define("_PRICE_PERCENT_", 1);
define("MIN_PAYMENT_AMOUNT", 1000);
define("PRODUCT_DEFAULT_LANG", "ru");
$scheme = json_decode($this->request->getServer("HTTP_CF_VISITOR"), true);
if($scheme["scheme"] !== "https"){
if(DOMAIN_ID == 5)
{
$redirect = "https://butashop.biz" . $_SERVER['REQUEST_URI'];
}
else
{
$redirect= "https://butashop.com".$_SERVER['REQUEST_URI'];
}
header("HTTP/1.1 301 Moved Permanently");
header("Location:$redirect");
exit;
}
if($dispatcher->getControllerName() !== "auth" && !Users::$data){
//header("Location: /auth/login");
//exit;
}
$cat_arr = Cache::get("s_cat_arr_"._LANG_."_".DOMAIN_ID);
$cat_data = Cache::get("s_cat_data_"._LANG_."_".DOMAIN_ID);
$cat_ids = Cache::get("s_cat_ids_"._LANG_."_".DOMAIN_ID);
if(!$cat_arr || !$cat_data){
if((int)DOMAIN_ID == 5){
$binds = ["visible" => 1];
}else{
$binds = [];
}
$cat_query = MongoCategories::find([
$binds,
"sort" => ["index_id" => 1]
]);
$cat_arr = [];
$cat_data = [];
$cat_ids = [];
$lang_keys = [];
IF (count($cat_query) > 0){
foreach($cat_query as $value){
$cat_ids[] = (int)$value->id;
$lang_keys[] = $value->lang_key;
$cat_arr[(int)$value->parent_id][] = (int)$value->id;
$cat_data[(int)$value->id] = [
"id" => (int)$value->id,
"parent_id" => (int)$value->parent_id,
"title" => (@$value->title->{_LANG_}) ? $value->title->{_LANG_}: $value->title->{$value->default_lang},
];
}
Cache::set("s_cat_arr_"._LANG_."_".DOMAIN_ID, $cat_arr, 3600);
Cache::set("s_cat_data_"._LANG_."_".DOMAIN_ID, $cat_data, 3600);
Cache::set("s_cat_ids_"._LANG_."_".DOMAIN_ID, $cat_ids, 3600);
}
}
MongoCategories::$cat_arr = $cat_arr;
MongoCategories::$cat_data = $cat_data;
MongoCategories::$cat_ids = $cat_ids;
Users::$is_bot = $is_bot = (strpos($this->request->getServer("HTTP_USER_AGENT"), "bot") == false) ? false: true;
$keywords = [];
if($is_bot){
if($_SERVER["REMOTE_ADDR"] == "212.90.33.98"){
//exit("ok");
}
if(DOMAIN_ID == 3 && _LANG_ !== 3){
//header("Location: /ru/".substr($this->request->getServer("REQUEST_URI"),4));
//exit;
}
$keyword_count = Cache::get("buta_keyword_count_"._LANG_);
if(!$keyword_count){
$keyword_count = MongoKeywords::count([
["lang" => _LANG_]
]);
Cache::set("buta_keyword_count_"._LANG_, $keyword_count, 2*3600);
}
if($keyword_count > 0){
$keyword_query = MongoKeywords::find([
["lang" => _LANG_],
"limit" => 50,
"skip" => abs(rand(0,$keyword_count) - 50),
"sort" => [
"index_id" => 1
]
]);
$keyword = "";
foreach($keyword_query as $value){
//if(rand(1,10) == 1 && strlen($keyword.$value->keyword) < 90){
// $keyword .= " ".$value->keyword;
//}else{
$keyword = $value->keyword;
//}
$keywords[] = [
"name" => trim($keyword),
"lang" => $value->lang[0],
];
}
}
}
$keyword_domains = [
"az" => "az.butashop.com",
"ua" => "butashop.com.ua",
"ru" => "butashop.ru",
"en" => "butashop.com",
];
if(DOMAIN_ID == 2)
$keyword_domains["ru"] = "butashop.com.ua";
if(DOMAIN_ID == 1 && rand(1,3) == 1){
$keyword_domains = [];
}
if((int)DOMAIN_ID == 5){
Languages::$langs = ["ua", "en", "ru"];
}
$this->view->setVar("is_bot", $is_bot);
$this->view->setVar("cat_arr", $cat_arr);
$this->view->setVar("cat_data", $cat_data);
$this->view->setVar("keywords", $keywords);
$this->view->setVar("keyword_domains", $keyword_domains);
$this->view->setVar("Lang", Languages::$lang_data);
$this->view->setVar("Language", new Languages());
$this->view->setVar("Lib", new Lib());
$this->view->setVar("currencies", Currency::getByList());
$this->view->setVar("colors", MongoColors::getByList());
$this->view->setVar("materials", MongoMaterial::getByList());
$this->view->setVar("product_country", MongoProductCountry::getByList());
$this->view->setVar("product_options", MongoProductOptions::getByList());
$this->view->setVar("countries", MongoCountry::getByList());
$this->view->setVar("for_whats", MongoForWhat::getByList());
$this->view->setVar("brands", MongoBrands::getByList());
$this->view->setVar("genders", [1 => "Male", 2 => "Female", 3 => "Unisex"]);
$this->view->setVar("controller", $dispatcher->getControllerName());
$this->view->setVar("action", $dispatcher->getActionName());
$this->view->setVar("error", $this->error);
}
} |
#2 | Acl->beforeExecuteRoute(Object(Phalcon\Events\Event), Object(Phalcon\Mvc\Dispatcher), null) |
#3 | Phalcon\Events\Manager->fireQueue(Object(SplPriorityQueue), Object(Phalcon\Events\Event)) |
#4 | Phalcon\Events\Manager->fire(dispatch:beforeExecuteRoute, Object(Phalcon\Mvc\Dispatcher)) |
#5 | Phalcon\Dispatcher\AbstractDispatcher->dispatch() |
#6 | Phalcon\Mvc\Application->handle(/ua/%D1%82%D1%80%D0%B5%D0%BD%D0%B4-%D0%BE%D0%B1%D1%83%D0%B2%D1%8C-%D0%B2%D0%B5%D1%81%D0%BD%D0%B0-2014.html)
/home/ebooking/sites/erobooking.com/public/index.php (152) <?php
error_reporting(1);
mb_internal_encoding('utf-8');
ini_set("display_errors", "1");
define("EMAIL_DOMAIN", "http://sualcavab.az/msend.php");
class Application extends \Phalcon\Mvc\Application
{
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
protected function _registerServices()
{
$di = new \Phalcon\DI\FactoryDefault();
$loader = new \Phalcon\Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(
array(
__DIR__ . '/../apps/library/'
)
)->register();
define('DEBUG', true);
if(DEBUG) {
error_reporting(1);
(new Phalcon\Debug)->listen();
}
// DB connection
$di->set('db', function () {
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => "localhost",
"username" => "ebooking",
"password" => "ebooking",
"dbname" => "ebooking",
"options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')
));
});
//Registering a router
$di->set('router', function(){
$router = new \Phalcon\Mvc\Router();
$router->setDefaultModule("frontend");
$router->setDefaultController("index");
$router->setDefaultAction("index");
$router->removeExtraSlashes(true);
$router->add('/:controller/:action/:int', array(
'controller' => 1,
'action' => 2,
'id' => 3,
));
$router->add('/:controller/:action', array(
'controller' => 1,
'action' => 2,
));
$router->add('/:controller', array(
'controller' => 1,
));
$router->add('/{language:[a-z]{2}}/:controller/:action/:int/:int', array(
'controller' => 2,
'action' => 3,
'lang' => 1,
'id' => 4,
'page' => 5,
));
$router->add("/{language:[a-z]{2}}/:params", array(
'controller' => 'index',
'action' => 'index',
'lang' => 1,
'keyword' => 2,
));
$router->add('/{language:[a-z]{2}}/:controller/:action/:int', array(
'controller' => 2,
'action' => 3,
'id' => 4,
'lang' => 1,
));
$router->add('/{language:[a-z]{2}}/:controller/:action', array(
'controller' => 2,
'action' => 3,
'lang' => 1,
));
$router->add("/{language:[a-z]{2}}/:controller", array(
'controller' => 2,
'lang' => 1,
));
$router->add("/{language:[a-z]{2}}/view/:int", array(
'controller' => 'products',
'action' => 'view',
'id' => 2,
'lang' => 1,
));
$router->add("/{language:[a-z]{2}}/view/:int/:params", array(
'controller' => 'products',
'action' => 'view',
'id' => 2,
'lang' => 1,
));
$router->add('/{language:[a-z]{2}}/news/:int/:params', array(
'controller' => "news",
'action' => "view",
'lang' => 1,
'id' => 2,
'slug' => 3,
));
$router->add("/{language:[a-z]{2}}", array(
'lang' => 1,
));
return $router;
});
$this->setDI($di);
}
public function main()
{
$this->_registerServices();
//Register the installed modules
$this->registerModules(array(
'frontend' => array(
'className' => 'Multiple\Frontend\Module',
'path' => '../apps/frontend/Module.php'
)
));
$request = new Phalcon\Http\Request();
echo $this->handle($request->getURI())->getContent();
}
}
$application = new Application();
$application->main();
|
#7 | Application->main()
/home/ebooking/sites/erobooking.com/public/index.php (158) <?php
error_reporting(1);
mb_internal_encoding('utf-8');
ini_set("display_errors", "1");
define("EMAIL_DOMAIN", "http://sualcavab.az/msend.php");
class Application extends \Phalcon\Mvc\Application
{
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
protected function _registerServices()
{
$di = new \Phalcon\DI\FactoryDefault();
$loader = new \Phalcon\Loader();
/**
* We're a registering a set of directories taken from the configuration file
*/
$loader->registerDirs(
array(
__DIR__ . '/../apps/library/'
)
)->register();
define('DEBUG', true);
if(DEBUG) {
error_reporting(1);
(new Phalcon\Debug)->listen();
}
// DB connection
$di->set('db', function () {
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => "localhost",
"username" => "ebooking",
"password" => "ebooking",
"dbname" => "ebooking",
"options" => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')
));
});
//Registering a router
$di->set('router', function(){
$router = new \Phalcon\Mvc\Router();
$router->setDefaultModule("frontend");
$router->setDefaultController("index");
$router->setDefaultAction("index");
$router->removeExtraSlashes(true);
$router->add('/:controller/:action/:int', array(
'controller' => 1,
'action' => 2,
'id' => 3,
));
$router->add('/:controller/:action', array(
'controller' => 1,
'action' => 2,
));
$router->add('/:controller', array(
'controller' => 1,
));
$router->add('/{language:[a-z]{2}}/:controller/:action/:int/:int', array(
'controller' => 2,
'action' => 3,
'lang' => 1,
'id' => 4,
'page' => 5,
));
$router->add("/{language:[a-z]{2}}/:params", array(
'controller' => 'index',
'action' => 'index',
'lang' => 1,
'keyword' => 2,
));
$router->add('/{language:[a-z]{2}}/:controller/:action/:int', array(
'controller' => 2,
'action' => 3,
'id' => 4,
'lang' => 1,
));
$router->add('/{language:[a-z]{2}}/:controller/:action', array(
'controller' => 2,
'action' => 3,
'lang' => 1,
));
$router->add("/{language:[a-z]{2}}/:controller", array(
'controller' => 2,
'lang' => 1,
));
$router->add("/{language:[a-z]{2}}/view/:int", array(
'controller' => 'products',
'action' => 'view',
'id' => 2,
'lang' => 1,
));
$router->add("/{language:[a-z]{2}}/view/:int/:params", array(
'controller' => 'products',
'action' => 'view',
'id' => 2,
'lang' => 1,
));
$router->add('/{language:[a-z]{2}}/news/:int/:params', array(
'controller' => "news",
'action' => "view",
'lang' => 1,
'id' => 2,
'slug' => 3,
));
$router->add("/{language:[a-z]{2}}", array(
'lang' => 1,
));
return $router;
});
$this->setDI($di);
}
public function main()
{
$this->_registerServices();
//Register the installed modules
$this->registerModules(array(
'frontend' => array(
'className' => 'Multiple\Frontend\Module',
'path' => '../apps/frontend/Module.php'
)
));
$request = new Phalcon\Http\Request();
echo $this->handle($request->getURI())->getContent();
}
}
$application = new Application();
$application->main();
|