/** * @mcms_message ru.molinos.cms.hook.node */ public static function on_node_change(Context $ctx, $node, $op) { try { list($sql, $params) = sql::getInsert('node__log', array('nid' => $node->id, 'uid' => $ctx->user->id, 'username' => $ctx->user->getNode()->getName(), 'operation' => $op, 'ip' => $_SERVER['REMOTE_ADDR'], 'timestamp' => mcms::now(), 'name' => $node->name)); $ctx->db->exec($sql, $params); } catch (TableNotFoundException $e) { } }
/** * @mcms_message ru.molinos.cms.log.access */ public static function on_log(Context $ctx, Node $node) { try { $ctx->db->beginTransaction(); $ctx->db->exec("INSERT INTO `node__astat` (`nid`, `timestamp`) VALUES (?, ?)", array($node->id, mcms::now())); $ctx->db->commit(); } catch (TableNotFoundException $e) { } }
/** * Вызов api/ads/get.xml * * Возвращает случайные баннеры. * * @route GET//api/ads/get.xml */ public static function on_get_banners(Context $ctx) { $limit = intval($ctx->get('limit', 1)); $sql = "SELECT `node`.`id`, `xml` FROM `node` " . "INNER JOIN `node__banners` ON `node__banners`.`id` = `node`.`id` " . "WHERE `class` = 'banner' AND `deleted` = 0 AND `published` = 1 " . "AND (`time_limit` IS NULL OR `time_limit` < ?) " . "AND (`display_limit` IS NULL OR `display_count` IS NULL OR `display_count` < `display_limit`) " . "ORDER BY RAND() LIMIT " . $limit; $data = $ctx->db->getResultsKV("id", "xml", $sql, array(mcms::now())); $params = array(); $ctx->db->beginTransaction(); $ctx->db->exec("UPDATE `node__banners` SET `display_count` = 0 WHERE `display_count` IS NULL"); $ctx->db->exec("UPDATE `node__banners` SET `display_count` = `display_count` + 1 WHERE `id` " . sql::in(array_keys($data), $params), $params); $ctx->db->commit(); return new Response(html::em('nodes', implode('', $data)), 'text/xml'); }
/** * Добавление файлов с FTP (форма). */ public static function on_get_ftp_form(Context $ctx) { if (!($files = self::getFtpFiles($ctx))) { throw new PageNotFoundException(); } $options = array('name' => 'addfile', 'title' => t('Добавление <a href="@url">файлов</a>, загруженных по FTP', array('@url' => 'admin/content/files')), 'mode' => 'ftp', 'target' => 'admin/create/file/ftp?destination=' . urlencode($ctx->get('destination')), 'back' => $ctx->get('destination')); $content = ''; foreach ($files as $file) { $content .= html::em('file', array('name' => basename($file), 'size' => filesize($file), 'sizeh' => mcms::filesize(filesize($file)), 'time' => mcms::now(filemtime($file)))); } $content .= self::get_modes($ctx, 'ftp'); return html::em('content', $options, $content); }