function path() { $sep = ' <span>→</span> '; $first = params::get('first'); $last = params::get('last'); $i = 0; foreach (web::$pages as $v) { if ($first == 'no' && $v['page_folder'] == '/') { continue; } if ($last == 'no' && $v['page_id'] == PAGE_ID) { continue; } if ($v['page_folder'] == '/users/[dynamic]/') { $v['page_folder'] = '/users/' . router::get(1) . '/'; $v['page_title'] = router::get(1); } if ($v['page_id'] == PAGE_ID) { $path_item = web::get('page_title'); } else { $path_item = '<a href="' . $v['page_folder'] . '">' . $v['page_title'] . '</a>'; } s::roll('page_path', array('path_item' => $path_item)); if ($v['page_id'] != PAGE_ID) { s::roll('page_path', array('path_item' => $sep)); } } }
function edit() { events::observe('save', 'templates', 'apps', '_save'); events::observer(); $tmpl_file = events::get('tmpl_file'); $app = events::get('app'); if (events::detect('restore')) { self::restoreVersion($app, $tmpl_file, events::get('restore')); } admin::components('tabs', 'validator'); f::set('app', $app); f::set('tmpl_file', $tmpl_file); s::set('app', $app); s::set('tmpl_file', $tmpl_file); $file = SYS_ROOT . 'tmpls/' . ADMIN_SITE . '/' . $app . '/' . $tmpl_file; $code = files::get($file); f::set('tmpl_code', $code); self::getApps(); /* Load versions */ db::table('templates_versions'); db::where('app', $app); db::where('tmpl_file', $tmpl_file); db::order('version_date', 'DESC'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { $row['version_date'] = dt::date2print('%H:%i %d.%m.%Y', $row['version_date']); $row['version_code'] = '{non}' . htmlspecialchars($row['version_code']) . '{/non}'; s::roll('versions', $row); } }
function view() { $tmp = $modules = array(); $file = SYS_ROOT . 'conf/global/modules.ini'; $tmp = ini::parse($file); foreach ($tmp as $k => $v) { $arr = explode('.', $k); $modules[$arr[0]][] = array('module_name' => $arr[1], 'module_title' => $v['title'], 'module_version' => $v['ver']); } $tmp = $apps = array(); $file = SYS_ROOT . 'conf/global/apps.ini'; $tmp = ini::parse($file); foreach ($tmp as $k => $v) { $v['app'] = $k; if ($v['in'] == '1') { s::roll('appsin', $v); if (isset($modules[$k])) { s::rollArray('appsin' . $k, $modules[$k]); } } else { s::roll('apps', $v); if (isset($modules[$k])) { s::rollArray('apps' . $k, $modules[$k]); } } } }
function setup() { db::table('pages_content'); db::where('page_id', PAGE_ID); db::where('content_pub', '1'); db::order('content_id'); $res = db::select('content'); $i = 0; if ($res) { while ($row = mysql_fetch_assoc($res)) { $i++; s::set('page_content' . $i, $row['content']); } } db::table('pages_files'); db::where('page_id', PAGE_ID); $r = db::select(); if (db::rows() != 0) { s::section('page_files_show'); } while ($a = mysql_fetch_assoc($r)) { $a['file_icon'] = files::getFileIco($a['file_type']); $a['file_size'] = files::parseSizeSmart($a['file_size']); s::roll('page_files', $a); } }
function get($res, $name = 'clouds') { $nums_clouds = array(); if (db::rows() > 0) { while ($row = mysql_fetch_array($res)) { $nums_clouds[$row['tag_name']] = $row['num']; } ksort($nums_clouds); $max_size = 200; // max font size in % $min_size = 100; // min font size in % $max_qty = max(array_values($nums_clouds)); $min_qty = min(array_values($nums_clouds)); $spread = $max_qty - $min_qty; if (0 == $spread) { $spread = 1; } $step = ($max_size - $min_size) / $spread; foreach ($nums_clouds as $k => $v) { $size = $min_size + ($v - $min_qty) * $step; s::roll($name, array('name' => $k, 'size' => $size, 'value' => $v)); } } }
function rollApps() { $tmp = $apps = array(); $file = SYS_ROOT . 'conf/global/apps.ini'; $tmp = ini::parse($file); foreach ($tmp as $k => $v) { $v['app'] = $k; s::roll('apps', $v); } }
function getMenus($site_id) { db::table('menus'); db::where('site_id', $site_id); db::where('menu_pub', '1'); db::order('menu_title'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { s::roll('menus', $row); } }
function getBlocks($site_id = 1) { db::table('blocks'); db::where('site_id', $site_id); db::where('block_pub', '1'); db::order('block_name'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { s::roll('blocks', $row); } }
function view() { db::table('news'); db::order('news_date', 'DESC'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { $row = filter::get('news_pub', array('unpub', 'pub'), $row); $row['news_title'] = strip_tags($row['news_title']); $row['news_date'] = dt::date2print('%d %F %Y, %H:%i', $row['news_date']); s::roll('news', $row); } }
function view() { db::table('admin_log_actions'); db::join('admin_users', 'admin_log_actions', 'user_id'); db::order('log_date', 'DESC'); db::limit(30); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { $row['log_date'] = dt::format('%d.%m.%Y %H:%M', $row['log_date']); s::roll('logs_list', $row); } }
function show() { $event = web::getEvent(); if ($event === false) { $year = date('Y'); } else { $year = $event; } s::set('info_date_select', htmlspecialchars($year)); $sql = "SELECT `section_year` as date FROM `info_sections` WHERE `section_view`='0' GROUP BY `date` ORDER BY `date` DESC"; $res = db::query($sql); $rows = mysql_num_rows($res); if ($rows > 1) { s::add('info_date_selector', '<ul class="years">'); while ($row = mysql_fetch_assoc($res)) { if ($row['date'] == $year) { $row['date'] = '<li><span>' . $row['date'] . '</span></li>'; } else { $row['date'] = '<li><a href="' . web::get('page_folder') . '' . $row['date'] . '/">' . $row['date'] . '</a></li>'; } s::add('info_date_selector', $row['date']); } s::add('info_date_selector', '</ul>'); } $files = array(); db::table('info_files'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $files[$a['section_id']][] = $a; } db::table('info_sections'); db::order('section_order', 'DESC'); db::where('section_year', $year); $r = db::select(); if (db::rows() == 0) { web::error404(); } while ($a = mysql_fetch_assoc($r)) { if ($a['section_view'] == '0') { s::roll('sections', $a); } else { s::roll('sections_view', $a); } if (isset($files[$a['section_id']])) { foreach ($files[$a['section_id']] as $v) { $v['file_icon'] = files::getFileIco($v['file_type']); $v['file_size'] = files::parseSizeSmart($v['file_size']); s::roll('items' . $a['section_id'], $v); } } } }
function view() { events::observe('upload', 'index'); events::observer(); $dir = IMAGES_PATH . 'index/'; db::table('images'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $a = filter::get('img_set', array('unpub', 'pub'), $a); $a['thumb'] = $dir . $a['img_id'] . '_m.jpg'; s::roll('images', $a); } }
function view() { db::table('mails'); $res = db::select(); if (db::rows() == 0) { s::section('no_data'); } else { s::section('yes_data'); } while ($row = mysql_fetch_assoc($res)) { s::roll('mails', $row); } }
function getTmpls($site_id = 1) { db::table('templates'); db::where('site_id', $site_id); db::where('tmpl_pub', '1'); db::order('tmpl_name'); $res = db::select(); if (db::rows() == 0) { s::section('no_data'); } else { s::section('yes_data'); } while ($row = mysql_fetch_assoc($res)) { s::roll('tmpls', $row); } }
function show() { $list = params::get('list'); $event = web::getEvent(); if ($event === false) { $year = date('Y'); } else { $year = $event; } s::set('news_date_select', htmlspecialchars($year)); $sql = "SELECT DATE_FORMAT(`news_date`, '%Y') as date FROM `news` GROUP BY `date` ORDER BY `date` DESC"; $res = db::query($sql); $rows = mysql_num_rows($res); if ($rows > 1) { s::add('news_date_selector', '<ul class="years">'); while ($row = mysql_fetch_assoc($res)) { if ($row['date'] == $year) { $row['date'] = '<li><span>' . $row['date'] . '</span></li>'; } else { $row['date'] = '<li><a href="' . web::get('page_folder') . '' . $row['date'] . '/">' . $row['date'] . '</a></li>'; } s::add('news_date_selector', $row['date']); } s::add('news_date_selector', '</ul>'); } db::table('news'); db::where('news_pub', '1'); db::where('news_date', $year . '-01-01 00:00:00', '>='); db::where('news_date', $year . '-12-31 23:59:59', '<='); db::order('news_date', 'DESC'); if ($list !== false) { db::limit($list); } $res = db::select(); if (db::rows() == 0) { web::error404(); } while ($row = mysql_fetch_assoc($res)) { $row['news_date'] = dt::date2print('%d %F %Y', $row['news_date']); s::roll('news', $row); } }
function view() { events::observe('clear_pages_versions', 'system', 'base', 'clear_pages_versions'); events::observe('clear_templates_versions', 'system', 'base', 'clear_templates_versions'); events::observe('delete_dump', 'system', 'base', 'delete_dump'); events::observe('restore', 'system', 'base', 'restore'); events::observe('reserve', 'system', 'base', 'reserve'); events::observe('optimize', 'system', 'base', 'optimize'); events::observe('repair', 'system', 'base', 'repair'); events::observer(); $sql = "SHOW TABLE STATUS"; $res = db::query($sql); $data_length = 0; while ($row = mysql_fetch_array($res)) { $vol = $row['Data_length'] + $row['Index_length']; $data_length += $vol; } if ($data_length > 1000000) { s::set('base_volume', round($data_length / 1000000, 2) . ' MB'); } else { s::set('base_volume', round($data_length / 1024, 2) . ' KB'); } if ($data_length > 1000000) { s::set('base_damp_need', round($data_length / 1000000 / 4.6) . ' MB'); } else { s::set('base_damp_need', round($data_length / 1024 / 4.6) . ' KB'); } $files = files::listDir(SYS_ROOT . 'var/backup/'); if (count($files)) { foreach ($files as $v) { s::roll('restore_files', array('value' => $v, 'file' => $v)); } } else { s::roll('restore_files', array('value' => 0, 'file' => 'нет файла'), 0); } }
function view() { db::table('admin_log_trash'); db::limit(30); db::order('log_date', 'DESC'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { if ($row['log_restored'] != '0000-00-00 00:00:00') { $row['log_restored'] = dt::date2print('%H:%i:%s<br />%d %F %y', $row['log_restored']); } else { $row['log_restored'] = ''; } $row['log_date'] = dt::date2print('%H:%i:%s<br />%d %F %y', $row['log_date']); $tables = ''; $array = explode(",", $row['log_tables']); foreach ($array as $v) { if (!empty($v)) { $tables .= T_ . $v . '<br />'; } } $row['log_tables'] = $tables; s::roll('basket', $row); } }
function handlers() { $ini = conf::parse('pages'); foreach ($ini as $k => $v) { $methods = $v['methods']; if (empty($methods[0])) { continue; } foreach ($methods as $f) { s::roll('page_handlers' . $k, array('handler' => $f)); } $page = appPages::getPage($k); s::roll('handlers', array('page_title' => $page['page_title'], 'page_id' => $k, 'page_folder' => appPages::getUrl($page['page_folder']))); } }
function loadGroupSetups() { $array = ini::parse(SYS_ROOT . 'conf/global/apps.ini'); $check = array(); foreach ($array as $k => $v) { if ($v) { $check['apps'][$k] = 1; s::roll('apps', array('app' => $k, 'app_title' => $v['title'])); } } $rules = ini::parse(SYS_ROOT . 'conf/admin/rules.ini'); foreach ($rules as $k => $v) { s::roll('rules', array('rule' => $k, 'rule_name' => $v)); } db::table('admin_sites'); db::order('site_domain'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { $check['sites'][$row['site_id']] = 1; s::roll('sites', $row); } return $check; }
function showMethods($tmpl_id = false) { if (!$tmpl_id) { $tmpl_id = params::get('tmpl_id'); } conf::parse('tmpls', $tmpl_id); $array = conf::get('tmpls', 'methods'); if (!$array) { buffer::setTmpl(); } foreach ($array as $v) { $arr = explode('::', $v); if (!isset($arr[1])) { buffer::setTmpl(); return false; } s::roll('methods', array('app' => $arr[0], 'module' => $arr[1], 'action' => $arr[2])); } }
function sections() { db::table('info_sections'); db::order('section_order', 'DESC'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { if ($a['section_view'] == '1') { $a['section_view'] = 'виден всегда'; } else { $a['section_view'] = ''; } s::roll('sections', $a); } }
function showSection() { $section_id = web::getThis(); $item_id = web::getEvent(); if ($item_id !== false) { buffer::setTmpl('card.html'); self::showCard($item_id, $section_id); return false; } $dir = IMAGES_ROOT . 'sections/'; $dir_path = IMAGES_PATH . 'sections/'; db::table('catalog_sections'); db::where('section_id', $section_id); $section = db::assoc(); if (db::rows() == 0) { web::error404(); } s::set($section); s::set('page_title', $section['section_name']); s::set('page_header', $section['section_name']); $file = $dir . $section['section_id'] . '.jpg'; if (file_exists($file)) { s::set('section_img', '<img src="' . $dir_path . $section['section_id'] . '.jpg' . '" />'); } db::table('catalog_items'); db::where('section_id', $section_id); $r = db::select('item_name', 'item_id', 'item_desc'); $i = 0; while ($a = mysql_fetch_assoc($r)) { $i++; if ($i % 2) { s::roll('items1', $a); } else { s::roll('items2', $a); } } }
function range($name, $start, $end) { for ($i = $start; $i < $end; $i++) { s::roll($name, array('value' => $i, 'name' => $i)); } }
function edit() { events::observe('save', 'pages', 'savePage'); events::observer(); if (events::detect('save')) { return true; } if (events::detect('restore')) { self::restoreVersion(events::get('restore')); } admin::components('tabs', 'validator', 'upload'); if (settings::get('pages', 'redactor')) { admin::components('redactor'); s::section('redactor'); } $page_id = admin::get('id'); appPages::getPagesSelect(ADMIN_SITE_ID, $page_id); appPages::getParentPages(ADMIN_SITE_ID, true); appTemplates::getTmpls(ADMIN_SITE_ID); db::table('pages'); db::where('page_id', $page_id); $row = db::assoc(); s::set('page_link', '<a href="' . self::getUrl($row['page_folder']) . '">Посмотреть страницу на сайте</a>'); if ($row['page_dynamic'] == '1') { $row['page_folder'] = ''; } else { if ($row['page_folder'] != '/') { $row['page_folder'] = string::clearBoth($row['page_folder']); $arr = explode('/', $row['page_folder']); $row['page_folder'] = arrays::lastValue($arr); } } f::set('page_content', $row['page_content'], 0); f::set($row); s::set('page_id', $page_id); db::table('pages_files'); db::where('page_id', $page_id); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $a['file_type'] = files::getFileIco($a['file_type']); s::roll('page_files', $a); } /* Load versions */ db::table('pages_versions'); db::where('page_id', $page_id); db::order('version_date', 'DESC'); $res = db::select(); $versions = array(); while ($row = mysql_fetch_assoc($res)) { $versions[$row['version_date']][$row['content_id']] = array('version_id' => $row['version_id'], 'content_id' => $row['content_id'], 'version_content' => $row['version_content']); } foreach ($versions as $k => $v) { s::roll('versions', array('date' => dt::date2print('%H:%i:%s %d.%m.%Y', $k), 'version_date' => $k, 'id' => md5($k))); foreach ($v as $d => $f) { $f['version_content'] = htmlspecialchars('{non}' . $f['version_content'] . '{/non}'); s::roll('versions_' . md5($k), $f); } } }
function _getPagesSelect($array, $parent = 0, $prefix = '-') { if (isset($array[$parent])) { foreach ($array[$parent] as $k => $v) { s::roll('page_select_tree', array('name' => ' ' . $prefix . ' ' . $v['page_title'], 'value' => $v['page_id'])); if (isset($array[$v['page_id']])) { self::_getPagesSelect($array, $v['page_id'], $prefix . $prefix); } } } }
function showEvents($block_id = false) { if (!$block_id) { $block_id = params::get('block_id'); } conf::parse('blocks', $block_id); $array = conf::get('blocks', 'events'); if (!$array) { buffer::setTmpl(); } foreach ($array as $v) { $arr = explode('::', $v); if (!isset($arr[1])) { buffer::setTmpl(); return false; } switch ($arr[3]) { case 'hide': s::roll('events', array('event_t' => $v, 'type' => $arr[3], 'mode' => $arr[0], 'name' => $arr[1], 'value' => $arr[2])); break; case 'show': s::roll('events', array('event_t' => $v, 'type' => $arr[3], 'mode' => $arr[0], 'name' => $arr[1], 'value' => $arr[2])); break; case 'replace': s::roll('events', array('event_t' => $v, 'type' => $arr[3], 'mode' => $arr[0], 'name' => $arr[1], 'value' => $arr[2], 'action' => '{!' . appBlocks::getBlockName($arr[4]) . '}')); break; case 'handler': s::roll('events', array('event_t' => $v, 'type' => $arr[3], 'mode' => $arr[0], 'name' => $arr[1], 'value' => $arr[2], 'action' => implode('::', array($arr[4], $arr[5], $arr[6])))); break; } } }
function view() { /* Block conf */ $block_conf = conf::parse('blocks'); $blocks = array(); db::table('blocks'); db::where('block_pub', 1); db::where('site_id', SITE_ID); $res = db::select('block_id', 'block_name', 'block_code', 'block_title'); while ($row = mysql_fetch_assoc($res)) { $blocks[$row['block_id']] = $row; } foreach ($blocks as $k => $row) { if ($block_conf) { /* Block pages */ $block_conf_pages_in = conf::get('blocks', 'in', $k); $block_conf_pages_out = conf::get('blocks', 'out', $k); if (!conf::testPages($block_conf_pages_out)) { if (in_array(PAGE_ID, $block_conf_pages_out)) { $row['block_code'] = false; continue; } } else { if (!conf::testPages($block_conf_pages_in)) { if (!in_array(PAGE_ID, $block_conf_pages_in)) { $row['block_code'] = false; continue; } } } /* Block events */ if (conf::get('blocks', 'events', $k)) { foreach (conf::get('blocks', 'events', $k) as $v) { $arr = explode('::', trim($v)); if (events::targetDetect($arr[0], $arr[1], $arr[2])) { if ($arr[3] == 'replace') { if (isset($blocks[$arr[4]])) { $row['block_code'] = $blocks[$arr[4]]['block_code']; } } else { if ($arr[3] == 'handler') { load::handler($arr[4], $arr[5], $arr[6]); } else { if ($arr[3] == 'hide') { $row['block_code'] = false; } } } } else { if ($arr[3] == 'show') { $row['block_code'] = false; } } } } /* Block handlers */ if (conf::get('blocks', 'methods', $k)) { foreach (conf::get('blocks', 'methods', $k) as $v) { $arr = explode('::', trim($v)); if (count($arr) == 3) { load::handler($arr[0], $arr[1], $arr[2]); } } } if ($row['block_code'] !== false) { s::set($row['block_name'], $row['block_code']); } else { s::set($row['block_name'], ''); } /* Block JIP */ if ($row['block_code'] !== false) { if (!empty($row['block_title'])) { $name = $row['block_title']; } else { $name = $row['block_name']; } s::roll('legenda_jip_blocks', array('path' => 'http://' . SITE . SYS_DIR . 'blocks/main/edit/' . $row['block_id'] . '/', 'name' => $name)); } } } }
function showEvents($menu_id = false) { if (!$menu_id) { $menu_id = params::get('menu_id'); } conf::parse('menus', $menu_id); $array = conf::get('menus', 'events'); if (!$array) { buffer::setTmpl(); } foreach ($array as $v) { $arr = explode('::', $v); if (!isset($arr[1])) { buffer::setTmpl(); return false; } switch ($arr[3]) { case 'hide': s::roll('events', array('event_t' => $v, 'type' => $arr[3], 'mode' => $arr[0], 'name' => $arr[1], 'value' => $arr[2])); break; case 'replace': s::roll('events', array('event_t' => $v, 'type' => $arr[3], 'mode' => $arr[0], 'name' => $arr[1], 'value' => $arr[2], 'action' => appMenus::getMenuName($arr[4]))); break; } } }
function sections() { $dir = IMAGES_ROOT . 'sections/'; $dir_path = IMAGES_PATH . 'sections/'; db::table('catalog_sections'); db::order('section_order'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $file = $dir . $a['section_id'] . '.jpg'; if (file_exists($file)) { $a['section_img'] = '<img src="' . $dir_path . $a['section_id'] . '.jpg' . '" />'; } s::roll('sections', $a); } }