Пример #1
0
 function __construct($params)
 {
     $file = 'console-' . date(@$params['log'] ?: 'Y-m-d') . '.log';
     $this->_file = \loader::get_temp($file);
     $this->_uid = substr(\functions::hash(microtime(true)), -5);
     $this->_head();
 }
Пример #2
0
 /**
  * Gets some hash
  */
 private function _hash($what)
 {
     return functions::hash($what);
 }
Пример #3
0
 /**
  * Make session key
  */
 function make_key()
 {
     $key = $this->salt;
     if ($this->with_browser) {
         $key .= isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
     }
     if ($this->ip_octets && isset($_SERVER['REMOTE_ADDR'])) {
         $num_blocks = $this->ip_octets > 4 ? $this->ip_octets : 4;
         $blocks = explode('.', $_SERVER['REMOTE_ADDR']);
         for ($i = 0; $i < $num_blocks; $i++) {
             $key .= $blocks[$i] . '.';
         }
     }
     return functions::hash($key);
 }
Пример #4
0
$nodes = $sat->get_news_handle();
$sid = $nodes->make_attach_sid();
$id = $nodes->create(['title' => 'Hello', 'attach_sid' => $sid]);
$node = $nodes->get_last_item();
// attach
/** @var SatCMS\Modules\Sat\Classes\Behaviors\ImageAttachs $imagesBehavior */
$imagesBehavior = $node->behavior('Sat.ImageAttachs');
$imageAttachs = $imagesBehavior->get_attachs();
$imageAttachs->create(['pid' => $id, 'title' => $node->id . '|' . functions::hash(microtime(1)), 'ctype_id' => $node->get_ctype_id()]);
class testBehavior extends model_behavior
{
    function remove_after()
    {
        test_assert(!$this->model->behavior('Sat.ImageAttachs')->get_attachs()->count());
    }
}
$node->add_behavior('test.behavior', new testBehavior());
/** @var SatCMS\Modules\Sat\Classes\Behaviors\Commentable $commentsBehavior */
$commentsBehavior = $node->behavior('Sat.Commentable');
$commentAttachs = $commentsBehavior->get_attachs();
for ($i = 0; $i <= 5; $i++) {
    $commentAttachs->create(['pid' => $id, 'comment' => $node->id . '|' . functions::hash(microtime(1)), 'ctype_id' => $node->get_ctype_id()]);
}
$node->remove();
$node = $nodes->load_only_id($id);
test_assert($imagesBehavior->get_attachs()->count() == 0);
$node = $nodes->get_last_item();
test_assert(!$node);
$node = $nodes->alloc();
$node->title = 'Привет Мир';
$node->save();