#0 | PDO->__construct(mysql:host=localhost;dbname=idporg_katalog;charset=utf8, idporg_katalog, 963258741, Array([3] => 2)) |
#1 | Phalcon\Db\Adapter\Pdo->connect(Array([host] => localhost, [username] => idporg_katalog, [password] => 963258741, [dbname] => idporg_katalog, [charset] => utf8)) |
#2 | Phalcon\Db\Adapter\Pdo->__construct(Array([host] => localhost, [username] => idporg_katalog, [password] => 963258741, [dbname] => idporg_katalog, [charset] => utf8))
/home/idporg/katalog.idp.org.tr/app/config/services.php (112) <?php
use Phalcon\DI\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Crypt;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Phalcon\Mvc\Model\Metadata\Files as MetaDataAdapter;
use Phalcon\Session\Adapter\Files as SessionAdapter;
use Phalcon\Flash\Direct as FlashDirect;
use Phalcon\Flash\Session as FlashSession;
use Phalcon\Logger\Adapter\File as FileLogger;
use Phalcon\Logger\Formatter\Line as FormatterLine;
use Phalcon\Breadcrumbs;
use Phalcon\Http\Response;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Cache\Frontend\Data as FrontendData;
use Phalcon\Cache\Backend\File as FileCache;
use Idp\Auth\Auth;
use Idp\Acl\Acl;
use Idp\Mail\Mail;
/**
* The FactoryDefault Dependency Injector automatically register the right services providing a full stack framework
*/
$di = new FactoryDefault();
/**
* Register the global configuration as config
*/
$di->setShared('config', $config);
/**
* The URL component is used to generate all kind of urls in the application
*/
$di->setShared('url', function () use ($config)
{
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Setting up the view component
*/
$di->setShared('view', function () use ($config)
{
$view = new View();
$view->setViewsDir($config->paths->views);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->paths->cache . 'volt/',
'compiledSeparator' => '_',
'compileAlways' => true
));
$compiler = $volt->getCompiler();
/**
* New translate volt function
*
* Sample Usage:
* _t(key, placeholders, default)
*
*/
$compiler->addFunction('_t', function ($resolvedArgs, $exprArgs){
return '_t(' . $resolvedArgs . ')';
});
$compiler->addFunction('urlTo', function ($resolvedArgs, $exprArgs){
return 'urlTo(' . $resolvedArgs . ')';
});
$compiler->addFunction('in_array', 'in_array');
/**
* Custom Functions
*
* Sample Usage:
* _func(key, params)
*
*/
$compiler->addFunction('_func', function ($resolvedArgs, $exprArgs){
return 'call_user_func(' . $resolvedArgs . ')';
});
return $volt;
}
));
return $view;
});
/**
* Database connection is created based in the parameters defined in the configuration file
*/
$di->setShared('db', function () use ($config)
{
return new DbAdapter(array(
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->dbname,
'charset' => $config->database->charset
));
});
/**
* If the configuration specify the use of metadata adapter use it or use memory otherwise
*/
$di->setShared('modelsMetadata', function () use ($config)
{
return new MetaDataAdapter(array(
'metaDataDir' => $config->paths->cache . 'models/'
));
});
/**
* Start the session the first time some component request the session service
*/
$di->setShared('session', function () {
$session = new SessionAdapter();
$session->start();
return $session;
});
/**
* Crypt service
*/
$di->setShared('crypt', function () use ($config)
{
$crypt = new Crypt();
$crypt->setKey($config->application->cryptSalt);
return $crypt;
});
/**
* Dispatcher use a default namespace
*/
$di->setShared('dispatcher', function ()
{
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('Idp\Controllers');
return $dispatcher;
});
/**
* Loading routes from the routes.php file
*/
$di->setShared('router', function () use ($config)
{
return require __DIR__ . '/routes.php';
});
/**
* Flash service with custom CSS classes
*/
$di->setShared('flash', function ()
{
$flashDirect = new FlashDirect(array(
'error' => 'notification error closeable',
'success' => 'notification success closeable',
'notice' => 'notification notice closeable',
'warning' => 'notification warning closeable'
));
$flashDirect->setAutoescape(false);
return $flashDirect;
});
/**
* Flash service with session
*/
$di->setShared('flashdata', function ()
{
$flashdata = new FlashSession(array(
'error' => 'notification error closeable',
'success' => 'notification success closeable',
'notice' => 'notification notice closeable',
'warning' => 'notification warning closeable'
));
$flashdata->setAutoescape(false);
return $flashdata;
});
/**
* Custom authentication component
*/
$di->setShared('auth', function ()
{
return new Auth();
});
/**
* Mail service
*/
$di->setShared('mail', function ()
{
return new Mail();
});
/**
* Logger service
*/
$di->setShared('logger', function($message = null) use ($config)
{
$format = $config->get('logger')->format;
$filename = date('Y-m-d') . '.log';
$path = rtrim($config->get('logger')->path, '\\/') . DS;
$formatter = new FormatterLine($format, $config->get('logger')->date);
$logger = new FileLogger($path . $filename);
$logger->setFormatter($formatter);
$logger->setLogLevel($config->get('logger')->logLevel);
return $logger;
});
// Initialize the Breadcrumbs component.
$di->setShared('breadcrumbs', function ()
{
$breadcrumbs = new Breadcrumbs();
$breadcrumbs
->setSeparator('')
->setTemplate(
'<li><a href="{{link}}">{{icon}}{{label}}</a></li>', // linked
'<li class="active">{{icon}}{{label}}</li>', // not linked
'<i class="icon-home2 position-left"></i>' // first icon
);
return $breadcrumbs;
});
/**
* Response
*/
$di->setShared('response', function ()
{
return new Response();
});
/**
* EventsManager
*/
$di->setShared('events', function ()
{
return require __DIR__ . '/events.php';
});
/**
* Translate
*/
$di->setShared('trans', function() use($di, $config)
{
$session = $di->getShared('session');
$request = $di->getShared('request');
$dispatcher = $di->getShared('dispatcher');
// Get entered language.
if($language = $dispatcher->getParam('lang'))
{
if(array_key_exists($language, $config->languages))
{
$session->set("lang", $language);
}
else
{
$session->set("lang", $config->application->language);
}
}
else
{
// Get language code
if($session->has("lang"))
{
$language = $session->get("lang");
}
else
{
// Ask browser what is the best language
$language = $config->application->language;
$session->set("lang", $language);
}
}
// Check if we have a translation file for that language
if(file_exists(APP_PATH . DS. "messages/{$language}.php"))
{
$t = require APP_PATH . DS. "messages/{$language}.php";
}
else
{
// Fallback to default language
$t = require APP_PATH . DS . "messages/{$config->application->language}.php";
}
unset($language);
// Return a translation object
return new \Phalcon\Translate\Adapter\NativeArray(array(
"content" => $t
));
});
/**
* Models Cache
*/
$di->setShared(
"modelsCache",
function () use ($config)
{
// Cache data for one day by default
$frontCache = new FrontendData(
[
"lifetime" => 86400,
]
);
$cache = new FileCache(
$frontCache,
[
"cacheDir" => $config->paths->cache . 'queries/',
]
);
return $cache;
}
); |
#3 | Closure->{closure}() |
#4 | Phalcon\Di\Service->resolve(null, Object(Phalcon\Di\FactoryDefault)) |
#5 | Phalcon\Di->get(db, null) |
#6 | Phalcon\Di->getShared(db) |
#7 | Phalcon\Mvc\Model\Manager->_getConnection(Object(Idp\Models\Pages: 11), null) |
#8 | Phalcon\Mvc\Model\Manager->getReadConnection(Object(Idp\Models\Pages: 11)) |
#9 | Phalcon\Mvc\Model->getReadConnection() |
#10 | Phalcon\Mvc\Model\Query->getReadConnection(Object(Idp\Models\Pages: 11), Array([models] => Array([0] => Idp\Models\Pages), [tables] => Array([0] => pages), [columns] => Array([idp\Models\Pages] => Array([type] => object, [model] => Idp\Models\Pages, [column] => pages, [balias] => idp\Models\Pages)), [where] => Array([type] => binary-op, [op] => AND, [left] => Array([type] => parentheses, [left] => Array()), [right] => Array([type] => parentheses, [left] => Array())), [order] => Array([0] => Array([0] => Array(), [1] => ASC))), Array([status] => 1), null) |
#11 | Phalcon\Mvc\Model\Query->_executeSelect(Array([models] => Array([0] => Idp\Models\Pages), [tables] => Array([0] => pages), [columns] => Array([idp\Models\Pages] => Array([type] => object, [model] => Idp\Models\Pages, [column] => pages, [balias] => idp\Models\Pages)), [where] => Array([type] => binary-op, [op] => AND, [left] => Array([type] => parentheses, [left] => Array()), [right] => Array([type] => parentheses, [left] => Array())), [order] => Array([0] => Array([0] => Array(), [1] => ASC))), Array([status] => 1), null) |
#12 | Phalcon\Mvc\Model\Query->execute() |
#13 | Phalcon\Mvc\Model::find(Array([di] => Object(Phalcon\Di\FactoryDefault), [conditions] => (status = :status:) AND (parent_id IS NULL), [bind] => Array([status] => 1), [order] => Idp\Models\Pages.sort ASC)) |
#14 | Phalcon\Mvc\Model\Criteria->execute()
/home/idporg/katalog.idp.org.tr/app/models/Pages.php (59) <?php
namespace Idp\Models;
class Pages extends BaseModel
{
public $id;
public $parent_id;
public $title;
public $alias;
public $content;
public $is_link;
public $sort;
public $views;
public $status;
public $created;
public $updated;
public function initialize()
{
$this->belongsTo('parent_id', __NAMESPACE__ . '\Pages', 'id', array(
'alias' => 'parent',
'reusable' => true
));
$this->hasMany('id', __NAMESPACE__ . '\Pages', 'parent_id', array(
'alias' => 'children',
'reusable' => true,
'params' => array(
'order' => 'sort ASC',
"status = 1"
)
));
}
public function afterFetch()
{
// Get Services
$config = \Phalcon\Di::getDefault()->getConfig();
$url = \Phalcon\Di::getDefault()->getUrl();
// URL
$this->url = $url->get("{$this->alias}");
$this->url_edit = $url->get("panel/sayfa/{$this->id}");
$this->created_time = strtotime($this->created);
$this->updated_time = !empty($this->updated) ? strtotime($this->updated) : NULL;
}
public static function getActivePages()
{
$tbl = __NAMESPACE__ . '\Pages';
return self::query()
->where('status = :status:')
->andWhere('parent_id IS NULL')
->bind(['status' => true])
// ->columns(["{$tbl}.id", "{$tbl}.icon", "sk.name", "sk.slug", "sk.description"])
->orderBy("{$tbl}.sort ASC")
->execute();
}
}
|
#15 | Idp\Models\Pages::getActivePages()
/home/idporg/katalog.idp.org.tr/app/controllers/ControllerBase.php (25) <?php
namespace Idp\Controllers;
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Idp\Models\Pages;
use Idp\Models\UsersActivitiesLogs;
class ControllerBase extends Controller
{
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
$identity = $this->auth->getIdentity();
if($this->auth->isLogged())
{
$logged_user = $this->auth->getUser();
$this->checkUserActivity($logged_user);
}
$this->view->setVar('is_homepage', false);
$this->view->setVar('is_panel', false);
$this->view->setVar('identity', $identity);
$this->view->setVar('menu_items', Pages::getActivePages());
$this->view
->setViewsDir($this->config->paths->views)
->setLayoutsDir($this->config->paths->views . DS . $this->config->paths->layouts)
->setPartialsDir($this->config->paths->partials)
->setTemplateBefore('public');
}
private function checkUserActivity($user)
{
// Get session refresh time
$session_refresh = $this->config->application->session_refresh;
// Get the activity
$activity = UsersActivitiesLogs::findFirst(
[
"conditions" => "user_id = :user_id: AND end_time >= :end_time:",
"bind" => ['user_id' => $user->id, 'end_time' => time() - $session_refresh]
]
);
if($activity)
{
$activity->update(['end_time' => time() + 10]);
}
else
{
$activity = new UsersActivitiesLogs();
$activity->create(['user_id' => $user->id, 'start_time' => time(), 'end_time' => time() + 10]);
}
}
}
|
#16 | Idp\Controllers\ControllerBase->beforeExecuteRoute(Object(Phalcon\Mvc\Dispatcher)) |
#17 | Phalcon\Dispatcher->dispatch() |
#18 | Phalcon\Mvc\Application->handle()
/home/idporg/katalog.idp.org.tr/public/index.php (62) <?php
/**
* Set Locate
*/
setlocale(LC_COLLATE, 'turkish', 'tr_TR.UTF-8', 'tr_TR', 'tr');
setlocale(LC_MONETARY, 'turkish', 'tr_TR.UTF-8', 'tr_TR', 'tr');
setlocale(LC_NUMERIC, 'turkish', 'tr_TR.UTF-8', 'tr_TR', 'tr');
setlocale(LC_TIME, 'turkish', 'tr_TR.UTF-8', 'tr_TR', 'tr');
setlocale(LC_CTYPE,'en_US.utf8');
// setlocale(LC_MESSAGES,'tr_TR.utf8');
/**
* Set Time Zone
*/
date_default_timezone_set('Europe/Istanbul');
/**
* Define some useful constants
*/
define('DOT', '.');
define('DS', DIRECTORY_SEPARATOR);
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . DS. 'app');
define('PUBLIC_PATH', BASE_PATH . DS . 'public');
/**
* Read the constants
*/
$config = include APP_PATH . '/config/constants.php';
/**
* Read the configuration
*/
$config = include APP_PATH . '/config/config.php';
/**
* Read auto-loader
*/
include APP_PATH . '/config/loader.php';
/**
* Read services
*/
include APP_PATH . '/config/services.php';
// Debug Application
if($config->application->debug)
{
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
(new Phalcon\Debug)->listen();
/**
* Handle the request
*/
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
}
else
{
try
{
/**
* Handle the request
*/
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
}
catch(Exception $e)
{
$di->getLogger()->error($e->getMessage());
echo $e->getMessage(), '<br>';
echo nl2br(htmlentities($e->getTraceAsString()));
exit;
}
} |